Add flags for _STA (status) methods and convenience macros for checking

the presence of batteries and devices.
This commit is contained in:
njl 2004-08-06 00:38:50 +00:00
parent 854b82db14
commit 9b4d7989dc
2 changed files with 18 additions and 4 deletions

View File

@ -1339,7 +1339,7 @@ acpi_DeviceIsPresent(device_t dev)
ret = TRUE;
/* Return true for 'present' and 'functioning' */
if ((devinfo->CurrentStatus & 0x9) == 0x9)
if (ACPI_DEVICE_PRESENT(devinfo->CurrentStatus))
ret = TRUE;
AcpiOsFree(buf.Pointer);
@ -1372,8 +1372,8 @@ acpi_BatteryIsPresent(device_t dev)
if ((devinfo->Valid & ACPI_VALID_STA) == 0)
ret = TRUE;
/* Return true for 'present' and 'functioning' */
if ((devinfo->CurrentStatus & 0x19) == 0x19)
/* Return true for 'present', 'battery present', and 'functioning' */
if (ACPI_BATTERY_PRESENT(devinfo->CurrentStatus))
ret = TRUE;
AcpiOsFree(buf.Pointer);

View File

@ -222,7 +222,21 @@ void acpi_EnterDebugger(void);
device_printf(dev, x); \
} while (0)
#define ACPI_DEVINFO_PRESENT(x) (((x) & 0x9) == 9)
/* Values for the device _STA (status) method. */
#define ACPI_STA_PRESENT (1 << 0)
#define ACPI_STA_ENABLED (1 << 1)
#define ACPI_STA_SHOW_IN_UI (1 << 2)
#define ACPI_STA_FUNCTIONAL (1 << 3)
#define ACPI_STA_BATT_PRESENT (1 << 4)
#define ACPI_DEVINFO_PRESENT(x, flags) \
(((x) & (flags)) == (flags))
#define ACPI_DEVICE_PRESENT(x) \
ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL)
#define ACPI_BATTERY_PRESENT(x) \
ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL | \
ACPI_STA_BATT_PRESENT)
BOOLEAN acpi_DeviceIsPresent(device_t dev);
BOOLEAN acpi_BatteryIsPresent(device_t dev);
ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,