Update to work with the new ACPI CA snapshot.

- Use ACPI_PHYSICAL_ADDRESS
 - RSDT -> XSDT
 - FACP -> FADT
 - No APIC table support
 - Don't install a global EC handler; this has bad side-effects
   (it invokes _REG in *all* EC spaces in the namespace!)
 - Check for PCI bus instances already existing before adding them
This commit is contained in:
Mike Smith 2000-12-01 10:18:57 +00:00
parent 6e4cd31d99
commit 042283a67b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69458
7 changed files with 63 additions and 85 deletions

View File

@ -152,11 +152,11 @@ SYSCTL_INT(_debug, OID_AUTO, acpi_debug_level, CTLFLAG_RW, &AcpiDbgLevel, 0, "")
static void
acpi_identify(driver_t *driver, device_t parent)
{
device_t child;
void *rsdp;
int error;
device_t child;
ACPI_PHYSICAL_ADDRESS rsdp;
int error;
#ifdef ENABLE_DEBUGGER
char *debugpoint = getenv("debug.acpi.debugger");
char *debugpoint = getenv("debug.acpi.debugger");
#endif
if(!cold){
@ -214,8 +214,8 @@ acpi_probe(device_t dev)
char buf[20];
int error;
if ((error = AcpiGetTableHeader(ACPI_TABLE_RSDT, 1, &th)) != AE_OK) {
device_printf(dev, "couldn't get RSDT header: %s\n", acpi_strerror(error));
if ((error = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th)) != AE_OK) {
device_printf(dev, "couldn't get XSDT header: %s\n", acpi_strerror(error));
return(ENXIO);
}
sprintf(buf, "%.6s %.8s", th.OemId, th.OemTableId);
@ -295,13 +295,13 @@ acpi_attach(device_t dev)
sc->acpi_lid_switch_sx = ACPI_LID_SWITCH_DEFAULT_SX;
/* Enable and clear fixed events and install handlers. */
if (AcpiGbl_FACP != NULL && AcpiGbl_FACP->PwrButton == 0) {
if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->PwrButton == 0) {
AcpiEnableEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
AcpiClearEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, acpi_eventhandler_power_button_for_sleep, sc);
device_printf(dev, "power button is handled as a fixed feature programming model.\n");
}
if (AcpiGbl_FACP != NULL && AcpiGbl_FACP->SleepButton == 0) {
if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->SleepButton == 0) {
AcpiEnableEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, acpi_eventhandler_sleep_button_for_sleep, sc);

View File

@ -80,6 +80,10 @@ acpi_apic_identify(driver_t *driver, device_t bus)
device_t child;
int len;
void *private;
#if 1
return;
#else /* broken by new ACPICA update that doesn't support the APIC table */
/*
* Perform the tedious double-get to fetch the actual table.
@ -131,6 +135,7 @@ acpi_apic_identify(driver_t *driver, device_t bus)
}
AcpiOsFree(buf.Pointer);
#endif
}
static int

View File

@ -205,10 +205,8 @@ static struct acpi_ec_softc acpi_ec_default; /* for the default EC handler */
static void EcGpeHandler(void *Context);
static ACPI_STATUS EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function,
void *Context, void **return_Context);
static ACPI_STATUS EcSpaceHandler(UINT32 Function, UINT32 Address, UINT32 width, UINT32 *Value,
static ACPI_STATUS EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UINT32 *Value,
void *Context, void *RegionContext);
static ACPI_STATUS EcDefaultSpaceHandler(UINT32 Function, UINT32 Address, UINT32 width, UINT32 *Value,
void *Context, void *RegionContext);
static ACPI_STATUS EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event);
static ACPI_STATUS EcQuery(struct acpi_ec_softc *sc, UINT8 *Data);
@ -251,18 +249,6 @@ acpi_ec_identify(driver_t driver, device_t bus)
ACPI_STATUS Status;
/* XXX implement - need an ACPI 2.0 system to test this */
/*
* XXX install a do-nothing handler at the top of the namespace to catch
* bogus accesses being made due to apparent interpreter bugs.
*/
acpi_ec_default.ec_dev = bus;
if ((Status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ADDRESS_SPACE_EC,
&EcDefaultSpaceHandler, &EcSpaceSetup,
&acpi_ec_default)) != AE_OK) {
device_printf(acpi_ec_default.ec_dev, "can't install default EC address space handler - %s\n",
acpi_strerror(Status));
}
}
/*
@ -462,7 +448,8 @@ EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context, void **RegionCo
}
static ACPI_STATUS
EcSpaceHandler(UINT32 Function, UINT32 Address, UINT32 width, UINT32 *Value, void *Context, void *RegionContext)
EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UINT32 *Value,
void *Context, void *RegionContext)
{
struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
ACPI_STATUS Status = AE_OK;
@ -498,28 +485,6 @@ EcSpaceHandler(UINT32 Function, UINT32 Address, UINT32 width, UINT32 *Value, voi
return(Status);
}
static ACPI_STATUS
EcDefaultSpaceHandler(UINT32 Function, UINT32 Address, UINT32 width, UINT32 *Value, void *Context, void *RegionContext)
{
if ((Address > 0xFF) || (width != 8) || (Value == NULL) || (Context == NULL))
return(AE_BAD_PARAMETER);
switch (Function) {
case ADDRESS_SPACE_READ:
printf("ACPI: Illegal EC read from 0x%x\n", Address);
*Value = 0;
break;
case ADDRESS_SPACE_WRITE:
printf("ACPI: Illegal EC write 0x%x to 0x%x\n", *Value, Address);
break;
default:
printf("ACPI: Illegal EC unknown operation");
break;
}
/* let things keep going */
return(AE_OK);
}
static ACPI_STATUS
EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event)
{

View File

@ -151,6 +151,10 @@ acpi_pcib_attach(device_t dev)
* meant to use a private configuration space mechanism for this bus,
* so we should dig out our resources and check to see if we have
* anything like that. How do we do this?
* XXX If we have the requisite information, and if we don't think the
* default PCI configuration space handlers can deal with this bus,
* we should attach our own handler.
* XXX invoke _REG on this for the PCI config space address space?
*/
if ((status = acpi_EvaluateNumber(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) {
if (status != AE_NOT_FOUND) {
@ -162,27 +166,26 @@ acpi_pcib_attach(device_t dev)
}
/*
* XXX we should check here to make sure that this bus number hasn't already
* been attached. It shouldn't really be an issue.
* Make sure that this bus hasn't already been found. If it has, return silently
* (should we complain here?).
*/
if (devclass_get_device(devclass_find("pci"), sc->ap_bus) != NULL)
return(0);
/*
* Attach the PCI bus proper.
*/
if ((child = device_add_child(dev, "pci", sc->ap_bus)) == NULL) {
device_printf(device_get_parent(dev), "couldn't attach pci bus");
return(ENXIO);
}
/*
* XXX If we have the requisite information, and if we don't think the
* default PCI configuration space handlers can deal with this bus,
* we should attach our own handler.
*/
/* XXX invoke _REG on this for the PCI config space address space? */
/*
* Now go scan the bus.
*
* XXX is it possible to defer this and count on the nexus getting to it
* reliably after it's finished with ACPI? Should we really care?
* Note that we defer the actual scan of the child PCI bus; ACPI will call
* bus_generic_attach on its children a second time after the first pass
* is complete. This leads to slightly neater output.
*/
return(bus_generic_attach(dev));
return(0);
}
static int

View File

@ -151,6 +151,10 @@ acpi_pcib_attach(device_t dev)
* meant to use a private configuration space mechanism for this bus,
* so we should dig out our resources and check to see if we have
* anything like that. How do we do this?
* XXX If we have the requisite information, and if we don't think the
* default PCI configuration space handlers can deal with this bus,
* we should attach our own handler.
* XXX invoke _REG on this for the PCI config space address space?
*/
if ((status = acpi_EvaluateNumber(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) {
if (status != AE_NOT_FOUND) {
@ -162,27 +166,26 @@ acpi_pcib_attach(device_t dev)
}
/*
* XXX we should check here to make sure that this bus number hasn't already
* been attached. It shouldn't really be an issue.
* Make sure that this bus hasn't already been found. If it has, return silently
* (should we complain here?).
*/
if (devclass_get_device(devclass_find("pci"), sc->ap_bus) != NULL)
return(0);
/*
* Attach the PCI bus proper.
*/
if ((child = device_add_child(dev, "pci", sc->ap_bus)) == NULL) {
device_printf(device_get_parent(dev), "couldn't attach pci bus");
return(ENXIO);
}
/*
* XXX If we have the requisite information, and if we don't think the
* default PCI configuration space handlers can deal with this bus,
* we should attach our own handler.
*/
/* XXX invoke _REG on this for the PCI config space address space? */
/*
* Now go scan the bus.
*
* XXX is it possible to defer this and count on the nexus getting to it
* reliably after it's finished with ACPI? Should we really care?
* Note that we defer the actual scan of the child PCI bus; ACPI will call
* bus_generic_attach on its children a second time after the first pass
* is complete. This leads to slightly neater output.
*/
return(bus_generic_attach(dev));
return(0);
}
static int

View File

@ -389,7 +389,8 @@ acpi_pr_FindLapic(device_t dev, ACPI_HANDLE handle, PROCESSOR_APIC *lapic)
return;
}
lapic->ProcessorEnabled = (cpuno == 0);
#if 0 /* broken by new ACPICA code that doesn't support the APIC table */
/*
* Perform the tedious double-get to fetch the actual APIC table, and suck it in.
*/
@ -434,6 +435,7 @@ acpi_pr_FindLapic(device_t dev, ACPI_HANDLE handle, PROCESSOR_APIC *lapic)
hdr = (APIC_HEADER *)((char *)hdr + hdr->Length);
}
AcpiOsFree(buf.Pointer);
#endif
}
static ACPI_STATUS

View File

@ -67,20 +67,20 @@ DRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, acpi_timer_devclass, 0, 0);
static void
acpi_timer_identify(driver_t *driver, device_t parent)
{
static FIXED_ACPI_DESCRIPTION_TABLE facp;
ACPI_BUFFER buf;
ACPI_STATUS status;
device_t dev;
char desc[40];
static FADT_DESCRIPTOR_REV1 fadt;
ACPI_BUFFER buf;
ACPI_STATUS status;
device_t dev;
char desc[40];
buf.Pointer = &facp;
buf.Length = sizeof(facp);
if ((status = AcpiGetTable(ACPI_TABLE_FACP, 1, &buf)) != AE_OK) {
device_printf(parent, "can't locate FACP - %s\n", acpi_strerror(status));
buf.Pointer = &fadt;
buf.Length = sizeof(fadt);
if ((status = AcpiGetTable(ACPI_TABLE_FADT, 1, &buf)) != AE_OK) {
device_printf(parent, "can't locate FADT - %s\n", acpi_strerror(status));
return;
}
if (buf.Length != sizeof(facp)) {
device_printf(parent, "invalid FACP\n");
if (buf.Length != sizeof(fadt)) {
device_printf(parent, "invalid FADT\n");
return;
}
@ -93,7 +93,7 @@ acpi_timer_identify(driver_t *driver, device_t parent)
return;
}
sprintf(desc, "%d-bit timer at 3.579545MHz", facp.TmrValExt ? 32 : 24);
sprintf(desc, "%d-bit timer at 3.579545MHz", fadt.TmrValExt ? 32 : 24);
device_set_desc_copy(dev, desc);
}