> Date: Wed, 20 Dec 2023 12:00:47 +0100
> From: Henryk Paluch <hpal...@seznam.cz>
> 
> Hello!
> 
>  > Ah, cool.  That is a bit of a heck though.  I did look into what is
>  > needed to fix this properly.  If I send you a diff, can you test it?
> 
> Feel free to send me patches. I will test them.
> 
> Best regards
>    --Henryk Paluch

Can you try the attached diff?


Index: dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.425
diff -u -p -r1.425 acpi.c
--- dev/acpi/acpi.c     8 Jul 2023 08:01:10 -0000       1.425
+++ dev/acpi/acpi.c     21 Dec 2023 16:37:18 -0000
@@ -1104,16 +1104,16 @@ acpi_attach_common(struct acpi_softc *sc
                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));
                }
        }
 
Index: dev/acpi/dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.264
diff -u -p -r1.264 dsdt.c
--- dev/acpi/dsdt.c     9 Dec 2021 20:21:35 -0000       1.264
+++ dev/acpi/dsdt.c     21 Dec 2023 16:37:18 -0000
@@ -634,8 +634,9 @@ __aml_search(struct aml_node *root, uint
 
                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, con
        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, con
                    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,10 +4519,18 @@ 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));
Index: dev/acpi/dsdt.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.h,v
retrieving revision 1.80
diff -u -p -r1.80 dsdt.h
--- dev/acpi/dsdt.h     2 Apr 2023 11:32:48 -0000       1.80
+++ dev/acpi/dsdt.h     21 Dec 2023 16:37:18 -0000
@@ -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);

Reply via email to