Import backup from 2003-09-11
This commit is contained in:
parent
fdfeb94ae3
commit
a40131b163
3
io.asm
3
io.asm
@ -9,6 +9,7 @@
|
|||||||
[global _writeCursorPosition]
|
[global _writeCursorPosition]
|
||||||
[global _getCursorPosition]
|
[global _getCursorPosition]
|
||||||
[global _putc]
|
[global _putc]
|
||||||
|
[global _puts]
|
||||||
[global _printf]
|
[global _printf]
|
||||||
[global _console_scroll]
|
[global _console_scroll]
|
||||||
[global _console_cls]
|
[global _console_cls]
|
||||||
@ -242,7 +243,7 @@ printf_string:
|
|||||||
call _puts
|
call _puts
|
||||||
add esp, 4
|
add esp, 4
|
||||||
jmp printf_special_done
|
jmp printf_special_done
|
||||||
|
|
||||||
printf_char:
|
printf_char:
|
||||||
mov eax, [esi]
|
mov eax, [esi]
|
||||||
push eax
|
push eax
|
||||||
|
17
kernel.c
17
kernel.c
@ -36,11 +36,10 @@ void k_init()
|
|||||||
mm_init();
|
mm_init();
|
||||||
enable_ints();
|
enable_ints();
|
||||||
console_cls();
|
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 (;;)
|
for (;;)
|
||||||
{
|
printf("%c ", kbdWaitKey());
|
||||||
printf("%d ", kbdWaitKey());
|
|
||||||
}
|
|
||||||
/* pageblock *pb = first_pageblock;
|
/* pageblock *pb = first_pageblock;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -53,8 +52,9 @@ void k_init()
|
|||||||
|
|
||||||
void isr(dword num)
|
void isr(dword num)
|
||||||
{
|
{
|
||||||
if (num == 0x20)
|
switch(num)
|
||||||
{
|
{
|
||||||
|
case 0x20:
|
||||||
timer++;
|
timer++;
|
||||||
(*(byte *)0xb8000)++;
|
(*(byte *)0xb8000)++;
|
||||||
switch(timer)
|
switch(timer)
|
||||||
@ -82,10 +82,11 @@ void isr(dword num)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
eoi();
|
eoi();
|
||||||
}
|
break;
|
||||||
if (num == 0x21)
|
case 0x21:
|
||||||
{
|
printf("------------------KEYBOARD ISR--------------------------\n");
|
||||||
isr_keyboard();
|
isr_keyboard();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
keyboard.c
29
keyboard.c
@ -3,14 +3,15 @@
|
|||||||
// Modified: 09/09/03
|
// Modified: 09/09/03
|
||||||
//for HOS
|
//for HOS
|
||||||
|
|
||||||
|
#define KBD_BUFFER_LENGTH 64
|
||||||
|
|
||||||
byte kbdFlags = 0;
|
byte kbdFlags = 0;
|
||||||
byte kbdAscii = 0;
|
byte kbdAscii = 0;
|
||||||
byte kbdScan = 0;
|
byte kbdScan = 0;
|
||||||
|
|
||||||
dword kbdBuffer[32];
|
dword kbdBuffer[KBD_BUFFER_LENGTH];
|
||||||
byte kbdBufferStart = 0;
|
byte kbdBufferStart = 0;
|
||||||
byte kbdBufferEnd = 0;
|
byte 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)
|
||||||
@ -28,6 +29,8 @@ void isr_keyboard()
|
|||||||
byte inState = inportb(0x61);
|
byte inState = inportb(0x61);
|
||||||
outportb(0x61, inState|0x80);
|
outportb(0x61, inState|0x80);
|
||||||
outportb(0x61, inState);
|
outportb(0x61, inState);
|
||||||
|
|
||||||
|
printf("IRQ 1: %x\n", kbdScan);
|
||||||
|
|
||||||
if (kbdScan == 0xFA) //250 //ACKnowledge
|
if (kbdScan == 0xFA) //250 //ACKnowledge
|
||||||
{
|
{
|
||||||
@ -178,22 +181,15 @@ void isr_keyboard()
|
|||||||
}
|
}
|
||||||
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
|
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
|
||||||
{
|
{
|
||||||
if ((kbdBufferStart-kbdBufferEnd) == 1) //no key slots available
|
if (kbdBufferLen >= KBD_BUFFER_LENGTH) //no key slots available
|
||||||
{
|
|
||||||
eoi();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ((kbdBufferStart == 0) & (kbdBufferEnd == 31)) //no key slots available
|
|
||||||
{
|
{
|
||||||
eoi();
|
eoi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kbdBuffer[kbdBufferEnd] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
kbdBuffer[(kbdBufferStart+kbdBufferLen)%KBD_BUFFER_LENGTH] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
||||||
kbdBufferEnd++;
|
kbdBufferLen++;
|
||||||
if (kbdBufferEnd == 32)
|
|
||||||
kbdBufferEnd = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,11 +210,13 @@ inline byte switchCase(byte asciiCode)
|
|||||||
|
|
||||||
dword kbdGetKey()
|
dword kbdGetKey()
|
||||||
{
|
{
|
||||||
if (kbdBufferEnd == kbdBufferStart) //buffer empty
|
if (kbdBufferLen == 0) //buffer empty
|
||||||
return 0;
|
return 0;
|
||||||
dword retVal = kbdBuffer[kbdBufferStart];
|
dword retVal = kbdBuffer[kbdBufferStart];
|
||||||
|
printf("S:%d\tE:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, retVal);
|
||||||
kbdBufferStart++;
|
kbdBufferStart++;
|
||||||
if (kbdBufferStart == 32)
|
kbdBufferLen--;
|
||||||
|
if (kbdBufferStart == KBD_BUFFER_LENGTH)
|
||||||
kbdBufferStart = 0;
|
kbdBufferStart = 0;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@ -230,7 +228,10 @@ dword kbdWaitKey()
|
|||||||
{
|
{
|
||||||
retVal = kbdGetKey();
|
retVal = kbdGetKey();
|
||||||
if (retVal != 0)
|
if (retVal != 0)
|
||||||
|
{
|
||||||
|
printf("S:%d\tE:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user