Import backup from 2003-09-23

This commit is contained in:
Josh Holtrop 2003-09-23 22:00:00 -04:00
parent 06d7cbef47
commit c3309d4e5d
4 changed files with 20 additions and 33 deletions

4
io.asm
View File

@ -25,6 +25,7 @@ _writeCursorPosition:
push ebp push ebp
mov ebp, esp mov ebp, esp
push eax
push ebx push ebx
push edx push edx
@ -49,6 +50,7 @@ _writeCursorPosition:
pop edx pop edx
pop ebx pop ebx
pop eax
pop ebp pop ebp
ret ret
@ -175,7 +177,7 @@ _printf:
push ebp push ebp
mov ebp, esp mov ebp, esp
pusha pusha
mov ebx, [ebp+8] ;ebx = in format string mov ebx, [ebp+8] ;ebx = position in format string
mov esi, ebp mov esi, ebp
add esi, 12 ;esi = to next variable arg add esi, 12 ;esi = to next variable arg
xor ecx, ecx ;ecx used if we encounter a '%' xor ecx, ecx ;ecx used if we encounter a '%'

6
io.h
View File

@ -3,9 +3,9 @@
#ifndef __HIO_H__ #ifndef __HIO_H__
#define __HIO_H__ __HIO_H__ #define __HIO_H__ __HIO_H__
void writeCursorPosition(word pos); void writeCursorPosition(dword pos);
word getCursorPosition(); dword getCursorPosition();
int putc(byte chr); int putc(dword chr);
int printf(char *fmt, ...); int printf(char *fmt, ...);
int puts(char *str); int puts(char *str);
int putDec(int number); int putDec(int number);

View File

@ -38,26 +38,12 @@ void k_init()
mm_init(); mm_init();
enable_ints(); enable_ints();
console_cls(); console_cls();
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem); //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()
{
dword key = 0; dword key = 0;
for (;;) for (;;)
{ {
key = kbdWaitKey(); key = kbdWaitKey();
// printf("Key %c ", key); putc(key);
putc('!');
} }
} }
@ -95,7 +81,6 @@ void isr(dword num)
eoi(); eoi();
break; break;
case 0x21: case 0x21:
printf("------------------KEYBOARD ISR--------------------------\n");
isr_keyboard(); isr_keyboard();
break; break;
} }

View File

@ -10,8 +10,8 @@ byte kbdAscii = 0;
byte kbdScan = 0; byte kbdScan = 0;
dword kbdBuffer[KBD_BUFFER_LENGTH]; dword kbdBuffer[KBD_BUFFER_LENGTH];
byte kbdBufferStart = 0; int kbdBufferStart = 0;
byte kbdBufferLen = 0; int kbdBufferLen = 0;
byte kbdExt = 0; byte kbdExt = 0;
byte kbdExt2 = 0; byte kbdExt2 = 0;
byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA) byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA)
@ -210,30 +210,30 @@ inline byte switchCase(byte asciiCode)
dword kbdGetKey() dword kbdGetKey()
{ {
return 0;
if (kbdBufferLen == 0) //buffer empty if (kbdBufferLen == 0) //buffer empty
return 0; return 0;
dword retVal = kbdBuffer[kbdBufferStart]; dword retVal = kbdBuffer[kbdBufferStart];
kbdBufferStart++; kbdBufferStart++;
kbdBufferLen--; kbdBufferLen--;
if (kbdBufferStart == KBD_BUFFER_LENGTH) if (kbdBufferStart >= KBD_BUFFER_LENGTH)
kbdBufferStart = 0; kbdBufferStart = 0;
putDec(retVal);
return retVal; return retVal;
} }
dword kbdWaitKey() dword kbdWaitKey()
{ {
dword retVal = 0;
for (;;) for (;;)
{ {
retVal = kbdGetKey(); if (kbdBufferLen != 0) //buffer empty
if (retVal) break;
{ }
dword retVal = kbdBuffer[kbdBufferStart];
kbdBufferStart++;
kbdBufferLen--;
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
kbdBufferStart = 0;
return retVal; return retVal;
} }
}
}
inline void kbd_resetLEDs() inline void kbd_resetLEDs()
{ {