i386/ioapic_abi: Augment intr_{setup,teardown} w/ assertions
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 18 Dec 2011 12:09:31 +0000 (20:09 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 18 Dec 2011 12:09:31 +0000 (20:09 +0800)
This merges 88100cf6c15096c1eb0776d2a8bd9dcf04d19095

sys/platform/pc32/apic/ioapic_abi.c

index 7c22c37..fc9bbd8 100644 (file)
@@ -601,13 +601,26 @@ ioapic_abi_stabilize(void)
 static void
 ioapic_abi_intr_setup(int intr, int flags)
 {
+       const struct ioapic_irqmap *map;
        int vector, select;
        uint32_t value;
        u_long ef;
 
-       KKASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS &&
-           intr != IOAPIC_HWI_SYSCALL);
-       KKASSERT(ioapic_irqs[intr].io_addr != NULL);
+       KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
+           ("ioapic setup, invalid irq %d\n", intr));
+
+       map = &ioapic_irqmaps[mycpuid][intr];
+       KASSERT(IOAPIC_IMT_ISHWI(map),
+           ("ioapic setup, not hwi irq %d, type %d, cpu%d",
+            intr, map->im_type, mycpuid));
+       if (map->im_type != IOAPIC_IMT_LINE) {
+               kprintf("ioapic setup, irq %d cpu%d not LINE\n",
+                   intr, mycpuid);
+               return;
+       }
+
+       KASSERT(ioapic_irqs[intr].io_addr != NULL,
+           ("ioapic setup, no GSI information, irq %d\n", intr));
 
        ef = read_eflags();
        cpu_disable_intr();
@@ -642,13 +655,26 @@ ioapic_abi_intr_setup(int intr, int flags)
 static void
 ioapic_abi_intr_teardown(int intr)
 {
+       const struct ioapic_irqmap *map;
        int vector, select;
        uint32_t value;
        u_long ef;
 
-       KKASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS &&
-           intr != IOAPIC_HWI_SYSCALL);
-       KKASSERT(ioapic_irqs[intr].io_addr != NULL);
+       KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
+           ("ioapic teardown, invalid irq %d\n", intr));
+
+       map = &ioapic_irqmaps[mycpuid][intr];
+       KASSERT(IOAPIC_IMT_ISHWI(map),
+           ("ioapic teardown, not hwi irq %d, type %d, cpu%d",
+            intr, map->im_type, mycpuid));
+       if (map->im_type != IOAPIC_IMT_LINE) {
+               kprintf("ioapic teardown, irq %d cpu%d not LINE\n",
+                   intr, mycpuid);
+               return;
+       }
+
+       KASSERT(ioapic_irqs[intr].io_addr != NULL,
+           ("ioapic teardown, no GSI information, irq %d\n", intr));
 
        ef = read_eflags();
        cpu_disable_intr();