Page 1 of 1
how to write a keyboard ISR
Posted: Sun Aug 18, 2002 11:00 pm
by chendsh
I want to write a keyboard interrupt handler and wonder if there is
a sample and something like that. I know the first 32 entries in IDT
are reserved for CPU exceptions and the keyboard interrupt is from IRQ1.
which must have a handler for INT9. I am confused and do not know how to
arrange the IDT table.
Is there anyone who can help me with the hardware interrupts?
Would like to know this 2
Posted: Mon Aug 19, 2002 11:00 pm
by DaNo
I dont know how to do this either...does anybody??
RE:how to write a keyboard ISR
Posted: Mon Aug 19, 2002 11:00 pm
by carbonBased
Well, ideally you want to remap your IRQs to above the processor exceptions... this means mapping them to 0x20 (32d) and above, therefore the keyboard int would be 0x21 (0x21 would be the timer).
Have you written an ISR before? A basic keyboard ISR isn't much more than the skeleton code:
ISR:
; save registers used
push eax
; put isr code here
in al, 0x60
; save the scan code
mov [keyScanCode], al
; acknowledge interrupt
mov al, 0x20
out al, 0x20
; restore registers
pop eax
; and return
iret
This is just off the top of my head, though. I'm pretty sure the keyboard scan code read port is 0x60 (?).
Later on you'll want to convert the scancode to something more relavent to your OS, such as ascii, or unicode. You can use look-up tables for this purpose.
Honestly, though, the keyboard driver is probably the _easiest_ drive you'll ever write. Just download an OS's source code and take a look at the keyb driver for a full code implementation and you'll agree; it's quite simple.
Jeff
RE:how to write a keyboard ISR (oops)
Posted: Mon Aug 19, 2002 11:00 pm
by carbonBased
0x20 is the timer, of course, in the above example.
Jeff
RE:how to write a keyboard ISR
Posted: Mon Aug 19, 2002 11:00 pm
by crg
RE:how to write a keyboard ISR (oops)
Posted: Mon Aug 19, 2002 11:00 pm
by chendsh
thank you for your kindness.