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

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
ITchimp
Member
Member
Posts: 134
Joined: Sat Aug 18, 2018 8:44 pm

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

Post 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;
        }
    }
    
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

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

Post 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.
Carpe diem!
Post Reply