From aef690c8e8f24bd1169780ebc7bade827fb3f370 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 16 Dec 2011 15:21:44 +0800 Subject: [PATCH] x86_64/ioapic_abi: Augment intr_disable/intr_enable w/ assertions --- sys/platform/pc64/apic/ioapic_abi.c | 30 +++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/sys/platform/pc64/apic/ioapic_abi.c b/sys/platform/pc64/apic/ioapic_abi.c index d7f180fd38..2edf55958e 100644 --- a/sys/platform/pc64/apic/ioapic_abi.c +++ b/sys/platform/pc64/apic/ioapic_abi.c @@ -524,20 +524,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); } -- 2.41.0