VirtualBox

Ignore:
Timestamp:
Aug 14, 2024 1:16:30 PM (6 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
3 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c

    r99404 r105670  
    22  FADT Table Generator
    33
    4   Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
     4  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    8   - ACPI 6.4 Specification, January 2021
     8  - ACPI 6.5 Specification, Aug 29, 2022
    99
    1010**/
     
    3333/** This macro defines the FADT flag options for ARM Platforms.
    3434*/
    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)
    3737
    3838/** This macro defines the valid mask for the FADT flag option
     
    4343
    4444  Valid bits are:
    45     EFI_ACPI_6_4_WBINVD                               BIT0
    46     EFI_ACPI_6_4_PWR_BUTTON                           BIT4
    47     EFI_ACPI_6_4_SLP_BUTTON                           BIT5
    48     EFI_ACPI_6_4_FIX_RTC                              BIT6
    49     EFI_ACPI_6_4_DCK_CAP                              BIT9
    50     EFI_ACPI_6_4_RESET_REG_SUP                        BIT10
    51     EFI_ACPI_6_4_SEALED_CASE                          BIT11
    52     EFI_ACPI_6_4_HEADLESS                             BIT12
    53     EFI_ACPI_6_4_USE_PLATFORM_CLOCK                   BIT15
    54     EFI_ACPI_6_4_FORCE_APIC_CLUSTER_MODEL             BIT18
    55     EFI_ACPI_6_4_FORCE_APIC_PHYSICAL_DESTINATION_MODE BIT19
    56     EFI_ACPI_6_4_HW_REDUCED_ACPI                      BIT20
    57     EFI_ACPI_6_4_LOW_POWER_S0_IDLE_CAPABLE            BIT21
     45    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
    5858*/
    5959#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)
    7373
    7474#pragma pack(1)
    7575
    76 /** The AcpiFadt is a template EFI_ACPI_6_4_FIXED_ACPI_DESCRIPTION_TABLE
     76/** The AcpiFadt is a template EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE
    7777    structure used for generating the FADT Table.
    7878  Note: fields marked with "{Template}" will be updated dynamically.
    7979*/
    8080STATIC
    81 EFI_ACPI_6_4_FIXED_ACPI_DESCRIPTION_TABLE  AcpiFadt = {
     81EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE  AcpiFadt = {
    8282  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_REVISION
     83    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
    8686    ),
    8787  // UINT32     FirmwareCtrl
     
    9292  EFI_ACPI_RESERVED_BYTE,
    9393  // UINT8      PreferredPmProfile
    94   EFI_ACPI_6_4_PM_PROFILE_UNSPECIFIED,  // {Template}: Power Management Profile
     94  EFI_ACPI_6_5_PM_PROFILE_UNSPECIFIED,  // {Template}: Power Management Profile
    9595  // UINT16     SciInt
    9696  0,
     
    161161  // UINT32     Flags
    162162  FADT_FLAGS,
    163   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  ResetReg
     163  // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE  ResetReg
    164164  NULL_GAS,
    165165  // UINT8      ResetValue
    166166  0,
    167167  // UINT16     ArmBootArch
    168   EFI_ACPI_6_4_ARM_PSCI_COMPLIANT,  // {Template}: ARM Boot Architecture Flags
     168  EFI_ACPI_6_5_ARM_PSCI_COMPLIANT,  // {Template}: ARM Boot Architecture Flags
    169169  // 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}
    171171  // UINT64     XFirmwareCtrl
    172172  0,
    173173  // UINT64     XDsdt
    174174  0,
    175   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk
    176   NULL_GAS,
    177   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk
    178   NULL_GAS,
    179   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk
    180   NULL_GAS,
    181   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk
    182   NULL_GAS,
    183   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk
    184   NULL_GAS,
    185   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk
    186   NULL_GAS,
    187   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk
    188   NULL_GAS,
    189   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk
    190   NULL_GAS,
    191   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  SleepControlReg
    192   NULL_GAS,
    193   // EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  SleepStatusReg
     175  // 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
    194194  NULL_GAS,
    195195  // UINT64     HypervisorVendorIdentity
     
    536536             (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt,
    537537             AcpiTableInfo,
    538              sizeof (EFI_ACPI_6_4_FIXED_ACPI_DESCRIPTION_TABLE)
     538             sizeof (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE)
    539539             );
    540540  if (EFI_ERROR (Status)) {
     
    558558         EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION) &&
    559559        ((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))
    561561    {
    562562      AcpiFadt.MinorVersion = AcpiTableInfo->MinorRevision;
     
    567567        "defaulting to FADT Minor Revision 0x%x\n",
    568568        AcpiTableInfo->MinorRevision,
    569         EFI_ACPI_6_4_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION
     569        EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION
    570570        ));
    571571    }
     
    643643  L"ACPI.STD.FADT.GENERATOR",
    644644  // ACPI Table Signature
    645   EFI_ACPI_6_4_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
     645  EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
    646646  // 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,
    648648  // Minimum supported ACPI Table Revision
    649649  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c

    r99404 r105670  
    22  MADT Table Generator
    33
    4   Copyright (c) 2017 - 2020, ARM Limited. All rights reserved.
     4  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    8   - ACPI 6.3 Specification - January 2019
     8  - ACPI 6.5 Specification - Aug 29, 2022
    99
    1010**/
     
    8383
    8484/** 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.
    8686
    8787  @param [in]  Gicc       Pointer to GIC CPU Interface structure.
     
    9292VOID
    9393AddGICC (
    94   IN        EFI_ACPI_6_3_GIC_STRUCTURE  *CONST  Gicc,
     94  IN        EFI_ACPI_6_5_GIC_STRUCTURE  *CONST  Gicc,
    9595  IN  CONST CM_ARM_GICC_INFO            *CONST  GicCInfo,
    9696  IN  CONST UINT8                               MadtRev
     
    101101
    102102  // UINT8 Type
    103   Gicc->Type = EFI_ACPI_6_3_GIC;
     103  Gicc->Type = EFI_ACPI_6_5_GIC;
    104104  // UINT8 Length
    105   Gicc->Length = sizeof (EFI_ACPI_6_3_GIC_STRUCTURE);
     105  Gicc->Length = sizeof (EFI_ACPI_6_5_GIC_STRUCTURE);
    106106  // UINT16 Reserved
    107107  Gicc->Reserved = EFI_ACPI_RESERVED_WORD;
     
    149149    Gicc->SpeOverflowInterrupt = 0;
    150150  }
     151
     152  // UINT16  TrbeInterrupt
     153  if (MadtRev > EFI_ACPI_6_4_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) {
     154    Gicc->TrbeInterrupt = GicCInfo->TrbeInterrupt;
     155  }
    151156}
    152157
     
    215220EFI_STATUS
    216221AddGICCList (
    217   IN  EFI_ACPI_6_3_GIC_STRUCTURE  *Gicc,
     222  IN  EFI_ACPI_6_5_GIC_STRUCTURE  *Gicc,
    218223  IN  CONST CM_ARM_GICC_INFO      *GicCInfo,
    219224  IN        UINT32                GicCCount,
     
    253258VOID
    254259AddGICD (
    255   EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE  *CONST  Gicd,
     260  EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE  *CONST  Gicd,
    256261  CONST CM_ARM_GICD_INFO                  *CONST  GicDInfo
    257262  )
     
    261266
    262267  // UINT8 Type
    263   Gicd->Type = EFI_ACPI_6_3_GICD;
     268  Gicd->Type = EFI_ACPI_6_5_GICD;
    264269  // UINT8 Length
    265   Gicd->Length = sizeof (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE);
     270  Gicd->Length = sizeof (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE);
    266271  // UINT16 Reserved
    267272  Gicd->Reserved1 = EFI_ACPI_RESERVED_WORD;
     
    290295VOID
    291296AddGICMsiFrame (
    292   IN  EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE  *CONST  GicMsiFrame,
     297  IN  EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE  *CONST  GicMsiFrame,
    293298  IN  CONST CM_ARM_GIC_MSI_FRAME_INFO       *CONST  GicMsiFrameInfo
    294299  )
     
    297302  ASSERT (GicMsiFrameInfo != NULL);
    298303
    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);
    301306  GicMsiFrame->Reserved1           = EFI_ACPI_RESERVED_WORD;
    302307  GicMsiFrame->GicMsiFrameId       = GicMsiFrameInfo->GicMsiFrameId;
     
    317322VOID
    318323AddGICMsiFrameInfoList (
    319   IN  EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE  *GicMsiFrame,
     324  IN  EFI_ACPI_6_5_GIC_MSI_FRAME_STRUCTURE  *GicMsiFrame,
    320325  IN  CONST CM_ARM_GIC_MSI_FRAME_INFO       *GicMsiFrameInfo,
    321326  IN        UINT32                          GicMsiFrameCount
     
    338343VOID
    339344AddGICRedistributor (
    340   IN  EFI_ACPI_6_3_GICR_STRUCTURE   *CONST  Gicr,
     345  IN  EFI_ACPI_6_5_GICR_STRUCTURE   *CONST  Gicr,
    341346  IN  CONST CM_ARM_GIC_REDIST_INFO  *CONST  GicRedistributorInfo
    342347  )
     
    345350  ASSERT (GicRedistributorInfo != NULL);
    346351
    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);
    349354  Gicr->Reserved                  = EFI_ACPI_RESERVED_WORD;
    350355  Gicr->DiscoveryRangeBaseAddress =
     
    362367VOID
    363368AddGICRedistributorList (
    364   IN  EFI_ACPI_6_3_GICR_STRUCTURE   *Gicr,
     369  IN  EFI_ACPI_6_5_GICR_STRUCTURE   *Gicr,
    365370  IN  CONST CM_ARM_GIC_REDIST_INFO  *GicRInfo,
    366371  IN        UINT32                  GicRCount
     
    383388VOID
    384389AddGICInterruptTranslationService (
    385   IN  EFI_ACPI_6_3_GIC_ITS_STRUCTURE  *CONST  GicIts,
     390  IN  EFI_ACPI_6_5_GIC_ITS_STRUCTURE  *CONST  GicIts,
    386391  IN  CONST CM_ARM_GIC_ITS_INFO       *CONST  GicItsInfo
    387392  )
     
    390395  ASSERT (GicItsInfo != NULL);
    391396
    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);
    394399  GicIts->Reserved            = EFI_ACPI_RESERVED_WORD;
    395400  GicIts->GicItsId            = GicItsInfo->GicItsId;
     
    408413VOID
    409414AddGICItsList (
    410   IN  EFI_ACPI_6_3_GIC_ITS_STRUCTURE  *GicIts,
     415  IN  EFI_ACPI_6_5_GIC_ITS_STRUCTURE  *GicIts,
    411416  IN  CONST CM_ARM_GIC_ITS_INFO       *GicItsInfo,
    412417  IN        UINT32                    GicItsCount
     
    471476  UINT32                     GicItsOffset;
    472477
    473   EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
     478  EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
    474479
    475480  ASSERT (This != NULL);
     
    603608  }
    604609
    605   TableSize = sizeof (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);
     610  TableSize = sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);
    606611
    607612  GicCOffset = TableSize;
    608   TableSize += (sizeof (EFI_ACPI_6_3_GIC_STRUCTURE) * GicCCount);
     613  TableSize += (sizeof (EFI_ACPI_6_5_GIC_STRUCTURE) * GicCCount);
    609614
    610615  GicDOffset = TableSize;
    611   TableSize += (sizeof (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount);
     616  TableSize += (sizeof (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount);
    612617
    613618  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);
    615620
    616621  GicRedistOffset = TableSize;
    617   TableSize      += (sizeof (EFI_ACPI_6_3_GICR_STRUCTURE) * GicRedistCount);
     622  TableSize      += (sizeof (EFI_ACPI_6_5_GICR_STRUCTURE) * GicRedistCount);
    618623
    619624  GicItsOffset = TableSize;
    620   TableSize   += (sizeof (EFI_ACPI_6_3_GIC_ITS_STRUCTURE) * GicItsCount);
     625  TableSize   += (sizeof (EFI_ACPI_6_5_GIC_ITS_STRUCTURE) * GicItsCount);
    621626
    622627  // Allocate the Buffer for MADT table
     
    634639  }
    635640
    636   Madt = (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)*Table;
     641  Madt = (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)*Table;
    637642
    638643  DEBUG ((
     
    660665
    661666  Status = AddGICCList (
    662              (EFI_ACPI_6_3_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset),
     667             (EFI_ACPI_6_5_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset),
    663668             GicCInfo,
    664669             GicCCount,
     
    675680
    676681  AddGICD (
    677     (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE *)((UINT8 *)Madt + GicDOffset),
     682    (EFI_ACPI_6_5_GIC_DISTRIBUTOR_STRUCTURE *)((UINT8 *)Madt + GicDOffset),
    678683    GicDInfo
    679684    );
     
    681686  if (GicMSICount != 0) {
    682687    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),
    684689      GicMSIInfo,
    685690      GicMSICount
     
    689694  if (GicRedistCount != 0) {
    690695    AddGICRedistributorList (
    691       (EFI_ACPI_6_3_GICR_STRUCTURE *)((UINT8 *)Madt + GicRedistOffset),
     696      (EFI_ACPI_6_5_GICR_STRUCTURE *)((UINT8 *)Madt + GicRedistOffset),
    692697      GicRedistInfo,
    693698      GicRedistCount
     
    697702  if (GicItsCount != 0) {
    698703    AddGICItsList (
    699       (EFI_ACPI_6_3_GIC_ITS_STRUCTURE *)((UINT8 *)Madt + GicItsOffset),
     704      (EFI_ACPI_6_5_GIC_ITS_STRUCTURE *)((UINT8 *)Madt + GicItsOffset),
    700705      GicItsInfo,
    701706      GicItsCount
     
    765770  L"ACPI.STD.MADT.GENERATOR",
    766771  // ACPI Table Signature
    767   EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
     772  EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
    768773  // 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,
    770775  // Minimum supported ACPI Table Revision
    771776  EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

    r101291 r105670  
    22  SSDT Cpu Topology Table Generator.
    33
    4   Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
     4  Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.<BR>
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    88    - 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.
    915**/
    1016
     
    3642  - EArmObjCmRef (OPTIONAL)
    3743  - EArmObjLpiInfo (OPTIONAL)
     44  - GetEArmObjEtInfo (OPTIONAL)
     45  - EArmObjPsdInfo (OPTIONAL)
    3846*/
    3947
     
    8795  );
    8896
     97/**
     98  This macro expands to a function that retrieves the ET device
     99  information from the Configuration Manager.
     100*/
     101GET_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*/
     111GET_OBJECT_LIST (
     112  EObjNameSpaceArm,
     113  EArmObjPsdInfo,
     114  CM_ARM_PSD_INFO
     115  );
     116
    89117/** Initialize the TokenTable.
    90118
     
    238266
    239267  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**/
     306STATIC
     307EFI_STATUS
     308EFIAPI
     309CreateAmlPsdNode (
     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;
    240337}
    241338
     
    327424}
    328425
     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**/
     450STATIC
     451EFI_STATUS
     452EFIAPI
     453CreateAmlEtd (
     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**/
     526STATIC
     527EFI_STATUS
     528EFIAPI
     529CreateAmlEtNode (
     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
    329567/** Create and add an _LPI method to Cpu/Cluster Node.
    330568
     
    685923  }
    686924
     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
    687933  // If a CPC info is associated with the
    688934  // GicCinfo, create an _CPC method returning them.
    689935  if (GicCInfo->CpcToken != CM_NULL_TOKEN) {
    690936    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               );
    691952    if (EFI_ERROR (Status)) {
    692953      ASSERT_EFI_ERROR (Status);
     
    8121073  @param [in]  NodeToken        NodeToken of the ProcNode.
    8131074  @param [in]  ParentNodeToken  Parent NodeToken of the ProcNode.
     1075  @param [in]  PackageNodeSeen  A parent of the ProcNode has the physical package flag set.
    8141076
    8151077  @retval EFI_SUCCESS             Success.
     
    8231085  BOOLEAN          IsLeaf,
    8241086  CM_OBJECT_TOKEN  NodeToken,
    825   CM_OBJECT_TOKEN  ParentNodeToken
     1087  CM_OBJECT_TOKEN  ParentNodeToken,
     1088  BOOLEAN          PackageNodeSeen
    8261089  )
    8271090{
    8281091  BOOLEAN  InvalidFlags;
    8291092  BOOLEAN  HasPhysicalPackageBit;
    830   BOOLEAN  IsTopLevelNode;
    8311093
    8321094  HasPhysicalPackageBit = (NodeFlags & EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) ==
    8331095                          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;
    8381099
    8391100  // Check Leaf specific flags.
    8401101  if (IsLeaf) {
    8411102    InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != PPTT_LEAF_MASK);
     1103    // Must have Physical Package flag somewhere in the hierarchy
     1104    InvalidFlags |= !(HasPhysicalPackageBit || PackageNodeSeen);
    8421105  } else {
    8431106    InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != 0);
     
    8701133  @param [in,out] ProcContainerIndex  Pointer to the current processor container
    8711134                                      index to be used as UID.
     1135  @param [in]  PackageNodeSeen        A parent of the ProcNode has the physical package flag set.
    8721136
    8731137  @retval EFI_SUCCESS             Success.
     
    8831147  IN        CM_OBJECT_TOKEN                               NodeToken,
    8841148  IN        AML_NODE_HANDLE                               ParentNode,
    885   IN OUT    UINT32                                        *ProcContainerIndex
     1149  IN OUT    UINT32                                        *ProcContainerIndex,
     1150  IN        BOOLEAN                                       PackageNodeSeen
    8861151  )
    8871152{
     
    8931158  UINT32                  Uid;
    8941159  UINT16                  Name;
     1160  BOOLEAN                 HasPhysicalPackageBit;
    8951161
    8961162  ASSERT (Generator != NULL);
     
    9151181                   TRUE,
    9161182                   Generator->ProcNodeList[Index].Token,
    917                    NodeToken
     1183                   NodeToken,
     1184                   PackageNodeSeen
    9181185                   );
    9191186        if (EFI_ERROR (Status)) {
     
    9481215                   FALSE,
    9491216                   Generator->ProcNodeList[Index].Token,
    950                    NodeToken
     1217                   NodeToken,
     1218                   PackageNodeSeen
    9511219                   );
    9521220        if (EFI_ERROR (Status)) {
     
    9891257        }
    9901258
     1259        HasPhysicalPackageBit = (Generator->ProcNodeList[Index].Flags & EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) ==
     1260                                EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;
     1261
    9911262        // Recursively continue creating an AML tree.
    9921263        Status = CreateAmlCpuTopologyTree (
     
    9951266                   Generator->ProcNodeList[Index].Token,
    9961267                   ProcContainerNode,
    997                    ProcContainerIndex
     1268                   ProcContainerIndex,
     1269                   (PackageNodeSeen || HasPhysicalPackageBit)
    9981270                   );
    9991271        if (EFI_ERROR (Status)) {
     
    10511323             CM_NULL_TOKEN,
    10521324             ScopeNode,
    1053              &ProcContainerIndex
     1325             &ProcContainerIndex,
     1326             FALSE
    10541327             );
    10551328  if (EFI_ERROR (Status)) {
     
    11271400    }
    11281401
     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
    11291410    // If a CPC info is associated with the
    11301411    // GicCinfo, create an _CPC method returning them.
    1131     if (GicCInfo->CpcToken != CM_NULL_TOKEN) {
     1412    if (GicCInfo[Index].CpcToken != CM_NULL_TOKEN) {
    11321413      Status = CreateAmlCpcNode (Generator, CfgMgrProtocol, &GicCInfo[Index], CpuNode);
    11331414      if (EFI_ERROR (Status)) {
    11341415        ASSERT_EFI_ERROR (Status);
    11351416        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;
    11361431      }
    11371432    }
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.h

    r101291 r105670  
    22  SSDT Cpu Topology Table Generator.
    33
    4   Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
     4  Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.<BR>
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    88    - 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.
    915**/
    1016
     
    4955/// HID for a processor device.
    5056#define ACPI_HID_PROCESSOR_DEVICE  "ACPI0007"
     57
     58/// HID for a ETM/ETE device.
     59#define ACPI_HID_ET_DEVICE  "ARMHC500"
    5160
    5261/// HID for a processor container device.
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

    r99404 r105670  
    541541    switch (AddrMapInfo->SpaceCode) {
    542542      case PCI_SS_IO:
    543         Status = AmlCodeGenRdDWordIo (
     543        Status = AmlCodeGenRdQWordIo (
    544544                   FALSE,
    545545                   TRUE,
     
    567567                   TRUE,
    568568                   TRUE,
    569                    TRUE,
     569                   AmlMemoryCacheable,
    570570                   TRUE,
    571571                   0,
     
    576576                   0,
    577577                   NULL,
    578                    0,
     578                   AmlAddressRangeMemory,
    579579                   TRUE,
    580580                   CrsNode,
     
    589589                   TRUE,
    590590                   TRUE,
    591                    TRUE,
     591                   AmlMemoryCacheable,
    592592                   TRUE,
    593593                   0,
     
    598598                   0,
    599599                   NULL,
    600                    0,
     600                   AmlAddressRangeMemory,
    601601                   TRUE,
    602602                   CrsNode,
     
    719719             TRUE,
    720720             TRUE,
    721              FALSE,  // non-cacheable
     721             AmlMemoryNonCacheable,
    722722             TRUE,
    723723             0,
     
    728728             0,
    729729             NULL,
    730              0,
     730             AmlAddressRangeMemory,
    731731             TRUE,
    732732             CrsNode,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf

    r99404 r105670  
    33#
    44#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
     5#  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
    56#
    67#  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    6970  AcpiHelperLib
    7071  BaseLib
     72  MemoryAllocationLib
     73
     74[FixedPcd]
     75  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdDevelopmentPlatformRelaxations
    7176
    7277[BuildOptions]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

    r99404 r105670  
    22  AML Code Generation.
    33
    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>
    56
    67  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    1213
    1314#include <AmlCoreInterface.h>
    14 #include <AmlCpcInfo.h>
     15#include <AcpiObjects.h>
    1516#include <AmlEncoding/Aml.h>
    1617#include <Api/AmlApiHelper.h>
     
    870871}
    871872
     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**/
     895EFI_STATUS
     896EFIAPI
     897AmlCodeGenNameUnicodeString (
     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
    872959/** Add a _PRT entry.
    873960
     
    11621249  Status = AmlCreateObjectNode (
    11631250             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
     1295error_handler2:
     1296  if (ObjectNode != NULL) {
     1297    AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
     1298  }
     1299
     1300error_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**/
     1328EFI_STATUS
     1329EFIAPI
     1330AmlCodeGenThermalZone (
     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),
    11641367             AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),
    11651368             &ObjectNode
     
    17661969}
    17671970
     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**/
     2005STATIC
     2006EFI_STATUS
     2007EFIAPI
     2008AmlCodeGenReturnNameStringIntegerArgument (
     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
     2084exit_handler1:
     2085  if (IntNode != NULL) {
     2086    AmlDeleteTree ((AML_NODE_HANDLE)IntNode);
     2087  }
     2088
     2089exit_handler:
     2090  if (AmlNameString != NULL) {
     2091    FreePool (AmlNameString);
     2092  }
     2093
     2094  return Status;
     2095}
     2096
    17682097/** AML code generation for a method returning a NameString.
    17692098
     
    18452174    Status = AmlCodeGenReturnNameString (
    18462175               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
     2197error_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**/
     2246EFI_STATUS
     2247EFIAPI
     2248AmlCodeGenMethodRetNameStringIntegerArgument (
     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,
    18472288               (AML_NODE_HANDLE)MethodNode,
    18482289               NULL
     
    30843525
    30853526  // Revision 3 per ACPI 6.4 specification
    3086   if (CpcInfo->Revision == 3) {
     3527  if (CpcInfo->Revision == EFI_ACPI_6_5_AML_CPC_REVISION) {
    30873528    // NumEntries 23 per ACPI 6.4 specification
    30883529    NumberOfEntries = 23;
     
    30903531    ASSERT (0);
    30913532    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    }
    30923556  }
    30933557
     
    31003564      (IsNullGenericAddress (&CpcInfo->LowestPerformanceBuffer) &&
    31013565       (CpcInfo->LowestPerformanceInteger == 0)) ||
    3102       IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister) ||
    3103       IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister) ||
    3104       IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister) ||
    3105       IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister))
     3566      IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister))
    31063567  {
    31073568    ASSERT (0);
     
    33263787  return Status;
    33273788}
     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**/
     3800EFI_STATUS
     3801EFIAPI
     3802AmlAddNameStringToNamedPackage (
     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
     3866exit_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**/
     3906EFI_STATUS
     3907EFIAPI
     3908AmlAddIntegerToNamedPackage (
     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 **/
     3995EFI_STATUS
     3996EFIAPI
     3997AmlCodeGenInvokeMethod (
     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
     4161exit_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
     4169exit_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**/
     4206EFI_STATUS
     4207EFIAPI
     4208AmlCreatePsdNode (
     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
     4362error_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  
    33
    44  Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR>
     5  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
    56
    67  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    571572  IN        BOOLEAN IsMinFixed,
    572573  IN        BOOLEAN IsMaxFixed,
    573   IN        UINT8 Cacheable,
     574  IN        AML_MEMORY_ATTRIBUTES_MEM Cacheable,
    574575  IN        BOOLEAN IsReadWrite,
    575576  IN        UINT32 AddressGranularity,
     
    580581  IN        UINT8 ResourceSourceIndex,
    581582  IN  CONST CHAR8 *ResourceSource,
    582   IN        UINT8 MemoryRangeType,
     583  IN        AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
    583584  IN        BOOLEAN IsTypeStatic,
    584585  IN        AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
     
    848849  IN        BOOLEAN IsMaxFixed,
    849850  IN        BOOLEAN IsPosDecode,
    850   IN        UINT32 AddressGranularity,
    851   IN        UINT32 AddressMinimum,
    852   IN        UINT32 AddressMaximum,
    853   IN        UINT32 AddressTranslation,
    854   IN        UINT32 RangeLength,
     851  IN        UINT16 AddressGranularity,
     852  IN        UINT16 AddressMinimum,
     853  IN        UINT16 AddressMaximum,
     854  IN        UINT16 AddressTranslation,
     855  IN        UINT16 RangeLength,
    855856  IN        UINT8 ResourceSourceIndex,
    856857  IN  CONST CHAR8 *ResourceSource,
     
    867868           IsMaxFixed,
    868869           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**/
     925EFI_STATUS
     926EFIAPI
     927AmlCodeGenRdWordIo (
     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             ),
    869957           AddressGranularity,
    870958           AddressMinimum,
     
    10111099
    10121100  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**/
     1149EFI_STATUS
     1150EFIAPI
     1151AmlCodeGenRdQWordIo (
     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           );
    10131191}
    10141192
     
    10721250  IN        BOOLEAN IsMinFixed,
    10731251  IN        BOOLEAN IsMaxFixed,
    1074   IN        UINT8 Cacheable,
     1252  IN        AML_MEMORY_ATTRIBUTES_MEM Cacheable,
    10751253  IN        BOOLEAN IsReadWrite,
    10761254  IN        UINT64 AddressGranularity,
     
    10811259  IN        UINT8 ResourceSourceIndex,
    10821260  IN  CONST CHAR8 *ResourceSource,
    1083   IN        UINT8 MemoryRangeType,
     1261  IN        AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
    10841262  IN        BOOLEAN IsTypeStatic,
    10851263  IN        AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c

    r99404 r105670  
    101101typedef
    102102EFI_STATUS
    103 EFIAPI
    104 (*AML_PARSE_FUNCTION) (
     103(EFIAPI *AML_PARSE_FUNCTION)(
    105104  IN      CONST AML_NODE_HEADER   *Node,
    106105  IN            AML_PARSE_FORMAT  ExpectedFormat,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c

    r99404 r105670  
    33
    44  Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
     5  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
    56
    67  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    288289  CmObjDesc           = &This->ArmCmObjArray[ArmObjIndex];
    289290  CmObjDesc->ObjectId = CmObjId;
    290   CmObjDesc->Size     = Size;
    291   CmObjDesc->Count    = Count;
     291  CmObjDesc->Size     = (UINT32)Size;
     292  CmObjDesc->Count    = (UINT32)Count;
    292293  CmObjDesc->Data     = GroupedData;
    293294
     
    341342  //  - Add the Token/CmObj binding to the token mapper.
    342343  for (ArmObjIndex = 0; ArmObjIndex < EArmObjMax; ArmObjIndex++) {
    343     Status = GroupCmObjNodes (This, ArmObjIndex);
     344    Status = GroupCmObjNodes (This, (UINT32)ArmObjIndex);
    344345    if (EFI_ERROR (Status)) {
    345346      ASSERT (0);
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c

    r99404 r105670  
    22  SSDT Serial Port Fixup Library.
    33
    4   Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
     4  Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR>
    55
    66  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    1010  - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
    1111  - 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/)
    1215**/
    1316
     
    2730#include <Library/AmlLib/AmlLib.h>
    2831#include <Protocol/ConfigurationManagerProtocol.h>
     32
     33#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     34  #include <Library/ArmGicArchLib.h>
     35#endif
    2936
    3037/** C array containing the compiled AML template.
     
    100107      return EFI_INVALID_PARAMETER;
    101108    }
     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
    102129
    103130    DEBUG ((DEBUG_INFO, "UART Configuration:\n"));
     
    271298  AML_OBJECT_NODE_HANDLE  NameOpCrsNode;
    272299  AML_DATA_NODE_HANDLE    QWordRdNode;
    273   AML_DATA_NODE_HANDLE    InterruptRdNode;
    274300
    275301  // Get the "_CRS" object defined by the "Name ()" statement.
     
    304330  }
    305331
    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;
    320348}
    321349
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf

    r99404 r105670  
    1919  SsdtSerialPortTemplate.asl
    2020
    21 [Packages]
     21[Packages.common]
    2222  MdePkg/MdePkg.dec
    2323  MdeModulePkg/MdeModulePkg.dec
    2424  EmbeddedPkg/EmbeddedPkg.dec
    2525  DynamicTablesPkg/DynamicTablesPkg.dec
     26
     27[Packages.ARM, Packages.AARCH64]
     28  ArmPkg/ArmPkg.dec
    2629
    2730[LibraryClasses]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl

    r89983 r105670  
    22  SSDT Serial Template
    33
    4   Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
     4  Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR>
    55
    66  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    1111  @par Glossary:
    1212    - {template} - Data fixed up using AML Fixup APIs.
     13    - {codegen}  - Data generated using AML Codegen APIs.
    1314**/
    1415
     
    4445                              // TranslationType
    4546        ) // 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
    5762      }) // Name
    5863    } // Device
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c

    r101291 r105670  
    1515VOID
    1616EFIAPI
    17 PrintOemId (
     17PrintString (
    1818  CONST CHAR8  *Format,
    1919  UINT8        *Ptr
     
    2323VOID
    2424EFIAPI
    25 PrintString (
     25PrintStringPtr (
     26  CONST CHAR8  *Format,
     27  UINT8        *Ptr
     28  );
     29
     30STATIC
     31VOID
     32EFIAPI
     33PrintChar4 (
     34  CONST CHAR8  *Format,
     35  UINT8        *Ptr
     36  );
     37
     38STATIC
     39VOID
     40EFIAPI
     41PrintChar6 (
     42  CONST CHAR8  *Format,
     43  UINT8        *Ptr
     44  );
     45
     46STATIC
     47VOID
     48EFIAPI
     49PrintChar8 (
    2650  CONST CHAR8  *Format,
    2751  UINT8        *Ptr
     
    6084  { "ClockDomain",                   4,                        "0x%x",   NULL },
    6185  { "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 },
    6390};
    6491
     
    191218*/
    192219STATIC 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           },
    203230};
    204231
     
    636663    NULL, NULL, CmArmMailboxRegisterInfoParser,
    637664    ARRAY_SIZE (CmArmMailboxRegisterInfoParser) },
     665};
     666
     667/** A parser for EArmObjEtInfo.
     668*/
     669STATIC CONST CM_OBJ_PARSER  CmArmEtInfo[] = {
     670  { "EtType", sizeof (ARM_ET_TYPE), "0x%x", NULL }
     671};
     672
     673/** A parser for EArmObjPsdInfo.
     674*/
     675STATIC 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 },
    638680};
    639681
     
    734776  { "EArmObjPccSubspaceType5Info",         CmArmPccSubspaceType5InfoParser,
    735777    ARRAY_SIZE (CmArmPccSubspaceType5InfoParser) },
     778  { "EArmObjEtInfo",                       CmArmEtInfo,
     779    ARRAY_SIZE (CmArmEtInfo) },
     780  { "EArmObjPsdInfo",                      CmArmPsdInfoParser,
     781    ARRAY_SIZE (CmArmPsdInfoParser) },
    736782  { "EArmObjMax",                          NULL,                                  0                                },
    737783};
     
    741787STATIC CONST CM_OBJ_PARSER  StdObjCfgMgrInfoParser[] = {
    742788  { "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 }
    744790};
    745791
     
    747793*/
    748794STATIC 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      },
    756802};
    757803
     
    772818  { "EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser,
    773819    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.
    777826
    778827  @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.
    780829**/
    781830STATIC
    782831VOID
    783832EFIAPI
    784 PrintOemId (
     833PrintString (
     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**/
     853STATIC
     854VOID
     855EFIAPI
     856PrintStringPtr (
     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**/
     882STATIC
     883VOID
     884EFIAPI
     885PrintChar4 (
    785886  IN  CONST CHAR8  *Format,
    786887  IN  UINT8        *Ptr
     
    788889{
    789890  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**/
     905STATIC
     906VOID
     907EFIAPI
     908PrintChar6 (
     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",
    792916    Ptr[0],
    793917    Ptr[1],
     
    799923}
    800924
    801 /** Print string.
    802 
    803   The string must be NULL terminated.
     925/** Print 8 characters.
    804926
    805927  @param [in]  Format  Format to print the Ptr.
    806   @param [in]  Ptr     Pointer to the string.
     928  @param [in]  Ptr     Pointer to the characters.
    807929**/
    808930STATIC
    809931VOID
    810932EFIAPI
    811 PrintString (
    812   CONST CHAR8  *Format,
    813   UINT8        *Ptr
     933PrintChar8 (
     934  IN  CONST CHAR8  *Format,
     935  IN  UINT8        *Ptr
    814936  )
    815937{
    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    ));
    817950}
    818951
     
    9571090      }
    9581091
     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
    9591098      ParserArray = &StdNamespaceObjectParser[ObjId];
    9601099      break;
     
    9651104      }
    9661105
     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
    9671112      ParserArray = &ArmNamespaceObjectParser[ObjId];
    9681113      break;
    9691114    default:
    9701115      // Not supported
     1116      DEBUG ((DEBUG_ERROR, "NameSpaceId 0x%x, ObjId 0x%x is not supported by the parser\n", NameSpaceId, ObjId));
    9711117      ASSERT (0);
    9721118      return;
     
    9861132      ObjectCount
    9871133      ));
    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;
    10001153    }
    1001 
    1002     Offset = CmObjDesc->Size - RemainingSize;
    10031154  } // for
    10041155
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c

    r99404 r105670  
    33
    44  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
     5  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
    56
    67  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    1516#include <AcpiTableGenerator.h>
    1617#include <ConfigurationManagerObject.h>
     18#include <Library/AmlLib/AmlLib.h>
    1719#include <Library/TableHelperLib.h>
    1820#include <Protocol/ConfigurationManagerProtocol.h>
     
    169171                               CfgMfrInfo->OemId[3]
    170172                               ) |
    171                              ((UINT64)Generator->AcpiTableSignature << 32);
     173                             LShiftU64 (
     174                               (UINT64)Generator->AcpiTableSignature,
     175                               32
     176                               );
    172177  }
    173178
     
    256261                   CfgMfrInfo->OemId[3]
    257262                   ) |
    258                  ((UINT64)Generator->AcpiTableSignature << 32);
     263                 LShiftU64 ((UINT64)Generator->AcpiTableSignature, 32);
    259264  }
    260265
  • trunk/src/VBox/Devices/EFI/FirmwareNew/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf

    r99404 r105670  
    33#
    44#  Copyright (c) 2017 - 2021, ARM Limited. All rights reserved.
     5#  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
    56#
    67#  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    2526
    2627[LibraryClasses]
     28  AmlLib
    2729  BaseLib
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette