Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/acpi_support/acpi_wmi.c
Show First 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | acpi_wmi_attach(device_t dev) | ||||
ACPI_SERIAL_BEGIN(acpi_wmi); | ACPI_SERIAL_BEGIN(acpi_wmi); | ||||
sc->wmi_dev = dev; | sc->wmi_dev = dev; | ||||
sc->wmi_handle = acpi_get_handle(dev); | sc->wmi_handle = acpi_get_handle(dev); | ||||
TAILQ_INIT(&sc->wmi_info_list); | TAILQ_INIT(&sc->wmi_info_list); | ||||
/* XXX Only works with one EC, but nearly all systems only have one. */ | /* XXX Only works with one EC, but nearly all systems only have one. */ | ||||
if ((sc->ec_dev = devclass_get_device(devclass_find("acpi_ec"), 0)) | if ((sc->ec_dev = devclass_get_device(devclass_find("acpi_ec"), 0)) | ||||
== NULL) | == NULL) | ||||
device_printf(dev, "cannot find EC device\n"); | device_printf(dev, "cannot find EC device\n"); | ||||
else if (ACPI_FAILURE((status = AcpiInstallNotifyHandler(sc->wmi_handle, | if (ACPI_FAILURE((status = AcpiInstallNotifyHandler(sc->wmi_handle, | ||||
ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler, sc)))) | ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler, sc)))) | ||||
device_printf(sc->wmi_dev, "couldn't install notify handler - %s\n", | device_printf(sc->wmi_dev, "couldn't install notify handler - %s\n", | ||||
AcpiFormatException(status)); | AcpiFormatException(status)); | ||||
else if (ACPI_FAILURE((status = AcpiInstallAddressSpaceHandler( | else if (ACPI_FAILURE((status = AcpiInstallAddressSpaceHandler( | ||||
sc->wmi_handle, ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler, | sc->wmi_handle, ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler, | ||||
NULL, sc)))) { | NULL, sc)))) { | ||||
device_printf(sc->wmi_dev, "couldn't install EC handler - %s\n", | device_printf(sc->wmi_dev, "couldn't install EC handler - %s\n", | ||||
AcpiFormatException(status)); | AcpiFormatException(status)); | ||||
▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | acpi_wmi_ec_handler(UINT32 function, ACPI_PHYSICAL_ADDRESS address, | ||||
ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, (UINT32)address); | ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, (UINT32)address); | ||||
sc = (struct acpi_wmi_softc *)context; | sc = (struct acpi_wmi_softc *)context; | ||||
if (width % 8 != 0 || value == NULL || context == NULL) | if (width % 8 != 0 || value == NULL || context == NULL) | ||||
return (AE_BAD_PARAMETER); | return (AE_BAD_PARAMETER); | ||||
if (address + (width / 8) - 1 > 0xFF) | if (address + (width / 8) - 1 > 0xFF) | ||||
return (AE_BAD_ADDRESS); | return (AE_BAD_ADDRESS); | ||||
if (sc->ec_dev == NULL) | |||||
return (AE_NOT_FOUND); | |||||
if (function == ACPI_READ) | if (function == ACPI_READ) | ||||
*value = 0; | *value = 0; | ||||
ec_addr = address; | ec_addr = address; | ||||
status = AE_ERROR; | status = AE_ERROR; | ||||
for (i = 0; i < width; i += 8, ++ec_addr) { | for (i = 0; i < width; i += 8, ++ec_addr) { | ||||
switch (function) { | switch (function) { | ||||
case ACPI_READ: | case ACPI_READ: | ||||
▲ Show 20 Lines • Show All 336 Lines • Show Last 20 Lines |