From 88100cf6c15096c1eb0776d2a8bd9dcf04d19095 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 16 Dec 2011 16:01:05 +0800 Subject: [PATCH] x86_64/ioapic_abi: Augment intr_{setup,teardown} w/ assertions --- sys/platform/pc64/apic/ioapic_abi.c | 38 +++++++++++++++++++++++++++++----- 1 files changed, 32 insertions(+), 6 deletions(-) diff --git a/sys/platform/pc64/apic/ioapic_abi.c b/sys/platform/pc64/apic/ioapic_abi.c index 2edf559..336727f 100644 --- a/sys/platform/pc64/apic/ioapic_abi.c +++ b/sys/platform/pc64/apic/ioapic_abi.c @@ -600,13 +600,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; register_t 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_rflags(); cpu_disable_intr(); @@ -641,13 +654,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; register_t 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_rflags(); cpu_disable_intr(); -- 1.7.7.2