VirtualBox

Changeset 108150 in vbox


Ignore:
Timestamp:
Feb 11, 2025 9:45:04 AM (10 days ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167461
Message:

Runtime/RTAcpi*: Start implementing some basic namespace handling for the compiler, bugref:10733

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/acpi.h

    r108141 r108150  
    903903
    904904/**
     905 * Returns the offset where the next resource added to the template would be.
     906 *
     907 * @returns Offset into the resource buffer where the next resource will be appended
     908 * @retval  UINT32_MAX if the handle is invalid or the resource is in an error state.
     909 * @param   hAcpiRes            The ACPI resource handle.
     910 */
     911RTDECL(uint32_t) RTAcpiResourceGetOffset(RTACPIRES hAcpiRes);
     912
     913
     914/**
    905915 * Seals the given ACPI resource against further changes and adds any
    906916 * missing data required to complete the resource buffer.
  • trunk/include/iprt/mangling.h

    r108141 r108150  
    385385# define RTAcpiResourceCreate                           RT_MANGLER(RTAcpiResourceCreate)
    386386# define RTAcpiResourceDestroy                          RT_MANGLER(RTAcpiResourceDestroy)
     387# define RTAcpiResourceGetOffset                        RT_MANGLER(RTAcpiResourceGetOffset)
    387388# define RTAcpiResourceQueryBuffer                      RT_MANGLER(RTAcpiResourceQueryBuffer)
    388389# define RTAcpiResourceReset                            RT_MANGLER(RTAcpiResourceReset)
  • trunk/src/VBox/Runtime/Makefile.kmk

    r108029 r108150  
    399399        common/acpi/acpi-compiler.cpp \
    400400        common/acpi/acpi-decompiler.cpp \
     401        common/acpi/acpi-ns.cpp \
    401402        common/alloc/alloc.cpp \
    402403        common/alloc/heapsimple.cpp \
  • trunk/src/VBox/Runtime/common/acpi/acpi-compiler.cpp

    r108114 r108150  
    155155    /** List of AST nodes for the DefinitionBlock() scope. */
    156156    RTLISTANCHOR            LstStmts;
     157    /** The ACPI namespace. */
     158    PRTACPINSROOT           pNs;
    157159} RTACPIASLCU;
    158160/** Pointer to an ACPI ASL compilation unit state. */
     
    907909
    908910    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
     911
     912    int rc = rtAcpiNsAddEntryAstNode(pThis->pNs, pAstNd->aArgs[0].u.pszNameString, pAstNd, true /*fSwitchTo*/);
     913    if (RT_FAILURE(rc))
     914        return RTErrInfoSetF(pThis->pErrInfo, rc, "Failed to add External(%s,,,) to namespace", pAstNd->aArgs[0].u.pszNameString);
     915
    909916    return VINF_SUCCESS;
    910917}
     
    10031010
    10041011    RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
     1012
     1013    int rc = rtAcpiNsAddEntryAstNode(pThis->pNs, pAstNd->aArgs[0].u.pszNameString, pAstNd, true /*fSwitchTo*/);
     1014    if (RT_FAILURE(rc))
     1015        return RTErrInfoSetF(pThis->pErrInfo, rc, "Failed to add Method(%s,,,) to namespace", pAstNd->aArgs[0].u.pszNameString);
     1016
    10051017    return VINF_SUCCESS;
    10061018}
     
    14491461    /* kAcpiAstNodeOp_StringLiteral     */  RTACPI_ASL_KEYWORD_DEFINE_INVALID,
    14501462    /* kAcpiAstNodeOp_Number            */  RTACPI_ASL_KEYWORD_DEFINE_INVALID,
    1451     /* kAcpiAstNodeOp_Scope             */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Scope",            RTACPI_AST_NODE_F_NEW_SCOPE, kAcpiAstArgType_NameString),
     1463    /* kAcpiAstNodeOp_Scope             */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Scope",            RTACPI_AST_NODE_F_NEW_SCOPE | RTACPI_AST_NODE_F_NS_ENTRY,  kAcpiAstArgType_NameString),
    14521464    /* kAcpiAstNodeOp_Processor         */  {
    1453                                                 "Processor", NULL, 2, 2, RTACPI_AST_NODE_F_NEW_SCOPE,
     1465                                                "Processor", NULL, 2, 2, RTACPI_AST_NODE_F_NEW_SCOPE | RTACPI_AST_NODE_F_NS_ENTRY,
    14541466                                                {
    14551467                                                    kAcpiAstArgType_NameString,
     
    14671479    /* kAcpiAstNodeOp_External          */  RTACPI_ASL_KEYWORD_DEFINE_HANDLER(  "External",         rtAcpiTblAslParseExternal, 1, 2, RTACPI_AST_NODE_F_DEFAULT),
    14681480    /* kAcpiAstNodeOp_Method            */  RTACPI_ASL_KEYWORD_DEFINE_HANDLER(  "Method",           rtAcpiTblAslParseMethod,   1, 3, RTACPI_AST_NODE_F_NEW_SCOPE),
    1469     /* kAcpiAstNodeOp_Device            */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Device",           RTACPI_AST_NODE_F_NEW_SCOPE, kAcpiAstArgType_NameString),
    1470     /* kAcpiAstNodeOp_If                */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("If",               RTACPI_AST_NODE_F_NEW_SCOPE, kAcpiAstArgType_AstNode),
     1481    /* kAcpiAstNodeOp_Device            */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Device",           RTACPI_AST_NODE_F_NEW_SCOPE | RTACPI_AST_NODE_F_NS_ENTRY,  kAcpiAstArgType_NameString),
     1482    /* kAcpiAstNodeOp_If                */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("If",               RTACPI_AST_NODE_F_NEW_SCOPE,                                kAcpiAstArgType_AstNode),
    14711483    /* kAcpiAstNodeOp_Else              */  RTACPI_ASL_KEYWORD_DEFINE_0REQ_0OPT("Else",             RTACPI_AST_NODE_F_NEW_SCOPE),
    1472     /* kAcpiAstNodeOp_LAnd              */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LAnd",             RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1473     /* kAcpiAstNodeOp_LEqual            */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LEqual",           RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1474     /* kAcpiAstNodeOp_LGreater          */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LGreater",         RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1475     /* kAcpiAstNodeOp_LGreaterEqual     */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LGreaterEqual",    RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1476     /* kAcpiAstNodeOp_LLess             */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LLess",            RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1477     /* kAcpiAstNodeOp_LLessEqual        */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LLessEqual",       RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    1478     /* kAcpiAstNodeOp_LNot              */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("LNot",             RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode),
    1479     /* kAcpiAstNodeOp_LNotEqual         */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LNotEqual",        RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1484    /* kAcpiAstNodeOp_LAnd              */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LAnd",             RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1485    /* kAcpiAstNodeOp_LEqual            */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LEqual",           RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1486    /* kAcpiAstNodeOp_LGreater          */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LGreater",         RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1487    /* kAcpiAstNodeOp_LGreaterEqual     */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LGreaterEqual",    RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1488    /* kAcpiAstNodeOp_LLess             */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LLess",            RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1489    /* kAcpiAstNodeOp_LLessEqual        */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LLessEqual",       RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1490    /* kAcpiAstNodeOp_LNot              */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("LNot",             RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode),
     1491    /* kAcpiAstNodeOp_LNotEqual         */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("LNotEqual",        RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    14801492    /* kAcpiAstNodeOp_Zero              */  RTACPI_ASL_KEYWORD_DEFINE_0REQ_0OPT("Zero",             RTACPI_AST_NODE_F_DEFAULT),
    14811493    /* kAcpiAstNodeOp_One               */  RTACPI_ASL_KEYWORD_DEFINE_0REQ_0OPT("One",              RTACPI_AST_NODE_F_DEFAULT),
    14821494    /* kAcpiAstNodeOp_Ones              */  RTACPI_ASL_KEYWORD_DEFINE_0REQ_0OPT("Ones",             RTACPI_AST_NODE_F_DEFAULT),
    14831495    /* kAcpiAstNodeOp_Return            */  RTACPI_ASL_KEYWORD_DEFINE_HANDLER(  "Return",           rtAcpiTblAslParseReturn,  0, 1, RTACPI_AST_NODE_F_DEFAULT),
    1484     /* kAcpiAstNodeOp_Unicode           */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Unicode",          RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_AstNode), /* Actually only String allowed here */
    1485     /* kAcpiAstNodeOp_OperationRegion   */  RTACPI_ASL_KEYWORD_DEFINE_4REQ_0OPT("OperationRegion",  RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_NameString, kAcpiAstArgType_RegionSpace, kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
     1496    /* kAcpiAstNodeOp_Unicode           */  RTACPI_ASL_KEYWORD_DEFINE_1REQ_0OPT("Unicode",          RTACPI_AST_NODE_F_DEFAULT,                                  kAcpiAstArgType_AstNode), /* Actually only String allowed here */
     1497    /* kAcpiAstNodeOp_OperationRegion   */  RTACPI_ASL_KEYWORD_DEFINE_4REQ_0OPT("OperationRegion",  RTACPI_AST_NODE_F_DEFAULT | RTACPI_AST_NODE_F_NS_ENTRY,     kAcpiAstArgType_NameString, kAcpiAstArgType_RegionSpace, kAcpiAstArgType_AstNode, kAcpiAstArgType_AstNode),
    14861498    /* kAcpiAstNodeOp_Field             */  RTACPI_ASL_KEYWORD_DEFINE_HANDLER(  "Field",            rtAcpiTblAslParseFieldOrIndexField, 4, 0, RTACPI_AST_NODE_F_DEFAULT),
    1487     /* kAcpiAstNodeOp_Name              */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("Name",             RTACPI_AST_NODE_F_DEFAULT,   kAcpiAstArgType_NameString, kAcpiAstArgType_AstNode),
     1499    /* kAcpiAstNodeOp_Name              */  RTACPI_ASL_KEYWORD_DEFINE_2REQ_0OPT("Name",             RTACPI_AST_NODE_F_NS_ENTRY,                                 kAcpiAstArgType_NameString, kAcpiAstArgType_AstNode),
    14881500    /* kAcpiAstNodeOp_ResourceTemplate  */  RTACPI_ASL_KEYWORD_DEFINE_HANDLER(  "ResourceTemplate", rtAcpiTblAslParseResourceTemplate,  0, 0, RTACPI_AST_NODE_F_DEFAULT),
    14891501    /* kAcpiAstNodeOp_Arg0              */  RTACPI_ASL_KEYWORD_DEFINE_0REQ_0OPT("Arg0",             RTACPI_AST_NODE_F_DEFAULT),
     
    17141726        /* Now there must be a closing ) */
    17151727        RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_BRACKET, ')');
     1728
     1729        if (pAslKeyword->fFlags & RTACPI_AST_NODE_F_NS_ENTRY)
     1730        {
     1731            /*
     1732             * Create a new namespace entry, we currently assume that the first argument is a namestring
     1733             * which gives the path.
     1734             */
     1735            AssertReturn(pAstNd->aArgs[0].enmType == kAcpiAstArgType_NameString, VERR_NOT_SUPPORTED);
     1736
     1737            bool fSwitchTo = RT_BOOL(pAslKeyword->fFlags & RTACPI_AST_NODE_F_NEW_SCOPE);
     1738            rc = rtAcpiNsAddEntryAstNode(pThis->pNs, pAstNd->aArgs[0].u.pszNameString, pAstNd, fSwitchTo);
     1739            if (RT_FAILURE(rc))
     1740                return rc;
     1741        }
    17161742    }
    17171743
     
    17231749        if (RT_SUCCESS(rc))
    17241750            RTACPIASL_PARSE_PUNCTUATOR(RTACPIASLTERMINAL_PUNCTUATOR_CLOSE_CURLY_BRACKET, '}');
     1751
     1752        if (pAslKeyword->fFlags & RTACPI_AST_NODE_F_NS_ENTRY)
     1753            rtAcpiNsPop(pThis->pNs);
    17251754    }
    17261755
     
    19501979        RTListInit(&pThis->LstStmts);
    19511980
    1952         rc = RTScriptLexCreateFromReader(&pThis->hLexSource, rtAcpiAslLexerRead,
    1953                                          NULL /*pfnDtor*/, pThis /*pvUser*/, 0 /*cchBuf*/,
    1954                                          NULL /*phStrCacheId*/, NULL /*phStrCacheStringLit*/,
    1955                                          &s_AslLexCfg);
    1956         if (RT_SUCCESS(rc))
    1957         {
    1958             rc = rtAcpiTblAslParserParse(pThis);
     1981        pThis->pNs = rtAcpiNsCreate();
     1982        if (pThis->pNs)
     1983        {
     1984            rc = RTScriptLexCreateFromReader(&pThis->hLexSource, rtAcpiAslLexerRead,
     1985                                             NULL /*pfnDtor*/, pThis /*pvUser*/, 0 /*cchBuf*/,
     1986                                             NULL /*phStrCacheId*/, NULL /*phStrCacheStringLit*/,
     1987                                             &s_AslLexCfg);
    19591988            if (RT_SUCCESS(rc))
    19601989            {
    1961                 /* 2. - Optimize AST (constant folding, etc). */
    1962 
    1963                 /* 3. - Traverse AST and output table. */
    1964                 PRTACPIASTNODE pIt;
    1965                 RTListForEach(&pThis->LstStmts, pIt, RTACPIASTNODE, NdAst)
    1966                 {
    1967                     rc = rtAcpiAstNodeTransform(pIt, pErrInfo);
    1968                     if (RT_FAILURE(rc))
    1969                         break;
    1970 
    1971                     rc = rtAcpiAstDumpToTbl(pIt, pThis->hAcpiTbl);
    1972                     if (RT_FAILURE(rc))
    1973                         break;
    1974                 }
    1975 
    1976                 /* Finalize and write to the VFS I/O stream. */
     1990                rc = rtAcpiTblAslParserParse(pThis);
    19771991                if (RT_SUCCESS(rc))
    19781992                {
    1979                     rc = RTAcpiTblFinalize(pThis->hAcpiTbl);
     1993                    /* 2. - Optimize AST (constant folding, etc). */
     1994
     1995                    /* 3. - Traverse AST and output table. */
     1996                    PRTACPIASTNODE pIt;
     1997                    RTListForEach(&pThis->LstStmts, pIt, RTACPIASTNODE, NdAst)
     1998                    {
     1999                        rc = rtAcpiAstNodeTransform(pIt, pErrInfo);
     2000                        if (RT_FAILURE(rc))
     2001                            break;
     2002
     2003                        rc = rtAcpiAstDumpToTbl(pIt, pThis->hAcpiTbl);
     2004                        if (RT_FAILURE(rc))
     2005                            break;
     2006                    }
     2007
     2008                    /* Finalize and write to the VFS I/O stream. */
    19802009                    if (RT_SUCCESS(rc))
    19812010                    {
    1982                         rc = RTAcpiTblDumpToVfsIoStrm(pThis->hAcpiTbl, RTACPITBLTYPE_AML, hVfsIosOut);
    1983                         if (RT_FAILURE(rc))
    1984                             rc = RTErrInfoSetF(pErrInfo, rc, "Writing the ACPI table failed with %Rrc", rc);
     2011                        rc = RTAcpiTblFinalize(pThis->hAcpiTbl);
     2012                        if (RT_SUCCESS(rc))
     2013                        {
     2014                            rc = RTAcpiTblDumpToVfsIoStrm(pThis->hAcpiTbl, RTACPITBLTYPE_AML, hVfsIosOut);
     2015                            if (RT_FAILURE(rc))
     2016                                rc = RTErrInfoSetF(pErrInfo, rc, "Writing the ACPI table failed with %Rrc", rc);
     2017                        }
     2018                        else
     2019                            rc = RTErrInfoSetF(pErrInfo, rc, "Finalizing the ACPI table failed with %Rrc", rc);
    19852020                    }
    19862021                    else
    1987                         rc = RTErrInfoSetF(pErrInfo, rc, "Finalizing the ACPI table failed with %Rrc", rc);
     2022                        rc = RTErrInfoSetF(pErrInfo, rc, "Dumping AST to ACPI table failed with %Rrc", rc);
    19882023                }
    1989                 else
    1990                     rc = RTErrInfoSetF(pErrInfo, rc, "Dumping AST to ACPI table failed with %Rrc", rc);
     2024
     2025                RTScriptLexDestroy(pThis->hLexSource);
    19912026            }
    1992 
    1993             RTScriptLexDestroy(pThis->hLexSource);
     2027            else
     2028                rc = RTErrInfoSetF(pErrInfo, rc, "Creating the ASL lexer failed with %Rrc", rc);
     2029
     2030            /* Destroy the AST nodes. */
     2031            PRTACPIASTNODE pIt, pItNext;
     2032            RTListForEachSafe(&pThis->LstStmts, pIt, pItNext, RTACPIASTNODE, NdAst)
     2033            {
     2034                RTListNodeRemove(&pIt->NdAst);
     2035                rtAcpiAstNodeFree(pIt);
     2036            }
     2037
     2038            rtAcpiNsDestroy(pThis->pNs);
    19942039        }
    19952040        else
    1996             rc = RTErrInfoSetF(pErrInfo, rc, "Creating the ASL lexer failed with %Rrc", rc);
    1997 
    1998         /* Destroy the AST nodes. */
    1999         PRTACPIASTNODE pIt, pItNext;
    2000         RTListForEachSafe(&pThis->LstStmts, pIt, pItNext, RTACPIASTNODE, NdAst)
    2001         {
    2002             RTListNodeRemove(&pIt->NdAst);
    2003             rtAcpiAstNodeFree(pIt);
    2004         }
     2041            rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Out of memory allocating the ACPI namespace state");
    20052042
    20062043        RTMemFree(pThis);
  • trunk/src/VBox/Runtime/common/acpi/acpi.cpp

    r108141 r108150  
    16161616
    16171617
     1618RTDECL(uint32_t) RTAcpiResourceGetOffset(RTACPIRES hAcpiRes)
     1619{
     1620    PRTACPIRESINT pThis = hAcpiRes;
     1621    AssertReturn(pThis, UINT32_MAX);
     1622    AssertRCReturn(pThis->rcErr, UINT32_MAX);
     1623
     1624    return pThis->offResBuf;
     1625}
     1626
     1627
    16181628RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes)
    16191629{
  • trunk/src/VBox/Runtime/include/internal/acpi.h

    r108095 r108150  
    220220/** The AST node opens a new scope. */
    221221#define RTACPI_AST_NODE_F_NEW_SCOPE     RT_BIT_32(0)
     222/** The AST node has an associated namespace entry. */
     223#define RTACPI_AST_NODE_F_NS_ENTRY      RT_BIT_32(1)
     224
     225
     226/** Pointer to an ACPI namespace entry. */
     227typedef struct RTACPINSENTRY *PRTACPINSENTRY;
     228
     229
     230/**
     231 * An ACPI namespace entry.
     232 */
     233typedef struct RTACPINSENTRY
     234{
     235    /** Node for the namespace list. */
     236    RTLISTNODE              NdNs;
     237    /** Pointer to the parent in the namespace, NULL if this is the root. */
     238    PRTACPINSENTRY          pParent;
     239    /** The name segment identifying the entry. */
     240    char                    achNameSeg[4];
     241    /** Flag whether the name space entry points to a node or just has some
     242     * integer data attached. */
     243    bool                    fAstNode;
     244    /** Type dependent data. */
     245    union
     246    {
     247        PCRTACPIASTNODE     pAstNd;
     248        uint64_t            u64Val;
     249    } u;
     250    /** List of namespace entries below this entry. */
     251    RTLISTANCHOR            LstNsEntries;
     252} RTACPINSENTRY;
     253/** Pointer to a const ACPI namespace entry. */
     254typedef const RTACPINSENTRY *PCRTACPINSENTRY;
     255
     256
     257/**
     258 * An ACPI namespace root
     259 */
     260typedef struct RTACPINSROOT
     261{
     262    /** Root namespace entry. */
     263    RTACPINSENTRY           RootEntry;
     264    /** Current top of the stack. */
     265    uint8_t                 idxNsStack;
     266    /** Stack of name space entries for navigation - 255 entries
     267     * is enough because a path name can only be encoded with 255 entries. */
     268    PRTACPINSENTRY          aNsStack[255];
     269} RTACPINSROOT;
     270/** Pointer to an ACPI namespace root. */
     271typedef RTACPINSROOT *PRTACPINSROOT;
     272/** Pointer to a const ACPI namespace root. */
     273typedef const RTACPINSROOT *PCRTACPINSROOT;
    222274
    223275
     
    255307
    256308/**
     309 * Creates a new namespace and returns the root.
     310 *
     311 * @returns Pointer to the namespace root or NULL if out of memory.
     312 */
     313DECLHIDDEN(PRTACPINSROOT) rtAcpiNsCreate(void);
     314
     315
     316/**
     317 * Destroys the given namespace, freeing all allocated resources,
     318 * including all namespace entries int it.
     319 *
     320 * @param   pNsRoot             The namespace root to destroy.
     321 */
     322DECLHIDDEN(void) rtAcpiNsDestroy(PRTACPINSROOT pNsRoot);
     323
     324
     325/**
     326 * Adds a new namespace entry to the given name space - AST node variant.
     327 *
     328 * @returns IPRT status code.
     329 * @param   pNsRoot             The namespace root to add the entry to.
     330 * @param   pszNameString       An ACPI NameString (either segment or path).
     331 * @param   pAstNd              The AST node to associate with the entry.
     332 * @param   fSwitchTo           Flag whether to switch the current point for the namespace to this entry.
     333 */
     334DECLHIDDEN(int) rtAcpiNsAddEntryAstNode(PRTACPINSROOT pNsRoot, const char *pszNameString, PCRTACPIASTNODE pAstNd, bool fSwitchTo);
     335
     336
     337/**
     338 * Adds a new namespace entry to the given name space - 64-bit value variant.
     339 *
     340 * @returns IPRT status code.
     341 * @param   pNsRoot             The namespace root to add the entry to.
     342 * @param   pszNameString       An ACPI NameString (either segment or path).
     343 * @param   u64Val              The 64-bit value to associate with the entry.
     344 * @param   fSwitchTo           Flag whether to switch the current point for the namespace to this entry.
     345 */
     346DECLHIDDEN(int) rtAcpiNsAddEntryU64(PRTACPINSROOT pNsRoot, const char *pszNameString, uint64_t u64Val, bool fSwitchTo);
     347
     348
     349/**
     350 * Pops the current name space entry from the stack and returns to the previous one.
     351 *
     352 * @returns IPRT status code.
     353 * @param   pNsRoot             The namespace root.
     354 */
     355DECLHIDDEN(int) rtAcpiNsPop(PRTACPINSROOT pNsRoot);
     356
     357
     358/**
     359 * Looks up the given name string and returns the namespace entry if found.
     360 *
     361 * @returns Pointer to the namespace entry or NULL if not found.
     362 * @param   pNsRoot             The namespace root.
     363 * @param   pszNameString       The ACPI NameString (either segment or path) to lookup.
     364 */
     365DECLHIDDEN(PCRTACPINSENTRY) rtAcpiNsLookup(PRTACPINSROOT pNsRoot, const char *pszNameString);
     366
     367
     368/**
    257369 * Dumps the given AST node and everything it references to the given ACPI table.
    258370 *
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette