Rework default hwirq handler so there is no confusion on which pic to eoi.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 20 Dec 2008 18:10:00 +0000 (13:10 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 20 Dec 2008 18:10:00 +0000 (13:10 -0500)
Introduce two default handlers (hwpic1 and hwpic2) and register them
    accordingly.  This ensures the proper pic always gets an eoi.
Also, use DEBUG_ISR_hwpic1/2 to determine debugging level.

src/config.h
src/pic.c
src/post.c
src/romlayout.S

index 7a875df79524c6dec8b667aef6ef9e09270cb314..35c7e3ecb43b2334f00c508029a4f39dba06bf75 100644 (file)
 #define DEBUG_ISR_74 9
 #define DEBUG_ISR_75 1
 #define DEBUG_ISR_76 10
-#define DEBUG_ISR_hwirq 30
+#define DEBUG_ISR_hwpic1 1
+#define DEBUG_ISR_hwpic2 1
 
 #endif // config.h
index e350d280f8cce132fe33fffb027487a29a66ad89..7ffdcb4dbe5fc0ac8c3d467972c6ca97817833f7 100644 (file)
--- a/src/pic.c
+++ b/src/pic.c
@@ -32,25 +32,22 @@ pic_setup()
 
 // Handler for otherwise unused hardware irqs.
 void VISIBLE16
-handle_hwirq(struct bregs *regs)
+handle_hwpic1(struct bregs *regs)
 {
-    debug_isr(DEBUG_ISR_hwirq);
-
-    u8 isr1 = get_pic1_isr();
-    if (! isr1) {
-        dprintf(1, "Got hwirq with no ISR\n");
-        return;
-    }
+    u8 isr = get_pic1_isr();
+    dprintf(DEBUG_ISR_hwpic1, "Got noisy pic1 irq %x\n", isr);
+    isr &= ~PIC1_IRQ2; // don't ever mask the cascaded irq
+    if (isr)
+        mask_pic1(isr);
+    eoi_pic1();
+}
 
-    u8 isr2 = get_pic2_isr();
-    u16 isr = isr2<<8 | isr1;
-    dprintf(1, "Masking noisy irq %x\n", isr);
-    if (isr2) {
-        mask_pic2(isr2);
-        eoi_pic2();
-    } else {
-        if (! (isr1 & PIC1_IRQ2)) // don't ever mask the cascaded irq
-            mask_pic1(isr1);
-        eoi_pic1();
-    }
+void VISIBLE16
+handle_hwpic2(struct bregs *regs)
+{
+    u8 isr = get_pic2_isr();
+    dprintf(DEBUG_ISR_hwpic2, "Got noisy pic2 irq %x\n", isr);
+    if (isr)
+        mask_pic2(isr);
+    eoi_pic2();
 }
index 77c77977389c8708e0af3f948d7f04b0b4889c08..b286826e81d62fb05eec812a24728bf8f461456c 100644 (file)
@@ -48,9 +48,9 @@ init_bda()
 
     // Initialize all hw vectors to a default hw handler.
     for (i=0x08; i<=0x0f; i++)
-        set_irq(i, entry_hwirq);
+        set_irq(i, entry_hwpic1);
     for (i=0x70; i<=0x77; i++)
-        set_irq(i, entry_hwirq);
+        set_irq(i, entry_hwpic2);
 
     // Initialize software handlers.
     set_irq(0x10, entry_10);
index 1391a8117dc1450b2a811ef58613c429067b41ae..52449b5aeaa0c3c4545b351d2f4f71ab8ddcf1a4 100644 (file)
@@ -580,7 +580,8 @@ entry_11_official:
         IRQ_ENTRY 70
         IRQ_ENTRY 74
         IRQ_ENTRY 75
-        IRQ_ENTRY hwirq
+        IRQ_ENTRY hwpic1
+        IRQ_ENTRY hwpic2
 
         // int 18/19 are special - they reset the stack and do not return.
 entry_19: