Index: acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.83 diff -u -r1.83 acpi.c --- acpi.c 28 Dec 2002 14:58:50 -0000 1.83 +++ acpi.c 28 Jan 2003 20:38:54 -0000 @@ -113,6 +113,7 @@ static struct resource *acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); static int acpi_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r); +static u_int32_t acpi_isa_get_compatid(device_t dev); static u_int32_t acpi_isa_get_logicalid(device_t dev); static int acpi_isa_pnp_probe(device_t bus, device_t child, struct isa_pnp_id *ids); @@ -127,6 +128,8 @@ static void acpi_system_eventhandler_sleep(void *arg, int state); static void acpi_system_eventhandler_wakeup(void *arg, int state); static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); +static ACPI_STATUS acpi_print_prw(ACPI_HANDLE h, UINT32 level, void *context, void ** result); +static ACPI_STATUS acpi_process_prw(ACPI_HANDLE h, UINT32 level, void *context, void ** result); static int acpi_pm_func(u_long cmd, void *arg, ...); @@ -509,7 +512,11 @@ if ((error = acpi_machdep_init(dev))) { goto out; } - + { + ACPI_HANDLE h; + AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &h); + AcpiWalkNamespace(ACPI_TYPE_ANY, h, 100, acpi_print_prw, NULL, NULL); + } /* Register ACPI again to pass the correct argument of pm_func. */ power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, sc); @@ -522,6 +529,29 @@ ACPI_UNLOCK; return_VALUE(error); } +static ACPI_STATUS acpi_print_prw(ACPI_HANDLE h, UINT32 level, void *context, void ** result) +{ + ACPI_BUFFER b; + char name[8]; + b.Pointer = name; + AcpiGetName(h, ACPI_SINGLE_NAME, &b); + if(strncmp(name, "_PRW", 4)== 0){ + printf("PRW:%s\n", acpi_name(h)); + } + return AE_OK; +} +static ACPI_STATUS acpi_process_prw(ACPI_HANDLE h, UINT32 level, void *context, void ** result) +{ + ACPI_BUFFER b; + char name[8]; + b.Pointer = name; + AcpiGetName(h, ACPI_SINGLE_NAME, &b); + if(strncmp(name, "_PRW", 4)== 0){ + printf("PRW:%s\n", acpi_name(h)); + acpi_device_enable_wake_capability(h, 1); + } + return AE_OK; +} /* * Handle a new device being added @@ -590,10 +620,11 @@ /* ISA compatibility */ case ISA_IVAR_VENDORID: case ISA_IVAR_SERIAL: - case ISA_IVAR_COMPATID: *(int *)result = -1; break; - + case ISA_IVAR_COMPATID: + *(int *)result = acpi_isa_get_compatid(child); + break; case ISA_IVAR_LOGICALID: *(int *)result = acpi_isa_get_logicalid(child); break; @@ -697,8 +728,33 @@ | (PNP_HEXTONUM(s[3]) << 20) \ | (PNP_HEXTONUM(s[6]) << 24) \ | (PNP_HEXTONUM(s[5]) << 28)) +#define MAX_VALID_EISAID 9 static u_int32_t +acpi_isa_get_compatid(device_t dev) +{ + ACPI_HANDLE h; + ACPI_OBJECT *obj; + ACPI_BUFFER resbuf; + char resbufbody[sizeof(ACPI_OBJECT) + MAX_VALID_EISAID +1]; + + /* + *resbuf size is allocated so that it can hold ACPI_OBJECT + *with EISAID string + */ + obj = (ACPI_OBJECT *)resbufbody; + resbuf.Length = sizeof(resbufbody); + resbuf.Pointer = resbufbody; + h = acpi_get_handle(dev); + if(ACPI_FAILURE(AcpiEvaluateObject(h, "_CID", NULL, &resbuf))) + return 0; + if(obj->Type == ACPI_TYPE_INTEGER) + return obj->Integer.Value; + else if(obj->Type == ACPI_TYPE_STRING) + return PNP_EISAID(obj->String.Pointer); + return 0; +} +static u_int32_t acpi_isa_get_logicalid(device_t dev) { ACPI_HANDLE h; @@ -730,7 +786,7 @@ acpi_isa_pnp_probe(device_t bus, device_t child, struct isa_pnp_id *ids) { int result; - u_int32_t pnpid; + u_int32_t pnpid, compatid; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -743,8 +799,10 @@ /* scan the supplied IDs for a match */ pnpid = acpi_isa_get_logicalid(child); + compatid = acpi_isa_get_compatid(child); while (ids && ids->ip_id) { - if (pnpid == ids->ip_id) { + if (pnpid == ids->ip_id|| + compatid == ids->ip_id) { result = 0; goto out; } @@ -894,7 +952,7 @@ acpi_shutdown_final(void *arg, int howto) { ACPI_STATUS status; - + ACPI_HANDLE h; ACPI_ASSERTLOCK; if (howto & RB_POWEROFF) { @@ -904,6 +962,9 @@ AcpiFormatException(status)); return; } + AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &h); + AcpiWalkNamespace(ACPI_TYPE_ANY,h, 100, acpi_process_prw, + NULL, NULL); if (ACPI_FAILURE(status = AcpiEnterSleepState(acpi_off_state))) { printf("ACPI power-off failed - %s\n", AcpiFormatException(status)); } else {