diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h index 61c726f150df..fc9bb0123539 100644 --- a/sys/x86/include/apicvar.h +++ b/sys/x86/include/apicvar.h @@ -196,19 +196,21 @@ extern int *apic_cpuids; /* Allow to replace the lapic_ipi_vectored implementation. */ extern void (*ipi_vectored)(u_int, int); +typedef struct ioapic *ioapic_drv_t; + void apic_register_enumerator(struct apic_enumerator *enumerator); -void *ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase); -int ioapic_disable_pin(void *cookie, u_int pin); -int ioapic_get_vector(void *cookie, u_int pin); -void ioapic_register(void *cookie); -int ioapic_remap_vector(void *cookie, u_int pin, int vector); -int ioapic_set_bus(void *cookie, u_int pin, int bus_type); -int ioapic_set_extint(void *cookie, u_int pin); -int ioapic_set_nmi(void *cookie, u_int pin); -int ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol); -int ioapic_set_triggermode(void *cookie, u_int pin, +ioapic_drv_t ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase); +int ioapic_disable_pin(ioapic_drv_t cookie, u_int pin); +int ioapic_get_vector(ioapic_drv_t cookie, u_int pin); +void ioapic_register(ioapic_drv_t cookie); +int ioapic_remap_vector(ioapic_drv_t cookie, u_int pin, int vector); +int ioapic_set_bus(ioapic_drv_t cookie, u_int pin, int bus_type); +int ioapic_set_extint(ioapic_drv_t cookie, u_int pin); +int ioapic_set_nmi(ioapic_drv_t cookie, u_int pin); +int ioapic_set_polarity(ioapic_drv_t cookie, u_int pin, enum intr_polarity pol); +int ioapic_set_triggermode(ioapic_drv_t cookie, u_int pin, enum intr_trigger trigger); -int ioapic_set_smi(void *cookie, u_int pin); +int ioapic_set_smi(ioapic_drv_t cookie, u_int pin); void lapic_create(u_int apic_id, int boot_cpu); void lapic_init(vm_paddr_t addr); diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index 36c7cba77a35..d0f47f82011a 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -606,7 +606,7 @@ ioapic_resume(struct pic *pic, bool suspend_cancelled) /* * Create a plain I/O APIC object. */ -void * +ioapic_drv_t ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) { struct ioapic *io; @@ -727,22 +727,18 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) } int -ioapic_get_vector(void *cookie, u_int pin) +ioapic_get_vector(ioapic_drv_t io, u_int pin) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (-1); return (io->io_pins[pin].io_irq); } int -ioapic_disable_pin(void *cookie, u_int pin) +ioapic_disable_pin(ioapic_drv_t io, u_int pin) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_DISABLED) @@ -754,11 +750,9 @@ ioapic_disable_pin(void *cookie, u_int pin) } int -ioapic_remap_vector(void *cookie, u_int pin, int vector) +ioapic_remap_vector(ioapic_drv_t io, u_int pin, int vector) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr || vector < 0) return (EINVAL); if (io->io_pins[pin].io_irq < 0) @@ -771,13 +765,11 @@ ioapic_remap_vector(void *cookie, u_int pin, int vector) } int -ioapic_set_bus(void *cookie, u_int pin, int bus_type) +ioapic_set_bus(ioapic_drv_t io, u_int pin, int bus_type) { - struct ioapic *io; if (bus_type < 0 || bus_type > APIC_BUS_MAX) return (EINVAL); - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); if (io->io_pins[pin].io_irq < 0) @@ -792,11 +784,9 @@ ioapic_set_bus(void *cookie, u_int pin, int bus_type) } int -ioapic_set_nmi(void *cookie, u_int pin) +ioapic_set_nmi(ioapic_drv_t io, u_int pin) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_NMI) @@ -815,11 +805,9 @@ ioapic_set_nmi(void *cookie, u_int pin) } int -ioapic_set_smi(void *cookie, u_int pin) +ioapic_set_smi(ioapic_drv_t io, u_int pin) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_SMI) @@ -838,11 +826,9 @@ ioapic_set_smi(void *cookie, u_int pin) } int -ioapic_set_extint(void *cookie, u_int pin) +ioapic_set_extint(ioapic_drv_t io, u_int pin) { - struct ioapic *io; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_EXTINT) @@ -864,12 +850,10 @@ ioapic_set_extint(void *cookie, u_int pin) } int -ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol) +ioapic_set_polarity(ioapic_drv_t io, u_int pin, enum intr_polarity pol) { - struct ioapic *io; int activehi; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr || pol == INTR_POLARITY_CONFORM) return (EINVAL); if (io->io_pins[pin].io_irq < 0) @@ -885,12 +869,10 @@ ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol) } int -ioapic_set_triggermode(void *cookie, u_int pin, enum intr_trigger trigger) +ioapic_set_triggermode(ioapic_drv_t io, u_int pin, enum intr_trigger trigger) { - struct ioapic *io; int edgetrigger; - io = (struct ioapic *)cookie; if (pin >= io->io_numintr || trigger == INTR_TRIGGER_CONFORM) return (EINVAL); if (io->io_pins[pin].io_irq < 0) @@ -909,15 +891,13 @@ ioapic_set_triggermode(void *cookie, u_int pin, enum intr_trigger trigger) * Register a complete I/O APIC object with the interrupt subsystem. */ void -ioapic_register(void *cookie) +ioapic_register(ioapic_drv_t io) { struct ioapic_intsrc *pin; - struct ioapic *io; volatile ioapic_t *apic; uint32_t flags; int i; - io = (struct ioapic *)cookie; apic = io->io_addr; mtx_lock_spin(&icu_lock); flags = ioapic_read(apic, IOAPIC_VER) & IOART_VER_VERSION; diff --git a/sys/x86/x86/mptable.c b/sys/x86/x86/mptable.c index 03b4d4362baa..4f078fd05ec6 100644 --- a/sys/x86/x86/mptable.c +++ b/sys/x86/x86/mptable.c @@ -157,7 +157,7 @@ struct pci_route_interrupt_args { static mpfps_t mpfps; static mpcth_t mpct; static ext_entry_ptr mpet; -static void *ioapics[IOAPIC_MAX_ID + 1]; +static ioapic_drv_t ioapics[IOAPIC_MAX_ID + 1]; static bus_datum *busses; static int mptable_nioapics, mptable_nbusses, mptable_maxbusid; static int pci0 = -1; @@ -760,7 +760,7 @@ intentry_trigger(int_entry_ptr intr) static void mptable_parse_io_int(int_entry_ptr intr) { - void *ioapic; + ioapic_drv_t ioapic; u_int pin, apic_id; apic_id = intr->dst_apic_id;