From: Sepherosa Ziehau Date: Sun, 18 Dec 2011 12:09:31 +0000 (+0800) Subject: i386/ioapic_abi: Augment intr_{setup,teardown} w/ assertions X-Git-Tag: v3.0.0~356 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/ba66d5060ccefff1644545dd19483766d09147e7 i386/ioapic_abi: Augment intr_{setup,teardown} w/ assertions This merges 88100cf6c15096c1eb0776d2a8bd9dcf04d19095 --- diff --git a/sys/platform/pc32/apic/ioapic_abi.c b/sys/platform/pc32/apic/ioapic_abi.c index 7c22c37f01..fc9bbd8e27 100644 --- a/sys/platform/pc32/apic/ioapic_abi.c +++ b/sys/platform/pc32/apic/ioapic_abi.c @@ -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();