IRQs

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.
jrfritz

IRQs

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:IRQs

Post 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.
-- Stu --
Ozguxxx

Re:IRQs

Post by Ozguxxx »

Can't we just disable the IRQ's that we do not want to handle?
jrfritz

Re:IRQs

Post 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?
jrfritz

Re:IRQs

Post by jrfritz »

I found some stuff in DFs code...but I would still like to know how to disable a IRQ.
Whatever5k

Re:IRQs

Post 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
                   */
}
jrfritz

Re:IRQs

Post by jrfritz »

Could I see the ocw1 and PIC1/PIC2 defs?
jrfritz

Re:IRQs

Post by jrfritz »

Can I disable IRQs using that code before init-ing my IDT and before sti()ing?
Unexpected

Re:IRQs

Post by Unexpected »

[attachment deleted by admin]
elias

Re:IRQs

Post by elias »

whats teh difference between an IRQ and an ISR?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:IRQs

Post 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
-- Stu --
Tim

Re:IRQs

Post 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)
elias

Re:IRQs

Post 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.
DarylD

Re:IRQs

Post 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.
jrfritz

Re:IRQs

Post 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?
Post Reply