Import backup from 2003-09-11

This commit is contained in:
Josh Holtrop 2003-09-11 22:00:00 -04:00
parent fdfeb94ae3
commit a40131b163
3 changed files with 26 additions and 23 deletions

1
io.asm
View File

@ -9,6 +9,7 @@
[global _writeCursorPosition]
[global _getCursorPosition]
[global _putc]
[global _puts]
[global _printf]
[global _console_scroll]
[global _console_cls]

View File

@ -36,11 +36,10 @@ void k_init()
mm_init();
enable_ints();
console_cls();
printf("Memory available to OS: %d MB", mm_totalmem/0x100000);
printf("Memory available to OS: %d MB\n (Bytes: %d)", mm_totalmem/0x100000, mm_totalmem);
for (;;)
{
printf("%d ", kbdWaitKey());
}
printf("%c ", kbdWaitKey());
/* pageblock *pb = first_pageblock;
for (;;)
{
@ -53,8 +52,9 @@ void k_init()
void isr(dword num)
{
if (num == 0x20)
switch(num)
{
case 0x20:
timer++;
(*(byte *)0xb8000)++;
switch(timer)
@ -82,10 +82,11 @@ void isr(dword num)
break;
}
eoi();
}
if (num == 0x21)
{
break;
case 0x21:
printf("------------------KEYBOARD ISR--------------------------\n");
isr_keyboard();
break;
}
}

View File

@ -3,14 +3,15 @@
// Modified: 09/09/03
//for HOS
#define KBD_BUFFER_LENGTH 64
byte kbdFlags = 0;
byte kbdAscii = 0;
byte kbdScan = 0;
dword kbdBuffer[32];
dword kbdBuffer[KBD_BUFFER_LENGTH];
byte kbdBufferStart = 0;
byte kbdBufferEnd = 0;
byte kbdBufferLen = 0;
byte kbdExt = 0;
byte kbdExt2 = 0;
byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA)
@ -29,6 +30,8 @@ void isr_keyboard()
outportb(0x61, inState|0x80);
outportb(0x61, inState);
printf("IRQ 1: %x\n", kbdScan);
if (kbdScan == 0xFA) //250 //ACKnowledge
{
if (ackReason == 0xED) //reset LEDs
@ -178,22 +181,15 @@ void isr_keyboard()
}
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
{
if ((kbdBufferStart-kbdBufferEnd) == 1) //no key slots available
{
eoi();
return;
}
else if ((kbdBufferStart == 0) & (kbdBufferEnd == 31)) //no key slots available
if (kbdBufferLen >= KBD_BUFFER_LENGTH) //no key slots available
{
eoi();
return;
}
else
{
kbdBuffer[kbdBufferEnd] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
kbdBufferEnd++;
if (kbdBufferEnd == 32)
kbdBufferEnd = 0;
kbdBuffer[(kbdBufferStart+kbdBufferLen)%KBD_BUFFER_LENGTH] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
kbdBufferLen++;
}
}
@ -214,11 +210,13 @@ inline byte switchCase(byte asciiCode)
dword kbdGetKey()
{
if (kbdBufferEnd == kbdBufferStart) //buffer empty
if (kbdBufferLen == 0) //buffer empty
return 0;
dword retVal = kbdBuffer[kbdBufferStart];
printf("S:%d\tE:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, retVal);
kbdBufferStart++;
if (kbdBufferStart == 32)
kbdBufferLen--;
if (kbdBufferStart == KBD_BUFFER_LENGTH)
kbdBufferStart = 0;
return retVal;
}
@ -230,9 +228,12 @@ dword kbdWaitKey()
{
retVal = kbdGetKey();
if (retVal != 0)
{
printf("S:%d\tE:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, retVal);
return retVal;
}
}
}
inline void kbd_resetLEDs()
{