Page 1 of 2

IRQs

Posted: Wed Dec 18, 2002 6:58 pm
by jrfritz
How do I use all the IRQs? Each one needs different stuff like 1 is different than 0. So, is there code that shows me now to use all the IRQs? I just want to use IRQs 0 and 1 but I get a GPF if I don't define the rest of the IRQs.

Re:IRQs

Posted: Thu Dec 19, 2002 2:10 am
by df
all you need to do is create dead handlers for all 16 of them, and change the handlers for the ones you need.

Re:IRQs

Posted: Thu Dec 19, 2002 5:12 am
by Ozguxxx
Can't we just disable the IRQ's that we do not want to handle?

Re:IRQs

Posted: Thu Dec 19, 2002 11:06 am
by jrfritz
Here's what I need help with:

I need to know what I need to send to the PIC in interrupts 8-15 and 0-7. Like in 0-7 you have outportb( 0x20, 0x20 ); but what do I put in 8-15?

And how do I disable all IRQs except 0 and 1?

Re:IRQs

Posted: Thu Dec 19, 2002 11:24 am
by jrfritz
I found some stuff in DFs code...but I would still like to know how to disable a IRQ.

Re:IRQs

Posted: Thu Dec 19, 2002 11:26 am
by Whatever5k
Here's some code from my operating system "Giggle":

Code: Select all

/* enable_irq()
 * sends command to PIC to enable an IRQ
 */
void enable_irq(int irq)
{
   ocw1 &= ~(1 << irq);   /* enable propriate bit with shifting to left
               invert the thing to enable the interrupt
               use AND operation to leave the other bits
               as they are
             */
   if (irq < 8)
      outb(PIC1 + 1, ocw1&0xFF);   /* AND with 0xFF to clear the high 8 
                       bits because we send to PIC1
                   */
   else
      outb(PIC2 + 1, ocw1 >> 8);   /* move high 8 bits to low 8 bits
                     since we send to PIC2
                   */
}

/* disable_irq()
 * sends a command to PIC to disable an IRQ
 */
void disable_irq(int irq)
{
   ocw1 |= (1 << irq);   /* shift left to disable the propriate bit
               OR to not change the mask
             */

   if (irq < 8)
      outb(PIC1 + 1, ocw1&0xFF);   /* AND with 0xFF to clear the
                     high 8 bits since we send to PIC1
                   */
   else
      outb(PIC2 + 1, ocw1 >> 8);   /* move high 8 bits to low 8 bits since
                     we send to PIC2
                   */
}

Re:IRQs

Posted: Thu Dec 19, 2002 11:33 am
by jrfritz
Could I see the ocw1 and PIC1/PIC2 defs?

Re:IRQs

Posted: Thu Dec 19, 2002 11:45 am
by jrfritz
Can I disable IRQs using that code before init-ing my IDT and before sti()ing?

Re:IRQs

Posted: Thu Dec 19, 2002 12:55 pm
by Unexpected
[attachment deleted by admin]

Re:IRQs

Posted: Thu Dec 19, 2002 5:15 pm
by elias
whats teh difference between an IRQ and an ISR?

Re:IRQs

Posted: Fri Dec 20, 2002 2:49 am
by df
an IRQ is a hardware triggered ISR.
basically is software fired interrupt routine, irq is hardware triggered interrupt routine.

there is 16 IRQ's, the top 8 are cascaded through one of the bottom 8.. i forget which. there is info int he faq on this

Re:IRQs

Posted: Fri Dec 20, 2002 7:02 am
by Tim
Hmm, what definition are we using for ISR here?

IMO:
IRQ = Interrupt request (hardware signal to trigger an interrupt on the CPU)
ISR = Interrupt service routine (piece of code that you write to handle an interrupt)

Re:IRQs

Posted: Fri Dec 20, 2002 7:08 am
by elias
ok. so then what should be an IRQ? all hardware devices, like floppies and hard drives? but i knwo that both also have ISR's.

Re:IRQs

Posted: Fri Dec 20, 2002 7:12 am
by DarylD
As Tim was saying, an ISR is the actual code that handles interrupts.

IRQ's are the actual hardware triggers themselves. An interrupt is simply a mechanism whereby a piece of hardware can notify the OS that an operation has completed, for example a disk transfer or communications request.

Don't get confused with interrupts that are used for system calls, they are similar but are not generated for hardware.

Re:IRQs

Posted: Sat Dec 21, 2002 9:13 pm
by jrfritz
Well...I get this error...what does it mean?

Message: iret: AR byte indicated non code segment

(Bochs error)

What does that mean?