VirtualBox

Changeset 107952 in vbox


Ignore:
Timestamp:
Jan 27, 2025 6:55:47 PM (4 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167199
Message:

Runtime: Start imlementing a basic ACPI decompiler and iasl compatible frontend, bugref:10733

Location:
trunk
Files:
2 added
7 edited

Legend:

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

    r107064 r107952  
    5656#ifdef IN_RING3
    5757
     58/**
     59 * ACPI table type.
     60 */
     61typedef enum RTACPITBLTYPE
     62{
     63    /** The invalid output type. */
     64    RTACPITBLTYPE_INVALID = 0,
     65    /** Type is an UTF-8 ASL source. */
     66    RTACPITBLTYPE_ASL,
     67    /** Type is the AML bytecode. */
     68    RTACPITBLTYPE_AML,
     69    /** Usual 32-bit hack. */
     70    RTACPITBLTYPE_32BIT_HACK = 0x7fffffff
     71} RTACPITBLTYPE;
     72
    5873
    5974/**
     
    7489 */
    7590RTDECL(void) RTAcpiTblHdrChecksumGenerate(PACPITBLHDR pTbl, size_t cbTbl);
     91
     92
     93/**
     94 * Creates an ACPI table from the given VFS file.
     95 *
     96 * @returns IPRT status code.
     97 * @param   phAcpiTbl           Where to store the ACPI table handle on success.
     98 * @param   hVfsIos             The VFS I/O stream handle to read the ACPI table from.
     99 * @param   enmInType           The input type of the ACPI table.
     100 * @param   pErrInfo            Where to return additional error information.
     101 */
     102RTDECL(int) RTAcpiTblCreateFromVfsIoStrm(PRTACPITBL phAcpiTbl, RTVFSIOSTREAM hVfsIos, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
     103
     104
     105/**
     106 * Converts a given ACPI table input stream to the given output type.
     107 *
     108 * @returns IPRT status code.
     109 * @param   hVfsIosOut          The VFS I/O stream handle to output the result to.
     110 * @param   enmOutType          The output type.
     111 * @param   hVfsIosIn           The VFS I/O stream handle to read the ACPI table from.
     112 * @param   enmInType           The input type of the ACPI table.
     113 * @param   pErrInfo            Where to return additional error information.
     114 */
     115RTDECL(int) RTAcpiTblConvertFromVfsIoStrm(RTVFSIOSTREAM hVfsIosOut, RTACPITBLTYPE enmOutType,
     116                                          RTVFSIOSTREAM hVfsIosIn, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
     117
     118
     119/**
     120 * Creates an ACPI table from the given filename.
     121 *
     122 * @returns IPRT status code.
     123 * @param   phAcpiTbl           Where to store the ACPI table handle on success.
     124 * @param   pszFilename         The filename to read the ACPI table from.
     125 * @param   enmInType           The input type of the ACPI table.
     126 * @param   pErrInfo            Where to return additional error information.
     127 */
     128RTDECL(int) RTAcpiTblCreateFromFile(PRTACPITBL phAcpiTbl, const char *pszFilename, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
    76129
    77130
     
    129182 * @returns IPRT status code.
    130183 * @param   hAcpiTbl            The ACPI table handle.
     184 * @param   enmOutType          The output type.
    131185 * @param   hVfsIos             The VFS I/O stream handle to dump the table to.
    132186 */
    133 RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTVFSIOSTREAM hVfsIos);
     187RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, RTVFSIOSTREAM hVfsIos);
    134188
    135189
     
    139193 * @returns IPRT status code.
    140194 * @param   hAcpiTbl            The ACPI table handle.
     195 * @param   enmOutType          The output type.
    141196 * @param   pszFilename         The file path to dump the table to.
    142197 */
    143 RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, const char *pszFilename);
     198RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, const char *pszFilename);
    144199
    145200
  • trunk/include/iprt/formats/acpi-aml.h

    r106070 r107952  
    5555/** @name AML Bytecode values (see https://uefi.org/specs/ACPI/6.5/20_AML_Specification.html#aml-byte-stream-byte-values).
    5656 * @{ */
     57/** Encoding Name: ZeroOp,              Encoding Group: Name Object */
     58#define ACPI_AML_BYTE_CODE_PREFIX_NULL_NAME      0x00
    5759/** Encoding Name: ZeroOp,              Encoding Group: Data Object */
    5860#define ACPI_AML_BYTE_CODE_OP_ZERO               0x00
     
    293295/** @} */
    294296
     297
     298/** @name Some helpers for classifying AML bytecode.
     299 * @{ */
     300DECLINLINE(bool) rtAcpiAmlOpcIsConstObj(uint8_t bOpc)
     301{
     302    return    bOpc == ACPI_AML_BYTE_CODE_OP_ZERO
     303           || bOpc == ACPI_AML_BYTE_CODE_OP_ONE
     304           || bOpc == ACPI_AML_BYTE_CODE_OP_ONES;
     305}
     306
     307
     308DECLINLINE(bool) rtAcpiAmlOpcIsComputationalData(uint8_t bOpc)
     309{
     310    /** @todo RevisionOp (requires two bytes) */
     311    return    rtAcpiAmlOpcIsConstObj(bOpc)
     312           || bOpc == ACPI_AML_BYTE_CODE_PREFIX_BYTE
     313           || bOpc == ACPI_AML_BYTE_CODE_PREFIX_WORD
     314           || bOpc == ACPI_AML_BYTE_CODE_PREFIX_DWORD
     315           || bOpc == ACPI_AML_BYTE_CODE_PREFIX_QWORD
     316           || bOpc == ACPI_AML_BYTE_CODE_PREFIX_STRING
     317           || bOpc == ACPI_AML_BYTE_CODE_OP_BUFFER;
     318}
     319
     320
     321DECLINLINE(bool) rtAcpiAmlOpcIsDataObject(uint8_t bOpc)
     322{
     323    return    rtAcpiAmlOpcIsComputationalData(bOpc)
     324           || bOpc == ACPI_AML_BYTE_CODE_OP_PACKAGE
     325           || bOpc == ACPI_AML_BYTE_CODE_OP_VAR_PACKAGE;
     326}
     327
     328
     329DECLINLINE(bool) rtAcpiAmlOpcIsDataRefObject(uint8_t bOpc)
     330{
     331    return rtAcpiAmlOpcIsDataObject(bOpc); /** @todo ObjectReference and DDBHandle. */
     332}
     333
     334
     335DECLINLINE(bool) rtAcpiAmlOpcIsArgObj(uint8_t bOpc)
     336{
     337    return    (bOpc >= ACPI_AML_BYTE_CODE_OP_ARG_0)
     338           && (bOpc <= ACPI_AML_BYTE_CODE_OP_ARG_6);
     339}
     340
     341
     342DECLINLINE(bool) rtAcpiAmlOpcIsLocalObj(uint8_t bOpc)
     343{
     344    return    (bOpc >= ACPI_AML_BYTE_CODE_OP_LOCAL_0)
     345           && (bOpc <= ACPI_AML_BYTE_CODE_OP_LOCAL_7);
     346}
     347
     348
     349DECLINLINE(bool) rtAcpiAmlOpcIsTermArg(uint8_t bOpc)
     350{
     351    /** @todo Type2Opcode */
     352    return    rtAcpiAmlOpcIsDataObject(bOpc)
     353           || rtAcpiAmlOpcIsArgObj(bOpc)
     354           || rtAcpiAmlOpcIsLocalObj(bOpc);
     355}
    295356/** @} */
    296357
     358/** @} */
     359
    297360#endif /* !IPRT_INCLUDED_formats_acpi_aml_h */
    298361
  • trunk/include/iprt/mangling.h

    r107192 r107952  
    391391# define RTAcpiTblBinaryOpAppend                        RT_MANGLER(RTAcpiTblBinaryOpAppend)
    392392# define RTAcpiTblBufferAppend                          RT_MANGLER(RTAcpiTblBufferAppend)
     393# define RTAcpiTblConvertFromVfsIoStrm                  RT_MANGLER(RTAcpiTblConvertFromVfsIoStrm)
    393394# define RTAcpiTblCreate                                RT_MANGLER(RTAcpiTblCreate)
     395# define RTAcpiTblCreateFromVfsIoStrm                   RT_MANGLER(RTAcpiTblCreateFromVfsIoStrm)
     396# define RTAcpiTblCreateFromFile                        RT_MANGLER(RTAcpiTblCreateFromFile)
    394397# define RTAcpiTblDestroy                               RT_MANGLER(RTAcpiTblDestroy)
    395398# define RTAcpiTblDeviceFinalize                        RT_MANGLER(RTAcpiTblDeviceFinalize)
  • trunk/src/VBox/Main/src-client/SystemTableBuilder.cpp

    r107770 r107952  
    170170
    171171    /* Write the DSDT. */
    172     vrc = RTAcpiTblDumpToVfsIoStrm(m_hAcpiDsdt, hVfsIos);
     172    vrc = RTAcpiTblDumpToVfsIoStrm(m_hAcpiDsdt, RTACPITBLTYPE_AML, hVfsIos);
    173173    AssertRCReturn(vrc, vrc);
    174174
     
    465465int SystemTableBuilderAcpi::dumpTables(const char *pszFilename)
    466466{
    467     return RTAcpiTblDumpToFile(m_hAcpiDsdt, pszFilename);
     467    return RTAcpiTblDumpToFile(m_hAcpiDsdt, RTACPITBLTYPE_AML, pszFilename);
    468468}
    469469
  • trunk/src/VBox/Runtime/Makefile.kmk

    r107192 r107952  
    599599        common/misc/RTSystemFirmwareTypeName.cpp \
    600600        common/misc/acpi.cpp \
     601        common/misc/acpi-decompiler.cpp \
    601602        common/misc/assert.cpp \
    602603        common/misc/buildconfig.cpp \
  • trunk/src/VBox/Runtime/common/misc/acpi.cpp

    r107951 r107952  
    605605
    606606
    607 RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTVFSIOSTREAM hVfsIos)
     607RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, RTVFSIOSTREAM hVfsIos)
    608608{
    609609    PRTACPITBLINT pThis = hAcpiTbl;
    610610    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    611611    AssertRCReturn(pThis->rcErr, 0);
     612    AssertReturn(enmOutType == RTACPITBLTYPE_AML, VERR_NOT_SUPPORTED);
    612613
    613614    return RTVfsIoStrmWrite(hVfsIos, pThis->pbTblBuf, pThis->paPkgStack[0].cbPkg,
     
    616617
    617618
    618 RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, const char *pszFilename)
     619RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, const char *pszFilename)
    619620{
    620621    RTVFSIOSTREAM hVfsIos = NIL_RTVFSIOSTREAM;
     
    624625        return rc;
    625626
    626     rc = RTAcpiTblDumpToVfsIoStrm(hAcpiTbl, hVfsIos);
     627    rc = RTAcpiTblDumpToVfsIoStrm(hAcpiTbl, enmOutType, hVfsIos);
    627628    RTVfsIoStrmRelease(hVfsIos);
    628629    return rc;
  • trunk/src/VBox/Runtime/tools/Makefile.kmk

    r106425 r107952  
    299299 RTDtc_SOURCES = RTDtc.cpp
    300300
     301 # RTIasl - ACPI source language compiler/decompiler.
     302 PROGRAMS += RTIasl
     303 RTIasl_TEMPLATE = VBoxR3Tool
     304 RTIasl_SOURCES = RTIasl.cpp
     305
    301306endif # !VBOX_ONLY_BUILD
    302307
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