From c3309d4e5d72ea16edee25ad30cb3b3aa96ee2f9 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 23 Sep 2003 22:00:00 -0400 Subject: [PATCH] Import backup from 2003-09-23 --- io.asm | 4 +++- io.h | 6 +++--- kernel.c | 19 ++----------------- keyboard.c | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/io.asm b/io.asm index 5369dc1..d828bb0 100644 --- a/io.asm +++ b/io.asm @@ -25,6 +25,7 @@ _writeCursorPosition: push ebp mov ebp, esp + push eax push ebx push edx @@ -49,6 +50,7 @@ _writeCursorPosition: pop edx pop ebx + pop eax pop ebp ret @@ -175,7 +177,7 @@ _printf: push ebp mov ebp, esp pusha - mov ebx, [ebp+8] ;ebx = in format string + mov ebx, [ebp+8] ;ebx = position in format string mov esi, ebp add esi, 12 ;esi = to next variable arg xor ecx, ecx ;ecx used if we encounter a '%' diff --git a/io.h b/io.h index 9a433d3..3a7b538 100644 --- a/io.h +++ b/io.h @@ -3,9 +3,9 @@ #ifndef __HIO_H__ #define __HIO_H__ __HIO_H__ -void writeCursorPosition(word pos); -word getCursorPosition(); -int putc(byte chr); +void writeCursorPosition(dword pos); +dword getCursorPosition(); +int putc(dword chr); int printf(char *fmt, ...); int puts(char *str); int putDec(int number); diff --git a/kernel.c b/kernel.c index f534116..9f8bb20 100644 --- a/kernel.c +++ b/kernel.c @@ -38,26 +38,12 @@ void k_init() mm_init(); enable_ints(); console_cls(); - printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem); - type(); -/* pageblock *pb = first_pageblock; - for (;;) - { - if (pb->flags == MM_PB_NP) - break; - printf("\nBase: 0x%x; Limit: 0x%x; Flags: 0x%x, Link: 0x%x", pb->base, pb->length, pb->flags, pb->link); - pb = (pageblock *) pb->link; - } */ -} - -void type() -{ + //printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem); dword key = 0; for (;;) { key = kbdWaitKey(); -// printf("Key %c ", key); - putc('!'); + putc(key); } } @@ -95,7 +81,6 @@ void isr(dword num) eoi(); break; case 0x21: - printf("------------------KEYBOARD ISR--------------------------\n"); isr_keyboard(); break; } diff --git a/keyboard.c b/keyboard.c index e9446e8..5170a2f 100644 --- a/keyboard.c +++ b/keyboard.c @@ -10,8 +10,8 @@ byte kbdAscii = 0; byte kbdScan = 0; dword kbdBuffer[KBD_BUFFER_LENGTH]; -byte kbdBufferStart = 0; -byte kbdBufferLen = 0; +int kbdBufferStart = 0; +int kbdBufferLen = 0; byte kbdExt = 0; byte kbdExt2 = 0; byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA) @@ -210,29 +210,29 @@ inline byte switchCase(byte asciiCode) dword kbdGetKey() { - return 0; if (kbdBufferLen == 0) //buffer empty return 0; dword retVal = kbdBuffer[kbdBufferStart]; kbdBufferStart++; kbdBufferLen--; - if (kbdBufferStart == KBD_BUFFER_LENGTH) + if (kbdBufferStart >= KBD_BUFFER_LENGTH) kbdBufferStart = 0; - putDec(retVal); return retVal; } dword kbdWaitKey() { - dword retVal = 0; for (;;) { - retVal = kbdGetKey(); - if (retVal) - { - return retVal; - } - } + if (kbdBufferLen != 0) //buffer empty + break; + } + dword retVal = kbdBuffer[kbdBufferStart]; + kbdBufferStart++; + kbdBufferLen--; + if (kbdBufferStart >= KBD_BUFFER_LENGTH) + kbdBufferStart = 0; + return retVal; } inline void kbd_resetLEDs()