diff options
author | jhb <jhb@FreeBSD.org> | 2008-03-13 20:39:04 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-03-13 20:39:04 +0000 |
commit | 64ab71ccbde607665b904ceeec12a57d5d596db9 (patch) | |
tree | 6f62dea9f9beb25f9322cfc93d6d3df609bad843 /sys/amd64/acpica/acpi_machdep.c | |
parent | 1dbd762cae46b79416ec1320094bb7eab96f8187 (diff) | |
download | FreeBSD-src-64ab71ccbde607665b904ceeec12a57d5d596db9.zip FreeBSD-src-64ab71ccbde607665b904ceeec12a57d5d596db9.tar.gz |
Rework how the nexus(4) device works on x86 to better handle the idea of
different "platforms" on x86 machines. The existing code already handles
having two platforms: ACPI and legacy. However, the existing approach was
rather hardcoded and difficult to extend. These changes take the approach
that each x86 hardware platform should provide its own nexus(4) driver (it
can inherit most of its behavior from the default legacy nexus(4) driver)
which is responsible for probing for the platform and performing
appropriate platform-specific setup during attach (such as adding a
platform-specific bus device). This does mean changing the x86 platform
busses to no longer use an identify routine for probing, but to move that
logic into their matching nexus(4) driver instead.
- Make the default nexus(4) driver in nexus.c on i386 and amd64 handle the
legacy platform. It's probe routine now returns BUS_PROBE_GENERIC so it
can be overriden.
- Expose a nexus_init_resources() routine which initializes the various
resource managers so that subclassed nexus(4) drivers can invoke it from
their attach routine.
- The legacy nexus(4) driver explicitly adds a legacy0 device in its
attach routine.
- The ACPI driver no longer contains an new-bus identify method. Instead
it exposes a public function (acpi_identify()) which is a probe routine
that the MD nexus(4) drivers can use to probe for ACPI. All of the
probe logic in acpi_probe() is now moved into acpi_identify() and
acpi_probe() is just a stub.
- On i386 and amd64, an ACPI-specific nexus(4) driver checks for ACPI via
acpi_identify() and claims the nexus0 device if the probe succeeds. It
then explicitly adds an acpi0 device in its attach routine.
- The legacy(4) driver no longer knows anything about the acpi0 device.
- On ia64 if acpi_identify() fails you basically end up with no devices.
This matches the previous behavior where the old acpi_identify() would
fail to add an acpi0 device again leaving you with no devices.
Discussed with: imp
Silence on: arch@
Diffstat (limited to 'sys/amd64/acpica/acpi_machdep.c')
-rw-r--r-- | sys/amd64/acpica/acpi_machdep.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c index 5201ad7..e9e9235 100644 --- a/sys/amd64/acpica/acpi_machdep.c +++ b/sys/amd64/acpica/acpi_machdep.c @@ -29,10 +29,14 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/bus.h> +#include <sys/kernel.h> +#include <sys/module.h> #include <contrib/dev/acpica/acpi.h> #include <dev/acpica/acpivar.h> +#include <machine/nexusvar.h> + static int intr_model = ACPI_INTR_PIC; int @@ -67,3 +71,43 @@ acpi_cpu_c1() { __asm __volatile("sti; hlt"); } + +/* + * ACPI nexus(4) driver. + */ +static int +nexus_acpi_probe(device_t dev) +{ + int error; + + error = acpi_identify(); + if (error) + return (error); + + return (BUS_PROBE_DEFAULT); +} + +static int +nexus_acpi_attach(device_t dev) +{ + + nexus_init_resources(); + bus_generic_probe(dev); + if (BUS_ADD_CHILD(dev, 10, "acpi", 0) == NULL) + panic("failed to add acpi0 device"); + + return (bus_generic_attach(dev)); +} + +static device_method_t nexus_acpi_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, nexus_acpi_probe), + DEVMETHOD(device_attach, nexus_acpi_attach), + + { 0, 0 } +}; + +DEFINE_CLASS_1(nexus, nexus_acpi_driver, nexus_acpi_methods, 1, nexus_driver); +static devclass_t nexus_devclass; + +DRIVER_MODULE(nexus_acpi, root, nexus_acpi_driver, nexus_devclass, 0, 0); |