Hi, I need to know a way on how to enable IRQ, I looked at http://www.osdev.org/osfaq2/index.php/S ... eFunctions and found this code
static __inline__
void irqUnlock(int no)
{
/* Val, Port */
if (no>7) outb(0x20,0xa0);
outb(0x20,0x20);
}
^^ i passed it number 9 and it didn't work... tho im sure I passed it the wrong info.
help ?
how to enable IRQ ?
- ManOfSteel
- Member
- Posts: 60
- Joined: Tue Feb 01, 2005 12:00 am
Hello,
this code has nothing to do with enabling an IRQ line. This is just the code that you should put at the end of every IRQ handler (keyboard, PIT, RTC, FDC, etc). All it does is to send an EOI (end of interrupt) signal thus re-allowing the hardware to trigger CPU interruptions.
To enable an IRQ line, you first have to set up the 8259 PIC master and slave. You should be able to find some code for that out there.
Now, if you have already done that, then, you can enable IRQ lines by clearing the right bits on the 0x21 port for master and port 0xa1 for slave (and set them to disable the IRQ lines).
For instance, to enable keyboard which is second in master you will send 11111101 in binary to master port 0x21. If you want to enable anything on the slave (PS2 mouse for example) you will have to enable cascading first (third master line) by sending 11111011 in binary to master port 0x21 (cascading enabled) and 11101111 (IRQ12 -> PS2 mouse) to slave port 0xa1.
Writing a routine to do that is straightforward: you first check if the value passed by the user is 8 or more. If it's not then you get the value of port 0x21, clear the right bit and send the new value back to port 0x21. If it is, you just do the same but with port 0xa1 instead.
this code has nothing to do with enabling an IRQ line. This is just the code that you should put at the end of every IRQ handler (keyboard, PIT, RTC, FDC, etc). All it does is to send an EOI (end of interrupt) signal thus re-allowing the hardware to trigger CPU interruptions.
To enable an IRQ line, you first have to set up the 8259 PIC master and slave. You should be able to find some code for that out there.
Now, if you have already done that, then, you can enable IRQ lines by clearing the right bits on the 0x21 port for master and port 0xa1 for slave (and set them to disable the IRQ lines).
For instance, to enable keyboard which is second in master you will send 11111101 in binary to master port 0x21. If you want to enable anything on the slave (PS2 mouse for example) you will have to enable cascading first (third master line) by sending 11111011 in binary to master port 0x21 (cascading enabled) and 11101111 (IRQ12 -> PS2 mouse) to slave port 0xa1.
Writing a routine to do that is straightforward: you first check if the value passed by the user is 8 or more. If it's not then you get the value of port 0x21, clear the right bit and send the new value back to port 0x21. If it is, you just do the same but with port 0xa1 instead.