VirtualBox

Changeset 107036 in vbox


Ignore:
Timestamp:
Nov 19, 2024 10:05:28 AM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165985
Message:

Runtime/RTAcpi*: Add new methods for adding if else statements, binary operands and referencing arguments, locals and appending UUIDs, bugref:10733

Location:
trunk
Files:
3 edited

Legend:

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

    r106344 r107036  
    333333 */
    334334RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt);
     335
     336
     337/**
     338 * Starts a new If statement operation.
     339 *
     340 * @returns IPRT status code.
     341 * @param   hAcpiTbl            The ACPI table handle.
     342 */
     343RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl);
     344
     345
     346/**
     347 * Finalizes the current If statement operation.
     348 *
     349 * @returns IPRT status code.
     350 * @param   hAcpiTbl            The ACPI table handle.
     351 */
     352RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl);
     353
     354
     355/**
     356 * Starts a new Else operation (only valid if currently inside an If oepration).
     357 *
     358 * @returns IPRT status code.
     359 * @param   hAcpiTbl            The ACPI table handle.
     360 */
     361RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl);
     362
     363
     364/**
     365 * Finalizes the current Else statement operation.
     366 *
     367 * @returns IPRT status code.
     368 * @param   hAcpiTbl            The ACPI table handle.
     369 */
     370RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl);
     371
     372
     373/**
     374 * List of binary operations.
     375 */
     376typedef enum RTACPIBINARYOP
     377{
     378    /** Invalid binary operation. */
     379    kAcpiBinaryOp_Invalid = 0,
     380    /** LAnd(Operand, Operand). */
     381    kAcpiBinaryOp_LAnd,
     382    /** LEqual(Operand, Operand). */
     383    kAcpiBinaryOp_LEqual,
     384    /** LGreater(Operand, Operand). */
     385    kAcpiBinaryOp_LGreater,
     386    /** LGreaterEqual(Operand, Operand). */
     387    kAcpiBinaryOp_LGreaterEqual,
     388    /** LLess(Operand, Operand). */
     389    kAcpiBinaryOp_LLess,
     390    /** LLessEqual(Operand, Operand). */
     391    kAcpiBinaryOp_LLessEqual,
     392    /** LNotEqual(Operand, Operand). */
     393    kAcpiBinaryOp_LNotEqual
     394} RTACPIBINARYOP;
     395
     396
     397/**
     398 * Appends the given binary operand.
     399 *
     400 * @returns IPRT status code.
     401 * @param   hAcpiTbl            The ACPI table handle.
     402 * @param   enmBinaryOp         The binary operation to append.
     403 */
     404RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp);
     405
     406
     407/**
     408 * Appends the given Arg<idArg> operand.
     409 *
     410 * @returns IPRT status code.
     411 * @param   hAcpiTbl            The ACPI table handle.
     412 * @param   idArg               The argument ID to append [0..6].
     413 */
     414RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg);
     415
     416
     417/**
     418 * Appends the given Local<idLocal> operand.
     419 *
     420 * @returns IPRT status code.
     421 * @param   hAcpiTbl            The ACPI table handle.
     422 * @param   idLocal             The local ID to append [0..7].
     423 */
     424RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal);
     425
     426
     427/**
     428 * Appends the given UUID as a buffer object.
     429 *
     430 * @returns IPRT status code.
     431 * @param   hAcpiTbl            The ACPI table handle.
     432 * @param   pUuid               The UUID to append.
     433 */
     434RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid);
     435
     436
     437/**
     438 * Appends the given UUID string as a UUID buffer object.
     439 *
     440 * @returns IPRT status code.
     441 * @param   hAcpiTbl            The ACPI table handle.
     442 * @param   pszUuid             The UUID string to append as a buffer.
     443 */
     444RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid);
    335445
    336446
  • trunk/include/iprt/mangling.h

    r106337 r107036  
    388388# define RTAcpiResourceReset                            RT_MANGLER(RTAcpiResourceReset)
    389389# define RTAcpiResourceSeal                             RT_MANGLER(RTAcpiResourceSeal)
     390# define RTAcpiTblArgOpAppend                           RT_MANGLER(RTAcpiTblArgOpAppend)
     391# define RTAcpiTblBinaryOpAppend                        RT_MANGLER(RTAcpiTblBinaryOpAppend)
    390392# define RTAcpiTblBufferAppend                          RT_MANGLER(RTAcpiTblBufferAppend)
    391393# define RTAcpiTblCreate                                RT_MANGLER(RTAcpiTblCreate)
     
    397399# define RTAcpiTblDumpToFile                            RT_MANGLER(RTAcpiTblDumpToFile)
    398400# define RTAcpiTblDumpToVfsIoStrm                       RT_MANGLER(RTAcpiTblDumpToVfsIoStrm)
     401# define RTAcpiTblElseFinalize                          RT_MANGLER(RTAcpiTblElseFinalize)
     402# define RTAcpiTblElseStart                             RT_MANGLER(RTAcpiTblElseStart)
    399403# define RTAcpiTblFinalize                              RT_MANGLER(RTAcpiTblFinalize)
    400404# define RTAcpiTblGetSize                               RT_MANGLER(RTAcpiTblGetSize)
    401405# define RTAcpiTblHdrChecksumGenerate                   RT_MANGLER(RTAcpiTblHdrChecksumGenerate)
     406# define RTAcpiTblIfFinalize                            RT_MANGLER(RTAcpiTblIfFinalize)
     407# define RTAcpiTblIfStart                               RT_MANGLER(RTAcpiTblIfStart)
    402408# define RTAcpiTblIntegerAppend                         RT_MANGLER(RTAcpiTblIntegerAppend)
     409# define RTAcpiTblLocalOpAppend                         RT_MANGLER(RTAcpiTblLocalOpAppend)
    403410# define RTAcpiTblMethodStart                           RT_MANGLER(RTAcpiTblMethodStart)
    404411# define RTAcpiTblMethodFinalize                        RT_MANGLER(RTAcpiTblMethodFinalize)
     
    411418# define RTAcpiTblStmtSimpleAppend                      RT_MANGLER(RTAcpiTblStmtSimpleAppend)
    412419# define RTAcpiTblStringAppend                          RT_MANGLER(RTAcpiTblStringAppend)
     420# define RTAcpiTblUuidAppend                            RT_MANGLER(RTAcpiTblUuidAppend)
     421# define RTAcpiTblUuidAppendFromStr                     RT_MANGLER(RTAcpiTblUuidAppendFromStr)
    413422# define RTAssertAreQuiet                               RT_MANGLER(RTAssertAreQuiet)
    414423# define RTAssertMayPanic                               RT_MANGLER(RTAssertMayPanic)
  • trunk/src/VBox/Runtime/common/misc/acpi.cpp

    r106486 r107036  
    4545#include <iprt/mem.h>
    4646#include <iprt/string.h>
     47#include <iprt/uuid.h>
    4748
    4849#include <iprt/formats/acpi-aml.h>
     
    809810
    810811
     812RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl)
     813{
     814    PRTACPITBLINT pThis = hAcpiTbl;
     815    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     816
     817    rtAcpiTblPkgStart(pThis, ACPI_AML_BYTE_CODE_OP_IF);
     818    return pThis->rcErr;
     819}
     820
     821
     822RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl)
     823{
     824    PRTACPITBLINT pThis = hAcpiTbl;
     825    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     826
     827    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_IF);
     828}
     829
     830
     831RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl)
     832{
     833    PRTACPITBLINT pThis = hAcpiTbl;
     834    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     835
     836    /* Makes only sense inside an IfOp package. */
     837    AssertReturn(pThis->paPkgStack[pThis->idxPkgStackElem].bOp == ACPI_AML_BYTE_CODE_OP_IF, VERR_INVALID_STATE);
     838
     839    rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
     840    return pThis->rcErr;
     841}
     842
     843
     844RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl)
     845{
     846    PRTACPITBLINT pThis = hAcpiTbl;
     847    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     848
     849    return rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_OP_ELSE);
     850}
     851
     852
     853RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp)
     854{
     855    PRTACPITBLINT pThis = hAcpiTbl;
     856    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     857
     858    uint8_t bOp;
     859    switch (enmBinaryOp)
     860    {
     861        case kAcpiBinaryOp_LAnd:            bOp = ACPI_AML_BYTE_CODE_OP_LAND;     break;
     862        case kAcpiBinaryOp_LEqual:          bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
     863        case kAcpiBinaryOp_LGreater:        bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
     864        case kAcpiBinaryOp_LLess:           bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
     865        case kAcpiBinaryOp_LGreaterEqual:
     866        case kAcpiBinaryOp_LLessEqual:   
     867        case kAcpiBinaryOp_LNotEqual:
     868            bOp = ACPI_AML_BYTE_CODE_OP_LNOT;
     869            break;
     870        default:
     871            AssertFailedReturn(VERR_INVALID_PARAMETER);
     872    }
     873    rtAcpiTblAppendByte(pThis, bOp);
     874    switch (enmBinaryOp)
     875    {
     876        case kAcpiBinaryOp_LGreaterEqual:   bOp = ACPI_AML_BYTE_CODE_OP_LLESS;    break;
     877        case kAcpiBinaryOp_LLessEqual:      bOp = ACPI_AML_BYTE_CODE_OP_LGREATER; break;
     878        case kAcpiBinaryOp_LNotEqual:       bOp = ACPI_AML_BYTE_CODE_OP_LEQUAL;   break;
     879        default:
     880            bOp = 0x00;
     881    }
     882    if (bOp != 0x00)
     883        rtAcpiTblAppendByte(pThis, bOp);
     884    return pThis->rcErr;
     885}
     886
     887
     888RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg)
     889{
     890    PRTACPITBLINT pThis = hAcpiTbl;
     891    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     892    AssertReturn(idArg <= 6, VERR_INVALID_PARAMETER);
     893
     894    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_ARG_0 + idArg);
     895    return pThis->rcErr;
     896}
     897
     898
     899RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal)
     900{
     901    PRTACPITBLINT pThis = hAcpiTbl;
     902    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     903    AssertReturn(idLocal <= 7, VERR_INVALID_PARAMETER);
     904
     905    rtAcpiTblAppendByte(pThis, ACPI_AML_BYTE_CODE_OP_LOCAL_0 + idLocal);
     906    return pThis->rcErr;
     907}
     908
     909
     910RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid)
     911{
     912    /* UUIDs are stored as a buffer object. */
     913    /** @todo Needs conversion on big endian machines. */
     914    return RTAcpiTblBufferAppend(hAcpiTbl, &pUuid->au8[0], sizeof(*pUuid));
     915}
     916
     917
     918RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid)
     919{
     920    PRTACPITBLINT pThis = hAcpiTbl;
     921    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     922
     923    RTUUID Uuid;
     924    pThis->rcErr = RTUuidFromStr(&Uuid, pszUuid);
     925    if (RT_SUCCESS(pThis->rcErr))
     926        return RTAcpiTblUuidAppend(pThis, &Uuid);
     927
     928    return pThis->rcErr;
     929}
     930
     931
    811932/**
    812933 * Ensures there is at least the given amount of space in the given ACPI resource.
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