From 4fd5269d5c82856b3086a80f409d6817570cf585 Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 8 Jan 2024 19:52:29 +0000 Subject: [PATCH] Implement RootPathString support in the LoadTable() AML function. Fixes booting OpenBSD on some (ancient?) Hyper-V version. Tested by Henryk Paluch ok mlarkin@ --- sys/dev/acpi/acpi.c | 10 +++++----- sys/dev/acpi/dsdt.c | 21 ++++++++++++++------- sys/dev/acpi/dsdt.h | 6 +++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index ba6a3c468a4..70b67bb8fa7 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.425 2023/07/08 08:01:10 tobhe Exp $ */ +/* $OpenBSD: acpi.c,v 1.426 2024/01/08 19:52:29 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -1104,16 +1104,16 @@ acpi_attach_common(struct acpi_softc *sc, paddr_t base) printf(" !DSDT"); p_dsdt = entry->q_table; - acpi_parse_aml(sc, p_dsdt->aml, p_dsdt->hdr_length - - sizeof(p_dsdt->hdr)); + acpi_parse_aml(sc, NULL, p_dsdt->aml, + p_dsdt->hdr_length - sizeof(p_dsdt->hdr)); /* Load SSDT's */ SIMPLEQ_FOREACH(entry, &sc->sc_tables, q_next) { if (memcmp(entry->q_table, SSDT_SIG, sizeof(SSDT_SIG) - 1) == 0) { p_dsdt = entry->q_table; - acpi_parse_aml(sc, p_dsdt->aml, p_dsdt->hdr_length - - sizeof(p_dsdt->hdr)); + acpi_parse_aml(sc, NULL, p_dsdt->aml, + p_dsdt->hdr_length - sizeof(p_dsdt->hdr)); } } diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 1a5694c9e4b..24ebf445551 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.264 2021/12/09 20:21:35 patrick Exp $ */ +/* $OpenBSD: dsdt.c,v 1.265 2024/01/08 19:52:29 kettenis Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave * @@ -634,8 +634,9 @@ __aml_search(struct aml_node *root, uint8_t *nameseg, int create) SIMPLEQ_INIT(&node->son); SIMPLEQ_INSERT_TAIL(&root->son, node, sib); + return node; } - return node; + return NULL; } /* Get absolute pathname of AML node */ @@ -3742,8 +3743,6 @@ aml_loadtable(struct acpi_softc *sc, const char *signature, struct acpi_dsdt *p_dsdt; struct acpi_q *entry; - if (strlen(rootpath) > 0) - aml_die("LoadTable: RootPathString unsupported"); if (strlen(parameterpath) > 0) aml_die("LoadTable: ParameterPathString unsupported"); @@ -3755,8 +3754,8 @@ aml_loadtable(struct acpi_softc *sc, const char *signature, strncmp(hdr->oemtableid, oemtableid, sizeof(hdr->oemtableid)) == 0) { p_dsdt = entry->q_table; - acpi_parse_aml(sc, p_dsdt->aml, p_dsdt->hdr_length - - sizeof(p_dsdt->hdr)); + acpi_parse_aml(sc, rootpath, p_dsdt->aml, + p_dsdt->hdr_length - sizeof(p_dsdt->hdr)); return aml_allocvalue(AML_OBJTYPE_DDBHANDLE, 0, 0); } } @@ -4520,11 +4519,19 @@ parse_error: } int -acpi_parse_aml(struct acpi_softc *sc, uint8_t *start, uint32_t length) +acpi_parse_aml(struct acpi_softc *sc, const char *rootpath, + uint8_t *start, uint32_t length) { + struct aml_node *root = &aml_root; struct aml_scope *scope; struct aml_value res; + if (rootpath) { + root = aml_searchname(&aml_root, rootpath); + if (root == NULL) + aml_die("Invalid RootPathName %s\n", rootpath); + } + aml_root.start = start; memset(&res, 0, sizeof(res)); res.type = AML_OBJTYPE_SCOPE; diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h index 41633ced748..f63d8b4ac91 100644 --- a/sys/dev/acpi/dsdt.h +++ b/sys/dev/acpi/dsdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.h,v 1.80 2023/04/02 11:32:48 jsg Exp $ */ +/* $OpenBSD: dsdt.h,v 1.81 2024/01/08 19:52:29 kettenis Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -56,8 +56,8 @@ void aml_walktree(struct aml_node *); void aml_find_node(struct aml_node *, const char *, int (*)(struct aml_node *, void *), void *); -int acpi_parse_aml(struct acpi_softc *, u_int8_t *, - uint32_t); +int acpi_parse_aml(struct acpi_softc *, const char *, + u_int8_t *, uint32_t); void aml_register_notify(struct aml_node *, const char *, int (*)(struct aml_node *, int, void *), void *, int); -- 2.20.1