ACPI_NUMBER becomes ACPI_INTEGER. acpi_EvaluateNumber becomes

acpi_EvaluateInteger.

Use acpi_EvaluateInteger instead of doing things the hard way where
possible.

AcpiSetSystemSleepState (unofficial) becomes AcpiEnterSleepState.

Use the AcpiGbl_FADT pointer rather than searching for the FADT.
This commit is contained in:
Mike Smith 2001-01-31 09:30:57 +00:00
parent b84bd585e9
commit 91467fc61d
8 changed files with 24 additions and 46 deletions

View File

@ -672,7 +672,7 @@ acpi_shutdown_final(void *arg, int howto)
if (howto & RB_POWEROFF) {
printf("Power system off using ACPI...\n");
if ((status = AcpiSetSystemSleepState(ACPI_STATE_S5)) != AE_OK) {
if ((status = AcpiEnterSleepState(ACPI_STATE_S5)) != AE_OK) {
printf("ACPI power-off failed - %s\n", acpi_strerror(status));
} else {
DELAY(1000000);
@ -779,9 +779,9 @@ acpi_SetSleepState(struct acpi_softc *sc, int state)
switch (state) {
case ACPI_STATE_S0: /* XXX only for testing */
status = AcpiSetSystemSleepState((UINT8)state);
status = AcpiEnterSleepState((UINT8)state);
if (status != AE_OK) {
device_printf(sc->acpi_dev, "AcpiSetSystemSleepState failed - %s\n", acpi_strerror(status));
device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n", acpi_strerror(status));
}
break;
@ -801,9 +801,9 @@ acpi_SetSleepState(struct acpi_softc *sc, int state)
return_ACPI_STATUS(AE_ERROR);
}
sc->acpi_sstate = state;
status = AcpiSetSystemSleepState((UINT8)state);
status = AcpiEnterSleepState((UINT8)state);
if (status != AE_OK) {
device_printf(sc->acpi_dev, "AcpiSetSystemSleepState failed - %s\n", acpi_strerror(status));
device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n", acpi_strerror(status));
}
DEVICE_RESUME(root_bus);
sc->acpi_sstate = ACPI_STATE_S0;
@ -887,22 +887,22 @@ acpi_DeviceIsPresent(device_t dev)
}
/*
* Evaluate a path that should return a number
* Evaluate a path that should return an integer.
*/
ACPI_STATUS
acpi_EvaluateNumber(ACPI_HANDLE handle, char *path, int *number)
acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
{
ACPI_STATUS error;
ACPI_BUFFER buf;
int param[4];
ACPI_OBJECT param;
if (handle == NULL)
handle = ACPI_ROOT_OBJECT;
buf.Pointer = &param[0];
buf.Pointer = &param;
buf.Length = sizeof(param);
if ((error = AcpiEvaluateObject(handle, path, NULL, &buf)) == AE_OK) {
if (param[0] == ACPI_TYPE_NUMBER) {
*number = param[1];
if (param.Type == ACPI_TYPE_INTEGER) {
*number = param.Integer.Value;
} else {
error = AE_TYPE;
}

View File

@ -64,7 +64,7 @@ acpi_acad_get_status(void *context)
struct acpi_acad_softc *sc = device_get_softc(dev);
ACPI_HANDLE h = acpi_get_handle(dev);
if (acpi_EvaluateNumber(h, "_PSR", &sc->status) != AE_OK)
if (acpi_EvaluateInteger(h, "_PSR", &sc->status) != AE_OK)
return;
device_printf(dev,"%s\n",(sc->status) ? "On Line" : "Off Line");
}

View File

@ -67,9 +67,9 @@ static int acpi_cmbat_units = 0;
#define PKG_GETINT(res, tmp, idx, dest, label) do { \
tmp = &res->Package.Elements[idx]; \
if (tmp->Type != ACPI_TYPE_NUMBER) \
if (tmp->Type != ACPI_TYPE_INTEGER) \
goto label ; \
dest = tmp->Number.Value; \
dest = tmp->Integer.Value; \
} while(0)
#define PKG_GETSTR(res, tmp, idx, dest, size, label) do { \

View File

@ -108,29 +108,18 @@ acpi_lid_notify_status_changed(void *arg)
{
struct acpi_lid_softc *sc;
struct acpi_softc *acpi_sc;
ACPI_BUFFER Buffer;
ACPI_OBJECT Object;
FUNCTION_TRACE(__FUNCTION__);
sc = (struct acpi_lid_softc *)arg;
/*
* Evaluate _LID and check the return value
* Evaluate _LID and check the return value, update lid status.
* Zero: The lid is closed
* Non-zero: The lid is open
*/
Buffer.Length = sizeof(Object);
Buffer.Pointer = &Object;
if (AcpiEvaluateObject(sc->lid_handle, "_LID", NULL, &Buffer) != AE_OK)
if (acpi_EvaluateInteger(sc->lid_handle, "_LID", &sc->lid_status) != AE_OK)
return_VOID;
if (Object.Type != ACPI_TYPE_NUMBER)
return_VOID;
/*
* Update lid status
*/
sc->lid_status = Object.Number.Value;
device_printf(sc->lid_dev, "Lid %s\n", sc->lid_status ? "opened" : "closed");
acpi_sc = acpi_device_get_parent_softc(sc->lid_dev);

View File

@ -144,7 +144,7 @@ acpi_pcib_attach(device_t dev)
* Get our segment number by evaluating _SEG
* It's OK for this to not exist.
*/
if ((status = acpi_EvaluateNumber(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) {
if ((status = acpi_EvaluateInteger(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _SEG - %s\n", acpi_strerror(status));
return_VALUE(ENXIO);
@ -166,7 +166,7 @@ acpi_pcib_attach(device_t dev)
* 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 = acpi_EvaluateInteger(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _BBN - %s\n", acpi_strerror(status));
return_VALUE(ENXIO);

View File

@ -144,7 +144,7 @@ acpi_pcib_attach(device_t dev)
* Get our segment number by evaluating _SEG
* It's OK for this to not exist.
*/
if ((status = acpi_EvaluateNumber(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) {
if ((status = acpi_EvaluateInteger(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _SEG - %s\n", acpi_strerror(status));
return_VALUE(ENXIO);
@ -166,7 +166,7 @@ acpi_pcib_attach(device_t dev)
* 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 = acpi_EvaluateInteger(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _BBN - %s\n", acpi_strerror(status));
return_VALUE(ENXIO);

View File

@ -73,9 +73,6 @@ 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 FADT_DESCRIPTOR_REV1 fadt;
ACPI_BUFFER buf;
ACPI_STATUS status;
device_t dev;
char desc[40];
@ -84,17 +81,9 @@ acpi_timer_identify(driver_t *driver, device_t parent)
if (acpi_disabled("timer"))
return_VOID;
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));
if (AcpiGbl_FADT == NULL)
return_VOID;
}
if (buf.Length != sizeof(fadt)) {
device_printf(parent, "invalid FADT\n");
return_VOID;
}
if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
device_printf(parent, "could not add acpi_timer0\n");
return_VOID;
@ -104,7 +93,7 @@ acpi_timer_identify(driver_t *driver, device_t parent)
return_VOID;
}
sprintf(desc, "%d-bit timer at 3.579545MHz", fadt.TmrValExt ? 32 : 24);
sprintf(desc, "%d-bit timer at 3.579545MHz", AcpiGbl_FADT->TmrValExt ? 32 : 24);
device_set_desc_copy(dev, desc);
return_VOID;

View File

@ -163,7 +163,7 @@ extern ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state);
extern ACPI_STATUS acpi_Enable(struct acpi_softc *sc);
extern ACPI_STATUS acpi_Disable(struct acpi_softc *sc);
extern BOOLEAN acpi_DeviceIsPresent(device_t dev);
extern ACPI_STATUS acpi_EvaluateNumber(ACPI_HANDLE handle, char *path, int *number);
extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number);
struct acpi_parse_resource_set {
void (* set_init)(device_t dev, void **context);