i386/ioapic_abi: Augment intr_disable/intr_enable w/ assertions
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 18 Dec 2011 12:02:11 +0000 (20:02 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 18 Dec 2011 12:02:11 +0000 (20:02 +0800)
This merges aef690c8e8f24bd1169780ebc7bade827fb3f370

sys/platform/pc32/apic/ioapic_abi.c

index 77110ae..7c22c37 100644 (file)
@@ -525,20 +525,42 @@ struct ioapic_irqinfo     ioapic_irqs[IOAPIC_HWI_VECTORS];
 static void
 ioapic_abi_intr_enable(int irq)
 {
-       if (irq < 0 || irq >= IOAPIC_HWI_VECTORS) {
-               kprintf("ioapic_abi_intr_enable invalid irq %d\n", irq);
+       const struct ioapic_irqmap *map;
+
+       KASSERT(irq >= 0 && irq < IOAPIC_HWI_VECTORS,
+           ("ioapic enable, invalid irq %d\n", irq));
+
+       map = &ioapic_irqmaps[mycpuid][irq];
+       KASSERT(IOAPIC_IMT_ISHWI(map),
+           ("ioapic enable, not hwi irq %d, type %d, cpu%d\n",
+            irq, map->im_type, mycpuid));
+       if (map->im_type != IOAPIC_IMT_LINE) {
+               kprintf("ioapic enable, irq %d cpu%d not LINE\n",
+                   irq, mycpuid);
                return;
        }
+
        IOAPIC_INTREN(irq);
 }
 
 static void
 ioapic_abi_intr_disable(int irq)
 {
-       if (irq < 0 || irq >= IOAPIC_HWI_VECTORS) {
-               kprintf("ioapic_abi_intr_disable invalid irq %d\n", irq);
+       const struct ioapic_irqmap *map;
+
+       KASSERT(irq >= 0 && irq < IOAPIC_HWI_VECTORS,
+           ("ioapic disable, invalid irq %d\n", irq));
+
+       map = &ioapic_irqmaps[mycpuid][irq];
+       KASSERT(IOAPIC_IMT_ISHWI(map),
+           ("ioapic disable, not hwi irq %d, type %d, cpu%d\n",
+            irq, map->im_type, mycpuid));
+       if (map->im_type != IOAPIC_IMT_LINE) {
+               kprintf("ioapic disable, irq %d cpu%d not LINE\n",
+                   irq, mycpuid);
                return;
        }
+
        IOAPIC_INTRDIS(irq);
 }