From db181dc741b63797fad3a1acf14e66bc2e801894 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 5 Mar 2007 16:22:49 +0000 Subject: [PATCH] Add a simple device driver to "eat" any I/O APICs that show up as PCI devices. MFC after: 1 week --- sys/amd64/amd64/io_apic.c | 49 ++++++++++++++++++++++++++++++++++++++- sys/i386/i386/io_apic.c | 49 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/io_apic.c b/sys/amd64/amd64/io_apic.c index b27db7e294e6..b4bbcaf52501 100644 --- a/sys/amd64/amd64/io_apic.c +++ b/sys/amd64/amd64/io_apic.c @@ -36,11 +36,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include +#include #include #include +#include +#include + #include #include @@ -727,3 +731,46 @@ ioapic_register(void *cookie) if (pin->io_irq < NUM_IO_INTS) intr_register_source(&pin->io_intsrc); } + +/* A simple new-bus driver to consume PCI I/O APIC devices. */ +static int +ioapic_pci_probe(device_t dev) +{ + + if (pci_get_class(dev) == PCIC_BASEPERIPH && + pci_get_subclass(dev) == PCIS_BASEPERIPH_PIC) { + switch (pci_get_progif(dev)) { + case PCIP_BASEPERIPH_PIC_IO_APIC: + device_set_desc(dev, "IO APIC"); + break; + case PCIP_BASEPERIPH_PIC_IOX_APIC: + device_set_desc(dev, "IO(x) APIC"); + break; + default: + return (ENXIO); + } + device_quiet(dev); + return (-10000); + } + return (ENXIO); +} + +static int +ioapic_pci_attach(device_t dev) +{ + + return (0); +} + +static device_method_t ioapic_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ioapic_pci_probe), + DEVMETHOD(device_attach, ioapic_pci_attach), + + { 0, 0 } +}; + +DEFINE_CLASS_0(ioapic, ioapic_pci_driver, ioapic_pci_methods, 0); + +static devclass_t ioapic_devclass; +DRIVER_MODULE(ioapic, pci, ioapic_pci_driver, ioapic_devclass, 0, 0); diff --git a/sys/i386/i386/io_apic.c b/sys/i386/i386/io_apic.c index 597383660696..0db8ea3bcc5c 100644 --- a/sys/i386/i386/io_apic.c +++ b/sys/i386/i386/io_apic.c @@ -36,11 +36,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include +#include #include #include +#include +#include + #include #include @@ -727,3 +731,46 @@ ioapic_register(void *cookie) if (pin->io_irq < NUM_IO_INTS) intr_register_source(&pin->io_intsrc); } + +/* A simple new-bus driver to consume PCI I/O APIC devices. */ +static int +ioapic_pci_probe(device_t dev) +{ + + if (pci_get_class(dev) == PCIC_BASEPERIPH && + pci_get_subclass(dev) == PCIS_BASEPERIPH_PIC) { + switch (pci_get_progif(dev)) { + case PCIP_BASEPERIPH_PIC_IO_APIC: + device_set_desc(dev, "IO APIC"); + break; + case PCIP_BASEPERIPH_PIC_IOX_APIC: + device_set_desc(dev, "IO(x) APIC"); + break; + default: + return (ENXIO); + } + device_quiet(dev); + return (-10000); + } + return (ENXIO); +} + +static int +ioapic_pci_attach(device_t dev) +{ + + return (0); +} + +static device_method_t ioapic_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ioapic_pci_probe), + DEVMETHOD(device_attach, ioapic_pci_attach), + + { 0, 0 } +}; + +DEFINE_CLASS_0(ioapic, ioapic_pci_driver, ioapic_pci_methods, 0); + +static devclass_t ioapic_devclass; +DRIVER_MODULE(ioapic, pci, ioapic_pci_driver, ioapic_devclass, 0, 0);