Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard interrupts

I am studying low-level device driver stuff. I am confused between interrupts and IRQ. A sample driver code that hooks keyboard suggests keyboard interrupt is 0x31 but my book on microprocessor says it is 0x09. On opening 'Device Manager->Keyboards->Resources', it shows IRQ is 1. Can anyone clarify this?

Thanks, Sanjeev

like image 281
Sanjeev Avatar asked Sep 09 '26 22:09

Sanjeev


1 Answers

It's like this. In your computer you have a unit called the (A)PIC. This unit takes input from some of your perpipheral devices, like the PS2 keyboard, and raises an interrupt on the CPU. In a modern system there are two APICs. One is called the primary and the other one is called the slave and each hold 8 IRQ lines. When you press a key on the keyboard the APIC gets a signal on line 1 (IRQ 1) which then causes an interrupt to occur on the CPU.

The APIC can be programmed so even if it recieves a signal on line 1 it will not raise interrupt 9 on the CPU (even though weirdly this actually is the default if you do not program it) because that would conflict with some of the CPUs internal interrupts so you usually program it to go somewhere else. In your case it seems like it translates it to interrupt 0x31 which sounds like it could be correct (it adds IRQ + 0x30).

I strongly don't believe it is mapped to interrupt 9 because that would conflict with the Double Fault exception interrupt for the processor, the book probably just mention the default setting.

like image 137
origamicoder Avatar answered Sep 12 '26 20:09

origamicoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!