diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-07-01 10:27:35 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-07-01 10:27:35 +0000 |
commit | 022e3cf53110f765dc3aba906125e9a98db3169a (patch) | |
tree | 862c1cc471b50c0d1e7a37abe066a9166bc4aa08 /sys/dev/acpi | |
parent | c417ba9fd9c04ff57bbfa80e3015755625fe361f (diff) |
Add support for _DSD Device Properties.
ok mlarkin@
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpi.c | 46 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 4 |
2 files changed, 48 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 9e42f1899e6..ef23283a92a 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.350 2018/06/30 10:16:35 kettenis Exp $ */ +/* $OpenBSD: acpi.c,v 1.351 2018/07/01 10:27:34 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2875,6 +2875,50 @@ acpi_foundsony(struct aml_node *node, void *arg) return 0; } +/* Support for _DSD Device Properties. */ + +uint32_t +acpi_getpropint(struct aml_node *node, const char *prop, uint32_t defval) +{ + struct aml_value dsd; + int i; + + /* daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */ + static uint8_t prop_guid[] = { + 0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d, + 0x8a, 0x91, 0xbc, 0x9b, 0xbf, 0x4a, 0xa3, 0x01, + }; + + if (aml_evalname(acpi_softc, node, "_DSD", 0, NULL, &dsd)) + return defval; + + if (dsd.type != AML_OBJTYPE_PACKAGE || dsd.length != 2 || + dsd.v_package[0]->type != AML_OBJTYPE_BUFFER || + dsd.v_package[1]->type != AML_OBJTYPE_PACKAGE) + return defval; + + /* Check UUID. */ + if (dsd.v_package[0]->length != sizeof(prop_guid) || + memcmp(dsd.v_package[0]->v_buffer, prop_guid, + sizeof(prop_guid)) != 0) + return defval; + + /* Check properties. */ + for (i = 0; i < dsd.v_package[1]->length; i++) { + struct aml_value *res = dsd.v_package[1]->v_package[i]; + + if (res->type != AML_OBJTYPE_PACKAGE || res->length != 2 || + res->v_package[0]->type != AML_OBJTYPE_STRING || + res->v_package[1]->type != AML_OBJTYPE_INTEGER) + continue; + + if (strcmp(res->v_package[0]->v_string, prop) == 0) + return res->v_package[1]->v_integer; + } + + return defval; +} + int acpi_parsehid(struct aml_node *node, void *arg, char *outcdev, char *outdev, size_t devlen) diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 172daa7aa17..121a28edcdd 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.93 2018/06/29 17:39:18 kettenis Exp $ */ +/* $OpenBSD: acpivar.h,v 1.94 2018/07/01 10:27:34 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -365,6 +365,8 @@ void acpi_sleep(int, char *); int acpi_matchhids(struct acpi_attach_args *, const char *[], const char *); int acpi_parsehid(struct aml_node *, void *, char *, char *, size_t); +uint32_t acpi_getpropint(struct aml_node *, const char *, uint32_t); + int acpi_record_event(struct acpi_softc *, u_int); void acpi_addtask(struct acpi_softc *, void (*)(void *, int), void *, int); |