Changeset 105670 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library
- Timestamp:
- Aug 14, 2024 1:16:30 PM (6 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 3 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-159268 /vendor/edk2/current 103735-103757,103769-103776,129194-164365
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
r99404 r105670 2 2 FADT Table Generator 3 3 4 Copyright (c) 2017 - 202 2, Arm Limited. All rights reserved.4 Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. 5 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 6 7 7 @par Reference(s): 8 - ACPI 6. 4 Specification, January 20218 - ACPI 6.5 Specification, Aug 29, 2022 9 9 10 10 **/ … … 33 33 /** This macro defines the FADT flag options for ARM Platforms. 34 34 */ 35 #define FADT_FLAGS (EFI_ACPI_6_ 4_HW_REDUCED_ACPI | \36 EFI_ACPI_6_ 4_LOW_POWER_S0_IDLE_CAPABLE)35 #define FADT_FLAGS (EFI_ACPI_6_5_HW_REDUCED_ACPI | \ 36 EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE) 37 37 38 38 /** This macro defines the valid mask for the FADT flag option … … 43 43 44 44 Valid bits are: 45 EFI_ACPI_6_ 4_WBINVD BIT046 EFI_ACPI_6_ 4_PWR_BUTTON BIT447 EFI_ACPI_6_ 4_SLP_BUTTON BIT548 EFI_ACPI_6_ 4_FIX_RTC BIT649 EFI_ACPI_6_ 4_DCK_CAP BIT950 EFI_ACPI_6_ 4_RESET_REG_SUP BIT1051 EFI_ACPI_6_ 4_SEALED_CASE BIT1152 EFI_ACPI_6_ 4_HEADLESS BIT1253 EFI_ACPI_6_ 4_USE_PLATFORM_CLOCK BIT1554 EFI_ACPI_6_ 4_FORCE_APIC_CLUSTER_MODEL BIT1855 EFI_ACPI_6_ 4_FORCE_APIC_PHYSICAL_DESTINATION_MODE BIT1956 EFI_ACPI_6_ 4_HW_REDUCED_ACPI BIT2057 EFI_ACPI_6_ 4_LOW_POWER_S0_IDLE_CAPABLE BIT2145 EFI_ACPI_6_5_WBINVD BIT0 46 EFI_ACPI_6_5_PWR_BUTTON BIT4 47 EFI_ACPI_6_5_SLP_BUTTON BIT5 48 EFI_ACPI_6_5_FIX_RTC BIT6 49 EFI_ACPI_6_5_DCK_CAP BIT9 50 EFI_ACPI_6_5_RESET_REG_SUP BIT10 51 EFI_ACPI_6_5_SEALED_CASE BIT11 52 EFI_ACPI_6_5_HEADLESS BIT12 53 EFI_ACPI_6_5_USE_PLATFORM_CLOCK BIT15 54 EFI_ACPI_6_5_FORCE_APIC_CLUSTER_MODEL BIT18 55 EFI_ACPI_6_5_FORCE_APIC_PHYSICAL_DESTINATION_MODE BIT19 56 EFI_ACPI_6_5_HW_REDUCED_ACPI BIT20 57 EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE BIT21 58 58 */ 59 59 #define VALID_HARDWARE_REDUCED_FLAG_MASK ( \ 60 EFI_ACPI_6_ 4_WBINVD | \61 EFI_ACPI_6_ 4_PWR_BUTTON | \62 EFI_ACPI_6_ 4_SLP_BUTTON | \63 EFI_ACPI_6_ 4_FIX_RTC | \64 EFI_ACPI_6_ 4_DCK_CAP | \65 EFI_ACPI_6_ 4_RESET_REG_SUP | \66 EFI_ACPI_6_ 4_SEALED_CASE | \67 EFI_ACPI_6_ 4_HEADLESS | \68 EFI_ACPI_6_ 4_USE_PLATFORM_CLOCK | \69 EFI_ACPI_6_ 4_FORCE_APIC_CLUSTER_MODEL | \70 EFI_ACPI_6_ 4_FORCE_APIC_PHYSICAL_DESTINATION_MODE | \71 EFI_ACPI_6_ 4_HW_REDUCED_ACPI | \72 EFI_ACPI_6_ 4_LOW_POWER_S0_IDLE_CAPABLE)60 EFI_ACPI_6_5_WBINVD | \ 61 EFI_ACPI_6_5_PWR_BUTTON | \ 62 EFI_ACPI_6_5_SLP_BUTTON | \ 63 EFI_ACPI_6_5_FIX_RTC | \ 64 EFI_ACPI_6_5_DCK_CAP | \ 65 EFI_ACPI_6_5_RESET_REG_SUP | \ 66 EFI_ACPI_6_5_SEALED_CASE | \ 67 EFI_ACPI_6_5_HEADLESS | \ 68 EFI_ACPI_6_5_USE_PLATFORM_CLOCK | \ 69 EFI_ACPI_6_5_FORCE_APIC_CLUSTER_MODEL | \ 70 EFI_ACPI_6_5_FORCE_APIC_PHYSICAL_DESTINATION_MODE | \ 71 EFI_ACPI_6_5_HW_REDUCED_ACPI | \ 72 EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE) 73 73 74 74 #pragma pack(1) 75 75 76 /** The AcpiFadt is a template EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE76 /** The AcpiFadt is a template EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE 77 77 structure used for generating the FADT Table. 78 78 Note: fields marked with "{Template}" will be updated dynamically. 79 79 */ 80 80 STATIC 81 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = {81 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = { 82 82 ACPI_HEADER ( 83 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,84 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE,85 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_REVISION83 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 84 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE, 85 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 86 86 ), 87 87 // UINT32 FirmwareCtrl … … 92 92 EFI_ACPI_RESERVED_BYTE, 93 93 // UINT8 PreferredPmProfile 94 EFI_ACPI_6_ 4_PM_PROFILE_UNSPECIFIED, // {Template}: Power Management Profile94 EFI_ACPI_6_5_PM_PROFILE_UNSPECIFIED, // {Template}: Power Management Profile 95 95 // UINT16 SciInt 96 96 0, … … 161 161 // UINT32 Flags 162 162 FADT_FLAGS, 163 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE ResetReg163 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg 164 164 NULL_GAS, 165 165 // UINT8 ResetValue 166 166 0, 167 167 // UINT16 ArmBootArch 168 EFI_ACPI_6_ 4_ARM_PSCI_COMPLIANT, // {Template}: ARM Boot Architecture Flags168 EFI_ACPI_6_5_ARM_PSCI_COMPLIANT, // {Template}: ARM Boot Architecture Flags 169 169 // UINT8 MinorRevision 170 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template}170 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template} 171 171 // UINT64 XFirmwareCtrl 172 172 0, 173 173 // UINT64 XDsdt 174 174 0, 175 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk176 NULL_GAS, 177 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk178 NULL_GAS, 179 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk180 NULL_GAS, 181 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk182 NULL_GAS, 183 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk184 NULL_GAS, 185 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk186 NULL_GAS, 187 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XGpe0Blk188 NULL_GAS, 189 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE XGpe1Blk190 NULL_GAS, 191 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE SleepControlReg192 NULL_GAS, 193 // EFI_ACPI_6_ 4_GENERIC_ADDRESS_STRUCTURE SleepStatusReg175 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk 176 NULL_GAS, 177 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk 178 NULL_GAS, 179 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk 180 NULL_GAS, 181 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk 182 NULL_GAS, 183 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk 184 NULL_GAS, 185 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk 186 NULL_GAS, 187 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe0Blk 188 NULL_GAS, 189 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe1Blk 190 NULL_GAS, 191 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepControlReg 192 NULL_GAS, 193 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepStatusReg 194 194 NULL_GAS, 195 195 // UINT64 HypervisorVendorIdentity … … 536 536 (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt, 537 537 AcpiTableInfo, 538 sizeof (EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE)538 sizeof (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE) 539 539 ); 540 540 if (EFI_ERROR (Status)) { … … 558 558 EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION) && 559 559 ((AcpiTableInfo->MinorRevision & 0xF) <= 560 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION))560 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION)) 561 561 { 562 562 AcpiFadt.MinorVersion = AcpiTableInfo->MinorRevision; … … 567 567 "defaulting to FADT Minor Revision 0x%x\n", 568 568 AcpiTableInfo->MinorRevision, 569 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION569 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION 570 570 )); 571 571 } … … 643 643 L"ACPI.STD.FADT.GENERATOR", 644 644 // ACPI Table Signature 645 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,645 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 646 646 // ACPI Table Revision supported by this Generator 647 EFI_ACPI_6_ 4_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,647 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_REVISION, 648 648 // Minimum supported ACPI Table Revision 649 649 EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION, -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
r99404 r105670 2 2 MADT Table Generator 3 3 4 Copyright (c) 2017 - 202 0, ARMLimited. All rights reserved.4 Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. 5 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 6 7 7 @par Reference(s): 8 - ACPI 6. 3 Specification - January 20198 - ACPI 6.5 Specification - Aug 29, 2022 9 9 10 10 **/ … … 83 83 84 84 /** This function updates the GIC CPU Interface Information in the 85 EFI_ACPI_6_ 3_GIC_STRUCTURE structure.85 EFI_ACPI_6_5_GIC_STRUCTURE structure. 86 86 87 87 @param [in] Gicc Pointer to GIC CPU Interface structure. … … 92 92 VOID 93 93 AddGICC ( 94 IN EFI_ACPI_6_ 3_GIC_STRUCTURE *CONST Gicc,94 IN EFI_ACPI_6_5_GIC_STRUCTURE *CONST Gicc, 95 95 IN CONST CM_ARM_GICC_INFO *CONST GicCInfo, 96 96 IN CONST UINT8 MadtRev … … 101 101 102 102 // UINT8 Type 103 Gicc->Type = EFI_ACPI_6_ 3_GIC;103 Gicc->Type = EFI_ACPI_6_5_GIC; 104 104 // UINT8 Length 105 Gicc->Length = sizeof (EFI_ACPI_6_ 3_GIC_STRUCTURE);105 Gicc->Length = sizeof (EFI_ACPI_6_5_GIC_STRUCTURE); 106 106 // UINT16 Reserved 107 107 Gicc->Reserved = EFI_ACPI_RESERVED_WORD; … … 149 149 Gicc->SpeOverflowInterrupt = 0; 150 150 } 151 152 // UINT16 TrbeInterrupt 153 if (MadtRev > EFI_ACPI_6_4_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) { 154 Gicc->TrbeInterrupt = GicCInfo->TrbeInterrupt; 155 } 151 156 } 152 157 … … 215 220 EFI_STATUS 216 221 AddGICCList ( 217 IN EFI_ACPI_6_ 3_GIC_STRUCTURE *Gicc,222 IN EFI_ACPI_6_5_GIC_STRUCTURE *Gicc, 218 223 IN CONST CM_ARM_GICC_INFO *GicCInfo, 219 224 IN UINT32 GicCCount, … … 253 258 VOID 254 259 AddGICD ( 255 EFI_ACPI_6_ 3_GIC_DISTRIBUTOR_STRUCTURE *CONST Gicd,260 EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE *CONST Gicd, 256 261 CONST CM_ARM_GICD_INFO *CONST GicDInfo 257 262 ) … … 261 266 262 267 // UINT8 Type 263 Gicd->Type = EFI_ACPI_6_ 3_GICD;268 Gicd->Type = EFI_ACPI_6_5_GICD; 264 269 // UINT8 Length 265 Gicd->Length = sizeof (EFI_ACPI_6_ 3_GIC_DISTRIBUTOR_STRUCTURE);270 Gicd->Length = sizeof (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE); 266 271 // UINT16 Reserved 267 272 Gicd->Reserved1 = EFI_ACPI_RESERVED_WORD; … … 290 295 VOID 291 296 AddGICMsiFrame ( 292 IN EFI_ACPI_6_ 3_GIC_MSI_FRAME_STRUCTURE *CONST GicMsiFrame,297 IN EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE *CONST GicMsiFrame, 293 298 IN CONST CM_ARM_GIC_MSI_FRAME_INFO *CONST GicMsiFrameInfo 294 299 ) … … 297 302 ASSERT (GicMsiFrameInfo != NULL); 298 303 299 GicMsiFrame->Type = EFI_ACPI_6_ 3_GIC_MSI_FRAME;300 GicMsiFrame->Length = sizeof (EFI_ACPI_6_ 3_GIC_MSI_FRAME_STRUCTURE);304 GicMsiFrame->Type = EFI_ACPI_6_5_GIC_MSI_FRAME; 305 GicMsiFrame->Length = sizeof (EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE); 301 306 GicMsiFrame->Reserved1 = EFI_ACPI_RESERVED_WORD; 302 307 GicMsiFrame->GicMsiFrameId = GicMsiFrameInfo->GicMsiFrameId; … … 317 322 VOID 318 323 AddGICMsiFrameInfoList ( 319 IN EFI_ACPI_6_ 3_GIC_MSI_FRAME_STRUCTURE *GicMsiFrame,324 IN EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE *GicMsiFrame, 320 325 IN CONST CM_ARM_GIC_MSI_FRAME_INFO *GicMsiFrameInfo, 321 326 IN UINT32 GicMsiFrameCount … … 338 343 VOID 339 344 AddGICRedistributor ( 340 IN EFI_ACPI_6_ 3_GICR_STRUCTURE *CONST Gicr,345 IN EFI_ACPI_6_5_GICR_STRUCTURE *CONST Gicr, 341 346 IN CONST CM_ARM_GIC_REDIST_INFO *CONST GicRedistributorInfo 342 347 ) … … 345 350 ASSERT (GicRedistributorInfo != NULL); 346 351 347 Gicr->Type = EFI_ACPI_6_ 3_GICR;348 Gicr->Length = sizeof (EFI_ACPI_6_ 3_GICR_STRUCTURE);352 Gicr->Type = EFI_ACPI_6_5_GICR; 353 Gicr->Length = sizeof (EFI_ACPI_6_5_GICR_STRUCTURE); 349 354 Gicr->Reserved = EFI_ACPI_RESERVED_WORD; 350 355 Gicr->DiscoveryRangeBaseAddress = … … 362 367 VOID 363 368 AddGICRedistributorList ( 364 IN EFI_ACPI_6_ 3_GICR_STRUCTURE *Gicr,369 IN EFI_ACPI_6_5_GICR_STRUCTURE *Gicr, 365 370 IN CONST CM_ARM_GIC_REDIST_INFO *GicRInfo, 366 371 IN UINT32 GicRCount … … 383 388 VOID 384 389 AddGICInterruptTranslationService ( 385 IN EFI_ACPI_6_ 3_GIC_ITS_STRUCTURE *CONST GicIts,390 IN EFI_ACPI_6_5_GIC_ITS_STRUCTURE *CONST GicIts, 386 391 IN CONST CM_ARM_GIC_ITS_INFO *CONST GicItsInfo 387 392 ) … … 390 395 ASSERT (GicItsInfo != NULL); 391 396 392 GicIts->Type = EFI_ACPI_6_ 3_GIC_ITS;393 GicIts->Length = sizeof (EFI_ACPI_6_ 3_GIC_ITS_STRUCTURE);397 GicIts->Type = EFI_ACPI_6_5_GIC_ITS; 398 GicIts->Length = sizeof (EFI_ACPI_6_5_GIC_ITS_STRUCTURE); 394 399 GicIts->Reserved = EFI_ACPI_RESERVED_WORD; 395 400 GicIts->GicItsId = GicItsInfo->GicItsId; … … 408 413 VOID 409 414 AddGICItsList ( 410 IN EFI_ACPI_6_ 3_GIC_ITS_STRUCTURE *GicIts,415 IN EFI_ACPI_6_5_GIC_ITS_STRUCTURE *GicIts, 411 416 IN CONST CM_ARM_GIC_ITS_INFO *GicItsInfo, 412 417 IN UINT32 GicItsCount … … 471 476 UINT32 GicItsOffset; 472 477 473 EFI_ACPI_6_ 3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt;478 EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt; 474 479 475 480 ASSERT (This != NULL); … … 603 608 } 604 609 605 TableSize = sizeof (EFI_ACPI_6_ 3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);610 TableSize = sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER); 606 611 607 612 GicCOffset = TableSize; 608 TableSize += (sizeof (EFI_ACPI_6_ 3_GIC_STRUCTURE) * GicCCount);613 TableSize += (sizeof (EFI_ACPI_6_5_GIC_STRUCTURE) * GicCCount); 609 614 610 615 GicDOffset = TableSize; 611 TableSize += (sizeof (EFI_ACPI_6_ 3_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount);616 TableSize += (sizeof (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount); 612 617 613 618 GicMSIOffset = TableSize; 614 TableSize += (sizeof (EFI_ACPI_6_ 3_GIC_MSI_FRAME_STRUCTURE) * GicMSICount);619 TableSize += (sizeof (EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE) * GicMSICount); 615 620 616 621 GicRedistOffset = TableSize; 617 TableSize += (sizeof (EFI_ACPI_6_ 3_GICR_STRUCTURE) * GicRedistCount);622 TableSize += (sizeof (EFI_ACPI_6_5_GICR_STRUCTURE) * GicRedistCount); 618 623 619 624 GicItsOffset = TableSize; 620 TableSize += (sizeof (EFI_ACPI_6_ 3_GIC_ITS_STRUCTURE) * GicItsCount);625 TableSize += (sizeof (EFI_ACPI_6_5_GIC_ITS_STRUCTURE) * GicItsCount); 621 626 622 627 // Allocate the Buffer for MADT table … … 634 639 } 635 640 636 Madt = (EFI_ACPI_6_ 3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)*Table;641 Madt = (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)*Table; 637 642 638 643 DEBUG (( … … 660 665 661 666 Status = AddGICCList ( 662 (EFI_ACPI_6_ 3_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset),667 (EFI_ACPI_6_5_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset), 663 668 GicCInfo, 664 669 GicCCount, … … 675 680 676 681 AddGICD ( 677 (EFI_ACPI_6_ 3_GIC_DISTRIBUTOR_STRUCTURE *)((UINT8 *)Madt + GicDOffset),682 (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE *)((UINT8 *)Madt + GicDOffset), 678 683 GicDInfo 679 684 ); … … 681 686 if (GicMSICount != 0) { 682 687 AddGICMsiFrameInfoList ( 683 (EFI_ACPI_6_ 3_GIC_MSI_FRAME_STRUCTURE *)((UINT8 *)Madt + GicMSIOffset),688 (EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE *)((UINT8 *)Madt + GicMSIOffset), 684 689 GicMSIInfo, 685 690 GicMSICount … … 689 694 if (GicRedistCount != 0) { 690 695 AddGICRedistributorList ( 691 (EFI_ACPI_6_ 3_GICR_STRUCTURE *)((UINT8 *)Madt + GicRedistOffset),696 (EFI_ACPI_6_5_GICR_STRUCTURE *)((UINT8 *)Madt + GicRedistOffset), 692 697 GicRedistInfo, 693 698 GicRedistCount … … 697 702 if (GicItsCount != 0) { 698 703 AddGICItsList ( 699 (EFI_ACPI_6_ 3_GIC_ITS_STRUCTURE *)((UINT8 *)Madt + GicItsOffset),704 (EFI_ACPI_6_5_GIC_ITS_STRUCTURE *)((UINT8 *)Madt + GicItsOffset), 700 705 GicItsInfo, 701 706 GicItsCount … … 765 770 L"ACPI.STD.MADT.GENERATOR", 766 771 // ACPI Table Signature 767 EFI_ACPI_6_ 3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,772 EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, 768 773 // ACPI Table Revision supported by this Generator 769 EFI_ACPI_6_ 3_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,774 EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, 770 775 // Minimum supported ACPI Table Revision 771 776 EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
r101291 r105670 2 2 SSDT Cpu Topology Table Generator. 3 3 4 Copyright (c) 2021 , Arm Limited. All rights reserved.<BR>4 Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.<BR> 5 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 6 7 7 @par Reference(s): 8 8 - ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors 9 - ACPI for CoreSight version 1.2 Platform Design Document 10 (https://developer.arm.com/documentation/den0067/a/?lang=en) 11 12 @par Glossary: 13 - ETE - Embedded Trace Extension. 14 - ETM - Embedded Trace Macrocell. 9 15 **/ 10 16 … … 36 42 - EArmObjCmRef (OPTIONAL) 37 43 - EArmObjLpiInfo (OPTIONAL) 44 - GetEArmObjEtInfo (OPTIONAL) 45 - EArmObjPsdInfo (OPTIONAL) 38 46 */ 39 47 … … 87 95 ); 88 96 97 /** 98 This macro expands to a function that retrieves the ET device 99 information from the Configuration Manager. 100 */ 101 GET_OBJECT_LIST ( 102 EObjNameSpaceArm, 103 EArmObjEtInfo, 104 CM_ARM_ET_INFO 105 ); 106 107 /** 108 This macro expands to a function that retrieves the PSD 109 information from the Configuration Manager. 110 */ 111 GET_OBJECT_LIST ( 112 EObjNameSpaceArm, 113 EArmObjPsdInfo, 114 CM_ARM_PSD_INFO 115 ); 116 89 117 /** Initialize the TokenTable. 90 118 … … 238 266 239 267 return EFI_SUCCESS; 268 } 269 270 /** Create and add an _PSD Node to Cpu Node. 271 272 For instance, transform an AML node from: 273 Device (C002) 274 { 275 Name (_UID, 2) 276 Name (_HID, "ACPI0007") 277 } 278 279 To: 280 Device (C002) 281 { 282 Name (_UID, 2) 283 Name (_HID, "ACPI0007") 284 Name (_PSD, Package() 285 { 286 NumEntries, // Integer 287 Revision, // Integer 288 Domain, // Integer 289 CoordType, // Integer 290 NumProcessors, // Integer 291 }) 292 } 293 294 @param [in] Generator The SSDT Cpu Topology generator. 295 @param [in] CfgMgrProtocol Pointer to the Configuration Manager 296 Protocol Interface. 297 @param [in] GicCInfo Pointer to the CM_ARM_GICC_INFO object 298 describing the Cpu. 299 @param [in] Node CPU Node to which the _CPC node is 300 attached. 301 302 @retval EFI_SUCCESS The function completed successfully. 303 @retval EFI_INVALID_PARAMETER Invalid parameter. 304 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 305 **/ 306 STATIC 307 EFI_STATUS 308 EFIAPI 309 CreateAmlPsdNode ( 310 IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, 311 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, 312 IN CM_ARM_GICC_INFO *GicCInfo, 313 IN AML_OBJECT_NODE_HANDLE *Node 314 ) 315 { 316 EFI_STATUS Status; 317 CM_ARM_PSD_INFO *PsdInfo; 318 319 Status = GetEArmObjPsdInfo ( 320 CfgMgrProtocol, 321 GicCInfo->PsdToken, 322 &PsdInfo, 323 NULL 324 ); 325 if (EFI_ERROR (Status)) { 326 ASSERT_EFI_ERROR (Status); 327 return Status; 328 } 329 330 Status = AmlCreatePsdNode ( 331 PsdInfo, 332 Node, 333 NULL 334 ); 335 ASSERT_EFI_ERROR (Status); 336 return Status; 240 337 } 241 338 … … 327 424 } 328 425 426 /** Create an embedded trace device and add it to the Cpu Node in the 427 AML namespace. 428 429 This generates the following ASL code: 430 Device (E002) 431 { 432 Name (_UID, 2) 433 Name (_HID, "ARMHC500") 434 } 435 436 Note: Currently we only support generating ETE nodes. Unlike ETM, 437 ETE has a system register interface and therefore does not need 438 the MMIO range to be described. 439 440 @param [in] Generator The SSDT Cpu Topology generator. 441 @param [in] ParentNode Parent node to attach the Cpu node to. 442 @param [in] GicCInfo CM_ARM_GICC_INFO object used to create the node. 443 @param [in] CpuName Value used to generate the node name. 444 @param [out] EtNodePtr If not NULL, return the created Cpu node. 445 446 @retval EFI_SUCCESS Success. 447 @retval EFI_INVALID_PARAMETER Invalid parameter. 448 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 449 **/ 450 STATIC 451 EFI_STATUS 452 EFIAPI 453 CreateAmlEtd ( 454 IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, 455 IN AML_NODE_HANDLE ParentNode, 456 IN CM_ARM_GICC_INFO *GicCInfo, 457 IN UINT32 CpuName, 458 OUT AML_OBJECT_NODE_HANDLE *EtNodePtr OPTIONAL 459 ) 460 { 461 EFI_STATUS Status; 462 AML_OBJECT_NODE_HANDLE EtNode; 463 CHAR8 AslName[AML_NAME_SEG_SIZE + 1]; 464 465 ASSERT (Generator != NULL); 466 ASSERT (ParentNode != NULL); 467 468 Status = WriteAslName ('E', CpuName, AslName); 469 if (EFI_ERROR (Status)) { 470 ASSERT (0); 471 return Status; 472 } 473 474 Status = AmlCodeGenDevice (AslName, ParentNode, &EtNode); 475 if (EFI_ERROR (Status)) { 476 ASSERT (0); 477 return Status; 478 } 479 480 Status = AmlCodeGenNameInteger ( 481 "_UID", 482 GicCInfo->AcpiProcessorUid, 483 EtNode, 484 NULL 485 ); 486 if (EFI_ERROR (Status)) { 487 ASSERT (0); 488 return Status; 489 } 490 491 Status = AmlCodeGenNameString ( 492 "_HID", 493 ACPI_HID_ET_DEVICE, 494 EtNode, 495 NULL 496 ); 497 if (EFI_ERROR (Status)) { 498 ASSERT (0); 499 return Status; 500 } 501 502 // If requested, return the handle to the EtNode. 503 if (EtNodePtr != NULL) { 504 *EtNodePtr = EtNode; 505 } 506 507 return Status; 508 } 509 510 /** Create and add an Embedded trace device to the Cpu Node. 511 512 @param [in] Generator The SSDT Cpu Topology generator. 513 @param [in] CfgMgrProtocol Pointer to the Configuration Manager 514 Protocol Interface. 515 @param [in] GicCInfo Pointer to the CM_ARM_GICC_INFO object 516 describing the Cpu. 517 @param [in] CpuName Value used to generate the CPU node name. 518 @param [in] Node CPU Node to which the ET device node is 519 attached. 520 521 @retval EFI_SUCCESS The function completed successfully. 522 @retval EFI_UNSUPPORTED Feature Unsupported. 523 @retval EFI_INVALID_PARAMETER Invalid parameter. 524 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 525 **/ 526 STATIC 527 EFI_STATUS 528 EFIAPI 529 CreateAmlEtNode ( 530 IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, 531 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, 532 IN CM_ARM_GICC_INFO *GicCInfo, 533 IN UINT32 CpuName, 534 IN AML_OBJECT_NODE_HANDLE *Node 535 ) 536 { 537 EFI_STATUS Status; 538 CM_ARM_ET_INFO *EtInfo; 539 540 Status = GetEArmObjEtInfo ( 541 CfgMgrProtocol, 542 GicCInfo->EtToken, 543 &EtInfo, 544 NULL 545 ); 546 if (EFI_ERROR (Status)) { 547 ASSERT (0); 548 return Status; 549 } 550 551 // Currently we only support creation of a ETE Node. 552 if (EtInfo->EtType != ArmEtTypeEte) { 553 return EFI_UNSUPPORTED; 554 } 555 556 Status = CreateAmlEtd ( 557 Generator, 558 Node, 559 GicCInfo, 560 CpuName, 561 NULL 562 ); 563 ASSERT_EFI_ERROR (Status); 564 return Status; 565 } 566 329 567 /** Create and add an _LPI method to Cpu/Cluster Node. 330 568 … … 685 923 } 686 924 925 if (GicCInfo->PsdToken != CM_NULL_TOKEN) { 926 Status = CreateAmlPsdNode (Generator, CfgMgrProtocol, GicCInfo, CpuNode); 927 if (EFI_ERROR (Status)) { 928 ASSERT_EFI_ERROR (Status); 929 return Status; 930 } 931 } 932 687 933 // If a CPC info is associated with the 688 934 // GicCinfo, create an _CPC method returning them. 689 935 if (GicCInfo->CpcToken != CM_NULL_TOKEN) { 690 936 Status = CreateAmlCpcNode (Generator, CfgMgrProtocol, GicCInfo, CpuNode); 937 if (EFI_ERROR (Status)) { 938 ASSERT_EFI_ERROR (Status); 939 return Status; 940 } 941 } 942 943 // Add an Embedded Trace node if present. 944 if (GicCInfo->EtToken != CM_NULL_TOKEN) { 945 Status = CreateAmlEtNode ( 946 Generator, 947 CfgMgrProtocol, 948 GicCInfo, 949 CpuName, 950 CpuNode 951 ); 691 952 if (EFI_ERROR (Status)) { 692 953 ASSERT_EFI_ERROR (Status); … … 812 1073 @param [in] NodeToken NodeToken of the ProcNode. 813 1074 @param [in] ParentNodeToken Parent NodeToken of the ProcNode. 1075 @param [in] PackageNodeSeen A parent of the ProcNode has the physical package flag set. 814 1076 815 1077 @retval EFI_SUCCESS Success. … … 823 1085 BOOLEAN IsLeaf, 824 1086 CM_OBJECT_TOKEN NodeToken, 825 CM_OBJECT_TOKEN ParentNodeToken 1087 CM_OBJECT_TOKEN ParentNodeToken, 1088 BOOLEAN PackageNodeSeen 826 1089 ) 827 1090 { 828 1091 BOOLEAN InvalidFlags; 829 1092 BOOLEAN HasPhysicalPackageBit; 830 BOOLEAN IsTopLevelNode;831 1093 832 1094 HasPhysicalPackageBit = (NodeFlags & EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) == 833 1095 EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL; 834 IsTopLevelNode = (ParentNodeToken == CM_NULL_TOKEN); 835 836 // A top-level node is a Physical Package and conversely. 837 InvalidFlags = HasPhysicalPackageBit ^ IsTopLevelNode; 1096 1097 // Only one Physical Package flag is allowed in the hierarchy 1098 InvalidFlags = HasPhysicalPackageBit && PackageNodeSeen; 838 1099 839 1100 // Check Leaf specific flags. 840 1101 if (IsLeaf) { 841 1102 InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != PPTT_LEAF_MASK); 1103 // Must have Physical Package flag somewhere in the hierarchy 1104 InvalidFlags |= !(HasPhysicalPackageBit || PackageNodeSeen); 842 1105 } else { 843 1106 InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != 0); … … 870 1133 @param [in,out] ProcContainerIndex Pointer to the current processor container 871 1134 index to be used as UID. 1135 @param [in] PackageNodeSeen A parent of the ProcNode has the physical package flag set. 872 1136 873 1137 @retval EFI_SUCCESS Success. … … 883 1147 IN CM_OBJECT_TOKEN NodeToken, 884 1148 IN AML_NODE_HANDLE ParentNode, 885 IN OUT UINT32 *ProcContainerIndex 1149 IN OUT UINT32 *ProcContainerIndex, 1150 IN BOOLEAN PackageNodeSeen 886 1151 ) 887 1152 { … … 893 1158 UINT32 Uid; 894 1159 UINT16 Name; 1160 BOOLEAN HasPhysicalPackageBit; 895 1161 896 1162 ASSERT (Generator != NULL); … … 915 1181 TRUE, 916 1182 Generator->ProcNodeList[Index].Token, 917 NodeToken 1183 NodeToken, 1184 PackageNodeSeen 918 1185 ); 919 1186 if (EFI_ERROR (Status)) { … … 948 1215 FALSE, 949 1216 Generator->ProcNodeList[Index].Token, 950 NodeToken 1217 NodeToken, 1218 PackageNodeSeen 951 1219 ); 952 1220 if (EFI_ERROR (Status)) { … … 989 1257 } 990 1258 1259 HasPhysicalPackageBit = (Generator->ProcNodeList[Index].Flags & EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) == 1260 EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL; 1261 991 1262 // Recursively continue creating an AML tree. 992 1263 Status = CreateAmlCpuTopologyTree ( … … 995 1266 Generator->ProcNodeList[Index].Token, 996 1267 ProcContainerNode, 997 ProcContainerIndex 1268 ProcContainerIndex, 1269 (PackageNodeSeen || HasPhysicalPackageBit) 998 1270 ); 999 1271 if (EFI_ERROR (Status)) { … … 1051 1323 CM_NULL_TOKEN, 1052 1324 ScopeNode, 1053 &ProcContainerIndex 1325 &ProcContainerIndex, 1326 FALSE 1054 1327 ); 1055 1328 if (EFI_ERROR (Status)) { … … 1127 1400 } 1128 1401 1402 if (GicCInfo->PsdToken != CM_NULL_TOKEN) { 1403 Status = CreateAmlPsdNode (Generator, CfgMgrProtocol, GicCInfo, CpuNode); 1404 if (EFI_ERROR (Status)) { 1405 ASSERT_EFI_ERROR (Status); 1406 return Status; 1407 } 1408 } 1409 1129 1410 // If a CPC info is associated with the 1130 1411 // GicCinfo, create an _CPC method returning them. 1131 if (GicCInfo ->CpcToken != CM_NULL_TOKEN) {1412 if (GicCInfo[Index].CpcToken != CM_NULL_TOKEN) { 1132 1413 Status = CreateAmlCpcNode (Generator, CfgMgrProtocol, &GicCInfo[Index], CpuNode); 1133 1414 if (EFI_ERROR (Status)) { 1134 1415 ASSERT_EFI_ERROR (Status); 1135 1416 break; 1417 } 1418 } 1419 1420 if (GicCInfo[Index].EtToken != CM_NULL_TOKEN) { 1421 Status = CreateAmlEtNode ( 1422 Generator, 1423 CfgMgrProtocol, 1424 &GicCInfo[Index], 1425 Index, 1426 CpuNode 1427 ); 1428 if (EFI_ERROR (Status)) { 1429 ASSERT_EFI_ERROR (Status); 1430 return Status; 1136 1431 } 1137 1432 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.h
r101291 r105670 2 2 SSDT Cpu Topology Table Generator. 3 3 4 Copyright (c) 2021 , Arm Limited. All rights reserved.<BR>4 Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.<BR> 5 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 6 7 7 @par Reference(s): 8 8 - ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors 9 - ACPI for CoreSight version 1.2 Platform Design Document 10 (https://developer.arm.com/documentation/den0067/a/?lang=en) 11 12 @par Glossary: 13 - ETE - Embedded Trace Extension. 14 - ETM - Embedded Trace Macrocell. 9 15 **/ 10 16 … … 49 55 /// HID for a processor device. 50 56 #define ACPI_HID_PROCESSOR_DEVICE "ACPI0007" 57 58 /// HID for a ETM/ETE device. 59 #define ACPI_HID_ET_DEVICE "ARMHC500" 51 60 52 61 /// HID for a processor container device. -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
r99404 r105670 541 541 switch (AddrMapInfo->SpaceCode) { 542 542 case PCI_SS_IO: 543 Status = AmlCodeGenRd DWordIo (543 Status = AmlCodeGenRdQWordIo ( 544 544 FALSE, 545 545 TRUE, … … 567 567 TRUE, 568 568 TRUE, 569 TRUE,569 AmlMemoryCacheable, 570 570 TRUE, 571 571 0, … … 576 576 0, 577 577 NULL, 578 0,578 AmlAddressRangeMemory, 579 579 TRUE, 580 580 CrsNode, … … 589 589 TRUE, 590 590 TRUE, 591 TRUE,591 AmlMemoryCacheable, 592 592 TRUE, 593 593 0, … … 598 598 0, 599 599 NULL, 600 0,600 AmlAddressRangeMemory, 601 601 TRUE, 602 602 CrsNode, … … 719 719 TRUE, 720 720 TRUE, 721 FALSE, // non-cacheable721 AmlMemoryNonCacheable, 722 722 TRUE, 723 723 0, … … 728 728 0, 729 729 NULL, 730 0,730 AmlAddressRangeMemory, 731 731 TRUE, 732 732 CrsNode, -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
r99404 r105670 3 3 # 4 4 # Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR> 5 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 # 6 7 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 69 70 AcpiHelperLib 70 71 BaseLib 72 MemoryAllocationLib 73 74 [FixedPcd] 75 gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdDevelopmentPlatformRelaxations 71 76 72 77 [BuildOptions] -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
r99404 r105670 2 2 AML Code Generation. 3 3 4 Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.<BR> 4 Copyright (c) 2020 - 2023, Arm Limited. All rights reserved.<BR> 5 Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 12 13 13 14 #include <AmlCoreInterface.h> 14 #include <A mlCpcInfo.h>15 #include <AcpiObjects.h> 15 16 #include <AmlEncoding/Aml.h> 16 17 #include <Api/AmlApiHelper.h> … … 870 871 } 871 872 873 /** AML code generation for a Name object node, containing a String. 874 875 AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is 876 equivalent of the following ASL code: 877 Name(_STR, Unicode ("String")) 878 879 @ingroup CodeGenApis 880 881 @param [in] NameString The new variable name. 882 Must be a NULL-terminated ASL NameString 883 e.g.: "DEV0", "DV15.DEV0", etc. 884 The input string is copied. 885 @param [in] String NULL terminated Unicode String to associate to the 886 NameString. 887 @param [in] ParentNode If provided, set ParentNode as the parent 888 of the node created. 889 @param [out] NewObjectNode If success, contains the created node. 890 891 @retval EFI_SUCCESS Success. 892 @retval EFI_INVALID_PARAMETER Invalid parameter. 893 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 894 **/ 895 EFI_STATUS 896 EFIAPI 897 AmlCodeGenNameUnicodeString ( 898 IN CONST CHAR8 *NameString, 899 IN CHAR16 *String, 900 IN AML_NODE_HANDLE ParentNode OPTIONAL, 901 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL 902 ) 903 { 904 EFI_STATUS Status; 905 AML_OBJECT_NODE *ObjectNode; 906 AML_DATA_NODE *DataNode; 907 908 if ((NameString == NULL) || 909 (String == NULL) || 910 ((ParentNode == NULL) && (NewObjectNode == NULL))) 911 { 912 ASSERT (0); 913 return EFI_INVALID_PARAMETER; 914 } 915 916 Status = AmlCodeGenBuffer (NULL, 0, &ObjectNode); 917 if (EFI_ERROR (Status)) { 918 ASSERT_EFI_ERROR (Status); 919 return Status; 920 } 921 922 Status = AmlCreateDataNode ( 923 EAmlNodeDataTypeRaw, 924 (CONST UINT8 *)String, 925 (UINT32)StrSize (String), 926 &DataNode 927 ); 928 if (EFI_ERROR (Status)) { 929 ASSERT_EFI_ERROR (Status); 930 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); 931 return Status; 932 } 933 934 Status = AmlVarListAddTail ( 935 (AML_NODE_HEADER *)ObjectNode, 936 (AML_NODE_HEADER *)DataNode 937 ); 938 if (EFI_ERROR (Status)) { 939 ASSERT_EFI_ERROR (Status); 940 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); 941 AmlDeleteTree ((AML_NODE_HANDLE)DataNode); 942 return Status; 943 } 944 945 Status = AmlCodeGenName ( 946 NameString, 947 ObjectNode, 948 ParentNode, 949 NewObjectNode 950 ); 951 if (EFI_ERROR (Status)) { 952 ASSERT (0); 953 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); 954 } 955 956 return Status; 957 } 958 872 959 /** Add a _PRT entry. 873 960 … … 1162 1249 Status = AmlCreateObjectNode ( 1163 1250 AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_DEVICE_OP), 1251 AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize), 1252 &ObjectNode 1253 ); 1254 if (EFI_ERROR (Status)) { 1255 ASSERT (0); 1256 goto error_handler1; 1257 } 1258 1259 Status = AmlCreateDataNode ( 1260 EAmlNodeDataTypeNameString, 1261 (UINT8 *)AmlNameString, 1262 AmlNameStringSize, 1263 &DataNode 1264 ); 1265 if (EFI_ERROR (Status)) { 1266 ASSERT (0); 1267 goto error_handler2; 1268 } 1269 1270 Status = AmlSetFixedArgument ( 1271 ObjectNode, 1272 EAmlParseIndexTerm0, 1273 (AML_NODE_HEADER *)DataNode 1274 ); 1275 if (EFI_ERROR (Status)) { 1276 ASSERT (0); 1277 AmlDeleteTree ((AML_NODE_HEADER *)DataNode); 1278 goto error_handler2; 1279 } 1280 1281 Status = LinkNode ( 1282 ObjectNode, 1283 ParentNode, 1284 NewObjectNode 1285 ); 1286 if (EFI_ERROR (Status)) { 1287 ASSERT (0); 1288 goto error_handler2; 1289 } 1290 1291 // Free AmlNameString before returning as it is copied 1292 // in the call to AmlCreateDataNode(). 1293 goto error_handler1; 1294 1295 error_handler2: 1296 if (ObjectNode != NULL) { 1297 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); 1298 } 1299 1300 error_handler1: 1301 if (AmlNameString != NULL) { 1302 FreePool (AmlNameString); 1303 } 1304 1305 return Status; 1306 } 1307 1308 /** AML code generation for a ThermalZone object node. 1309 1310 AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is 1311 equivalent of the following ASL code: 1312 ThermalZone(TZ00) {} 1313 1314 @ingroup CodeGenApis 1315 1316 @param [in] NameString The new ThermalZone's name. 1317 Must be a NULL-terminated ASL NameString 1318 e.g.: "DEV0", "DV15.DEV0", etc. 1319 The input string is copied. 1320 @param [in] ParentNode If provided, set ParentNode as the parent 1321 of the node created. 1322 @param [out] NewObjectNode If success, contains the created node. 1323 1324 @retval EFI_SUCCESS Success. 1325 @retval EFI_INVALID_PARAMETER Invalid parameter. 1326 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 1327 **/ 1328 EFI_STATUS 1329 EFIAPI 1330 AmlCodeGenThermalZone ( 1331 IN CONST CHAR8 *NameString, 1332 IN AML_NODE_HANDLE ParentNode OPTIONAL, 1333 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL 1334 ) 1335 { 1336 EFI_STATUS Status; 1337 AML_OBJECT_NODE *ObjectNode; 1338 AML_DATA_NODE *DataNode; 1339 CHAR8 *AmlNameString; 1340 UINT32 AmlNameStringSize; 1341 1342 if ((NameString == NULL) || 1343 ((ParentNode == NULL) && (NewObjectNode == NULL))) 1344 { 1345 ASSERT (0); 1346 return EFI_INVALID_PARAMETER; 1347 } 1348 1349 ObjectNode = NULL; 1350 DataNode = NULL; 1351 AmlNameString = NULL; 1352 1353 Status = ConvertAslNameToAmlName (NameString, &AmlNameString); 1354 if (EFI_ERROR (Status)) { 1355 ASSERT (0); 1356 return Status; 1357 } 1358 1359 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); 1360 if (EFI_ERROR (Status)) { 1361 ASSERT (0); 1362 goto error_handler1; 1363 } 1364 1365 Status = AmlCreateObjectNode ( 1366 AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP), 1164 1367 AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize), 1165 1368 &ObjectNode … … 1766 1969 } 1767 1970 1971 /** AML code generation for a Return object node, 1972 returning the object as an input NameString with a integer argument. 1973 1974 AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is 1975 equivalent of the following ASL code: 1976 Return(NAM1 (6)) 1977 1978 The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: 1979 DefReturn := ReturnOp ArgObject 1980 ReturnOp := 0xA4 1981 ArgObject := TermArg => DataRefObject 1982 1983 Thus, the ReturnNode must be evaluated as a DataRefObject. It can 1984 be a NameString referencing an object. As this CodeGen Api doesn't 1985 do semantic checking, it is strongly advised to check the AML bytecode 1986 generated by this function against an ASL compiler. 1987 1988 The ReturnNode must be generated inside a Method body scope. 1989 1990 @param [in] NameString The object referenced by this NameString 1991 is returned by the Return ASL statement. 1992 Must be a NULL-terminated ASL NameString 1993 e.g.: "NAM1", "_SB.NAM1", etc. 1994 The input string is copied. 1995 @param [in] Integer Argument to pass to the NameString 1996 @param [in] ParentNode If provided, set ParentNode as the parent 1997 of the node created. 1998 Must be a MethodOp node. 1999 @param [out] NewObjectNode If success, contains the created node. 2000 2001 @retval EFI_SUCCESS Success. 2002 @retval EFI_INVALID_PARAMETER Invalid parameter. 2003 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 2004 **/ 2005 STATIC 2006 EFI_STATUS 2007 EFIAPI 2008 AmlCodeGenReturnNameStringIntegerArgument ( 2009 IN CONST CHAR8 *NameString, 2010 IN UINT64 Integer, 2011 IN AML_NODE_HEADER *ParentNode OPTIONAL, 2012 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL 2013 ) 2014 { 2015 EFI_STATUS Status; 2016 AML_DATA_NODE *DataNode; 2017 AML_OBJECT_NODE *IntNode; 2018 CHAR8 *AmlNameString; 2019 UINT32 AmlNameStringSize; 2020 AML_OBJECT_NODE *ObjectNode; 2021 2022 DataNode = NULL; 2023 IntNode = NULL; 2024 ObjectNode = NULL; 2025 2026 Status = ConvertAslNameToAmlName (NameString, &AmlNameString); 2027 if (EFI_ERROR (Status)) { 2028 ASSERT (0); 2029 return Status; 2030 } 2031 2032 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); 2033 if (EFI_ERROR (Status)) { 2034 ASSERT (0); 2035 goto exit_handler; 2036 } 2037 2038 Status = AmlCodeGenInteger (Integer, &IntNode); 2039 if (EFI_ERROR (Status)) { 2040 ASSERT (0); 2041 goto exit_handler; 2042 } 2043 2044 Status = AmlCreateDataNode ( 2045 EAmlNodeDataTypeNameString, 2046 (UINT8 *)AmlNameString, 2047 AmlNameStringSize, 2048 &DataNode 2049 ); 2050 if (EFI_ERROR (Status)) { 2051 ASSERT (0); 2052 goto exit_handler1; 2053 } 2054 2055 // AmlCodeGenReturn() deletes DataNode if error. 2056 Status = AmlCodeGenReturn ( 2057 (AML_NODE_HEADER *)DataNode, 2058 ParentNode, 2059 &ObjectNode 2060 ); 2061 if (EFI_ERROR (Status)) { 2062 ASSERT (0); 2063 goto exit_handler1; 2064 } 2065 2066 Status = AmlVarListAddTail ( 2067 (AML_NODE_HANDLE)ObjectNode, 2068 (AML_NODE_HANDLE)IntNode 2069 ); 2070 if (EFI_ERROR (Status)) { 2071 // ObjectNode is already attached to ParentNode in AmlCodeGenReturn(), 2072 // so no need to free it here, it will be deleted when deleting the 2073 // ParentNode tree 2074 ASSERT (0); 2075 goto exit_handler1; 2076 } 2077 2078 if (NewObjectNode != 0) { 2079 *NewObjectNode = ObjectNode; 2080 } 2081 2082 goto exit_handler; 2083 2084 exit_handler1: 2085 if (IntNode != NULL) { 2086 AmlDeleteTree ((AML_NODE_HANDLE)IntNode); 2087 } 2088 2089 exit_handler: 2090 if (AmlNameString != NULL) { 2091 FreePool (AmlNameString); 2092 } 2093 2094 return Status; 2095 } 2096 1768 2097 /** AML code generation for a method returning a NameString. 1769 2098 … … 1845 2174 Status = AmlCodeGenReturnNameString ( 1846 2175 ReturnedNameString, 2176 (AML_NODE_HANDLE)MethodNode, 2177 NULL 2178 ); 2179 if (EFI_ERROR (Status)) { 2180 ASSERT (0); 2181 goto error_handler; 2182 } 2183 } 2184 2185 Status = LinkNode ( 2186 MethodNode, 2187 ParentNode, 2188 NewObjectNode 2189 ); 2190 if (EFI_ERROR (Status)) { 2191 ASSERT (0); 2192 goto error_handler; 2193 } 2194 2195 return Status; 2196 2197 error_handler: 2198 if (MethodNode != NULL) { 2199 AmlDeleteTree ((AML_NODE_HANDLE)MethodNode); 2200 } 2201 2202 return Status; 2203 } 2204 2205 /** AML code generation for a method returning a NameString that takes an 2206 integer argument. 2207 2208 AmlCodeGenMethodRetNameStringIntegerArgument ( 2209 "MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode 2210 ); 2211 is equivalent of the following ASL code: 2212 Method(MET0, 1, Serialized, 3) { 2213 Return (MET1 (5)) 2214 } 2215 2216 The ASL parameters "ReturnType" and "ParameterTypes" are not asked 2217 in this function. They are optional parameters in ASL. 2218 2219 @param [in] MethodNameString The new Method's name. 2220 Must be a NULL-terminated ASL NameString 2221 e.g.: "MET0", "_SB.MET0", etc. 2222 The input string is copied. 2223 @param [in] ReturnedNameString The name of the object returned by the 2224 method. Optional parameter, can be: 2225 - NULL (ignored). 2226 - A NULL-terminated ASL NameString. 2227 e.g.: "MET0", "_SB.MET0", etc. 2228 The input string is copied. 2229 @param [in] NumArgs Number of arguments. 2230 Must be 0 <= NumArgs <= 6. 2231 @param [in] IsSerialized TRUE is equivalent to Serialized. 2232 FALSE is equivalent to NotSerialized. 2233 Default is NotSerialized in ASL spec. 2234 @param [in] SyncLevel Synchronization level for the method. 2235 Must be 0 <= SyncLevel <= 15. 2236 Default is 0 in ASL. 2237 @param [in] IntegerArgument Argument to pass to the NameString. 2238 @param [in] ParentNode If provided, set ParentNode as the parent 2239 of the node created. 2240 @param [out] NewObjectNode If success, contains the created node. 2241 2242 @retval EFI_SUCCESS Success. 2243 @retval EFI_INVALID_PARAMETER Invalid parameter. 2244 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 2245 **/ 2246 EFI_STATUS 2247 EFIAPI 2248 AmlCodeGenMethodRetNameStringIntegerArgument ( 2249 IN CONST CHAR8 *MethodNameString, 2250 IN CONST CHAR8 *ReturnedNameString OPTIONAL, 2251 IN UINT8 NumArgs, 2252 IN BOOLEAN IsSerialized, 2253 IN UINT8 SyncLevel, 2254 IN UINT64 IntegerArgument, 2255 IN AML_NODE_HANDLE ParentNode OPTIONAL, 2256 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL 2257 ) 2258 { 2259 EFI_STATUS Status; 2260 AML_OBJECT_NODE_HANDLE MethodNode; 2261 2262 if ((MethodNameString == NULL) || 2263 ((ParentNode == NULL) && (NewObjectNode == NULL))) 2264 { 2265 ASSERT (0); 2266 return EFI_INVALID_PARAMETER; 2267 } 2268 2269 // Create a Method named MethodNameString. 2270 Status = AmlCodeGenMethod ( 2271 MethodNameString, 2272 NumArgs, 2273 IsSerialized, 2274 SyncLevel, 2275 NULL, 2276 &MethodNode 2277 ); 2278 if (EFI_ERROR (Status)) { 2279 ASSERT (0); 2280 return Status; 2281 } 2282 2283 // Return ReturnedNameString if provided. 2284 if (ReturnedNameString != NULL) { 2285 Status = AmlCodeGenReturnNameStringIntegerArgument ( 2286 ReturnedNameString, 2287 IntegerArgument, 1847 2288 (AML_NODE_HANDLE)MethodNode, 1848 2289 NULL … … 3084 3525 3085 3526 // Revision 3 per ACPI 6.4 specification 3086 if (CpcInfo->Revision == 3) {3527 if (CpcInfo->Revision == EFI_ACPI_6_5_AML_CPC_REVISION) { 3087 3528 // NumEntries 23 per ACPI 6.4 specification 3088 3529 NumberOfEntries = 23; … … 3090 3531 ASSERT (0); 3091 3532 return EFI_INVALID_PARAMETER; 3533 } 3534 3535 /// The following fields are theoretically mandatory, but not supported 3536 /// by some platforms. 3537 /// - PerformanceLimitedRegister 3538 /// - ReferencePerformanceCounterRegister 3539 /// - DeliveredPerformanceCounterRegister 3540 /// Warn if BIT0 in PcdDevelopmentPlatformRelaxations is set, otherwise 3541 /// return an error. 3542 if (IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister) || 3543 IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister) || 3544 IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister)) 3545 { 3546 if ((PcdGet64 (PcdDevelopmentPlatformRelaxations) & BIT0) != 0) { 3547 DEBUG (( 3548 DEBUG_WARN, 3549 "Missing PerformanceLimited|ReferencePerformanceCounter|" 3550 "DeliveredPerformanceCounter field in _CPC object\n" 3551 )); 3552 } else { 3553 ASSERT (0); 3554 return EFI_INVALID_PARAMETER; 3555 } 3092 3556 } 3093 3557 … … 3100 3564 (IsNullGenericAddress (&CpcInfo->LowestPerformanceBuffer) && 3101 3565 (CpcInfo->LowestPerformanceInteger == 0)) || 3102 IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister) || 3103 IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister) || 3104 IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister) || 3105 IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister)) 3566 IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister)) 3106 3567 { 3107 3568 ASSERT (0); … … 3326 3787 return Status; 3327 3788 } 3789 3790 /** AML code generation to add a NameString to the package in a named node. 3791 3792 3793 @param [in] NameString NameString to add 3794 @param [in] NamedNode Node to add the string to the included package. 3795 3796 @retval EFI_SUCCESS Success. 3797 @retval EFI_INVALID_PARAMETER Invalid parameter. 3798 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 3799 **/ 3800 EFI_STATUS 3801 EFIAPI 3802 AmlAddNameStringToNamedPackage ( 3803 IN CHAR8 *NameString, 3804 IN AML_OBJECT_NODE_HANDLE NamedNode 3805 ) 3806 { 3807 EFI_STATUS Status; 3808 AML_DATA_NODE *DataNode; 3809 CHAR8 *AmlNameString; 3810 UINT32 AmlNameStringSize; 3811 AML_OBJECT_NODE_HANDLE PackageNode; 3812 3813 DataNode = NULL; 3814 3815 if ((NamedNode == NULL) || 3816 (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject) || 3817 (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0))) 3818 { 3819 ASSERT (0); 3820 return EFI_INVALID_PARAMETER; 3821 } 3822 3823 PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( 3824 NamedNode, 3825 EAmlParseIndexTerm1 3826 ); 3827 if ((PackageNode == NULL) || 3828 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) || 3829 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) 3830 { 3831 ASSERT (0); 3832 return EFI_INVALID_PARAMETER; 3833 } 3834 3835 Status = ConvertAslNameToAmlName (NameString, &AmlNameString); 3836 if (EFI_ERROR (Status)) { 3837 ASSERT (0); 3838 return Status; 3839 } 3840 3841 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); 3842 if (EFI_ERROR (Status)) { 3843 ASSERT (0); 3844 goto exit_handler; 3845 } 3846 3847 Status = AmlCreateDataNode ( 3848 EAmlNodeDataTypeNameString, 3849 (UINT8 *)AmlNameString, 3850 AmlNameStringSize, 3851 &DataNode 3852 ); 3853 if (EFI_ERROR (Status)) { 3854 ASSERT (0); 3855 goto exit_handler; 3856 } 3857 3858 Status = AmlVarListAddTail ( 3859 (AML_NODE_HANDLE)PackageNode, 3860 (AML_NODE_HANDLE)DataNode 3861 ); 3862 if (EFI_ERROR (Status)) { 3863 AmlDeleteTree ((AML_NODE_HANDLE)DataNode); 3864 } 3865 3866 exit_handler: 3867 if (AmlNameString != NULL) { 3868 FreePool (AmlNameString); 3869 } 3870 3871 return Status; 3872 } 3873 3874 /** Add an integer value to the named package node. 3875 3876 AmlCodeGenNamePackage ("_CID", NULL, &PackageNode); 3877 AmlGetEisaIdFromString ("PNP0A03", &EisaId); 3878 AmlAddIntegerToNamedPackage (EisaId, NameNode); 3879 AmlGetEisaIdFromString ("PNP0A08", &EisaId); 3880 AmlAddIntegerToNamedPackage (EisaId, NameNode); 3881 3882 equivalent of the following ASL code: 3883 Name (_CID, Package (0x02) // _CID: Compatible ID 3884 { 3885 EisaId ("PNP0A03"), 3886 EisaId ("PNP0A08") 3887 }) 3888 3889 The package is added at the tail of the list of the input package node 3890 name: 3891 Name ("NamePackageNode", Package () { 3892 [Pre-existing package entries], 3893 [Newly created integer entry] 3894 }) 3895 3896 3897 @ingroup CodeGenApis 3898 3899 @param [in] Integer Integer value that need to be added to package node. 3900 @param [in, out] NameNode Package named node to add the object to. 3901 3902 @retval EFI_SUCCESS Success. 3903 @retval EFI_INVALID_PARAMETER Invalid parameter. 3904 @retval Others Error occurred during the operation. 3905 **/ 3906 EFI_STATUS 3907 EFIAPI 3908 AmlAddIntegerToNamedPackage ( 3909 IN UINT32 Integer, 3910 IN OUT AML_OBJECT_NODE_HANDLE NameNode 3911 ) 3912 { 3913 EFI_STATUS Status; 3914 AML_OBJECT_NODE *PackageNode; 3915 3916 if (NameNode == NULL) { 3917 ASSERT_EFI_ERROR (FALSE); 3918 return EFI_INVALID_PARAMETER; 3919 } 3920 3921 PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( 3922 NameNode, 3923 EAmlParseIndexTerm1 3924 ); 3925 if ((PackageNode == NULL) || 3926 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) || 3927 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) 3928 { 3929 ASSERT_EFI_ERROR (FALSE); 3930 return EFI_INVALID_PARAMETER; 3931 } 3932 3933 Status = AmlAddRegisterOrIntegerToPackage (NULL, Integer, PackageNode); 3934 if (EFI_ERROR (Status)) { 3935 ASSERT_EFI_ERROR (Status); 3936 } 3937 3938 return Status; 3939 } 3940 3941 /** AML code generation to invoke/call another method. 3942 3943 This method is a subset implementation of MethodInvocation 3944 defined in the ACPI specification 6.5, 3945 section 20.2.5 "Term Objects Encoding". 3946 Added integer, string, ArgObj and LocalObj support. 3947 3948 Example 1: 3949 AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode); 3950 is equivalent to the following ASL code: 3951 MET0 (); 3952 3953 Example 2: 3954 AML_METHOD_PARAM Param[4]; 3955 Param[0].Data.Integer = 0x100; 3956 Param[0].Type = AmlMethodParamTypeInteger; 3957 Param[1].Data.Buffer = "TEST"; 3958 Param[1].Type = AmlMethodParamTypeString; 3959 Param[2].Data.Arg = 0; 3960 Param[2].Type = AmlMethodParamTypeArg; 3961 Param[3].Data.Local = 2; 3962 Param[3].Type = AmlMethodParamTypeLocal; 3963 AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode); 3964 3965 is equivalent to the following ASL code: 3966 MET0 (0x100, "TEST", Arg0, Local2); 3967 3968 Example 3: 3969 AML_METHOD_PARAM Param[2]; 3970 Param[0].Data.Arg = 0; 3971 Param[0].Type = AmlMethodParamTypeArg; 3972 Param[1].Data.Integer = 0x100; 3973 Param[1].Type = AmlMethodParamTypeInteger; 3974 AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, 3975 ParentNode, &MethodNode); 3976 AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode); 3977 3978 is equivalent to the following ASL code: 3979 Method (MET2, 2, Serialized) 3980 { 3981 MET3 (Arg0, 0x0100) 3982 } 3983 3984 @param [in] MethodNameString The method name to be called or invoked. 3985 @param [in] NumArgs Number of arguments to be passed, 3986 0 to 7 are permissible values. 3987 @param [in] Parameters Contains the parameter data. 3988 @param [in] ParentNode The parent node to which the method invocation 3989 nodes are attached. 3990 3991 @retval EFI_SUCCESS Success. 3992 @retval EFI_INVALID_PARAMETER Invalid parameter. 3993 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 3994 **/ 3995 EFI_STATUS 3996 EFIAPI 3997 AmlCodeGenInvokeMethod ( 3998 IN CONST CHAR8 *MethodNameString, 3999 IN UINT8 NumArgs, 4000 IN AML_METHOD_PARAM *Parameters OPTIONAL, 4001 IN AML_NODE_HANDLE ParentNode 4002 ) 4003 { 4004 EFI_STATUS Status; 4005 UINT8 Index; 4006 CHAR8 *AmlNameString; 4007 UINT32 AmlNameStringSize; 4008 AML_DATA_NODE *DataNode; 4009 AML_OBJECT_NODE *ObjectNode; 4010 AML_NODE_HANDLE *NodeStream; 4011 4012 if ((MethodNameString == NULL) || (ParentNode == NULL)) { 4013 ASSERT (0); 4014 return EFI_INVALID_PARAMETER; 4015 } 4016 4017 if ((NumArgs > 7) || 4018 ((Parameters == NULL) && (NumArgs > 0))) 4019 { 4020 ASSERT (0); 4021 return EFI_INVALID_PARAMETER; 4022 } 4023 4024 /// Allocate space to store methodname, object, data node pointers 4025 NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs + 1)); 4026 if (NodeStream == NULL) { 4027 ASSERT (0); 4028 return EFI_OUT_OF_RESOURCES; 4029 } 4030 4031 /// Create a called or invoked method name string. 4032 Status = ConvertAslNameToAmlName (MethodNameString, &AmlNameString); 4033 if (EFI_ERROR (Status)) { 4034 ASSERT_EFI_ERROR (Status); 4035 goto exit_handler; 4036 } 4037 4038 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); 4039 if (EFI_ERROR (Status)) { 4040 ASSERT_EFI_ERROR (Status); 4041 FreePool (AmlNameString); 4042 goto exit_handler; 4043 } 4044 4045 DataNode = NULL; 4046 Status = AmlCreateDataNode ( 4047 EAmlNodeDataTypeNameString, 4048 (UINT8 *)AmlNameString, 4049 AmlNameStringSize, 4050 &DataNode 4051 ); 4052 FreePool (AmlNameString); 4053 if (EFI_ERROR (Status)) { 4054 ASSERT_EFI_ERROR (Status); 4055 goto exit_handler; 4056 } 4057 4058 NodeStream[0] = (AML_NODE_HANDLE)DataNode; 4059 4060 if (Parameters != NULL) { 4061 /// Validate and convert the Parameters to the stream of nodes. 4062 for (Index = 0; Index < NumArgs; Index++) { 4063 ObjectNode = NULL; 4064 switch (Parameters[Index].Type) { 4065 case AmlMethodParamTypeInteger: 4066 Status = AmlCodeGenInteger ( 4067 Parameters[Index].Data.Integer, 4068 &ObjectNode 4069 ); 4070 if (EFI_ERROR (Status)) { 4071 ASSERT_EFI_ERROR (Status); 4072 goto exit_handler; 4073 } 4074 4075 break; 4076 case AmlMethodParamTypeString: 4077 if (Parameters[Index].Data.Buffer == NULL) { 4078 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); 4079 Status = EFI_INVALID_PARAMETER; 4080 goto exit_handler; 4081 } 4082 4083 Status = AmlCodeGenString ( 4084 Parameters[Index].Data.Buffer, 4085 &ObjectNode 4086 ); 4087 if (EFI_ERROR (Status)) { 4088 ASSERT_EFI_ERROR (Status); 4089 goto exit_handler; 4090 } 4091 4092 break; 4093 case AmlMethodParamTypeArg: 4094 if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) { 4095 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); 4096 Status = EFI_INVALID_PARAMETER; 4097 goto exit_handler; 4098 } 4099 4100 Status = AmlCreateObjectNode ( 4101 AmlGetByteEncodingByOpCode ( 4102 AML_ARG0 + Parameters[Index].Data.Arg, 4103 0 4104 ), 4105 0, 4106 &ObjectNode 4107 ); 4108 if (EFI_ERROR (Status)) { 4109 ASSERT_EFI_ERROR (Status); 4110 goto exit_handler; 4111 } 4112 4113 break; 4114 case AmlMethodParamTypeLocal: 4115 if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) { 4116 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); 4117 Status = EFI_INVALID_PARAMETER; 4118 goto exit_handler; 4119 } 4120 4121 Status = AmlCreateObjectNode ( 4122 AmlGetByteEncodingByOpCode ( 4123 AML_LOCAL0 + Parameters[Index].Data.Local, 4124 0 4125 ), 4126 0, 4127 &ObjectNode 4128 ); 4129 if (EFI_ERROR (Status)) { 4130 ASSERT_EFI_ERROR (Status); 4131 goto exit_handler; 4132 } 4133 4134 break; 4135 default: 4136 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); 4137 Status = EFI_INVALID_PARAMETER; 4138 goto exit_handler; 4139 } // switch 4140 4141 // Link the Object Node in the Node Stream. 4142 NodeStream[Index + 1] = (AML_NODE_HANDLE)ObjectNode; 4143 } // for 4144 } 4145 4146 /// Index <= NumArgs, because an additional method name was added. 4147 for (Index = 0; Index <= NumArgs; Index++) { 4148 Status = AmlVarListAddTail ( 4149 (AML_NODE_HANDLE)ParentNode, 4150 (AML_NODE_HANDLE)NodeStream[Index] 4151 ); 4152 if (EFI_ERROR (Status)) { 4153 ASSERT_EFI_ERROR (Status); 4154 goto exit_handler_detach; 4155 } 4156 } 4157 4158 FreePool (NodeStream); 4159 return Status; 4160 4161 exit_handler_detach: 4162 /// The index contains the last successful node attached. 4163 for ( ; Index > 0; Index--) { 4164 /// Index contains the node number that is failed for AmlVarListAddTail(). 4165 /// Hence, start detaching from the last successful 4166 AmlDetachNode (NodeStream[Index-1]); 4167 } 4168 4169 exit_handler: 4170 /// Index <= NumArgs, because an additional method name was added. 4171 for (Index = 0; Index <= NumArgs; Index++) { 4172 if (NodeStream[Index] != 0) { 4173 AmlDeleteTree (NodeStream[Index]); 4174 } 4175 } 4176 4177 FreePool (NodeStream); 4178 return Status; 4179 } 4180 4181 /** Create a _PSD node. 4182 4183 Creates and optionally adds the following node 4184 Name(_PSD, Package() 4185 { 4186 NumEntries, // Integer 4187 Revision, // Integer 4188 Domain, // Integer 4189 CoordType, // Integer 4190 NumProc, // Integer 4191 }) 4192 4193 Cf. ACPI 6.5, s8.4.5.5 _PSD (P-State Dependency) 4194 4195 @ingroup CodeGenApis 4196 4197 @param [in] PsdInfo PsdInfo object 4198 @param [in] ParentNode If provided, set ParentNode as the parent 4199 of the node created. 4200 @param [out] NewPsdNode If success and provided, contains the created node. 4201 4202 @retval EFI_SUCCESS The function completed successfully. 4203 @retval EFI_INVALID_PARAMETER Invalid parameter. 4204 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 4205 **/ 4206 EFI_STATUS 4207 EFIAPI 4208 AmlCreatePsdNode ( 4209 IN AML_PSD_INFO *PsdInfo, 4210 IN AML_NODE_HANDLE ParentNode OPTIONAL, 4211 OUT AML_OBJECT_NODE_HANDLE *NewPsdNode OPTIONAL 4212 ) 4213 { 4214 EFI_STATUS Status; 4215 AML_OBJECT_NODE_HANDLE PsdNode; 4216 AML_OBJECT_NODE_HANDLE PsdPackage; 4217 AML_OBJECT_NODE_HANDLE IntegerNode; 4218 UINT32 NumberOfEntries; 4219 4220 if ((PsdInfo == NULL) || 4221 ((ParentNode == NULL) && (NewPsdNode == NULL))) 4222 { 4223 Status = EFI_INVALID_PARAMETER; 4224 ASSERT_EFI_ERROR (Status); 4225 return Status; 4226 } 4227 4228 // Revision 3 per ACPI 6.5 specification 4229 if (PsdInfo->Revision == EFI_ACPI_6_5_AML_PSD_REVISION) { 4230 // NumEntries 5 per ACPI 6.5 specification 4231 NumberOfEntries = 5; 4232 } else { 4233 Status = EFI_INVALID_PARAMETER; 4234 ASSERT_EFI_ERROR (Status); 4235 return Status; 4236 } 4237 4238 if (((PsdInfo->CoordType != ACPI_AML_COORD_TYPE_SW_ALL) && 4239 (PsdInfo->CoordType != ACPI_AML_COORD_TYPE_SW_ANY) && 4240 (PsdInfo->CoordType != ACPI_AML_COORD_TYPE_HW_ALL)) || 4241 (PsdInfo->NumProc == 0)) 4242 { 4243 Status = EFI_INVALID_PARAMETER; 4244 ASSERT_EFI_ERROR (Status); 4245 return Status; 4246 } 4247 4248 Status = AmlCodeGenNamePackage ("_PSD", NULL, &PsdNode); 4249 if (EFI_ERROR (Status)) { 4250 ASSERT_EFI_ERROR (Status); 4251 return Status; 4252 } 4253 4254 // Get the Package object node of the _PSD node, 4255 // which is the 2nd fixed argument (i.e. index 1). 4256 PsdPackage = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( 4257 PsdNode, 4258 EAmlParseIndexTerm1 4259 ); 4260 if ((PsdPackage == NULL) || 4261 (AmlGetNodeType ((AML_NODE_HANDLE)PsdPackage) != EAmlNodeObject) || 4262 (!AmlNodeHasOpCode (PsdPackage, AML_PACKAGE_OP, 0))) 4263 { 4264 Status = EFI_INVALID_PARAMETER; 4265 ASSERT_EFI_ERROR (Status); 4266 goto error_handler; 4267 } 4268 4269 // NumEntries 4270 Status = AmlCodeGenInteger (NumberOfEntries, &IntegerNode); 4271 if (EFI_ERROR (Status)) { 4272 ASSERT_EFI_ERROR (Status); 4273 goto error_handler; 4274 } 4275 4276 Status = AmlVarListAddTail ( 4277 (AML_NODE_HANDLE)PsdPackage, 4278 (AML_NODE_HANDLE)IntegerNode 4279 ); 4280 if (EFI_ERROR (Status)) { 4281 ASSERT_EFI_ERROR (Status); 4282 FreePool (IntegerNode); 4283 goto error_handler; 4284 } 4285 4286 // Revision 4287 Status = AmlCodeGenInteger (PsdInfo->Revision, &IntegerNode); 4288 if (EFI_ERROR (Status)) { 4289 ASSERT_EFI_ERROR (Status); 4290 goto error_handler; 4291 } 4292 4293 Status = AmlVarListAddTail ( 4294 (AML_NODE_HANDLE)PsdPackage, 4295 (AML_NODE_HANDLE)IntegerNode 4296 ); 4297 if (EFI_ERROR (Status)) { 4298 ASSERT_EFI_ERROR (Status); 4299 FreePool (IntegerNode); 4300 goto error_handler; 4301 } 4302 4303 // Domain 4304 Status = AmlCodeGenInteger (PsdInfo->Domain, &IntegerNode); 4305 if (EFI_ERROR (Status)) { 4306 ASSERT_EFI_ERROR (Status); 4307 goto error_handler; 4308 } 4309 4310 Status = AmlVarListAddTail ( 4311 (AML_NODE_HANDLE)PsdPackage, 4312 (AML_NODE_HANDLE)IntegerNode 4313 ); 4314 if (EFI_ERROR (Status)) { 4315 ASSERT_EFI_ERROR (Status); 4316 FreePool (IntegerNode); 4317 goto error_handler; 4318 } 4319 4320 // CoordType 4321 Status = AmlCodeGenInteger (PsdInfo->CoordType, &IntegerNode); 4322 if (EFI_ERROR (Status)) { 4323 ASSERT_EFI_ERROR (Status); 4324 goto error_handler; 4325 } 4326 4327 Status = AmlVarListAddTail ( 4328 (AML_NODE_HANDLE)PsdPackage, 4329 (AML_NODE_HANDLE)IntegerNode 4330 ); 4331 if (EFI_ERROR (Status)) { 4332 ASSERT_EFI_ERROR (Status); 4333 FreePool (IntegerNode); 4334 goto error_handler; 4335 } 4336 4337 // Num Processors 4338 Status = AmlCodeGenInteger (PsdInfo->NumProc, &IntegerNode); 4339 if (EFI_ERROR (Status)) { 4340 ASSERT_EFI_ERROR (Status); 4341 goto error_handler; 4342 } 4343 4344 Status = AmlVarListAddTail ( 4345 (AML_NODE_HANDLE)PsdPackage, 4346 (AML_NODE_HANDLE)IntegerNode 4347 ); 4348 if (EFI_ERROR (Status)) { 4349 ASSERT_EFI_ERROR (Status); 4350 FreePool (IntegerNode); 4351 goto error_handler; 4352 } 4353 4354 Status = LinkNode (PsdNode, ParentNode, NewPsdNode); 4355 if (EFI_ERROR (Status)) { 4356 ASSERT_EFI_ERROR (Status); 4357 goto error_handler; 4358 } 4359 4360 return Status; 4361 4362 error_handler: 4363 AmlDeleteTree ((AML_NODE_HANDLE)PsdNode); 4364 return Status; 4365 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
r99404 r105670 3 3 4 4 Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR> 5 Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 571 572 IN BOOLEAN IsMinFixed, 572 573 IN BOOLEAN IsMaxFixed, 573 IN UINT8Cacheable,574 IN AML_MEMORY_ATTRIBUTES_MEM Cacheable, 574 575 IN BOOLEAN IsReadWrite, 575 576 IN UINT32 AddressGranularity, … … 580 581 IN UINT8 ResourceSourceIndex, 581 582 IN CONST CHAR8 *ResourceSource, 582 IN UINT8MemoryRangeType,583 IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType, 583 584 IN BOOLEAN IsTypeStatic, 584 585 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL … … 848 849 IN BOOLEAN IsMaxFixed, 849 850 IN BOOLEAN IsPosDecode, 850 IN UINT 32AddressGranularity,851 IN UINT 32AddressMinimum,852 IN UINT 32AddressMaximum,853 IN UINT 32AddressTranslation,854 IN UINT 32RangeLength,851 IN UINT16 AddressGranularity, 852 IN UINT16 AddressMinimum, 853 IN UINT16 AddressMaximum, 854 IN UINT16 AddressTranslation, 855 IN UINT16 RangeLength, 855 856 IN UINT8 ResourceSourceIndex, 856 857 IN CONST CHAR8 *ResourceSource, … … 867 868 IsMaxFixed, 868 869 0, 870 AddressGranularity, 871 AddressMinimum, 872 AddressMaximum, 873 AddressTranslation, 874 RangeLength, 875 ResourceSourceIndex, 876 ResourceSource, 877 NameOpNode, 878 NewRdNode 879 ); 880 } 881 882 /** Code generation for the "WordIO ()" ASL function. 883 884 The Resource Data effectively created is a Word Address Space Resource 885 Data. Cf ACPI 6.5: 886 - s6.4.3.5.3 "Word Address Space Descriptor". 887 888 The created resource data node can be: 889 - appended to the list of resource data elements of the NameOpNode. 890 In such case NameOpNode must be defined by a the "Name ()" ASL statement 891 and initially contain a "ResourceTemplate ()". 892 - returned through the NewRdNode parameter. 893 894 @param [in] IsResourceConsumer ResourceUsage parameter. 895 @param [in] IsMinFixed Minimum address is fixed. 896 @param [in] IsMaxFixed Maximum address is fixed. 897 @param [in] IsPosDecode Decode parameter 898 @param [in] IsaRanges Possible values are: 899 0-Reserved 900 1-NonISAOnly 901 2-ISAOnly 902 3-EntireRange 903 @param [in] AddressGranularity Address granularity. 904 @param [in] AddressMinimum Minimum address. 905 @param [in] AddressMaximum Maximum address. 906 @param [in] AddressTranslation Address translation. 907 @param [in] RangeLength Range length. 908 @param [in] ResourceSourceIndex Resource Source index. 909 Not supported. Must be 0. 910 @param [in] ResourceSource Resource Source. 911 Not supported. Must be NULL. 912 @param [in] IsDenseTranslation TranslationDensity parameter. 913 @param [in] IsTypeStatic TranslationType parameter. 914 @param [in] NameOpNode NameOp object node defining a named object. 915 If provided, append the new resource data 916 node to the list of resource data elements 917 of this node. 918 @param [out] NewRdNode If provided and success, 919 contain the created node. 920 921 @retval EFI_SUCCESS The function completed successfully. 922 @retval EFI_INVALID_PARAMETER Invalid parameter. 923 @retval EFI_OUT_OF_RESOURCES Could not allocate memory. 924 **/ 925 EFI_STATUS 926 EFIAPI 927 AmlCodeGenRdWordIo ( 928 IN BOOLEAN IsResourceConsumer, 929 IN BOOLEAN IsMinFixed, 930 IN BOOLEAN IsMaxFixed, 931 IN BOOLEAN IsPosDecode, 932 IN UINT8 IsaRanges, 933 IN UINT16 AddressGranularity, 934 IN UINT16 AddressMinimum, 935 IN UINT16 AddressMaximum, 936 IN UINT16 AddressTranslation, 937 IN UINT16 RangeLength, 938 IN UINT8 ResourceSourceIndex, 939 IN CONST CHAR8 *ResourceSource, 940 IN BOOLEAN IsDenseTranslation, 941 IN BOOLEAN IsTypeStatic, 942 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL 943 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL 944 ) 945 { 946 return AmlCodeGenRdWordSpace ( 947 ACPI_ADDRESS_SPACE_TYPE_IO, 948 IsResourceConsumer, 949 IsPosDecode, 950 IsMinFixed, 951 IsMaxFixed, 952 RdIoRangeSpecificFlags ( 953 IsaRanges, 954 IsDenseTranslation, 955 IsTypeStatic 956 ), 869 957 AddressGranularity, 870 958 AddressMinimum, … … 1011 1099 1012 1100 return LinkRdNode (RdNode, NameOpNode, NewRdNode); 1101 } 1102 1103 /** Code generation for the "QWordIO ()" ASL function. 1104 1105 The Resource Data effectively created is a QWord Address Space Resource 1106 Data. Cf ACPI 6.4: 1107 - s6.4.3.5.1 "QWord Address Space Descriptor". 1108 - s19.6.109 "QWordIO". 1109 1110 The created resource data node can be: 1111 - appended to the list of resource data elements of the NameOpNode. 1112 In such case NameOpNode must be defined by a the "Name ()" ASL statement 1113 and initially contain a "ResourceTemplate ()". 1114 - returned through the NewRdNode parameter. 1115 1116 See ACPI 6.4 spec, s19.6.109 for more. 1117 1118 @param [in] IsResourceConsumer ResourceUsage parameter. 1119 @param [in] IsMinFixed Minimum address is fixed. 1120 @param [in] IsMaxFixed Maximum address is fixed. 1121 @param [in] IsPosDecode Decode parameter 1122 @param [in] IsaRanges Possible values are: 1123 0-Reserved 1124 1-NonISAOnly 1125 2-ISAOnly 1126 3-EntireRange 1127 @param [in] AddressGranularity Address granularity. 1128 @param [in] AddressMinimum Minimum address. 1129 @param [in] AddressMaximum Maximum address. 1130 @param [in] AddressTranslation Address translation. 1131 @param [in] RangeLength Range length. 1132 @param [in] ResourceSourceIndex Resource Source index. 1133 Unused. Must be 0. 1134 @param [in] ResourceSource Resource Source. 1135 Unused. Must be NULL. 1136 @param [in] IsDenseTranslation TranslationDensity parameter. 1137 @param [in] IsTypeStatic TranslationType parameter. 1138 @param [in] NameOpNode NameOp object node defining a named object. 1139 If provided, append the new resource data 1140 node to the list of resource data elements 1141 of this node. 1142 @param [out] NewRdNode If provided and success, 1143 contain the created node. 1144 1145 @retval EFI_SUCCESS The function completed successfully. 1146 @retval EFI_INVALID_PARAMETER Invalid parameter. 1147 @retval EFI_OUT_OF_RESOURCES Could not allocate memory. 1148 **/ 1149 EFI_STATUS 1150 EFIAPI 1151 AmlCodeGenRdQWordIo ( 1152 IN BOOLEAN IsResourceConsumer, 1153 IN BOOLEAN IsMinFixed, 1154 IN BOOLEAN IsMaxFixed, 1155 IN BOOLEAN IsPosDecode, 1156 IN UINT8 IsaRanges, 1157 IN UINT64 AddressGranularity, 1158 IN UINT64 AddressMinimum, 1159 IN UINT64 AddressMaximum, 1160 IN UINT64 AddressTranslation, 1161 IN UINT64 RangeLength, 1162 IN UINT8 ResourceSourceIndex, 1163 IN CONST CHAR8 *ResourceSource, 1164 IN BOOLEAN IsDenseTranslation, 1165 IN BOOLEAN IsTypeStatic, 1166 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL 1167 OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL 1168 ) 1169 { 1170 return AmlCodeGenRdQWordSpace ( 1171 ACPI_ADDRESS_SPACE_TYPE_IO, 1172 IsResourceConsumer, 1173 IsPosDecode, 1174 IsMinFixed, 1175 IsMaxFixed, 1176 RdIoRangeSpecificFlags ( 1177 IsaRanges, 1178 IsDenseTranslation, 1179 IsTypeStatic 1180 ), 1181 AddressGranularity, 1182 AddressMinimum, 1183 AddressMaximum, 1184 AddressTranslation, 1185 RangeLength, 1186 ResourceSourceIndex, 1187 ResourceSource, 1188 NameOpNode, 1189 NewRdNode 1190 ); 1013 1191 } 1014 1192 … … 1072 1250 IN BOOLEAN IsMinFixed, 1073 1251 IN BOOLEAN IsMaxFixed, 1074 IN UINT8Cacheable,1252 IN AML_MEMORY_ATTRIBUTES_MEM Cacheable, 1075 1253 IN BOOLEAN IsReadWrite, 1076 1254 IN UINT64 AddressGranularity, … … 1081 1259 IN UINT8 ResourceSourceIndex, 1082 1260 IN CONST CHAR8 *ResourceSource, 1083 IN UINT8MemoryRangeType,1261 IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType, 1084 1262 IN BOOLEAN IsTypeStatic, 1085 1263 IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
r99404 r105670 101 101 typedef 102 102 EFI_STATUS 103 EFIAPI 104 (*AML_PARSE_FUNCTION) ( 103 (EFIAPI *AML_PARSE_FUNCTION)( 105 104 IN CONST AML_NODE_HEADER *Node, 106 105 IN AML_PARSE_FORMAT ExpectedFormat, -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c
r99404 r105670 3 3 4 4 Copyright (c) 2021, Arm Limited. All rights reserved.<BR> 5 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 288 289 CmObjDesc = &This->ArmCmObjArray[ArmObjIndex]; 289 290 CmObjDesc->ObjectId = CmObjId; 290 CmObjDesc->Size = Size;291 CmObjDesc->Count = Count;291 CmObjDesc->Size = (UINT32)Size; 292 CmObjDesc->Count = (UINT32)Count; 292 293 CmObjDesc->Data = GroupedData; 293 294 … … 341 342 // - Add the Token/CmObj binding to the token mapper. 342 343 for (ArmObjIndex = 0; ArmObjIndex < EArmObjMax; ArmObjIndex++) { 343 Status = GroupCmObjNodes (This, ArmObjIndex);344 Status = GroupCmObjNodes (This, (UINT32)ArmObjIndex); 344 345 if (EFI_ERROR (Status)) { 345 346 ASSERT (0); -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
r99404 r105670 2 2 SSDT Serial Port Fixup Library. 3 3 4 Copyright (c) 2019 - 202 1, Arm Limited. All rights reserved.<BR>4 Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR> 5 5 6 6 SPDX-License-Identifier: BSD-2-Clause-Patent … … 10 10 - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015. 11 11 - ACPI for Arm Components 1.0 - 2020 12 - Arm Generic Interrupt Controller Architecture Specification, 13 Issue H, January 2022. 14 (https://developer.arm.com/documentation/ihi0069/) 12 15 **/ 13 16 … … 27 30 #include <Library/AmlLib/AmlLib.h> 28 31 #include <Protocol/ConfigurationManagerProtocol.h> 32 33 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) 34 #include <Library/ArmGicArchLib.h> 35 #endif 29 36 30 37 /** C array containing the compiled AML template. … … 100 107 return EFI_INVALID_PARAMETER; 101 108 } 109 110 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) 111 // If an interrupt is not wired to the serial port, the Configuration 112 // Manager specifies the interrupt as 0. 113 // Any other value must be within the SPI or extended SPI range. 114 if ((SerialPortInfo->Interrupt != 0) && 115 !(((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_SPI_MIN) && 116 (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_SPI_MAX)) || 117 ((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_EXT_SPI_MIN) && 118 (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_EXT_SPI_MAX)))) 119 { 120 DEBUG (( 121 DEBUG_ERROR, 122 "ERROR: Invalid UART port interrupt ID. Interrupt = %lu\n", 123 SerialPortInfo->Interrupt 124 )); 125 return EFI_INVALID_PARAMETER; 126 } 127 128 #endif 102 129 103 130 DEBUG ((DEBUG_INFO, "UART Configuration:\n")); … … 271 298 AML_OBJECT_NODE_HANDLE NameOpCrsNode; 272 299 AML_DATA_NODE_HANDLE QWordRdNode; 273 AML_DATA_NODE_HANDLE InterruptRdNode;274 300 275 301 // Get the "_CRS" object defined by the "Name ()" statement. … … 304 330 } 305 331 306 // Get the Interrupt node. 307 // It is the second Resource Data element in the NameOpCrsNode's 308 // variable list of arguments. 309 Status = AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode); 310 if (EFI_ERROR (Status)) { 311 return Status; 312 } 313 314 if (InterruptRdNode == NULL) { 315 return EFI_INVALID_PARAMETER; 316 } 317 318 // Update the interrupt number. 319 return AmlUpdateRdInterrupt (InterruptRdNode, SerialPortInfo->Interrupt); 332 // Generate an interrupt node as the second Resource Data element in the 333 // NameOpCrsNode, if the interrupt for the serial-port is a valid SPI from 334 // Table 2-1 in Arm Generic Interrupt Controller Architecture Specification. 335 Status = AmlCodeGenRdInterrupt ( 336 TRUE, // Resource Consumer 337 FALSE, // Level Triggered 338 FALSE, // Active High 339 FALSE, // Exclusive 340 (UINT32 *)&SerialPortInfo->Interrupt, 341 1, 342 NameOpCrsNode, 343 NULL 344 ); 345 ASSERT_EFI_ERROR (Status); 346 347 return Status; 320 348 } 321 349 -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
r99404 r105670 19 19 SsdtSerialPortTemplate.asl 20 20 21 [Packages ]21 [Packages.common] 22 22 MdePkg/MdePkg.dec 23 23 MdeModulePkg/MdeModulePkg.dec 24 24 EmbeddedPkg/EmbeddedPkg.dec 25 25 DynamicTablesPkg/DynamicTablesPkg.dec 26 27 [Packages.ARM, Packages.AARCH64] 28 ArmPkg/ArmPkg.dec 26 29 27 30 [LibraryClasses] -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
r89983 r105670 2 2 SSDT Serial Template 3 3 4 Copyright (c) 2019 - 202 0, Arm Limited. All rights reserved.<BR>4 Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR> 5 5 6 6 SPDX-License-Identifier: BSD-2-Clause-Patent … … 11 11 @par Glossary: 12 12 - {template} - Data fixed up using AML Fixup APIs. 13 - {codegen} - Data generated using AML Codegen APIs. 13 14 **/ 14 15 … … 44 45 // TranslationType 45 46 ) // QWordMemory 46 Interrupt ( 47 ResourceConsumer, // ResourceUsage 48 Level, // EdgeLevel 49 ActiveHigh, // ActiveLevel 50 Exclusive, // Shared 51 , // ResourceSourceIndex 52 , // ResourceSource 53 // DescriptorName 54 ) { 55 0xA5 // {template} 56 } // Interrupt 47 48 // The Interrupt information is generated using AmlCodegen. 49 // 50 // Interrupt ( // {codegen} 51 // ResourceConsumer, // ResourceUsage 52 // Level, // EdgeLevel 53 // ActiveHigh, // ActiveLevel 54 // Exclusive, // Shared 55 // , // ResourceSourceIndex 56 // , // ResourceSource 57 // // DescriptorName 58 // ) { 59 // <IRQ> // <spi> 60 // } // Interrupt 61 57 62 }) // Name 58 63 } // Device -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
r101291 r105670 15 15 VOID 16 16 EFIAPI 17 Print OemId(17 PrintString ( 18 18 CONST CHAR8 *Format, 19 19 UINT8 *Ptr … … 23 23 VOID 24 24 EFIAPI 25 PrintString ( 25 PrintStringPtr ( 26 CONST CHAR8 *Format, 27 UINT8 *Ptr 28 ); 29 30 STATIC 31 VOID 32 EFIAPI 33 PrintChar4 ( 34 CONST CHAR8 *Format, 35 UINT8 *Ptr 36 ); 37 38 STATIC 39 VOID 40 EFIAPI 41 PrintChar6 ( 42 CONST CHAR8 *Format, 43 UINT8 *Ptr 44 ); 45 46 STATIC 47 VOID 48 EFIAPI 49 PrintChar8 ( 26 50 CONST CHAR8 *Format, 27 51 UINT8 *Ptr … … 60 84 { "ClockDomain", 4, "0x%x", NULL }, 61 85 { "AffinityFlags", 4, "0x%x", NULL }, 62 { "CpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL } 86 { "CpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, 87 { "TRBEInterrupt", 2, "0x%x", NULL }, 88 { "EtToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, 89 { "PsdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, 63 90 }; 64 91 … … 191 218 */ 192 219 STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] = { 193 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },194 { "IdMappingCount", 4, "0x%x", NULL },195 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },196 { "Flags", 4, "0x%x", NULL },197 { "CacheCoherent", 4, "0x%x", NULL },198 { "AllocationHints", 1, "0x%x", NULL },199 { "MemoryAccessFlags", 1, "0x%x", NULL },200 { "AddressSizeLimit", 1, "0x%x", NULL },201 { "ObjectName", sizeof (CHAR8 *), NULL, PrintString },202 { "Identifier", 4, "0x%x", NULL },220 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, 221 { "IdMappingCount", 4, "0x%x", NULL }, 222 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, 223 { "Flags", 4, "0x%x", NULL }, 224 { "CacheCoherent", 4, "0x%x", NULL }, 225 { "AllocationHints", 1, "0x%x", NULL }, 226 { "MemoryAccessFlags", 1, "0x%x", NULL }, 227 { "AddressSizeLimit", 1, "0x%x", NULL }, 228 { "ObjectName", sizeof (CHAR8 *), NULL, PrintStringPtr }, 229 { "Identifier", 4, "0x%x", NULL }, 203 230 }; 204 231 … … 636 663 NULL, NULL, CmArmMailboxRegisterInfoParser, 637 664 ARRAY_SIZE (CmArmMailboxRegisterInfoParser) }, 665 }; 666 667 /** A parser for EArmObjEtInfo. 668 */ 669 STATIC CONST CM_OBJ_PARSER CmArmEtInfo[] = { 670 { "EtType", sizeof (ARM_ET_TYPE), "0x%x", NULL } 671 }; 672 673 /** A parser for EArmObjPsdInfo. 674 */ 675 STATIC CONST CM_OBJ_PARSER CmArmPsdInfoParser[] = { 676 { "Revision", 1, "0x%x", NULL }, 677 { "DomainId", 4, "0x%x", NULL }, 678 { "CoordType", 4, "0x%x", NULL }, 679 { "NumProc", 4, "0x%x", NULL }, 638 680 }; 639 681 … … 734 776 { "EArmObjPccSubspaceType5Info", CmArmPccSubspaceType5InfoParser, 735 777 ARRAY_SIZE (CmArmPccSubspaceType5InfoParser) }, 778 { "EArmObjEtInfo", CmArmEtInfo, 779 ARRAY_SIZE (CmArmEtInfo) }, 780 { "EArmObjPsdInfo", CmArmPsdInfoParser, 781 ARRAY_SIZE (CmArmPsdInfoParser) }, 736 782 { "EArmObjMax", NULL, 0 }, 737 783 }; … … 741 787 STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] = { 742 788 { "Revision", 4, "0x%x", NULL }, 743 { "OemId[6]", 6, "% C%C%C%C%C%C", PrintOemId}789 { "OemId[6]", 6, "%c%c%c%c%c%c", PrintChar6 } 744 790 }; 745 791 … … 747 793 */ 748 794 STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] = { 749 { "AcpiTableSignature", 4, " 0x%x", NULL},750 { "AcpiTableRevision", 1, "%d", NULL},751 { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL},752 { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", NULL},753 { "OemTableId", 8, " 0x%LLX", NULL},754 { "OemRevision", 4, "0x%x", NULL},755 { "MinorRevision", 1, "0x%x", NULL},795 { "AcpiTableSignature", 4, "%c%c%c%c", PrintChar4 }, 796 { "AcpiTableRevision", 1, "%d", NULL }, 797 { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL }, 798 { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", NULL }, 799 { "OemTableId", 8, "%c%c%c%c%c%c%c%c", PrintChar8 }, 800 { "OemRevision", 4, "0x%x", NULL }, 801 { "MinorRevision", 1, "0x%x", NULL }, 756 802 }; 757 803 … … 772 818 { "EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser, 773 819 ARRAY_SIZE (StdObjSmbiosTableInfoParser) }, 774 }; 775 776 /** Print OEM Id. 820 { "EStdObjMax", NULL, 0} 821 }; 822 823 /** Print string data. 824 825 The string must be NULL terminated. 777 826 778 827 @param [in] Format Format to print the Ptr. 779 @param [in] Ptr Pointer to the OEM Id.828 @param [in] Ptr Pointer to the string. 780 829 **/ 781 830 STATIC 782 831 VOID 783 832 EFIAPI 784 PrintOemId ( 833 PrintString ( 834 IN CONST CHAR8 *Format, 835 IN UINT8 *Ptr 836 ) 837 { 838 if (Ptr == NULL) { 839 ASSERT (0); 840 return; 841 } 842 843 DEBUG ((DEBUG_ERROR, "%a", Ptr)); 844 } 845 846 /** Print string from pointer. 847 848 The string must be NULL terminated. 849 850 @param [in] Format Format to print the string. 851 @param [in] Ptr Pointer to the string pointer. 852 **/ 853 STATIC 854 VOID 855 EFIAPI 856 PrintStringPtr ( 857 IN CONST CHAR8 *Format, 858 IN UINT8 *Ptr 859 ) 860 { 861 UINT8 *String; 862 863 if (Ptr == NULL) { 864 ASSERT (0); 865 return; 866 } 867 868 String = *(UINT8 **)Ptr; 869 870 if (String == NULL) { 871 String = (UINT8 *)"(NULLPTR)"; 872 } 873 874 PrintString (Format, String); 875 } 876 877 /** Print 4 characters. 878 879 @param [in] Format Format to print the Ptr. 880 @param [in] Ptr Pointer to the characters. 881 **/ 882 STATIC 883 VOID 884 EFIAPI 885 PrintChar4 ( 785 886 IN CONST CHAR8 *Format, 786 887 IN UINT8 *Ptr … … 788 889 { 789 890 DEBUG (( 790 DEBUG_INFO, 791 (Format != NULL) ? Format : "%C%C%C%C%C%C", 891 DEBUG_ERROR, 892 (Format != NULL) ? Format : "%c%c%c%c", 893 Ptr[0], 894 Ptr[1], 895 Ptr[2], 896 Ptr[3] 897 )); 898 } 899 900 /** Print 6 characters. 901 902 @param [in] Format Format to print the Ptr. 903 @param [in] Ptr Pointer to the characters. 904 **/ 905 STATIC 906 VOID 907 EFIAPI 908 PrintChar6 ( 909 IN CONST CHAR8 *Format, 910 IN UINT8 *Ptr 911 ) 912 { 913 DEBUG (( 914 DEBUG_ERROR, 915 (Format != NULL) ? Format : "%c%c%c%c%c%c", 792 916 Ptr[0], 793 917 Ptr[1], … … 799 923 } 800 924 801 /** Print string. 802 803 The string must be NULL terminated. 925 /** Print 8 characters. 804 926 805 927 @param [in] Format Format to print the Ptr. 806 @param [in] Ptr Pointer to the string.928 @param [in] Ptr Pointer to the characters. 807 929 **/ 808 930 STATIC 809 931 VOID 810 932 EFIAPI 811 Print String(812 CONST CHAR8 *Format,813 UINT8 *Ptr933 PrintChar8 ( 934 IN CONST CHAR8 *Format, 935 IN UINT8 *Ptr 814 936 ) 815 937 { 816 DEBUG ((DEBUG_ERROR, "%a", Ptr)); 938 DEBUG (( 939 DEBUG_ERROR, 940 (Format != NULL) ? Format : "%c%c%c%c%c%c%c%c", 941 Ptr[0], 942 Ptr[1], 943 Ptr[2], 944 Ptr[3], 945 Ptr[4], 946 Ptr[5], 947 Ptr[6], 948 Ptr[7] 949 )); 817 950 } 818 951 … … 957 1090 } 958 1091 1092 if (ObjId >= ARRAY_SIZE (StdNamespaceObjectParser)) { 1093 DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the StdNamespaceObjectParser array\n", ObjId)); 1094 ASSERT (0); 1095 return; 1096 } 1097 959 1098 ParserArray = &StdNamespaceObjectParser[ObjId]; 960 1099 break; … … 965 1104 } 966 1105 1106 if (ObjId >= ARRAY_SIZE (ArmNamespaceObjectParser)) { 1107 DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the ArmNamespaceObjectParser array\n", ObjId)); 1108 ASSERT (0); 1109 return; 1110 } 1111 967 1112 ParserArray = &ArmNamespaceObjectParser[ObjId]; 968 1113 break; 969 1114 default: 970 1115 // Not supported 1116 DEBUG ((DEBUG_ERROR, "NameSpaceId 0x%x, ObjId 0x%x is not supported by the parser\n", NameSpaceId, ObjId)); 971 1117 ASSERT (0); 972 1118 return; … … 986 1132 ObjectCount 987 1133 )); 988 PrintCmObjDesc ( 989 (VOID *)((UINTN)CmObjDesc->Data + Offset), 990 ParserArray->Parser, 991 ParserArray->ItemCount, 992 &RemainingSize, 993 1 994 ); 995 if ((RemainingSize > CmObjDesc->Size) || 996 (RemainingSize < 0)) 997 { 998 ASSERT (0); 999 return; 1134 if (ParserArray->Parser == NULL) { 1135 DEBUG ((DEBUG_ERROR, "Parser not implemented\n")); 1136 RemainingSize = 0; 1137 } else { 1138 PrintCmObjDesc ( 1139 (VOID *)((UINTN)CmObjDesc->Data + Offset), 1140 ParserArray->Parser, 1141 ParserArray->ItemCount, 1142 &RemainingSize, 1143 1 1144 ); 1145 if ((RemainingSize > (INTN)CmObjDesc->Size) || 1146 (RemainingSize < 0)) 1147 { 1148 ASSERT (0); 1149 return; 1150 } 1151 1152 Offset = CmObjDesc->Size - RemainingSize; 1000 1153 } 1001 1002 Offset = CmObjDesc->Size - RemainingSize;1003 1154 } // for 1004 1155 -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
r99404 r105670 3 3 4 4 Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR> 5 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 15 16 #include <AcpiTableGenerator.h> 16 17 #include <ConfigurationManagerObject.h> 18 #include <Library/AmlLib/AmlLib.h> 17 19 #include <Library/TableHelperLib.h> 18 20 #include <Protocol/ConfigurationManagerProtocol.h> … … 169 171 CfgMfrInfo->OemId[3] 170 172 ) | 171 ((UINT64)Generator->AcpiTableSignature << 32); 173 LShiftU64 ( 174 (UINT64)Generator->AcpiTableSignature, 175 32 176 ); 172 177 } 173 178 … … 256 261 CfgMfrInfo->OemId[3] 257 262 ) | 258 ((UINT64)Generator->AcpiTableSignature <<32);263 LShiftU64 ((UINT64)Generator->AcpiTableSignature, 32); 259 264 } 260 265 -
trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
r99404 r105670 3 3 # 4 4 # Copyright (c) 2017 - 2021, ARM Limited. All rights reserved. 5 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 # 6 7 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 25 26 26 27 [LibraryClasses] 28 AmlLib 27 29 BaseLib
Note:
See TracChangeset
for help on using the changeset viewer.