Page 1 of 1

my code about handling the spurious irq (please help!!)

Posted: Thu Sep 03, 2020 9:25 pm
by ITchimp
I am adding the following code into the IRQ handler code after reading the OS dev PIC explanation page...
but after I check the isr register value (16 bit, 8 bits lower for master, 8 bits higher for slave) I got the value of
0x0001, the 8th bit is not set indicate it is a spurious irq... but the lowest bit is set to 1... what does it mean?
also can someone critique my code about handling the spurious irq??!!!!

Code: Select all

 if (r->isr_num == 0x27){
        outb(0x20,0xb);
        outb(0xa0,0xb);
        unsigned short isr = (inb(0xa0)<<8)| inb(0x20);
        print(" ISR ---> ");    
        print_hex(isr);put('\n');
        if ((isr&0x80)==0){
          print("spurious master irq return!!\n");
          return;
        }
    } 
    // spurious irq for slave
    if (r->isr_num == 0x2f){
         outb(0x20,0xb);
         outb(0xa0,0xb);
         unsigned short isr = (inb(0xa0)<<8)| inb(0x20);
        print(" ISR ---> ");    
        print_hex(isr);put('\n');
        if ((isr&0x8000)==0){
            print("spurious slave irq return!!\n");
            outb(0x20, 0x20); // acknowledge for the master
            return;
        }
    }
    

Re: my code about handling the spurious irq (please help!!)

Posted: Thu Sep 03, 2020 9:37 pm
by nullplan
ITchimp wrote:but the lowest bit is set to 1... what does it mean?
That IRQ0 is pending? In general, reading out both ISRs should not be necessary. You only need to read the master's ISR in the handler for IRQ7, and only the slave's ISR in the handler for IRQ15. No other IRQ has even a chance of being spurious.