My interrupts won't fire more than once

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Mikumiku747
Member
Member
Posts: 64
Joined: Thu Apr 16, 2015 7:37 am

My interrupts won't fire more than once

Post by Mikumiku747 »

Thanks to previous help on the forum, I managed to get basic interrupts working today, almost. I say almost, because I can get my ISR to run when I press any key on the keyboard, but then, it won't fire any more. I decided to open up the debugger for virtual-box, and get info about the PICs, to see if anything was wrong.

This is the part where I'm stuck, as the display of information about the PIC mostly makes sense, except for one field. I'll include a picture of an info dump of the pics, once before the first key-press, and once after the first key-press.

Image

As you can see, the two dumps are almost identical, except for the LIRR register in the master PIC. It goes from 1, to 3, which means that something happened with bit 1 (for interrupt line 1, the keyboard). However, I don't know what the LIRR is. I know the IRR is for which lines are requesting interrupts, which makes sense (bit 0, or line 0, is that clock thingy that ticks 18 times a second, so I'd expect it to be on), but is this LIRR the same or different? If it is the same, does this mean there is a problem with the way I sent EOI?

I can provide my code if needed, but I'm hoping that I've already provided enough info for somebody to suggest a solution or test I could run to find the problem. If you have any solutions, or even things that you need me to test, let me know, I would greatly appreciate it.

Thanks for providing such a helpful forum,
Mikumiku747
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: My interrupts won't fire more than once

Post by Kevin »

If you don't get a second interrupt, generally you didn't handle the first one correctly/completely. In the case of the keyboard controller, you have to read out the buffer before a second interrupt will be generated. And don't forget the EOI, of course.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: My interrupts won't fire more than once

Post by Combuster »

LIRR is documented as "Last IRR", or rather, it contains the electrical status of the IRQ lines. For legacy, an IRQ is only generated when the IRQ line goes high, not when it is high.

Hence, when IRR is clear while LIRR is not, the PIC thinks a previous interrupt was handled, but the device didn't. For this you'll actually want to read from the keyboard controller rather than merely printing a message on a keypress
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Mikumiku747
Member
Member
Posts: 64
Joined: Thu Apr 16, 2015 7:37 am

Re: My interrupts won't fire more than once

Post by Mikumiku747 »

Ok, thanks for the tip :wink: , I had assumed that the keyboard just sent an interrupt every time a key was pressed, but not so. Also, is there anything else I should take into account? Thanks for the explanation of LIRR as well.

Thanks for the help,
Mikumiku747
Post Reply