From: Sepherosa Ziehau Date: Fri, 16 Dec 2011 07:21:44 +0000 (+0800) Subject: x86_64/ioapic_abi: Augment intr_disable/intr_enable w/ assertions X-Git-Tag: v3.0.0~370 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/aef690c8e8f24bd1169780ebc7bade827fb3f370 x86_64/ioapic_abi: Augment intr_disable/intr_enable w/ assertions --- 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); }