From 2cd08dee7024afb7b8ae9b3a7fe2ae160d0f80e7 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 11 Feb 2004 22:00:00 -0500 Subject: [PATCH] Import backup from 2004-02-11 --- Functions.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ functions.h | 6 +++++ idt.inc | 6 +++++ kernel.c | 3 +-- stage2.asm | 2 +- 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/Functions.c b/Functions.c index 470f97b..8359550 100644 --- a/Functions.c +++ b/Functions.c @@ -45,6 +45,37 @@ char *strcat(char *dest, char *src) } +//Splits a string into multiple strings by turning all characters +// equal to delim into null values (string termination character) +//Returns the number of strings after the split, 1 if no delim chars +int string_split(char *str, char delim) +{ + if (strlen(str) < 1) + return 0; //empty string + int count = 1; + for (; *str; str++) + { + if (*str == delim) + { + count++; + *str = 0; + } + } + return count; +} + + +//Advances a char pointer to the byte after the current string's +// null-terminating character +//Useful after calling string_split() +//Returns a pointer to the following string +char *string_advance(char *str) +{ + for (; *str; str++); + return str+1; +} + + //converts a binary-coded-decimal byte to its decimal equivalent inline byte bcd2byte(byte bcd) { @@ -268,6 +299,39 @@ void rtc_setHour(byte hour) } +//Returns the cmos type of floppy disk drive 0 (0 = not present) +byte cmos_getfd0() +{ + outportb(0x70, 0x10); + return (inportb(0x71) >> 4); +} + + +//Returns the cmos type of floppy disk drive 1 (0 = not present) +byte cmos_getfd1() +{ + outportb(0x70, 0x10); + return (inportb(0x71) & 0x0F); +} + + +//Returns the cmos type of hard disk drive 0 (0 = not present) +byte cmos_gethd0() +{ + outportb(0x70, 0x12); + return (inportb(0x71) >> 4); +} + + +//Returns the cmos type of hard disk drive 1 (0 = not present) +byte cmos_gethd1() +{ + outportb(0x70, 0x12); + return (inportb(0x71) & 0x0F); +} + + + diff --git a/functions.h b/functions.h index 497fe8a..f979a58 100644 --- a/functions.h +++ b/functions.h @@ -22,6 +22,8 @@ inline void eoi2(); inline dword kernel_size(); inline void init_timer(); char *strcat(char *dest, char *src); +int string_split(char *str, char delim); +char *string_advance(char *str); void rtrim(char *str); char *ucase(char *str); char *lcase(char *str); @@ -39,6 +41,10 @@ void rtc_setYear(byte year); void rtc_setSecond(byte second); void rtc_setMinute(byte minute); void rtc_setHour(byte hour); +byte cmos_getfd0(); +byte cmos_getfd1(); +byte cmos_gethd0(); +byte cmos_gethd1(); diff --git a/idt.inc b/idt.inc index b3b6d1f..03067d5 100644 --- a/idt.inc +++ b/idt.inc @@ -94,10 +94,16 @@ isr_syscall: push ds push es +sc1: + cmp eax, 1 ;syscall 1 - putc + jnz sc2 push ebx call _putc add esp, 4 + jmp scdone +sc2: +scdone: pop es pop ds popa diff --git a/kernel.c b/kernel.c index 01a783a..e18ccb9 100644 --- a/kernel.c +++ b/kernel.c @@ -75,7 +75,7 @@ void k_init() { int p = video_mode.XResolution*video_mode.YResolution-1; for (; p >= 0; p--) - video_psetp(p, 0x00000044); + video_psetp(p, 0x00000077); video_drawConsole(); } @@ -85,7 +85,6 @@ void k_init() printf("%d/%d/%d\t%d:%d:%d\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond()); printf("Root Directory: %s/\n", rootDevice->id); - /* int a; byte *addr = 0; for (a = 0; a < 5; a++) diff --git a/stage2.asm b/stage2.asm index 753c55f..88096a0 100644 --- a/stage2.asm +++ b/stage2.asm @@ -853,7 +853,7 @@ puthex2_goon2: ;------------------------------------------------------ txt_welcome: db " Welcome to HOS v", VERSION, "! ", 0 txt_rd1: db "1. Do not load an initial ram disk", 0 -txt_rd2: db "2. Load initial ram disk from floppy", 0 +txt_rd2: db "2. Load initial ram disk from boot media", 0 txt_input: db "Enter your selection: ", 0 txt_vesa: db "VESA version: ", 0 txt_vesaerror: db "VESA function call error! Halting system!", 0