mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-26 11:47:31 +00:00
intr/x86: add ioapic_drv_t to reduce number of casts in IO-APIC implementation
void * is handy when you truly do not care about the type. Yet there is so much casting back and forth in the IO-APIC code as to be hazardous. Achieve better static checking by the compiler using a typedef. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1457
This commit is contained in:
parent
0e8a36a2ab
commit
90fb07edbd
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user