VirtualBox

Ignore:
Timestamp:
Feb 13, 2025 6:24:31 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167535
Message:

Runtime/RTAcpi*: Treat External delcarations differently so that they can be properly dumped to the AML code. With this RTIasl is capable of producing AML code for vbox-tpm.dsl matching that generated by iasl, bugref:10733

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/acpi/acpi-ns.cpp

    r108184 r108215  
    231231    int rc = rtAcpiNsAddEntryWorker(pNsRoot, pszNameString, fSwitchTo, &pNsEntry);
    232232    if (RT_SUCCESS(rc))
     233    {
     234        pNsEntry->fAstNd = true;
    233235        pNsEntry->pAstNd = pAstNd;
     236    }
    234237
    235238    return rc;
     
    243246    if (RT_SUCCESS(rc))
    244247    {
     248        pNsEntry->fAstNd  = false;
    245249        pNsEntry->pAstNd  = NULL;
    246250        pNsEntry->offBits = offBits;
     
    252256
    253257
     258DECLHIDDEN(int) rtAcpiNsAddEntryExternal(PRTACPINSROOT pNsRoot, const char *pszNameString, PCRTACPIASLEXTERNAL pExternal)
     259{
     260    PRTACPINSENTRY pNsEntry = NULL;
     261    int rc = rtAcpiNsAddEntryWorker(pNsRoot, pszNameString, false /*fSwitchTo*/, &pNsEntry);
     262    if (RT_SUCCESS(rc))
     263    {
     264        pNsEntry->fAstNd    = false;
     265        pNsEntry->pExternal = pExternal;
     266    }
     267
     268    return rc;
     269}
     270
     271
     272DECLHIDDEN(int) rtAcpiNsQueryNamePathForNameString(PRTACPINSROOT pNsRoot, const char *pszNameString, char *pachNamePath, size_t *pcchNamePath)
     273{
     274    AssertReturn(!pachNamePath || *pcchNamePath >= 6, VERR_INVALID_PARAMETER); /* Needs to support at least \XXXX and the zero terminator. */
     275
     276    const char *pszNameSegLast = NULL;
     277    PCRTACPINSENTRY pNsEntry = rtAcpiNsLookupWorker(pNsRoot, pszNameString, true /*fExcludeLast*/, &pszNameSegLast);
     278    if (pNsEntry)
     279    {
     280        int rc = VERR_BUFFER_OVERFLOW;
     281        size_t cchNamePath = 1; /* For the root prefix. */
     282
     283        if (!pachNamePath)
     284        {
     285            /* Calculate the name path size based on the number of segments. */
     286            uint32_t cEntries = 0;
     287            do
     288            {
     289                cEntries++;
     290                pNsEntry = pNsEntry->pParent;
     291            } while (pNsEntry);
     292
     293            cchNamePath += cEntries * (4 + 1) - 1; /* XXXX., except for the last one. */
     294        }
     295        else
     296        {
     297            uint32_t idxEntry = 0;
     298            PCRTACPINSENTRY aNsEntries[255]; /* Maximum amount of name segments possible. */
     299            do
     300            {
     301                aNsEntries[idxEntry++] = pNsEntry;
     302                pNsEntry = pNsEntry->pParent;
     303            } while (pNsEntry);
     304
     305            char *pch = pachNamePath;
     306            *pch++ = '\\';
     307            *pch   = '\0';
     308
     309            /* The last entry must be the root entry. */
     310            idxEntry--;
     311            Assert(!aNsEntries[idxEntry]->pParent);
     312
     313            while (idxEntry)
     314            {
     315                pNsEntry = aNsEntries[--idxEntry];
     316                if (cchNamePath + 5 < *pcchNamePath)
     317                {
     318                    pch[0] = pNsEntry->achNameSeg[0];
     319                    pch[1] = pNsEntry->achNameSeg[1];
     320                    pch[2] = pNsEntry->achNameSeg[2];
     321                    pch[3] = pNsEntry->achNameSeg[3];
     322                    pch[4] = '.';
     323                    pch += 5;
     324                }
     325                cchNamePath += 5;
     326            }
     327
     328            /* Append the last name segment. */
     329            if (cchNamePath + 5 < *pcchNamePath)
     330            {
     331                pch[0] = pszNameSegLast[0];
     332                pch[1] = pszNameSegLast[1];
     333                pch[2] = pszNameSegLast[2];
     334                pch[3] = pszNameSegLast[3];
     335                pch[4] = '\0';
     336                cchNamePath += 4;
     337            }
     338
     339            if (cchNamePath <= *pcchNamePath)
     340                rc = VINF_SUCCESS;
     341        }
     342
     343        *pcchNamePath = cchNamePath;
     344        return rc;
     345    }
     346
     347    *pcchNamePath = 0;
     348    return VERR_NOT_FOUND;
     349}
     350
     351
    254352DECLHIDDEN(int) rtAcpiNsPop(PRTACPINSROOT pNsRoot)
    255353{
Note: See TracChangeset for help on using the changeset viewer.

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