Changeset 107063 in vbox
- Timestamp:
- Nov 20, 2024 5:22:16 PM (6 months ago)
- svn:sync-xref-src-repo-rev:
- 166017
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/acpi.h
r107036 r107063 445 445 446 446 447 /** 448 * Known operation region space types. 449 */ 450 typedef enum RTACPIOPREGIONSPACE 451 { 452 /** Invalid region space type. */ 453 kAcpiOperationRegionSpace_Invalid = 0, 454 /** Region is in system memory space. */ 455 kAcpiOperationRegionSpace_SystemMemory, 456 /** Region is in system I/O space. */ 457 kAcpiOperationRegionSpace_SystemIo, 458 /** Region is in PCI config space. */ 459 kAcpiOperationRegionSpace_PciConfig, 460 /** Region is in embedded control space. */ 461 kAcpiOperationRegionSpace_EmbeddedControl, 462 /** Region is in SMBUS space. */ 463 kAcpiOperationRegionSpace_SmBus, 464 /** Region is in system CMOS space. */ 465 kAcpiOperationRegionSpace_SystemCmos, 466 /** Region is a PCI bar target. */ 467 kAcpiOperationRegionSpace_PciBarTarget, 468 /** Region is in IPMI space. */ 469 kAcpiOperationRegionSpace_Ipmi, 470 /** Region is in GPIO space. */ 471 kAcpiOperationRegionSpace_Gpio, 472 /** Region is in generic serial bus space. */ 473 kAcpiOperationRegionSpace_GenericSerialBus, 474 /** Region is in platform communications channel (PCC) space. */ 475 kAcpiOperationRegionSpace_Pcc, 476 /** 32bit hack. */ 477 kAcpiOperationRegionSpace_32bit_Hack = 0x7fffffff 478 } RTACPIOPREGIONSPACE; 479 480 481 /** 482 * Appends a new OperationRegion() to the given ACPI table. 483 * 484 * @returns IPRT status code. 485 * @param hAcpiTbl The ACPI table handle. 486 * @param pszName The name of the operation region. 487 * @param enmSpace The operation region space type. 488 * @param offRegion Offset of the region. 489 * @param cbRegion Size of the region in bytes. 490 */ 491 RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace, 492 uint64_t offRegion, uint64_t cbRegion); 493 494 495 /** 496 * Field access type. 497 */ 498 typedef enum RTACPIFIELDACC 499 { 500 /** Invalid access type. */ 501 kAcpiFieldAcc_Invalid = 0, 502 /** Any access width is okay. */ 503 kAcpiFieldAcc_Any, 504 /** Byte (8-bit) access. */ 505 kAcpiFieldAcc_Byte, 506 /** Word (16-bit) access. */ 507 kAcpiFieldAcc_Word, 508 /** Double word (32-bit) access. */ 509 kAcpiFieldAcc_DWord, 510 /** Quad word (64-bit) access. */ 511 kAcpiFieldAcc_QWord, 512 /** Buffer like access. */ 513 kAcpiFieldAcc_Buffer 514 } RTACPIFIELDACC; 515 516 517 /** 518 * Field update rule. 519 */ 520 typedef enum RTACPIFIELDUPDATE 521 { 522 /** Invalid upadte rule. */ 523 kAcpiFieldUpdate_Invalid = 0, 524 /** Preserve content not being accessed. */ 525 kAcpiFieldUpdate_Preserve, 526 /** Write as ones. */ 527 kAcpiFieldUpdate_WriteAsOnes, 528 /** Write as zeroes. */ 529 kAcpiFieldUpdate_WriteAsZeroes 530 } RTACPIFIELDUPDATE; 531 532 533 /** 534 * Field entry. 535 */ 536 typedef struct RTACPIFIELDENTRY 537 { 538 /** The field name. */ 539 const char *pszName; 540 /** Number of bits of the field. */ 541 uint64_t cBits; 542 } RTACPIFIELDENTRY; 543 /** Pointer to a field entry. */ 544 typedef RTACPIFIELDENTRY *PRTACPIFIELDENTRY; 545 /** Pointer to a const field entry. */ 546 typedef const RTACPIFIELDENTRY *PCRTACPIFIELDENTRY; 547 548 549 /** 550 * Appends a new field descriptor to the given ACPI table. 551 * 552 * @returns IPRT status code. 553 * @param hAcpiTbl The ACPI table handle. 554 * @param pszNameRef The region/buffer the field describes. 555 * @param enmAcc The access type, 556 * @param fLock Flag whether access must happen under a lock. 557 * @param enmUpdate The update rule. 558 * @param paFields Pointer to the field descriptors. 559 * @param cFields Number of entries in the array. 560 */ 561 RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc, 562 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields, 563 uint32_t cFields); 564 565 566 447 567 /** @name ACPI resource builder related API. 448 568 * @{ */ -
trunk/include/iprt/mangling.h
r107036 r107063 401 401 # define RTAcpiTblElseFinalize RT_MANGLER(RTAcpiTblElseFinalize) 402 402 # define RTAcpiTblElseStart RT_MANGLER(RTAcpiTblElseStart) 403 # define RTAcpiTblFieldAppend RT_MANGLER(RTAcpiTblFieldAppend) 403 404 # define RTAcpiTblFinalize RT_MANGLER(RTAcpiTblFinalize) 404 405 # define RTAcpiTblGetSize RT_MANGLER(RTAcpiTblGetSize) … … 411 412 # define RTAcpiTblMethodFinalize RT_MANGLER(RTAcpiTblMethodFinalize) 412 413 # define RTAcpiTblNameAppend RT_MANGLER(RTAcpiTblNameAppend) 414 # define RTAcpiTblOpRegionAppend RT_MANGLER(RTAcpiTblOpRegionAppend) 413 415 # define RTAcpiTblPackageStart RT_MANGLER(RTAcpiTblPackageStart) 414 416 # define RTAcpiTblPackageFinalize RT_MANGLER(RTAcpiTblPackageFinalize) -
trunk/src/VBox/Runtime/common/misc/acpi.cpp
r107058 r107063 431 431 432 432 433 /** 434 * Encodes a PkgLength item for the given number. 435 * 436 * @returns IPRT status code. 437 * @param pThis The ACPI table instance. 438 * @param u64Length The length to encode. 439 */ 440 DECLINLINE(int) rtAcpiTblEncodePkgLength(PRTACPITBLINT pThis, uint64_t u64Length) 441 { 442 AssertReturn(u64Length < RT_BIT_32(28), VERR_BUFFER_OVERFLOW); 443 444 if (u64Length <= 63) 445 { 446 /* PkgLength only consists of the package lead byte. */ 447 rtAcpiTblAppendByte(pThis, (u64Length & 0x3f)); 448 } 449 else if (u64Length < RT_BIT_32(12)) 450 { 451 uint8_t abData[2]; 452 abData[0] = (1 << 6) | (u64Length & 0xf); 453 abData[1] = (u64Length >> 4) & 0xff; 454 rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData)); 455 } 456 else if (u64Length < RT_BIT_32(20)) 457 { 458 uint8_t abData[3]; 459 abData[0] = (1 << 6) | (u64Length & 0xf); 460 abData[1] = (u64Length >> 4) & 0xff; 461 abData[2] = (u64Length >> 12) & 0xff; 462 rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData)); 463 } 464 else if (u64Length < RT_BIT_32(28)) 465 { 466 uint8_t abData[4]; 467 abData[0] = (1 << 6) | (u64Length & 0xf); 468 abData[1] = (u64Length >> 4) & 0xff; 469 abData[2] = (u64Length >> 12) & 0xff; 470 abData[3] = (u64Length >> 20) & 0xff; 471 rtAcpiTblAppendData(pThis, &abData[0], sizeof(abData)); 472 } 473 else 474 AssertReleaseFailed(); 475 476 return VINF_SUCCESS; 477 } 478 479 433 480 RTDECL(uint8_t) RTAcpiChecksumGenerate(const void *pvData, size_t cbData) 434 481 { … … 926 973 return RTAcpiTblUuidAppend(pThis, &Uuid); 927 974 975 return pThis->rcErr; 976 } 977 978 979 RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace, 980 uint64_t offRegion, uint64_t cbRegion) 981 { 982 PRTACPITBLINT pThis = hAcpiTbl; 983 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 984 985 uint8_t abOp[2] = { ACPI_AML_BYTE_CODE_PREFIX_EXT_OP, ACPI_AML_BYTE_CODE_EXT_OP_OP_REGION }; 986 rtAcpiTblAppendData(pThis, &abOp[0], sizeof(abOp)); 987 rtAcpiTblAppendNameString(pThis, pszName); 988 989 uint8_t bRegionSpace = 0xff; 990 switch (enmSpace) 991 { 992 case kAcpiOperationRegionSpace_SystemMemory: bRegionSpace = 0x00; break; 993 case kAcpiOperationRegionSpace_SystemIo: bRegionSpace = 0x01; break; 994 case kAcpiOperationRegionSpace_PciConfig: bRegionSpace = 0x02; break; 995 case kAcpiOperationRegionSpace_EmbeddedControl: bRegionSpace = 0x03; break; 996 case kAcpiOperationRegionSpace_SmBus: bRegionSpace = 0x04; break; 997 case kAcpiOperationRegionSpace_SystemCmos: bRegionSpace = 0x05; break; 998 case kAcpiOperationRegionSpace_PciBarTarget: bRegionSpace = 0x06; break; 999 case kAcpiOperationRegionSpace_Ipmi: bRegionSpace = 0x07; break; 1000 case kAcpiOperationRegionSpace_Gpio: bRegionSpace = 0x08; break; 1001 case kAcpiOperationRegionSpace_GenericSerialBus: bRegionSpace = 0x09; break; 1002 case kAcpiOperationRegionSpace_Pcc: bRegionSpace = 0x0a; break; 1003 default: 1004 pThis->rcErr = VERR_INVALID_PARAMETER; 1005 AssertFailedReturn(pThis->rcErr); 1006 } 1007 rtAcpiTblAppendByte(pThis, bRegionSpace); 1008 RTAcpiTblIntegerAppend(pThis, offRegion); 1009 RTAcpiTblIntegerAppend(pThis, cbRegion); 1010 return pThis->rcErr; 1011 } 1012 1013 1014 RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc, 1015 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields, 1016 uint32_t cFields) 1017 { 1018 PRTACPITBLINT pThis = hAcpiTbl; 1019 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1020 1021 rtAcpiTblPkgStartExt(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD); 1022 rtAcpiTblAppendNameString(pThis, pszNameRef); 1023 1024 uint8_t fFlags = 0; 1025 switch (enmAcc) 1026 { 1027 case kAcpiFieldAcc_Any: fFlags = 0; break; 1028 case kAcpiFieldAcc_Byte: fFlags = 1; break; 1029 case kAcpiFieldAcc_Word: fFlags = 2; break; 1030 case kAcpiFieldAcc_DWord: fFlags = 3; break; 1031 case kAcpiFieldAcc_QWord: fFlags = 4; break; 1032 case kAcpiFieldAcc_Buffer: fFlags = 5; break; 1033 default: 1034 pThis->rcErr = VERR_INVALID_PARAMETER; 1035 AssertFailedReturn(pThis->rcErr); 1036 } 1037 if (fLock) 1038 fFlags |= RT_BIT(4); 1039 switch (enmUpdate) 1040 { 1041 case kAcpiFieldUpdate_Preserve: fFlags |= 0 << 5; break; 1042 case kAcpiFieldUpdate_WriteAsOnes: fFlags |= 1 << 5; break; 1043 case kAcpiFieldUpdate_WriteAsZeroes: fFlags |= 2 << 5; break; 1044 default: 1045 pThis->rcErr = VERR_INVALID_PARAMETER; 1046 AssertFailedReturn(pThis->rcErr); 1047 } 1048 rtAcpiTblAppendByte(pThis, fFlags); 1049 1050 for (uint32_t i = 0; i < cFields; i++) 1051 { 1052 rtAcpiTblAppendNameString(pThis, paFields[i].pszName); 1053 rtAcpiTblEncodePkgLength(pThis, paFields[i].cBits); 1054 } 1055 1056 rtAcpiTblPkgFinish(pThis, ACPI_AML_BYTE_CODE_EXT_OP_FIELD); 928 1057 return pThis->rcErr; 929 1058 }
Note:
See TracChangeset
for help on using the changeset viewer.