Changeset 107036 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Nov 19, 2024 10:05:28 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/acpi.cpp
r106486 r107036 45 45 #include <iprt/mem.h> 46 46 #include <iprt/string.h> 47 #include <iprt/uuid.h> 47 48 48 49 #include <iprt/formats/acpi-aml.h> … … 809 810 810 811 812 RTDECL(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 822 RTDECL(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 831 RTDECL(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 844 RTDECL(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 853 RTDECL(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 888 RTDECL(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 899 RTDECL(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 910 RTDECL(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 918 RTDECL(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 811 932 /** 812 933 * 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.