Index: trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- trunk/src/VBox/Runtime/Makefile.kmk	(revision 108014)
+++ trunk/src/VBox/Runtime/Makefile.kmk	(revision 108015)
@@ -395,4 +395,7 @@
 
 RuntimeBaseR3_SOURCES      := \
+	common/acpi/acpi.cpp \
+	common/acpi/acpi-compiler.cpp \
+	common/acpi/acpi-decompiler.cpp \
 	common/alloc/alloc.cpp \
 	common/alloc/heapsimple.cpp \
@@ -598,6 +601,4 @@
 	common/misc/RTMemWipeThoroughly.cpp \
 	common/misc/RTSystemFirmwareTypeName.cpp \
-	common/misc/acpi.cpp \
-	common/misc/acpi-decompiler.cpp \
 	common/misc/assert.cpp \
 	common/misc/buildconfig.cpp \
Index: trunk/src/VBox/Runtime/common/acpi/acpi-compiler.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/acpi/acpi-compiler.cpp	(revision 108015)
+++ trunk/src/VBox/Runtime/common/acpi/acpi-compiler.cpp	(revision 108015)
@@ -0,0 +1,719 @@
+/* $Id$ */
+/** @file
+ * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
+ */
+
+/*
+ * Copyright (C) 2025 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from https://www.virtualbox.org.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, in version 3 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses>.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
+ * in the VirtualBox distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP RTLOGGROUP_ACPI
+#include <iprt/acpi.h>
+#include <iprt/asm.h>
+#include <iprt/buildconfig.h>
+#include <iprt/ctype.h>
+#include <iprt/err.h>
+#include <iprt/file.h>
+#include <iprt/list.h>
+#include <iprt/mem.h>
+#include <iprt/script.h>
+#include <iprt/string.h>
+#include <iprt/uuid.h>
+
+#include <iprt/formats/acpi-aml.h>
+#include <iprt/formats/acpi-resources.h>
+
+#include "internal/acpi.h"
+
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+
+/**
+ * Terminals in the ACPI ASL lnaguage like keywords, operators and punctuators.
+ */
+typedef enum RTACPIASLTERMINAL
+{
+    RTACPIASLTERMINAL_INVALID = 0,
+    RTACPIASLTERMINAL_KEYWORD_DEFINITION_BLOCK,
+    RTACPIASLTERMINAL_KEYWORD_SCOPE,
+    RTACPIASLTERMINAL_KEYWORD_PROCESSOR,
+
+    RTACPIASLTERMINAL_KEYWORD_AND,
+    RTACPIASLTERMINAL_KEYWORD_ARRAY,
+    RTACPIASLTERMINAL_KEYWORD_ASM,
+    RTACPIASLTERMINAL_KEYWORD_BEGIN,
+    RTACPIASLTERMINAL_KEYWORD_BREAK,
+    RTACPIASLTERMINAL_KEYWORD_CASE,
+    RTACPIASLTERMINAL_KEYWORD_CONSTRUCTOR,
+    RTACPIASLTERMINAL_KEYWORD_CONST,
+    RTACPIASLTERMINAL_KEYWORD_CONTINUE,
+    RTACPIASLTERMINAL_KEYWORD_DESTRUCTOR,
+    RTACPIASLTERMINAL_KEYWORD_DIV,
+    RTACPIASLTERMINAL_KEYWORD_DOWNTO,
+    RTACPIASLTERMINAL_KEYWORD_DO,
+    RTACPIASLTERMINAL_KEYWORD_ELSE,
+    RTACPIASLTERMINAL_KEYWORD_END,
+    RTACPIASLTERMINAL_KEYWORD_FALSE,
+    RTACPIASLTERMINAL_KEYWORD_FILE,
+    RTACPIASLTERMINAL_KEYWORD_FOR,
+    RTACPIASLTERMINAL_KEYWORD_FUNCTION,
+    RTACPIASLTERMINAL_KEYWORD_GOTO,
+    RTACPIASLTERMINAL_KEYWORD_IF,
+    RTACPIASLTERMINAL_KEYWORD_IMPLEMENTATION,
+    RTACPIASLTERMINAL_KEYWORD_INTERFACE,
+    RTACPIASLTERMINAL_KEYWORD_INLINE,
+    RTACPIASLTERMINAL_KEYWORD_IN,
+    RTACPIASLTERMINAL_KEYWORD_LABEL,
+    RTACPIASLTERMINAL_KEYWORD_MOD,
+    RTACPIASLTERMINAL_KEYWORD_NIL,
+    RTACPIASLTERMINAL_KEYWORD_NOT,
+    RTACPIASLTERMINAL_KEYWORD_OBJECT,
+    RTACPIASLTERMINAL_KEYWORD_OF,
+    RTACPIASLTERMINAL_KEYWORD_ON,
+    RTACPIASLTERMINAL_KEYWORD_OPERATOR,
+    RTACPIASLTERMINAL_KEYWORD_OR,
+    RTACPIASLTERMINAL_KEYWORD_PACKED,
+    RTACPIASLTERMINAL_KEYWORD_PROCEDURE,
+    RTACPIASLTERMINAL_KEYWORD_PROGRAM,
+    RTACPIASLTERMINAL_KEYWORD_RECORD,
+    RTACPIASLTERMINAL_KEYWORD_REPEAT,
+    RTACPIASLTERMINAL_KEYWORD_SET,
+    RTACPIASLTERMINAL_KEYWORD_SHL,
+    RTACPIASLTERMINAL_KEYWORD_SHR,
+    RTACPIASLTERMINAL_KEYWORD_STRING,
+    RTACPIASLTERMINAL_KEYWORD_THEN,
+    RTACPIASLTERMINAL_KEYWORD_TO,
+    RTACPIASLTERMINAL_KEYWORD_TRUE,
+    RTACPIASLTERMINAL_KEYWORD_TYPE,
+    RTACPIASLTERMINAL_KEYWORD_UNIT,
+    RTACPIASLTERMINAL_KEYWORD_UNTIL,
+    RTACPIASLTERMINAL_KEYWORD_USES,
+    RTACPIASLTERMINAL_KEYWORD_VAR,
+    RTACPIASLTERMINAL_KEYWORD_WHILE,
+    RTACPIASLTERMINAL_KEYWORD_WITH,
+    RTACPIASLTERMINAL_KEYWORD_XOR,
+
+    RTACPIASLTERMINAL_OPERATOR_EQUALS,
+    RTACPIASLTERMINAL_OPERATOR_ASSIGN,
+    RTACPIASLTERMINAL_OPERATOR_UNEQUAL,
+    RTACPIASLTERMINAL_OPERATOR_GREATER_EQUAL,
+    RTACPIASLTERMINAL_OPERATOR_SMALLER_EQUAL,
+    RTACPIASLTERMINAL_OPERATOR_SHIFT_RIGHT,
+    RTACPIASLTERMINAL_OPERATOR_SHIFT_LEFT,
+    RTACPIASLTERMINAL_OPERATOR_GREATER,
+    RTACPIASLTERMINAL_OPERATOR_SMALLER,
+    RTACPIASLTERMINAL_OPERATOR_PLUS,
+    RTACPIASLTERMINAL_OPERATOR_MINUS,
+    RTACPIASLTERMINAL_OPERATOR_MUL,
+    RTACPIASLTERMINAL_OPERATOR_DIV,
+    RTACPIASLTERMINAL_OPERATOR_MOD,
+    RTACPIASLTERMINAL_OPERATOR_TILDE,
+    RTACPIASLTERMINAL_OPERATOR_NOT,
+
+    RTACPIASLTERMINAL_PUNCTUATOR_COMMA,
+    RTACPIASLTERMINAL_PUNCTUATOR_DOT,
+    RTACPIASLTERMINAL_PUNCTUATOR_OPEN_BRACKET,
+    RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET,
+    RTACPIASLTERMINAL_PUNCTUATOR_OPEN_CURLY_BRACKET,
+    RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET,
+
+} RTACPIASLTERMINAL;
+
+
+/**
+ * The ACPI ASL compilation unit state.
+ */
+typedef struct RTACPIASLCU
+{
+    /** The lexer handle. */
+    RTSCRIPTLEX             hLexSource;
+    /** The VFS I/O input stream. */
+    RTVFSIOSTREAM           hVfsIosIn;
+    /** The ACPI table handle. */
+    RTACPITBL               hAcpiTbl;
+    /** Error information. */
+    PRTERRINFO              pErrInfo;
+} RTACPIASLCU;
+/** Pointer to an ACPI ASL compilation unit state. */
+typedef RTACPIASLCU *PRTACPIASLCU;
+/** Pointer to a constant ACPI ASL compilation unit state. */
+typedef const RTACPIASLCU *PCRTACPIASLCU;
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+
+static DECLCALLBACK(int) rtAcpiAslLexerParseNumber(RTSCRIPTLEX hScriptLex, char ch, PRTSCRIPTLEXTOKEN pToken, void *pvUser);
+static DECLCALLBACK(int) rtAcpiAslLexerParseNameString(RTSCRIPTLEX hScriptLex, char ch, PRTSCRIPTLEXTOKEN pToken, void *pvUser);
+
+
+static const char *s_aszSingleStart[] =
+{
+    "//",
+    NULL
+};
+
+
+static const char *s_aszMultiStart[] =
+{
+    "/*",
+    NULL
+};
+
+
+static const char *s_aszMultiEnd[] =
+{
+    "*/",
+    NULL
+};
+
+
+static const RTSCRIPTLEXTOKMATCH s_aMatches[] =
+{
+    /* Keywords */
+    { RT_STR_TUPLE("DefinitionBlock"),          RTSCRIPTLEXTOKTYPE_KEYWORD,    true,  RTACPIASLTERMINAL_KEYWORD_DEFINITION_BLOCK       },
+    { RT_STR_TUPLE("Processor"),                RTSCRIPTLEXTOKTYPE_KEYWORD,    true,  RTACPIASLTERMINAL_KEYWORD_PROCESSOR              },
+    { RT_STR_TUPLE("Scope"),                    RTSCRIPTLEXTOKTYPE_KEYWORD,    true,  RTACPIASLTERMINAL_KEYWORD_SCOPE                  },
+
+    /* Punctuators */
+    { RT_STR_TUPLE(","),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_COMMA               },
+    { RT_STR_TUPLE("."),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_DOT                 },
+    { RT_STR_TUPLE("("),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_OPEN_BRACKET        },
+    { RT_STR_TUPLE(")"),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET       },
+    { RT_STR_TUPLE("{"),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_OPEN_CURLY_BRACKET  },
+    { RT_STR_TUPLE("}"),                        RTSCRIPTLEXTOKTYPE_PUNCTUATOR, false, RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET },
+    { NULL, 0,                                  RTSCRIPTLEXTOKTYPE_INVALID,    false, 0 }
+};
+
+
+static const RTSCRIPTLEXRULE s_aRules[] =
+{
+    { '\"', '\"',  RTSCRIPT_LEX_RULE_CONSUME, RTScriptLexScanStringLiteralC,      NULL},
+    { '0',  '9',   RTSCRIPT_LEX_RULE_CONSUME, rtAcpiAslLexerParseNumber,          NULL},
+    { 'A',  'Z',   RTSCRIPT_LEX_RULE_CONSUME, rtAcpiAslLexerParseNameString,      NULL},
+    { '_',  '_',   RTSCRIPT_LEX_RULE_CONSUME, rtAcpiAslLexerParseNameString,      NULL},
+    { '^',  '^',   RTSCRIPT_LEX_RULE_CONSUME, rtAcpiAslLexerParseNameString,      NULL},
+    { '\\',  '\\', RTSCRIPT_LEX_RULE_CONSUME, rtAcpiAslLexerParseNameString,      NULL},
+
+    { '\0', '\0',  RTSCRIPT_LEX_RULE_DEFAULT, NULL,                               NULL}
+};
+
+
+static const RTSCRIPTLEXCFG s_AslLexCfg =
+{
+    /** pszName */
+    "AcpiAsl",
+    /** pszDesc */
+    "ACPI ASL lexer",
+    /** fFlags */
+    RTSCRIPT_LEX_CFG_F_DEFAULT,
+    /** pszWhitespace */
+    NULL,
+    /** pszNewline */
+    NULL,
+    /** papszCommentMultiStart */
+    s_aszMultiStart,
+    /** papszCommentMultiEnd */
+    s_aszMultiEnd,
+    /** papszCommentSingleStart */
+    s_aszSingleStart,
+    /** paTokMatches */
+    s_aMatches,
+    /** paRules */
+    s_aRules,
+    /** pfnProdDef */
+    NULL,
+    /** pfnProdDefUser */
+    NULL
+};
+
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+
+static DECLCALLBACK(int) rtAcpiAslLexerParseNumber(RTSCRIPTLEX hScriptLex, char ch, PRTSCRIPTLEXTOKEN pToken, void *pvUser)
+{
+    RT_NOREF(ch, pvUser);
+    return RTScriptLexScanNumber(hScriptLex, 0 /*uBase*/, false /*fAllowReal*/, pToken);
+}
+
+
+static int rtAcpiAslLexerParseNameSeg(RTSCRIPTLEX hScriptLex, PRTSCRIPTLEXTOKEN pTok, char *pachNameSeg)
+{
+    /*
+     * A Nameseg consist of a lead character and up to 3 following characters A-Z, 0-9 or _.
+     * If the name segment is not 4 characters long the remainder is filled with _.
+     */
+    char ch = RTScriptLexGetCh(hScriptLex);
+    if (   ch != '_'
+        && (  ch < 'A'
+            || ch > 'Z'))
+        return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_INVALID_PARAMETER, "Lexer: Name segment starts with invalid character '%c'", ch);
+    RTScriptLexConsumeCh(hScriptLex);
+
+    /* Initialize the default name segment. */
+    pachNameSeg[0] = ch;
+    pachNameSeg[1] = '_';
+    pachNameSeg[2] = '_';
+    pachNameSeg[3] = '_';
+
+    for (uint8_t i = 1; i < 4; i++)
+    {
+        ch = RTScriptLexGetCh(hScriptLex);
+
+        /* Anything not belonging to the allowed characters terminates the parsing. */
+        if (   ch != '_'
+            && (  ch < 'A'
+                || ch > 'Z')
+            && (  ch < '0'
+                || ch > '9'))
+            return VINF_SUCCESS;
+        RTScriptLexConsumeCh(hScriptLex);
+        pachNameSeg[i] = ch;
+    } 
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) rtAcpiAslLexerParseNameString(RTSCRIPTLEX hScriptLex, char ch,
+                                                       PRTSCRIPTLEXTOKEN pTok, void *pvUser)
+{
+    RT_NOREF(pvUser);
+
+    char aszIde[513]; RT_ZERO(aszIde);
+    unsigned idx = 0;
+    aszIde[idx++] = ch;
+
+    if (ch == '^') /* PrefixPath */
+    {
+        ch = RTScriptLexGetCh(hScriptLex);
+        while (   idx < sizeof(aszIde) - 1
+               && ch == '^')
+        {
+            RTScriptLexConsumeCh(hScriptLex);
+            aszIde[idx++] = ch;
+            ch = RTScriptLexGetCh(hScriptLex);
+        }
+
+        if (idx == sizeof(aszIde) - 1)
+            return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_BUFFER_OVERFLOW, "Lexer: PrefixPath exceeds the allowed length");
+    } 
+
+    /* Now there is only a sequence of NameSeg allowed (separated by the . separator). */
+    while (idx < sizeof(aszIde) - 1 - 4)
+    {
+        char achNameSeg[4];
+        int rc = rtAcpiAslLexerParseNameSeg(hScriptLex, pTok, &achNameSeg[0]);
+        if (RT_FAILURE(rc))
+            return rc;
+
+        aszIde[idx++] = achNameSeg[0];
+        aszIde[idx++] = achNameSeg[1];
+        aszIde[idx++] = achNameSeg[2];
+        aszIde[idx++] = achNameSeg[3];
+
+        ch = RTScriptLexGetCh(hScriptLex);
+        if (ch != '.')
+            break;
+    }
+
+    if (idx == sizeof(aszIde) - 1)
+        return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_BUFFER_OVERFLOW, "Lexer: Identifier exceeds the allowed length");
+
+    return RTScriptLexProduceTokIde(hScriptLex, pTok, &aszIde[0], idx);
+}
+
+
+static DECLCALLBACK(int) rtAcpiAslLexerRead(RTSCRIPTLEX hScriptLex, size_t offBuf, char *pchCur,
+                                            size_t cchBuf, size_t *pcchRead, void *pvUser)
+{
+    PCRTACPIASLCU pThis = (PCRTACPIASLCU)pvUser;
+    RT_NOREF(hScriptLex, offBuf);
+
+    size_t cbRead = 0;
+    int rc = RTVfsIoStrmRead(pThis->hVfsIosIn, pchCur, cchBuf, true /*fBlocking*/, &cbRead);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    *pcchRead = cbRead * sizeof(char);
+    if (!cbRead)
+        return VINF_EOF;
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslLexerConsumeIfKeyword(PCRTACPIASLCU pThis, RTACPIASLTERMINAL enmTerm, bool *pfConsumed)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query keyword token with %Rrc", rc);
+
+    if (   pTok->enmType == RTSCRIPTLEXTOKTYPE_KEYWORD
+        && pTok->Type.Keyword.pKeyword->u64Val == enmTerm)
+    {
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        *pfConsumed = true;
+        return VINF_SUCCESS;
+    }
+
+    *pfConsumed = false;
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslLexerConsumeIfPunctuator(PCRTACPIASLCU pThis, RTACPIASLTERMINAL enmTerm, bool *pfConsumed)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query punctuator token with %Rrc", rc);
+
+    if (   pTok->enmType == RTSCRIPTLEXTOKTYPE_PUNCTUATOR
+        && pTok->Type.Keyword.pKeyword->u64Val == enmTerm)
+    {
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        *pfConsumed = true;
+        return VINF_SUCCESS;
+    }
+
+    *pfConsumed = false;
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslLexerConsumeIfStringLit(PCRTACPIASLCU pThis, const char **ppszStrLit)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query string literal token with %Rrc", rc);
+
+    if (pTok->enmType == RTSCRIPTLEXTOKTYPE_STRINGLIT)
+    {
+        *ppszStrLit = pTok->Type.StringLit.pszString;
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        return VINF_SUCCESS;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslLexerConsumeIfIdentifier(PCRTACPIASLCU pThis, const char **ppszIde)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query string literal token with %Rrc", rc);
+
+    if (pTok->enmType == RTSCRIPTLEXTOKTYPE_IDENTIFIER)
+    {
+        *ppszIde = pTok->Type.Id.pszIde;
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        return VINF_SUCCESS;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslLexerConsumeIfNatural(PCRTACPIASLCU pThis, uint64_t *pu64, bool *pfConsumed)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query punctuator token with %Rrc", rc);
+
+    if (   pTok->enmType == RTSCRIPTLEXTOKTYPE_NUMBER
+        && pTok->Type.Number.enmType == RTSCRIPTLEXTOKNUMTYPE_NATURAL)
+    {
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        *pfConsumed = true;
+        *pu64 = pTok->Type.Number.Type.u64;
+        return VINF_SUCCESS;
+    }
+
+    *pfConsumed = false;
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiAslParserConsumeEos(PCRTACPIASLCU pThis)
+{
+    PCRTSCRIPTLEXTOKEN pTok;
+    int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pThis->pErrInfo, rc, "Lexer: Failed to query punctuator token with %Rrc", rc);
+
+    if (pTok->enmType == RTSCRIPTLEXTOKTYPE_EOS)
+    {
+        RTScriptLexConsumeToken(pThis->hLexSource);
+        return VINF_SUCCESS;
+    }
+
+    return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER,
+                         "Parser: Found unexpected token after final closing }, expected end of stream");
+}
+
+
+/* Some parser helper macros. */
+#define RTACPIASL_PARSE_KEYWORD(a_enmKeyword, a_pszKeyword) \
+    do { \
+        bool fConsumed = false; \
+        int rc2 = rtAcpiAslLexerConsumeIfKeyword(pThis, a_enmKeyword, &fConsumed); \
+        if (RT_FAILURE(rc2)) \
+            return rc2; \
+        if (!fConsumed) \
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Expected keyword '%s'", a_pszKeyword); \
+    } while(0)
+
+#define RTACPIASL_PARSE_PUNCTUATOR(a_enmPunctuator, a_chPunctuator) \
+    do { \
+        bool fConsumed = false; \
+        int rc2 = rtAcpiAslLexerConsumeIfPunctuator(pThis, a_enmPunctuator, &fConsumed); \
+        if (RT_FAILURE(rc2)) \
+            return rc2; \
+        if (!fConsumed) \
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Expected punctuator '%c'", a_chPunctuator); \
+    } while(0)
+
+#define RTACPIASL_PARSE_STRING_LIT(a_pszStrLit) \
+    const char *a_pszStrLit = NULL; \
+    do { \
+        int rc2 = rtAcpiAslLexerConsumeIfStringLit(pThis, &a_pszStrLit); \
+        if (RT_FAILURE(rc2)) \
+            return rc2; \
+        if (!a_pszStrLit) \
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Expected a string literal"); \
+    } while(0)
+
+#define RTACPIASL_PARSE_NAME_STRING(a_pszIde) \
+    const char *a_pszIde = NULL; \
+    do { \
+        int rc2 = rtAcpiAslLexerConsumeIfIdentifier(pThis, &a_pszIde); \
+        if (RT_FAILURE(rc2)) \
+            return rc2; \
+        if (!a_pszIde) \
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Expected an identifier"); \
+    } while(0)
+
+#define RTACPIASL_PARSE_NATURAL(a_u64) \
+    uint64_t a_u64 = 0; \
+    do { \
+        bool fConsumed = false; \
+        int rc2 = rtAcpiAslLexerConsumeIfNatural(pThis, &a_u64, &fConsumed); \
+        if (RT_FAILURE(rc2)) \
+            return rc2; \
+        if (!fConsumed) \
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Expected a natural number"); \
+    } while(0)
+
+static int rtAcpiTblAslParseInner(PRTACPIASLCU pThis);
+
+static int rtAcpiTblAslParseTerminal(PRTACPIASLCU pThis, RTACPIASLTERMINAL enmTerminal)
+{
+    int rc = VINF_SUCCESS;
+
+    switch (enmTerminal)
+    {
+        case RTACPIASLTERMINAL_KEYWORD_SCOPE:
+        {
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_BRACKET, '(');
+            RTACPIASL_PARSE_NAME_STRING(pszName);
+            RT_NOREF(pszName);
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_CURLY_BRACKET, '{');
+            rc = rtAcpiTblAslParseInner(pThis);
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET, '}');
+            break;
+        }
+        case RTACPIASLTERMINAL_KEYWORD_PROCESSOR:
+        {
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_BRACKET, '(');
+            RTACPIASL_PARSE_NAME_STRING(pszName);
+            RT_NOREF(pszName);
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+            AssertFailed();
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_CURLY_BRACKET, '{');
+            rc = rtAcpiTblAslParseInner(pThis);
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET, '}');
+            break;
+        }
+        default:
+            rc = RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Unexpected keyword encountered");
+            break;
+    }
+
+    return rc;
+}
+
+
+static int rtAcpiTblAslParseInner(PRTACPIASLCU pThis)
+{
+    for (;;)
+    {
+        PCRTSCRIPTLEXTOKEN pTok;
+        int rc = RTScriptLexQueryToken(pThis->hLexSource, &pTok);
+        if (RT_FAILURE(rc))
+            return RTErrInfoSetF(pThis->pErrInfo, rc, "Parser: Failed to query next token with %Rrc", rc);
+
+        if (   pTok->enmType == RTSCRIPTLEXTOKTYPE_PUNCTUATOR
+            && pTok->Type.Keyword.pKeyword->u64Val == RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET)
+            return VINF_SUCCESS;
+
+        if (pTok->enmType == RTSCRIPTLEXTOKTYPE_EOS)
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Unexpected end of stream");
+        if (pTok->enmType != RTSCRIPTLEXTOKTYPE_KEYWORD)
+            return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Parser: Unexpected token encountered");
+
+        RTACPIASLTERMINAL enmKeyword = (RTACPIASLTERMINAL)pTok->Type.Keyword.pKeyword->u64Val;
+        RTScriptLexConsumeToken(pThis->hLexSource);
+
+        rc = rtAcpiTblAslParseTerminal(pThis, enmKeyword);
+        if (RT_FAILURE(rc))
+            return rc;
+    }
+}
+
+
+static int rtAcpiTblAslParserParse(PRTACPIASLCU pThis)
+{
+    /*
+     * The first keyword must be DefinitionBlock:
+     *
+     *     DefinitionBlock ("SSDT.aml", "SSDT", 1, "VBOX  ", "VBOXCPUT", 2)
+     */
+    RTACPIASL_PARSE_KEYWORD(RTACPIASLTERMINAL_KEYWORD_DEFINITION_BLOCK, "DefinitionBlock");
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_BRACKET, '(');
+    RTACPIASL_PARSE_STRING_LIT(pszOutFile);
+    RT_NOREF(pszOutFile); /* We ignore the output file hint. */
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+    RTACPIASL_PARSE_STRING_LIT(pszTblSig);
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+    RTACPIASL_PARSE_NATURAL(u64ComplianceRev);
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+    RTACPIASL_PARSE_STRING_LIT(pszOemId);
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+    RTACPIASL_PARSE_STRING_LIT(pszOemTblId);
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_COMMA, ',');
+    RTACPIASL_PARSE_NATURAL(u64OemRev);
+    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
+
+    /* Some additional checks. */
+    uint32_t u32TblSig = ACPI_TABLE_HDR_SIGNATURE_MISC;
+    if (!strcmp(pszTblSig, "DSDT"))
+        u32TblSig = ACPI_TABLE_HDR_SIGNATURE_DSDT;
+    else if (!strcmp(pszTblSig, "SSDT"))
+        u32TblSig = ACPI_TABLE_HDR_SIGNATURE_SSDT;
+
+    if (u32TblSig == ACPI_TABLE_HDR_SIGNATURE_MISC)
+        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Table signature must be either 'DSDT' or 'SSDT': %s", pszTblSig);
+
+    if (u64ComplianceRev > UINT8_MAX)
+        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "Compliance revision %RU64 is out of range, must be in range [0..255]");
+
+    if (strlen(pszOemId) > 6)
+        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "OEM ID string must be at most 6 characters long");
+
+    if (strlen(pszOemTblId) > 8)
+        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "OEM table ID string must be at most 8 characters long");
+
+    if (u64OemRev > UINT32_MAX)
+        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER, "OEM revision ID %RU64 is out of range, must fit into 32-bit unsigned integer");
+
+    int rc = RTAcpiTblCreate(&pThis->hAcpiTbl, u32TblSig, (uint8_t)u64ComplianceRev, pszOemId,
+                             pszOemTblId, (uint32_t)u64OemRev, "VBOX", RTBldCfgRevision());
+    if (RT_SUCCESS(rc))
+    {
+        RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_OPEN_CURLY_BRACKET, '{');
+        rc = rtAcpiTblAslParseInner(pThis);
+        if (RT_SUCCESS(rc))
+        {
+            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET, '}');
+            rc = rtAcpiAslParserConsumeEos(pThis); /* No junk after the final closing bracket. */
+        }
+    }
+
+    return rc;
+}
+
+
+DECLHIDDEN(int) rtAcpiTblConvertFromAslToAml(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo)
+{
+    int rc;
+    PRTACPIASLCU pThis = (PRTACPIASLCU)RTMemAllocZ(sizeof(*pThis));
+    if (pThis)
+    {
+        pThis->hVfsIosIn  = hVfsIosIn;
+        pThis->pErrInfo   = pErrInfo;
+
+        rc = RTScriptLexCreateFromReader(&pThis->hLexSource, rtAcpiAslLexerRead,
+                                         NULL /*pfnDtor*/, pThis /*pvUser*/, 0 /*cchBuf*/,
+                                         NULL /*phStrCacheId*/, NULL /*phStrCacheStringLit*/,
+                                         &s_AslLexCfg);
+        if (RT_SUCCESS(rc))
+        {
+            rc = rtAcpiTblAslParserParse(pThis);
+            if (RT_SUCCESS(rc))
+            {
+                /* 2. - Optimize AST (constant folding, etc). */
+                /* 3. - Traverse AST and output table. */
+                RT_NOREF(hVfsIosOut);
+            }
+
+            /** @todo Destroy AST. */
+            RTScriptLexDestroy(pThis->hLexSource);
+        }
+        else
+            rc = RTErrInfoSetF(pErrInfo, rc, "Creating the ASL lexer failed with %Rrc", rc);
+
+        RTMemFree(pThis);
+    }
+    else
+        rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Out of memory allocating the ASL compilation unit state");
+
+    return rc;
+}
Index: trunk/src/VBox/Runtime/common/acpi/acpi-decompiler.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/acpi/acpi-decompiler.cpp	(revision 108015)
+++ trunk/src/VBox/Runtime/common/acpi/acpi-decompiler.cpp	(revision 108015)
@@ -0,0 +1,1705 @@
+/* $Id$ */
+/** @file
+ * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
+ */
+
+/*
+ * Copyright (C) 2025 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from https://www.virtualbox.org.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, in version 3 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses>.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
+ * in the VirtualBox distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP RTLOGGROUP_ACPI
+#include <iprt/acpi.h>
+#include <iprt/asm.h>
+#include <iprt/ctype.h>
+#include <iprt/err.h>
+#include <iprt/file.h>
+#include <iprt/list.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+#include <iprt/uuid.h>
+
+#include <iprt/formats/acpi-aml.h>
+#include <iprt/formats/acpi-resources.h>
+
+#include "internal/acpi.h"
+
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+
+
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+
+
+/**
+ * AML object type.
+ */
+typedef enum RTACPITBLAMLOBJTYPE
+{
+    /** Invalid object type. */
+    kAcpiAmlObjType_Invalid = 0,
+    /** Unknown object type. */
+    kAcpiAmlObjType_Unknown,
+    /** Method object type. */
+    kAcpiAmlObjType_Method,
+    /** 32bit hack. */
+    kAcpiAmlObjType_32Bit_Hack = 0x7fffffff
+} RTACPITBLAMLOBJTYPE;
+
+
+/**
+ * Known object in namespace.
+ */
+typedef struct RTACPITBLAMLOBJ
+{
+    /** List node. */
+    RTLISTNODE          NdObjs;
+    /** Object Type. */
+    RTACPITBLAMLOBJTYPE enmType;
+    /** Additional data depending on the type. */
+    union
+    {
+        /** Method object argument count. */
+        uint32_t        cMethodArgs;
+    } u;
+    /** Zero terminated object name - variable in size. */
+    char                szName[1];
+} RTACPITBLAMLOBJ;
+typedef RTACPITBLAMLOBJ *PRTACPITBLAMLOBJ;
+typedef const RTACPITBLAMLOBJ *PCRTACPITBLAMLOBJ;
+
+
+
+/**
+ * ACPI AML -> ASL decoder state.
+ */
+typedef struct RTACPITBLAMLDECODE
+{
+    /** Pointe to the raw table data. */
+    const uint8_t *pbTbl;
+    /** Size of the table. */
+    uint32_t      cbTbl;
+    /** Offset into the table. */
+    uint32_t      offTbl;
+    /** Current stack level. */
+    uint32_t      iLvl;
+    /** Number of entries in the package stack. */
+    uint32_t      cPkgStackMax;
+    /** Stack of package lengths. */
+    size_t        *pacbPkgLeft;
+    /** Stack of original package lengths. */
+    size_t        *pacbPkg;
+    /** Flag whether to indent. */
+    bool          fIndent;
+    /** List of known objects. */
+    RTLISTANCHOR  LstObjs;
+} RTACPITBLAMLDECODE;
+/** Pointer to a ACPI AML -> ASL decoder state. */
+typedef RTACPITBLAMLDECODE *PRTACPITBLAMLDECODE;
+
+
+/**
+ * ACPI AML -> ASL decode callback
+ *
+ * @returns IPRT status code.
+ * @param   pThis               ACPI table decoder state.
+ * @param   hVfsIosOut          VFS I/O stream output handle.
+ * @param   bOp                 The opcode.
+ * @param   pErrInfo            Where to return additional error information.
+ */
+typedef DECLCALLBACKTYPE(int, FNRTACPITBLAMLOPCDECODE,(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo));
+/** Pointer to a ACPI AML -> ASL decode callback. */
+typedef FNRTACPITBLAMLOPCDECODE *PFNRTACPITBLAMLOPCDECODE;
+
+
+typedef enum ACPIAMLOPCTYPE
+{
+    kAcpiAmlOpcType_Invalid = 0,
+    kAcpiAmlOpcType_Byte,
+    kAcpiAmlOpcType_Word,
+    kAcpiAmlOpcType_DWord,
+    kAcpiAmlOpcType_NameString,
+    kAcpiAmlOpcType_TermArg,
+    kAcpiAmlOpcType_SuperName,
+    kAcpiAmlOpcType_32BitHack = 0x7fffffff
+} ACPIAMLOPCTYPE;
+
+
+typedef struct RTACPIAMLOPC
+{
+    /** Name of the opcode. */
+    const char               *pszOpc;
+    /** Flags for the opcode. */
+    uint32_t                 fFlags;
+    /** Opcode type for the fields following. */
+    ACPIAMLOPCTYPE           aenmTypes[5];
+    /** Optional decoder callback. */
+    PFNRTACPITBLAMLOPCDECODE pfnDecode;
+} RTACPIAMLOPC;
+typedef RTACPIAMLOPC *PRTACPIAMLOPC;
+typedef const RTACPIAMLOPC *PCRTACPIAMLOPC;
+
+#define RTACPI_AML_OPC_F_NONE           0
+#define RTACPI_AML_OPC_F_HAS_PKG_LENGTH RT_BIT_32(0)
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+
+static int rtAcpiTblAmlDecodeTerminal(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo);
+
+
+DECLINLINE(int) rtAcpiTblAmlDecodeReadU8(PRTACPITBLAMLDECODE pThis, uint8_t *pb, PRTERRINFO pErrInfo)
+{
+    if (pThis->offTbl < pThis->cbTbl)
+    { /* probable */ }
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read a byte", pThis->offTbl);
+
+    if (!pThis->pacbPkgLeft[pThis->iLvl])
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
+
+    pThis->pacbPkgLeft[pThis->iLvl]--;
+
+    *pb = pThis->pbTbl[pThis->offTbl++];
+    return VINF_SUCCESS;
+}
+
+
+#if 0
+DECLINLINE(int) rtAcpiTblAmlDecodeSkipU8IfEqual(PRTACPITBLAMLDECODE pThis, uint8_t ch, bool *fSkipped, PRTERRINFO pErrInfo)
+{
+    if (pThis->offTbl < pThis->cbTbl)
+    { /* probable */ }
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read a byte", pThis->offTbl);
+
+    if (pThis->pbTbl[pThis->offTbl] == ch)
+    {
+        pThis->offTbl++;
+        *pfSkipped = true;
+    }
+    else
+        *pfSkipped = false;
+    return VINF_SUCCESS;
+}
+#endif
+
+
+DECLINLINE(int) rtAcpiTblAmlDecodeReadU16(PRTACPITBLAMLDECODE pThis, uint16_t *pu16, PRTERRINFO pErrInfo)
+{
+    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint16_t))
+    { /* probable */ }
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read two bytes", pThis->offTbl);
+
+    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint16_t))
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
+
+    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint16_t);
+
+    *pu16 =  pThis->pbTbl[pThis->offTbl++];
+    *pu16 |= (uint16_t)pThis->pbTbl[pThis->offTbl++] << 8;
+    return VINF_SUCCESS;
+}
+
+
+DECLINLINE(int) rtAcpiTblAmlDecodeReadU32(PRTACPITBLAMLDECODE pThis, uint32_t *pu32, PRTERRINFO pErrInfo)
+{
+    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint32_t))
+    { /* probable */ }
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read four bytes", pThis->offTbl);
+
+    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint32_t))
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
+
+    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint32_t);
+
+    *pu32 =  pThis->pbTbl[pThis->offTbl++];
+    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] <<  8;
+    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] << 16;
+    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] << 24;
+    return VINF_SUCCESS;
+}
+
+
+DECLINLINE(int) rtAcpiTblAmlDecodeReadU64(PRTACPITBLAMLDECODE pThis, uint64_t *pu64, PRTERRINFO pErrInfo)
+{
+    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint64_t))
+    { /* probable */ }
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read eight bytes", pThis->offTbl);
+
+    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint64_t))
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
+
+    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint64_t);
+
+    *pu64 =  pThis->pbTbl[pThis->offTbl++];
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] <<  8;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 16;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 24;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 32;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 40;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 48;
+    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 54;
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeNameSeg(PRTACPITBLAMLDECODE pThis, char *pszNameString, PRTERRINFO pErrInfo)
+{
+    uint8_t abNameSeg[4];
+    for (uint8_t i = 0; i < sizeof(abNameSeg); i++)
+    {
+        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &abNameSeg[i], pErrInfo);
+        if (RT_FAILURE(rc)) return rc;
+    }
+
+    /* LeadNameChar */
+    if (   abNameSeg[0] != '_'
+        && !RTLocCIsUpper(abNameSeg[0]))
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid lead name character '%#02RX8'", abNameSeg[0]);
+
+    for (uint8_t i = 1; i < sizeof(abNameSeg); i++)
+    {
+        if (   abNameSeg[i] != '_'
+            && !RTLocCIsUpper(abNameSeg[i])
+            && !RTLocCIsDigit(abNameSeg[i]))
+            return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid name character '%#02RX8", abNameSeg[i]);
+    }
+
+    pszNameString[0] = (char)abNameSeg[0];
+    pszNameString[1] = (char)abNameSeg[1];
+    pszNameString[2] = (char)abNameSeg[2];
+    pszNameString[3] = (char)abNameSeg[3];
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeNameSegWithoutLeadChar(PRTACPITBLAMLDECODE pThis, uint8_t bLeadChar, char *pszNameString, PRTERRINFO pErrInfo)
+{
+    uint8_t abNameSeg[3];
+    for (uint8_t i = 0; i < sizeof(abNameSeg); i++)
+    {
+        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &abNameSeg[i], pErrInfo);
+        if (RT_FAILURE(rc)) return rc;
+    }
+
+    /* LeadNameChar */
+    if (   bLeadChar != '_'
+        && !RTLocCIsUpper(bLeadChar))
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid lead name character '%#02RX8'", bLeadChar);
+
+    for (uint8_t i = 1; i < sizeof(abNameSeg); i++)
+    {
+        if (   abNameSeg[i] != '_'
+            && !RTLocCIsUpper(abNameSeg[i])
+            && !RTLocCIsDigit(abNameSeg[i]))
+            return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid name character '%#02RX8'", abNameSeg[i]);
+    }
+
+    pszNameString[0] = (char)bLeadChar;
+    pszNameString[1] = (char)abNameSeg[0];
+    pszNameString[2] = (char)abNameSeg[1];
+    pszNameString[3] = (char)abNameSeg[2];
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeNameStringWithLead(PRTACPITBLAMLDECODE pThis, uint8_t bLeadChar, char *pszNameString, size_t cchNameString, size_t *pcbNameString, PRTERRINFO pErrInfo)
+{
+    AssertReturn(cchNameString >= 5, VERR_INVALID_PARAMETER); /* One name segment is at least 4 bytes (+ terminator). */
+
+    /* Check for a root path. */
+    int rc = VINF_SUCCESS;
+    uint8_t bTmp = bLeadChar;
+    size_t idxName = 0;
+    if (bTmp == '\\')
+    {
+        pszNameString[idxName++] = '\\';
+
+        rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+        if (RT_FAILURE(rc)) return rc;
+    }
+    else if (bTmp == '^')
+    {
+        /* Prefix path, can have multiple ^ prefixes. */
+        pszNameString[idxName++] = '^';
+
+        for (;;)
+        {
+            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+            if (RT_FAILURE(rc)) return rc;
+
+            if (bTmp != '^')
+                break;
+
+            if (idxName == cchNameString - 1)
+                return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "PrefixPath in AML byte stream is too long to fit into a %zu byte buffer",
+                                     cchNameString - 1);
+
+            pszNameString[idxName++] = '^';
+        }
+    }
+
+    if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_DUAL_NAME)
+    {
+        if (idxName + 8 < cchNameString)
+        {
+            rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName], pErrInfo);
+            if (RT_FAILURE(rc)) return rc;
+
+            rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName + 4], pErrInfo);
+            if (RT_FAILURE(rc)) return rc;
+
+            idxName += 8;
+            pszNameString[idxName] = '\0';
+        }
+        else
+            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "DualNamePrefix string in AML byte stream is too long to fit into a %zu byte buffer",
+                               cchNameString - 1);
+    }
+    else if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_MULTI_NAME)
+    {
+        uint8_t cSegs = 0;
+        rc = rtAcpiTblAmlDecodeReadU8(pThis, &cSegs, pErrInfo);
+        if (RT_FAILURE(rc)) return rc;
+
+        if (idxName + cSegs * 4 < cchNameString)
+        {
+            for (uint8_t i = 0; i < cSegs; i++)
+            {
+                rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName + i * 4], pErrInfo);
+                if (RT_FAILURE(rc)) return rc;
+            }
+
+            idxName += cSegs * 4;
+            pszNameString[idxName] = '\0';
+        }
+        else
+            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "MultiNamePrefix string in AML byte stream is too long to fit into a %zu byte buffer",
+                               cchNameString - 1);
+    }
+    else if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_NULL_NAME)
+        pszNameString[idxName] = '\0';
+    else
+    {
+        if (idxName + 4 < cchNameString)
+        {
+            rc = rtAcpiTblAmlDecodeNameSegWithoutLeadChar(pThis, bTmp, &pszNameString[idxName], pErrInfo);
+            if (RT_FAILURE(rc)) return rc;
+
+            idxName += 4;
+            pszNameString[idxName] = '\0';
+        }
+        else
+            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "Name string in AML byte stream is too long to fit into a %zu byte buffer",
+                               cchNameString - 1);
+    }
+
+    *pcbNameString = idxName;
+    return rc;
+}
+
+
+static int rtAcpiTblAmlDecodeNameString(PRTACPITBLAMLDECODE pThis, char *pszNameString, size_t cchNameString, size_t *pcbNameString, PRTERRINFO pErrInfo)
+{
+    AssertReturn(cchNameString >= 5, VERR_INVALID_PARAMETER); /* One name segment is at least 4 bytes (+ terminator). */
+
+    uint8_t bLead = 0; /* shut up gcc */
+    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bLead, pErrInfo);
+    if (RT_FAILURE(rc)) return rc;
+
+    return rtAcpiTblAmlDecodeNameStringWithLead( pThis, bLead, pszNameString, cchNameString, pcbNameString, pErrInfo);
+}
+
+
+/**
+ * Adds the proper indentation before a new line.
+ *
+ * @returns IPRT status code.
+ * @param   hVfsIos         The VFS I/O stream handle to dump the ASL to.
+ * @param   uIndentLvl      The level of indentation.
+ */
+static int rtAcpiTblAmlDecodeIndent(RTVFSIOSTREAM hVfsIos, uint32_t uIndentLvl)
+{
+    ssize_t cch = RTVfsIoStrmPrintf(hVfsIos, "\n");
+    if (cch != 1)
+        return cch < 0 ? (int)cch : VERR_BUFFER_UNDERFLOW;
+
+    while (uIndentLvl--)
+    {
+        cch = RTVfsIoStrmPrintf(hVfsIos, "    ");
+        if (cch != 4)
+            return cch < 0 ? (int)cch : VERR_BUFFER_UNDERFLOW;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeFormat(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIos, const char *pszFmt, ...)
+{
+    int rc = VINF_SUCCESS;
+    if (pThis->fIndent)
+        rc = rtAcpiTblAmlDecodeIndent(hVfsIos, pThis->iLvl);
+    if (RT_SUCCESS(rc))
+    {
+        va_list VaArgs;
+        va_start(VaArgs, pszFmt);
+        ssize_t cch = RTVfsIoStrmPrintfV(hVfsIos, pszFmt, VaArgs);
+        va_end(VaArgs);
+        if (cch <= 0)
+            rc = cch < 0 ? (int)cch : VERR_NO_MEMORY;
+    }
+
+    return rc;
+}
+
+
+static int rtAcpiTblAmlDecodePkgLength(PRTACPITBLAMLDECODE pThis, size_t *pcbPkg, size_t *pcbPkgLength, PRTERRINFO pErrInfo)
+{
+    uint8_t bTmp = 0; /* shut up gcc */
+    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    /* High 2 bits give the remaining bytes following to form the final package length. */
+    uint8_t cBytesRemaining = (bTmp >> 6) & 0x3;
+    *pcbPkgLength = 1 + cBytesRemaining;
+
+    if (cBytesRemaining)
+    {
+        size_t cbPkg = bTmp & 0xf;
+        for (uint8_t i = 0; i < cBytesRemaining; i++)
+        {
+            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            cbPkg |= (size_t)bTmp << (i * 8 + 4);
+            *pcbPkg = cbPkg;
+        }
+    }
+    else
+        *pcbPkg = bTmp & 0x3f;
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodePkgPush(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, size_t cbPkg, PRTERRINFO pErrInfo)
+{
+    /* Get a new stack element. */
+    if (pThis->iLvl == pThis->cPkgStackMax)
+    {
+        uint32_t const cPkgElemsNew = pThis->cPkgStackMax + 8;
+        size_t *pacbPkgLeftNew = (size_t *)RTMemRealloc(pThis->pacbPkgLeft, 2 * cPkgElemsNew * sizeof(*pacbPkgLeftNew));
+        if (!pacbPkgLeftNew)
+            return RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Out of memory pushing a new package onto the stack");
+
+        pThis->pacbPkgLeft  = pacbPkgLeftNew;
+        pThis->pacbPkg      = pacbPkgLeftNew + cPkgElemsNew;
+        pThis->cPkgStackMax = cPkgElemsNew;
+    }
+
+    uint32_t const iLvlNew = pThis->iLvl + 1;
+    pThis->pacbPkgLeft[iLvlNew] = cbPkg;
+    pThis->pacbPkg[iLvlNew]     = cbPkg;
+    int rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "{");
+    pThis->iLvl = iLvlNew;
+    return rc;
+}
+
+
+DECLINLINE(int) rtAcpiTblAmlDecodePkgPop(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
+{
+    while (!pThis->pacbPkgLeft[pThis->iLvl])
+    {
+        size_t cbPkg = pThis->pacbPkg[pThis->iLvl];
+        pThis->iLvl--;
+
+        if (pThis->pacbPkgLeft[pThis->iLvl] < cbPkg)
+            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "AML contains invalid package length encoding");
+
+        pThis->pacbPkgLeft[pThis->iLvl] -= cbPkg;
+        int rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "}");
+        if (RT_FAILURE(rc))
+            return rc;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeIntegerFromPrefix(PRTACPITBLAMLDECODE pThis, uint8_t bPrefix, uint64_t *pu64, size_t cbDecodeMax, size_t *pcbDecoded, PRTERRINFO pErrInfo)
+{
+    switch (bPrefix)
+    {
+        case ACPI_AML_BYTE_CODE_PREFIX_BYTE:
+        {
+            if (!cbDecodeMax)
+                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode byte integer in AML stream");
+
+            uint8_t bInt = 0;
+            int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bInt, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            *pu64       = bInt;
+            *pcbDecoded = 2;
+            break;
+        }
+        case ACPI_AML_BYTE_CODE_PREFIX_WORD:
+        {
+            if (cbDecodeMax < 2)
+                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode word integer in AML stream");
+
+            uint16_t u16 = 0;
+            int rc = rtAcpiTblAmlDecodeReadU16(pThis, &u16, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            *pu64       = u16;
+            *pcbDecoded = 3;
+            break;
+        }
+        case ACPI_AML_BYTE_CODE_PREFIX_DWORD:
+        {
+            if (cbDecodeMax < 4)
+                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode double word integer in AML stream");
+
+            uint32_t u32 = 0;
+            int rc = rtAcpiTblAmlDecodeReadU32(pThis, &u32, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            *pu64       = u32;
+            *pcbDecoded = 5;
+            break;
+        }
+        case ACPI_AML_BYTE_CODE_PREFIX_QWORD:
+        {
+            if (cbDecodeMax < 8)
+                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode quad word integer in AML stream");
+
+            uint64_t u64 = 0;
+            int rc = rtAcpiTblAmlDecodeReadU64(pThis, &u64, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            *pu64       = u64;
+            *pcbDecoded = 9;
+            break;
+        }
+        default:
+            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid integer prefix '%#02RX8'", bPrefix);
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+static int rtAcpiTblAmlDecodeIntegerWorker(PRTACPITBLAMLDECODE pThis, uint64_t *pu64, size_t cbDecodeMax, size_t *pcbDecoded, PRTERRINFO pErrInfo)
+{
+    AssertReturn(cbDecodeMax >= 1, VERR_INVALID_PARAMETER);
+
+    uint8_t bPrefix = 0; /* shut up gcc */
+    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bPrefix, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    cbDecodeMax--;
+    return rtAcpiTblAmlDecodeIntegerFromPrefix(pThis, bPrefix, pu64, cbDecodeMax, pcbDecoded, pErrInfo);
+}
+
+
+static DECLCALLBACK(int) rtAcpiTblAmlDecodeNameObject(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
+{
+    char szName[512];
+    size_t cbName = 0;
+
+    int rc = rtAcpiTblAmlDecodeNameStringWithLead(pThis, bOp, &szName[0], sizeof(szName), &cbName, pErrInfo);
+    if (RT_FAILURE(rc)) return rc;
+
+    PRTACPITBLAMLOBJ pIt;
+    bool fFound = false;
+    RTListForEach(&pThis->LstObjs, pIt, RTACPITBLAMLOBJ, NdObjs)
+    {
+        if (!strcmp(pIt->szName, szName))
+        {
+            fFound = true;
+            break;
+        }
+    }
+
+    if (fFound)
+    {
+        if (pIt->enmType == kAcpiAmlObjType_Method)
+        {
+            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s(", szName);
+            if (RT_FAILURE(rc)) return rc;
+
+            bool fIndentOld = pThis->fIndent;
+            pThis->fIndent = false;
+            for (uint32_t iArg = 0; iArg < pIt->u.cMethodArgs; iArg++)
+            {
+                rc = rtAcpiTblAmlDecodeTerminal(pThis, hVfsIosOut, pErrInfo);
+                if (RT_FAILURE(rc)) return rc;
+
+                if (iArg < pIt->u.cMethodArgs - 1)
+                {
+                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ", ", szName);
+                    if (RT_FAILURE(rc)) return rc;
+                }
+            }
+            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ")");
+            pThis->fIndent = fIndentOld;
+        }
+        else
+            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
+    }
+    else
+        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
+
+    return rc;
+}
+
+
+static DECLCALLBACK(int) rtAcpiTblAmlDecodeString(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
+{
+    RT_NOREF(bOp);
+
+    char szStr[512];
+    uint32_t i = 0;
+    for (;;)
+    {
+        uint8_t bTmp = 0; /* shut up gcc */
+        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+        if (RT_FAILURE(rc))
+            return rc;
+
+        if (bTmp >= 0x1 && bTmp <= 0x7f)
+            szStr[i++] = (char)bTmp;
+        else if (bTmp == 0x00)
+        {
+            szStr[i++] = '\0';
+            break;
+        }
+        else
+            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid ASCII string character %#x in string", bTmp);
+
+        if (i == sizeof(szStr))
+            return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "ASCII string is out of bounds");
+    }
+
+    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "\"%s\"", szStr);
+}
+
+
+static DECLCALLBACK(int) rtAcpiTblAmlDecodeBuffer(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
+{
+    RT_NOREF(bOp);
+
+    size_t cbPkg = 0;
+    size_t cbPkgLength = 0;
+    int rc = rtAcpiTblAmlDecodePkgLength(pThis, &cbPkg, &cbPkgLength, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    cbPkg -= cbPkgLength;
+    uint64_t u64 = 0;
+    size_t cbInt = 0;
+    rc = rtAcpiTblAmlDecodeIntegerWorker(pThis, &u64, cbPkg, &cbInt, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    cbPkg -= cbInt;
+
+    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "Buffer (%RU64) {", u64);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    /* Decode remaining bytes. */
+    while (cbPkg--)
+    {
+        uint8_t bTmp = 0;
+        rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
+        if (RT_FAILURE(rc))
+            return rc;
+
+        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%#02RX8%s", bTmp, cbPkg ? "," : "");
+        if (RT_FAILURE(rc))
+            return rc;
+    }
+
+    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "}");
+}
+
+
+static DECLCALLBACK(int) rtAcpiTblAmlDecodeInteger(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
+{
+    uint64_t u64 = 0;
+    size_t cbDecoded = 0;
+    int rc = rtAcpiTblAmlDecodeIntegerFromPrefix(pThis, bOp, &u64, sizeof(uint64_t), &cbDecoded, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%#RX64", u64);
+}
+
+
+static DECLCALLBACK(int) rtAcpiTblAmlDecodeMethod(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
+{
+    RT_NOREF(bOp);
+
+    size_t cbPkg = 0;
+    size_t cbPkgLength = 0;
+    int rc = rtAcpiTblAmlDecodePkgLength(pThis, &cbPkg, &cbPkgLength, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    size_t cbPkgConsumed = cbPkgLength;
+    char szName[512]; RT_ZERO(szName);
+    size_t cchName = 0;
+    rc = rtAcpiTblAmlDecodeNameString(pThis, &szName[0], sizeof(szName), &cchName, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    cbPkgConsumed += cchName;
+
+    uint8_t bMethod;
+    rc = rtAcpiTblAmlDecodeReadU8(pThis, &bMethod, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    cbPkgConsumed++;
+
+    if (cbPkg < cbPkgConsumed)
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Number of bytes consumed for the current package exceeds package length (%zu vs %zu)",
+                             cbPkgConsumed, cbPkg);
+
+    PRTACPITBLAMLOBJ pObj = (PRTACPITBLAMLOBJ)RTMemAllocZ(RT_UOFFSETOF_DYN(RTACPITBLAMLOBJ, szName[cchName + 1]));
+    if (!pObj)
+        return RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Failed to allocate %zu bytes for method object %s",
+                             RT_UOFFSETOF_DYN(RTACPITBLAMLOBJ, szName[cchName + 1]), szName);
+
+    pObj->enmType       = kAcpiAmlObjType_Method;
+    pObj->u.cMethodArgs = bMethod & 0x7;
+    memcpy(&pObj->szName[0], &szName[0], cchName);
+    RTListAppend(&pThis->LstObjs, &pObj->NdObjs);
+
+    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "Method(%s, %u, %s, %u)",
+                                  pObj->szName, pObj->u.cMethodArgs, bMethod & RT_BIT(3) ? "Serialized" : "NotSerialized",
+                                  bMethod >> 4);
+    if (RT_FAILURE(rc))
+        return rc;
+    return rtAcpiTblAmlDecodePkgPush(pThis, hVfsIosOut, cbPkg - cbPkgConsumed, pErrInfo);
+}
+
+
+/**
+ * AML Opcode -> ASL decoder array.
+ */
+static const RTACPIAMLOPC g_aAmlOpcodeDecode[] =
+{
+#define RTACPI_AML_OPC_INVALID \
+    { NULL,     RTACPI_AML_OPC_F_NONE,  { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_0(a_pszOpc, a_fFlags) \
+    { a_pszOpc, a_fFlags,               { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_1(a_pszOpc, a_fFlags, a_enmType0) \
+    { a_pszOpc, a_fFlags,               { a_enmType0,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_2(a_pszOpc, a_fFlags, a_enmType0, a_enmType1) \
+    { a_pszOpc, a_fFlags,               { a_enmType0,              a_enmType1,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_3(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2) \
+    { a_pszOpc, a_fFlags,               { a_enmType0,              a_enmType1,              a_enmType2,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_4(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2, a_enmType3) \
+    { a_pszOpc, a_fFlags,               { a_enmType0,              a_enmType1,              a_enmType2,              a_enmType3,              kAcpiAmlOpcType_Invalid }, NULL }
+#define RTACPI_AML_OPC_SIMPLE_5(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2, a_enmType3, a_enmType4) \
+    { a_pszOpc, a_fFlags,               { a_enmType0,              a_enmType1,              a_enmType2,              a_enmType3,              a_enmType4              }, NULL }
+#define RTACPI_AML_OPC_HANDLER(a_pszOpc, a_pfnHandler) \
+    { a_pszOpc, RTACPI_AML_OPC_F_NONE, { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, a_pfnHandler }
+
+    /* 0x00 */ RTACPI_AML_OPC_SIMPLE_0("Zero", RTACPI_AML_OPC_F_NONE),
+    /* 0x01 */ RTACPI_AML_OPC_SIMPLE_0("One",  RTACPI_AML_OPC_F_NONE),
+    /* 0x02 */ RTACPI_AML_OPC_INVALID,
+    /* 0x03 */ RTACPI_AML_OPC_INVALID,
+    /* 0x04 */ RTACPI_AML_OPC_INVALID,
+    /* 0x05 */ RTACPI_AML_OPC_INVALID,
+    /* 0x06 */ RTACPI_AML_OPC_INVALID,
+    /* 0x07 */ RTACPI_AML_OPC_INVALID,
+    /* 0x08 */ RTACPI_AML_OPC_SIMPLE_2("Name",   0,     kAcpiAmlOpcType_NameString,  kAcpiAmlOpcType_TermArg),
+    /* 0x09 */ RTACPI_AML_OPC_INVALID,
+    /* 0x0a */ RTACPI_AML_OPC_HANDLER( "ByteInteger",   rtAcpiTblAmlDecodeInteger),
+    /* 0x0b */ RTACPI_AML_OPC_HANDLER( "WordInteger",   rtAcpiTblAmlDecodeInteger),
+    /* 0x0c */ RTACPI_AML_OPC_HANDLER( "DWordInteger",  rtAcpiTblAmlDecodeInteger),
+    /* 0x0d */ RTACPI_AML_OPC_HANDLER( "StringPrefix",  rtAcpiTblAmlDecodeString),
+    /* 0x0e */ RTACPI_AML_OPC_HANDLER( "QWordInteger",  rtAcpiTblAmlDecodeInteger),
+    /* 0x0f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x10 */ RTACPI_AML_OPC_SIMPLE_1("Scope",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH,  kAcpiAmlOpcType_NameString),
+    /* 0x11 */ RTACPI_AML_OPC_HANDLER( "Buffer",   rtAcpiTblAmlDecodeBuffer),
+    /* 0x12 */ RTACPI_AML_OPC_INVALID,
+    /* 0x13 */ RTACPI_AML_OPC_INVALID,
+    /* 0x14 */ RTACPI_AML_OPC_HANDLER( "Method",        rtAcpiTblAmlDecodeMethod),
+    /* 0x15 */ RTACPI_AML_OPC_SIMPLE_3("External", RTACPI_AML_OPC_F_NONE,            kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_Byte),
+    /* 0x16 */ RTACPI_AML_OPC_INVALID,
+    /* 0x17 */ RTACPI_AML_OPC_INVALID,
+    /* 0x18 */ RTACPI_AML_OPC_INVALID,
+    /* 0x19 */ RTACPI_AML_OPC_INVALID,
+    /* 0x1a */ RTACPI_AML_OPC_INVALID,
+    /* 0x1b */ RTACPI_AML_OPC_INVALID,
+    /* 0x1c */ RTACPI_AML_OPC_INVALID,
+    /* 0x1d */ RTACPI_AML_OPC_INVALID,
+    /* 0x1e */ RTACPI_AML_OPC_INVALID,
+    /* 0x1f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x20 */ RTACPI_AML_OPC_INVALID,
+    /* 0x21 */ RTACPI_AML_OPC_INVALID,
+    /* 0x22 */ RTACPI_AML_OPC_INVALID,
+    /* 0x23 */ RTACPI_AML_OPC_INVALID,
+    /* 0x24 */ RTACPI_AML_OPC_INVALID,
+    /* 0x25 */ RTACPI_AML_OPC_INVALID,
+    /* 0x26 */ RTACPI_AML_OPC_INVALID,
+    /* 0x27 */ RTACPI_AML_OPC_INVALID,
+    /* 0x28 */ RTACPI_AML_OPC_INVALID,
+    /* 0x29 */ RTACPI_AML_OPC_INVALID,
+    /* 0x2a */ RTACPI_AML_OPC_INVALID,
+    /* 0x2b */ RTACPI_AML_OPC_INVALID,
+    /* 0x2c */ RTACPI_AML_OPC_INVALID,
+    /* 0x2d */ RTACPI_AML_OPC_INVALID,
+    /* 0x2e */ RTACPI_AML_OPC_INVALID,
+    /* 0x2f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x30 */ RTACPI_AML_OPC_INVALID,
+    /* 0x31 */ RTACPI_AML_OPC_INVALID,
+    /* 0x32 */ RTACPI_AML_OPC_INVALID,
+    /* 0x33 */ RTACPI_AML_OPC_INVALID,
+    /* 0x34 */ RTACPI_AML_OPC_INVALID,
+    /* 0x35 */ RTACPI_AML_OPC_INVALID,
+    /* 0x36 */ RTACPI_AML_OPC_INVALID,
+    /* 0x37 */ RTACPI_AML_OPC_INVALID,
+    /* 0x38 */ RTACPI_AML_OPC_INVALID,
+    /* 0x39 */ RTACPI_AML_OPC_INVALID,
+    /* 0x3a */ RTACPI_AML_OPC_INVALID,
+    /* 0x3b */ RTACPI_AML_OPC_INVALID,
+    /* 0x3c */ RTACPI_AML_OPC_INVALID,
+    /* 0x3d */ RTACPI_AML_OPC_INVALID,
+    /* 0x3e */ RTACPI_AML_OPC_INVALID,
+    /* 0x3f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x40 */ RTACPI_AML_OPC_INVALID,
+    /* 0x41 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x42 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x43 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x44 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x45 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x46 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x47 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x48 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x49 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4a */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4b */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4c */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4d */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4e */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x4f */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+
+    /* 0x50 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x51 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x52 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x53 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x54 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x55 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x56 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x57 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x58 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x59 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x5a */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x5b */ RTACPI_AML_OPC_INVALID,
+    /* 0x5c */ RTACPI_AML_OPC_HANDLER("RootChar",         rtAcpiTblAmlDecodeNameObject),
+    /* 0x5d */ RTACPI_AML_OPC_INVALID,
+    /* 0x5e */ RTACPI_AML_OPC_HANDLER("ParentPrefixChar", rtAcpiTblAmlDecodeNameObject),
+    /* 0x5f */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
+
+    /* 0x60 */ RTACPI_AML_OPC_SIMPLE_0("Local0", RTACPI_AML_OPC_F_NONE),
+    /* 0x61 */ RTACPI_AML_OPC_SIMPLE_0("Local1", RTACPI_AML_OPC_F_NONE),
+    /* 0x62 */ RTACPI_AML_OPC_SIMPLE_0("Local2", RTACPI_AML_OPC_F_NONE),
+    /* 0x63 */ RTACPI_AML_OPC_SIMPLE_0("Local3", RTACPI_AML_OPC_F_NONE),
+    /* 0x64 */ RTACPI_AML_OPC_SIMPLE_0("Local4", RTACPI_AML_OPC_F_NONE),
+    /* 0x65 */ RTACPI_AML_OPC_SIMPLE_0("Local5", RTACPI_AML_OPC_F_NONE),
+    /* 0x66 */ RTACPI_AML_OPC_SIMPLE_0("Local6", RTACPI_AML_OPC_F_NONE),
+    /* 0x67 */ RTACPI_AML_OPC_SIMPLE_0("Local7", RTACPI_AML_OPC_F_NONE),
+    /* 0x68 */ RTACPI_AML_OPC_SIMPLE_0("Arg0",   RTACPI_AML_OPC_F_NONE),
+    /* 0x69 */ RTACPI_AML_OPC_SIMPLE_0("Arg1",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6a */ RTACPI_AML_OPC_SIMPLE_0("Arg2",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6b */ RTACPI_AML_OPC_SIMPLE_0("Arg3",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6c */ RTACPI_AML_OPC_SIMPLE_0("Arg4",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6d */ RTACPI_AML_OPC_SIMPLE_0("Arg5",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6e */ RTACPI_AML_OPC_SIMPLE_0("Arg6",   RTACPI_AML_OPC_F_NONE),
+    /* 0x6f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x70 */ RTACPI_AML_OPC_SIMPLE_2("Store",   0,     kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_SuperName),
+    /* 0x71 */ RTACPI_AML_OPC_INVALID,
+    /* 0x72 */ RTACPI_AML_OPC_INVALID,
+    /* 0x73 */ RTACPI_AML_OPC_INVALID,
+    /* 0x74 */ RTACPI_AML_OPC_INVALID,
+    /* 0x75 */ RTACPI_AML_OPC_INVALID,
+    /* 0x76 */ RTACPI_AML_OPC_INVALID,
+    /* 0x77 */ RTACPI_AML_OPC_INVALID,
+    /* 0x78 */ RTACPI_AML_OPC_INVALID,
+    /* 0x79 */ RTACPI_AML_OPC_INVALID,
+    /* 0x7a */ RTACPI_AML_OPC_INVALID,
+    /* 0x7b */ RTACPI_AML_OPC_INVALID,
+    /* 0x7c */ RTACPI_AML_OPC_INVALID,
+    /* 0x7d */ RTACPI_AML_OPC_INVALID,
+    /* 0x7e */ RTACPI_AML_OPC_INVALID,
+    /* 0x7f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x80 */ RTACPI_AML_OPC_INVALID,
+    /* 0x81 */ RTACPI_AML_OPC_INVALID,
+    /* 0x82 */ RTACPI_AML_OPC_INVALID,
+    /* 0x83 */ RTACPI_AML_OPC_INVALID,
+    /* 0x84 */ RTACPI_AML_OPC_INVALID,
+    /* 0x85 */ RTACPI_AML_OPC_INVALID,
+    /* 0x86 */ RTACPI_AML_OPC_SIMPLE_2("Notify",                                0,     kAcpiAmlOpcType_SuperName, kAcpiAmlOpcType_TermArg),
+    /* 0x87 */ RTACPI_AML_OPC_INVALID,
+    /* 0x88 */ RTACPI_AML_OPC_SIMPLE_3("Index",                                 0,     kAcpiAmlOpcType_TermArg,   kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_SuperName),
+    /* 0x89 */ RTACPI_AML_OPC_INVALID,
+    /* 0x8a */ RTACPI_AML_OPC_INVALID,
+    /* 0x8b */ RTACPI_AML_OPC_INVALID,
+    /* 0x8c */ RTACPI_AML_OPC_INVALID,
+    /* 0x8d */ RTACPI_AML_OPC_INVALID,
+    /* 0x8e */ RTACPI_AML_OPC_INVALID,
+    /* 0x8f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x90 */ RTACPI_AML_OPC_INVALID,
+    /* 0x91 */ RTACPI_AML_OPC_INVALID,
+    /* 0x92 */ RTACPI_AML_OPC_INVALID,
+    /* 0x93 */ RTACPI_AML_OPC_SIMPLE_2("LEqual",                                0,     kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_TermArg),
+    /* 0x94 */ RTACPI_AML_OPC_INVALID,
+    /* 0x95 */ RTACPI_AML_OPC_INVALID,
+    /* 0x96 */ RTACPI_AML_OPC_INVALID,
+    /* 0x97 */ RTACPI_AML_OPC_INVALID,
+    /* 0x98 */ RTACPI_AML_OPC_INVALID,
+    /* 0x99 */ RTACPI_AML_OPC_INVALID,
+    /* 0x9a */ RTACPI_AML_OPC_INVALID,
+    /* 0x9b */ RTACPI_AML_OPC_INVALID,
+    /* 0x9c */ RTACPI_AML_OPC_INVALID,
+    /* 0x9d */ RTACPI_AML_OPC_INVALID,
+    /* 0x9e */ RTACPI_AML_OPC_INVALID,
+    /* 0x9f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xa0 */ RTACPI_AML_OPC_SIMPLE_1("If",      RTACPI_AML_OPC_F_HAS_PKG_LENGTH,     kAcpiAmlOpcType_TermArg),
+    /* 0xa1 */ RTACPI_AML_OPC_SIMPLE_0("Else",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH),
+    /* 0xa2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa4 */ RTACPI_AML_OPC_SIMPLE_1("Return",                                0,     kAcpiAmlOpcType_TermArg),
+    /* 0xa5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xaa */ RTACPI_AML_OPC_INVALID,
+    /* 0xab */ RTACPI_AML_OPC_INVALID,
+    /* 0xac */ RTACPI_AML_OPC_INVALID,
+    /* 0xad */ RTACPI_AML_OPC_INVALID,
+    /* 0xae */ RTACPI_AML_OPC_INVALID,
+    /* 0xaf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xb0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xba */ RTACPI_AML_OPC_INVALID,
+    /* 0xbb */ RTACPI_AML_OPC_INVALID,
+    /* 0xbc */ RTACPI_AML_OPC_INVALID,
+    /* 0xbd */ RTACPI_AML_OPC_INVALID,
+    /* 0xbe */ RTACPI_AML_OPC_INVALID,
+    /* 0xbf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xc0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xca */ RTACPI_AML_OPC_INVALID,
+    /* 0xcb */ RTACPI_AML_OPC_INVALID,
+    /* 0xcc */ RTACPI_AML_OPC_INVALID,
+    /* 0xcd */ RTACPI_AML_OPC_INVALID,
+    /* 0xce */ RTACPI_AML_OPC_INVALID,
+    /* 0xcf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xd0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xda */ RTACPI_AML_OPC_INVALID,
+    /* 0xdb */ RTACPI_AML_OPC_INVALID,
+    /* 0xdc */ RTACPI_AML_OPC_INVALID,
+    /* 0xdd */ RTACPI_AML_OPC_INVALID,
+    /* 0xde */ RTACPI_AML_OPC_INVALID,
+    /* 0xdf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xe0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xea */ RTACPI_AML_OPC_INVALID,
+    /* 0xeb */ RTACPI_AML_OPC_INVALID,
+    /* 0xec */ RTACPI_AML_OPC_INVALID,
+    /* 0xed */ RTACPI_AML_OPC_INVALID,
+    /* 0xee */ RTACPI_AML_OPC_INVALID,
+    /* 0xef */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xf0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xfa */ RTACPI_AML_OPC_INVALID,
+    /* 0xfb */ RTACPI_AML_OPC_INVALID,
+    /* 0xfc */ RTACPI_AML_OPC_INVALID,
+    /* 0xfd */ RTACPI_AML_OPC_INVALID,
+    /* 0xfe */ RTACPI_AML_OPC_INVALID,
+    /* 0xff */ RTACPI_AML_OPC_INVALID
+};
+
+
+/**
+ * AML extended opcode -> ASL decoder array.
+ */
+static const RTACPIAMLOPC g_aAmlExtOpcodeDecode[] =
+{
+    /* 0x00 */ RTACPI_AML_OPC_INVALID,
+    /* 0x01 */ RTACPI_AML_OPC_INVALID,
+    /* 0x02 */ RTACPI_AML_OPC_INVALID,
+    /* 0x03 */ RTACPI_AML_OPC_INVALID,
+    /* 0x04 */ RTACPI_AML_OPC_INVALID,
+    /* 0x05 */ RTACPI_AML_OPC_INVALID,
+    /* 0x06 */ RTACPI_AML_OPC_INVALID,
+    /* 0x07 */ RTACPI_AML_OPC_INVALID,
+    /* 0x08 */ RTACPI_AML_OPC_INVALID,
+    /* 0x09 */ RTACPI_AML_OPC_INVALID,
+    /* 0x0a */ RTACPI_AML_OPC_INVALID,
+    /* 0x0b */ RTACPI_AML_OPC_INVALID,
+    /* 0x0c */ RTACPI_AML_OPC_INVALID,
+    /* 0x0d */ RTACPI_AML_OPC_INVALID,
+    /* 0x0e */ RTACPI_AML_OPC_INVALID,
+    /* 0x0f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x10 */ RTACPI_AML_OPC_INVALID,
+    /* 0x11 */ RTACPI_AML_OPC_INVALID,
+    /* 0x12 */ RTACPI_AML_OPC_INVALID,
+    /* 0x13 */ RTACPI_AML_OPC_INVALID,
+    /* 0x14 */ RTACPI_AML_OPC_INVALID,
+    /* 0x15 */ RTACPI_AML_OPC_INVALID,
+    /* 0x16 */ RTACPI_AML_OPC_INVALID,
+    /* 0x17 */ RTACPI_AML_OPC_INVALID,
+    /* 0x18 */ RTACPI_AML_OPC_INVALID,
+    /* 0x19 */ RTACPI_AML_OPC_INVALID,
+    /* 0x1a */ RTACPI_AML_OPC_INVALID,
+    /* 0x1b */ RTACPI_AML_OPC_INVALID,
+    /* 0x1c */ RTACPI_AML_OPC_INVALID,
+    /* 0x1d */ RTACPI_AML_OPC_INVALID,
+    /* 0x1e */ RTACPI_AML_OPC_INVALID,
+    /* 0x1f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x20 */ RTACPI_AML_OPC_INVALID,
+    /* 0x21 */ RTACPI_AML_OPC_INVALID,
+    /* 0x22 */ RTACPI_AML_OPC_INVALID,
+    /* 0x23 */ RTACPI_AML_OPC_INVALID,
+    /* 0x24 */ RTACPI_AML_OPC_INVALID,
+    /* 0x25 */ RTACPI_AML_OPC_INVALID,
+    /* 0x26 */ RTACPI_AML_OPC_INVALID,
+    /* 0x27 */ RTACPI_AML_OPC_INVALID,
+    /* 0x28 */ RTACPI_AML_OPC_INVALID,
+    /* 0x29 */ RTACPI_AML_OPC_INVALID,
+    /* 0x2a */ RTACPI_AML_OPC_INVALID,
+    /* 0x2b */ RTACPI_AML_OPC_INVALID,
+    /* 0x2c */ RTACPI_AML_OPC_INVALID,
+    /* 0x2d */ RTACPI_AML_OPC_INVALID,
+    /* 0x2e */ RTACPI_AML_OPC_INVALID,
+    /* 0x2f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x30 */ RTACPI_AML_OPC_INVALID,
+    /* 0x31 */ RTACPI_AML_OPC_SIMPLE_0("Debug", RTACPI_AML_OPC_F_NONE),
+    /* 0x32 */ RTACPI_AML_OPC_INVALID,
+    /* 0x33 */ RTACPI_AML_OPC_INVALID,
+    /* 0x34 */ RTACPI_AML_OPC_INVALID,
+    /* 0x35 */ RTACPI_AML_OPC_INVALID,
+    /* 0x36 */ RTACPI_AML_OPC_INVALID,
+    /* 0x37 */ RTACPI_AML_OPC_INVALID,
+    /* 0x38 */ RTACPI_AML_OPC_INVALID,
+    /* 0x39 */ RTACPI_AML_OPC_INVALID,
+    /* 0x3a */ RTACPI_AML_OPC_INVALID,
+    /* 0x3b */ RTACPI_AML_OPC_INVALID,
+    /* 0x3c */ RTACPI_AML_OPC_INVALID,
+    /* 0x3d */ RTACPI_AML_OPC_INVALID,
+    /* 0x3e */ RTACPI_AML_OPC_INVALID,
+    /* 0x3f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x40 */ RTACPI_AML_OPC_INVALID,
+    /* 0x41 */ RTACPI_AML_OPC_INVALID,
+    /* 0x42 */ RTACPI_AML_OPC_INVALID,
+    /* 0x43 */ RTACPI_AML_OPC_INVALID,
+    /* 0x44 */ RTACPI_AML_OPC_INVALID,
+    /* 0x45 */ RTACPI_AML_OPC_INVALID,
+    /* 0x46 */ RTACPI_AML_OPC_INVALID,
+    /* 0x47 */ RTACPI_AML_OPC_INVALID,
+    /* 0x48 */ RTACPI_AML_OPC_INVALID,
+    /* 0x49 */ RTACPI_AML_OPC_INVALID,
+    /* 0x4a */ RTACPI_AML_OPC_INVALID,
+    /* 0x4b */ RTACPI_AML_OPC_INVALID,
+    /* 0x4c */ RTACPI_AML_OPC_INVALID,
+    /* 0x4d */ RTACPI_AML_OPC_INVALID,
+    /* 0x4e */ RTACPI_AML_OPC_INVALID,
+    /* 0x4f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x50 */ RTACPI_AML_OPC_INVALID,
+    /* 0x51 */ RTACPI_AML_OPC_INVALID,
+    /* 0x52 */ RTACPI_AML_OPC_INVALID,
+    /* 0x53 */ RTACPI_AML_OPC_INVALID,
+    /* 0x54 */ RTACPI_AML_OPC_INVALID,
+    /* 0x55 */ RTACPI_AML_OPC_INVALID,
+    /* 0x56 */ RTACPI_AML_OPC_INVALID,
+    /* 0x57 */ RTACPI_AML_OPC_INVALID,
+    /* 0x58 */ RTACPI_AML_OPC_INVALID,
+    /* 0x59 */ RTACPI_AML_OPC_INVALID,
+    /* 0x5a */ RTACPI_AML_OPC_INVALID,
+    /* 0x5b */ RTACPI_AML_OPC_INVALID,
+    /* 0x5c */ RTACPI_AML_OPC_INVALID,
+    /* 0x5d */ RTACPI_AML_OPC_INVALID,
+    /* 0x5e */ RTACPI_AML_OPC_INVALID,
+    /* 0x5f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x60 */ RTACPI_AML_OPC_INVALID,
+    /* 0x61 */ RTACPI_AML_OPC_INVALID,
+    /* 0x62 */ RTACPI_AML_OPC_INVALID,
+    /* 0x63 */ RTACPI_AML_OPC_INVALID,
+    /* 0x64 */ RTACPI_AML_OPC_INVALID,
+    /* 0x65 */ RTACPI_AML_OPC_INVALID,
+    /* 0x66 */ RTACPI_AML_OPC_INVALID,
+    /* 0x67 */ RTACPI_AML_OPC_INVALID,
+    /* 0x68 */ RTACPI_AML_OPC_INVALID,
+    /* 0x69 */ RTACPI_AML_OPC_INVALID,
+    /* 0x6a */ RTACPI_AML_OPC_INVALID,
+    /* 0x6b */ RTACPI_AML_OPC_INVALID,
+    /* 0x6c */ RTACPI_AML_OPC_INVALID,
+    /* 0x6d */ RTACPI_AML_OPC_INVALID,
+    /* 0x6e */ RTACPI_AML_OPC_INVALID,
+    /* 0x6f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x70 */ RTACPI_AML_OPC_INVALID,
+    /* 0x71 */ RTACPI_AML_OPC_INVALID,
+    /* 0x72 */ RTACPI_AML_OPC_INVALID,
+    /* 0x73 */ RTACPI_AML_OPC_INVALID,
+    /* 0x74 */ RTACPI_AML_OPC_INVALID,
+    /* 0x75 */ RTACPI_AML_OPC_INVALID,
+    /* 0x76 */ RTACPI_AML_OPC_INVALID,
+    /* 0x77 */ RTACPI_AML_OPC_INVALID,
+    /* 0x78 */ RTACPI_AML_OPC_INVALID,
+    /* 0x79 */ RTACPI_AML_OPC_INVALID,
+    /* 0x7a */ RTACPI_AML_OPC_INVALID,
+    /* 0x7b */ RTACPI_AML_OPC_INVALID,
+    /* 0x7c */ RTACPI_AML_OPC_INVALID,
+    /* 0x7d */ RTACPI_AML_OPC_INVALID,
+    /* 0x7e */ RTACPI_AML_OPC_INVALID,
+    /* 0x7f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x80 */ RTACPI_AML_OPC_SIMPLE_4("OpRegion",                                0, kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_TermArg),
+    /* 0x81 */ RTACPI_AML_OPC_INVALID,
+    /* 0x82 */ RTACPI_AML_OPC_SIMPLE_1("Device",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH, kAcpiAmlOpcType_NameString),
+    /* 0x83 */ RTACPI_AML_OPC_SIMPLE_4("Processor", RTACPI_AML_OPC_F_HAS_PKG_LENGTH, kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_DWord,   kAcpiAmlOpcType_Byte),
+    /* 0x84 */ RTACPI_AML_OPC_INVALID,
+    /* 0x85 */ RTACPI_AML_OPC_INVALID,
+    /* 0x86 */ RTACPI_AML_OPC_INVALID,
+    /* 0x87 */ RTACPI_AML_OPC_INVALID,
+    /* 0x88 */ RTACPI_AML_OPC_INVALID,
+    /* 0x89 */ RTACPI_AML_OPC_INVALID,
+    /* 0x8a */ RTACPI_AML_OPC_INVALID,
+    /* 0x8b */ RTACPI_AML_OPC_INVALID,
+    /* 0x8c */ RTACPI_AML_OPC_INVALID,
+    /* 0x8d */ RTACPI_AML_OPC_INVALID,
+    /* 0x8e */ RTACPI_AML_OPC_INVALID,
+    /* 0x8f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0x90 */ RTACPI_AML_OPC_INVALID,
+    /* 0x91 */ RTACPI_AML_OPC_INVALID,
+    /* 0x92 */ RTACPI_AML_OPC_INVALID,
+    /* 0x93 */ RTACPI_AML_OPC_INVALID,
+    /* 0x94 */ RTACPI_AML_OPC_INVALID,
+    /* 0x95 */ RTACPI_AML_OPC_INVALID,
+    /* 0x96 */ RTACPI_AML_OPC_INVALID,
+    /* 0x97 */ RTACPI_AML_OPC_INVALID,
+    /* 0x98 */ RTACPI_AML_OPC_INVALID,
+    /* 0x99 */ RTACPI_AML_OPC_INVALID,
+    /* 0x9a */ RTACPI_AML_OPC_INVALID,
+    /* 0x9b */ RTACPI_AML_OPC_INVALID,
+    /* 0x9c */ RTACPI_AML_OPC_INVALID,
+    /* 0x9d */ RTACPI_AML_OPC_INVALID,
+    /* 0x9e */ RTACPI_AML_OPC_INVALID,
+    /* 0x9f */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xa0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xa9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xaa */ RTACPI_AML_OPC_INVALID,
+    /* 0xab */ RTACPI_AML_OPC_INVALID,
+    /* 0xac */ RTACPI_AML_OPC_INVALID,
+    /* 0xad */ RTACPI_AML_OPC_INVALID,
+    /* 0xae */ RTACPI_AML_OPC_INVALID,
+    /* 0xaf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xb0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xb9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xba */ RTACPI_AML_OPC_INVALID,
+    /* 0xbb */ RTACPI_AML_OPC_INVALID,
+    /* 0xbc */ RTACPI_AML_OPC_INVALID,
+    /* 0xbd */ RTACPI_AML_OPC_INVALID,
+    /* 0xbe */ RTACPI_AML_OPC_INVALID,
+    /* 0xbf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xc0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xc9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xca */ RTACPI_AML_OPC_INVALID,
+    /* 0xcb */ RTACPI_AML_OPC_INVALID,
+    /* 0xcc */ RTACPI_AML_OPC_INVALID,
+    /* 0xcd */ RTACPI_AML_OPC_INVALID,
+    /* 0xce */ RTACPI_AML_OPC_INVALID,
+    /* 0xcf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xd0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xd9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xda */ RTACPI_AML_OPC_INVALID,
+    /* 0xdb */ RTACPI_AML_OPC_INVALID,
+    /* 0xdc */ RTACPI_AML_OPC_INVALID,
+    /* 0xdd */ RTACPI_AML_OPC_INVALID,
+    /* 0xde */ RTACPI_AML_OPC_INVALID,
+    /* 0xdf */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xe0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xe9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xea */ RTACPI_AML_OPC_INVALID,
+    /* 0xeb */ RTACPI_AML_OPC_INVALID,
+    /* 0xec */ RTACPI_AML_OPC_INVALID,
+    /* 0xed */ RTACPI_AML_OPC_INVALID,
+    /* 0xee */ RTACPI_AML_OPC_INVALID,
+    /* 0xef */ RTACPI_AML_OPC_INVALID,
+
+    /* 0xf0 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf1 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf2 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf3 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf4 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf5 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf6 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf7 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf8 */ RTACPI_AML_OPC_INVALID,
+    /* 0xf9 */ RTACPI_AML_OPC_INVALID,
+    /* 0xfa */ RTACPI_AML_OPC_INVALID,
+    /* 0xfb */ RTACPI_AML_OPC_INVALID,
+    /* 0xfc */ RTACPI_AML_OPC_INVALID,
+    /* 0xfd */ RTACPI_AML_OPC_INVALID,
+    /* 0xfe */ RTACPI_AML_OPC_INVALID,
+    /* 0xff */ RTACPI_AML_OPC_INVALID
+};
+
+
+static int rtAcpiTblAmlDecodeSimple(PRTACPITBLAMLDECODE pThis, PCRTACPIAMLOPC pAmlOpc, uint8_t bOpc, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
+{
+    RT_NOREF(bOpc);
+
+    int rc;
+
+    /* Decode any package length field first. */
+    size_t cbPkg         = 0;
+    size_t cbPkgLength   = 0;
+    size_t cbPkgConsumed = 0;
+    if (pAmlOpc->fFlags & RTACPI_AML_OPC_F_HAS_PKG_LENGTH)
+    {
+        rc = rtAcpiTblAmlDecodePkgLength(pThis, &cbPkg, &cbPkgLength, pErrInfo);
+        if (RT_FAILURE(rc)) return rc;
+
+        cbPkgConsumed += cbPkgLength;
+    }
+
+    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", pAmlOpc->pszOpc);
+    if (RT_FAILURE(rc)) return rc;
+
+    /* Any arguments? */
+    if (pAmlOpc->aenmTypes[0] != kAcpiAmlOpcType_Invalid)
+    {
+        bool fOld = pThis->fIndent;
+        pThis->fIndent = false;
+
+        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, " (");
+        if (RT_FAILURE(rc)) return rc;
+
+        for (uint32_t i = 0; i < RT_ELEMENTS(pAmlOpc->aenmTypes); i++)
+        {
+            if (pAmlOpc->aenmTypes[i] == kAcpiAmlOpcType_Invalid)
+                break; /* End of arguments. */
+
+            if (i > 0)
+            {
+                rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ", ");
+                if (RT_FAILURE(rc)) return rc;
+            }
+
+            switch (pAmlOpc->aenmTypes[i])
+            {
+                case kAcpiAmlOpcType_Byte:
+                {
+                    uint8_t bVal = 0; /* shut up gcc */
+                    rc = rtAcpiTblAmlDecodeReadU8(pThis, &bVal, pErrInfo);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RU8", bVal);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    cbPkgConsumed++;
+                    break;
+                }
+                case kAcpiAmlOpcType_Word:
+                {
+                    uint16_t u16Val = 0; /* shut up gcc */
+                    rc = rtAcpiTblAmlDecodeReadU16(pThis, &u16Val, pErrInfo);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RX16", u16Val);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    cbPkgConsumed += sizeof(uint16_t);
+                    break;
+                }
+                case kAcpiAmlOpcType_DWord:
+                {
+                    uint32_t u32Val = 0; /* shut up gcc */
+                    rc = rtAcpiTblAmlDecodeReadU32(pThis, &u32Val, pErrInfo);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RX32", u32Val);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    cbPkgConsumed += sizeof(uint32_t);
+                    break;
+                }
+                case kAcpiAmlOpcType_NameString:
+                {
+                    char szName[512];
+                    size_t cbName = 0;
+                    rc = rtAcpiTblAmlDecodeNameString(pThis, &szName[0], sizeof(szName), &cbName, pErrInfo);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    PRTACPITBLAMLOBJ pIt;
+                    bool fFound = false;
+                    RTListForEach(&pThis->LstObjs, pIt, RTACPITBLAMLOBJ, NdObjs)
+                    {
+                        if (!strcmp(pIt->szName, szName))
+                        {
+                            fFound = true;
+                            break;
+                        }
+                    }
+
+                    if (fFound)
+                    {
+                        if (pIt->enmType == kAcpiAmlObjType_Method)
+                        {
+                            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s(", szName);
+                            if (RT_FAILURE(rc)) return rc;
+
+                            bool fIndentOld = pThis->fIndent;
+                            pThis->fIndent = false;
+
+                            size_t offTblOrig = pThis->offTbl;
+                            for (uint32_t iArg = 0; iArg < pIt->u.cMethodArgs; iArg++)
+                            {
+                                rc = rtAcpiTblAmlDecodeTerminal(pThis, hVfsIosOut, pErrInfo);
+                                if (RT_FAILURE(rc)) return rc;
+
+                                if (iArg < pIt->u.cMethodArgs - 1)
+                                {
+                                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ", ", szName);
+                                    if (RT_FAILURE(rc)) return rc;
+                                }
+                            }
+                            cbPkgConsumed += pThis->offTbl - offTblOrig;
+
+                            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ")");
+                            pThis->fIndent = fIndentOld;
+                        }
+                        else
+                            rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
+                    }
+                    else
+                        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
+                    if (RT_FAILURE(rc)) return rc;
+
+
+                    cbPkgConsumed += cbName;
+                    break;
+                }
+                case kAcpiAmlOpcType_SuperName:
+                case kAcpiAmlOpcType_TermArg:
+                {
+                    /** @todo SuperName has limited allowed arguments. */
+                    size_t offTblOrig = pThis->offTbl;
+
+                    rc = rtAcpiTblAmlDecodeTerminal(pThis, hVfsIosOut, pErrInfo);
+                    if (RT_FAILURE(rc)) return rc;
+
+                    cbPkgConsumed += pThis->offTbl - offTblOrig;
+                    break;
+                }
+                case kAcpiAmlOpcType_Invalid:
+                default:
+                    AssertReleaseFailed();
+            }
+        }
+
+        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ")");
+        if (RT_FAILURE(rc)) return rc;
+
+        pThis->fIndent = fOld;
+    }
+
+    if (pAmlOpc->fFlags & RTACPI_AML_OPC_F_HAS_PKG_LENGTH)
+    {
+        if (cbPkg < cbPkgConsumed)
+            return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "Opcode arguments consumed more than the package length indicated (%zu vs %zu)", cbPkg, cbPkgConsumed);
+        rc = rtAcpiTblAmlDecodePkgPush(pThis, hVfsIosOut, cbPkg - cbPkgConsumed, pErrInfo);
+    }
+
+    return rc;
+}
+
+static int rtAcpiTblAmlDecode(PRTACPITBLAMLDECODE pThis, PCRTACPIAMLOPC pAmlOpc, uint8_t bOpc, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
+{
+    if (pAmlOpc->pszOpc)
+    {
+        if (pAmlOpc->pfnDecode)
+            return pAmlOpc->pfnDecode(pThis, hVfsIosOut, bOpc, pErrInfo);
+        return rtAcpiTblAmlDecodeSimple(pThis, pAmlOpc, bOpc, hVfsIosOut, pErrInfo);
+    }
+
+    return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid opcode %#x in ACPI table at offset %u", bOpc, pThis->offTbl);
+}
+
+
+static int rtAcpiTblAmlDecodeTerminal(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
+{
+    PCRTACPIAMLOPC pAmlOpc = NULL;
+    uint8_t bOpc = 0; /* shut up gcc */
+    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bOpc, pErrInfo);
+    if (RT_SUCCESS(rc))
+    {
+        if (bOpc == ACPI_AML_BYTE_CODE_PREFIX_EXT_OP)
+        {
+            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bOpc, pErrInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            pAmlOpc = &g_aAmlExtOpcodeDecode[bOpc];
+        }
+        else
+            pAmlOpc = &g_aAmlOpcodeDecode[bOpc];
+
+        return rtAcpiTblAmlDecode(pThis, pAmlOpc, bOpc, hVfsIosOut, pErrInfo);
+    }
+
+    return rc;
+}
+
+
+DECLHIDDEN(int) rtAcpiTblConvertFromAmlToAsl(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo)
+{
+    ACPITBLHDR Hdr;
+    int rc = RTVfsIoStrmRead(hVfsIosIn, &Hdr, sizeof(Hdr), true /*fBlocking*/, NULL /*pcbRead*/);
+    if (RT_SUCCESS(rc))
+    {
+        Hdr.u32Signature       = RT_LE2H_U32(Hdr.u32Signature);
+        Hdr.cbTbl              = RT_LE2H_U32(Hdr.cbTbl);
+        Hdr.u32OemRevision     = RT_LE2H_U32(Hdr.u32OemRevision);
+        Hdr.u32CreatorRevision = RT_LE2H_U32(Hdr.u32CreatorRevision);
+
+        if (   Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT
+            || Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_DSDT)
+        {
+            uint8_t *pbTbl = (uint8_t *)RTMemAlloc(Hdr.cbTbl);
+            if (pbTbl)
+            {
+                rc = RTVfsIoStrmRead(hVfsIosIn, pbTbl, Hdr.cbTbl - sizeof(Hdr), true /*fBlocking*/, NULL /*pcbRead*/);
+                if (RT_SUCCESS(rc))
+                {
+                    /** @todo Verify checksum */
+                    ssize_t cch = RTVfsIoStrmPrintf(hVfsIosOut, "DefinitionBlock(\"\", \"%s\", %u, \"%.6s\", \"%.8s\", %u)",
+                                                    Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT ? "SSDT" : "DSDT",
+                                                    1, &Hdr.abOemId[0], &Hdr.abOemTblId[0], Hdr.u32OemRevision);
+                    if (cch > 0)
+                    {
+                        RTACPITBLAMLDECODE AmlDecode;
+                        AmlDecode.pbTbl        = pbTbl;
+                        AmlDecode.cbTbl        = Hdr.cbTbl - sizeof(Hdr);
+                        AmlDecode.offTbl       = 0;
+                        AmlDecode.iLvl         = 0;
+                        AmlDecode.cPkgStackMax = 0;
+                        AmlDecode.pacbPkgLeft  = NULL;
+                        AmlDecode.fIndent      = true;
+                        RTListInit(&AmlDecode.LstObjs);
+                        rc = rtAcpiTblAmlDecodePkgPush(&AmlDecode, hVfsIosOut, AmlDecode.cbTbl, pErrInfo);
+                        while (   RT_SUCCESS(rc)
+                               && AmlDecode.offTbl < Hdr.cbTbl - sizeof(Hdr))
+                        {
+                            rc = rtAcpiTblAmlDecodeTerminal(&AmlDecode, hVfsIosOut, pErrInfo);
+                            if (RT_SUCCESS(rc))
+                                rc = rtAcpiTblAmlDecodePkgPop(&AmlDecode, hVfsIosOut, pErrInfo);
+                        }
+                        if (AmlDecode.pacbPkgLeft)
+                            RTMemFree(AmlDecode.pacbPkgLeft);
+
+                        PRTACPITBLAMLOBJ pIt, pItNext;
+                        RTListForEachSafe(&AmlDecode.LstObjs, pIt, pItNext, RTACPITBLAMLOBJ, NdObjs)
+                        {
+                            RTListNodeRemove(&pIt->NdObjs);
+                            RTMemFree(pIt);
+                        } 
+
+                        if (RT_SUCCESS(rc))
+                        {
+                            cch = RTVfsIoStrmPrintf(hVfsIosOut, "}\n");
+                            if (cch <= 0)
+                                rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit closing definition block");
+                        }
+                    }
+                    else
+                        rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit DefinitionBlock()");
+                }
+                else
+                    rc = RTErrInfoSetF(pErrInfo, rc, "Reading %u bytes of the ACPI table failed", Hdr.cbTbl);
+
+                RTMemFree(pbTbl);
+                pbTbl = NULL;
+            }
+            else
+                rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Allocating memory for the ACPI table failed");
+        }
+        else
+            rc = RTErrInfoSetF(pErrInfo, VERR_NOT_SUPPORTED, "Only DSDT and SSDT ACPI tables are supported");
+    }
+    else
+        rc = RTErrInfoSetF(pErrInfo, rc, "Reading the ACPI table header failed with %Rrc", rc);
+
+    return rc;
+}
Index: trunk/src/VBox/Runtime/common/acpi/acpi.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/acpi/acpi.cpp	(revision 108015)
+++ trunk/src/VBox/Runtime/common/acpi/acpi.cpp	(revision 108015)
@@ -0,0 +1,1630 @@
+/* $Id$ */
+/** @file
+ * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
+ */
+
+/*
+ * Copyright (C) 2024 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from https://www.virtualbox.org.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, in version 3 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses>.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
+ * in the VirtualBox distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP RTLOGGROUP_ACPI
+#include <iprt/acpi.h>
+#include <iprt/asm.h>
+#include <iprt/file.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+#include <iprt/uuid.h>
+
+#include <iprt/formats/acpi-aml.h>
+#include <iprt/formats/acpi-resources.h>
+
+#include "internal/acpi.h"
+
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+
+
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+
+/**
+ * Package stack element.
+ */
+typedef struct RTACPITBLSTACKELEM
+{
+    /** Pointer to the table buffer memory where the PkgLength object starts. */
+    uint8_t                     *pbPkgLength;
+    /** Current size of the package in bytes, without the PkgLength object. */
+    uint32_t                    cbPkg;
+    /** The operator creating the package, UINT8_MAX denotes the special root operator. */
+    uint8_t                     bOp;
+} RTACPITBLSTACKELEM;
+/** Pointer to a package stack element. */
+typedef RTACPITBLSTACKELEM *PRTACPITBLSTACKELEM;
+/** Pointer to a const package stack element. */
+typedef const RTACPITBLSTACKELEM *PCRTACPITBLSTACKELEM;
+
+
+/**
+ * ACPI table generator instance.
+ */
+typedef struct RTACPITBLINT
+{
+    /** Pointer to the ACPI table header, needed when finalizing the table. */
+    PACPITBLHDR                 pHdr;
+    /** Byte buffer holding the actual table. */
+    uint8_t                     *pbTblBuf;
+    /** Size of the table buffer. */
+    uint32_t                    cbTblBuf;
+    /** Current offset into the table buffer. */
+    uint32_t                    offTblBuf;
+    /** Flag whether the table is finalized. */
+    bool                        fFinalized;
+    /** First error code encountered. */
+    int                         rcErr;
+    /** Pointer to the package element stack. */
+    PRTACPITBLSTACKELEM         paPkgStack;
+    /** Number of elements the package stack can hold. */
+    uint32_t                    cPkgStackElems;
+    /** Index of the current package in the package stack. */
+    uint32_t                    idxPkgStackElem;
+} RTACPITBLINT;
+/** Pointer to an ACPI table generator instance. */
+typedef RTACPITBLINT *PRTACPITBLINT;
+
+
+/**
+ * ACPI resource builder instance.
+ */
+typedef struct RTACPIRESINT
+{
+    /** Byte buffer holding the resource. */
+    uint8_t                     *pbResBuf;
+    /** Size of the resource buffer. */
+    size_t                      cbResBuf;
+    /** Current offset into the resource buffer. */
+    uint32_t                    offResBuf;
+    /** Flag whether the resource is sealed. */
+    bool                        fSealed;
+    /** First error code encountered. */
+    int                         rcErr;
+} RTACPIRESINT;
+/** Pointer to an ACPI resource builder instance. */
+typedef RTACPIRESINT *PRTACPIRESINT;
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+
+
+/**
+ * Copies the given string into the given buffer padding the remainder with the given character.
+ *
+ * @param    pbId           The destination to copy the string to.
+ * @param    cbId           Size of the buffer in bytes.
+ * @param    pszStr         The string to copy.
+ * @param    chPad          The character to pad with.
+ */
+static void rtAcpiTblCopyStringPadWith(uint8_t *pbId, size_t cbId, const char *pszStr, char chPad)
+{
+    Assert(strlen(pszStr) <= cbId);
+
+    uint32_t idx = 0;
+    while (*pszStr != '\0')
+        pbId[idx++] = (uint8_t)*pszStr++;
+
+    while (idx < cbId)
+        pbId[idx++] = chPad;
+}
+
+
+/**
+ * Updates the package length of the current package in the stack
+ *
+ * @param pThis                 The ACPI table instance.
+ * @param cbAdd                 How many bytes to add to the package length.
+ */
+DECL_FORCE_INLINE(void) rtAcpiTblUpdatePkgLength(PRTACPITBLINT pThis, uint32_t cbAdd)
+{
+    PRTACPITBLSTACKELEM pPkgElem = &pThis->paPkgStack[pThis->idxPkgStackElem];
+    pPkgElem->cbPkg += cbAdd;
+}
+
+
+/**
+ * Ensures there is the given amount of room in the ACPI table buffer returning the pointer.
+ *
+ * @returns The pointer to the free space on success or NULL if out of memory.
+ * @param pThis                 The ACPI table instance.
+ * @param cbReq                 Amount of bytes requested.
+ */
+static uint8_t *rtAcpiTblBufEnsureSpace(PRTACPITBLINT pThis, uint32_t cbReq)
+{
+    if (RT_LIKELY(pThis->cbTblBuf - pThis->offTblBuf >= cbReq))
+    {
+        uint8_t *pb = &pThis->pbTblBuf[pThis->offTblBuf];
+        pThis->offTblBuf += cbReq;
+        return pb;
+    }
+
+    uint32_t const cbNew = RT_ALIGN_32(pThis->cbTblBuf + cbReq, _4K);
+    uint8_t *pbNew = (uint8_t *)RTMemRealloc(pThis->pbTblBuf, cbNew);
+    if (RT_UNLIKELY(!pbNew))
+    {
+        pThis->rcErr = VERR_NO_MEMORY;
+        return NULL;
+    }
+
+    pThis->pbTblBuf = pbNew;
+    pThis->cbTblBuf = cbNew;
+
+    uint8_t *pb = &pThis->pbTblBuf[pThis->offTblBuf];
+    pThis->offTblBuf += cbReq;
+    return pb;
+}
+
+
+/**
+ * Appends a new package in the given ACPI table instance package stack.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
+ * @param pThis                 The ACPI table instance.
+ * @param bOp                   The opcode byte the package starts with (for verification purposes when finalizing the package).
+ * @param pbPkgBuf              The Start of the package buffer.
+ */
+static int rtAcpiTblPkgAppendEx(PRTACPITBLINT pThis, uint8_t bOp, uint8_t *pbPkgBuf)
+{
+    /* Get a new stack element. */
+    if (pThis->idxPkgStackElem + 1 == pThis->cPkgStackElems)
+    {
+        uint32_t const cPkgElemsNew = pThis->cPkgStackElems + 8;
+        PRTACPITBLSTACKELEM paPkgStackNew = (PRTACPITBLSTACKELEM)RTMemRealloc(pThis->paPkgStack, cPkgElemsNew * sizeof(*paPkgStackNew));
+        if (!paPkgStackNew)
+        {
+            pThis->rcErr = VERR_NO_MEMORY;
+            return VERR_NO_MEMORY;
+        }
+
+        pThis->paPkgStack     = paPkgStackNew;
+        pThis->cPkgStackElems = cPkgElemsNew;
+    }
+
+    PRTACPITBLSTACKELEM pStackElem = &pThis->paPkgStack[++pThis->idxPkgStackElem];
+    pStackElem->pbPkgLength = pbPkgBuf;
+    pStackElem->cbPkg       = 0;
+    pStackElem->bOp         = bOp;
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Starts a new ACPI package in the given ACPI table instance.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
+ * @param pThis                 The ACPI table instance.
+ * @param bOp                   The opcode byte identifying the package content.
+ */
+static int rtAcpiTblPkgStart(PRTACPITBLINT pThis, uint8_t bOp)
+{
+    /*
+     * Allocate 1 byte for opcode + always 4 bytes for the PkgLength, as we don't know how much we will need upfront.
+     * This will be corrected when the package is finalized.
+     */
+    uint8_t *pbPkg = rtAcpiTblBufEnsureSpace(pThis, 5);
+    if (!pbPkg)
+    {
+        pThis->rcErr = VERR_NO_MEMORY;
+        return VERR_NO_MEMORY;
+    }
+
+    *pbPkg = bOp;
+    /*
+     * Update the package length of the outer package for the opcode,
+     * the PkgLength object's final length will be added in rtAcpiTblPkgFinish().
+     */
+    rtAcpiTblUpdatePkgLength(pThis, sizeof(bOp));
+    return rtAcpiTblPkgAppendEx(pThis, bOp, pbPkg + 1);
+}
+
+
+/**
+ * Starts a new ACPI package in the given ACPI table instance. This is for opcodes prefixed with
+ * ACPI_AML_BYTE_CODE_PREFIX_EXT_O, which will be added automatically.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
+ * @param pThis                 The ACPI table instance.
+ * @param bOp                   The opcode byte identifying the package content.
+ */
+static int rtAcpiTblPkgStartExt(PRTACPITBLINT pThis, uint8_t bOp)
+{
+    /*
+     * Allocate 2 bytes for ExtOpPrefix opcode + always 4 bytes for the PkgLength, as we don't know how much we will need upfront.
+     * This will be corrected when the package is finalized.
+     */
+    uint8_t *pbPkg = rtAcpiTblBufEnsureSpace(pThis, 6);
+    if (!pbPkg)
+    {
+        pThis->rcErr = VERR_NO_MEMORY;
+        return VERR_NO_MEMORY;
+    }
+
+    pbPkg[0] = ACPI_AML_BYTE_CODE_PREFIX_EXT_OP;
+    pbPkg[1] = bOp;
+
+    /*
+     * Update the package length of the outer package for the opcode,
+     * the PkgLength object's final length will be added in rtAcpiTblPkgFinish().
+     */
+    rtAcpiTblUpdatePkgLength(pThis, sizeof(uint8_t) + sizeof(bOp));
+    return rtAcpiTblPkgAppendEx(pThis, bOp, pbPkg + 2);
+}
+
+
+/**
+ * Finishes the current package on the top of the package stack, setting the
+ * package length accordingly.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_STATE if bOp doesn't match the opcode the package was started with (asserted in debug builds).
+ * @retval VERR_BUFFER_OVERFLOW if the package length exceeds what can be encoded in the package length field.
+ * @param pThis                 The ACPI table instance.
+ * @param bOp                   The opcode byte identifying the package content the package was started with.
+ */
+static int rtAcpiTblPkgFinish(PRTACPITBLINT pThis, uint8_t bOp)
+{
+    /* Ensure the op matches what is current on the top of the stack. */
+    AssertReturn(pThis->paPkgStack[pThis->idxPkgStackElem].bOp == bOp, VERR_INVALID_STATE);
+
+    /* Pop the topmost stack element from the stack. */
+    PRTACPITBLSTACKELEM pPkgElem = &pThis->paPkgStack[pThis->idxPkgStackElem--];
+
+    /*
+     * Determine how many bytes we actually need for the PkgLength and re-arrange the ACPI table.
+     *
+     * Note! PkgLength will also include its own length.
+     */
+    uint8_t  *pbPkgLength = pPkgElem->pbPkgLength;
+    uint32_t cbThisPkg    = pPkgElem->cbPkg;
+    if (cbThisPkg + 1 <= 63)
+    {
+        /* Remove the gap. */
+        memmove(pbPkgLength + 1, pbPkgLength + 4, cbThisPkg);
+        pThis->offTblBuf -= 3;
+
+        /* PkgLength only consists of the package lead byte. */
+        cbThisPkg += 1;
+        *pbPkgLength = (cbThisPkg & 0x3f);
+    }
+    else if (cbThisPkg + 2 < RT_BIT_32(12))
+    {
+        /* Remove the gap. */
+        memmove(pbPkgLength + 2, pbPkgLength + 4, cbThisPkg);
+        pThis->offTblBuf -= 2;
+
+        cbThisPkg += 2;
+        pbPkgLength[0] = (1 << 6) | (cbThisPkg & 0xf);
+        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
+    }
+    else if (cbThisPkg + 3 < RT_BIT_32(20))
+    {
+        /* Remove the gap. */
+        memmove(pbPkgLength + 3, pbPkgLength + 4, cbThisPkg);
+        pThis->offTblBuf -= 1;
+
+        cbThisPkg += 3;
+        pbPkgLength[0] = (2 << 6) | (cbThisPkg & 0xf);
+        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
+        pbPkgLength[2] = (cbThisPkg >> 12) & 0xff;
+    }
+    else if (cbThisPkg + 4 < RT_BIT_32(28))
+    {
+        cbThisPkg += 4;
+        pbPkgLength[0] = (3 << 6) | (cbThisPkg & 0xf);
+        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
+        pbPkgLength[2] = (cbThisPkg >> 12) & 0xff;
+        pbPkgLength[3] = (cbThisPkg >> 20) & 0xff;
+    }
+    else
+        return VERR_BUFFER_OVERFLOW;
+
+    /* Update the size of the outer package. */
+    pThis->paPkgStack[pThis->idxPkgStackElem].cbPkg += cbThisPkg;
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Appends the given byte to the ACPI table, updating the package length of the current package.
+ *
+ * @param pThis                 The ACPI table instance.
+ * @param bData                 The byte data to append.
+ */
+DECLINLINE(void) rtAcpiTblAppendByte(PRTACPITBLINT pThis, uint8_t bData)
+{
+    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, sizeof(bData));
+    if (pb)
+    {
+        *pb = bData;
+        rtAcpiTblUpdatePkgLength(pThis, sizeof(bData));
+    }
+}
+
+
+/**
+ * Appends the given date to the ACPI table, updating the package length of the current package.
+ *
+ * @param pThis                 The ACPI table instance.
+ * @param pvData                The data to append.
+ * @param cbData                Size of the data in bytes.
+ */
+DECLINLINE(void) rtAcpiTblAppendData(PRTACPITBLINT pThis, const void *pvData, uint32_t cbData)
+{
+    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, cbData);
+    if (pb)
+    {
+        memcpy(pb, pvData, cbData);
+        rtAcpiTblUpdatePkgLength(pThis, cbData);
+    }
+}
+
+
+/**
+ * Appends the given namestring to the ACPI table, updating the package length of the current package
+ * and padding the name with _ if too short.
+ *
+ * @param pThis                 The ACPI table instance.
+ * @param pszName               The name to append, maximum is 4 bytes (or 5 if \\ is the first character).
+ */
+DECLINLINE(void) rtAcpiTblAppendNameString(PRTACPITBLINT pThis, const char *pszName)
+{
+    uint32_t cbName = *pszName == '\\' ? 5 : 4;
+    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, cbName);
+    if (pb)
+    {
+        rtAcpiTblCopyStringPadWith(pb, cbName, pszName, '_');
+        rtAcpiTblUpdatePkgLength(pThis, cbName);
+    }
+}
+
+
+/**
+ * Encodes a PkgLength item for the given number.
+ *
+ * @returns IPRT status code.
+ * @param pThis                 The ACPI table instance.
+ * @param u64Length             The length to encode.
+ */
+DECLINLINE(int) rtAcpiTblEncodePkgLength(PRTACPITBLINT pThis, uint64_t u64Length)
+{
+    AssertReturn(u64Length < RT_BIT_32(28), VERR_BUFFER_OVERFLOW);
+
+    if (u64Length <= 63)
+    {
+        /* PkgLength only consists of the package lead byte. */
+        rtAcpiTblAppendByte(pThis, (u64Length & 0x3f));
+    }
+    else if (u64Length < RT_BIT_32(12))
+    {
+        uint8_t abData[2];
+        abData[0] = (1 << 6) | (u64Length & 0xf);
+        abData[1] = (u64Length >> 4) & 0xff;
+        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
+    }
+    else if (u64Length < RT_BIT_32(20))
+    {
+        uint8_t abData[3];
+        abData[0] = (2 << 6) | (u64Length & 0xf);
+        abData[1] = (u64Length >> 4)  & 0xff;
+        abData[2] = (u64Length >> 12) & 0xff;
+        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
+    }
+    else if (u64Length < RT_BIT_32(28))
+    {
+        uint8_t abData[4];
+        abData[0] = (3 << 6) | (u64Length & 0xf);
+        abData[1] = (u64Length >> 4)  & 0xff;
+        abData[2] = (u64Length >> 12) & 0xff;
+        abData[3] = (u64Length >> 20) & 0xff;
+        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
+    }
+    else
+        AssertReleaseFailed();
+
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(uint8_t) RTAcpiChecksumGenerate(const void *pvData, size_t cbData)
+{
+    uint8_t const *pbSrc = (uint8_t const *)pvData;
+    uint8_t bSum = 0;
+    for (size_t i = 0; i < cbData; ++i)
+        bSum += pbSrc[i];
+
+    return -bSum;
+}
+
+
+RTDECL(void) RTAcpiTblHdrChecksumGenerate(PACPITBLHDR pTbl, size_t cbTbl)
+{
+    pTbl->bChkSum = 0;
+    pTbl->bChkSum = RTAcpiChecksumGenerate(pTbl, cbTbl);
+}
+
+
+RTDECL(int) RTAcpiTblCreate(PRTACPITBL phAcpiTbl, uint32_t u32TblSig, uint8_t bRevision, const char *pszOemId,
+                            const char *pszOemTblId, uint32_t u32OemRevision, const char *pszCreatorId,
+                            uint32_t u32CreatorRevision)
+{
+    AssertPtrReturn(phAcpiTbl,   VERR_INVALID_POINTER);
+    AssertPtrReturn(pszOemId,    VERR_INVALID_POINTER);
+    AssertPtrReturn(pszOemTblId, VERR_INVALID_POINTER);
+    AssertReturn(strlen(pszOemId) <= 6, VERR_INVALID_PARAMETER);
+    AssertReturn(strlen(pszOemTblId) <= 8, VERR_INVALID_PARAMETER);
+    AssertReturn(!pszCreatorId || strlen(pszCreatorId) <= 4, VERR_INVALID_PARAMETER);
+
+    PRTACPITBLINT pThis = (PRTACPITBLINT)RTMemAllocZ(sizeof(*pThis));
+    if (pThis)
+    {
+        pThis->pbTblBuf = (uint8_t *)RTMemAlloc(_4K);
+        if (pThis->pbTblBuf)
+        {
+            pThis->pHdr            = (PACPITBLHDR)pThis->pbTblBuf;
+            pThis->offTblBuf       = sizeof(*pThis->pHdr);
+            pThis->cbTblBuf        = _4K;
+            pThis->fFinalized      = false;
+            pThis->rcErr           = VINF_SUCCESS;
+            pThis->paPkgStack      = NULL;
+            pThis->cPkgStackElems  = 0;
+            pThis->idxPkgStackElem = 0;
+
+            /* Add the root stack element for the table, aka DefinitionBlock() in ASL. */
+            uint32_t const cPkgElemsInitial = 8;
+            pThis->paPkgStack = (PRTACPITBLSTACKELEM)RTMemAlloc(cPkgElemsInitial * sizeof(*pThis->paPkgStack));
+            if (pThis->paPkgStack)
+            {
+                pThis->cPkgStackElems = cPkgElemsInitial;
+
+                PRTACPITBLSTACKELEM pStackElem = &pThis->paPkgStack[pThis->idxPkgStackElem];
+                pStackElem->pbPkgLength        = pThis->pbTblBuf; /* Starts with the header. */
+                pStackElem->cbPkg              = sizeof(*pThis->pHdr);
+                pStackElem->bOp                = UINT8_MAX;
+
+                /* Init the table header with static things. */
+                pThis->pHdr->u32Signature       = u32TblSig;
+                pThis->pHdr->bRevision          = bRevision;
+                pThis->pHdr->u32OemRevision     = RT_H2LE_U32(u32OemRevision);
+                pThis->pHdr->u32CreatorRevision = RT_H2LE_U32(u32CreatorRevision);
+
+                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abOemId[0],     sizeof(pThis->pHdr->abOemId),     pszOemId,    ' ');
+                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abOemTblId[0],  sizeof(pThis->pHdr->abOemTblId),  pszOemTblId, ' ');
+                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abCreatorId[0], sizeof(pThis->pHdr->abCreatorId),
+                                           pszCreatorId ? pszCreatorId : "IPRT", ' ');
+
+                *phAcpiTbl = pThis;
+                return VINF_SUCCESS;
+            }
+
+            RTMemFree(pThis->pbTblBuf);
+        }
+
+        RTMemFree(pThis);
+    }
+
+    return VERR_NO_MEMORY;
+}
+
+
+RTDECL(void) RTAcpiTblDestroy(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturnVoid(pThis);
+
+    RTMemFree(pThis->paPkgStack);
+    RTMemFree(pThis->pbTblBuf);
+    pThis->pHdr            = NULL;
+    pThis->pbTblBuf        = NULL;
+    pThis->cbTblBuf        = 0;
+    pThis->offTblBuf       = 0;
+    pThis->paPkgStack      = NULL;
+    pThis->cPkgStackElems  = 0;
+    pThis->idxPkgStackElem = 0;
+    RTMemFree(pThis);
+}
+
+
+RTDECL(int) RTAcpiTblFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+    AssertReturn(!pThis->fFinalized, VERR_INVALID_PARAMETER);
+    AssertReturn(pThis->idxPkgStackElem == 0, VERR_INVALID_STATE); /** @todo Better status code. */
+    AssertReturn(pThis->paPkgStack[0].bOp == UINT8_MAX, VERR_INVALID_STATE);
+
+    pThis->pHdr->cbTbl = RT_H2LE_U32(pThis->paPkgStack[0].cbPkg);
+    RTAcpiTblHdrChecksumGenerate(pThis->pHdr, pThis->paPkgStack[0].cbPkg);
+
+    pThis->fFinalized = true;
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(uint32_t) RTAcpiTblGetSize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, 0);
+    AssertRCReturn(pThis->rcErr, 0);
+    AssertReturn(pThis->fFinalized, 0);
+
+    return pThis->paPkgStack[0].cbPkg;
+}
+
+
+RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, RTVFSIOSTREAM hVfsIos)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertRCReturn(pThis->rcErr, 0);
+    AssertReturn(enmOutType == RTACPITBLTYPE_AML, VERR_NOT_SUPPORTED);
+
+    return RTVfsIoStrmWrite(hVfsIos, pThis->pbTblBuf, pThis->paPkgStack[0].cbPkg,
+                            true /*fBlocking*/, NULL /*pcbWritten*/);
+}
+
+
+RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, const char *pszFilename)
+{
+    RTVFSIOSTREAM hVfsIos = NIL_RTVFSIOSTREAM;
+    int rc = RTVfsChainOpenIoStream(pszFilename, RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_NONE,
+                                    &hVfsIos, NULL /*poffError*/, NULL);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    rc = RTAcpiTblDumpToVfsIoStrm(hAcpiTbl, enmOutType, hVfsIos);
+    RTVfsIoStrmRelease(hVfsIos);
+    return rc;
+}
+
+
+RTDECL(int) RTAcpiTblScopeFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_SCOPE);
+}
+
+
+RTDECL(int) RTAcpiTblScopeStart(RTACPITBL hAcpiTbl, const char *pszName)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_SCOPE);
+    rtAcpiTblAppendNameString(pThis, pszName);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblPackageStart(RTACPITBL hAcpiTbl, uint8_t cElements)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_PACKAGE);
+    rtAcpiTblAppendByte(pThis, cElements);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblPackageFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_PACKAGE);
+}
+
+
+RTDECL(int) RTAcpiTblDeviceStart(RTACPITBL hAcpiTbl, const char *pszName)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_EXT_OP_DEVICE);
+    rtAcpiTblAppendNameString(pThis, pszName);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblDeviceStartF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...)
+{
+    va_list va;
+    va_start(va, pszNameFmt);
+    int rc = RTAcpiTblDeviceStartV(hAcpiTbl, pszNameFmt, va);
+    va_end(va);
+    return rc;
+}
+
+
+RTDECL(int) RTAcpiTblDeviceStartV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va)
+{
+    char szName[5];
+    ssize_t cch = RTStrPrintf2V(&szName[0], sizeof(szName), pszNameFmt, va);
+    if (cch <= 0)
+        return VERR_BUFFER_OVERFLOW;
+
+    return RTAcpiTblDeviceStart(hAcpiTbl, &szName[0]);
+}
+
+
+RTDECL(int) RTAcpiTblDeviceFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_EXT_OP_DEVICE);
+}
+
+
+RTDECL(int) RTAcpiTblMethodStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t cArgs, uint32_t fFlags, uint8_t uSyncLvl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(cArgs < 8, VERR_INVALID_PARAMETER);
+    AssertReturn(uSyncLvl < 0x10, VERR_INVALID_PARAMETER);
+
+    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_METHOD);
+    rtAcpiTblAppendNameString(pThis, pszName);
+
+    uint8_t bFlags = cArgs;
+    bFlags |= fFlags & RTACPI_METHOD_F_SERIALIZED ? RT_BIT(3) : 0;
+    bFlags |= uSyncLvl << 4;
+
+    rtAcpiTblAppendByte(pThis, bFlags);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblMethodFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_METHOD);
+}
+
+
+RTDECL(int) RTAcpiTblNameAppend(RTACPITBL hAcpiTbl, const char *pszName)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_NAME);
+    rtAcpiTblAppendNameString(pThis, pszName);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblNullNameAppend(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblAppendByte(pThis, 0x00);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblNameStringAppend(RTACPITBL hAcpiTbl, const char *pszName)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblAppendNameString(pThis, pszName);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblStringAppend(RTACPITBL hAcpiTbl, const char *psz)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_STRING);
+    rtAcpiTblAppendData(pThis, psz, (uint32_t)strlen(psz) + 1);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblIntegerAppend(RTACPITBL hAcpiTbl, uint64_t u64)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    if (!u64)
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ZERO);
+    else if (u64 == 1)
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ONE);
+    else if (u64 <= UINT8_MAX)
+    {
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_BYTE);
+        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
+    }
+    else if (u64 <= UINT16_MAX)
+    {
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_WORD);
+        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 8));
+    }
+    else if (u64 <= UINT32_MAX)
+    {
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_DWORD);
+        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >>  8));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 16));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 24));
+    }
+    else
+    {
+        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_QWORD);
+        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >>  8));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 16));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 24));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 32));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 40));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 48));
+        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 56));
+    }
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblBufferAppend(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(!cbBuf || RT_VALID_PTR(pvBuf), VERR_INVALID_PARAMETER);
+    AssertReturn(cbBuf <= UINT32_MAX, VERR_BUFFER_OVERFLOW);
+
+    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_BUFFER);
+    RTAcpiTblIntegerAppend(hAcpiTbl, cbBuf);
+    if (pvBuf)
+        rtAcpiTblAppendData(pThis, pvBuf, (uint32_t)cbBuf);
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_BUFFER);
+}
+
+
+RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    const void *pvRes = NULL;
+    size_t cbRes = 0;
+    int rc = RTAcpiResourceQueryBuffer(hAcpiRes, &pvRes, &cbRes);
+    if (RT_SUCCESS(rc))
+        rc = RTAcpiTblBufferAppend(pThis, pvRes, cbRes);
+
+    return rc;
+}
+
+
+RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    uint8_t bOp;
+    switch (enmStmt)
+    {
+        case kAcpiStmt_Return:     bOp = ACPI_AML_BYTE_CODE_OP_RETURN;      break;
+        case kAcpiStmt_Breakpoint: bOp = ACPI_AML_BYTE_CODE_OP_BREAK_POINT; break;
+        case kAcpiStmt_Nop:        bOp = ACPI_AML_BYTE_CODE_OP_NOOP;        break;
+        case kAcpiStmt_Break:      bOp = ACPI_AML_BYTE_CODE_OP_BREAK;       break;
+        case kAcpiStmt_Continue:   bOp = ACPI_AML_BYTE_CODE_OP_CONTINUE;    break;
+        case kAcpiStmt_Add:        bOp = ACPI_AML_BYTE_CODE_OP_ADD;         break;
+        case kAcpiStmt_Subtract:   bOp = ACPI_AML_BYTE_CODE_OP_SUBTRACT;    break;
+        case kAcpiStmt_And:        bOp = ACPI_AML_BYTE_CODE_OP_AND;         break;
+        case kAcpiStmt_Nand:       bOp = ACPI_AML_BYTE_CODE_OP_NAND;        break;
+        case kAcpiStmt_Or:         bOp = ACPI_AML_BYTE_CODE_OP_OR;          break;
+        case kAcpiStmt_Xor:        bOp = ACPI_AML_BYTE_CODE_OP_XOR;         break;
+        case kAcpiStmt_Not:        bOp = ACPI_AML_BYTE_CODE_OP_NOT;         break;
+        case kAcpiStmt_Store:      bOp = ACPI_AML_BYTE_CODE_OP_STORE;       break;
+        case kAcpiStmt_Index:      bOp = ACPI_AML_BYTE_CODE_OP_INDEX;       break;
+        case kAcpiStmt_DerefOf:    bOp = ACPI_AML_BYTE_CODE_OP_DEREF_OF;    break;
+        default:
+            AssertFailedReturn(VERR_INVALID_PARAMETER);
+    }
+    rtAcpiTblAppendByte(pThis, bOp);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_IF);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_IF);
+}
+
+
+RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    /* Makes only sense inside an IfOp package. */
+    AssertReturn(pThis->paPkgStack[pThis->idxPkgStackElem].bOp == ACPI_AML_BYTE_CODE_OP_IF, VERR_INVALID_STATE);
+
+    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
+}
+
+
+RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    uint8_t bOp;
+    switch (enmBinaryOp)
+    {
+        case kAcpiBinaryOp_LAnd:            bOp = ACPI_AML_BYTE_CODE_OP_LAND;     break;
+        case kAcpiBinaryOp_LEqual:          bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
+        case kAcpiBinaryOp_LGreater:        bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
+        case kAcpiBinaryOp_LLess:           bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
+        case kAcpiBinaryOp_LGreaterEqual:
+        case kAcpiBinaryOp_LLessEqual:
+        case kAcpiBinaryOp_LNotEqual:
+            bOp = ACPI_AML_BYTE_CODE_OP_LNOT;
+            break;
+        default:
+            AssertFailedReturn(VERR_INVALID_PARAMETER);
+    }
+    rtAcpiTblAppendByte(pThis, bOp);
+    switch (enmBinaryOp)
+    {
+        case kAcpiBinaryOp_LGreaterEqual:   bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
+        case kAcpiBinaryOp_LLessEqual:      bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
+        case kAcpiBinaryOp_LNotEqual:       bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
+        default:
+            bOp = 0x00;
+    }
+    if (bOp != 0x00)
+        rtAcpiTblAppendByte(pThis, bOp);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(idArg <= 6, VERR_INVALID_PARAMETER);
+
+    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ARG_0 + idArg);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(idLocal <= 7, VERR_INVALID_PARAMETER);
+
+    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_LOCAL_0 + idLocal);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid)
+{
+    /* UUIDs are stored as a buffer object. */
+    /** @todo Needs conversion on big endian machines. */
+    return RTAcpiTblBufferAppend(hAcpiTbl, &pUuid->au8[0], sizeof(*pUuid));
+}
+
+
+RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    RTUUID Uuid;
+    pThis->rcErr = RTUuidFromStr(&Uuid, pszUuid);
+    if (RT_SUCCESS(pThis->rcErr))
+        return RTAcpiTblUuidAppend(pThis, &Uuid);
+
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblOpRegionAppendEx(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    uint8_t abOp[2] = { ACPI_AML_BYTE_CODE_PREFIX_EXT_OP, ACPI_AML_BYTE_CODE_EXT_OP_OP_REGION };
+    rtAcpiTblAppendData(pThis, &abOp[0], sizeof(abOp));
+    rtAcpiTblAppendNameString(pThis, pszName);
+
+    uint8_t bRegionSpace = 0xff;
+    switch (enmSpace)
+    {
+        case kAcpiOperationRegionSpace_SystemMemory:        bRegionSpace = 0x00; break;
+        case kAcpiOperationRegionSpace_SystemIo:            bRegionSpace = 0x01; break;
+        case kAcpiOperationRegionSpace_PciConfig:           bRegionSpace = 0x02; break;
+        case kAcpiOperationRegionSpace_EmbeddedControl:     bRegionSpace = 0x03; break;
+        case kAcpiOperationRegionSpace_SmBus:               bRegionSpace = 0x04; break;
+        case kAcpiOperationRegionSpace_SystemCmos:          bRegionSpace = 0x05; break;
+        case kAcpiOperationRegionSpace_PciBarTarget:        bRegionSpace = 0x06; break;
+        case kAcpiOperationRegionSpace_Ipmi:                bRegionSpace = 0x07; break;
+        case kAcpiOperationRegionSpace_Gpio:                bRegionSpace = 0x08; break;
+        case kAcpiOperationRegionSpace_GenericSerialBus:    bRegionSpace = 0x09; break;
+        case kAcpiOperationRegionSpace_Pcc:                 bRegionSpace = 0x0a; break;
+        default:
+            pThis->rcErr = VERR_INVALID_PARAMETER;
+            AssertFailedReturn(pThis->rcErr);
+    }
+    rtAcpiTblAppendByte(pThis, bRegionSpace);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace,
+                                    uint64_t offRegion, uint64_t cbRegion)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    int rc = RTAcpiTblOpRegionAppendEx(pThis, pszName, enmSpace);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    RTAcpiTblIntegerAppend(pThis, offRegion);
+    RTAcpiTblIntegerAppend(pThis, cbRegion);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc,
+                                 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields,
+                                 uint32_t cFields)
+{
+    PRTACPITBLINT pThis = hAcpiTbl;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+
+    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD);
+    rtAcpiTblAppendNameString(pThis, pszNameRef);
+
+    uint8_t fFlags = 0;
+    switch (enmAcc)
+    {
+        case kAcpiFieldAcc_Any:    fFlags = 0; break;
+        case kAcpiFieldAcc_Byte:   fFlags = 1; break;
+        case kAcpiFieldAcc_Word:   fFlags = 2; break;
+        case kAcpiFieldAcc_DWord:  fFlags = 3; break;
+        case kAcpiFieldAcc_QWord:  fFlags = 4; break;
+        case kAcpiFieldAcc_Buffer: fFlags = 5; break;
+        default:
+            pThis->rcErr = VERR_INVALID_PARAMETER;
+            AssertFailedReturn(pThis->rcErr);
+    }
+    if (fLock)
+        fFlags |= RT_BIT(4);
+    switch (enmUpdate)
+    {
+        case kAcpiFieldUpdate_Preserve:      fFlags |= 0 << 5; break;
+        case kAcpiFieldUpdate_WriteAsOnes:   fFlags |= 1 << 5; break;
+        case kAcpiFieldUpdate_WriteAsZeroes: fFlags |= 2 << 5; break;
+        default:
+            pThis->rcErr = VERR_INVALID_PARAMETER;
+            AssertFailedReturn(pThis->rcErr);
+    }
+    rtAcpiTblAppendByte(pThis, fFlags);
+
+    for (uint32_t i = 0; i < cFields; i++)
+    {
+        rtAcpiTblAppendNameString(pThis, paFields[i].pszName);
+        rtAcpiTblEncodePkgLength(pThis, paFields[i].cBits);
+    }
+
+    rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD);
+    return pThis->rcErr;
+}
+
+
+RTDECL(int) RTAcpiTblCreateFromVfsIoStrm(PRTACPITBL phAcpiTbl, RTVFSIOSTREAM hVfsIos, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
+{
+    AssertPtrReturn(phAcpiTbl, VERR_INVALID_POINTER);
+    AssertReturn(hVfsIos != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
+
+    RT_NOREF(pErrInfo, enmInType);
+#if 0
+    if (enmInType == RTACPITBLTYPE_AML)
+        return rtAcpiTblLoadAml(phAcpiTbl, hVfsIos, pErrInfo);
+#endif
+
+    return VERR_NOT_IMPLEMENTED;
+}
+
+
+RTDECL(int) RTAcpiTblConvertFromVfsIoStrm(RTVFSIOSTREAM hVfsIosOut, RTACPITBLTYPE enmOutType,
+                                          RTVFSIOSTREAM hVfsIosIn, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
+{
+    AssertReturn(hVfsIosOut != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
+    AssertReturn(hVfsIosIn  != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
+
+    if (enmInType == RTACPITBLTYPE_AML && enmOutType == RTACPITBLTYPE_ASL)
+        return rtAcpiTblConvertFromAmlToAsl(hVfsIosOut, hVfsIosIn, pErrInfo);
+    else if (enmInType == RTACPITBLTYPE_ASL && enmOutType == RTACPITBLTYPE_AML)
+        return rtAcpiTblConvertFromAslToAml(hVfsIosOut, hVfsIosIn, pErrInfo);
+
+    return VERR_NOT_SUPPORTED;
+}
+
+
+RTDECL(int) RTAcpiTblCreateFromFile(PRTACPITBL phAcpiTbl, const char *pszFilename, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
+{
+    RTVFSIOSTREAM hVfsIos = NIL_RTVFSIOSTREAM;
+    int rc = RTVfsChainOpenIoStream(pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
+                                    &hVfsIos, NULL /*poffError*/, pErrInfo);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    rc = RTAcpiTblCreateFromVfsIoStrm(phAcpiTbl, hVfsIos, enmInType, pErrInfo);
+    RTVfsIoStrmRelease(hVfsIos);
+    return rc;
+}
+
+
+/**
+ * Ensures there is at least the given amount of space in the given ACPI resource.
+ *
+ * @returns Pointer to the free buffer space or NULL if out of memory.
+ * @param   pThis               The ACPI resource instance.
+ * @param   cbReq               Number of free bytes required.
+ */
+static uint8_t *rtAcpiResBufEnsureSpace(PRTACPIRESINT pThis, uint32_t cbReq)
+{
+    if (RT_LIKELY(pThis->cbResBuf - pThis->offResBuf >= cbReq))
+    {
+        uint8_t *pb = &pThis->pbResBuf[pThis->offResBuf];
+        pThis->offResBuf += cbReq;
+        return pb;
+    }
+
+    size_t const cbNew = RT_ALIGN_Z(pThis->cbResBuf + cbReq, _4K);
+    uint8_t *pbNew = (uint8_t *)RTMemRealloc(pThis->pbResBuf, cbNew);
+    if (RT_UNLIKELY(!pbNew))
+    {
+        pThis->rcErr = VERR_NO_MEMORY;
+        return NULL;
+    }
+
+    pThis->pbResBuf = pbNew;
+    pThis->cbResBuf = cbNew;
+
+    uint8_t *pb = &pThis->pbResBuf[pThis->offResBuf];
+    pThis->offResBuf += cbReq;
+    return pb;
+}
+
+
+/**
+ * Encodes an ACPI 16-bit integer in the given byte buffer.
+ *
+ * @returns Pointer to after the encoded integer.
+ * @param   pb                  Where to encode the integer into.
+ * @param   u16                 The 16-bit unsigned integere to encode.
+ */
+DECLINLINE(uint8_t *) rtAcpiResEncode16BitInteger(uint8_t *pb, uint16_t u16)
+{
+    *pb++ = (uint8_t)u16;
+    *pb++ = (uint8_t)(u16 >>  8);
+    return pb;
+}
+
+
+/**
+ * Encodes an ACPI 32-bit integer in the given byte buffer.
+ *
+ * @returns Pointer to after the encoded integer.
+ * @param   pb                  Where to encode the integer into.
+ * @param   u32                 The 32-bit unsigned integere to encode.
+ */
+DECLINLINE(uint8_t *) rtAcpiResEncode32BitInteger(uint8_t *pb, uint32_t u32)
+{
+    *pb++ = (uint8_t)u32;
+    *pb++ = (uint8_t)(u32 >>  8);
+    *pb++ = (uint8_t)(u32 >> 16);
+    *pb++ = (uint8_t)(u32 >> 24);
+    return pb;
+}
+
+/**
+ * Encodes an ACPI 64-bit integer in the given byte buffer.
+ *
+ * @returns Pointer to after the encoded integer.
+ * @param   pb                  Where to encode the integer into.
+ * @param   u64                 The 64-bit unsigned integere to encode.
+ */
+
+DECLINLINE(uint8_t *) rtAcpiResEncode64BitInteger(uint8_t *pb, uint64_t u64)
+{
+    *pb++ = (uint8_t)u64;
+    *pb++ = (uint8_t)(u64 >>  8);
+    *pb++ = (uint8_t)(u64 >> 16);
+    *pb++ = (uint8_t)(u64 >> 24);
+    *pb++ = (uint8_t)(u64 >> 32);
+    *pb++ = (uint8_t)(u64 >> 40);
+    *pb++ = (uint8_t)(u64 >> 48);
+    *pb++ = (uint8_t)(u64 >> 56);
+    return pb;
+}
+
+
+RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes)
+{
+    AssertPtrReturn(phAcpiRes, VERR_INVALID_POINTER);
+
+    PRTACPIRESINT pThis = (PRTACPIRESINT)RTMemAllocZ(sizeof(*pThis));
+    if (pThis)
+    {
+        pThis->pbResBuf = (uint8_t *)RTMemAlloc(64);
+        if (pThis->pbResBuf)
+        {
+            pThis->offResBuf = 0;
+            pThis->cbResBuf  = 64;
+            pThis->fSealed   = false;
+            pThis->rcErr     = VINF_SUCCESS;
+
+            *phAcpiRes = pThis;
+            return VINF_SUCCESS;
+        }
+
+        RTMemFree(pThis);
+    }
+
+    return VERR_NO_MEMORY;
+}
+
+
+RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturnVoid(pThis);
+
+    RTMemFree(pThis->pbResBuf);
+    pThis->pbResBuf        = NULL;
+    pThis->cbResBuf        = 0;
+    pThis->offResBuf       = 0;
+    RTMemFree(pThis);
+}
+
+
+RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturnVoid(pThis);
+
+    pThis->offResBuf = 0;
+    pThis->fSealed   = false;
+    pThis->rcErr     = VINF_SUCCESS;
+}
+
+
+RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    /* Add the end tag. */
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 2);
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    *pb++ = ACPI_RSRCS_TAG_END;
+    /*
+     * Generate checksum, we could just write 0 here which will be treated as checksum operation succeeded,
+     * but having this might catch some bugs.
+     *
+     * Checksum algorithm is the same as with the ACPI tables.
+     */
+    *pb = RTAcpiChecksumGenerate(pThis->pbResBuf, pThis->offResBuf - 1); /* Exclude the checksum field. */
+
+    pThis->fSealed = true;
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    *ppvRes = pThis->pbResBuf;
+    *pcbRes = pThis->offResBuf;
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
+                                                   bool fRw)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 12);
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_32BIT_FIXED_MEMORY_RANGE; /* Tag          */
+    pb[1] = 9;                                                                /* Length[7:0]  */
+    pb[2] = 0;                                                                /* Length[15:8] */
+    pb[3] = fRw ? 1 : 0;                                                      /* Information  */
+    rtAcpiResEncode32BitInteger(&pb[4], u32AddrBase);
+    rtAcpiResEncode32BitInteger(&pb[8], cbRange);
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
+                                               bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 2 + cIntrs * sizeof(uint32_t));
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_EXTENDED_INTERRUPT;       /* Tag          */
+    rtAcpiResEncode16BitInteger(&pb[1], 2 + cIntrs * sizeof(uint32_t));       /* Length[15:0] */
+    pb[3] =   (fConsumer      ? ACPI_RSRCS_EXT_INTR_VEC_F_CONSUMER       : ACPI_RSRCS_EXT_INTR_VEC_F_PRODUCER)
+            | (fEdgeTriggered ? ACPI_RSRCS_EXT_INTR_VEC_F_EDGE_TRIGGERED : ACPI_RSRCS_EXT_INTR_VEC_F_LEVEL_TRIGGERED)
+            | (fActiveLow     ? ACPI_RSRCS_EXT_INTR_VEC_F_ACTIVE_LOW     : ACPI_RSRCS_EXT_INTR_VEC_F_ACTIVE_HIGH)
+            | (fShared        ? ACPI_RSRCS_EXT_INTR_VEC_F_SHARED         : ACPI_RSRCS_EXT_INTR_VEC_F_EXCLUSIVE)
+            | (fWakeCapable   ? ACPI_RSRCS_EXT_INTR_VEC_F_WAKE_CAP       : ACPI_RSRCS_EXT_INTR_VEC_F_NOT_WAKE_CAP);
+    pb[4] = cIntrs;
+    pb = &pb[5];
+    for (uint32_t i = 0; i < cIntrs; i++)
+        pb = rtAcpiResEncode32BitInteger(pb, pau32Intrs[i]);
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Common worker for encoding a new quad word (64-bit) address range.
+ *
+ * @returns IPRT status code
+ * @retval  VERR_NO_MEMORY if not enough memory could be reserved in the ACPI resource descriptor.
+ * @param   pThis               The ACPI resource instance.
+ * @param   bType               The ACPI address range type.
+ * @param   fAddrSpace          Combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX.
+ * @param   fType               The range flags returned from rtAcpiResourceMemoryRangeToTypeFlags().
+ * @param   u64AddrMin          The start address of the memory range.
+ * @param   u64AddrMax          Last valid address of the range.
+ * @param   u64OffTrans         Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
+ * @param   u64Granularity      The access granularity of the range in bytes.
+ * @param   u64Length           Length of the memory range in bytes.
+ */
+static int rtAcpiResourceAddQWordAddressRange(PRTACPIRESINT pThis, uint8_t bType, uint32_t fAddrSpace, uint8_t fType,
+                                              uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
+                                              uint64_t u64Granularity, uint64_t u64Length)
+{
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 43);
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_QWORD_ADDR_SPACE;         /* Tag          */
+    pb[1] = 43;                                                               /* Length[7:0]  */
+    pb[2] = 0;                                                                /* Length[15:8] */
+    pb[3] = bType;
+    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
+    pb[5] = fType;
+
+    pb = rtAcpiResEncode64BitInteger(&pb[6], u64Granularity);
+    pb = rtAcpiResEncode64BitInteger(pb,     u64AddrMin);
+    pb = rtAcpiResEncode64BitInteger(pb,     u64AddrMax);
+    pb = rtAcpiResEncode64BitInteger(pb,     u64OffTrans);
+         rtAcpiResEncode64BitInteger(pb,     u64Length);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Common worker for encoding a new double word (32-bit) address range.
+ *
+ * @returns IPRT status code
+ * @retval  VERR_NO_MEMORY if not enough memory could be reserved in the ACPI resource descriptor.
+ * @param   pThis               The ACPI resource instance.
+ * @param   bType               The ACPI address range type.
+ * @param   fAddrSpace          Combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX.
+ * @param   fType               The range flags returned from rtAcpiResourceMemoryRangeToTypeFlags().
+ * @param   u32AddrMin          The start address of the memory range.
+ * @param   u32AddrMax          Last valid address of the range.
+ * @param   u32OffTrans         Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
+ * @param   u32Granularity      The access granularity of the range in bytes.
+ * @param   u32Length           Length of the memory range in bytes.
+ */
+static int rtAcpiResourceAddDWordAddressRange(PRTACPIRESINT pThis, uint8_t bType, uint32_t fAddrSpace, uint8_t fType,
+                                              uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
+                                              uint32_t u32Granularity, uint32_t u32Length)
+{
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 23);
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_DWORD_ADDR_SPACE;         /* Tag          */
+    pb[1] = 23;                                                               /* Length[7:0]  */
+    pb[2] = 0;                                                                /* Length[15:8] */
+    pb[3] = bType;
+    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
+    pb[5] = fType;
+
+    pb = rtAcpiResEncode32BitInteger(&pb[6], u32Granularity);
+    pb = rtAcpiResEncode32BitInteger(pb,     u32AddrMin);
+    pb = rtAcpiResEncode32BitInteger(pb,     u32AddrMax);
+    pb = rtAcpiResEncode32BitInteger(pb,     u32OffTrans);
+         rtAcpiResEncode32BitInteger(pb,     u32Length);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Converts the given cacheability, range type and R/W flag to the ACPI resource flags.
+ *
+ * @returns Converted ACPI resource flags.
+ * @param   enmCacheability     The cacheability enum to convert.
+ * @param   enmType             THe memory range type enum to convert.
+ * @param   fRw                 The read/write flag.
+ */
+DECLINLINE(uint8_t) rtAcpiResourceMemoryRangeToTypeFlags(RTACPIRESMEMRANGECACHEABILITY enmCacheability, RTACPIRESMEMRANGETYPE enmType,
+                                                         bool fRw)
+{
+    uint8_t fType = fRw ? ACPI_RSRCS_ADDR_SPACE_MEM_F_RW : ACPI_RSRCS_ADDR_SPACE_MEM_F_RO;
+
+    switch (enmCacheability)
+    {
+        case kAcpiResMemRangeCacheability_NonCacheable:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_NON_CACHEABLE;
+            break;
+        case kAcpiResMemRangeCacheability_Cacheable:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE;
+            break;
+        case kAcpiResMemRangeCacheability_CacheableWriteCombining:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE_WR_COMB;
+            break;
+        case kAcpiResMemRangeCacheability_CacheablePrefetchable:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE_PREFETCHABLE;
+            break;
+        case kAcpiResMemRangeCacheability_Invalid:
+        default:
+            AssertFailedReturn(0);
+    }
+
+    switch (enmType)
+    {
+        case kAcpiResMemType_Memory:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_MEMORY;
+            break;
+        case kAcpiResMemType_Reserved:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_RESERVED;
+            break;
+        case kAcpiResMemType_Acpi:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_ACPI;
+            break;
+        case kAcpiResMemType_Nvs:
+            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_NVS;
+            break;
+        case kAcpiResMemType_Invalid:
+        default:
+            AssertFailedReturn(0);
+    }
+
+    return fType;
+}
+
+
+RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
+                                              RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
+                                              uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
+                                              uint64_t u64Granularity, uint64_t u64Length)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(enmCacheability != kAcpiResMemRangeCacheability_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(enmType != kAcpiResMemType_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t fType = rtAcpiResourceMemoryRangeToTypeFlags(enmCacheability, enmType, fRw);
+    return rtAcpiResourceAddQWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_MEMORY, fAddrSpace, fType,
+                                              u64AddrMin, u64AddrMax, u64OffTrans, u64Granularity, u64Length);
+}
+
+
+RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
+                                              RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
+                                              uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
+                                              uint32_t u32Granularity, uint32_t u32Length)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(enmCacheability != kAcpiResMemRangeCacheability_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(enmType != kAcpiResMemType_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t fType = rtAcpiResourceMemoryRangeToTypeFlags(enmCacheability, enmType, fRw);
+    return rtAcpiResourceAddDWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_MEMORY, fAddrSpace, fType,
+                                              u32AddrMin, u32AddrMax, u32OffTrans, u32Granularity, u32Length);
+}
+
+
+RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
+                                          uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
+                                          uint64_t u64Granularity, uint64_t u64Length)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(enmIoType != kAcpiResIoRangeType_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(enmIoRange != kAcpiResIoRange_Invalid, VERR_INVALID_PARAMETER);
+    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t fType = 0;
+    switch (enmIoType)
+    {
+        case kAcpiResIoRangeType_Static:
+            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_STATIC;
+            break;
+        case kAcpiResIoRangeType_Translation_Sparse:
+            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_TRANSLATION | ACPI_RSRCS_ADDR_SPACE_IO_F_TRANSLATION_SPARSE;
+            break;
+        case kAcpiResIoRangeType_Translation_Dense:
+            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_TRANSLATION | ACPI_RSRCS_ADDR_SPACE_IO_F_TRANSLATION_DENSE;
+            break;
+        case kAcpiResIoRangeType_Invalid:
+        default:
+            AssertFailedReturn(VERR_INVALID_PARAMETER);
+    }
+
+    switch (enmIoRange)
+    {
+        case kAcpiResIoRange_NonIsaOnly:
+            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_NON_ISA_ONLY;
+            break;
+        case kAcpiResIoRange_IsaOnly:
+            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_ISA_ONLY;
+            break;
+        case kAcpiResIoRange_Whole:
+            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_WHOLE;
+            break;
+        case kAcpiResIoRange_Invalid:
+        default:
+            AssertFailedReturn(VERR_INVALID_PARAMETER);
+    }
+
+    return rtAcpiResourceAddQWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_IO, fAddrSpace, fType,
+                                              u64AddrMin, u64AddrMax, u64OffTrans, u64Granularity, u64Length);
+}
+
+
+RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
+                                           uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length)
+{
+    PRTACPIRESINT pThis = hAcpiRes;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
+    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
+    AssertRCReturn(pThis->rcErr, pThis->rcErr);
+
+    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 13);
+    if (!pb)
+        return VERR_NO_MEMORY;
+
+    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_WORD_ADDR_SPACE;          /* Tag          */
+    pb[1] = 13;                                                               /* Length[7:0]  */
+    pb[2] = 0;                                                                /* Length[15:8] */
+    pb[3] = ACPI_RSRCS_ADDR_SPACE_TYPE_BUS_NUM_RANGE;
+    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
+            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
+    pb[5] = 0;
+
+    pb = rtAcpiResEncode16BitInteger(&pb[6], u16Granularity);
+    pb = rtAcpiResEncode16BitInteger(pb,     u16BusMin);
+    pb = rtAcpiResEncode16BitInteger(pb,     u16BusMax);
+    pb = rtAcpiResEncode16BitInteger(pb,     u16OffTrans);
+         rtAcpiResEncode16BitInteger(pb,     u16Length);
+    return VINF_SUCCESS;
+
+}
Index: trunk/src/VBox/Runtime/common/misc/acpi-decompiler.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/acpi-decompiler.cpp	(revision 108014)
+++ 	(revision )
@@ -1,1555 +1,0 @@
-/* $Id$ */
-/** @file
- * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
- */
-
-/*
- * Copyright (C) 2025 Oracle and/or its affiliates.
- *
- * This file is part of VirtualBox base platform packages, as
- * available from https://www.virtualbox.org.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, in version 3 of the
- * License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses>.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
- * in the VirtualBox distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- *
- * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
- */
-
-
-/*********************************************************************************************************************************
-*   Header Files                                                                                                                 *
-*********************************************************************************************************************************/
-#define LOG_GROUP RTLOGGROUP_ACPI
-#include <iprt/acpi.h>
-#include <iprt/asm.h>
-#include <iprt/ctype.h>
-#include <iprt/err.h>
-#include <iprt/file.h>
-#include <iprt/mem.h>
-#include <iprt/string.h>
-#include <iprt/uuid.h>
-
-#include <iprt/formats/acpi-aml.h>
-#include <iprt/formats/acpi-resources.h>
-
-
-/*********************************************************************************************************************************
-*   Defined Constants And Macros                                                                                                 *
-*********************************************************************************************************************************/
-
-
-
-/*********************************************************************************************************************************
-*   Structures and Typedefs                                                                                                      *
-*********************************************************************************************************************************/
-
-/**
- * ACPI AML -> ASL decoder state.
- */
-typedef struct RTACPITBLAMLDECODE
-{
-    /** Pointe to the raw table data. */
-    const uint8_t *pbTbl;
-    /** Size of the table. */
-    uint32_t      cbTbl;
-    /** Offset into the table. */
-    uint32_t      offTbl;
-    /** Current stack level. */
-    uint32_t      iLvl;
-    /** Number of entries in the package stack. */
-    uint32_t      cPkgStackMax;
-    /** Stack of package lengths. */
-    size_t        *pacbPkgLeft;
-    /** Stack of original package lengths. */
-    size_t        *pacbPkg;
-    /** Flag whether to indent. */
-    bool          fIndent;
-} RTACPITBLAMLDECODE;
-/** Pointer to a ACPI AML -> ASL decoder state. */
-typedef RTACPITBLAMLDECODE *PRTACPITBLAMLDECODE;
-
-
-/**
- * ACPI AML -> ASL decode callback
- *
- * @returns IPRT status code.
- * @param   pThis               ACPI table decoder state.
- * @param   hVfsIosOut          VFS I/O stream output handle.
- * @param   bOp                 The opcode.
- * @param   pErrInfo            Where to return additional error information.
- */
-typedef DECLCALLBACKTYPE(int, FNRTACPITBLAMLOPCDECODE,(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo));
-/** Pointer to a ACPI AML -> ASL decode callback. */
-typedef FNRTACPITBLAMLOPCDECODE *PFNRTACPITBLAMLOPCDECODE;
-
-
-typedef enum ACPIAMLOPCTYPE
-{
-    kAcpiAmlOpcType_Invalid = 0,
-    kAcpiAmlOpcType_Byte,
-    kAcpiAmlOpcType_Word,
-    kAcpiAmlOpcType_DWord,
-    kAcpiAmlOpcType_NameString,
-    kAcpiAmlOpcType_TermArg,
-    kAcpiAmlOpcType_SuperName,
-    kAcpiAmlOpcType_32BitHack = 0x7fffffff
-} ACPIAMLOPCTYPE;
-
-
-typedef struct RTACPIAMLOPC
-{
-    /** Name of the opcode. */
-    const char               *pszOpc;
-    /** Flags for the opcode. */
-    uint32_t                 fFlags;
-    /** Opcode type for the fields following. */
-    ACPIAMLOPCTYPE           aenmTypes[5];
-    /** Optional decoder callback. */
-    PFNRTACPITBLAMLOPCDECODE pfnDecode;
-} RTACPIAMLOPC;
-typedef RTACPIAMLOPC *PRTACPIAMLOPC;
-typedef const RTACPIAMLOPC *PCRTACPIAMLOPC;
-
-#define RTACPI_AML_OPC_F_NONE           0
-#define RTACPI_AML_OPC_F_HAS_PKG_LENGTH RT_BIT_32(0)
-
-
-/*********************************************************************************************************************************
-*   Global Variables                                                                                                             *
-*********************************************************************************************************************************/
-
-
-/*********************************************************************************************************************************
-*   Internal Functions                                                                                                           *
-*********************************************************************************************************************************/
-
-static int rtAcpiTblAmlDecodeTerminal(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo);
-
-
-DECLINLINE(int) rtAcpiTblAmlDecodeReadU8(PRTACPITBLAMLDECODE pThis, uint8_t *pb, PRTERRINFO pErrInfo)
-{
-    if (pThis->offTbl < pThis->cbTbl)
-    { /* probable */ }
-    else
-        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read a byte", pThis->offTbl);
-
-    if (!pThis->pacbPkgLeft[pThis->iLvl])
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
-
-    pThis->pacbPkgLeft[pThis->iLvl]--;
-
-    *pb = pThis->pbTbl[pThis->offTbl++];
-    return VINF_SUCCESS;
-}
-
-
-#if 0
-DECLINLINE(int) rtAcpiTblAmlDecodeSkipU8IfEqual(PRTACPITBLAMLDECODE pThis, uint8_t ch, bool *fSkipped, PRTERRINFO pErrInfo)
-{
-    if (pThis->offTbl < pThis->cbTbl)
-    { /* probable */ }
-    else
-        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read a byte", pThis->offTbl);
-
-    if (pThis->pbTbl[pThis->offTbl] == ch)
-    {
-        pThis->offTbl++;
-        *pfSkipped = true;
-    }
-    else
-        *pfSkipped = false;
-    return VINF_SUCCESS;
-}
-#endif
-
-
-DECLINLINE(int) rtAcpiTblAmlDecodeReadU16(PRTACPITBLAMLDECODE pThis, uint16_t *pu16, PRTERRINFO pErrInfo)
-{
-    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint16_t))
-    { /* probable */ }
-    else
-        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read two bytes", pThis->offTbl);
-
-    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint16_t))
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
-
-    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint16_t);
-
-    *pu16 =  pThis->pbTbl[pThis->offTbl++];
-    *pu16 |= (uint16_t)pThis->pbTbl[pThis->offTbl++] << 8;
-    return VINF_SUCCESS;
-}
-
-
-DECLINLINE(int) rtAcpiTblAmlDecodeReadU32(PRTACPITBLAMLDECODE pThis, uint32_t *pu32, PRTERRINFO pErrInfo)
-{
-    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint32_t))
-    { /* probable */ }
-    else
-        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read four bytes", pThis->offTbl);
-
-    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint32_t))
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
-
-    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint32_t);
-
-    *pu32 =  pThis->pbTbl[pThis->offTbl++];
-    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] <<  8;
-    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] << 16;
-    *pu32 |= (uint32_t)pThis->pbTbl[pThis->offTbl++] << 24;
-    return VINF_SUCCESS;
-}
-
-
-DECLINLINE(int) rtAcpiTblAmlDecodeReadU64(PRTACPITBLAMLDECODE pThis, uint64_t *pu64, PRTERRINFO pErrInfo)
-{
-    if (pThis->offTbl <= pThis->cbTbl + sizeof(uint64_t))
-    { /* probable */ }
-    else
-        return RTErrInfoSetF(pErrInfo, VERR_EOF, "AML stream ended prematurely at offset '%#x' trying to read eight bytes", pThis->offTbl);
-
-    if (pThis->pacbPkgLeft[pThis->iLvl] < sizeof(uint64_t))
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Data overflows current package limitation");
-
-    pThis->pacbPkgLeft[pThis->iLvl] -= sizeof(uint64_t);
-
-    *pu64 =  pThis->pbTbl[pThis->offTbl++];
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] <<  8;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 16;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 24;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 32;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 40;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 48;
-    *pu64 |= (uint64_t)pThis->pbTbl[pThis->offTbl++] << 54;
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeNameSeg(PRTACPITBLAMLDECODE pThis, char *pszNameString, PRTERRINFO pErrInfo)
-{
-    uint8_t abNameSeg[4];
-    for (uint8_t i = 0; i < sizeof(abNameSeg); i++)
-    {
-        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &abNameSeg[i], pErrInfo);
-        if (RT_FAILURE(rc)) return rc;
-    }
-
-    /* LeadNameChar */
-    if (   abNameSeg[0] != '_'
-        && !RTLocCIsUpper(abNameSeg[0]))
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid lead name character '%#02RX8'", abNameSeg[0]);
-
-    for (uint8_t i = 1; i < sizeof(abNameSeg); i++)
-    {
-        if (   abNameSeg[i] != '_'
-            && !RTLocCIsUpper(abNameSeg[i])
-            && !RTLocCIsDigit(abNameSeg[i]))
-            return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid name character '%#02RX8", abNameSeg[i]);
-    }
-
-    pszNameString[0] = (char)abNameSeg[0];
-    pszNameString[1] = (char)abNameSeg[1];
-    pszNameString[2] = (char)abNameSeg[2];
-    pszNameString[3] = (char)abNameSeg[3];
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeNameSegWithoutLeadChar(PRTACPITBLAMLDECODE pThis, uint8_t bLeadChar, char *pszNameString, PRTERRINFO pErrInfo)
-{
-    uint8_t abNameSeg[3];
-    for (uint8_t i = 0; i < sizeof(abNameSeg); i++)
-    {
-        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &abNameSeg[i], pErrInfo);
-        if (RT_FAILURE(rc)) return rc;
-    }
-
-    /* LeadNameChar */
-    if (   bLeadChar != '_'
-        && !RTLocCIsUpper(bLeadChar))
-        return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid lead name character '%#02RX8'", bLeadChar);
-
-    for (uint8_t i = 1; i < sizeof(abNameSeg); i++)
-    {
-        if (   abNameSeg[i] != '_'
-            && !RTLocCIsUpper(abNameSeg[i])
-            && !RTLocCIsDigit(abNameSeg[i]))
-            return RTErrInfoSetF(pErrInfo, VERR_INVALID_PARAMETER, "AML stream contains invalid name character '%#02RX8'", abNameSeg[i]);
-    }
-
-    pszNameString[0] = (char)bLeadChar;
-    pszNameString[1] = (char)abNameSeg[0];
-    pszNameString[2] = (char)abNameSeg[1];
-    pszNameString[3] = (char)abNameSeg[2];
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeNameStringWithLead(PRTACPITBLAMLDECODE pThis, uint8_t bLeadChar, char *pszNameString, size_t cchNameString, size_t *pcbNameString, PRTERRINFO pErrInfo)
-{
-    AssertReturn(cchNameString >= 5, VERR_INVALID_PARAMETER); /* One name segment is at least 4 bytes (+ terminator). */
-
-    /* Check for a root path. */
-    int rc = VINF_SUCCESS;
-    uint8_t bTmp = bLeadChar;
-    size_t idxName = 0;
-    if (bTmp == '\\')
-    {
-        pszNameString[idxName++] = '\\';
-
-        rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-        if (RT_FAILURE(rc)) return rc;
-    }
-    else if (bTmp == '^')
-    {
-        /* Prefix path, can have multiple ^ prefixes. */
-        pszNameString[idxName++] = '^';
-
-        for (;;)
-        {
-            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-            if (RT_FAILURE(rc)) return rc;
-
-            if (bTmp != '^')
-                break;
-
-            if (idxName == cchNameString - 1)
-                return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "PrefixPath in AML byte stream is too long to fit into a %zu byte buffer",
-                                     cchNameString - 1);
-
-            pszNameString[idxName++] = '^';
-        }
-    }
-
-    if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_DUAL_NAME)
-    {
-        if (idxName + 8 < cchNameString)
-        {
-            rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName], pErrInfo);
-            if (RT_FAILURE(rc)) return rc;
-
-            rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName + 4], pErrInfo);
-            if (RT_FAILURE(rc)) return rc;
-
-            idxName += 8;
-            pszNameString[idxName] = '\0';
-        }
-        else
-            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "DualNamePrefix string in AML byte stream is too long to fit into a %zu byte buffer",
-                               cchNameString - 1);
-    }
-    else if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_MULTI_NAME)
-    {
-        uint8_t cSegs = 0;
-        rc = rtAcpiTblAmlDecodeReadU8(pThis, &cSegs, pErrInfo);
-        if (RT_FAILURE(rc)) return rc;
-
-        if (idxName + cSegs * 4 < cchNameString)
-        {
-            for (uint8_t i = 0; i < cSegs; i++)
-            {
-                rc = rtAcpiTblAmlDecodeNameSeg(pThis, &pszNameString[idxName + i * 4], pErrInfo);
-                if (RT_FAILURE(rc)) return rc;
-            }
-
-            idxName += cSegs * 4;
-            pszNameString[idxName] = '\0';
-        }
-        else
-            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "MultiNamePrefix string in AML byte stream is too long to fit into a %zu byte buffer",
-                               cchNameString - 1);
-    }
-    else if (bTmp == ACPI_AML_BYTE_CODE_PREFIX_NULL_NAME)
-        pszNameString[idxName] = '\0';
-    else
-    {
-        if (idxName + 4 < cchNameString)
-        {
-            rc = rtAcpiTblAmlDecodeNameSegWithoutLeadChar(pThis, bTmp, &pszNameString[idxName], pErrInfo);
-            if (RT_FAILURE(rc)) return rc;
-
-            idxName += 4;
-            pszNameString[idxName] = '\0';
-        }
-        else
-            rc = RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "Name string in AML byte stream is too long to fit into a %zu byte buffer",
-                               cchNameString - 1);
-    }
-
-    *pcbNameString = idxName;
-    return rc;
-}
-
-
-static int rtAcpiTblAmlDecodeNameString(PRTACPITBLAMLDECODE pThis, char *pszNameString, size_t cchNameString, size_t *pcbNameString, PRTERRINFO pErrInfo)
-{
-    AssertReturn(cchNameString >= 5, VERR_INVALID_PARAMETER); /* One name segment is at least 4 bytes (+ terminator). */
-
-    uint8_t bLead = 0; /* shut up gcc */
-    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bLead, pErrInfo);
-    if (RT_FAILURE(rc)) return rc;
-
-    return rtAcpiTblAmlDecodeNameStringWithLead( pThis, bLead, pszNameString, cchNameString, pcbNameString, pErrInfo);
-}
-
-
-/**
- * Adds the proper indentation before a new line.
- *
- * @returns IPRT status code.
- * @param   hVfsIos         The VFS I/O stream handle to dump the ASL to.
- * @param   uIndentLvl      The level of indentation.
- */
-static int rtAcpiTblAmlDecodeIndent(RTVFSIOSTREAM hVfsIos, uint32_t uIndentLvl)
-{
-    while (uIndentLvl--)
-    {
-        ssize_t cch = RTVfsIoStrmPrintf(hVfsIos, "    ");
-        if (cch != 4)
-            return cch < 0 ? (int)cch : VERR_BUFFER_UNDERFLOW;
-    }
-
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeFormat(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIos, const char *pszFmt, ...)
-{
-    int rc = VINF_SUCCESS;
-    if (pThis->fIndent)
-        rc = rtAcpiTblAmlDecodeIndent(hVfsIos, pThis->iLvl);
-    if (RT_SUCCESS(rc))
-    {
-        va_list VaArgs;
-        va_start(VaArgs, pszFmt);
-        ssize_t cch = RTVfsIoStrmPrintfV(hVfsIos, pszFmt, VaArgs);
-        va_end(VaArgs);
-        if (cch <= 0)
-            rc = cch < 0 ? (int)cch : VERR_NO_MEMORY;
-    }
-
-    return rc;
-}
-
-
-static int rtAcpiTblAmlDecodePkgLength(PRTACPITBLAMLDECODE pThis, size_t *pcbPkg, size_t *pcbPkgLength, PRTERRINFO pErrInfo)
-{
-    uint8_t bTmp = 0; /* shut up gcc */
-    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    /* High 2 bits give the remaining bytes following to form the final package length. */
-    uint8_t cBytesRemaining = (bTmp >> 6) & 0x3;
-    *pcbPkgLength = 1 + cBytesRemaining;
-
-    if (cBytesRemaining)
-    {
-        size_t cbPkg = bTmp & 0xf;
-        for (uint8_t i = 0; i < cBytesRemaining; i++)
-        {
-            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            cbPkg |= (size_t)bTmp << (i * 8 + 4);
-            *pcbPkg = cbPkg;
-        }
-    }
-    else
-        *pcbPkg = bTmp & 0x3f;
-
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodePkgPush(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, size_t cbPkg, PRTERRINFO pErrInfo)
-{
-    /* Get a new stack element. */
-    if (pThis->iLvl == pThis->cPkgStackMax)
-    {
-        uint32_t const cPkgElemsNew = pThis->cPkgStackMax + 8;
-        size_t *pacbPkgLeftNew = (size_t *)RTMemRealloc(pThis->pacbPkgLeft, 2 * cPkgElemsNew * sizeof(*pacbPkgLeftNew));
-        if (!pacbPkgLeftNew)
-            return RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Out of memory pushing a new package onto the stack");
-
-        pThis->pacbPkgLeft  = pacbPkgLeftNew;
-        pThis->pacbPkg      = pacbPkgLeftNew + cPkgElemsNew;
-        pThis->cPkgStackMax = cPkgElemsNew;
-    }
-
-    uint32_t const iLvlNew = pThis->iLvl + 1;
-    pThis->pacbPkgLeft[iLvlNew] = cbPkg;
-    pThis->pacbPkg[iLvlNew]     = cbPkg;
-    int rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "{\n");
-    pThis->iLvl = iLvlNew;
-    return rc;
-}
-
-
-DECLINLINE(int) rtAcpiTblAmlDecodePkgPop(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
-{
-    while (!pThis->pacbPkgLeft[pThis->iLvl])
-    {
-        size_t cbPkg = pThis->pacbPkg[pThis->iLvl];
-        pThis->iLvl--;
-
-        if (pThis->pacbPkgLeft[pThis->iLvl] < cbPkg)
-            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "AML contains invalid package length encoding");
-
-        pThis->pacbPkgLeft[pThis->iLvl] -= cbPkg;
-        int rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "}\n");
-        if (RT_FAILURE(rc))
-            return rc;
-    }
-
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeIntegerFromPrefix(PRTACPITBLAMLDECODE pThis, uint8_t bPrefix, uint64_t *pu64, size_t cbDecodeMax, size_t *pcbDecoded, PRTERRINFO pErrInfo)
-{
-    switch (bPrefix)
-    {
-        case ACPI_AML_BYTE_CODE_PREFIX_BYTE:
-        {
-            if (!cbDecodeMax)
-                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode byte integer in AML stream");
-
-            uint8_t bInt = 0;
-            int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bInt, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            *pu64       = bInt;
-            *pcbDecoded = 2;
-            break;
-        }
-        case ACPI_AML_BYTE_CODE_PREFIX_WORD:
-        {
-            if (cbDecodeMax < 2)
-                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode word integer in AML stream");
-
-            uint16_t u16 = 0;
-            int rc = rtAcpiTblAmlDecodeReadU16(pThis, &u16, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            *pu64       = u16;
-            *pcbDecoded = 3;
-            break;
-        }
-        case ACPI_AML_BYTE_CODE_PREFIX_DWORD:
-        {
-            if (cbDecodeMax < 4)
-                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode double word integer in AML stream");
-
-            uint32_t u32 = 0;
-            int rc = rtAcpiTblAmlDecodeReadU32(pThis, &u32, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            *pu64       = u32;
-            *pcbDecoded = 5;
-            break;
-        }
-        case ACPI_AML_BYTE_CODE_PREFIX_QWORD:
-        {
-            if (cbDecodeMax < 8)
-                return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Not enough data left to decode quad word integer in AML stream");
-
-            uint64_t u64 = 0;
-            int rc = rtAcpiTblAmlDecodeReadU64(pThis, &u64, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            *pu64       = u64;
-            *pcbDecoded = 9;
-            break;
-        }
-        default:
-            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid integer prefix '%#02RX8'", bPrefix);
-    }
-
-    return VINF_SUCCESS;
-}
-
-
-static int rtAcpiTblAmlDecodeIntegerWorker(PRTACPITBLAMLDECODE pThis, uint64_t *pu64, size_t cbDecodeMax, size_t *pcbDecoded, PRTERRINFO pErrInfo)
-{
-    AssertReturn(cbDecodeMax >= 1, VERR_INVALID_PARAMETER);
-
-    uint8_t bPrefix = 0; /* shut up gcc */
-    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bPrefix, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    cbDecodeMax--;
-    return rtAcpiTblAmlDecodeIntegerFromPrefix(pThis, bPrefix, pu64, cbDecodeMax, pcbDecoded, pErrInfo);
-}
-
-
-static DECLCALLBACK(int) rtAcpiTblAmlDecodeNameObject(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
-{
-    char szName[512];
-    size_t cbName = 0;
-
-    int rc = rtAcpiTblAmlDecodeNameStringWithLead(pThis, bOp, &szName[0], sizeof(szName), &cbName, pErrInfo);
-    if (RT_FAILURE(rc)) return rc;
-
-    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
-}
-
-
-static DECLCALLBACK(int) rtAcpiTblAmlDecodeString(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
-{
-    RT_NOREF(bOp);
-
-    char szStr[512];
-    uint32_t i = 0;
-    for (;;)
-    {
-        uint8_t bTmp = 0; /* shut up gcc */
-        int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-        if (RT_FAILURE(rc))
-            return rc;
-
-        if (bTmp >= 0x1 && bTmp <= 0x7f)
-            szStr[i++] = (char)bTmp;
-        else if (bTmp == 0x00)
-        {
-            szStr[i++] = '\0';
-            break;
-        }
-        else
-            return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid ASCII string character %#x in string", bTmp);
-
-        if (i == sizeof(szStr))
-            return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "ASCII string is out of bounds");
-    }
-
-    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "\"%s\"", szStr);
-}
-
-
-static DECLCALLBACK(int) rtAcpiTblAmlDecodeBuffer(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
-{
-    RT_NOREF(bOp);
-
-    size_t cbPkg = 0;
-    size_t cbPkgLength = 0;
-    int rc = rtAcpiTblAmlDecodePkgLength(pThis, &cbPkg, &cbPkgLength, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    cbPkg -= cbPkgLength;
-    uint64_t u64 = 0;
-    size_t cbInt = 0;
-    rc = rtAcpiTblAmlDecodeIntegerWorker(pThis, &u64, cbPkg, &cbInt, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    cbPkg -= cbInt;
-
-    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "Buffer (%RU64) {", u64);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    /* Decode remaining bytes. */
-    while (cbPkg--)
-    {
-        uint8_t bTmp = 0;
-        rc = rtAcpiTblAmlDecodeReadU8(pThis, &bTmp, pErrInfo);
-        if (RT_FAILURE(rc))
-            return rc;
-
-        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%#02RX8%s", bTmp, cbPkg ? "," : "");
-        if (RT_FAILURE(rc))
-            return rc;
-    }
-
-    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "}");
-}
-
-
-static DECLCALLBACK(int) rtAcpiTblAmlDecodeInteger(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, uint8_t bOp, PRTERRINFO pErrInfo)
-{
-    uint64_t u64 = 0;
-    size_t cbDecoded = 0;
-    int rc = rtAcpiTblAmlDecodeIntegerFromPrefix(pThis, bOp, &u64, sizeof(uint64_t), &cbDecoded, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    return rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%#RX64", u64);
-}
-
-
-/**
- * AML Opcode -> ASL decoder array.
- */
-static const RTACPIAMLOPC g_aAmlOpcodeDecode[] =
-{
-#define RTACPI_AML_OPC_INVALID \
-    { NULL,     0,        { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_0(a_pszOpc, a_fFlags) \
-    { a_pszOpc, a_fFlags, { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_1(a_pszOpc, a_fFlags, a_enmType0) \
-    { a_pszOpc, a_fFlags, { a_enmType0,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_2(a_pszOpc, a_fFlags, a_enmType0, a_enmType1) \
-    { a_pszOpc, a_fFlags, { a_enmType0,              a_enmType1,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_3(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2) \
-    { a_pszOpc, a_fFlags, { a_enmType0,              a_enmType1,              a_enmType2,              kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_4(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2, a_enmType3) \
-    { a_pszOpc, a_fFlags, { a_enmType0,              a_enmType1,              a_enmType2,              a_enmType3,              kAcpiAmlOpcType_Invalid }, NULL }
-#define RTACPI_AML_OPC_SIMPLE_5(a_pszOpc, a_fFlags, a_enmType0, a_enmType1, a_enmType2, a_enmType3, a_enmType4) \
-    { a_pszOpc, a_fFlags, { a_enmType0,              a_enmType1,              a_enmType2,              a_enmType3,              a_enmType4              }, NULL }
-#define RTACPI_AML_OPC_HANDLER(a_pszOpc, a_pfnHandler) \
-    { a_pszOpc, 0,        { kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid, kAcpiAmlOpcType_Invalid }, a_pfnHandler }
-
-    /* 0x00 */ RTACPI_AML_OPC_SIMPLE_0("Zero", RTACPI_AML_OPC_F_NONE),
-    /* 0x01 */ RTACPI_AML_OPC_SIMPLE_0("One",  RTACPI_AML_OPC_F_NONE),
-    /* 0x02 */ RTACPI_AML_OPC_INVALID,
-    /* 0x03 */ RTACPI_AML_OPC_INVALID,
-    /* 0x04 */ RTACPI_AML_OPC_INVALID,
-    /* 0x05 */ RTACPI_AML_OPC_INVALID,
-    /* 0x06 */ RTACPI_AML_OPC_INVALID,
-    /* 0x07 */ RTACPI_AML_OPC_INVALID,
-    /* 0x08 */ RTACPI_AML_OPC_SIMPLE_2("Name",   0,     kAcpiAmlOpcType_NameString,  kAcpiAmlOpcType_TermArg),
-    /* 0x09 */ RTACPI_AML_OPC_INVALID,
-    /* 0x0a */ RTACPI_AML_OPC_HANDLER( "ByteInteger",   rtAcpiTblAmlDecodeInteger),
-    /* 0x0b */ RTACPI_AML_OPC_HANDLER( "WordInteger",   rtAcpiTblAmlDecodeInteger),
-    /* 0x0c */ RTACPI_AML_OPC_HANDLER( "DWordInteger",  rtAcpiTblAmlDecodeInteger),
-    /* 0x0d */ RTACPI_AML_OPC_HANDLER( "StringPrefix",  rtAcpiTblAmlDecodeString),
-    /* 0x0e */ RTACPI_AML_OPC_HANDLER( "QWordInteger",  rtAcpiTblAmlDecodeInteger),
-    /* 0x0f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x10 */ RTACPI_AML_OPC_SIMPLE_1("Scope",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH,  kAcpiAmlOpcType_NameString),
-    /* 0x11 */ RTACPI_AML_OPC_HANDLER( "Buffer",   rtAcpiTblAmlDecodeBuffer),
-    /* 0x12 */ RTACPI_AML_OPC_INVALID,
-    /* 0x13 */ RTACPI_AML_OPC_INVALID,
-    /* 0x14 */ RTACPI_AML_OPC_SIMPLE_2("Method",   RTACPI_AML_OPC_F_HAS_PKG_LENGTH,  kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte),
-    /* 0x15 */ RTACPI_AML_OPC_SIMPLE_3("External", RTACPI_AML_OPC_F_NONE,            kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_Byte),
-    /* 0x16 */ RTACPI_AML_OPC_INVALID,
-    /* 0x17 */ RTACPI_AML_OPC_INVALID,
-    /* 0x18 */ RTACPI_AML_OPC_INVALID,
-    /* 0x19 */ RTACPI_AML_OPC_INVALID,
-    /* 0x1a */ RTACPI_AML_OPC_INVALID,
-    /* 0x1b */ RTACPI_AML_OPC_INVALID,
-    /* 0x1c */ RTACPI_AML_OPC_INVALID,
-    /* 0x1d */ RTACPI_AML_OPC_INVALID,
-    /* 0x1e */ RTACPI_AML_OPC_INVALID,
-    /* 0x1f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x20 */ RTACPI_AML_OPC_INVALID,
-    /* 0x21 */ RTACPI_AML_OPC_INVALID,
-    /* 0x22 */ RTACPI_AML_OPC_INVALID,
-    /* 0x23 */ RTACPI_AML_OPC_INVALID,
-    /* 0x24 */ RTACPI_AML_OPC_INVALID,
-    /* 0x25 */ RTACPI_AML_OPC_INVALID,
-    /* 0x26 */ RTACPI_AML_OPC_INVALID,
-    /* 0x27 */ RTACPI_AML_OPC_INVALID,
-    /* 0x28 */ RTACPI_AML_OPC_INVALID,
-    /* 0x29 */ RTACPI_AML_OPC_INVALID,
-    /* 0x2a */ RTACPI_AML_OPC_INVALID,
-    /* 0x2b */ RTACPI_AML_OPC_INVALID,
-    /* 0x2c */ RTACPI_AML_OPC_INVALID,
-    /* 0x2d */ RTACPI_AML_OPC_INVALID,
-    /* 0x2e */ RTACPI_AML_OPC_INVALID,
-    /* 0x2f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x30 */ RTACPI_AML_OPC_INVALID,
-    /* 0x31 */ RTACPI_AML_OPC_INVALID,
-    /* 0x32 */ RTACPI_AML_OPC_INVALID,
-    /* 0x33 */ RTACPI_AML_OPC_INVALID,
-    /* 0x34 */ RTACPI_AML_OPC_INVALID,
-    /* 0x35 */ RTACPI_AML_OPC_INVALID,
-    /* 0x36 */ RTACPI_AML_OPC_INVALID,
-    /* 0x37 */ RTACPI_AML_OPC_INVALID,
-    /* 0x38 */ RTACPI_AML_OPC_INVALID,
-    /* 0x39 */ RTACPI_AML_OPC_INVALID,
-    /* 0x3a */ RTACPI_AML_OPC_INVALID,
-    /* 0x3b */ RTACPI_AML_OPC_INVALID,
-    /* 0x3c */ RTACPI_AML_OPC_INVALID,
-    /* 0x3d */ RTACPI_AML_OPC_INVALID,
-    /* 0x3e */ RTACPI_AML_OPC_INVALID,
-    /* 0x3f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x40 */ RTACPI_AML_OPC_INVALID,
-    /* 0x41 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x42 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x43 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x44 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x45 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x46 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x47 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x48 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x49 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4a */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4b */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4c */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4d */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4e */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x4f */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-
-    /* 0x50 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x51 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x52 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x53 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x54 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x55 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x56 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x57 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x58 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x59 */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x5a */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x5b */ RTACPI_AML_OPC_INVALID,
-    /* 0x5c */ RTACPI_AML_OPC_HANDLER("RootChar",         rtAcpiTblAmlDecodeNameObject),
-    /* 0x5d */ RTACPI_AML_OPC_INVALID,
-    /* 0x5e */ RTACPI_AML_OPC_HANDLER("ParentPrefixChar", rtAcpiTblAmlDecodeNameObject),
-    /* 0x5f */ RTACPI_AML_OPC_HANDLER("NameChar",         rtAcpiTblAmlDecodeNameObject),
-
-    /* 0x60 */ RTACPI_AML_OPC_SIMPLE_0("Local0", RTACPI_AML_OPC_F_NONE),
-    /* 0x61 */ RTACPI_AML_OPC_SIMPLE_0("Local1", RTACPI_AML_OPC_F_NONE),
-    /* 0x62 */ RTACPI_AML_OPC_SIMPLE_0("Local2", RTACPI_AML_OPC_F_NONE),
-    /* 0x63 */ RTACPI_AML_OPC_SIMPLE_0("Local3", RTACPI_AML_OPC_F_NONE),
-    /* 0x64 */ RTACPI_AML_OPC_SIMPLE_0("Local4", RTACPI_AML_OPC_F_NONE),
-    /* 0x65 */ RTACPI_AML_OPC_SIMPLE_0("Local5", RTACPI_AML_OPC_F_NONE),
-    /* 0x66 */ RTACPI_AML_OPC_SIMPLE_0("Local6", RTACPI_AML_OPC_F_NONE),
-    /* 0x67 */ RTACPI_AML_OPC_SIMPLE_0("Local7", RTACPI_AML_OPC_F_NONE),
-    /* 0x68 */ RTACPI_AML_OPC_SIMPLE_0("Arg0",   RTACPI_AML_OPC_F_NONE),
-    /* 0x69 */ RTACPI_AML_OPC_SIMPLE_0("Arg1",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6a */ RTACPI_AML_OPC_SIMPLE_0("Arg2",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6b */ RTACPI_AML_OPC_SIMPLE_0("Arg3",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6c */ RTACPI_AML_OPC_SIMPLE_0("Arg4",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6d */ RTACPI_AML_OPC_SIMPLE_0("Arg5",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6e */ RTACPI_AML_OPC_SIMPLE_0("Arg6",   RTACPI_AML_OPC_F_NONE),
-    /* 0x6f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x70 */ RTACPI_AML_OPC_SIMPLE_2("Store",   0,     kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_SuperName),
-    /* 0x71 */ RTACPI_AML_OPC_INVALID,
-    /* 0x72 */ RTACPI_AML_OPC_INVALID,
-    /* 0x73 */ RTACPI_AML_OPC_INVALID,
-    /* 0x74 */ RTACPI_AML_OPC_INVALID,
-    /* 0x75 */ RTACPI_AML_OPC_INVALID,
-    /* 0x76 */ RTACPI_AML_OPC_INVALID,
-    /* 0x77 */ RTACPI_AML_OPC_INVALID,
-    /* 0x78 */ RTACPI_AML_OPC_INVALID,
-    /* 0x79 */ RTACPI_AML_OPC_INVALID,
-    /* 0x7a */ RTACPI_AML_OPC_INVALID,
-    /* 0x7b */ RTACPI_AML_OPC_INVALID,
-    /* 0x7c */ RTACPI_AML_OPC_INVALID,
-    /* 0x7d */ RTACPI_AML_OPC_INVALID,
-    /* 0x7e */ RTACPI_AML_OPC_INVALID,
-    /* 0x7f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x80 */ RTACPI_AML_OPC_INVALID,
-    /* 0x81 */ RTACPI_AML_OPC_INVALID,
-    /* 0x82 */ RTACPI_AML_OPC_INVALID,
-    /* 0x83 */ RTACPI_AML_OPC_INVALID,
-    /* 0x84 */ RTACPI_AML_OPC_INVALID,
-    /* 0x85 */ RTACPI_AML_OPC_INVALID,
-    /* 0x86 */ RTACPI_AML_OPC_SIMPLE_2("Notify",                                0,     kAcpiAmlOpcType_SuperName, kAcpiAmlOpcType_TermArg),
-    /* 0x87 */ RTACPI_AML_OPC_INVALID,
-    /* 0x88 */ RTACPI_AML_OPC_SIMPLE_3("Index",                                 0,     kAcpiAmlOpcType_TermArg,   kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_SuperName),
-    /* 0x89 */ RTACPI_AML_OPC_INVALID,
-    /* 0x8a */ RTACPI_AML_OPC_INVALID,
-    /* 0x8b */ RTACPI_AML_OPC_INVALID,
-    /* 0x8c */ RTACPI_AML_OPC_INVALID,
-    /* 0x8d */ RTACPI_AML_OPC_INVALID,
-    /* 0x8e */ RTACPI_AML_OPC_INVALID,
-    /* 0x8f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x90 */ RTACPI_AML_OPC_INVALID,
-    /* 0x91 */ RTACPI_AML_OPC_INVALID,
-    /* 0x92 */ RTACPI_AML_OPC_INVALID,
-    /* 0x93 */ RTACPI_AML_OPC_SIMPLE_2("LEqual",                                0,     kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_TermArg),
-    /* 0x94 */ RTACPI_AML_OPC_INVALID,
-    /* 0x95 */ RTACPI_AML_OPC_INVALID,
-    /* 0x96 */ RTACPI_AML_OPC_INVALID,
-    /* 0x97 */ RTACPI_AML_OPC_INVALID,
-    /* 0x98 */ RTACPI_AML_OPC_INVALID,
-    /* 0x99 */ RTACPI_AML_OPC_INVALID,
-    /* 0x9a */ RTACPI_AML_OPC_INVALID,
-    /* 0x9b */ RTACPI_AML_OPC_INVALID,
-    /* 0x9c */ RTACPI_AML_OPC_INVALID,
-    /* 0x9d */ RTACPI_AML_OPC_INVALID,
-    /* 0x9e */ RTACPI_AML_OPC_INVALID,
-    /* 0x9f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xa0 */ RTACPI_AML_OPC_SIMPLE_1("If",      RTACPI_AML_OPC_F_HAS_PKG_LENGTH,     kAcpiAmlOpcType_TermArg),
-    /* 0xa1 */ RTACPI_AML_OPC_SIMPLE_0("Else",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH),
-    /* 0xa2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa4 */ RTACPI_AML_OPC_SIMPLE_1("Return",                                0,     kAcpiAmlOpcType_TermArg),
-    /* 0xa5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xaa */ RTACPI_AML_OPC_INVALID,
-    /* 0xab */ RTACPI_AML_OPC_INVALID,
-    /* 0xac */ RTACPI_AML_OPC_INVALID,
-    /* 0xad */ RTACPI_AML_OPC_INVALID,
-    /* 0xae */ RTACPI_AML_OPC_INVALID,
-    /* 0xaf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xb0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xba */ RTACPI_AML_OPC_INVALID,
-    /* 0xbb */ RTACPI_AML_OPC_INVALID,
-    /* 0xbc */ RTACPI_AML_OPC_INVALID,
-    /* 0xbd */ RTACPI_AML_OPC_INVALID,
-    /* 0xbe */ RTACPI_AML_OPC_INVALID,
-    /* 0xbf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xc0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xca */ RTACPI_AML_OPC_INVALID,
-    /* 0xcb */ RTACPI_AML_OPC_INVALID,
-    /* 0xcc */ RTACPI_AML_OPC_INVALID,
-    /* 0xcd */ RTACPI_AML_OPC_INVALID,
-    /* 0xce */ RTACPI_AML_OPC_INVALID,
-    /* 0xcf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xd0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xda */ RTACPI_AML_OPC_INVALID,
-    /* 0xdb */ RTACPI_AML_OPC_INVALID,
-    /* 0xdc */ RTACPI_AML_OPC_INVALID,
-    /* 0xdd */ RTACPI_AML_OPC_INVALID,
-    /* 0xde */ RTACPI_AML_OPC_INVALID,
-    /* 0xdf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xe0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xea */ RTACPI_AML_OPC_INVALID,
-    /* 0xeb */ RTACPI_AML_OPC_INVALID,
-    /* 0xec */ RTACPI_AML_OPC_INVALID,
-    /* 0xed */ RTACPI_AML_OPC_INVALID,
-    /* 0xee */ RTACPI_AML_OPC_INVALID,
-    /* 0xef */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xf0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xfa */ RTACPI_AML_OPC_INVALID,
-    /* 0xfb */ RTACPI_AML_OPC_INVALID,
-    /* 0xfc */ RTACPI_AML_OPC_INVALID,
-    /* 0xfd */ RTACPI_AML_OPC_INVALID,
-    /* 0xfe */ RTACPI_AML_OPC_INVALID,
-    /* 0xff */ RTACPI_AML_OPC_INVALID
-};
-
-
-/**
- * AML extended opcode -> ASL decoder array.
- */
-static const RTACPIAMLOPC g_aAmlExtOpcodeDecode[] =
-{
-    /* 0x00 */ RTACPI_AML_OPC_INVALID,
-    /* 0x01 */ RTACPI_AML_OPC_INVALID,
-    /* 0x02 */ RTACPI_AML_OPC_INVALID,
-    /* 0x03 */ RTACPI_AML_OPC_INVALID,
-    /* 0x04 */ RTACPI_AML_OPC_INVALID,
-    /* 0x05 */ RTACPI_AML_OPC_INVALID,
-    /* 0x06 */ RTACPI_AML_OPC_INVALID,
-    /* 0x07 */ RTACPI_AML_OPC_INVALID,
-    /* 0x08 */ RTACPI_AML_OPC_INVALID,
-    /* 0x09 */ RTACPI_AML_OPC_INVALID,
-    /* 0x0a */ RTACPI_AML_OPC_INVALID,
-    /* 0x0b */ RTACPI_AML_OPC_INVALID,
-    /* 0x0c */ RTACPI_AML_OPC_INVALID,
-    /* 0x0d */ RTACPI_AML_OPC_INVALID,
-    /* 0x0e */ RTACPI_AML_OPC_INVALID,
-    /* 0x0f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x10 */ RTACPI_AML_OPC_INVALID,
-    /* 0x11 */ RTACPI_AML_OPC_INVALID,
-    /* 0x12 */ RTACPI_AML_OPC_INVALID,
-    /* 0x13 */ RTACPI_AML_OPC_INVALID,
-    /* 0x14 */ RTACPI_AML_OPC_INVALID,
-    /* 0x15 */ RTACPI_AML_OPC_INVALID,
-    /* 0x16 */ RTACPI_AML_OPC_INVALID,
-    /* 0x17 */ RTACPI_AML_OPC_INVALID,
-    /* 0x18 */ RTACPI_AML_OPC_INVALID,
-    /* 0x19 */ RTACPI_AML_OPC_INVALID,
-    /* 0x1a */ RTACPI_AML_OPC_INVALID,
-    /* 0x1b */ RTACPI_AML_OPC_INVALID,
-    /* 0x1c */ RTACPI_AML_OPC_INVALID,
-    /* 0x1d */ RTACPI_AML_OPC_INVALID,
-    /* 0x1e */ RTACPI_AML_OPC_INVALID,
-    /* 0x1f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x20 */ RTACPI_AML_OPC_INVALID,
-    /* 0x21 */ RTACPI_AML_OPC_INVALID,
-    /* 0x22 */ RTACPI_AML_OPC_INVALID,
-    /* 0x23 */ RTACPI_AML_OPC_INVALID,
-    /* 0x24 */ RTACPI_AML_OPC_INVALID,
-    /* 0x25 */ RTACPI_AML_OPC_INVALID,
-    /* 0x26 */ RTACPI_AML_OPC_INVALID,
-    /* 0x27 */ RTACPI_AML_OPC_INVALID,
-    /* 0x28 */ RTACPI_AML_OPC_INVALID,
-    /* 0x29 */ RTACPI_AML_OPC_INVALID,
-    /* 0x2a */ RTACPI_AML_OPC_INVALID,
-    /* 0x2b */ RTACPI_AML_OPC_INVALID,
-    /* 0x2c */ RTACPI_AML_OPC_INVALID,
-    /* 0x2d */ RTACPI_AML_OPC_INVALID,
-    /* 0x2e */ RTACPI_AML_OPC_INVALID,
-    /* 0x2f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x30 */ RTACPI_AML_OPC_INVALID,
-    /* 0x31 */ RTACPI_AML_OPC_SIMPLE_0("Debug", RTACPI_AML_OPC_F_NONE),
-    /* 0x32 */ RTACPI_AML_OPC_INVALID,
-    /* 0x33 */ RTACPI_AML_OPC_INVALID,
-    /* 0x34 */ RTACPI_AML_OPC_INVALID,
-    /* 0x35 */ RTACPI_AML_OPC_INVALID,
-    /* 0x36 */ RTACPI_AML_OPC_INVALID,
-    /* 0x37 */ RTACPI_AML_OPC_INVALID,
-    /* 0x38 */ RTACPI_AML_OPC_INVALID,
-    /* 0x39 */ RTACPI_AML_OPC_INVALID,
-    /* 0x3a */ RTACPI_AML_OPC_INVALID,
-    /* 0x3b */ RTACPI_AML_OPC_INVALID,
-    /* 0x3c */ RTACPI_AML_OPC_INVALID,
-    /* 0x3d */ RTACPI_AML_OPC_INVALID,
-    /* 0x3e */ RTACPI_AML_OPC_INVALID,
-    /* 0x3f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x40 */ RTACPI_AML_OPC_INVALID,
-    /* 0x41 */ RTACPI_AML_OPC_INVALID,
-    /* 0x42 */ RTACPI_AML_OPC_INVALID,
-    /* 0x43 */ RTACPI_AML_OPC_INVALID,
-    /* 0x44 */ RTACPI_AML_OPC_INVALID,
-    /* 0x45 */ RTACPI_AML_OPC_INVALID,
-    /* 0x46 */ RTACPI_AML_OPC_INVALID,
-    /* 0x47 */ RTACPI_AML_OPC_INVALID,
-    /* 0x48 */ RTACPI_AML_OPC_INVALID,
-    /* 0x49 */ RTACPI_AML_OPC_INVALID,
-    /* 0x4a */ RTACPI_AML_OPC_INVALID,
-    /* 0x4b */ RTACPI_AML_OPC_INVALID,
-    /* 0x4c */ RTACPI_AML_OPC_INVALID,
-    /* 0x4d */ RTACPI_AML_OPC_INVALID,
-    /* 0x4e */ RTACPI_AML_OPC_INVALID,
-    /* 0x4f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x50 */ RTACPI_AML_OPC_INVALID,
-    /* 0x51 */ RTACPI_AML_OPC_INVALID,
-    /* 0x52 */ RTACPI_AML_OPC_INVALID,
-    /* 0x53 */ RTACPI_AML_OPC_INVALID,
-    /* 0x54 */ RTACPI_AML_OPC_INVALID,
-    /* 0x55 */ RTACPI_AML_OPC_INVALID,
-    /* 0x56 */ RTACPI_AML_OPC_INVALID,
-    /* 0x57 */ RTACPI_AML_OPC_INVALID,
-    /* 0x58 */ RTACPI_AML_OPC_INVALID,
-    /* 0x59 */ RTACPI_AML_OPC_INVALID,
-    /* 0x5a */ RTACPI_AML_OPC_INVALID,
-    /* 0x5b */ RTACPI_AML_OPC_INVALID,
-    /* 0x5c */ RTACPI_AML_OPC_INVALID,
-    /* 0x5d */ RTACPI_AML_OPC_INVALID,
-    /* 0x5e */ RTACPI_AML_OPC_INVALID,
-    /* 0x5f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x60 */ RTACPI_AML_OPC_INVALID,
-    /* 0x61 */ RTACPI_AML_OPC_INVALID,
-    /* 0x62 */ RTACPI_AML_OPC_INVALID,
-    /* 0x63 */ RTACPI_AML_OPC_INVALID,
-    /* 0x64 */ RTACPI_AML_OPC_INVALID,
-    /* 0x65 */ RTACPI_AML_OPC_INVALID,
-    /* 0x66 */ RTACPI_AML_OPC_INVALID,
-    /* 0x67 */ RTACPI_AML_OPC_INVALID,
-    /* 0x68 */ RTACPI_AML_OPC_INVALID,
-    /* 0x69 */ RTACPI_AML_OPC_INVALID,
-    /* 0x6a */ RTACPI_AML_OPC_INVALID,
-    /* 0x6b */ RTACPI_AML_OPC_INVALID,
-    /* 0x6c */ RTACPI_AML_OPC_INVALID,
-    /* 0x6d */ RTACPI_AML_OPC_INVALID,
-    /* 0x6e */ RTACPI_AML_OPC_INVALID,
-    /* 0x6f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x70 */ RTACPI_AML_OPC_INVALID,
-    /* 0x71 */ RTACPI_AML_OPC_INVALID,
-    /* 0x72 */ RTACPI_AML_OPC_INVALID,
-    /* 0x73 */ RTACPI_AML_OPC_INVALID,
-    /* 0x74 */ RTACPI_AML_OPC_INVALID,
-    /* 0x75 */ RTACPI_AML_OPC_INVALID,
-    /* 0x76 */ RTACPI_AML_OPC_INVALID,
-    /* 0x77 */ RTACPI_AML_OPC_INVALID,
-    /* 0x78 */ RTACPI_AML_OPC_INVALID,
-    /* 0x79 */ RTACPI_AML_OPC_INVALID,
-    /* 0x7a */ RTACPI_AML_OPC_INVALID,
-    /* 0x7b */ RTACPI_AML_OPC_INVALID,
-    /* 0x7c */ RTACPI_AML_OPC_INVALID,
-    /* 0x7d */ RTACPI_AML_OPC_INVALID,
-    /* 0x7e */ RTACPI_AML_OPC_INVALID,
-    /* 0x7f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x80 */ RTACPI_AML_OPC_SIMPLE_4("OpRegion",                                0, kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_TermArg, kAcpiAmlOpcType_TermArg),
-    /* 0x81 */ RTACPI_AML_OPC_INVALID,
-    /* 0x82 */ RTACPI_AML_OPC_SIMPLE_1("Device",    RTACPI_AML_OPC_F_HAS_PKG_LENGTH, kAcpiAmlOpcType_NameString),
-    /* 0x83 */ RTACPI_AML_OPC_SIMPLE_4("Processor", RTACPI_AML_OPC_F_HAS_PKG_LENGTH, kAcpiAmlOpcType_NameString, kAcpiAmlOpcType_Byte, kAcpiAmlOpcType_DWord,   kAcpiAmlOpcType_Byte),
-    /* 0x84 */ RTACPI_AML_OPC_INVALID,
-    /* 0x85 */ RTACPI_AML_OPC_INVALID,
-    /* 0x86 */ RTACPI_AML_OPC_INVALID,
-    /* 0x87 */ RTACPI_AML_OPC_INVALID,
-    /* 0x88 */ RTACPI_AML_OPC_INVALID,
-    /* 0x89 */ RTACPI_AML_OPC_INVALID,
-    /* 0x8a */ RTACPI_AML_OPC_INVALID,
-    /* 0x8b */ RTACPI_AML_OPC_INVALID,
-    /* 0x8c */ RTACPI_AML_OPC_INVALID,
-    /* 0x8d */ RTACPI_AML_OPC_INVALID,
-    /* 0x8e */ RTACPI_AML_OPC_INVALID,
-    /* 0x8f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0x90 */ RTACPI_AML_OPC_INVALID,
-    /* 0x91 */ RTACPI_AML_OPC_INVALID,
-    /* 0x92 */ RTACPI_AML_OPC_INVALID,
-    /* 0x93 */ RTACPI_AML_OPC_INVALID,
-    /* 0x94 */ RTACPI_AML_OPC_INVALID,
-    /* 0x95 */ RTACPI_AML_OPC_INVALID,
-    /* 0x96 */ RTACPI_AML_OPC_INVALID,
-    /* 0x97 */ RTACPI_AML_OPC_INVALID,
-    /* 0x98 */ RTACPI_AML_OPC_INVALID,
-    /* 0x99 */ RTACPI_AML_OPC_INVALID,
-    /* 0x9a */ RTACPI_AML_OPC_INVALID,
-    /* 0x9b */ RTACPI_AML_OPC_INVALID,
-    /* 0x9c */ RTACPI_AML_OPC_INVALID,
-    /* 0x9d */ RTACPI_AML_OPC_INVALID,
-    /* 0x9e */ RTACPI_AML_OPC_INVALID,
-    /* 0x9f */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xa0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xa9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xaa */ RTACPI_AML_OPC_INVALID,
-    /* 0xab */ RTACPI_AML_OPC_INVALID,
-    /* 0xac */ RTACPI_AML_OPC_INVALID,
-    /* 0xad */ RTACPI_AML_OPC_INVALID,
-    /* 0xae */ RTACPI_AML_OPC_INVALID,
-    /* 0xaf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xb0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xb9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xba */ RTACPI_AML_OPC_INVALID,
-    /* 0xbb */ RTACPI_AML_OPC_INVALID,
-    /* 0xbc */ RTACPI_AML_OPC_INVALID,
-    /* 0xbd */ RTACPI_AML_OPC_INVALID,
-    /* 0xbe */ RTACPI_AML_OPC_INVALID,
-    /* 0xbf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xc0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xc9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xca */ RTACPI_AML_OPC_INVALID,
-    /* 0xcb */ RTACPI_AML_OPC_INVALID,
-    /* 0xcc */ RTACPI_AML_OPC_INVALID,
-    /* 0xcd */ RTACPI_AML_OPC_INVALID,
-    /* 0xce */ RTACPI_AML_OPC_INVALID,
-    /* 0xcf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xd0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xd9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xda */ RTACPI_AML_OPC_INVALID,
-    /* 0xdb */ RTACPI_AML_OPC_INVALID,
-    /* 0xdc */ RTACPI_AML_OPC_INVALID,
-    /* 0xdd */ RTACPI_AML_OPC_INVALID,
-    /* 0xde */ RTACPI_AML_OPC_INVALID,
-    /* 0xdf */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xe0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xe9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xea */ RTACPI_AML_OPC_INVALID,
-    /* 0xeb */ RTACPI_AML_OPC_INVALID,
-    /* 0xec */ RTACPI_AML_OPC_INVALID,
-    /* 0xed */ RTACPI_AML_OPC_INVALID,
-    /* 0xee */ RTACPI_AML_OPC_INVALID,
-    /* 0xef */ RTACPI_AML_OPC_INVALID,
-
-    /* 0xf0 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf1 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf2 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf3 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf4 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf5 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf6 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf7 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf8 */ RTACPI_AML_OPC_INVALID,
-    /* 0xf9 */ RTACPI_AML_OPC_INVALID,
-    /* 0xfa */ RTACPI_AML_OPC_INVALID,
-    /* 0xfb */ RTACPI_AML_OPC_INVALID,
-    /* 0xfc */ RTACPI_AML_OPC_INVALID,
-    /* 0xfd */ RTACPI_AML_OPC_INVALID,
-    /* 0xfe */ RTACPI_AML_OPC_INVALID,
-    /* 0xff */ RTACPI_AML_OPC_INVALID
-};
-
-
-static int rtAcpiTblAmlDecodeSimple(PRTACPITBLAMLDECODE pThis, PCRTACPIAMLOPC pAmlOpc, uint8_t bOpc, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
-{
-    RT_NOREF(bOpc);
-
-    int rc;
-
-    /* Decode any package length field first. */
-    size_t cbPkg         = 0;
-    size_t cbPkgLength   = 0;
-    size_t cbPkgConsumed = 0;
-    if (pAmlOpc->fFlags & RTACPI_AML_OPC_F_HAS_PKG_LENGTH)
-    {
-        rc = rtAcpiTblAmlDecodePkgLength(pThis, &cbPkg, &cbPkgLength, pErrInfo);
-        if (RT_FAILURE(rc)) return rc;
-
-        cbPkgConsumed += cbPkgLength;
-    }
-
-    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", pAmlOpc->pszOpc);
-    if (RT_FAILURE(rc)) return rc;
-
-    /* Any arguments? */
-    if (pAmlOpc->aenmTypes[0] != kAcpiAmlOpcType_Invalid)
-    {
-        pThis->fIndent = false;
-
-        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "(");
-        if (RT_FAILURE(rc)) return rc;
-
-        for (uint32_t i = 0; i < RT_ELEMENTS(pAmlOpc->aenmTypes); i++)
-        {
-            if (pAmlOpc->aenmTypes[i] == kAcpiAmlOpcType_Invalid)
-                break; /* End of arguments. */
-
-            if (i > 0)
-            {
-                rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ", ");
-                if (RT_FAILURE(rc)) return rc;
-            }
-
-            switch (pAmlOpc->aenmTypes[i])
-            {
-                case kAcpiAmlOpcType_Byte:
-                {
-                    uint8_t bVal = 0; /* shut up gcc */
-                    rc = rtAcpiTblAmlDecodeReadU8(pThis, &bVal, pErrInfo);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RU8", bVal);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    cbPkgConsumed++;
-                    break;
-                }
-                case kAcpiAmlOpcType_Word:
-                {
-                    uint16_t u16Val = 0; /* shut up gcc */
-                    rc = rtAcpiTblAmlDecodeReadU16(pThis, &u16Val, pErrInfo);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RX16", u16Val);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    cbPkgConsumed += sizeof(uint16_t);
-                    break;
-                }
-                case kAcpiAmlOpcType_DWord:
-                {
-                    uint32_t u32Val = 0; /* shut up gcc */
-                    rc = rtAcpiTblAmlDecodeReadU32(pThis, &u32Val, pErrInfo);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%RX32", u32Val);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    cbPkgConsumed += sizeof(uint32_t);
-                    break;
-                }
-                case kAcpiAmlOpcType_NameString:
-                {
-                    char szName[512];
-                    size_t cbName = 0;
-                    rc = rtAcpiTblAmlDecodeNameString(pThis, &szName[0], sizeof(szName), &cbName, pErrInfo);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "%s", szName);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    cbPkgConsumed += cbName;
-                    break;
-                }
-                case kAcpiAmlOpcType_SuperName:
-                case kAcpiAmlOpcType_TermArg:
-                {
-                    /** @todo SuperName has limited allowed arguments. */
-                    size_t offTblOrig = pThis->offTbl;
-
-                    rc = rtAcpiTblAmlDecodeTerminal(pThis, hVfsIosOut, pErrInfo);
-                    if (RT_FAILURE(rc)) return rc;
-
-                    cbPkgConsumed += pThis->offTbl - offTblOrig;
-                    break;
-                }
-                case kAcpiAmlOpcType_Invalid:
-                default:
-                    AssertReleaseFailed();
-            }
-        }
-
-        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, ")\n");
-        if (RT_FAILURE(rc)) return rc;
-
-        pThis->fIndent = true;
-    }
-    else if (pThis->fIndent)
-    {
-        rc = rtAcpiTblAmlDecodeFormat(pThis, hVfsIosOut, "\n");
-        if (RT_FAILURE(rc)) return rc;
-    }
-
-    if (pAmlOpc->fFlags & RTACPI_AML_OPC_F_HAS_PKG_LENGTH)
-    {
-        if (cbPkg < cbPkgConsumed)
-            return RTErrInfoSetF(pErrInfo, VERR_BUFFER_OVERFLOW, "Opcode arguments consumed more than the package length indicated (%zu vs %zu)", cbPkg, cbPkgConsumed);
-        rc = rtAcpiTblAmlDecodePkgPush(pThis, hVfsIosOut, cbPkg - cbPkgConsumed, pErrInfo);
-    }
-
-    return rc;
-}
-
-static int rtAcpiTblAmlDecode(PRTACPITBLAMLDECODE pThis, PCRTACPIAMLOPC pAmlOpc, uint8_t bOpc, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
-{
-    if (pAmlOpc->pszOpc)
-    {
-        if (pAmlOpc->pfnDecode)
-            return pAmlOpc->pfnDecode(pThis, hVfsIosOut, bOpc, pErrInfo);
-        return rtAcpiTblAmlDecodeSimple(pThis, pAmlOpc, bOpc, hVfsIosOut, pErrInfo);
-    }
-
-    return RTErrInfoSetF(pErrInfo, VERR_INVALID_STATE, "Invalid opcode %#x in ACPI table at offset %u", bOpc, pThis->offTbl);
-}
-
-
-static int rtAcpiTblAmlDecodeTerminal(PRTACPITBLAMLDECODE pThis, RTVFSIOSTREAM hVfsIosOut, PRTERRINFO pErrInfo)
-{
-    PCRTACPIAMLOPC pAmlOpc = NULL;
-    uint8_t bOpc = 0; /* shut up gcc */
-    int rc = rtAcpiTblAmlDecodeReadU8(pThis, &bOpc, pErrInfo);
-    if (RT_SUCCESS(rc))
-    {
-        if (bOpc == ACPI_AML_BYTE_CODE_PREFIX_EXT_OP)
-        {
-            rc = rtAcpiTblAmlDecodeReadU8(pThis, &bOpc, pErrInfo);
-            if (RT_FAILURE(rc))
-                return rc;
-
-            pAmlOpc = &g_aAmlExtOpcodeDecode[bOpc];
-        }
-        else
-            pAmlOpc = &g_aAmlOpcodeDecode[bOpc];
-
-        return rtAcpiTblAmlDecode(pThis, pAmlOpc, bOpc, hVfsIosOut, pErrInfo);
-    }
-
-    return rc;
-}
-
-
-RTDECL(int) RTAcpiTblCreateFromVfsIoStrm(PRTACPITBL phAcpiTbl, RTVFSIOSTREAM hVfsIos, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
-{
-    AssertPtrReturn(phAcpiTbl, VERR_INVALID_POINTER);
-    AssertReturn(hVfsIos != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
-
-    RT_NOREF(pErrInfo, enmInType);
-#if 0
-    if (enmInType == RTACPITBLTYPE_AML)
-        return rtAcpiTblLoadAml(phAcpiTbl, hVfsIos, pErrInfo);
-#endif
-
-    return VERR_NOT_IMPLEMENTED;
-}
-
-
-RTDECL(int) RTAcpiTblConvertFromVfsIoStrm(RTVFSIOSTREAM hVfsIosOut, RTACPITBLTYPE enmOutType,
-                                          RTVFSIOSTREAM hVfsIosIn, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
-{
-    AssertReturn(hVfsIosOut != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
-    AssertReturn(hVfsIosIn  != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
-    AssertReturn(enmInType == RTACPITBLTYPE_AML, VERR_NOT_SUPPORTED);
-    AssertReturn(enmOutType == RTACPITBLTYPE_ASL, VERR_NOT_SUPPORTED);
-
-    ACPITBLHDR Hdr;
-    int rc = RTVfsIoStrmRead(hVfsIosIn, &Hdr, sizeof(Hdr), true /*fBlocking*/, NULL /*pcbRead*/);
-    if (RT_SUCCESS(rc))
-    {
-        Hdr.u32Signature       = RT_LE2H_U32(Hdr.u32Signature);
-        Hdr.cbTbl              = RT_LE2H_U32(Hdr.cbTbl);
-        Hdr.u32OemRevision     = RT_LE2H_U32(Hdr.u32OemRevision);
-        Hdr.u32CreatorRevision = RT_LE2H_U32(Hdr.u32CreatorRevision);
-
-        if (   Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT
-            || Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_DSDT)
-        {
-            uint8_t *pbTbl = (uint8_t *)RTMemAlloc(Hdr.cbTbl);
-            if (pbTbl)
-            {
-                rc = RTVfsIoStrmRead(hVfsIosIn, pbTbl, Hdr.cbTbl - sizeof(Hdr), true /*fBlocking*/, NULL /*pcbRead*/);
-                if (RT_SUCCESS(rc))
-                {
-                    /** @todo Verify checksum */
-                    ssize_t cch = RTVfsIoStrmPrintf(hVfsIosOut, "DefinitionBlock(\"\", \"%s\", %u, \"%.6s\", \"%.8s\", %u)\n",
-                                                    Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT ? "SSDT" : "DSDT",
-                                                    1, &Hdr.abOemId[0], &Hdr.abOemTblId[0], Hdr.u32OemRevision);
-                    if (cch > 0)
-                    {
-                        RTACPITBLAMLDECODE AmlDecode;
-                        AmlDecode.pbTbl        = pbTbl;
-                        AmlDecode.cbTbl        = Hdr.cbTbl - sizeof(Hdr);
-                        AmlDecode.offTbl       = 0;
-                        AmlDecode.iLvl         = 0;
-                        AmlDecode.cPkgStackMax = 0;
-                        AmlDecode.pacbPkgLeft  = NULL;
-                        AmlDecode.fIndent      = true;
-                        rc = rtAcpiTblAmlDecodePkgPush(&AmlDecode, hVfsIosOut, AmlDecode.cbTbl, pErrInfo);
-                        while (   RT_SUCCESS(rc)
-                               && AmlDecode.offTbl < Hdr.cbTbl - sizeof(Hdr))
-                        {
-                            rc = rtAcpiTblAmlDecodeTerminal(&AmlDecode, hVfsIosOut, pErrInfo);
-                            if (RT_SUCCESS(rc))
-                                rc = rtAcpiTblAmlDecodePkgPop(&AmlDecode, hVfsIosOut, pErrInfo);
-                        }
-                        if (AmlDecode.pacbPkgLeft)
-                            RTMemFree(AmlDecode.pacbPkgLeft);
-
-                        if (RT_SUCCESS(rc))
-                        {
-                            cch = RTVfsIoStrmPrintf(hVfsIosOut, "}\n");
-                            if (cch <= 0)
-                                rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit closing definition block");
-                        }
-                    }
-                    else
-                        rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit DefinitionBlock()");
-                }
-                else
-                    rc = RTErrInfoSetF(pErrInfo, rc, "Reading %u bytes of the ACPI table failed", Hdr.cbTbl);
-
-                RTMemFree(pbTbl);
-                pbTbl = NULL;
-            }
-            else
-                rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Allocating memory for the ACPI table failed");
-        }
-        else
-            rc = RTErrInfoSetF(pErrInfo, VERR_NOT_SUPPORTED, "Only DSDT and SSDT ACPI tables are supported");
-    }
-    else
-        rc = RTErrInfoSetF(pErrInfo, rc, "Reading the ACPI table header failed with %Rrc", rc);
-
-    return rc;
-}
-
-
-RTDECL(int) RTAcpiTblCreateFromFile(PRTACPITBL phAcpiTbl, const char *pszFilename, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo)
-{
-    RTVFSIOSTREAM hVfsIos = NIL_RTVFSIOSTREAM;
-    int rc = RTVfsChainOpenIoStream(pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
-                                    &hVfsIos, NULL /*poffError*/, pErrInfo);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    rc = RTAcpiTblCreateFromVfsIoStrm(phAcpiTbl, hVfsIos, enmInType, pErrInfo);
-    RTVfsIoStrmRelease(hVfsIos);
-    return rc;
-}
Index: trunk/src/VBox/Runtime/common/misc/acpi.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/acpi.cpp	(revision 108014)
+++ 	(revision )
@@ -1,1584 +1,0 @@
-/* $Id$ */
-/** @file
- * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
- */
-
-/*
- * Copyright (C) 2024 Oracle and/or its affiliates.
- *
- * This file is part of VirtualBox base platform packages, as
- * available from https://www.virtualbox.org.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, in version 3 of the
- * License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses>.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
- * in the VirtualBox distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- *
- * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
- */
-
-
-/*********************************************************************************************************************************
-*   Header Files                                                                                                                 *
-*********************************************************************************************************************************/
-#define LOG_GROUP RTLOGGROUP_ACPI
-#include <iprt/acpi.h>
-#include <iprt/asm.h>
-#include <iprt/file.h>
-#include <iprt/mem.h>
-#include <iprt/string.h>
-#include <iprt/uuid.h>
-
-#include <iprt/formats/acpi-aml.h>
-#include <iprt/formats/acpi-resources.h>
-
-
-/*********************************************************************************************************************************
-*   Defined Constants And Macros                                                                                                 *
-*********************************************************************************************************************************/
-
-
-
-/*********************************************************************************************************************************
-*   Structures and Typedefs                                                                                                      *
-*********************************************************************************************************************************/
-
-/**
- * Package stack element.
- */
-typedef struct RTACPITBLSTACKELEM
-{
-    /** Pointer to the table buffer memory where the PkgLength object starts. */
-    uint8_t                     *pbPkgLength;
-    /** Current size of the package in bytes, without the PkgLength object. */
-    uint32_t                    cbPkg;
-    /** The operator creating the package, UINT8_MAX denotes the special root operator. */
-    uint8_t                     bOp;
-} RTACPITBLSTACKELEM;
-/** Pointer to a package stack element. */
-typedef RTACPITBLSTACKELEM *PRTACPITBLSTACKELEM;
-/** Pointer to a const package stack element. */
-typedef const RTACPITBLSTACKELEM *PCRTACPITBLSTACKELEM;
-
-
-/**
- * ACPI table generator instance.
- */
-typedef struct RTACPITBLINT
-{
-    /** Pointer to the ACPI table header, needed when finalizing the table. */
-    PACPITBLHDR                 pHdr;
-    /** Byte buffer holding the actual table. */
-    uint8_t                     *pbTblBuf;
-    /** Size of the table buffer. */
-    uint32_t                    cbTblBuf;
-    /** Current offset into the table buffer. */
-    uint32_t                    offTblBuf;
-    /** Flag whether the table is finalized. */
-    bool                        fFinalized;
-    /** First error code encountered. */
-    int                         rcErr;
-    /** Pointer to the package element stack. */
-    PRTACPITBLSTACKELEM         paPkgStack;
-    /** Number of elements the package stack can hold. */
-    uint32_t                    cPkgStackElems;
-    /** Index of the current package in the package stack. */
-    uint32_t                    idxPkgStackElem;
-} RTACPITBLINT;
-/** Pointer to an ACPI table generator instance. */
-typedef RTACPITBLINT *PRTACPITBLINT;
-
-
-/**
- * ACPI resource builder instance.
- */
-typedef struct RTACPIRESINT
-{
-    /** Byte buffer holding the resource. */
-    uint8_t                     *pbResBuf;
-    /** Size of the resource buffer. */
-    size_t                      cbResBuf;
-    /** Current offset into the resource buffer. */
-    uint32_t                    offResBuf;
-    /** Flag whether the resource is sealed. */
-    bool                        fSealed;
-    /** First error code encountered. */
-    int                         rcErr;
-} RTACPIRESINT;
-/** Pointer to an ACPI resource builder instance. */
-typedef RTACPIRESINT *PRTACPIRESINT;
-
-
-/*********************************************************************************************************************************
-*   Global Variables                                                                                                             *
-*********************************************************************************************************************************/
-
-
-/*********************************************************************************************************************************
-*   Internal Functions                                                                                                           *
-*********************************************************************************************************************************/
-
-
-/**
- * Copies the given string into the given buffer padding the remainder with the given character.
- *
- * @param    pbId           The destination to copy the string to.
- * @param    cbId           Size of the buffer in bytes.
- * @param    pszStr         The string to copy.
- * @param    chPad          The character to pad with.
- */
-static void rtAcpiTblCopyStringPadWith(uint8_t *pbId, size_t cbId, const char *pszStr, char chPad)
-{
-    Assert(strlen(pszStr) <= cbId);
-
-    uint32_t idx = 0;
-    while (*pszStr != '\0')
-        pbId[idx++] = (uint8_t)*pszStr++;
-
-    while (idx < cbId)
-        pbId[idx++] = chPad;
-}
-
-
-/**
- * Updates the package length of the current package in the stack
- *
- * @param pThis                 The ACPI table instance.
- * @param cbAdd                 How many bytes to add to the package length.
- */
-DECL_FORCE_INLINE(void) rtAcpiTblUpdatePkgLength(PRTACPITBLINT pThis, uint32_t cbAdd)
-{
-    PRTACPITBLSTACKELEM pPkgElem = &pThis->paPkgStack[pThis->idxPkgStackElem];
-    pPkgElem->cbPkg += cbAdd;
-}
-
-
-/**
- * Ensures there is the given amount of room in the ACPI table buffer returning the pointer.
- *
- * @returns The pointer to the free space on success or NULL if out of memory.
- * @param pThis                 The ACPI table instance.
- * @param cbReq                 Amount of bytes requested.
- */
-static uint8_t *rtAcpiTblBufEnsureSpace(PRTACPITBLINT pThis, uint32_t cbReq)
-{
-    if (RT_LIKELY(pThis->cbTblBuf - pThis->offTblBuf >= cbReq))
-    {
-        uint8_t *pb = &pThis->pbTblBuf[pThis->offTblBuf];
-        pThis->offTblBuf += cbReq;
-        return pb;
-    }
-
-    uint32_t const cbNew = RT_ALIGN_32(pThis->cbTblBuf + cbReq, _4K);
-    uint8_t *pbNew = (uint8_t *)RTMemRealloc(pThis->pbTblBuf, cbNew);
-    if (RT_UNLIKELY(!pbNew))
-    {
-        pThis->rcErr = VERR_NO_MEMORY;
-        return NULL;
-    }
-
-    pThis->pbTblBuf = pbNew;
-    pThis->cbTblBuf = cbNew;
-
-    uint8_t *pb = &pThis->pbTblBuf[pThis->offTblBuf];
-    pThis->offTblBuf += cbReq;
-    return pb;
-}
-
-
-/**
- * Appends a new package in the given ACPI table instance package stack.
- *
- * @returns IPRT status code.
- * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
- * @param pThis                 The ACPI table instance.
- * @param bOp                   The opcode byte the package starts with (for verification purposes when finalizing the package).
- * @param pbPkgBuf              The Start of the package buffer.
- */
-static int rtAcpiTblPkgAppendEx(PRTACPITBLINT pThis, uint8_t bOp, uint8_t *pbPkgBuf)
-{
-    /* Get a new stack element. */
-    if (pThis->idxPkgStackElem + 1 == pThis->cPkgStackElems)
-    {
-        uint32_t const cPkgElemsNew = pThis->cPkgStackElems + 8;
-        PRTACPITBLSTACKELEM paPkgStackNew = (PRTACPITBLSTACKELEM)RTMemRealloc(pThis->paPkgStack, cPkgElemsNew * sizeof(*paPkgStackNew));
-        if (!paPkgStackNew)
-        {
-            pThis->rcErr = VERR_NO_MEMORY;
-            return VERR_NO_MEMORY;
-        }
-
-        pThis->paPkgStack     = paPkgStackNew;
-        pThis->cPkgStackElems = cPkgElemsNew;
-    }
-
-    PRTACPITBLSTACKELEM pStackElem = &pThis->paPkgStack[++pThis->idxPkgStackElem];
-    pStackElem->pbPkgLength = pbPkgBuf;
-    pStackElem->cbPkg       = 0;
-    pStackElem->bOp         = bOp;
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Starts a new ACPI package in the given ACPI table instance.
- *
- * @returns IPRT status code.
- * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
- * @param pThis                 The ACPI table instance.
- * @param bOp                   The opcode byte identifying the package content.
- */
-static int rtAcpiTblPkgStart(PRTACPITBLINT pThis, uint8_t bOp)
-{
-    /*
-     * Allocate 1 byte for opcode + always 4 bytes for the PkgLength, as we don't know how much we will need upfront.
-     * This will be corrected when the package is finalized.
-     */
-    uint8_t *pbPkg = rtAcpiTblBufEnsureSpace(pThis, 5);
-    if (!pbPkg)
-    {
-        pThis->rcErr = VERR_NO_MEMORY;
-        return VERR_NO_MEMORY;
-    }
-
-    *pbPkg = bOp;
-    /*
-     * Update the package length of the outer package for the opcode,
-     * the PkgLength object's final length will be added in rtAcpiTblPkgFinish().
-     */
-    rtAcpiTblUpdatePkgLength(pThis, sizeof(bOp));
-    return rtAcpiTblPkgAppendEx(pThis, bOp, pbPkg + 1);
-}
-
-
-/**
- * Starts a new ACPI package in the given ACPI table instance. This is for opcodes prefixed with
- * ACPI_AML_BYTE_CODE_PREFIX_EXT_O, which will be added automatically.
- *
- * @returns IPRT status code.
- * @retval VERR_NO_MEMORY if allocating additional resources to hold the new package failed.
- * @param pThis                 The ACPI table instance.
- * @param bOp                   The opcode byte identifying the package content.
- */
-static int rtAcpiTblPkgStartExt(PRTACPITBLINT pThis, uint8_t bOp)
-{
-    /*
-     * Allocate 2 bytes for ExtOpPrefix opcode + always 4 bytes for the PkgLength, as we don't know how much we will need upfront.
-     * This will be corrected when the package is finalized.
-     */
-    uint8_t *pbPkg = rtAcpiTblBufEnsureSpace(pThis, 6);
-    if (!pbPkg)
-    {
-        pThis->rcErr = VERR_NO_MEMORY;
-        return VERR_NO_MEMORY;
-    }
-
-    pbPkg[0] = ACPI_AML_BYTE_CODE_PREFIX_EXT_OP;
-    pbPkg[1] = bOp;
-
-    /*
-     * Update the package length of the outer package for the opcode,
-     * the PkgLength object's final length will be added in rtAcpiTblPkgFinish().
-     */
-    rtAcpiTblUpdatePkgLength(pThis, sizeof(uint8_t) + sizeof(bOp));
-    return rtAcpiTblPkgAppendEx(pThis, bOp, pbPkg + 2);
-}
-
-
-/**
- * Finishes the current package on the top of the package stack, setting the
- * package length accordingly.
- *
- * @returns IPRT status code.
- * @retval VERR_INVALID_STATE if bOp doesn't match the opcode the package was started with (asserted in debug builds).
- * @retval VERR_BUFFER_OVERFLOW if the package length exceeds what can be encoded in the package length field.
- * @param pThis                 The ACPI table instance.
- * @param bOp                   The opcode byte identifying the package content the package was started with.
- */
-static int rtAcpiTblPkgFinish(PRTACPITBLINT pThis, uint8_t bOp)
-{
-    /* Ensure the op matches what is current on the top of the stack. */
-    AssertReturn(pThis->paPkgStack[pThis->idxPkgStackElem].bOp == bOp, VERR_INVALID_STATE);
-
-    /* Pop the topmost stack element from the stack. */
-    PRTACPITBLSTACKELEM pPkgElem = &pThis->paPkgStack[pThis->idxPkgStackElem--];
-
-    /*
-     * Determine how many bytes we actually need for the PkgLength and re-arrange the ACPI table.
-     *
-     * Note! PkgLength will also include its own length.
-     */
-    uint8_t  *pbPkgLength = pPkgElem->pbPkgLength;
-    uint32_t cbThisPkg    = pPkgElem->cbPkg;
-    if (cbThisPkg + 1 <= 63)
-    {
-        /* Remove the gap. */
-        memmove(pbPkgLength + 1, pbPkgLength + 4, cbThisPkg);
-        pThis->offTblBuf -= 3;
-
-        /* PkgLength only consists of the package lead byte. */
-        cbThisPkg += 1;
-        *pbPkgLength = (cbThisPkg & 0x3f);
-    }
-    else if (cbThisPkg + 2 < RT_BIT_32(12))
-    {
-        /* Remove the gap. */
-        memmove(pbPkgLength + 2, pbPkgLength + 4, cbThisPkg);
-        pThis->offTblBuf -= 2;
-
-        cbThisPkg += 2;
-        pbPkgLength[0] = (1 << 6) | (cbThisPkg & 0xf);
-        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
-    }
-    else if (cbThisPkg + 3 < RT_BIT_32(20))
-    {
-        /* Remove the gap. */
-        memmove(pbPkgLength + 3, pbPkgLength + 4, cbThisPkg);
-        pThis->offTblBuf -= 1;
-
-        cbThisPkg += 3;
-        pbPkgLength[0] = (2 << 6) | (cbThisPkg & 0xf);
-        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
-        pbPkgLength[2] = (cbThisPkg >> 12) & 0xff;
-    }
-    else if (cbThisPkg + 4 < RT_BIT_32(28))
-    {
-        cbThisPkg += 4;
-        pbPkgLength[0] = (3 << 6) | (cbThisPkg & 0xf);
-        pbPkgLength[1] = (cbThisPkg >> 4)  & 0xff;
-        pbPkgLength[2] = (cbThisPkg >> 12) & 0xff;
-        pbPkgLength[3] = (cbThisPkg >> 20) & 0xff;
-    }
-    else
-        return VERR_BUFFER_OVERFLOW;
-
-    /* Update the size of the outer package. */
-    pThis->paPkgStack[pThis->idxPkgStackElem].cbPkg += cbThisPkg;
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Appends the given byte to the ACPI table, updating the package length of the current package.
- *
- * @param pThis                 The ACPI table instance.
- * @param bData                 The byte data to append.
- */
-DECLINLINE(void) rtAcpiTblAppendByte(PRTACPITBLINT pThis, uint8_t bData)
-{
-    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, sizeof(bData));
-    if (pb)
-    {
-        *pb = bData;
-        rtAcpiTblUpdatePkgLength(pThis, sizeof(bData));
-    }
-}
-
-
-/**
- * Appends the given date to the ACPI table, updating the package length of the current package.
- *
- * @param pThis                 The ACPI table instance.
- * @param pvData                The data to append.
- * @param cbData                Size of the data in bytes.
- */
-DECLINLINE(void) rtAcpiTblAppendData(PRTACPITBLINT pThis, const void *pvData, uint32_t cbData)
-{
-    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, cbData);
-    if (pb)
-    {
-        memcpy(pb, pvData, cbData);
-        rtAcpiTblUpdatePkgLength(pThis, cbData);
-    }
-}
-
-
-/**
- * Appends the given namestring to the ACPI table, updating the package length of the current package
- * and padding the name with _ if too short.
- *
- * @param pThis                 The ACPI table instance.
- * @param pszName               The name to append, maximum is 4 bytes (or 5 if \\ is the first character).
- */
-DECLINLINE(void) rtAcpiTblAppendNameString(PRTACPITBLINT pThis, const char *pszName)
-{
-    uint32_t cbName = *pszName == '\\' ? 5 : 4;
-    uint8_t *pb = rtAcpiTblBufEnsureSpace(pThis, cbName);
-    if (pb)
-    {
-        rtAcpiTblCopyStringPadWith(pb, cbName, pszName, '_');
-        rtAcpiTblUpdatePkgLength(pThis, cbName);
-    }
-}
-
-
-/**
- * Encodes a PkgLength item for the given number.
- *
- * @returns IPRT status code.
- * @param pThis                 The ACPI table instance.
- * @param u64Length             The length to encode.
- */
-DECLINLINE(int) rtAcpiTblEncodePkgLength(PRTACPITBLINT pThis, uint64_t u64Length)
-{
-    AssertReturn(u64Length < RT_BIT_32(28), VERR_BUFFER_OVERFLOW);
-
-    if (u64Length <= 63)
-    {
-        /* PkgLength only consists of the package lead byte. */
-        rtAcpiTblAppendByte(pThis, (u64Length & 0x3f));
-    }
-    else if (u64Length < RT_BIT_32(12))
-    {
-        uint8_t abData[2];
-        abData[0] = (1 << 6) | (u64Length & 0xf);
-        abData[1] = (u64Length >> 4) & 0xff;
-        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
-    }
-    else if (u64Length < RT_BIT_32(20))
-    {
-        uint8_t abData[3];
-        abData[0] = (2 << 6) | (u64Length & 0xf);
-        abData[1] = (u64Length >> 4)  & 0xff;
-        abData[2] = (u64Length >> 12) & 0xff;
-        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
-    }
-    else if (u64Length < RT_BIT_32(28))
-    {
-        uint8_t abData[4];
-        abData[0] = (3 << 6) | (u64Length & 0xf);
-        abData[1] = (u64Length >> 4)  & 0xff;
-        abData[2] = (u64Length >> 12) & 0xff;
-        abData[3] = (u64Length >> 20) & 0xff;
-        rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData));
-    }
-    else
-        AssertReleaseFailed();
-
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(uint8_t) RTAcpiChecksumGenerate(const void *pvData, size_t cbData)
-{
-    uint8_t const *pbSrc = (uint8_t const *)pvData;
-    uint8_t bSum = 0;
-    for (size_t i = 0; i < cbData; ++i)
-        bSum += pbSrc[i];
-
-    return -bSum;
-}
-
-
-RTDECL(void) RTAcpiTblHdrChecksumGenerate(PACPITBLHDR pTbl, size_t cbTbl)
-{
-    pTbl->bChkSum = 0;
-    pTbl->bChkSum = RTAcpiChecksumGenerate(pTbl, cbTbl);
-}
-
-
-RTDECL(int) RTAcpiTblCreate(PRTACPITBL phAcpiTbl, uint32_t u32TblSig, uint8_t bRevision, const char *pszOemId,
-                            const char *pszOemTblId, uint32_t u32OemRevision, const char *pszCreatorId,
-                            uint32_t u32CreatorRevision)
-{
-    AssertPtrReturn(phAcpiTbl,   VERR_INVALID_POINTER);
-    AssertPtrReturn(pszOemId,    VERR_INVALID_POINTER);
-    AssertPtrReturn(pszOemTblId, VERR_INVALID_POINTER);
-    AssertReturn(strlen(pszOemId) <= 6, VERR_INVALID_PARAMETER);
-    AssertReturn(strlen(pszOemTblId) <= 8, VERR_INVALID_PARAMETER);
-    AssertReturn(!pszCreatorId || strlen(pszCreatorId) <= 4, VERR_INVALID_PARAMETER);
-
-    PRTACPITBLINT pThis = (PRTACPITBLINT)RTMemAllocZ(sizeof(*pThis));
-    if (pThis)
-    {
-        pThis->pbTblBuf = (uint8_t *)RTMemAlloc(_4K);
-        if (pThis->pbTblBuf)
-        {
-            pThis->pHdr            = (PACPITBLHDR)pThis->pbTblBuf;
-            pThis->offTblBuf       = sizeof(*pThis->pHdr);
-            pThis->cbTblBuf        = _4K;
-            pThis->fFinalized      = false;
-            pThis->rcErr           = VINF_SUCCESS;
-            pThis->paPkgStack      = NULL;
-            pThis->cPkgStackElems  = 0;
-            pThis->idxPkgStackElem = 0;
-
-            /* Add the root stack element for the table, aka DefinitionBlock() in ASL. */
-            uint32_t const cPkgElemsInitial = 8;
-            pThis->paPkgStack = (PRTACPITBLSTACKELEM)RTMemAlloc(cPkgElemsInitial * sizeof(*pThis->paPkgStack));
-            if (pThis->paPkgStack)
-            {
-                pThis->cPkgStackElems = cPkgElemsInitial;
-
-                PRTACPITBLSTACKELEM pStackElem = &pThis->paPkgStack[pThis->idxPkgStackElem];
-                pStackElem->pbPkgLength        = pThis->pbTblBuf; /* Starts with the header. */
-                pStackElem->cbPkg              = sizeof(*pThis->pHdr);
-                pStackElem->bOp                = UINT8_MAX;
-
-                /* Init the table header with static things. */
-                pThis->pHdr->u32Signature       = u32TblSig;
-                pThis->pHdr->bRevision          = bRevision;
-                pThis->pHdr->u32OemRevision     = RT_H2LE_U32(u32OemRevision);
-                pThis->pHdr->u32CreatorRevision = RT_H2LE_U32(u32CreatorRevision);
-
-                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abOemId[0],     sizeof(pThis->pHdr->abOemId),     pszOemId,    ' ');
-                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abOemTblId[0],  sizeof(pThis->pHdr->abOemTblId),  pszOemTblId, ' ');
-                rtAcpiTblCopyStringPadWith(&pThis->pHdr->abCreatorId[0], sizeof(pThis->pHdr->abCreatorId),
-                                           pszCreatorId ? pszCreatorId : "IPRT", ' ');
-
-                *phAcpiTbl = pThis;
-                return VINF_SUCCESS;
-            }
-
-            RTMemFree(pThis->pbTblBuf);
-        }
-
-        RTMemFree(pThis);
-    }
-
-    return VERR_NO_MEMORY;
-}
-
-
-RTDECL(void) RTAcpiTblDestroy(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturnVoid(pThis);
-
-    RTMemFree(pThis->paPkgStack);
-    RTMemFree(pThis->pbTblBuf);
-    pThis->pHdr            = NULL;
-    pThis->pbTblBuf        = NULL;
-    pThis->cbTblBuf        = 0;
-    pThis->offTblBuf       = 0;
-    pThis->paPkgStack      = NULL;
-    pThis->cPkgStackElems  = 0;
-    pThis->idxPkgStackElem = 0;
-    RTMemFree(pThis);
-}
-
-
-RTDECL(int) RTAcpiTblFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-    AssertReturn(!pThis->fFinalized, VERR_INVALID_PARAMETER);
-    AssertReturn(pThis->idxPkgStackElem == 0, VERR_INVALID_STATE); /** @todo Better status code. */
-    AssertReturn(pThis->paPkgStack[0].bOp == UINT8_MAX, VERR_INVALID_STATE);
-
-    pThis->pHdr->cbTbl = RT_H2LE_U32(pThis->paPkgStack[0].cbPkg);
-    RTAcpiTblHdrChecksumGenerate(pThis->pHdr, pThis->paPkgStack[0].cbPkg);
-
-    pThis->fFinalized = true;
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(uint32_t) RTAcpiTblGetSize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, 0);
-    AssertRCReturn(pThis->rcErr, 0);
-    AssertReturn(pThis->fFinalized, 0);
-
-    return pThis->paPkgStack[0].cbPkg;
-}
-
-
-RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, RTVFSIOSTREAM hVfsIos)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertRCReturn(pThis->rcErr, 0);
-    AssertReturn(enmOutType == RTACPITBLTYPE_AML, VERR_NOT_SUPPORTED);
-
-    return RTVfsIoStrmWrite(hVfsIos, pThis->pbTblBuf, pThis->paPkgStack[0].cbPkg,
-                            true /*fBlocking*/, NULL /*pcbWritten*/);
-}
-
-
-RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, const char *pszFilename)
-{
-    RTVFSIOSTREAM hVfsIos = NIL_RTVFSIOSTREAM;
-    int rc = RTVfsChainOpenIoStream(pszFilename, RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_NONE,
-                                    &hVfsIos, NULL /*poffError*/, NULL);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    rc = RTAcpiTblDumpToVfsIoStrm(hAcpiTbl, enmOutType, hVfsIos);
-    RTVfsIoStrmRelease(hVfsIos);
-    return rc;
-}
-
-
-RTDECL(int) RTAcpiTblScopeFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_SCOPE);
-}
-
-
-RTDECL(int) RTAcpiTblScopeStart(RTACPITBL hAcpiTbl, const char *pszName)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_SCOPE);
-    rtAcpiTblAppendNameString(pThis, pszName);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblPackageStart(RTACPITBL hAcpiTbl, uint8_t cElements)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_PACKAGE);
-    rtAcpiTblAppendByte(pThis, cElements);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblPackageFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_PACKAGE);
-}
-
-
-RTDECL(int) RTAcpiTblDeviceStart(RTACPITBL hAcpiTbl, const char *pszName)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_EXT_OP_DEVICE);
-    rtAcpiTblAppendNameString(pThis, pszName);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblDeviceStartF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...)
-{
-    va_list va;
-    va_start(va, pszNameFmt);
-    int rc = RTAcpiTblDeviceStartV(hAcpiTbl, pszNameFmt, va);
-    va_end(va);
-    return rc;
-}
-
-
-RTDECL(int) RTAcpiTblDeviceStartV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va)
-{
-    char szName[5];
-    ssize_t cch = RTStrPrintf2V(&szName[0], sizeof(szName), pszNameFmt, va);
-    if (cch <= 0)
-        return VERR_BUFFER_OVERFLOW;
-
-    return RTAcpiTblDeviceStart(hAcpiTbl, &szName[0]);
-}
-
-
-RTDECL(int) RTAcpiTblDeviceFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_EXT_OP_DEVICE);
-}
-
-
-RTDECL(int) RTAcpiTblMethodStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t cArgs, uint32_t fFlags, uint8_t uSyncLvl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(cArgs < 8, VERR_INVALID_PARAMETER);
-    AssertReturn(uSyncLvl < 0x10, VERR_INVALID_PARAMETER);
-
-    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_METHOD);
-    rtAcpiTblAppendNameString(pThis, pszName);
-
-    uint8_t bFlags = cArgs;
-    bFlags |= fFlags & RTACPI_METHOD_F_SERIALIZED ? RT_BIT(3) : 0;
-    bFlags |= uSyncLvl << 4;
-
-    rtAcpiTblAppendByte(pThis, bFlags);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblMethodFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_METHOD);
-}
-
-
-RTDECL(int) RTAcpiTblNameAppend(RTACPITBL hAcpiTbl, const char *pszName)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_NAME);
-    rtAcpiTblAppendNameString(pThis, pszName);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblNullNameAppend(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblAppendByte(pThis, 0x00);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblNameStringAppend(RTACPITBL hAcpiTbl, const char *pszName)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblAppendNameString(pThis, pszName);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblStringAppend(RTACPITBL hAcpiTbl, const char *psz)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_STRING);
-    rtAcpiTblAppendData(pThis, psz, (uint32_t)strlen(psz) + 1);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblIntegerAppend(RTACPITBL hAcpiTbl, uint64_t u64)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    if (!u64)
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ZERO);
-    else if (u64 == 1)
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ONE);
-    else if (u64 <= UINT8_MAX)
-    {
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_BYTE);
-        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
-    }
-    else if (u64 <= UINT16_MAX)
-    {
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_WORD);
-        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 8));
-    }
-    else if (u64 <= UINT32_MAX)
-    {
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_DWORD);
-        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >>  8));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 16));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 24));
-    }
-    else
-    {
-        rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_PREFIX_QWORD);
-        rtAcpiTblAppendByte(pThis, (uint8_t)u64);
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >>  8));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 16));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 24));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 32));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 40));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 48));
-        rtAcpiTblAppendByte(pThis, (uint8_t)(u64 >> 56));
-    }
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblBufferAppend(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(!cbBuf || RT_VALID_PTR(pvBuf), VERR_INVALID_PARAMETER);
-    AssertReturn(cbBuf <= UINT32_MAX, VERR_BUFFER_OVERFLOW);
-
-    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_BUFFER);
-    RTAcpiTblIntegerAppend(hAcpiTbl, cbBuf);
-    if (pvBuf)
-        rtAcpiTblAppendData(pThis, pvBuf, (uint32_t)cbBuf);
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_BUFFER);
-}
-
-
-RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    const void *pvRes = NULL;
-    size_t cbRes = 0;
-    int rc = RTAcpiResourceQueryBuffer(hAcpiRes, &pvRes, &cbRes);
-    if (RT_SUCCESS(rc))
-        rc = RTAcpiTblBufferAppend(pThis, pvRes, cbRes);
-
-    return rc;
-}
-
-
-RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    uint8_t bOp;
-    switch (enmStmt)
-    {
-        case kAcpiStmt_Return:     bOp = ACPI_AML_BYTE_CODE_OP_RETURN;      break;
-        case kAcpiStmt_Breakpoint: bOp = ACPI_AML_BYTE_CODE_OP_BREAK_POINT; break;
-        case kAcpiStmt_Nop:        bOp = ACPI_AML_BYTE_CODE_OP_NOOP;        break;
-        case kAcpiStmt_Break:      bOp = ACPI_AML_BYTE_CODE_OP_BREAK;       break;
-        case kAcpiStmt_Continue:   bOp = ACPI_AML_BYTE_CODE_OP_CONTINUE;    break;
-        case kAcpiStmt_Add:        bOp = ACPI_AML_BYTE_CODE_OP_ADD;         break;
-        case kAcpiStmt_Subtract:   bOp = ACPI_AML_BYTE_CODE_OP_SUBTRACT;    break;
-        case kAcpiStmt_And:        bOp = ACPI_AML_BYTE_CODE_OP_AND;         break;
-        case kAcpiStmt_Nand:       bOp = ACPI_AML_BYTE_CODE_OP_NAND;        break;
-        case kAcpiStmt_Or:         bOp = ACPI_AML_BYTE_CODE_OP_OR;          break;
-        case kAcpiStmt_Xor:        bOp = ACPI_AML_BYTE_CODE_OP_XOR;         break;
-        case kAcpiStmt_Not:        bOp = ACPI_AML_BYTE_CODE_OP_NOT;         break;
-        case kAcpiStmt_Store:      bOp = ACPI_AML_BYTE_CODE_OP_STORE;       break;
-        case kAcpiStmt_Index:      bOp = ACPI_AML_BYTE_CODE_OP_INDEX;       break;
-        case kAcpiStmt_DerefOf:    bOp = ACPI_AML_BYTE_CODE_OP_DEREF_OF;    break;
-        default:
-            AssertFailedReturn(VERR_INVALID_PARAMETER);
-    }
-    rtAcpiTblAppendByte(pThis, bOp);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_IF);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_IF);
-}
-
-
-RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    /* Makes only sense inside an IfOp package. */
-    AssertReturn(pThis->paPkgStack[pThis->idxPkgStackElem].bOp == ACPI_AML_BYTE_CODE_OP_IF, VERR_INVALID_STATE);
-
-    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
-}
-
-
-RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    uint8_t bOp;
-    switch (enmBinaryOp)
-    {
-        case kAcpiBinaryOp_LAnd:            bOp = ACPI_AML_BYTE_CODE_OP_LAND;     break;
-        case kAcpiBinaryOp_LEqual:          bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
-        case kAcpiBinaryOp_LGreater:        bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
-        case kAcpiBinaryOp_LLess:           bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
-        case kAcpiBinaryOp_LGreaterEqual:
-        case kAcpiBinaryOp_LLessEqual:
-        case kAcpiBinaryOp_LNotEqual:
-            bOp = ACPI_AML_BYTE_CODE_OP_LNOT;
-            break;
-        default:
-            AssertFailedReturn(VERR_INVALID_PARAMETER);
-    }
-    rtAcpiTblAppendByte(pThis, bOp);
-    switch (enmBinaryOp)
-    {
-        case kAcpiBinaryOp_LGreaterEqual:   bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
-        case kAcpiBinaryOp_LLessEqual:      bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
-        case kAcpiBinaryOp_LNotEqual:       bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
-        default:
-            bOp = 0x00;
-    }
-    if (bOp != 0x00)
-        rtAcpiTblAppendByte(pThis, bOp);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(idArg <= 6, VERR_INVALID_PARAMETER);
-
-    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ARG_0 + idArg);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(idLocal <= 7, VERR_INVALID_PARAMETER);
-
-    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_LOCAL_0 + idLocal);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid)
-{
-    /* UUIDs are stored as a buffer object. */
-    /** @todo Needs conversion on big endian machines. */
-    return RTAcpiTblBufferAppend(hAcpiTbl, &pUuid->au8[0], sizeof(*pUuid));
-}
-
-
-RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    RTUUID Uuid;
-    pThis->rcErr = RTUuidFromStr(&Uuid, pszUuid);
-    if (RT_SUCCESS(pThis->rcErr))
-        return RTAcpiTblUuidAppend(pThis, &Uuid);
-
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblOpRegionAppendEx(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    uint8_t abOp[2] = { ACPI_AML_BYTE_CODE_PREFIX_EXT_OP, ACPI_AML_BYTE_CODE_EXT_OP_OP_REGION };
-    rtAcpiTblAppendData(pThis, &abOp[0], sizeof(abOp));
-    rtAcpiTblAppendNameString(pThis, pszName);
-
-    uint8_t bRegionSpace = 0xff;
-    switch (enmSpace)
-    {
-        case kAcpiOperationRegionSpace_SystemMemory:        bRegionSpace = 0x00; break;
-        case kAcpiOperationRegionSpace_SystemIo:            bRegionSpace = 0x01; break;
-        case kAcpiOperationRegionSpace_PciConfig:           bRegionSpace = 0x02; break;
-        case kAcpiOperationRegionSpace_EmbeddedControl:     bRegionSpace = 0x03; break;
-        case kAcpiOperationRegionSpace_SmBus:               bRegionSpace = 0x04; break;
-        case kAcpiOperationRegionSpace_SystemCmos:          bRegionSpace = 0x05; break;
-        case kAcpiOperationRegionSpace_PciBarTarget:        bRegionSpace = 0x06; break;
-        case kAcpiOperationRegionSpace_Ipmi:                bRegionSpace = 0x07; break;
-        case kAcpiOperationRegionSpace_Gpio:                bRegionSpace = 0x08; break;
-        case kAcpiOperationRegionSpace_GenericSerialBus:    bRegionSpace = 0x09; break;
-        case kAcpiOperationRegionSpace_Pcc:                 bRegionSpace = 0x0a; break;
-        default:
-            pThis->rcErr = VERR_INVALID_PARAMETER;
-            AssertFailedReturn(pThis->rcErr);
-    }
-    rtAcpiTblAppendByte(pThis, bRegionSpace);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace,
-                                    uint64_t offRegion, uint64_t cbRegion)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    int rc = RTAcpiTblOpRegionAppendEx(pThis, pszName, enmSpace);
-    if (RT_FAILURE(rc))
-        return rc;
-
-    RTAcpiTblIntegerAppend(pThis, offRegion);
-    RTAcpiTblIntegerAppend(pThis, cbRegion);
-    return pThis->rcErr;
-}
-
-
-RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc,
-                                 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields,
-                                 uint32_t cFields)
-{
-    PRTACPITBLINT pThis = hAcpiTbl;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-
-    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD);
-    rtAcpiTblAppendNameString(pThis, pszNameRef);
-
-    uint8_t fFlags = 0;
-    switch (enmAcc)
-    {
-        case kAcpiFieldAcc_Any:    fFlags = 0; break;
-        case kAcpiFieldAcc_Byte:   fFlags = 1; break;
-        case kAcpiFieldAcc_Word:   fFlags = 2; break;
-        case kAcpiFieldAcc_DWord:  fFlags = 3; break;
-        case kAcpiFieldAcc_QWord:  fFlags = 4; break;
-        case kAcpiFieldAcc_Buffer: fFlags = 5; break;
-        default:
-            pThis->rcErr = VERR_INVALID_PARAMETER;
-            AssertFailedReturn(pThis->rcErr);
-    }
-    if (fLock)
-        fFlags |= RT_BIT(4);
-    switch (enmUpdate)
-    {
-        case kAcpiFieldUpdate_Preserve:      fFlags |= 0 << 5; break;
-        case kAcpiFieldUpdate_WriteAsOnes:   fFlags |= 1 << 5; break;
-        case kAcpiFieldUpdate_WriteAsZeroes: fFlags |= 2 << 5; break;
-        default:
-            pThis->rcErr = VERR_INVALID_PARAMETER;
-            AssertFailedReturn(pThis->rcErr);
-    }
-    rtAcpiTblAppendByte(pThis, fFlags);
-
-    for (uint32_t i = 0; i < cFields; i++)
-    {
-        rtAcpiTblAppendNameString(pThis, paFields[i].pszName);
-        rtAcpiTblEncodePkgLength(pThis, paFields[i].cBits);
-    }
-
-    rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD);
-    return pThis->rcErr;
-}
-
-
-/**
- * Ensures there is at least the given amount of space in the given ACPI resource.
- *
- * @returns Pointer to the free buffer space or NULL if out of memory.
- * @param   pThis               The ACPI resource instance.
- * @param   cbReq               Number of free bytes required.
- */
-static uint8_t *rtAcpiResBufEnsureSpace(PRTACPIRESINT pThis, uint32_t cbReq)
-{
-    if (RT_LIKELY(pThis->cbResBuf - pThis->offResBuf >= cbReq))
-    {
-        uint8_t *pb = &pThis->pbResBuf[pThis->offResBuf];
-        pThis->offResBuf += cbReq;
-        return pb;
-    }
-
-    size_t const cbNew = RT_ALIGN_Z(pThis->cbResBuf + cbReq, _4K);
-    uint8_t *pbNew = (uint8_t *)RTMemRealloc(pThis->pbResBuf, cbNew);
-    if (RT_UNLIKELY(!pbNew))
-    {
-        pThis->rcErr = VERR_NO_MEMORY;
-        return NULL;
-    }
-
-    pThis->pbResBuf = pbNew;
-    pThis->cbResBuf = cbNew;
-
-    uint8_t *pb = &pThis->pbResBuf[pThis->offResBuf];
-    pThis->offResBuf += cbReq;
-    return pb;
-}
-
-
-/**
- * Encodes an ACPI 16-bit integer in the given byte buffer.
- *
- * @returns Pointer to after the encoded integer.
- * @param   pb                  Where to encode the integer into.
- * @param   u16                 The 16-bit unsigned integere to encode.
- */
-DECLINLINE(uint8_t *) rtAcpiResEncode16BitInteger(uint8_t *pb, uint16_t u16)
-{
-    *pb++ = (uint8_t)u16;
-    *pb++ = (uint8_t)(u16 >>  8);
-    return pb;
-}
-
-
-/**
- * Encodes an ACPI 32-bit integer in the given byte buffer.
- *
- * @returns Pointer to after the encoded integer.
- * @param   pb                  Where to encode the integer into.
- * @param   u32                 The 32-bit unsigned integere to encode.
- */
-DECLINLINE(uint8_t *) rtAcpiResEncode32BitInteger(uint8_t *pb, uint32_t u32)
-{
-    *pb++ = (uint8_t)u32;
-    *pb++ = (uint8_t)(u32 >>  8);
-    *pb++ = (uint8_t)(u32 >> 16);
-    *pb++ = (uint8_t)(u32 >> 24);
-    return pb;
-}
-
-/**
- * Encodes an ACPI 64-bit integer in the given byte buffer.
- *
- * @returns Pointer to after the encoded integer.
- * @param   pb                  Where to encode the integer into.
- * @param   u64                 The 64-bit unsigned integere to encode.
- */
-
-DECLINLINE(uint8_t *) rtAcpiResEncode64BitInteger(uint8_t *pb, uint64_t u64)
-{
-    *pb++ = (uint8_t)u64;
-    *pb++ = (uint8_t)(u64 >>  8);
-    *pb++ = (uint8_t)(u64 >> 16);
-    *pb++ = (uint8_t)(u64 >> 24);
-    *pb++ = (uint8_t)(u64 >> 32);
-    *pb++ = (uint8_t)(u64 >> 40);
-    *pb++ = (uint8_t)(u64 >> 48);
-    *pb++ = (uint8_t)(u64 >> 56);
-    return pb;
-}
-
-
-RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes)
-{
-    AssertPtrReturn(phAcpiRes, VERR_INVALID_POINTER);
-
-    PRTACPIRESINT pThis = (PRTACPIRESINT)RTMemAllocZ(sizeof(*pThis));
-    if (pThis)
-    {
-        pThis->pbResBuf = (uint8_t *)RTMemAlloc(64);
-        if (pThis->pbResBuf)
-        {
-            pThis->offResBuf = 0;
-            pThis->cbResBuf  = 64;
-            pThis->fSealed   = false;
-            pThis->rcErr     = VINF_SUCCESS;
-
-            *phAcpiRes = pThis;
-            return VINF_SUCCESS;
-        }
-
-        RTMemFree(pThis);
-    }
-
-    return VERR_NO_MEMORY;
-}
-
-
-RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturnVoid(pThis);
-
-    RTMemFree(pThis->pbResBuf);
-    pThis->pbResBuf        = NULL;
-    pThis->cbResBuf        = 0;
-    pThis->offResBuf       = 0;
-    RTMemFree(pThis);
-}
-
-
-RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturnVoid(pThis);
-
-    pThis->offResBuf = 0;
-    pThis->fSealed   = false;
-    pThis->rcErr     = VINF_SUCCESS;
-}
-
-
-RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    /* Add the end tag. */
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 2);
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    *pb++ = ACPI_RSRCS_TAG_END;
-    /*
-     * Generate checksum, we could just write 0 here which will be treated as checksum operation succeeded,
-     * but having this might catch some bugs.
-     *
-     * Checksum algorithm is the same as with the ACPI tables.
-     */
-    *pb = RTAcpiChecksumGenerate(pThis->pbResBuf, pThis->offResBuf - 1); /* Exclude the checksum field. */
-
-    pThis->fSealed = true;
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    *ppvRes = pThis->pbResBuf;
-    *pcbRes = pThis->offResBuf;
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
-                                                   bool fRw)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 12);
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_32BIT_FIXED_MEMORY_RANGE; /* Tag          */
-    pb[1] = 9;                                                                /* Length[7:0]  */
-    pb[2] = 0;                                                                /* Length[15:8] */
-    pb[3] = fRw ? 1 : 0;                                                      /* Information  */
-    rtAcpiResEncode32BitInteger(&pb[4], u32AddrBase);
-    rtAcpiResEncode32BitInteger(&pb[8], cbRange);
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
-                                               bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 2 + cIntrs * sizeof(uint32_t));
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_EXTENDED_INTERRUPT;       /* Tag          */
-    rtAcpiResEncode16BitInteger(&pb[1], 2 + cIntrs * sizeof(uint32_t));       /* Length[15:0] */
-    pb[3] =   (fConsumer      ? ACPI_RSRCS_EXT_INTR_VEC_F_CONSUMER       : ACPI_RSRCS_EXT_INTR_VEC_F_PRODUCER)
-            | (fEdgeTriggered ? ACPI_RSRCS_EXT_INTR_VEC_F_EDGE_TRIGGERED : ACPI_RSRCS_EXT_INTR_VEC_F_LEVEL_TRIGGERED)
-            | (fActiveLow     ? ACPI_RSRCS_EXT_INTR_VEC_F_ACTIVE_LOW     : ACPI_RSRCS_EXT_INTR_VEC_F_ACTIVE_HIGH)
-            | (fShared        ? ACPI_RSRCS_EXT_INTR_VEC_F_SHARED         : ACPI_RSRCS_EXT_INTR_VEC_F_EXCLUSIVE)
-            | (fWakeCapable   ? ACPI_RSRCS_EXT_INTR_VEC_F_WAKE_CAP       : ACPI_RSRCS_EXT_INTR_VEC_F_NOT_WAKE_CAP);
-    pb[4] = cIntrs;
-    pb = &pb[5];
-    for (uint32_t i = 0; i < cIntrs; i++)
-        pb = rtAcpiResEncode32BitInteger(pb, pau32Intrs[i]);
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Common worker for encoding a new quad word (64-bit) address range.
- *
- * @returns IPRT status code
- * @retval  VERR_NO_MEMORY if not enough memory could be reserved in the ACPI resource descriptor.
- * @param   pThis               The ACPI resource instance.
- * @param   bType               The ACPI address range type.
- * @param   fAddrSpace          Combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX.
- * @param   fType               The range flags returned from rtAcpiResourceMemoryRangeToTypeFlags().
- * @param   u64AddrMin          The start address of the memory range.
- * @param   u64AddrMax          Last valid address of the range.
- * @param   u64OffTrans         Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
- * @param   u64Granularity      The access granularity of the range in bytes.
- * @param   u64Length           Length of the memory range in bytes.
- */
-static int rtAcpiResourceAddQWordAddressRange(PRTACPIRESINT pThis, uint8_t bType, uint32_t fAddrSpace, uint8_t fType,
-                                              uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
-                                              uint64_t u64Granularity, uint64_t u64Length)
-{
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 43);
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_QWORD_ADDR_SPACE;         /* Tag          */
-    pb[1] = 43;                                                               /* Length[7:0]  */
-    pb[2] = 0;                                                                /* Length[15:8] */
-    pb[3] = bType;
-    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
-    pb[5] = fType;
-
-    pb = rtAcpiResEncode64BitInteger(&pb[6], u64Granularity);
-    pb = rtAcpiResEncode64BitInteger(pb,     u64AddrMin);
-    pb = rtAcpiResEncode64BitInteger(pb,     u64AddrMax);
-    pb = rtAcpiResEncode64BitInteger(pb,     u64OffTrans);
-         rtAcpiResEncode64BitInteger(pb,     u64Length);
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Common worker for encoding a new double word (32-bit) address range.
- *
- * @returns IPRT status code
- * @retval  VERR_NO_MEMORY if not enough memory could be reserved in the ACPI resource descriptor.
- * @param   pThis               The ACPI resource instance.
- * @param   bType               The ACPI address range type.
- * @param   fAddrSpace          Combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX.
- * @param   fType               The range flags returned from rtAcpiResourceMemoryRangeToTypeFlags().
- * @param   u32AddrMin          The start address of the memory range.
- * @param   u32AddrMax          Last valid address of the range.
- * @param   u32OffTrans         Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
- * @param   u32Granularity      The access granularity of the range in bytes.
- * @param   u32Length           Length of the memory range in bytes.
- */
-static int rtAcpiResourceAddDWordAddressRange(PRTACPIRESINT pThis, uint8_t bType, uint32_t fAddrSpace, uint8_t fType,
-                                              uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
-                                              uint32_t u32Granularity, uint32_t u32Length)
-{
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 23);
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_DWORD_ADDR_SPACE;         /* Tag          */
-    pb[1] = 23;                                                               /* Length[7:0]  */
-    pb[2] = 0;                                                                /* Length[15:8] */
-    pb[3] = bType;
-    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
-    pb[5] = fType;
-
-    pb = rtAcpiResEncode32BitInteger(&pb[6], u32Granularity);
-    pb = rtAcpiResEncode32BitInteger(pb,     u32AddrMin);
-    pb = rtAcpiResEncode32BitInteger(pb,     u32AddrMax);
-    pb = rtAcpiResEncode32BitInteger(pb,     u32OffTrans);
-         rtAcpiResEncode32BitInteger(pb,     u32Length);
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Converts the given cacheability, range type and R/W flag to the ACPI resource flags.
- *
- * @returns Converted ACPI resource flags.
- * @param   enmCacheability     The cacheability enum to convert.
- * @param   enmType             THe memory range type enum to convert.
- * @param   fRw                 The read/write flag.
- */
-DECLINLINE(uint8_t) rtAcpiResourceMemoryRangeToTypeFlags(RTACPIRESMEMRANGECACHEABILITY enmCacheability, RTACPIRESMEMRANGETYPE enmType,
-                                                         bool fRw)
-{
-    uint8_t fType = fRw ? ACPI_RSRCS_ADDR_SPACE_MEM_F_RW : ACPI_RSRCS_ADDR_SPACE_MEM_F_RO;
-
-    switch (enmCacheability)
-    {
-        case kAcpiResMemRangeCacheability_NonCacheable:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_NON_CACHEABLE;
-            break;
-        case kAcpiResMemRangeCacheability_Cacheable:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE;
-            break;
-        case kAcpiResMemRangeCacheability_CacheableWriteCombining:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE_WR_COMB;
-            break;
-        case kAcpiResMemRangeCacheability_CacheablePrefetchable:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_CACHE_CACHEABLE_PREFETCHABLE;
-            break;
-        case kAcpiResMemRangeCacheability_Invalid:
-        default:
-            AssertFailedReturn(0);
-    }
-
-    switch (enmType)
-    {
-        case kAcpiResMemType_Memory:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_MEMORY;
-            break;
-        case kAcpiResMemType_Reserved:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_RESERVED;
-            break;
-        case kAcpiResMemType_Acpi:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_ACPI;
-            break;
-        case kAcpiResMemType_Nvs:
-            fType |= ACPI_RSRCS_ADDR_SPACE_MEM_F_ATTR_NVS;
-            break;
-        case kAcpiResMemType_Invalid:
-        default:
-            AssertFailedReturn(0);
-    }
-
-    return fType;
-}
-
-
-RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
-                                              RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
-                                              uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
-                                              uint64_t u64Granularity, uint64_t u64Length)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(enmCacheability != kAcpiResMemRangeCacheability_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(enmType != kAcpiResMemType_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t fType = rtAcpiResourceMemoryRangeToTypeFlags(enmCacheability, enmType, fRw);
-    return rtAcpiResourceAddQWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_MEMORY, fAddrSpace, fType,
-                                              u64AddrMin, u64AddrMax, u64OffTrans, u64Granularity, u64Length);
-}
-
-
-RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
-                                              RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
-                                              uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
-                                              uint32_t u32Granularity, uint32_t u32Length)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(enmCacheability != kAcpiResMemRangeCacheability_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(enmType != kAcpiResMemType_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t fType = rtAcpiResourceMemoryRangeToTypeFlags(enmCacheability, enmType, fRw);
-    return rtAcpiResourceAddDWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_MEMORY, fAddrSpace, fType,
-                                              u32AddrMin, u32AddrMax, u32OffTrans, u32Granularity, u32Length);
-}
-
-
-RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
-                                          uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
-                                          uint64_t u64Granularity, uint64_t u64Length)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(enmIoType != kAcpiResIoRangeType_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(enmIoRange != kAcpiResIoRange_Invalid, VERR_INVALID_PARAMETER);
-    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t fType = 0;
-    switch (enmIoType)
-    {
-        case kAcpiResIoRangeType_Static:
-            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_STATIC;
-            break;
-        case kAcpiResIoRangeType_Translation_Sparse:
-            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_TRANSLATION | ACPI_RSRCS_ADDR_SPACE_IO_F_TRANSLATION_SPARSE;
-            break;
-        case kAcpiResIoRangeType_Translation_Dense:
-            fType = ACPI_RSRCS_ADDR_SPACE_IO_F_TYPE_TRANSLATION | ACPI_RSRCS_ADDR_SPACE_IO_F_TRANSLATION_DENSE;
-            break;
-        case kAcpiResIoRangeType_Invalid:
-        default:
-            AssertFailedReturn(VERR_INVALID_PARAMETER);
-    }
-
-    switch (enmIoRange)
-    {
-        case kAcpiResIoRange_NonIsaOnly:
-            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_NON_ISA_ONLY;
-            break;
-        case kAcpiResIoRange_IsaOnly:
-            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_ISA_ONLY;
-            break;
-        case kAcpiResIoRange_Whole:
-            fType |= ACPI_RSRCS_ADDR_SPACE_IO_F_RANGE_WHOLE;
-            break;
-        case kAcpiResIoRange_Invalid:
-        default:
-            AssertFailedReturn(VERR_INVALID_PARAMETER);
-    }
-
-    return rtAcpiResourceAddQWordAddressRange(pThis, ACPI_RSRCS_ADDR_SPACE_TYPE_IO, fAddrSpace, fType,
-                                              u64AddrMin, u64AddrMax, u64OffTrans, u64Granularity, u64Length);
-}
-
-
-RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
-                                           uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length)
-{
-    PRTACPIRESINT pThis = hAcpiRes;
-    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(!(fAddrSpace & ~RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK), VERR_INVALID_PARAMETER);
-    AssertReturn(!pThis->fSealed, VERR_INVALID_STATE);
-    AssertRCReturn(pThis->rcErr, pThis->rcErr);
-
-    uint8_t *pb = rtAcpiResBufEnsureSpace(pThis, 3 + 13);
-    if (!pb)
-        return VERR_NO_MEMORY;
-
-    pb[0] = ACPI_RSRCS_LARGE_TYPE | ACPI_RSRCS_ITEM_WORD_ADDR_SPACE;          /* Tag          */
-    pb[1] = 13;                                                               /* Length[7:0]  */
-    pb[2] = 0;                                                                /* Length[15:8] */
-    pb[3] = ACPI_RSRCS_ADDR_SPACE_TYPE_BUS_NUM_RANGE;
-    pb[4] =   (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB ? ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_SUB : ACPI_RSRCS_ADDR_SPACE_F_DECODE_TYPE_POS)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MIN_ADDR_CHANGEABLE)
-            | (fAddrSpace & RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED  ? ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_FIXED  : ACPI_RSRCS_ADDR_SPACE_F_MAX_ADDR_CHANGEABLE);
-    pb[5] = 0;
-
-    pb = rtAcpiResEncode16BitInteger(&pb[6], u16Granularity);
-    pb = rtAcpiResEncode16BitInteger(pb,     u16BusMin);
-    pb = rtAcpiResEncode16BitInteger(pb,     u16BusMax);
-    pb = rtAcpiResEncode16BitInteger(pb,     u16OffTrans);
-         rtAcpiResEncode16BitInteger(pb,     u16Length);
-    return VINF_SUCCESS;
-
-}
Index: trunk/src/VBox/Runtime/include/internal/acpi.h
===================================================================
--- trunk/src/VBox/Runtime/include/internal/acpi.h	(revision 108015)
+++ trunk/src/VBox/Runtime/include/internal/acpi.h	(revision 108015)
@@ -0,0 +1,72 @@
+/* $Id$ */
+/** @file
+ * IPRT - Internal RTAcpi header.
+ */
+
+/*
+ * Copyright (C) 2025 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from https://www.virtualbox.org.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, in version 3 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses>.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
+ * in the VirtualBox distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
+ */
+
+#ifndef IPRT_INCLUDED_INTERNAL_acpi_h
+#define IPRT_INCLUDED_INTERNAL_acpi_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/acpi.h>
+
+RT_C_DECLS_BEGIN
+
+/**
+ * Worker for decompiling AML bytecode to the ASL source language.
+ *
+ * @returns IPRT status code.
+ * @param   hVfsIosOut          The VFS I/O stream handle to output the result to.
+ * @param   hVfsIosIn           The VFS I/O stream handle to read the ACPI table from.
+ * @param   pErrInfo            Where to return additional error information.
+ */
+DECLHIDDEN(int) rtAcpiTblConvertFromAmlToAsl(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
+
+
+/**
+ * Worker for decompiling ASL bytecode to the AML source language.
+ *
+ * @returns IPRT status code.
+ * @param   hVfsIosOut          The VFS I/O stream handle to output the result to.
+ * @param   hVfsIosIn           The VFS I/O stream handle to read the ACPI table from.
+ * @param   pErrInfo            Where to return additional error information.
+ */
+DECLHIDDEN(int) rtAcpiTblConvertFromAslToAml(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
+
+
+RT_C_DECLS_END
+
+#endif /* !IPRT_INCLUDED_INTERNAL_acpi_h */
+
