VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156854
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
4 added
23 edited

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/AestParser.c

    r89983 r99404  
    1919
    2020// Local variables
    21 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
    22 STATIC UINT8*                       AestNodeType;
    23 STATIC UINT16*                      AestNodeLength;
    24 STATIC UINT32*                      NodeDataOffset;
    25 STATIC UINT32*                      NodeInterfaceOffset;
    26 STATIC UINT32*                      NodeInterruptArrayOffset;
    27 STATIC UINT32*                      NodeInterruptCount;
    28 STATIC UINT32*                      ProcessorId;
    29 STATIC UINT8*                       ProcessorFlags;
    30 STATIC UINT8*                       ProcessorResourceType;
     21STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
     22STATIC UINT8                         *AestNodeType;
     23STATIC UINT16                        *AestNodeLength;
     24STATIC UINT32                        *NodeDataOffset;
     25STATIC UINT32                        *NodeInterfaceOffset;
     26STATIC UINT32                        *NodeInterruptArrayOffset;
     27STATIC UINT32                        *NodeInterruptCount;
     28STATIC UINT32                        *ProcessorId;
     29STATIC UINT8                         *ProcessorFlags;
     30STATIC UINT8                         *ProcessorResourceType;
    3131
    3232/**
     
    4141EFIAPI
    4242ValidateProcessorFlags (
    43   IN UINT8* Ptr,
    44   IN VOIDContext
     43  IN UINT8  *Ptr,
     44  IN VOID   *Context
    4545  )
    4646{
     
    4949  if (((*Ptr & 0x3) != 0) && (*ProcessorId != 0)) {
    5050    IncrementErrorCount ();
    51     Print (L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
    52            L" or shared nodes.");
     51    Print (
     52      L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
     53      L" or shared nodes."
     54      );
    5355  }
    5456}
     
    6567EFIAPI
    6668ValidateGicInterfaceType (
    67   IN UINT8* Ptr,
    68   IN VOIDContext
    69   )
    70 {
    71   UINT32 GicInterfaceType;
    72 
    73   GicInterfaceType = *(UINT32*)Ptr;
     69  IN UINT8  *Ptr,
     70  IN VOID   *Context
     71  )
     72{
     73  UINT32  GicInterfaceType;
     74
     75  GicInterfaceType = *(UINT32 *)Ptr;
    7476  if (GicInterfaceType > 3) {
    7577    IncrementErrorCount ();
     
    8991EFIAPI
    9092ValidateInterfaceType (
    91   IN UINT8* Ptr,
    92   IN VOIDContext
     93  IN UINT8  *Ptr,
     94  IN VOID   *Context
    9395  )
    9496{
     
    110112EFIAPI
    111113ValidateInterruptType (
    112   IN UINT8* Ptr,
    113   IN VOIDContext
     114  IN UINT8  *Ptr,
     115  IN VOID   *Context
    114116  )
    115117{
     
    131133EFIAPI
    132134ValidateInterruptFlags (
    133   IN UINT8* Ptr,
    134   IN VOIDContext
     135  IN UINT8  *Ptr,
     136  IN VOID   *Context
    135137  )
    136138{
     
    150152EFIAPI
    151153DumpVendorSpecificData (
    152   IN CONST CHAR16* Format OPTIONAL,
    153   IN UINT8*        Ptr
     154  IN CONST CHAR16  *Format OPTIONAL,
     155  IN UINT8         *Ptr
    154156  )
    155157{
     
    184186  An ACPI_PARSER array describing the ACPI AEST Table.
    185187**/
    186 STATIC CONST ACPI_PARSER AestParser[] = {
     188STATIC CONST ACPI_PARSER  AestParser[] = {
    187189  PARSE_ACPI_HEADER (&AcpiHdrInfo)
    188190};
     
    191193  An ACPI_PARSER array describing the AEST Node Header.
    192194**/
    193 STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
    194   {L"Type", 1, 0, L"%d", NULL, (VOID**)&AestNodeType, NULL, NULL},
    195   {L"Length", 2, 1, L"%d", NULL, (VOID**)&AestNodeLength, NULL, NULL},
    196   {L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
    197   {L"Node Data Offset", 4, 4, L"%d", NULL, (VOID**)&NodeDataOffset, NULL, NULL},
    198   {L"Node Interface Offset", 4, 8, L"%d", NULL,
    199     (VOID**)&NodeInterfaceOffset, NULL, NULL},
    200   {L"Node Interrupt Array Offset", 4, 12, L"%d", NULL,
    201     (VOID**)&NodeInterruptArrayOffset, NULL, NULL},
    202   {L"Node Interrupt Count", 4, 16, L"%d", NULL,
    203     (VOID**)&NodeInterruptCount, NULL, NULL},
    204   {L"Timestamp Rate", 8, 20, L"%ld", NULL, NULL, NULL, NULL},
    205   {L"Reserved1", 8, 28, L"0x%lx", NULL, NULL, NULL, NULL},
    206   {L"Error Injection Countdown Rate", 8, 36, L"%ld", NULL, NULL, NULL, NULL}
     195STATIC CONST ACPI_PARSER  AestNodeHeaderParser[] = {
     196  { L"Type",                           1, 0,  L"%d",    NULL, (VOID **)&AestNodeType,   NULL, NULL },
     197  { L"Length",                         2, 1,  L"%d",    NULL, (VOID **)&AestNodeLength, NULL, NULL },
     198  { L"Reserved",                       1, 3,  L"0x%x",  NULL, NULL,                     NULL, NULL },
     199  { L"Node Data Offset",               4, 4,  L"%d",    NULL, (VOID **)&NodeDataOffset, NULL, NULL },
     200  { L"Node Interface Offset",          4, 8,  L"%d",    NULL,
     201    (VOID **)&NodeInterfaceOffset, NULL, NULL },
     202  { L"Node Interrupt Array Offset",    4, 12, L"%d",    NULL,
     203    (VOID **)&NodeInterruptArrayOffset, NULL, NULL },
     204  { L"Node Interrupt Count",           4, 16, L"%d",    NULL,
     205    (VOID **)&NodeInterruptCount, NULL, NULL },
     206  { L"Timestamp Rate",                 8, 20, L"%ld",   NULL, NULL,                     NULL, NULL },
     207  { L"Reserved1",                      8, 28, L"0x%lx", NULL, NULL,                     NULL, NULL },
     208  { L"Error Injection Countdown Rate", 8, 36, L"%ld",   NULL, NULL,                     NULL, NULL }
    207209  // Node specific data...
    208210  // Node interface...
     
    213215  An ACPI_PARSER array describing the Processor error node specific data.
    214216**/
    215 STATIC CONST ACPI_PARSER AestProcessorStructure[] = {
    216   {L"ACPI Processor ID", 4, 0, L"0x%x", NULL, (VOID**)&ProcessorId, NULL, NULL},
    217   {L"Resource Type", 1, 4, L"%d", NULL, (VOID**)&ProcessorResourceType, NULL,
    218     NULL},
    219   {L"Reserved", 1, 5, L"0x%x", NULL, NULL, NULL, NULL},
    220   {L"Flags", 1, 6, L"0x%x", NULL, (VOID**)&ProcessorFlags,
    221     ValidateProcessorFlags, NULL},
    222   {L"Revision", 1, 7, L"%d", NULL, NULL, NULL, NULL},
    223   {L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL, NULL,
    224     NULL},
     217STATIC CONST ACPI_PARSER  AestProcessorStructure[] = {
     218  { L"ACPI Processor ID",                  4, 0, L"0x%x",  NULL, (VOID **)&ProcessorId,           NULL, NULL },
     219  { L"Resource Type",                      1, 4, L"%d",    NULL, (VOID **)&ProcessorResourceType, NULL,
     220    NULL },
     221  { L"Reserved",                           1, 5, L"0x%x",  NULL, NULL,                            NULL, NULL },
     222  { L"Flags",                              1, 6, L"0x%x",  NULL, (VOID **)&ProcessorFlags,
     223    ValidateProcessorFlags, NULL },
     224  { L"Revision",                           1, 7, L"%d",    NULL, NULL,                            NULL, NULL },
     225  { L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL,                            NULL,
     226    NULL },
    225227  // Resource specific data...
    226228};
     
    229231  An ACPI_PARSER array describing the processor cache resource substructure.
    230232**/
    231 STATIC CONST ACPI_PARSER AestProcessorCacheResourceSubstructure[] = {
    232   {L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    233   {L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL}
     233STATIC CONST ACPI_PARSER  AestProcessorCacheResourceSubstructure[] = {
     234  { L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
     235  { L"Reserved",           4, 4, L"%d",   NULL, NULL, NULL, NULL }
    234236};
    235237
     
    237239  An ACPI_PARSER array describing the processor TLB resource substructure.
    238240**/
    239 STATIC CONST ACPI_PARSER AestProcessorTlbResourceSubstructure[] = {
    240   {L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    241   {L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL}
     241STATIC CONST ACPI_PARSER  AestProcessorTlbResourceSubstructure[] = {
     242  { L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
     243  { L"Reserved",         4, 4, L"%d",   NULL, NULL, NULL, NULL }
    242244};
    243245
     
    245247  An ACPI_PARSER array describing the processor generic resource substructure.
    246248**/
    247 STATIC CONST ACPI_PARSER AestProcessorGenericResourceSubstructure[] = {
    248   {L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL}
     249STATIC CONST ACPI_PARSER  AestProcessorGenericResourceSubstructure[] = {
     250  { L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL }
    249251};
    250252
     
    252254  An ACPI_PARSER array describing the memory controller structure.
    253255**/
    254 STATIC CONST ACPI_PARSER AestMemoryControllerStructure[] = {
    255   {L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}
     256STATIC CONST ACPI_PARSER  AestMemoryControllerStructure[] = {
     257  { L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL }
    256258};
    257259
     
    259261  An ACPI_PARSER array describing the SMMU structure.
    260262**/
    261 STATIC CONST ACPI_PARSER AestSmmuStructure[] = {
    262   {L"IORT Node reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    263   {L"SubComponent reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
     263STATIC CONST ACPI_PARSER  AestSmmuStructure[] = {
     264  { L"IORT Node reference ID",    4, 0, L"0x%x", NULL, NULL, NULL, NULL },
     265  { L"SubComponent reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL }
    264266};
    265267
     
    267269  An ACPI_PARSER array describing the vendor-defined structure.
    268270**/
    269 STATIC CONST ACPI_PARSER AestVendorDefinedStructure[] = {
    270   {L"Hardware ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    271   {L"Unique ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    272   {L"Vendor-specific data", 16, 8, NULL, DumpVendorSpecificData, NULL, NULL}
     271STATIC CONST ACPI_PARSER  AestVendorDefinedStructure[] = {
     272  { L"Hardware ID",          4,  0, L"0x%x", NULL,                   NULL, NULL, NULL },
     273  { L"Unique ID",            4,  4, L"0x%x", NULL,                   NULL, NULL, NULL },
     274  { L"Vendor-specific data", 16, 8, NULL,    DumpVendorSpecificData, NULL, NULL }
    273275};
    274276
     
    276278  An ACPI_PARSER array describing the GIC structure.
    277279**/
    278 STATIC CONST ACPI_PARSER AestGicStructure[] = {
    279   {L"GIC Interface Type", 4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType,
    280     NULL},
    281   {L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
     280STATIC CONST ACPI_PARSER  AestGicStructure[] = {
     281  { L"GIC Interface Type",        4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType,
     282    NULL },
     283  { L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL,                    NULL}
    282284};
    283285
     
    285287  An ACPI_PARSER array describing the node interface.
    286288**/
    287 STATIC CONST ACPI_PARSER AestNodeInterface[] = {
    288   {L"Interface Type", 1, 0, L"%d", NULL, NULL, ValidateInterfaceType, NULL},
    289   {L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},
    290   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    291   {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    292   {L"Start Error Record Index", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    293   {L"Number of Error Records", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    294   {L"Error Records Implemented", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL},
    295   {L"Error Records Support", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
    296   {L"Addressing mode", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}
     289STATIC CONST ACPI_PARSER  AestNodeInterface[] = {
     290  { L"Interface Type",            1, 0,  L"%d",       NULL,       NULL, ValidateInterfaceType, NULL },
     291  { L"Reserved",                  3, 1,  L"%x %x %x", Dump3Chars, NULL, NULL,                  NULL },
     292  { L"Flags",                     4, 4,  L"0x%x",     NULL,       NULL, NULL,                  NULL },
     293  { L"Base Address",              8, 8,  L"0x%lx",    NULL,       NULL, NULL,                  NULL },
     294  { L"Start Error Record Index",  4, 16, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     295  { L"Number of Error Records",   4, 20, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     296  { L"Error Records Implemented", 8, 24, L"0x%lx",    NULL,       NULL, NULL,                  NULL },
     297  { L"Error Records Support",     8, 32, L"0x%lx",    NULL,       NULL, NULL,                  NULL },
     298  { L"Addressing mode",           8, 40, L"0x%lx",    NULL,       NULL, NULL,                  NULL }
    297299};
    298300
     
    300302  An ACPI_PARSER array describing the node interrupts.
    301303**/
    302 STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
    303   {L"Interrupt Type", 1, 0, L"%d", NULL, NULL, ValidateInterruptType, NULL},
    304   {L"Reserved", 2, 1, L"0x%x", NULL, NULL, NULL, NULL},
    305   {L"Interrupt Flags", 1, 3, L"0x%x", NULL, NULL, ValidateInterruptFlags, NULL},
    306   {L"Interrupt GSIV", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    307   {L"ID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},
    308   {L"Reserved1", 3, 9, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
     304STATIC CONST ACPI_PARSER  AestNodeInterrupt[] = {
     305  { L"Interrupt Type",  1, 0, L"%d",       NULL,       NULL, ValidateInterruptType,  NULL },
     306  { L"Reserved",        2, 1, L"0x%x",     NULL,       NULL, NULL,                   NULL },
     307  { L"Interrupt Flags", 1, 3, L"0x%x",     NULL,       NULL, ValidateInterruptFlags, NULL },
     308  { L"Interrupt GSIV",  4, 4, L"0x%x",     NULL,       NULL, NULL,                   NULL },
     309  { L"ID",              1, 8, L"0x%x",     NULL,       NULL, NULL,                   NULL },
     310  { L"Reserved1",       3, 9, L"%x %x %x", Dump3Chars, NULL, NULL,                   NULL }
    309311};
    310312
     
    319321VOID
    320322DumpProcessorNode (
    321   IN UINT8* Ptr,
    322   IN UINT32 Length
    323   )
    324 {
    325   UINT32 Offset;
     323  IN UINT8   *Ptr,
     324  IN UINT32  Length
     325  )
     326{
     327  UINT32  Offset;
    326328
    327329  Offset = ParseAcpi (
     
    338340  if ((ProcessorId == NULL)           ||
    339341      (ProcessorResourceType == NULL) ||
    340       (ProcessorFlags == NULL)) {
     342      (ProcessorFlags == NULL))
     343  {
    341344    IncrementErrorCount ();
    342345    Print (
     
    394397VOID
    395398DumpMemoryControllerNode (
    396   IN UINT8* Ptr,
    397   IN UINT32 Length
     399  IN UINT8   *Ptr,
     400  IN UINT32  Length
    398401  )
    399402{
     
    417420VOID
    418421DumpSmmuNode (
    419   IN UINT8* Ptr,
    420   IN UINT32 Length
     422  IN UINT8   *Ptr,
     423  IN UINT32  Length
    421424  )
    422425{
     
    440443VOID
    441444DumpVendorDefinedNode (
    442   IN UINT8* Ptr,
    443   IN UINT32 Length
     445  IN UINT8   *Ptr,
     446  IN UINT32  Length
    444447  )
    445448{
     
    463466VOID
    464467DumpGicNode (
    465   IN UINT8* Ptr,
    466   IN UINT32 Length
     468  IN UINT8   *Ptr,
     469  IN UINT32  Length
    467470  )
    468471{
     
    486489VOID
    487490DumpNodeInterface (
    488   IN UINT8* Ptr,
    489   IN UINT32 Length
     491  IN UINT8   *Ptr,
     492  IN UINT32  Length
    490493  )
    491494{
     
    510513VOID
    511514DumpNodeInterrupts (
    512   IN UINT8* Ptr,
    513   IN UINT32 Length,
    514   IN UINT32 InterruptCount
    515   )
    516 {
    517   UINT32 Offset;
    518   UINT32 Index;
    519   CHAR8  Buffer[64];
     515  IN UINT8   *Ptr,
     516  IN UINT32  Length,
     517  IN UINT32  InterruptCount
     518  )
     519{
     520  UINT32  Offset;
     521  UINT32  Index;
     522  CHAR8   Buffer[64];
    520523
    521524  if (Length < (InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT))) {
    522525    IncrementErrorCount ();
    523526    Print (
    524       L"ERROR: Node not long enough for Interrupt Array.\n"\
     527      L"ERROR: Node not long enough for Interrupt Array.\n" \
    525528      L"       Length left = %d, Required = %d, Interrupt Count = %d\n",
    526529      Length,
     
    548551                PARSER_PARAMS (AestNodeInterrupt)
    549552                );
    550   } //for
     553  } // for
    551554}
    552555
     
    565568VOID
    566569DumpAestNodeStructure (
    567   IN UINT8Ptr,
     570  IN UINT8   *Ptr,
    568571  IN UINT32  Length,
    569572  IN UINT8   NodeType,
     
    574577  )
    575578{
    576   UINT32 Offset;
    577   UINT32 RemainingLength;
    578   UINT8* NodeDataPtr;
     579  UINT32  Offset;
     580  UINT32  RemainingLength;
     581  UINT8   *NodeDataPtr;
    579582
    580583  Offset = ParseAcpi (
     
    590593    IncrementErrorCount ();
    591594    Print (
    592       L"ERROR: Invalid Node Data Offset: %d.\n"\
     595      L"ERROR: Invalid Node Data Offset: %d.\n" \
    593596      L"       It should be between %d and %d.\n",
    594597      DataOffset,
     
    601604    IncrementErrorCount ();
    602605    Print (
    603       L"ERROR: Invalid Node Interface Offset: %d.\n"\
     606      L"ERROR: Invalid Node Interface Offset: %d.\n" \
    604607      L"       It should be between %d and %d.\n",
    605608      InterfaceOffset,
     
    612615    IncrementErrorCount ();
    613616    Print (
    614       L"ERROR: Invalid Node Interrupt Array Offset: %d.\n"\
     617      L"ERROR: Invalid Node Interrupt Array Offset: %d.\n" \
    615618      L"       It should be between %d and %d.\n",
    616619      InterruptArrayOffset,
     
    621624
    622625  // Parse Node Data Field.
    623   NodeDataPtr = Ptr + DataOffset;
     626  NodeDataPtr     = Ptr + DataOffset;
    624627  RemainingLength = Length - DataOffset;
    625628  switch (NodeType) {
     
    676679EFIAPI
    677680ParseAcpiAest (
    678   IN BOOLEAN Trace,
    679   IN UINT8Ptr,
    680   IN UINT32  AcpiTableLength,
    681   IN UINT8   AcpiTableRevision
     681  IN BOOLEAN  Trace,
     682  IN UINT8    *Ptr,
     683  IN UINT32   AcpiTableLength,
     684  IN UINT8    AcpiTableRevision
    682685  )
    683686{
    684687  UINT32  Offset;
    685   UINT8NodePtr;
     688  UINT8   *NodePtr;
    686689
    687690  if (!Trace) {
     
    717720        (NodeInterfaceOffset == NULL)      ||
    718721        (NodeInterruptArrayOffset == NULL) ||
    719         (NodeInterruptCount == NULL)) {
     722        (NodeInterruptCount == NULL))
     723    {
    720724      IncrementErrorCount ();
    721725      Print (
    722         L"ERROR: Insufficient length left for Node Structure.\n"\
     726        L"ERROR: Insufficient length left for Node Structure.\n" \
    723727        L"       Length left = %d.\n",
    724728        AcpiTableLength - Offset
     
    729733    // Validate AEST Node length
    730734    if ((*AestNodeLength == 0) ||
    731         ((Offset + (*AestNodeLength)) > AcpiTableLength)) {
     735        ((Offset + (*AestNodeLength)) > AcpiTableLength))
     736    {
    732737      IncrementErrorCount ();
    733738      Print (
    734739        L"ERROR: Invalid AEST Node length. " \
    735           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     740        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    736741        *AestNodeLength,
    737742        Offset,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c

    r80721 r99404  
    1515
    1616// Local variables
    17 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     17STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    1818
    1919/**
    2020  An ACPI_PARSER array describing the ACPI BDRT Table.
    2121**/
    22 STATIC CONST ACPI_PARSER BgrtParser[] = {
     22STATIC CONST ACPI_PARSER  BgrtParser[] = {
    2323  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    24   {L"Version", 2, 36, L"0x%x", NULL, NULL, NULL, NULL},
    25   {L"Status", 1, 38, L"0x%x", NULL,  NULL, NULL, NULL},
    26   {L"Image Type", 1, 39, L"0x%x", NULL, NULL, NULL, NULL},
    27   {L"Image Address", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL},
    28   {L"Image Offset X", 4, 48, L"%d", NULL, NULL, NULL, NULL},
    29   {L"Image Offset Y", 4, 52, L"%d", NULL, NULL, NULL, NULL}
     24  { L"Version",                    2,  36, L"0x%x",  NULL, NULL, NULL, NULL },
     25  { L"Status",                     1,  38, L"0x%x",  NULL, NULL, NULL, NULL },
     26  { L"Image Type",                 1,  39, L"0x%x",  NULL, NULL, NULL, NULL },
     27  { L"Image Address",              8,  40, L"0x%lx", NULL, NULL, NULL, NULL },
     28  { L"Image Offset X",             4,  48, L"%d",    NULL, NULL, NULL, NULL },
     29  { L"Image Offset Y",             4,  52, L"%d",    NULL, NULL, NULL, NULL }
    3030};
    3131
     
    4545EFIAPI
    4646ParseAcpiBgrt (
    47   IN BOOLEAN Trace,
    48   IN UINT8Ptr,
    49   IN UINT32  AcpiTableLength,
    50   IN UINT8   AcpiTableRevision
     47  IN BOOLEAN  Trace,
     48  IN UINT8    *Ptr,
     49  IN UINT32   AcpiTableLength,
     50  IN UINT8    AcpiTableRevision
    5151  )
    5252{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c

    r85718 r99404  
    1515
    1616// Local variables pointing to the table fields
    17 STATIC CONST UINT32* OffsetDbgDeviceInfo;
    18 STATIC CONST UINT32* NumberDbgDeviceInfo;
    19 STATIC CONST UINT16* DbgDevInfoLen;
    20 STATIC CONST UINT8GasCount;
    21 STATIC CONST UINT16* NameSpaceStringLength;
    22 STATIC CONST UINT16* NameSpaceStringOffset;
    23 STATIC CONST UINT16* OEMDataLength;
    24 STATIC CONST UINT16* OEMDataOffset;
    25 STATIC CONST UINT16* BaseAddrRegOffset;
    26 STATIC CONST UINT16* AddrSizeOffset;
    27 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     17STATIC CONST UINT32                  *OffsetDbgDeviceInfo;
     18STATIC CONST UINT32                  *NumberDbgDeviceInfo;
     19STATIC CONST UINT16                  *DbgDevInfoLen;
     20STATIC CONST UINT8                   *GasCount;
     21STATIC CONST UINT16                  *NameSpaceStringLength;
     22STATIC CONST UINT16                  *NameSpaceStringOffset;
     23STATIC CONST UINT16                  *OEMDataLength;
     24STATIC CONST UINT16                  *OEMDataOffset;
     25STATIC CONST UINT16                  *BaseAddrRegOffset;
     26STATIC CONST UINT16                  *AddrSizeOffset;
     27STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2828
    2929/**
     
    3838EFIAPI
    3939ValidateNameSpaceStrLen (
    40   IN UINT8* Ptr,
    41   IN VOIDContext
     40  IN UINT8  *Ptr,
     41  IN VOID   *Context
    4242  )
    4343{
    44   UINT16 NameSpaceStrLen;
    45 
    46   NameSpaceStrLen = *(UINT16*)Ptr;
     44  UINT16  NameSpaceStrLen;
     45
     46  NameSpaceStrLen = *(UINT16 *)Ptr;
    4747
    4848  if (NameSpaceStrLen < 2) {
     
    5050    Print (
    5151      L"\nERROR: NamespaceString Length = %d. If no Namespace device exists, " \
    52         L"NamespaceString[] must contain a period '.'",
     52      L"NamespaceString[] must contain a period '.'",
    5353      NameSpaceStrLen
    5454      );
     
    5757
    5858/// An ACPI_PARSER array describing the ACPI DBG2 table.
    59 STATIC CONST ACPI_PARSER Dbg2Parser[] = {
     59STATIC CONST ACPI_PARSER  Dbg2Parser[] = {
    6060  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    61   {L"OffsetDbgDeviceInfo", 4, 36, L"0x%x", NULL,
    62    (VOID**)&OffsetDbgDeviceInfo, NULL, NULL},
    63   {L"NumberDbgDeviceInfo", 4, 40, L"%d", NULL,
    64    (VOID**)&NumberDbgDeviceInfo, NULL, NULL}
     61  { L"OffsetDbgDeviceInfo",        4,    36, L"0x%x", NULL,
     62    (VOID **)&OffsetDbgDeviceInfo, NULL,  NULL },
     63  { L"NumberDbgDeviceInfo",        4,     40, L"%d",  NULL,
     64    (VOID **)&NumberDbgDeviceInfo, NULL,  NULL }
    6565};
    6666
    6767/// An ACPI_PARSER array describing the debug device information structure
    6868/// header.
    69 STATIC CONST ACPI_PARSER DbgDevInfoHeaderParser[] = {
    70   {L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    71   {L"Length", 2, 1, L"%d", NULL, (VOID**)&DbgDevInfoLen, NULL, NULL}
     69STATIC CONST ACPI_PARSER  DbgDevInfoHeaderParser[] = {
     70  { L"Revision", 1, 0, L"0x%x", NULL, NULL,                    NULL, NULL },
     71  { L"Length",   2, 1, L"%d",   NULL, (VOID **)&DbgDevInfoLen, NULL, NULL }
    7272};
    7373
    7474/// An ACPI_PARSER array describing the debug device information.
    75 STATIC CONST ACPI_PARSER DbgDevInfoParser[] = {
    76   {L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    77   {L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL},
    78 
    79   {L"Generic Address Registers Count", 1, 3, L"0x%x", NULL,
    80    (VOID**)&GasCount, NULL, NULL},
    81   {L"NameSpace String Length", 2, 4, L"%d", NULL,
    82    (VOID**)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL},
    83   {L"NameSpace String Offset", 2, 6, L"0x%x", NULL,
    84    (VOID**)&NameSpaceStringOffset, NULL, NULL},
    85   {L"OEM Data Length", 2, 8, L"%d", NULL, (VOID**)&OEMDataLength,
    86    NULL, NULL},
    87   {L"OEM Data Offset", 2, 10, L"0x%x", NULL, (VOID**)&OEMDataOffset,
    88    NULL, NULL},
    89 
    90   {L"Port Type", 2, 12, L"0x%x", NULL, NULL, NULL, NULL},
    91   {L"Port SubType", 2, 14, L"0x%x", NULL, NULL, NULL, NULL},
    92   {L"Reserved", 2, 16, L"%x", NULL, NULL, NULL, NULL},
    93 
    94   {L"Base Address Register Offset", 2, 18, L"0x%x", NULL,
    95    (VOID**)&BaseAddrRegOffset, NULL, NULL},
    96   {L"Address Size Offset", 2, 20, L"0x%x", NULL,
    97    (VOID**)&AddrSizeOffset, NULL, NULL}
     75STATIC CONST ACPI_PARSER  DbgDevInfoParser[] = {
     76  { L"Revision",                        1, 0,  L"0x%x", NULL, NULL,                    NULL, NULL },
     77  { L"Length",                          2, 1,  L"%d",   NULL, NULL,                    NULL, NULL },
     78
     79  { L"Generic Address Registers Count", 1, 3, L"0x%x", NULL,
     80    (VOID **)&GasCount, NULL, NULL },
     81  { L"NameSpace String Length",         2, 4,  L"%d",  NULL,
     82    (VOID **)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL },
     83  { L"NameSpace String Offset",         2, 6, L"0x%x", NULL,
     84    (VOID **)&NameSpaceStringOffset, NULL, NULL },
     85  { L"OEM Data Length",                 2, 8,  L"%d",   NULL, (VOID **)&OEMDataLength,
     86    NULL, NULL },
     87  { L"OEM Data Offset",                 2, 10, L"0x%x", NULL, (VOID **)&OEMDataOffset,
     88    NULL, NULL },
     89
     90  { L"Port Type",                       2, 12, L"0x%x", NULL, NULL,                    NULL, NULL },
     91  { L"Port SubType",                    2, 14, L"0x%x", NULL, NULL,                    NULL, NULL },
     92  { L"Reserved",                        2, 16, L"%x",   NULL, NULL,                    NULL, NULL },
     93
     94  { L"Base Address Register Offset",    2, 18, L"0x%x", NULL,
     95    (VOID **)&BaseAddrRegOffset, NULL, NULL },
     96  { L"Address Size Offset",            2, 20, L"0x%x", NULL,
     97    (VOID **)&AddrSizeOffset, NULL, NULL }
    9898};
    9999
     
    108108EFIAPI
    109109DumpDbgDeviceInfo (
    110   IN UINT8* Ptr,
    111   IN UINT16 Length
     110  IN UINT8   *Ptr,
     111  IN UINT16  Length
    112112  )
    113113{
     
    132132      (OEMDataOffset == NULL)         ||
    133133      (BaseAddrRegOffset == NULL)     ||
    134       (AddrSizeOffset == NULL)) {
     134      (AddrSizeOffset == NULL))
     135  {
    135136    IncrementErrorCount ();
    136137    Print (
    137138      L"ERROR: Insufficient Debug Device Information Structure length. " \
    138         L"Length = %d.\n",
     139      L"Length = %d.\n",
    139140      Length
    140141      );
     
    143144
    144145  // GAS
    145   Index = 0;
     146  Index  = 0;
    146147  Offset = *BaseAddrRegOffset;
    147148  while ((Index++ < *GasCount) &&
    148          (Offset < Length)) {
     149         (Offset < Length))
     150  {
    149151    PrintFieldName (4, L"BaseAddressRegister");
    150152    Offset += (UINT16)DumpGasStruct (
     
    161163    Print (
    162164      L"ERROR: Invalid GAS count. GasCount = %d. RemainingBufferLength = %d. " \
    163         L"Parsing of the Debug Device Information structure aborted.\n",
     165      L"Parsing of the Debug Device Information structure aborted.\n",
    164166      *GasCount,
    165167      Length - *AddrSizeOffset
     
    169171
    170172  // Address Size
    171   Index = 0;
     173  Index  = 0;
    172174  Offset = *AddrSizeOffset;
    173175  while ((Index++ < *GasCount) &&
    174          (Offset < Length)) {
     176         (Offset < Length))
     177  {
    175178    PrintFieldName (4, L"Address Size");
    176     Print (L"0x%x\n", *((UINT32*)(Ptr + Offset)));
     179    Print (L"0x%x\n", *((UINT32 *)(Ptr + Offset)));
    177180    Offset += sizeof (UINT32);
    178181  }
    179182
    180183  // NameSpace String
    181   Index = 0;
     184  Index  = 0;
    182185  Offset = *NameSpaceStringOffset;
    183186  PrintFieldName (4, L"NameSpace String");
    184187  while ((Index++ < *NameSpaceStringLength) &&
    185          (Offset < Length)) {
     188         (Offset < Length))
     189  {
    186190    Print (L"%c", *(Ptr + Offset));
    187191    Offset++;
    188192  }
     193
    189194  Print (L"\n");
    190195
    191196  // OEM Data
    192197  if (*OEMDataOffset != 0) {
    193     Index = 0;
     198    Index  = 0;
    194199    Offset = *OEMDataOffset;
    195200    PrintFieldName (4, L"OEM Data");
    196201    while ((Index++ < *OEMDataLength) &&
    197            (Offset < Length)) {
     202           (Offset < Length))
     203    {
    198204      Print (L"%x ", *(Ptr + Offset));
    199205      if ((Index & 7) == 0) {
    200206        Print (L"\n%-*s   ", OUTPUT_FIELD_COLUMN_WIDTH, L"");
    201207      }
     208
    202209      Offset++;
    203210    }
     211
    204212    Print (L"\n");
    205213  }
     
    221229EFIAPI
    222230ParseAcpiDbg2 (
    223   IN BOOLEAN Trace,
    224   IN UINT8Ptr,
    225   IN UINT32  AcpiTableLength,
    226   IN UINT8   AcpiTableRevision
     231  IN BOOLEAN  Trace,
     232  IN UINT8    *Ptr,
     233  IN UINT32   AcpiTableLength,
     234  IN UINT8    AcpiTableRevision
    227235  )
    228236{
    229   UINT32 Offset;
    230   UINT32 Index;
     237  UINT32  Offset;
     238  UINT32  Index;
    231239
    232240  if (!Trace) {
     
    246254  // successfully read.
    247255  if ((OffsetDbgDeviceInfo == NULL) ||
    248       (NumberDbgDeviceInfo == NULL)) {
     256      (NumberDbgDeviceInfo == NULL))
     257  {
    249258    IncrementErrorCount ();
    250259    Print (
     
    256265
    257266  Offset = *OffsetDbgDeviceInfo;
    258   Index = 0;
     267  Index  = 0;
    259268
    260269  while (Index++ < *NumberDbgDeviceInfo) {
    261 
    262270    // Parse the Debug Device Information Structure header to obtain Length
    263271    ParseAcpi (
     
    276284      Print (
    277285        L"ERROR: Insufficient remaining table buffer length to read the " \
    278           L"Debug Device Information structure's 'Length' field. " \
    279           L"RemainingTableBufferLength = %d.\n",
     286        L"Debug Device Information structure's 'Length' field. " \
     287        L"RemainingTableBufferLength = %d.\n",
    280288        AcpiTableLength - Offset
    281289        );
     
    285293    // Validate Debug Device Information Structure length
    286294    if ((*DbgDevInfoLen == 0) ||
    287         ((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) {
     295        ((Offset + (*DbgDevInfoLen)) > AcpiTableLength))
     296    {
    288297      IncrementErrorCount ();
    289298      Print (
    290299        L"ERROR: Invalid Debug Device Information Structure length. " \
    291           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     300        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    292301        *DbgDevInfoLen,
    293302        Offset,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c

    r80721 r99404  
    22  DSDT table parser
    33
    4   Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
     4  Copyright (c) 2016 - 2022, ARM Limited. All rights reserved.
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
     
    2929EFIAPI
    3030ParseAcpiDsdt (
    31   IN BOOLEAN Trace,
    32   IN UINT8Ptr,
    33   IN UINT32  AcpiTableLength,
    34   IN UINT8   AcpiTableRevision
     31  IN BOOLEAN  Trace,
     32  IN UINT8    *Ptr,
     33  IN UINT32   AcpiTableLength,
     34  IN UINT8    AcpiTableRevision
    3535  )
    3636{
     
    4040
    4141  DumpAcpiHeader (Ptr);
     42
     43  // As per 19.6.29 in the version 6.4 of the ACPI spec, a revision less than 2
     44  // restricts integers to 32 bit width. This may not be intended, raise a
     45  // warning
     46 #if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM)
     47  if (AcpiTableRevision < 2) {
     48    IncrementWarningCount ();
     49    Print (
     50      L"WARNING: DSDT Table Revision less than 2. Integer width restricted to "
     51      L"32 bits. Table Revision = %d.\n",
     52      AcpiTableRevision
     53      );
     54    return;
     55  }
     56
     57 #endif
    4258}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c

    r85718 r99404  
    1717  An ACPI_PARSER array describing the ACPI FACS Table.
    1818**/
    19 STATIC CONST ACPI_PARSER FacsParser[] = {
    20   {L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, NULL, NULL, NULL},
    21   {L"Length", 4, 4, L"%d", NULL,  NULL, NULL, NULL},
    22   {L"Hardware Signature", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    23   {L"Firmware Waking Vector", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    24   {L"Global Lock", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    25   {L"Flags", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    26   {L"X Firmware Walking Vector", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL},
    27   {L"Version", 1, 32, L"%d", NULL, NULL, NULL, NULL},
    28   {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},
    29   {L"OSPM Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL},
    30   {L"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
    31     NULL},
    32   {L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
    33     NULL},
    34   {L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
    35     NULL}
     19STATIC CONST ACPI_PARSER  FacsParser[] = {
     20  { L"Signature",                 4, 0,  L"%c%c%c%c",                Dump4Chars, NULL, NULL, NULL },
     21  { L"Length",                    4, 4,  L"%d",                      NULL,       NULL, NULL, NULL },
     22  { L"Hardware Signature",        4, 8,  L"0x%x",                    NULL,       NULL, NULL, NULL },
     23  { L"Firmware Waking Vector",    4, 12, L"0x%x",                    NULL,       NULL, NULL, NULL },
     24  { L"Global Lock",               4, 16, L"0x%x",                    NULL,       NULL, NULL, NULL },
     25  { L"Flags",                     4, 20, L"0x%x",                    NULL,       NULL, NULL, NULL },
     26  { L"X Firmware Walking Vector", 8, 24, L"0x%lx",                   NULL,       NULL, NULL, NULL },
     27  { L"Version",                   1, 32, L"%d",                      NULL,       NULL, NULL, NULL },
     28  { L"Reserved",                  3, 33, L"%x %x %x",                Dump3Chars, NULL, NULL, NULL },
     29  { L"OSPM Flags",                4, 36, L"0x%x",                    NULL,       NULL, NULL, NULL },
     30  { L"Reserved",                  8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
     31    NULL },
     32  { L"Reserved",                  8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
     33    NULL },
     34  { L"Reserved",                  8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
     35    NULL }
    3636};
    3737
     
    5151EFIAPI
    5252ParseAcpiFacs (
    53   IN BOOLEAN Trace,
    54   IN UINT8Ptr,
    55   IN UINT32  AcpiTableLength,
    56   IN UINT8   AcpiTableRevision
     53  IN BOOLEAN  Trace,
     54  IN UINT8    *Ptr,
     55  IN UINT32   AcpiTableLength,
     56  IN UINT8    AcpiTableRevision
    5757  )
    5858{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c

    r85718 r99404  
    33
    44  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
     5  Copyright (c) 2022, AMD Incorporated. All rights reserved.
    56  SPDX-License-Identifier: BSD-2-Clause-Patent
    67
     
    1617
    1718// Local variables
    18 STATIC CONST UINT32* DsdtAddress;
    19 STATIC CONST UINT64* X_DsdtAddress;
    20 STATIC CONST UINT32* Flags;
    21 STATIC CONST UINT32* FirmwareCtrl;
    22 STATIC CONST UINT64* X_FirmwareCtrl;
    23 STATIC CONST UINT8FadtMinorRevision;
    24 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     19STATIC CONST UINT32                  *DsdtAddress;
     20STATIC CONST UINT64                  *X_DsdtAddress;
     21STATIC CONST UINT32                  *Flags;
     22STATIC CONST UINT32                  *FirmwareCtrl;
     23STATIC CONST UINT64                  *X_FirmwareCtrl;
     24STATIC CONST UINT8                   *FadtMinorRevision;
     25STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2526
    2627/**
    2728  A macro defining the Hardware reduced ACPI flag
    2829**/
    29 #define HW_REDUCED_ACPI   BIT20
     30#define HW_REDUCED_ACPI  BIT20
    3031
    3132/**
    3233  Offset to the FACS signature from the start of the FACS.
    3334**/
    34 #define FACS_SIGNATURE_OFFSET   0
     35#define FACS_SIGNATURE_OFFSET  0
    3536
    3637/**
    3738  Offset to the FACS revision from the start of the FACS.
    3839**/
    39 #define FACS_VERSION_OFFSET     32
     40#define FACS_VERSION_OFFSET  32
    4041
    4142/**
    4243  Offset to the FACS length from the start of the FACS.
    4344**/
    44 #define FACS_LENGTH_OFFSET      4
     45#define FACS_LENGTH_OFFSET  4
    4546
    4647/**
     
    6465EFIAPI
    6566ValidateFirmwareCtrl (
    66   IN UINT8* Ptr,
    67   IN VOIDContext
    68 )
    69 {
    70 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    71   if (*(UINT32*)Ptr != 0) {
     67  IN UINT8  *Ptr,
     68  IN VOID   *Context
     69  )
     70{
     71 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     72  if (*(UINT32 *)Ptr != 0) {
    7273    IncrementErrorCount ();
    7374    Print (
    7475      L"\nERROR: Firmware Control must be zero for ARM platforms."
    75     );
    76   }
    77 #endif
     76      );
     77  }
     78
     79 #endif
    7880}
    7981
     
    8991EFIAPI
    9092ValidateXFirmwareCtrl (
    91   IN UINT8* Ptr,
    92   IN VOIDContext
    93 )
    94 {
    95 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    96   if (*(UINT64*)Ptr != 0) {
     93  IN UINT8  *Ptr,
     94  IN VOID   *Context
     95  )
     96{
     97 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     98  if (*(UINT64 *)Ptr != 0) {
    9799    IncrementErrorCount ();
    98100    Print (
    99101      L"\nERROR: X Firmware Control must be zero for ARM platforms."
    100     );
    101   }
    102 #endif
     102      );
     103  }
     104
     105 #endif
    103106}
    104107
     
    114117EFIAPI
    115118ValidateFlags (
    116   IN UINT8* Ptr,
    117   IN VOIDContext
    118 )
    119 {
    120 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    121   if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) == 0) {
     119  IN UINT8  *Ptr,
     120  IN VOID   *Context
     121  )
     122{
     123 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     124  if (((*(UINT32 *)Ptr) & HW_REDUCED_ACPI) == 0) {
    122125    IncrementErrorCount ();
    123126    Print (
    124127      L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms."
     128      );
     129  }
     130
     131 #endif
     132}
     133
     134STATIC CONST ACPI_PARSER  FadtFlagParser[] = {
     135  { L"WBINVD",                               1,  0,  L"%d", NULL, NULL, NULL, NULL },
     136  { L"WBINVD_FLUSH",                         1,  1,  L"%d", NULL, NULL, NULL, NULL },
     137  { L"PROC_C1",                              1,  2,  L"%d", NULL, NULL, NULL, NULL },
     138  { L"P_LVL2_UP",                            1,  3,  L"%d", NULL, NULL, NULL, NULL },
     139  { L"PWR_BUTTON",                           1,  4,  L"%d", NULL, NULL, NULL, NULL },
     140  { L"SLP_BUTTON",                           1,  5,  L"%d", NULL, NULL, NULL, NULL },
     141  { L"FIX_RTC",                              1,  6,  L"%d", NULL, NULL, NULL, NULL },
     142  { L"RTC_S4",                               1,  7,  L"%d", NULL, NULL, NULL, NULL },
     143  { L"TMR_VAL_EXT",                          1,  8,  L"%d", NULL, NULL, NULL, NULL },
     144  { L"DCK_CAP",                              1,  9,  L"%d", NULL, NULL, NULL, NULL },
     145  { L"RESET_REG_SUP",                        1,  10, L"%d", NULL, NULL, NULL, NULL },
     146  { L"SEALED_CASE",                          1,  11, L"%d", NULL, NULL, NULL, NULL },
     147  { L"HEADLESS",                             1,  12, L"%d", NULL, NULL, NULL, NULL },
     148  { L"CPU_SW_SLP",                           1,  13, L"%d", NULL, NULL, NULL, NULL },
     149  { L"PCI_EXP_WAK",                          1,  14, L"%d", NULL, NULL, NULL, NULL },
     150  { L"USE_PLATFORM_CLOCK",                   1,  15, L"%d", NULL, NULL, NULL, NULL },
     151  { L"S4_RTC_STS_VALID",                     1,  16, L"%d", NULL, NULL, NULL, NULL },
     152  { L"REMOTE_POWER_ON_CAPABLE",              1,  17, L"%d", NULL, NULL, NULL, NULL },
     153  { L"FORCE_APIC_CLUSTER_MODEL",             1,  18, L"%d", NULL, NULL, NULL, NULL },
     154  { L"FORCE_APIC_PHYSICAL_DESTINATION_MODE", 1,  19, L"%d", NULL, NULL, NULL, NULL },
     155  { L"HW_REDUCED_ACPI",                      1,  20, L"%d", NULL, NULL, NULL, NULL },
     156  { L"LOW_POWER_S0_IDLE_CAPABLE",            1,  21, L"%d", NULL, NULL, NULL, NULL },
     157  { L"Reserved",                             10, 22, L"%d", NULL, NULL, NULL, NULL }
     158};
     159
     160/**
     161  This function traces FADT Flags fields.
     162  If no format string is specified the Format must be NULL.
     163
     164  @param [in] Format  Optional format string for tracing the data.
     165  @param [in] Ptr     Pointer to the start of the buffer.
     166**/
     167VOID
     168EFIAPI
     169DumpFadtFlags (
     170  IN CONST CHAR16  *Format OPTIONAL,
     171  IN UINT8         *Ptr
     172  )
     173{
     174  if (Format != NULL) {
     175    Print (Format, *(UINT32 *)Ptr);
     176    return;
     177  }
     178
     179  Print (L"0x%X\n", *(UINT32 *)Ptr);
     180  ParseAcpiBitFields (
     181    TRUE,
     182    2,
     183    NULL,
     184    Ptr,
     185    4,
     186    PARSER_PARAMS (FadtFlagParser)
    125187    );
    126   }
    127 #endif
    128188}
    129189
     
    131191  An ACPI_PARSER array describing the ACPI FADT Table.
    132192**/
    133 STATIC CONST ACPI_PARSER FadtParser[] = {
     193STATIC CONST ACPI_PARSER  FadtParser[] = {
    134194  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    135   {L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID**)&FirmwareCtrl,
    136     ValidateFirmwareCtrl, NULL},
    137   {L"DSDT", 4, 40, L"0x%x", NULL, (VOID**)&DsdtAddress, NULL, NULL},
    138   {L"Reserved", 1, 44, L"%x", NULL, NULL, NULL, NULL},
    139   {L"Preferred_PM_Profile", 1, 45, L"0x%x", NULL, NULL, NULL, NULL},
    140   {L"SCI_INT", 2, 46, L"0x%x", NULL, NULL, NULL, NULL},
    141   {L"SMI_CMD", 4, 48, L"0x%x", NULL, NULL, NULL, NULL},
    142   {L"ACPI_ENABLE", 1, 52, L"0x%x", NULL, NULL, NULL, NULL},
    143   {L"ACPI_DISABLE", 1, 53, L"0x%x", NULL, NULL, NULL, NULL},
    144   {L"S4BIOS_REQ", 1, 54, L"0x%x", NULL, NULL, NULL, NULL},
    145   {L"PSTATE_CNT", 1, 55, L"0x%x", NULL, NULL, NULL, NULL},
    146   {L"PM1a_EVT_BLK", 4, 56, L"0x%x", NULL, NULL, NULL, NULL},
    147   {L"PM1b_EVT_BLK", 4, 60, L"0x%x", NULL, NULL, NULL, NULL},
    148   {L"PM1a_CNT_BLK", 4, 64, L"0x%x", NULL, NULL, NULL, NULL},
    149   {L"PM1b_CNT_BLK", 4, 68, L"0x%x", NULL, NULL, NULL, NULL},
    150   {L"PM2_CNT_BLK", 4, 72, L"0x%x", NULL, NULL, NULL, NULL},
    151   {L"PM_TMR_BLK", 4, 76, L"0x%x", NULL, NULL, NULL, NULL},
    152   {L"GPE0_BLK", 4, 80, L"0x%x", NULL, NULL, NULL, NULL},
    153   {L"GPE1_BLK", 4, 84, L"0x%x", NULL, NULL, NULL, NULL},
    154   {L"PM1_EVT_LEN", 1, 88, L"0x%x", NULL, NULL, NULL, NULL},
    155   {L"PM1_CNT_LEN", 1, 89, L"0x%x", NULL, NULL, NULL, NULL},
    156   {L"PM2_CNT_LEN", 1, 90, L"0x%x", NULL, NULL, NULL, NULL},
    157   {L"PM_TMR_LEN", 1, 91, L"0x%x", NULL, NULL, NULL, NULL},
    158   {L"GPE0_BLK_LEN", 1, 92, L"0x%x", NULL, NULL, NULL, NULL},
    159   {L"GPE1_BLK_LEN", 1, 93, L"0x%x", NULL, NULL, NULL, NULL},
    160   {L"GPE1_BASE", 1, 94, L"0x%x", NULL, NULL, NULL, NULL},
    161   {L"CST_CNT", 1, 95, L"0x%x", NULL, NULL, NULL, NULL},
    162   {L"P_LVL2_LAT", 2, 96, L"0x%x", NULL, NULL, NULL, NULL},
    163   {L"P_LVL3_LAT", 2, 98, L"0x%x", NULL, NULL, NULL, NULL},
    164   {L"FLUSH_SIZE", 2, 100, L"0x%x", NULL, NULL, NULL, NULL},
    165   {L"FLUSH_STRIDE", 2, 102, L"0x%x", NULL, NULL, NULL, NULL},
    166   {L"DUTY_OFFSET", 1, 104, L"0x%x", NULL, NULL, NULL, NULL},
    167   {L"DUTY_WIDTH", 1, 105, L"0x%x", NULL, NULL, NULL, NULL},
    168   {L"DAY_ALRM", 1, 106, L"0x%x", NULL, NULL, NULL, NULL},
    169   {L"MON_ALRM", 1, 107, L"0x%x", NULL, NULL, NULL, NULL},
    170   {L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL},
    171   {L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL},
    172   {L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL},
    173   {L"Flags", 4, 112, L"0x%x", NULL, (VOID**)&Flags, ValidateFlags, NULL},
    174   {L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL},
    175   {L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL},
    176   {L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL},
    177   {L"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID**)&FadtMinorRevision,
    178     NULL, NULL},
    179   {L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID**)&X_FirmwareCtrl,
    180     ValidateXFirmwareCtrl, NULL},
    181   {L"X_DSDT", 8, 140, L"0x%lx", NULL, (VOID**)&X_DsdtAddress, NULL, NULL},
    182   {L"X_PM1a_EVT_BLK", 12, 148, NULL, DumpGas, NULL, NULL, NULL},
    183   {L"X_PM1b_EVT_BLK", 12, 160, NULL, DumpGas, NULL, NULL, NULL},
    184   {L"X_PM1a_CNT_BLK", 12, 172, NULL, DumpGas, NULL, NULL, NULL},
    185   {L"X_PM1b_CNT_BLK", 12, 184, NULL, DumpGas, NULL, NULL, NULL},
    186   {L"X_PM2_CNT_BLK", 12, 196, NULL, DumpGas, NULL, NULL, NULL},
    187   {L"X_PM_TMR_BLK", 12, 208, NULL, DumpGas, NULL, NULL, NULL},
    188   {L"X_GPE0_BLK", 12, 220, NULL, DumpGas, NULL, NULL, NULL},
    189   {L"X_GPE1_BLK", 12, 232, NULL, DumpGas, NULL, NULL, NULL},
    190   {L"SLEEP_CONTROL_REG", 12, 244, NULL, DumpGas, NULL, NULL, NULL},
    191   {L"SLEEP_STATUS_REG", 12, 256, NULL, DumpGas, NULL, NULL, NULL},
    192   {L"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL}
     195  { L"FIRMWARE_CTRL",              4,   36,  L"0x%x",  NULL,          (VOID **)&FirmwareCtrl,
     196    ValidateFirmwareCtrl,          NULL },
     197  { L"DSDT",                       4,   40,  L"0x%x",  NULL,          (VOID **)&DsdtAddress,      NULL,           NULL },
     198  { L"Reserved",                   1,   44,  L"%x",    NULL,          NULL,                       NULL,           NULL },
     199  { L"Preferred_PM_Profile",       1,   45,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     200  { L"SCI_INT",                    2,   46,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     201  { L"SMI_CMD",                    4,   48,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     202  { L"ACPI_ENABLE",                1,   52,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     203  { L"ACPI_DISABLE",               1,   53,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     204  { L"S4BIOS_REQ",                 1,   54,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     205  { L"PSTATE_CNT",                 1,   55,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     206  { L"PM1a_EVT_BLK",               4,   56,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     207  { L"PM1b_EVT_BLK",               4,   60,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     208  { L"PM1a_CNT_BLK",               4,   64,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     209  { L"PM1b_CNT_BLK",               4,   68,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     210  { L"PM2_CNT_BLK",                4,   72,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     211  { L"PM_TMR_BLK",                 4,   76,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     212  { L"GPE0_BLK",                   4,   80,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     213  { L"GPE1_BLK",                   4,   84,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     214  { L"PM1_EVT_LEN",                1,   88,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     215  { L"PM1_CNT_LEN",                1,   89,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     216  { L"PM2_CNT_LEN",                1,   90,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     217  { L"PM_TMR_LEN",                 1,   91,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     218  { L"GPE0_BLK_LEN",               1,   92,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     219  { L"GPE1_BLK_LEN",               1,   93,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     220  { L"GPE1_BASE",                  1,   94,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     221  { L"CST_CNT",                    1,   95,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     222  { L"P_LVL2_LAT",                 2,   96,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     223  { L"P_LVL3_LAT",                 2,   98,  L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     224  { L"FLUSH_SIZE",                 2,   100, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     225  { L"FLUSH_STRIDE",               2,   102, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     226  { L"DUTY_OFFSET",                1,   104, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     227  { L"DUTY_WIDTH",                 1,   105, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     228  { L"DAY_ALRM",                   1,   106, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     229  { L"MON_ALRM",                   1,   107, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     230  { L"CENTURY",                    1,   108, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     231  { L"IAPC_BOOT_ARCH",             2,   109, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     232  { L"Reserved",                   1,   111, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     233  { L"Flags",                      4,   112, NULL,     DumpFadtFlags, (VOID **)&Flags,            ValidateFlags,  NULL },
     234  { L"RESET_REG",                  12,  116, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     235  { L"RESET_VALUE",                1,   128, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     236  { L"ARM_BOOT_ARCH",              2,   129, L"0x%x",  NULL,          NULL,                       NULL,           NULL },
     237  { L"FADT Minor Version",         1,   131, L"0x%x",  NULL,          (VOID **)&FadtMinorRevision,
     238    NULL,                          NULL },
     239  { L"X_FIRMWARE_CTRL",            8,   132, L"0x%lx", NULL,          (VOID **)&X_FirmwareCtrl,
     240    ValidateXFirmwareCtrl,         NULL },
     241  { L"X_DSDT",                     8,   140, L"0x%lx", NULL,          (VOID **)&X_DsdtAddress,    NULL,           NULL },
     242  { L"X_PM1a_EVT_BLK",             12,  148, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     243  { L"X_PM1b_EVT_BLK",             12,  160, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     244  { L"X_PM1a_CNT_BLK",             12,  172, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     245  { L"X_PM1b_CNT_BLK",             12,  184, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     246  { L"X_PM2_CNT_BLK",              12,  196, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     247  { L"X_PM_TMR_BLK",               12,  208, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     248  { L"X_GPE0_BLK",                 12,  220, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     249  { L"X_GPE1_BLK",                 12,  232, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     250  { L"SLEEP_CONTROL_REG",          12,  244, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     251  { L"SLEEP_STATUS_REG",           12,  256, NULL,     DumpGas,       NULL,                       NULL,           NULL },
     252  { L"Hypervisor VendorIdentity",  8,   268, L"%lx",   NULL,          NULL,                       NULL,           NULL }
    193253};
    194254
     
    207267EFIAPI
    208268ParseAcpiFadt (
    209   IN BOOLEAN Trace,
    210   IN UINT8Ptr,
    211   IN UINT32  AcpiTableLength,
    212   IN UINT8   AcpiTableRevision
    213   )
    214 {
    215   EFI_STATUS              Status;
    216   UINT8*                  DsdtPtr;
    217   UINT8*                  FirmwareCtrlPtr;
    218   UINT32                  FacsSignature;
    219   UINT32                  FacsLength;
    220   UINT8                   FacsRevision;
    221   PARSE_ACPI_TABLE_PROC   FacsParserProc;
     269  IN BOOLEAN  Trace,
     270  IN UINT8    *Ptr,
     271  IN UINT32   AcpiTableLength,
     272  IN UINT8    AcpiTableRevision
     273  )
     274{
     275  EFI_STATUS             Status;
     276  UINT8                  *DsdtPtr;
     277  UINT8                  *FirmwareCtrlPtr;
     278  UINT32                 FacsSignature;
     279  UINT32                 FacsLength;
     280  UINT8                  FacsRevision;
     281  PARSE_ACPI_TABLE_PROC  FacsParserProc;
    222282
    223283  ParseAcpi (
     
    234294      Print (L"\nSummary:\n");
    235295      PrintFieldName (2, L"FADT Version");
    236       Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
     296      Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision);
    237297    }
    238298
     
    246306  // FIRMWARE_CTRL, else use FIRMWARE_CTRL.
    247307  if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) {
    248     FirmwareCtrlPtr = (UINT8*)(UINTN)(*X_FirmwareCtrl);
     308    FirmwareCtrlPtr = (UINT8 *)(UINTN)(*X_FirmwareCtrl);
    249309  } else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) {
    250     FirmwareCtrlPtr = (UINT8*)(UINTN)(*FirmwareCtrl);
     310    FirmwareCtrlPtr = (UINT8 *)(UINTN)(*FirmwareCtrl);
    251311  } else {
    252312    FirmwareCtrlPtr = NULL;
     
    256316    if ((Trace) &&
    257317        (Flags != NULL) &&
    258         ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI)) {
     318        ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI))
     319    {
    259320      IncrementErrorCount ();
    260       Print (L"ERROR: No FACS table found, "
    261                L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n");
     321      Print (
     322        L"ERROR: No FACS table found, "
     323        L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"
     324        );
    262325    }
    263326  }
     
    267330    // the signature, length and version needs to be initially parsed.
    268331    // The FACS signature is 4 bytes starting at offset 0.
    269     FacsSignature = *(UINT32*)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET);
     332    FacsSignature = *(UINT32 *)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET);
    270333
    271334    // The FACS length is 4 bytes starting at offset 4.
    272     FacsLength = *(UINT32*)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
     335    FacsLength = *(UINT32 *)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
    273336
    274337    // The FACS version is 1 byte starting at offset 32.
    275     FacsRevision = *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
     338    FacsRevision = *(UINT8 *)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
    276339
    277340    Trace = ProcessTableReportOptions (
     
    299362  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
    300363  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
    301     DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
     364    DsdtPtr = (UINT8 *)(UINTN)(*X_DsdtAddress);
    302365  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
    303     DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
     366    DsdtPtr = (UINT8 *)(UINTN)(*DsdtAddress);
    304367  } else {
    305368    // Both DSDT and X_DSDT cannot be invalid.
    306 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     369 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    307370    if (Trace) {
    308371      // The DSDT Table is mandatory for ARM systems
     
    312375      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
    313376    }
    314 #endif
     377
     378 #endif
    315379    return;
    316380  }
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c

    r89983 r99404  
    22  GTDT table parser
    33
    4   Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
     4  Copyright (c) 2016 - 2021, 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.4 Specification - January 2021
    99  **/
    1010
     
    1616
    1717// "The number of GT Block Timers must be less than or equal to 8"
    18 #define GT_BLOCK_TIMER_COUNT_MAX 8
     18#define GT_BLOCK_TIMER_COUNT_MAX  8
    1919
    2020// Local variables
    21 STATIC CONST UINT32* GtdtPlatformTimerCount;
    22 STATIC CONST UINT32* GtdtPlatformTimerOffset;
    23 STATIC CONST UINT8PlatformTimerType;
    24 STATIC CONST UINT16* PlatformTimerLength;
    25 STATIC CONST UINT32* GtBlockTimerCount;
    26 STATIC CONST UINT32* GtBlockTimerOffset;
    27 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     21STATIC CONST UINT32                  *GtdtPlatformTimerCount;
     22STATIC CONST UINT32                  *GtdtPlatformTimerOffset;
     23STATIC CONST UINT8                   *PlatformTimerType;
     24STATIC CONST UINT16                  *PlatformTimerLength;
     25STATIC CONST UINT32                  *GtBlockTimerCount;
     26STATIC CONST UINT32                  *GtBlockTimerOffset;
     27STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2828
    2929/**
     
    3838EFIAPI
    3939ValidateGtBlockTimerCount (
    40   IN UINT8* Ptr,
    41   IN VOIDContext
    42   )
    43 {
    44   UINT32 BlockTimerCount;
    45 
    46   BlockTimerCount = *(UINT32*)Ptr;
     40  IN UINT8  *Ptr,
     41  IN VOID   *Context
     42  )
     43{
     44  UINT32  BlockTimerCount;
     45
     46  BlockTimerCount = *(UINT32 *)Ptr;
    4747
    4848  if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) {
     
    6767EFIAPI
    6868ValidateGtFrameNumber (
    69   IN UINT8* Ptr,
    70   IN VOIDContext
    71   )
    72 {
    73   UINT8 FrameNumber;
    74 
    75   FrameNumber = *(UINT8*)Ptr;
     69  IN UINT8  *Ptr,
     70  IN VOID   *Context
     71  )
     72{
     73  UINT8  FrameNumber;
     74
     75  FrameNumber = *(UINT8 *)Ptr;
    7676
    7777  if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) {
     
    8888  An ACPI_PARSER array describing the ACPI GTDT Table.
    8989**/
    90 STATIC CONST ACPI_PARSER GtdtParser[] = {
     90STATIC CONST ACPI_PARSER  GtdtParser[] = {
    9191  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    92   {L"CntControlBase Physical Address", 8, 36, L"0x%lx", NULL, NULL,
    93    NULL, NULL},
    94   {L"Reserved", 4, 44, L"0x%x", NULL, NULL, NULL, NULL},
    95   {L"Secure EL1 timer GSIV", 4, 48, L"0x%x", NULL, NULL, NULL, NULL},
    96   {L"Secure EL1 timer FLAGS", 4, 52, L"0x%x", NULL, NULL, NULL, NULL},
    97 
    98   {L"Non-Secure EL1 timer GSIV", 4, 56, L"0x%x", NULL, NULL, NULL, NULL},
    99   {L"Non-Secure EL1 timer FLAGS", 4, 60, L"0x%x", NULL, NULL, NULL, NULL},
    100 
    101   {L"Virtual timer GSIV", 4, 64, L"0x%x", NULL, NULL, NULL, NULL},
    102   {L"Virtual timer FLAGS", 4, 68, L"0x%x", NULL, NULL, NULL, NULL},
    103 
    104   {L"Non-Secure EL2 timer GSIV", 4, 72, L"0x%x", NULL, NULL, NULL, NULL},
    105   {L"Non-Secure EL2 timer FLAGS", 4, 76, L"0x%x", NULL, NULL, NULL, NULL},
    106 
    107   {L"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL},
    108   {L"Platform Timer Count", 4, 88, L"%d", NULL,
    109    (VOID**)&GtdtPlatformTimerCount, NULL, NULL},
    110   {L"Platform Timer Offset", 4, 92, L"0x%x", NULL,
    111    (VOID**)&GtdtPlatformTimerOffset, NULL, NULL},
    112   {L"Virtual EL2 Timer GSIV", 4, 96, L"0x%x", NULL, NULL, NULL, NULL},
    113   {L"Virtual EL2 Timer Flags", 4, 100, L"0x%x", NULL, NULL, NULL, NULL}
     92  { L"CntControlBase Physical Address",8,      36, L"0x%lx", NULL, NULL,
     93    NULL,                             NULL },
     94  { L"Reserved",                      4,      44,  L"0x%x",  NULL, NULL,NULL,  NULL },
     95  { L"Secure EL1 timer GSIV",         4,      48,  L"0x%x",  NULL, NULL,NULL,  NULL },
     96  { L"Secure EL1 timer FLAGS",        4,      52,  L"0x%x",  NULL, NULL,NULL,  NULL },
     97
     98  { L"Non-Secure EL1 timer GSIV",     4,      56,  L"0x%x",  NULL, NULL,NULL,  NULL },
     99  { L"Non-Secure EL1 timer FLAGS",    4,      60,  L"0x%x",  NULL, NULL,NULL,  NULL },
     100
     101  { L"Virtual timer GSIV",            4,      64,  L"0x%x",  NULL, NULL,NULL,  NULL },
     102  { L"Virtual timer FLAGS",           4,      68,  L"0x%x",  NULL, NULL,NULL,  NULL },
     103
     104  { L"Non-Secure EL2 timer GSIV",     4,      72,  L"0x%x",  NULL, NULL,NULL,  NULL },
     105  { L"Non-Secure EL2 timer FLAGS",    4,      76,  L"0x%x",  NULL, NULL,NULL,  NULL },
     106
     107  { L"CntReadBase Physical address",  8,      80,  L"0x%lx", NULL, NULL,NULL,  NULL },
     108  { L"Platform Timer Count",          4,      88,  L"%d",    NULL,
     109    (VOID **)&GtdtPlatformTimerCount, NULL,   NULL },
     110  { L"Platform Timer Offset",         4,      92,  L"0x%x", NULL,
     111    (VOID **)&GtdtPlatformTimerOffset,NULL,   NULL },
     112  { L"Virtual EL2 Timer GSIV",        4,      96,  L"0x%x",  NULL, NULL,NULL,  NULL },
     113  { L"Virtual EL2 Timer Flags",       4,      100, L"0x%x",  NULL, NULL,NULL,  NULL }
    114114};
    115115
     
    117117  An ACPI_PARSER array describing the Platform timer header.
    118118**/
    119 STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[] = {
    120   {L"Type", 1, 0, NULL, NULL, (VOID**)&PlatformTimerType, NULL, NULL},
    121   {L"Length", 2, 1, NULL, NULL, (VOID**)&PlatformTimerLength, NULL, NULL},
    122   {L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL}
     119STATIC CONST ACPI_PARSER  GtPlatformTimerHeaderParser[] = {
     120  { L"Type",     1, 0, NULL, NULL, (VOID **)&PlatformTimerType,   NULL, NULL },
     121  { L"Length",   2, 1, NULL, NULL, (VOID **)&PlatformTimerLength, NULL, NULL },
     122  { L"Reserved", 1, 3, NULL, NULL, NULL,                          NULL, NULL }
    123123};
    124124
     
    126126  An ACPI_PARSER array describing the Platform GT Block.
    127127**/
    128 STATIC CONST ACPI_PARSER GtBlockParser[] = {
    129   {L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL},
    130   {L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL},
    131   {L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL},
    132   {L"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},
    133   {L"Timer Count", 4, 12, L"%d", NULL, (VOID**)&GtBlockTimerCount,
    134    ValidateGtBlockTimerCount, NULL},
    135   {L"Timer Offset", 4, 16, L"%d", NULL, (VOID**)&GtBlockTimerOffset, NULL,
    136     NULL}
     128STATIC CONST ACPI_PARSER  GtBlockParser[] = {
     129  { L"Type",                          1, 0,  L"%d",    NULL, NULL,                         NULL, NULL },
     130  { L"Length",                        2, 1,  L"%d",    NULL, NULL,                         NULL, NULL },
     131  { L"Reserved",                      1, 3,  L"%x",    NULL, NULL,                         NULL, NULL },
     132  { L"Physical address (CntCtlBase)", 8, 4,  L"0x%lx", NULL, NULL,                         NULL, NULL },
     133  { L"Timer Count",                   4, 12, L"%d",    NULL, (VOID **)&GtBlockTimerCount,
     134    ValidateGtBlockTimerCount, NULL },
     135  { L"Timer Offset",                  4, 16, L"%d",    NULL, (VOID **)&GtBlockTimerOffset, NULL,
     136    NULL }
    137137};
    138138
     
    140140  An ACPI_PARSER array describing the GT Block timer.
    141141**/
    142 STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {
    143   {L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL},
    144   {L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},
    145   {L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},
    146   {L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL,
    147     NULL},
    148   {L"Physical Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    149   {L"Physical Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    150   {L"Virtual Timer GSIV", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
    151   {L"Virtual Timer Flags", 4, 32, L"0x%x", NULL, NULL, NULL, NULL},
    152   {L"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL}
     142STATIC CONST ACPI_PARSER  GtBlockTimerParser[] = {
     143  { L"Frame Number",                   1, 0,  L"%d",       NULL,       NULL, ValidateGtFrameNumber, NULL },
     144  { L"Reserved",                       3, 1,  L"%x %x %x", Dump3Chars, NULL, NULL,                  NULL },
     145  { L"Physical address (CntBaseX)",    8, 4,  L"0x%lx",    NULL,       NULL, NULL,                  NULL },
     146  { L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx",    NULL,      NULL, NULL,
     147    NULL },
     148  { L"Physical Timer GSIV",            4, 20, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     149  { L"Physical Timer Flags",           4, 24, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     150  { L"Virtual Timer GSIV",             4, 28, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     151  { L"Virtual Timer Flags",            4, 32, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     152  { L"Common Flags",                   4, 36, L"0x%x",     NULL,       NULL, NULL,                  NULL }
    153153};
    154154
     
    156156  An ACPI_PARSER array describing the Platform Watchdog.
    157157**/
    158 STATIC CONST ACPI_PARSER SBSAGenericWatchdogParser[] = {
    159   {L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL},
    160   {L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL},
    161   {L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL},
    162   {L"RefreshFrame Physical address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},
    163   {L"ControlFrame Physical address", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL},
    164   {L"Watchdog Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    165   {L"Watchdog Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}
     158STATIC CONST ACPI_PARSER  ArmGenericWatchdogParser[] = {
     159  { L"Type",                          1, 0,  L"%d",    NULL, NULL, NULL, NULL },
     160  { L"Length",                        2, 1,  L"%d",    NULL, NULL, NULL, NULL },
     161  { L"Reserved",                      1, 3,  L"%x",    NULL, NULL, NULL, NULL },
     162  { L"RefreshFrame Physical address", 8, 4,  L"0x%lx", NULL, NULL, NULL, NULL },
     163  { L"ControlFrame Physical address", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL },
     164  { L"Watchdog Timer GSIV",           4, 20, L"0x%x",  NULL, NULL, NULL, NULL },
     165  { L"Watchdog Timer Flags",          4, 24, L"0x%x",  NULL, NULL, NULL, NULL }
    166166};
    167167
     
    175175VOID
    176176DumpGTBlock (
    177   IN UINT8* Ptr,
    178   IN UINT16 Length
    179   )
    180 {
    181   UINT32 Index;
    182   UINT32 Offset;
     177  IN UINT8   *Ptr,
     178  IN UINT16  Length
     179  )
     180{
     181  UINT32  Index;
     182  UINT32  Offset;
    183183
    184184  ParseAcpi (
     
    194194  // successfully read.
    195195  if ((GtBlockTimerCount == NULL) ||
    196       (GtBlockTimerOffset == NULL)) {
     196      (GtBlockTimerOffset == NULL))
     197  {
    197198    IncrementErrorCount ();
    198199    Print (
     
    204205
    205206  Offset = *GtBlockTimerOffset;
    206   Index = 0;
     207  Index  = 0;
    207208
    208209  // Parse the specified number of GT Block Timer Structures or the GT Block
    209210  // Structure buffer length. Whichever is minimum.
    210211  while ((Index++ < *GtBlockTimerCount) &&
    211          (Offset < Length)) {
     212         (Offset < Length))
     213  {
    212214    Offset += ParseAcpi (
    213215                TRUE,
     
    230232VOID
    231233DumpWatchdogTimer (
    232   IN UINT8* Ptr,
    233   IN UINT16 Length
     234  IN UINT8   *Ptr,
     235  IN UINT16  Length
    234236  )
    235237{
     
    237239    TRUE,
    238240    2,
    239     "SBSA Generic Watchdog",
     241    "Arm Generic Watchdog",
    240242    Ptr,
    241243    Length,
    242     PARSER_PARAMS (SBSAGenericWatchdogParser)
     244    PARSER_PARAMS (ArmGenericWatchdogParser)
    243245    );
    244246}
     
    263265EFIAPI
    264266ParseAcpiGtdt (
    265   IN BOOLEAN Trace,
    266   IN UINT8Ptr,
    267   IN UINT32  AcpiTableLength,
    268   IN UINT8   AcpiTableRevision
    269   )
    270 {
    271   UINT32 Index;
    272   UINT32 Offset;
    273   UINT8* TimerPtr;
     267  IN BOOLEAN  Trace,
     268  IN UINT8    *Ptr,
     269  IN UINT32   AcpiTableLength,
     270  IN UINT8    AcpiTableRevision
     271  )
     272{
     273  UINT32  Index;
     274  UINT32  Offset;
     275  UINT8   *TimerPtr;
    274276
    275277  if (!Trace) {
     
    289291  // successfully read.
    290292  if ((GtdtPlatformTimerCount == NULL) ||
    291       (GtdtPlatformTimerOffset == NULL)) {
     293      (GtdtPlatformTimerOffset == NULL))
     294  {
    292295    IncrementErrorCount ();
    293296    Print (
     
    299302
    300303  TimerPtr = Ptr + *GtdtPlatformTimerOffset;
    301   Offset = *GtdtPlatformTimerOffset;
    302   Index = 0;
     304  Offset   = *GtdtPlatformTimerOffset;
     305  Index    = 0;
    303306
    304307  // Parse the specified number of Platform Timer Structures or the GTDT
    305308  // buffer length. Whichever is minimum.
    306309  while ((Index++ < *GtdtPlatformTimerCount) &&
    307          (Offset < AcpiTableLength)) {
     310         (Offset < AcpiTableLength))
     311  {
    308312    // Parse the Platform Timer Header to obtain Length and Type
    309313    ParseAcpi (
     
    319323    // successfully read.
    320324    if ((PlatformTimerType == NULL) ||
    321         (PlatformTimerLength == NULL)) {
     325        (PlatformTimerLength == NULL))
     326    {
    322327      IncrementErrorCount ();
    323328      Print (
    324329        L"ERROR: Insufficient remaining table buffer length to read the " \
    325           L"Platform Timer Structure header. Length = %d.\n",
     330        L"Platform Timer Structure header. Length = %d.\n",
    326331        AcpiTableLength - Offset
    327332        );
     
    331336    // Validate Platform Timer Structure length
    332337    if ((*PlatformTimerLength == 0) ||
    333         ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) {
     338        ((Offset + (*PlatformTimerLength)) > AcpiTableLength))
     339    {
    334340      IncrementErrorCount ();
    335341      Print (
    336342        L"ERROR: Invalid Platform Timer Structure length. " \
    337           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     343        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    338344        *PlatformTimerLength,
    339345        Offset,
     
    344350
    345351    switch (*PlatformTimerType) {
    346       case EFI_ACPI_6_3_GTDT_GT_BLOCK:
     352      case EFI_ACPI_6_4_GTDT_GT_BLOCK:
    347353        DumpGTBlock (TimerPtr, *PlatformTimerLength);
    348354        break;
    349       case EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG:
     355      case EFI_ACPI_6_4_GTDT_ARM_GENERIC_WATCHDOG:
    350356        DumpWatchdogTimer (TimerPtr, *PlatformTimerLength);
    351357        break;
     
    360366
    361367    TimerPtr += *PlatformTimerLength;
    362     Offset += *PlatformTimerLength;
     368    Offset   += *PlatformTimerLength;
    363369  } // while
    364370}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParser.c

    r89983 r99404  
    2222
    2323// Maximum Memory Domain matrix print size.
    24 #define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX    10
     24#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX  10
    2525
    2626// Local variables
    27 STATIC CONST UINT16HmatStructureType;
    28 STATIC CONST UINT32HmatStructureLength;
    29 
    30 STATIC CONST UINT32NumberInitiatorProximityDomain;
    31 STATIC CONST UINT32NumberTargetProximityDomain;
     27STATIC CONST UINT16  *HmatStructureType;
     28STATIC CONST UINT32  *HmatStructureLength;
     29
     30STATIC CONST UINT32  *NumberInitiatorProximityDomain;
     31STATIC CONST UINT32  *NumberTargetProximityDomain;
    3232STATIC CONST
    33 EFI_ACPI_6_3_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS*
    34 SllbiFlags;
    35 
    36 STATIC CONST UINT8*   SllbiDataType;
    37 STATIC CONST UINT16NumberSMBIOSHandles;
    38 
    39 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     33EFI_ACPI_6_4_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS *
     34  SllbiFlags;
     35
     36STATIC CONST UINT8   *SllbiDataType;
     37STATIC CONST UINT16  *NumberSMBIOSHandles;
     38
     39STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    4040
    4141/**
    4242  Names of System Locality Latency Bandwidth Information (SLLBI) data types
    4343**/
    44 STATIC CONST CHAR16* SllbiNames[] = {
     44STATIC CONST CHAR16  *SllbiNames[] = {
    4545  L"Access %sLatency%s",
    4646  L"Read %sLatency%s",
     
    6262EFIAPI
    6363ValidateCacheAttributes (
    64   IN UINT8* Ptr,
    65   IN VOIDContext
     64  IN UINT8  *Ptr,
     65  IN VOID   *Context
    6666  )
    6767{
    68   EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*
    69   Attributes;
     68  EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *
     69    Attributes;
    7070
    7171  Attributes =
    72     (EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)Ptr;
     72    (EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *)Ptr;
    7373
    7474  if (Attributes->TotalCacheLevels > 0x3) {
     
    7979      );
    8080  }
     81
    8182  if (Attributes->CacheLevel > 0x3) {
    8283    IncrementErrorCount ();
     
    8687      );
    8788  }
     89
    8890  if (Attributes->CacheAssociativity > 0x2) {
    8991    IncrementErrorCount ();
     
    9395      );
    9496  }
     97
    9598  if (Attributes->WritePolicy > 0x2) {
    9699    IncrementErrorCount ();
     
    112115EFIAPI
    113116DumpCacheAttributes (
    114   IN CONST CHAR16* Format OPTIONAL,
    115   IN UINT8*        Ptr
     117  IN CONST CHAR16  *Format OPTIONAL,
     118  IN UINT8         *Ptr
    116119  )
    117120{
    118   EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*
    119   Attributes;
     121  EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *
     122    Attributes;
    120123
    121124  Attributes =
    122     (EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)Ptr;
     125    (EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *)Ptr;
    123126
    124127  Print (L"\n");
     
    138141  An ACPI_PARSER array describing the ACPI HMAT Table.
    139142*/
    140 STATIC CONST ACPI_PARSER HmatParser[] = {
     143STATIC CONST ACPI_PARSER  HmatParser[] = {
    141144  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    142   {L"Reserved", 4, 36, NULL, NULL, NULL, NULL, NULL}
     145  { L"Reserved",                   4,36, NULL, NULL, NULL, NULL, NULL }
    143146};
    144147
     
    146149  An ACPI_PARSER array describing the HMAT structure header.
    147150*/
    148 STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = {
    149   {L"Type", 2, 0, NULL, NULL, (VOID**)&HmatStructureType, NULL, NULL},
    150   {L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL},
    151   {L"Length", 4, 4, NULL, NULL, (VOID**)&HmatStructureLength, NULL, NULL}
     151STATIC CONST ACPI_PARSER  HmatStructureHeaderParser[] = {
     152  { L"Type",     2, 0, NULL, NULL, (VOID **)&HmatStructureType,   NULL, NULL },
     153  { L"Reserved", 2, 2, NULL, NULL, NULL,                          NULL, NULL },
     154  { L"Length",   4, 4, NULL, NULL, (VOID **)&HmatStructureLength, NULL, NULL }
    152155};
    153156
     
    156159  Structure - Type 0.
    157160*/
    158 STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = {
    159   {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL},
    160   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    161   {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL},
    162   {L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL},
    163   {L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL},
    164   {L"Proximity Dom for initiator", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    165   {L"Proximity Dom for memory", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    166   {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    167   {L"Reserved", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL},
    168   {L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}
     161STATIC CONST ACPI_PARSER  MemProximityDomainAttributeParser[] = {
     162  { L"Type",                        2, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     163  { L"Reserved",                    2, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     164  { L"Length",                      4, 4,  L"%d",    NULL, NULL, NULL, NULL },
     165  { L"Flags",                       2, 8,  L"0x%x",  NULL, NULL, NULL, NULL },
     166  { L"Reserved",                    2, 10, L"0x%x",  NULL, NULL, NULL, NULL },
     167  { L"Proximity Dom for initiator", 4, 12, L"0x%x",  NULL, NULL, NULL, NULL },
     168  { L"Proximity Dom for memory",    4, 16, L"0x%x",  NULL, NULL, NULL, NULL },
     169  { L"Reserved",                    4, 20, L"0x%x",  NULL, NULL, NULL, NULL },
     170  { L"Reserved",                    8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
     171  { L"Reserved",                    8, 32, L"0x%lx", NULL, NULL, NULL, NULL }
    169172};
    170173
     
    173176  Information Structure - Type 1.
    174177*/
    175 STATIC CONST ACPI_PARSER SllbiParser[] = {
    176   {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL},
    177   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    178   {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL},
    179   {L"Flags", 1, 8, L"0x%x", NULL, (VOID**)&SllbiFlags, NULL, NULL},
    180   {L"Data type", 1, 9, L"0x%x", NULL, (VOID**)&SllbiDataType, NULL, NULL},
    181   {L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL},
    182   {L"Initiator Proximity Dom Count", 4, 12, L"%d", NULL,
    183     (VOID**)&NumberInitiatorProximityDomain, NULL, NULL},
    184   {L"Target Proximity Dom Count", 4, 16, L"%d", NULL,
    185     (VOID**)&NumberTargetProximityDomain, NULL, NULL},
    186   {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    187   {L"Entry Base Unit", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}
     178STATIC CONST ACPI_PARSER  SllbiParser[] = {
     179  { L"Type",                          2, 0,  L"0x%x",  NULL, NULL,                    NULL, NULL },
     180  { L"Reserved",                      2, 2,  L"0x%x",  NULL, NULL,                    NULL, NULL },
     181  { L"Length",                        4, 4,  L"%d",    NULL, NULL,                    NULL, NULL },
     182  { L"Flags",                         1, 8,  L"0x%x",  NULL, (VOID **)&SllbiFlags,    NULL, NULL },
     183  { L"Data type",                     1, 9,  L"0x%x",  NULL, (VOID **)&SllbiDataType, NULL, NULL },
     184  { L"Min Transfer Size",             1, 10, L"%d",    NULL, NULL,                    NULL, NULL },
     185  { L"Reserved",                      1, 11, L"0x%x",  NULL, NULL,                    NULL, NULL },
     186  { L"Initiator Proximity Dom Count", 4, 12, L"%d",    NULL,
     187    (VOID **)&NumberInitiatorProximityDomain, NULL, NULL },
     188  { L"Target Proximity Dom Count",    4, 16, L"%d",    NULL,
     189    (VOID **)&NumberTargetProximityDomain, NULL, NULL },
     190  { L"Reserved",                      4, 20, L"0x%x",  NULL, NULL,                    NULL, NULL },
     191  { L"Entry Base Unit",               8, 24, L"0x%lx", NULL, NULL,                    NULL, NULL }
    188192  // initiator Proximity Domain list ...
    189193  // target Proximity Domain list ...
     
    195199  Structure - Type 2.
    196200*/
    197 STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
    198   {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL},
    199   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    200   {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL},
    201   {L"Proximity Dom for memory", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    202   {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    203   {L"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
    204   {L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL,
    205     ValidateCacheAttributes, NULL},
    206   {L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL},
    207   {L"SMBIOS Handle Count", 2, 30, L"%d", NULL,
    208     (VOID**)&NumberSMBIOSHandles, NULL, NULL}
     201STATIC CONST ACPI_PARSER  MemSideCacheInfoParser[] = {
     202  { L"Type",                     2, 0,  L"0x%x",  NULL,                NULL, NULL, NULL },
     203  { L"Reserved",                 2, 2,  L"0x%x",  NULL,                NULL, NULL, NULL },
     204  { L"Length",                   4, 4,  L"%d",    NULL,                NULL, NULL, NULL },
     205  { L"Proximity Dom for memory", 4, 8,  L"0x%x",  NULL,                NULL, NULL, NULL },
     206  { L"Reserved",                 4, 12, L"0x%x",  NULL,                NULL, NULL, NULL },
     207  { L"Memory Side Cache Size",   8, 16, L"0x%lx", NULL,                NULL, NULL, NULL },
     208  { L"Cache Attributes",         4, 24, NULL,    DumpCacheAttributes, NULL,
     209    ValidateCacheAttributes, NULL },
     210  { L"Reserved",                 2, 28, L"0x%x",  NULL,                NULL, NULL, NULL },
     211  { L"SMBIOS Handle Count",      2, 30, L"%d",    NULL,
     212    (VOID **)&NumberSMBIOSHandles, NULL, NULL }
    209213  // SMBIOS handles List ...
    210214};
     
    222226VOID
    223227DumpMpda (
    224   IN UINT8* Ptr,
    225   IN UINT32 Length
     228  IN UINT8   *Ptr,
     229  IN UINT32  Length
    226230  )
    227231{
     
    248252VOID
    249253DumpSllbi (
    250   IN UINT8* Ptr,
    251   IN UINT32 Length
     254  IN UINT8   *Ptr,
     255  IN UINT32  Length
    252256  )
    253257{
    254   CONST UINT32* InitiatorProximityDomainList;
    255   CONST UINT32* TargetProximityDomainList;
    256   CONST UINT16* LatencyBandwidthMatrix;
     258  CONST UINT32  *InitiatorProximityDomainList;
     259  CONST UINT32  *TargetProximityDomainList;
     260  CONST UINT16  *LatencyBandwidthMatrix;
    257261  UINT32        Offset;
    258262  CHAR16        Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
     
    278282      (SllbiDataType == NULL)                  ||
    279283      (NumberInitiatorProximityDomain == NULL) ||
    280       (NumberTargetProximityDomain == NULL)) {
     284      (NumberTargetProximityDomain == NULL))
     285  {
    281286    IncrementErrorCount ();
    282287    Print (
    283288      L"ERROR: Insufficient remaining table buffer length to read the " \
    284         L"SLLBI structure header. Length = %d.\n",
     289      L"SLLBI structure header. Length = %d.\n",
    285290      Length
    286291      );
     
    306311  }
    307312
    308   InitiatorProximityDomainList = (UINT32*) (Ptr + Offset);
    309   TargetProximityDomainList = InitiatorProximityDomainList +
    310                               *NumberInitiatorProximityDomain;
    311   LatencyBandwidthMatrix = (UINT16*) (TargetProximityDomainList +
     313  InitiatorProximityDomainList = (UINT32 *)(Ptr + Offset);
     314  TargetProximityDomainList    = InitiatorProximityDomainList +
     315                                 *NumberInitiatorProximityDomain;
     316  LatencyBandwidthMatrix = (UINT16 *)(TargetProximityDomainList +
    312317                                      *NumberTargetProximityDomain);
    313318
     
    350355    return;
    351356  }
     357
    352358  StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]);
    353359
     
    381387        );
    382388      return;
    383 
    384389  } // switch
    385390
     
    400405    for (IndexTarget = 0;
    401406         IndexTarget < *NumberTargetProximityDomain;
    402          IndexTarget++) {
     407         IndexTarget++)
     408    {
    403409      Print (L"    %2d", IndexTarget);
    404410    }
     
    407413    for (IndexTarget = 0;
    408414         IndexTarget < *NumberTargetProximityDomain;
    409          IndexTarget++) {
     415         IndexTarget++)
     416    {
    410417      Print (L"------");
    411418    }
     419
    412420    Print (L"\n");
    413421
     
    415423    for (IndexInitiator = 0;
    416424         IndexInitiator < *NumberInitiatorProximityDomain;
    417          IndexInitiator++) {
     425         IndexInitiator++)
     426    {
    418427      Print (L"      %2d |", IndexInitiator);
    419428      for (IndexTarget = 0;
    420429           IndexTarget < *NumberTargetProximityDomain;
    421            IndexTarget++) {
     430           IndexTarget++)
     431      {
    422432        Print (
    423433          L" %5d",
     
    425435          );
    426436      } // for Target
     437
    427438      Print (L"\n");
    428439      TargetStartOffset += (*NumberTargetProximityDomain);
    429440    } // for Initiator
     441
    430442    Print (L"\n");
    431443  } else {
     
    441453    for (IndexInitiator = 0;
    442454         IndexInitiator < *NumberInitiatorProximityDomain;
    443          IndexInitiator++) {
     455         IndexInitiator++)
     456    {
    444457      for (IndexTarget = 0;
    445458           IndexTarget < *NumberTargetProximityDomain;
    446            IndexTarget++) {
     459           IndexTarget++)
     460      {
    447461        UnicodeSPrint (
    448462          SecondBuffer,
     
    459473          );
    460474      } // for Target
     475
    461476      TargetStartOffset += (*NumberTargetProximityDomain);
    462477    } // for Initiator
     
    474489VOID
    475490DumpMsci (
    476   IN UINT8* Ptr,
    477   IN UINT32 Length
     491  IN UINT8   *Ptr,
     492  IN UINT32  Length
    478493  )
    479494{
    480   CONST UINT16* SMBIOSHandlesList;
     495  CONST UINT16  *SMBIOSHandlesList;
    481496  CHAR16        Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
    482497  UINT32        Offset;
     
    498513    Print (
    499514      L"ERROR: Insufficient remaining table buffer length to read the " \
    500         L"MSCI structure header. Length = %d.\n",
     515      L"MSCI structure header. Length = %d.\n",
    501516      Length
    502517      );
     
    515530  }
    516531
    517   SMBIOSHandlesList = (UINT16*) (Ptr + Offset);
     532  SMBIOSHandlesList = (UINT16 *)(Ptr + Offset);
    518533
    519534  for (Index = 0; Index < *NumberSMBIOSHandles; Index++) {
     
    553568EFIAPI
    554569ParseAcpiHmat (
    555   IN BOOLEAN Trace,
    556   IN UINT8Ptr,
    557   IN UINT32  AcpiTableLength,
    558   IN UINT8   AcpiTableRevision
     570  IN BOOLEAN  Trace,
     571  IN UINT8    *Ptr,
     572  IN UINT32   AcpiTableLength,
     573  IN UINT8    AcpiTableRevision
    559574  )
    560575{
    561   UINT32 Offset;
    562   UINT8* HmatStructurePtr;
     576  UINT32  Offset;
     577  UINT8   *HmatStructurePtr;
    563578
    564579  if (!Trace) {
     
    591606    // successfully read.
    592607    if ((HmatStructureType == NULL) ||
    593         (HmatStructureLength == NULL)) {
     608        (HmatStructureLength == NULL))
     609    {
    594610      IncrementErrorCount ();
    595611      Print (
    596612        L"ERROR: Insufficient remaining table buffer length to read the " \
    597           L"HMAT structure header. Length = %d.\n",
     613        L"HMAT structure header. Length = %d.\n",
    598614        AcpiTableLength - Offset
    599615        );
     
    603619    // Validate HMAT Structure length.
    604620    if ((*HmatStructureLength == 0) ||
    605         ((Offset + (*HmatStructureLength)) > AcpiTableLength)) {
     621        ((Offset + (*HmatStructureLength)) > AcpiTableLength))
     622    {
    606623      IncrementErrorCount ();
    607624      Print (
    608625        L"ERROR: Invalid HMAT Structure length. " \
    609           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     626        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    610627        *HmatStructureLength,
    611628        Offset,
     
    616633
    617634    switch (*HmatStructureType) {
    618       case EFI_ACPI_6_3_HMAT_TYPE_MEMORY_PROXIMITY_DOMAIN_ATTRIBUTES:
     635      case EFI_ACPI_6_4_HMAT_TYPE_MEMORY_PROXIMITY_DOMAIN_ATTRIBUTES:
    619636        DumpMpda (
    620637          HmatStructurePtr,
     
    622639          );
    623640        break;
    624       case EFI_ACPI_6_3_HMAT_TYPE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO:
     641      case EFI_ACPI_6_4_HMAT_TYPE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO:
    625642        DumpSllbi (
    626643          HmatStructurePtr,
     
    628645          );
    629646        break;
    630       case EFI_ACPI_6_3_HMAT_TYPE_MEMORY_SIDE_CACHE_INFO:
    631          DumpMsci (
     647      case EFI_ACPI_6_4_HMAT_TYPE_MEMORY_SIDE_CACHE_INFO:
     648        DumpMsci (
    632649          HmatStructurePtr,
    633650          *HmatStructureLength
     
    638655        Print (
    639656          L"ERROR: Unknown HMAT structure:"
    640             L" Type = %d, Length = %d\n",
     657          L" Type = %d, Length = %d\n",
    641658          *HmatStructureType,
    642659          *HmatStructureLength
     
    646663
    647664    HmatStructurePtr += *HmatStructureLength;
    648     Offset += *HmatStructureLength;
     665    Offset           += *HmatStructureLength;
    649666  } // while
    650667}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c

    r89983 r99404  
    22  IORT table parser
    33
    4   Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
     4  Copyright (c) 2016 - 2022, Arm Limited. All rights reserved.
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    8     - IO Remapping Table, Platform Design Document, Revision D, March 2018
     8    - IO Remapping Table, Platform Design Document, Revision E.d, Feb 2022
     9      (https://developer.arm.com/documentation/den0049/)
     10
     11  @par Glossary:
     12    - Ref  - Reference
     13    - Desc - Descriptor
    914**/
    1015
     
    1722
    1823// Local variables
    19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
    20 
    21 STATIC CONST UINT32* IortNodeCount;
    22 STATIC CONST UINT32* IortNodeOffset;
    23 
    24 STATIC CONST UINT8*  IortNodeType;
    25 STATIC CONST UINT16* IortNodeLength;
    26 STATIC CONST UINT32* IortIdMappingCount;
    27 STATIC CONST UINT32* IortIdMappingOffset;
    28 
    29 STATIC CONST UINT32* InterruptContextCount;
    30 STATIC CONST UINT32* InterruptContextOffset;
    31 STATIC CONST UINT32* PmuInterruptCount;
    32 STATIC CONST UINT32* PmuInterruptOffset;
    33 
    34 STATIC CONST UINT32* ItsCount;
     24STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
     25
     26STATIC CONST UINT32  *IortNodeCount;
     27STATIC CONST UINT32  *IortNodeOffset;
     28
     29STATIC CONST UINT8   *IortNodeType;
     30STATIC CONST UINT16  *IortNodeLength;
     31STATIC CONST UINT8   *IortNodeRevision;
     32STATIC CONST UINT32  *IortIdMappingCount;
     33STATIC CONST UINT32  *IortIdMappingOffset;
     34
     35STATIC CONST UINT32  *InterruptContextCount;
     36STATIC CONST UINT32  *InterruptContextOffset;
     37STATIC CONST UINT32  *PmuInterruptCount;
     38STATIC CONST UINT32  *PmuInterruptOffset;
     39
     40STATIC CONST UINT32  *ItsCount;
     41
     42STATIC CONST UINT32  *RmrMemDescCount;
     43STATIC CONST UINT32  *RmrMemDescOffset;
    3544
    3645/**
     
    4554EFIAPI
    4655ValidateItsIdMappingCount (
    47   IN UINT8* Ptr,
    48   IN VOIDContext
    49   )
    50 {
    51   if (*(UINT32*)Ptr != 0) {
     56  IN UINT8  *Ptr,
     57  IN VOID   *Context
     58  )
     59{
     60  if (*(UINT32 *)Ptr != 0) {
    5261    IncrementErrorCount ();
    5362    Print (L"\nERROR: IORT ID Mapping count must be zero.");
     
    6776EFIAPI
    6877ValidatePmcgIdMappingCount (
    69   IN UINT8* Ptr,
    70   IN VOIDContext
    71   )
    72 {
    73   if (*(UINT32*)Ptr > 1) {
     78  IN UINT8  *Ptr,
     79  IN VOID   *Context
     80  )
     81{
     82  if (*(UINT32 *)Ptr > 1) {
    7483    IncrementErrorCount ();
    7584    Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");
     
    8897EFIAPI
    8998ValidateItsIdArrayReference (
    90   IN UINT8* Ptr,
    91   IN VOIDContext
    92   )
    93 {
    94   if (*(UINT32*)Ptr != 0) {
     99  IN UINT8  *Ptr,
     100  IN VOID   *Context
     101  )
     102{
     103  if (*(UINT32 *)Ptr != 0) {
    95104    IncrementErrorCount ();
    96105    Print (L"\nERROR: IORT ID Mapping offset must be zero.");
     106  }
     107}
     108
     109/**
     110  This function validates that the Physical Range address or length is not zero
     111  and is 64K aligned.
     112
     113  @param [in] Ptr     Pointer to the start of the field data.
     114  @param [in] Context Pointer to context specific information e.g. this
     115                      could be a pointer to the ACPI table header.
     116**/
     117STATIC
     118VOID
     119EFIAPI
     120ValidatePhysicalRange (
     121  IN UINT8  *Ptr,
     122  IN VOID   *Context
     123  )
     124{
     125  UINT64  Value;
     126
     127  Value = *(UINT64 *)Ptr;
     128  if ((Value == 0) || ((Value & (SIZE_64KB - 1)) != 0)) {
     129    IncrementErrorCount ();
     130    Print (L"\nERROR: Physical Range must be 64K aligned and cannot be zero.");
     131  }
     132}
     133
     134/**
     135  This function validates that the RMR memory range descriptor count.
     136
     137  @param [in] Ptr     Pointer to the start of the field data.
     138  @param [in] Context Pointer to context specific information e.g. this
     139                      could be a pointer to the ACPI table header.
     140**/
     141STATIC
     142VOID
     143EFIAPI
     144ValidateRmrMemDescCount (
     145  IN UINT8  *Ptr,
     146  IN VOID   *Context
     147  )
     148{
     149  if (*(UINT32 *)Ptr == 0) {
     150    IncrementErrorCount ();
     151    Print (L"\nERROR: Memory Range Descriptor count must be >=1.");
    97152  }
    98153}
     
    106161                                         validating the ID Array reference.
    107162**/
    108 #define PARSE_IORT_NODE_HEADER(ValidateIdMappingCount,                   \
    109                                ValidateIdArrayReference)                 \
    110   { L"Type", 1, 0, L"%d", NULL, (VOID**)&IortNodeType, NULL, NULL },     \
    111   { L"Length", 2, 1, L"%d", NULL, (VOID**)&IortNodeLength, NULL, NULL }, \
    112   { L"Revision", 1, 3, L"%d", NULL, NULL, NULL, NULL },                  \
    113   { L"Reserved", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },                \
    114   { L"Number of ID mappings", 4, 8, L"%d", NULL,                         \
    115     (VOID**)&IortIdMappingCount, ValidateIdMappingCount, NULL },         \
    116   { L"Reference to ID Array", 4, 12, L"0x%x", NULL,                      \
     163#define PARSE_IORT_NODE_HEADER(ValidateIdMappingCount,                        \
     164                               ValidateIdArrayReference)                      \
     165  { L"Type", 1, 0, L"%d", NULL, (VOID**)&IortNodeType, NULL, NULL },          \
     166  { L"Length", 2, 1, L"%d", NULL, (VOID**)&IortNodeLength, NULL, NULL },      \
     167  { L"Revision", 1, 3, L"%d", NULL, (VOID**)&IortNodeRevision, NULL, NULL },  \
     168  { L"Identifier", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },                   \
     169  { L"Number of ID mappings", 4, 8, L"%d", NULL,                              \
     170    (VOID**)&IortIdMappingCount, ValidateIdMappingCount, NULL },              \
     171  { L"Reference to ID Array", 4, 12, L"0x%x", NULL,                           \
    117172    (VOID**)&IortIdMappingOffset, ValidateIdArrayReference, NULL }
    118173
     
    120175  An ACPI_PARSER array describing the ACPI IORT Table
    121176**/
    122 STATIC CONST ACPI_PARSER IortParser[] = {
     177STATIC CONST ACPI_PARSER  IortParser[] = {
    123178  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    124   {L"Number of IORT Nodes", 4, 36, L"%d", NULL,
    125    (VOID**)&IortNodeCount, NULL, NULL},
    126   {L"Offset to Array of IORT Nodes", 4, 40, L"0x%x", NULL,
    127    (VOID**)&IortNodeOffset, NULL, NULL},
    128   {L"Reserved", 4, 44, L"0x%x", NULL, NULL, NULL, NULL}
     179  { L"Number of IORT Nodes",       4,     36, L"%d",  NULL,
     180    (VOID **)&IortNodeCount,       NULL,  NULL },
     181  { L"Offset to Array of IORT Nodes",4,    40, L"0x%x", NULL,
     182    (VOID **)&IortNodeOffset,      NULL,  NULL },
     183  { L"Reserved",                   4,     44, L"0x%x", NULL,NULL,NULL, NULL }
    129184};
    130185
     
    132187  An ACPI_PARSER array describing the IORT node header structure.
    133188**/
    134 STATIC CONST ACPI_PARSER IortNodeHeaderParser[] = {
     189STATIC CONST ACPI_PARSER  IortNodeHeaderParser[] = {
    135190  PARSE_IORT_NODE_HEADER (NULL, NULL)
    136191};
     
    139194  An ACPI_PARSER array describing the IORT SMMUv1/2 node.
    140195**/
    141 STATIC CONST ACPI_PARSER IortNodeSmmuV1V2Parser[] = {
     196STATIC CONST ACPI_PARSER  IortNodeSmmuV1V2Parser[] = {
     197  PARSE_IORT_NODE_HEADER (NULL,       NULL),
     198  { L"Base Address",                  8,    16,  L"0x%lx", NULL, NULL, NULL, NULL },
     199  { L"Span",                          8,    24,  L"0x%lx", NULL, NULL, NULL, NULL },
     200  { L"Model",                         4,    32,  L"%d",    NULL, NULL, NULL, NULL },
     201  { L"Flags",                         4,    36,  L"0x%x",  NULL, NULL, NULL, NULL },
     202  { L"Global Interrupt Array Ref",    4,    40,  L"0x%x",  NULL, NULL, NULL,
     203    NULL },
     204  { L"Number of context interrupts",  4,    44,  L"%d",    NULL,
     205    (VOID **)&InterruptContextCount,  NULL, NULL },
     206  { L"Context Interrupt Array Ref",   4,    48,  L"0x%x",  NULL,
     207    (VOID **)&InterruptContextOffset, NULL, NULL },
     208  { L"Number of PMU Interrupts",      4,    52,  L"%d",    NULL,
     209    (VOID **)&PmuInterruptCount,      NULL, NULL },
     210  { L"PMU Interrupt Array Ref",       4,    56,  L"0x%x",  NULL,
     211    (VOID **)&PmuInterruptOffset,     NULL, NULL },
     212
     213  // Interrupt Array
     214  { L"SMMU_NSgIrpt",                  4,    60,  L"0x%x",  NULL, NULL, NULL, NULL },
     215  { L"SMMU_NSgIrpt interrupt flags",  4,    64,  L"0x%x",  NULL, NULL, NULL, NULL },
     216  { L"SMMU_NSgCfgIrpt",               4,    68,  L"0x%x",  NULL, NULL, NULL, NULL },
     217  { L"SMMU_NSgCfgIrpt interrupt flags",4,    72,  L"0x%x",  NULL, NULL, NULL, NULL }
     218};
     219
     220/**
     221  An ACPI_PARSER array describing the SMMUv1/2 Node Interrupt Array.
     222**/
     223STATIC CONST ACPI_PARSER  InterruptArrayParser[] = {
     224  { L"Interrupt GSIV", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
     225  { L"Flags",          4, 4, L"0x%x", NULL, NULL, NULL, NULL }
     226};
     227
     228/**
     229  An ACPI_PARSER array describing the IORT ID Mapping.
     230**/
     231STATIC CONST ACPI_PARSER  IortNodeIdMappingParser[] = {
     232  { L"Input base",       4, 0,  L"0x%x", NULL, NULL, NULL, NULL },
     233  { L"Number of IDs",    4, 4,  L"0x%x", NULL, NULL, NULL, NULL },
     234  { L"Output base",      4, 8,  L"0x%x", NULL, NULL, NULL, NULL },
     235  { L"Output reference", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
     236  { L"Flags",            4, 16, L"0x%x", NULL, NULL, NULL, NULL }
     237};
     238
     239/**
     240  An ACPI_PARSER array describing the IORT SMMUv3 node.
     241**/
     242STATIC CONST ACPI_PARSER  IortNodeSmmuV3Parser[] = {
    142243  PARSE_IORT_NODE_HEADER (NULL, NULL),
    143   {L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
    144   {L"Span", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL},
    145   {L"Model", 4, 32, L"%d", NULL, NULL, NULL, NULL},
    146   {L"Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL},
    147   {L"Reference to Global Interrupt Array", 4, 40, L"0x%x", NULL, NULL, NULL,
    148    NULL},
    149   {L"Number of context interrupts", 4, 44, L"%d", NULL,
    150    (VOID**)&InterruptContextCount, NULL, NULL},
    151   {L"Reference to Context Interrupt Array", 4, 48, L"0x%x", NULL,
    152    (VOID**)&InterruptContextOffset, NULL, NULL},
    153   {L"Number of PMU Interrupts", 4, 52, L"%d", NULL,
    154    (VOID**)&PmuInterruptCount, NULL, NULL},
    155   {L"Reference to PMU Interrupt Array", 4, 56, L"0x%x", NULL,
    156    (VOID**)&PmuInterruptOffset, NULL, NULL},
    157 
    158   // Interrupt Array
    159   {L"SMMU_NSgIrpt", 4, 60, L"0x%x", NULL, NULL, NULL, NULL},
    160   {L"SMMU_NSgIrpt interrupt flags", 4, 64, L"0x%x", NULL, NULL, NULL, NULL},
    161   {L"SMMU_NSgCfgIrpt", 4, 68, L"0x%x", NULL, NULL, NULL, NULL},
    162   {L"SMMU_NSgCfgIrpt interrupt flags", 4, 72, L"0x%x", NULL, NULL, NULL, NULL}
    163 };
    164 
    165 /**
    166   An ACPI_PARSER array describing the SMMUv1/2 Node Interrupt Array.
    167 **/
    168 STATIC CONST ACPI_PARSER InterruptArrayParser[] = {
    169   {L"Interrupt GSIV", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    170   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
    171 };
    172 
    173 /**
    174   An ACPI_PARSER array describing the IORT ID Mapping.
    175 **/
    176 STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = {
    177   {L"Input base", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
    178   {L"Number of IDs", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    179   {L"Output base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    180   {L"Output reference", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    181   {L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}
    182 };
    183 
    184 /**
    185   An ACPI_PARSER array describing the IORT SMMUv3 node.
    186 **/
    187 STATIC CONST ACPI_PARSER IortNodeSmmuV3Parser[] = {
    188   PARSE_IORT_NODE_HEADER (NULL, NULL),
    189   {L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
    190   {L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    191   {L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
    192   {L"VATOS Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
    193   {L"Model", 4, 40, L"%d", NULL, NULL, NULL, NULL},
    194   {L"Event", 4, 44, L"0x%x", NULL, NULL, NULL, NULL},
    195   {L"PRI", 4, 48, L"0x%x", NULL, NULL, NULL, NULL},
    196   {L"GERR", 4, 52, L"0x%x", NULL, NULL, NULL, NULL},
    197   {L"Sync", 4, 56, L"0x%x", NULL, NULL, NULL, NULL},
    198   {L"Proximity domain", 4, 60, L"0x%x", NULL, NULL, NULL, NULL},
    199   {L"Device ID mapping index", 4, 64, L"%d", NULL, NULL, NULL, NULL}
     244  { L"Base Address",            8,    16,  L"0x%lx", NULL, NULL, NULL, NULL },
     245  { L"Flags",                   4,    24,  L"0x%x",  NULL, NULL, NULL, NULL },
     246  { L"Reserved",                4,    28,  L"0x%x",  NULL, NULL, NULL, NULL },
     247  { L"VATOS Address",           8,    32,  L"0x%lx", NULL, NULL, NULL, NULL },
     248  { L"Model",                   4,    40,  L"%d",    NULL, NULL, NULL, NULL },
     249  { L"Event",                   4,    44,  L"0x%x",  NULL, NULL, NULL, NULL },
     250  { L"PRI",                     4,    48,  L"0x%x",  NULL, NULL, NULL, NULL },
     251  { L"GERR",                    4,    52,  L"0x%x",  NULL, NULL, NULL, NULL },
     252  { L"Sync",                    4,    56,  L"0x%x",  NULL, NULL, NULL, NULL },
     253  { L"Proximity domain",        4,    60,  L"0x%x",  NULL, NULL, NULL, NULL },
     254  { L"Device ID mapping index", 4,    64,  L"%d",    NULL, NULL, NULL, NULL }
    200255};
    201256
     
    203258  An ACPI_PARSER array describing the IORT ITS node.
    204259**/
    205 STATIC CONST ACPI_PARSER IortNodeItsParser[] = {
     260STATIC CONST ACPI_PARSER  IortNodeItsParser[] = {
    206261  PARSE_IORT_NODE_HEADER (
    207262    ValidateItsIdMappingCount,
    208263    ValidateItsIdArrayReference
    209264    ),
    210   {L"Number of ITSs", 4, 16, L"%d", NULL, (VOID**)&ItsCount, NULL}
     265  { L"Number of ITSs",        4,16, L"%d", NULL, (VOID **)&ItsCount, NULL }
    211266};
    212267
     
    214269  An ACPI_PARSER array describing the ITS ID.
    215270**/
    216 STATIC CONST ACPI_PARSER ItsIdParser[] = {
     271STATIC CONST ACPI_PARSER  ItsIdParser[] = {
    217272  { L"GIC ITS Identifier", 4, 0, L"%d", NULL, NULL, NULL }
    218273};
     
    221276  An ACPI_PARSER array describing the IORT Names Component node.
    222277**/
    223 STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = {
     278STATIC CONST ACPI_PARSER  IortNodeNamedComponentParser[] = {
    224279  PARSE_IORT_NODE_HEADER (NULL, NULL),
    225   {L"Node Flags", 4, 16, L"%d", NULL, NULL, NULL, NULL},
    226   {L"Memory access properties", 8, 20, L"0x%lx", NULL, NULL, NULL, NULL},
    227   {L"Device memory address size limit", 1, 28, L"%d", NULL, NULL, NULL, NULL}
     280  { L"Node Flags",              4,    16,  L"%d",    NULL, NULL, NULL, NULL },
     281  { L"Memory access properties",8,    20,  L"0x%lx", NULL, NULL, NULL, NULL },
     282  { L"Device memory address size limit",1,    28,  L"%d",    NULL, NULL, NULL, NULL }
    228283};
    229284
     
    231286  An ACPI_PARSER array describing the IORT Root Complex node.
    232287**/
    233 STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
     288STATIC CONST ACPI_PARSER  IortNodeRootComplexParser[] = {
    234289  PARSE_IORT_NODE_HEADER (NULL, NULL),
    235   {L"Memory access properties", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
    236   {L"ATS Attribute", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    237   {L"PCI Segment number", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
    238   {L"Memory access size limit", 1, 32, L"0x%x", NULL, NULL, NULL, NULL},
    239   {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
     290  { L"Memory access properties",8,    16,  L"0x%lx", NULL, NULL, NULL, NULL },
     291  { L"ATS Attribute",           4,    24,  L"0x%x",  NULL, NULL, NULL, NULL },
     292  { L"PCI Segment number",      4,    28,  L"0x%x",  NULL, NULL, NULL, NULL },
     293  { L"Memory access size limit",1,    32,  L"0x%x",  NULL, NULL, NULL, NULL },
     294  { L"PASID capabilities",      2,    33,  L"0x%x",  NULL, NULL, NULL, NULL },
     295  { L"Reserved",                1,    35,  L"%x",    NULL, NULL, NULL, NULL },
     296  { L"Flags",                   4,    36,  L"0x%x",  NULL, NULL, NULL, NULL },
    240297};
    241298
     
    243300  An ACPI_PARSER array describing the IORT PMCG node.
    244301**/
    245 STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
     302STATIC CONST ACPI_PARSER  IortNodePmcgParser[] = {
    246303  PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL),
    247   {L"Page 0 Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
    248   {L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    249   {L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
    250   {L"Page 1 Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}
     304  { L"Page 0 Base Address",                           8,    16,  L"0x%lx", NULL, NULL, NULL, NULL },
     305  { L"Overflow interrupt GSIV",                       4,    24,  L"0x%x",  NULL, NULL, NULL, NULL },
     306  { L"Node reference",                                4,    28,  L"0x%x",  NULL, NULL, NULL, NULL },
     307  { L"Page 1 Base Address",                           8,    32,  L"0x%lx", NULL, NULL, NULL, NULL }
     308};
     309
     310/**
     311  An ACPI_PARSER array describing the IORT RMR node.
     312**/
     313STATIC CONST ACPI_PARSER  IortNodeRmrParser[] = {
     314  PARSE_IORT_NODE_HEADER (NULL, NULL),
     315  { L"Flags",                   4,                      16,  L"0x%x", NULL, NULL, NULL, NULL },
     316  { L"Memory Range Desc count", 4,                      20,  L"%d",   NULL,
     317    (VOID **)&RmrMemDescCount,  ValidateRmrMemDescCount,NULL },
     318  { L"Memory Range Desc Ref",   4,                      24,  L"0x%x", NULL,
     319    (VOID **)&RmrMemDescOffset, NULL,                   NULL }
     320};
     321
     322/**
     323  An ACPI_PARSER array describing the IORT RMR Memory Range Descriptor.
     324**/
     325STATIC CONST ACPI_PARSER  IortNodeRmrMemRangeDescParser[] = {
     326  { L"Physical Range offset", 8, 0,  L"0x%lx", NULL, NULL, ValidatePhysicalRange,
     327    NULL },
     328  { L"Physical Range length", 8, 8,  L"0x%lx", NULL, NULL, ValidatePhysicalRange,
     329    NULL },
     330  { L"Reserved",              4, 16, L"0x%x",  NULL, NULL, NULL,                 NULL}
    251331};
    252332
     
    261341VOID
    262342DumpIortNodeIdMappings (
    263   IN UINT8* Ptr,
    264   IN UINT32 Length,
    265   IN UINT32 MappingCount
    266   )
    267 {
    268   UINT32 Index;
    269   UINT32 Offset;
    270   CHAR8  Buffer[40]; // Used for AsciiName param of ParseAcpi
    271 
    272   Index = 0;
     343  IN UINT8   *Ptr,
     344  IN UINT32  Length,
     345  IN UINT32  MappingCount
     346  )
     347{
     348  UINT32  Index;
     349  UINT32  Offset;
     350  CHAR8   Buffer[40]; // Used for AsciiName param of ParseAcpi
     351
     352  Index  = 0;
    273353  Offset = 0;
    274354
    275355  while ((Index < MappingCount) &&
    276          (Offset < Length)) {
     356         (Offset < Length))
     357  {
    277358    AsciiSPrint (
    278359      Buffer,
     
    305386VOID
    306387DumpIortNodeSmmuV1V2 (
    307   IN UINT8* Ptr,
    308   IN UINT16 Length,
    309   IN UINT32 MappingCount,
    310   IN UINT32 MappingOffset
    311   )
    312 {
    313   UINT32 Index;
    314   UINT32 Offset;
    315   CHAR8  Buffer[50]; // Used for AsciiName param of ParseAcpi
     388  IN UINT8   *Ptr,
     389  IN UINT16  Length,
     390  IN UINT32  MappingCount,
     391  IN UINT32  MappingOffset
     392  )
     393{
     394  UINT32  Index;
     395  UINT32  Offset;
     396  CHAR8   Buffer[50]; // Used for AsciiName param of ParseAcpi
    316397
    317398  ParseAcpi (
     
    329410      (InterruptContextOffset == NULL)  ||
    330411      (PmuInterruptCount == NULL)       ||
    331       (PmuInterruptOffset == NULL)) {
     412      (PmuInterruptOffset == NULL))
     413  {
    332414    IncrementErrorCount ();
    333415    Print (
     
    339421
    340422  Offset = *InterruptContextOffset;
    341   Index = 0;
     423  Index  = 0;
    342424
    343425  while ((Index < *InterruptContextCount) &&
    344          (Offset < Length)) {
     426         (Offset < Length))
     427  {
    345428    AsciiSPrint (
    346429      Buffer,
     
    361444
    362445  Offset = *PmuInterruptOffset;
    363   Index = 0;
     446  Index  = 0;
    364447
    365448  while ((Index < *PmuInterruptCount) &&
    366          (Offset < Length)) {
     449         (Offset < Length))
     450  {
    367451    AsciiSPrint (
    368452      Buffer,
     
    401485VOID
    402486DumpIortNodeSmmuV3 (
    403   IN UINT8* Ptr,
    404   IN UINT16 Length,
    405   IN UINT32 MappingCount,
    406   IN UINT32 MappingOffset
     487  IN UINT8   *Ptr,
     488  IN UINT16  Length,
     489  IN UINT32  MappingCount,
     490  IN UINT32  MappingOffset
    407491  )
    408492{
     
    432516VOID
    433517DumpIortNodeIts (
    434   IN UINT8* Ptr,
    435   IN UINT16 Length
    436   )
    437 {
    438   UINT32 Offset;
    439   UINT32 Index;
    440   CHAR8  Buffer[80]; // Used for AsciiName param of ParseAcpi
     518  IN UINT8   *Ptr,
     519  IN UINT16  Length
     520  )
     521{
     522  UINT32  Offset;
     523  UINT32  Index;
     524  CHAR8   Buffer[80]; // Used for AsciiName param of ParseAcpi
    441525
    442526  Offset = ParseAcpi (
    443             TRUE,
    444             2,
    445             "ITS Node",
    446             Ptr,
    447             Length,
    448             PARSER_PARAMS (IortNodeItsParser)
    449             );
     527             TRUE,
     528             2,
     529             "ITS Node",
     530             Ptr,
     531             Length,
     532             PARSER_PARAMS (IortNodeItsParser)
     533             );
    450534
    451535  // Check if the values used to control the parsing logic have been
     
    463547
    464548  while ((Index < *ItsCount) &&
    465          (Offset < Length)) {
     549         (Offset < Length))
     550  {
    466551    AsciiSPrint (
    467552      Buffer,
     
    482567
    483568  // Note: ITS does not have the ID Mappings Array
    484 
    485569}
    486570
     
    497581VOID
    498582DumpIortNodeNamedComponent (
    499   IN UINT8* Ptr,
    500   IN UINT16 Length,
    501   IN UINT32 MappingCount,
    502   IN UINT32 MappingOffset
    503   )
    504 {
    505   UINT32 Offset;
     583  IN UINT8   *Ptr,
     584  IN UINT16  Length,
     585  IN UINT32  MappingCount,
     586  IN UINT32  MappingOffset
     587  )
     588{
     589  UINT32  Offset;
    506590
    507591  Offset = ParseAcpi (
     
    518602
    519603  while ((*(Ptr + Offset) != 0) &&
    520          (Offset < Length)) {
     604         (Offset < Length))
     605  {
    521606    Print (L"%c", *(Ptr + Offset));
    522607    Offset++;
    523608  }
     609
    524610  Print (L"\n");
    525611
     
    543629VOID
    544630DumpIortNodeRootComplex (
    545   IN UINT8* Ptr,
    546   IN UINT16 Length,
    547   IN UINT32 MappingCount,
    548   IN UINT32 MappingOffset
     631  IN UINT8   *Ptr,
     632  IN UINT16  Length,
     633  IN UINT32  MappingCount,
     634  IN UINT32  MappingOffset
    549635  )
    550636{
     
    577663VOID
    578664DumpIortNodePmcg (
    579   IN UINT8* Ptr,
    580   IN UINT16 Length,
    581   IN UINT32 MappingCount,
    582   IN UINT32 MappingOffset
    583 )
     665  IN UINT8   *Ptr,
     666  IN UINT16  Length,
     667  IN UINT32  MappingCount,
     668  IN UINT32  MappingOffset
     669  )
    584670{
    585671  ParseAcpi (
     
    600686
    601687/**
     688  This function parses the IORT RMR Node Memory Range Descriptor array.
     689
     690  @param [in] Ptr         Pointer to the start of the Memory Range Descriptor
     691                          array.
     692  @param [in] Length      Length of the buffer.
     693  @param [in] DescCount   Memory Range Descriptor count.
     694**/
     695STATIC
     696VOID
     697DumpIortNodeRmrMemRangeDesc (
     698  IN UINT8   *Ptr,
     699  IN UINT32  Length,
     700  IN UINT32  DescCount
     701  )
     702{
     703  UINT32  Index;
     704  UINT32  Offset;
     705  CHAR8   Buffer[40]; // Used for AsciiName param of ParseAcpi
     706
     707  Index  = 0;
     708  Offset = 0;
     709
     710  while ((Index < DescCount) &&
     711         (Offset < Length))
     712  {
     713    AsciiSPrint (
     714      Buffer,
     715      sizeof (Buffer),
     716      "Mem range Descriptor [%d]",
     717      Index
     718      );
     719    Offset += ParseAcpi (
     720                TRUE,
     721                4,
     722                Buffer,
     723                Ptr + Offset,
     724                Length - Offset,
     725                PARSER_PARAMS (IortNodeRmrMemRangeDescParser)
     726                );
     727    Index++;
     728  }
     729}
     730
     731/**
     732  This function parses the IORT RMR node.
     733
     734  @param [in] Ptr            Pointer to the start of the buffer.
     735  @param [in] Length         Length of the buffer.
     736  @param [in] MappingCount   The ID Mapping count.
     737  @param [in] MappingOffset  The offset of the ID Mapping array
     738                             from the start of the IORT table.
     739**/
     740STATIC
     741VOID
     742DumpIortNodeRmr (
     743  IN UINT8   *Ptr,
     744  IN UINT16  Length,
     745  IN UINT32  MappingCount,
     746  IN UINT32  MappingOffset
     747  )
     748{
     749  ParseAcpi (
     750    TRUE,
     751    2,
     752    "RMR Node",
     753    Ptr,
     754    Length,
     755    PARSER_PARAMS (IortNodeRmrParser)
     756    );
     757
     758  if (*IortNodeRevision == EFI_ACPI_IORT_RMR_NODE_REVISION_02) {
     759    IncrementErrorCount ();
     760    Print (
     761      L"ERROR: RMR node Rev 2 (defined in IORT Rev E.c) must not be used."
     762      L" IORT tabe Revision E.c is deprecated and must not be used.\n"
     763      );
     764  }
     765
     766  DumpIortNodeIdMappings (
     767    Ptr + MappingOffset,
     768    Length - MappingOffset,
     769    MappingCount
     770    );
     771
     772  DumpIortNodeRmrMemRangeDesc (
     773    Ptr + (*RmrMemDescOffset),
     774    Length - (*RmrMemDescOffset),
     775    *RmrMemDescCount
     776    );
     777}
     778
     779/**
    602780  This function parses the ACPI IORT table.
    603   When trace is enabled this function parses the IORT table and traces the ACPI fields.
     781  When trace is enabled this function parses the IORT table and traces the ACPI
     782  fields.
    604783
    605784  This function also parses the following nodes:
     
    610789    - SMMUv3
    611790    - PMCG
     791    - RMR
    612792
    613793  This function also performs validation of the ACPI table fields.
     
    621801EFIAPI
    622802ParseAcpiIort (
    623   IN BOOLEAN Trace,
    624   IN UINT8Ptr,
    625   IN UINT32  AcpiTableLength,
    626   IN UINT8   AcpiTableRevision
    627   )
    628 {
    629   UINT32 Offset;
    630   UINT32 Index;
    631   UINT8* NodePtr;
     803  IN BOOLEAN  Trace,
     804  IN UINT8    *Ptr,
     805  IN UINT32   AcpiTableLength,
     806  IN UINT8    AcpiTableRevision
     807  )
     808{
     809  UINT32  Offset;
     810  UINT32  Index;
     811  UINT8   *NodePtr;
    632812
    633813  if (!Trace) {
     814    return;
     815  }
     816
     817  if ((AcpiTableRevision > EFI_ACPI_IO_REMAPPING_TABLE_REVISION_00) &&
     818      (AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REVISION_05))
     819  {
     820    Print (
     821      L"ERROR: Parsing not supported for IORT tabe Revision E, E.<a,b,c>.\n"
     822      );
     823    if (AcpiTableRevision == EFI_ACPI_IO_REMAPPING_TABLE_REVISION_04) {
     824      IncrementErrorCount ();
     825      Print (
     826        L"ERROR: IORT tabe Revision E.c is deprecated and must not be used.\n"
     827        );
     828    }
     829
    634830    return;
    635831  }
     
    647843  // successfully read.
    648844  if ((IortNodeCount == NULL) ||
    649       (IortNodeOffset == NULL)) {
     845      (IortNodeOffset == NULL))
     846  {
    650847    IncrementErrorCount ();
    651848    Print (
     
    656853  }
    657854
    658   Offset = *IortNodeOffset;
     855  Offset  = *IortNodeOffset;
    659856  NodePtr = Ptr + Offset;
    660   Index = 0;
     857  Index   = 0;
    661858
    662859  // Parse the specified number of IORT nodes or the IORT table buffer length.
    663860  // Whichever is minimum.
    664861  while ((Index++ < *IortNodeCount) &&
    665          (Offset < AcpiTableLength)) {
     862         (Offset < AcpiTableLength))
     863  {
    666864    // Parse the IORT Node Header
    667865    ParseAcpi (
     
    679877        (IortNodeLength == NULL)      ||
    680878        (IortIdMappingCount == NULL)  ||
    681         (IortIdMappingOffset == NULL)) {
     879        (IortIdMappingOffset == NULL))
     880    {
    682881      IncrementErrorCount ();
    683882      Print (
    684883        L"ERROR: Insufficient remaining table buffer length to read the " \
    685           L"IORT node header. Length = %d.\n",
     884        L"IORT node header. Length = %d.\n",
    686885        AcpiTableLength - Offset
    687886        );
     
    691890    // Validate IORT Node length
    692891    if ((*IortNodeLength == 0) ||
    693         ((Offset + (*IortNodeLength)) > AcpiTableLength)) {
     892        ((Offset + (*IortNodeLength)) > AcpiTableLength))
     893    {
    694894      IncrementErrorCount ();
    695895      Print (
    696896        L"ERROR: Invalid IORT Node length. " \
    697           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     897        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    698898        *IortNodeLength,
    699899        Offset,
     
    751951          *IortIdMappingCount,
    752952          *IortIdMappingOffset
    753         );
     953          );
    754954        break;
    755 
     955      case EFI_ACPI_IORT_TYPE_RMR:
     956        DumpIortNodeRmr (
     957          NodePtr,
     958          *IortNodeLength,
     959          *IortIdMappingCount,
     960          *IortIdMappingOffset
     961          );
     962        break;
    756963      default:
    757964        IncrementErrorCount ();
     
    760967
    761968    NodePtr += (*IortNodeLength);
    762     Offset += (*IortNodeLength);
     969    Offset  += (*IortNodeLength);
    763970  } // while
    764971}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c

    r89983 r99404  
    33
    44  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
     5  Copyright (c) 2022, AMD Incorporated. All rights reserved.
    56  SPDX-License-Identifier: BSD-2-Clause-Patent
    67
     
    2021
    2122// Local Variables
    22 STATIC CONST UINT8* MadtInterruptControllerType;
    23 STATIC CONST UINT8* MadtInterruptControllerLength;
    24 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     23STATIC CONST UINT8                   *MadtInterruptControllerType;
     24STATIC CONST UINT8                   *MadtInterruptControllerLength;
     25STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2526
    2627/**
     
    3536EFIAPI
    3637ValidateGICDSystemVectorBase (
    37   IN UINT8* Ptr,
    38   IN VOIDContext
    39 )
     38  IN UINT8  *Ptr,
     39  IN VOID   *Context
     40  )
    4041{
    41   if (*(UINT32*)Ptr != 0) {
     42  if (*(UINT32 *)Ptr != 0) {
    4243    IncrementErrorCount ();
    4344    Print (
    4445      L"\nERROR: System Vector Base must be zero."
    45     );
     46      );
    4647  }
    4748}
     
    5859EFIAPI
    5960ValidateSpeOverflowInterrupt (
    60   IN UINT8* Ptr,
    61   IN VOIDContext
     61  IN UINT8  *Ptr,
     62  IN VOID   *Context
    6263  )
    6364{
    64   UINT16 SpeOverflowInterrupt;
    65 
    66   SpeOverflowInterrupt = *(UINT16*)Ptr;
     65  UINT16  SpeOverflowInterrupt;
     66
     67  SpeOverflowInterrupt = *(UINT16 *)Ptr;
    6768
    6869  // SPE not supported by this processor
     
    7475      ((SpeOverflowInterrupt > ARM_PPI_ID_MAX) &&
    7576       (SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
    76       (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) {
     77      (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX))
     78  {
    7779    IncrementErrorCount ();
    7880    Print (
    7981      L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
    80         L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
     82      L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
    8183      SpeOverflowInterrupt,
    8284      ARM_PPI_ID_MIN,
     
    8486      ARM_PPI_ID_EXTENDED_MIN,
    8587      ARM_PPI_ID_EXTENDED_MAX
    86     );
     88      );
    8789  } else if (SpeOverflowInterrupt != ARM_PPI_ID_PMBIRQ) {
    88     IncrementWarningCount();
     90    IncrementWarningCount ();
    8991    Print (
    9092      L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with SBSA "
    91         L"Level 3 PPI ID assignment: %d.",
     93      L"Level 3 PPI ID assignment: %d.",
    9294      SpeOverflowInterrupt,
    9395      ARM_PPI_ID_PMBIRQ
    94     );
     96      );
    9597  }
    9698}
     
    99101  An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
    100102**/
    101 STATIC CONST ACPI_PARSER GicCParser[] = {
    102   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    103   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    104   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    105 
    106   {L"CPU Interface Number", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    107   {L"ACPI Processor UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    108   {L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    109   {L"Parking Protocol Version", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    110 
    111   {L"Performance Interrupt GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    112   {L"Parked Address", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL},
    113   {L"Physical Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
    114   {L"GICV", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL},
    115   {L"GICH", 8, 48, L"0x%lx", NULL, NULL, NULL, NULL},
    116   {L"VGIC Maintenance interrupt", 4, 56, L"0x%x", NULL, NULL, NULL, NULL},
    117   {L"GICR Base Address", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL},
    118   {L"MPIDR", 8, 68, L"0x%lx", NULL, NULL, NULL, NULL},
    119   {L"Processor Power Efficiency Class", 1, 76, L"0x%x", NULL, NULL, NULL,
    120    NULL},
    121   {L"Reserved", 1, 77, L"0x%x", NULL, NULL, NULL, NULL},
    122   {L"SPE overflow Interrupt", 2, 78, L"0x%x", NULL, NULL,
    123     ValidateSpeOverflowInterrupt, NULL}
     103STATIC CONST ACPI_PARSER  GicCParser[] = {
     104  { L"Type",                             1, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     105  { L"Length",                           1, 1,  L"%d",    NULL, NULL, NULL, NULL },
     106  { L"Reserved",                         2, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     107
     108  { L"CPU Interface Number",             4, 4,  L"0x%x",  NULL, NULL, NULL, NULL },
     109  { L"ACPI Processor UID",               4, 8,  L"0x%x",  NULL, NULL, NULL, NULL },
     110  { L"Flags",                            4, 12, L"0x%x",  NULL, NULL, NULL, NULL },
     111  { L"Parking Protocol Version",         4, 16, L"0x%x",  NULL, NULL, NULL, NULL },
     112
     113  { L"Performance Interrupt GSIV",       4, 20, L"0x%x",  NULL, NULL, NULL, NULL },
     114  { L"Parked Address",                   8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
     115  { L"Physical Base Address",            8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
     116  { L"GICV",                             8, 40, L"0x%lx", NULL, NULL, NULL, NULL },
     117  { L"GICH",                             8, 48, L"0x%lx", NULL, NULL, NULL, NULL },
     118  { L"VGIC Maintenance interrupt",       4, 56, L"0x%x",  NULL, NULL, NULL, NULL },
     119  { L"GICR Base Address",                8, 60, L"0x%lx", NULL, NULL, NULL, NULL },
     120  { L"MPIDR",                            8, 68, L"0x%lx", NULL, NULL, NULL, NULL },
     121  { L"Processor Power Efficiency Class", 1, 76, L"0x%x", NULL, NULL, NULL,
     122    NULL },
     123  { L"Reserved",                         1, 77, L"0x%x",  NULL, NULL, NULL, NULL },
     124  { L"SPE overflow Interrupt",           2, 78, L"0x%x", NULL, NULL,
     125    ValidateSpeOverflowInterrupt, NULL }
    124126};
    125127
     
    127129  An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
    128130**/
    129 STATIC CONST ACPI_PARSER GicDParser[] = {
    130   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    131   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    132   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    133 
    134   {L"GIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    135   {L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    136   {L"System Vector Base", 4, 16, L"0x%x", NULL, NULL,
    137     ValidateGICDSystemVectorBase, NULL},
    138   {L"GIC Version", 1, 20, L"%d", NULL, NULL, NULL, NULL},
    139   {L"Reserved", 3, 21, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
     131STATIC CONST ACPI_PARSER  GicDParser[] = {
     132  { L"Type",                  1, 0,  L"0x%x",     NULL,       NULL, NULL, NULL },
     133  { L"Length",                1, 1,  L"%d",       NULL,       NULL, NULL, NULL },
     134  { L"Reserved",              2, 2,  L"0x%x",     NULL,       NULL, NULL, NULL },
     135
     136  { L"GIC ID",                4, 4,  L"0x%x",     NULL,       NULL, NULL, NULL },
     137  { L"Physical Base Address", 8, 8,  L"0x%lx",    NULL,       NULL, NULL, NULL },
     138  { L"System Vector Base",    4, 16, L"0x%x",     NULL,      NULL,
     139    ValidateGICDSystemVectorBase, NULL },
     140  { L"GIC Version",           1, 20, L"%d",       NULL,       NULL, NULL, NULL },
     141  { L"Reserved",              3, 21, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
    140142};
    141143
     
    143145  An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure.
    144146**/
    145 STATIC CONST ACPI_PARSER GicMSIFrameParser[] = {
    146   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    147   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    148   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    149 
    150   {L"MSI Frame ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    151   {L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    152   {L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    153 
    154   {L"SPI Count", 2, 20, L"%d", NULL, NULL, NULL, NULL},
    155   {L"SPI Base", 2, 22, L"0x%x", NULL, NULL, NULL, NULL}
     147STATIC CONST ACPI_PARSER  GicMSIFrameParser[] = {
     148  { L"Type",                  1, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     149  { L"Length",                1, 1,  L"%d",    NULL, NULL, NULL, NULL },
     150  { L"Reserved",              2, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     151
     152  { L"MSI Frame ID",          4, 4,  L"0x%x",  NULL, NULL, NULL, NULL },
     153  { L"Physical Base Address", 8, 8,  L"0x%lx", NULL, NULL, NULL, NULL },
     154  { L"Flags",                 4, 16, L"0x%x",  NULL, NULL, NULL, NULL },
     155
     156  { L"SPI Count",             2, 20, L"%d",    NULL, NULL, NULL, NULL },
     157  { L"SPI Base",              2, 22, L"0x%x",  NULL, NULL, NULL, NULL }
    156158};
    157159
     
    159161  An ACPI_PARSER array describing the GICR Interrupt Controller Structure.
    160162**/
    161 STATIC CONST ACPI_PARSER GicRParser[] = {
    162   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    163   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    164   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    165 
    166   {L"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL,
    167    NULL},
    168   {L"Discovery Range Length", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
     163STATIC CONST ACPI_PARSER  GicRParser[] = {
     164  { L"Type",                         1, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     165  { L"Length",                       1, 1,  L"%d",    NULL, NULL, NULL, NULL },
     166  { L"Reserved",                     2, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     167
     168  { L"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL,
     169    NULL },
     170  { L"Discovery Range Length",       4, 12, L"0x%x",  NULL, NULL, NULL, NULL }
    169171};
    170172
     
    172174  An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure.
    173175**/
    174 STATIC CONST ACPI_PARSER GicITSParser[] = {
    175   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    176   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    177   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    178 
    179   {L"GIC ITS ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    180   {L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    181   {L"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}
     176STATIC CONST ACPI_PARSER  GicITSParser[] = {
     177  { L"Type",                  1, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     178  { L"Length",                1, 1,  L"%d",    NULL, NULL, NULL, NULL },
     179  { L"Reserved",              2, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     180
     181  { L"GIC ITS ID",            4, 4,  L"0x%x",  NULL, NULL, NULL, NULL },
     182  { L"Physical Base Address", 8, 8,  L"0x%lx", NULL, NULL, NULL, NULL },
     183  { L"Reserved",              4, 16, L"0x%x",  NULL, NULL, NULL, NULL }
     184};
     185
     186/**
     187  An ACPI_PARSER array describing the IO APIC Structure.
     188**/
     189STATIC CONST ACPI_PARSER  IoApic[] = {
     190  { L"Type",                         1, 0, L"0x%x", NULL, NULL, NULL, NULL },
     191  { L"Length",                       1, 1, L"%d",   NULL, NULL, NULL, NULL },
     192  { L"I/O APIC ID",                  1, 2, L"0x%x", NULL, NULL, NULL, NULL },
     193  { L"Reserved",                     1, 3, L"0x%x", NULL, NULL, NULL, NULL },
     194  { L"I/O APIC Address",             4, 4, L"0x%x", NULL, NULL, NULL, NULL },
     195  { L"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL }
     196};
     197
     198/**
     199  An ACPI_PARSER array describing the Interrupt Source Override Structure.
     200**/
     201STATIC CONST ACPI_PARSER  InterruptSourceOverride[] = {
     202  { L"Type",                    1, 0, L"0x%x", NULL, NULL, NULL, NULL },
     203  { L"Length",                  1, 1, L"%d",   NULL, NULL, NULL, NULL },
     204  { L"Bus",                     1, 2, L"0x%x", NULL, NULL, NULL, NULL },
     205  { L"Source",                  1, 3, L"0x%x", NULL, NULL, NULL, NULL },
     206  { L"Global System Interrupt", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
     207  { L"Flags",                   2, 8, L"0x%x", NULL, NULL, NULL, NULL }
     208};
     209
     210STATIC CONST ACPI_PARSER  LocalApicFlags[] = {
     211  { L"Enabled",        1,  0, L"%d", NULL, NULL, NULL, NULL },
     212  { L"Online Capable", 1,  1, L"%d", NULL, NULL, NULL, NULL },
     213  { L"Reserved",       30, 2, L"%d", NULL, NULL, NULL, NULL }
     214};
     215
     216/**
     217  This function traces Bit Flags fields.
     218  If no format string is specified the Format must be NULL.
     219
     220  @param [in] Format  Optional format string for tracing the data.
     221  @param [in] Ptr     Pointer to the start of the buffer.
     222**/
     223VOID
     224EFIAPI
     225DumpLocalApicBitFlags (
     226  IN CONST CHAR16  *Format OPTIONAL,
     227  IN UINT8         *Ptr
     228  )
     229{
     230  if (Format != NULL) {
     231    Print (Format, *(UINT32 *)Ptr);
     232    return;
     233  }
     234
     235  Print (L"0x%X\n", *(UINT32 *)Ptr);
     236  ParseAcpiBitFields (
     237    TRUE,
     238    2,
     239    NULL,
     240    Ptr,
     241    4,
     242    PARSER_PARAMS (LocalApicFlags)
     243    );
     244}
     245
     246/**
     247   An ACPI_PARSER array describing the Processor Local APIC Structure.
     248 **/
     249STATIC CONST ACPI_PARSER  ProcessorLocalApic[] = {
     250  { L"Type",               1, 0, L"0x%x", NULL,                  NULL, NULL, NULL },
     251  { L"Length",             1, 1, L"%d",   NULL,                  NULL, NULL, NULL },
     252
     253  { L"ACPI Processor UID", 1, 2, L"0x%x", NULL,                  NULL, NULL, NULL },
     254  { L"APIC ID",            1, 3, L"0x%x", NULL,                  NULL, NULL, NULL },
     255  { L"Flags",              4, 4, NULL,    DumpLocalApicBitFlags, NULL, NULL, NULL }
     256};
     257
     258/**
     259  An ACPI_PARSER array describing the Processor Local x2APIC Structure.
     260**/
     261STATIC CONST ACPI_PARSER  ProcessorLocalX2Apic[] = {
     262  { L"Type",               1, 0,  L"0x%x", NULL,                  NULL, NULL, NULL },
     263  { L"Length",             1, 1,  L"%d",   NULL,                  NULL, NULL, NULL },
     264  { L"Reserved",           2, 2,  L"0x%x", NULL,                  NULL, NULL, NULL },
     265
     266  { L"X2APIC ID",          4, 4,  L"0x%x", NULL,                  NULL, NULL, NULL },
     267  { L"Flags",              4, 8,  NULL,    DumpLocalApicBitFlags, NULL, NULL, NULL },
     268  { L"ACPI Processor UID", 4, 12, L"0x%x", NULL,                  NULL, NULL, NULL }
     269};
     270
     271/**
     272  An ACPI_PARSER array describing the Local x2APIC NMI Structure.
     273**/
     274STATIC CONST ACPI_PARSER  LocalX2ApicNmi[] = {
     275  { L"Type",               1, 0, L"0x%x",     NULL,       NULL, NULL, NULL },
     276  { L"Length",             1, 1, L"%d",       NULL,       NULL, NULL, NULL },
     277  { L"Flags",              2, 2, L"0x%x",     NULL,       NULL, NULL, NULL },
     278
     279  { L"ACPI Processor UID", 4, 4, L"0x%x",     NULL,       NULL, NULL, NULL },
     280  { L"Local x2APIC LINT#", 1, 8, L"0x%x",     NULL,       NULL, NULL, NULL },
     281  { L"Reserved",           3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL }
    182282};
    183283
     
    185285  An ACPI_PARSER array describing the ACPI MADT Table.
    186286**/
    187 STATIC CONST ACPI_PARSER MadtParser[] = {
     287STATIC CONST ACPI_PARSER  MadtParser[] = {
    188288  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    189   {L"Local Interrupt Controller Address", 4, 36, L"0x%x", NULL, NULL, NULL,
    190    NULL},
    191   {L"Flags", 4, 40, L"0x%x", NULL, NULL, NULL, NULL}
     289  { L"Local Interrupt Controller Address",4,        36, L"0x%x", NULL, NULL, NULL,
     290    NULL },
     291  { L"Flags",                      4,         40, L"0x%x", NULL, NULL, NULL,NULL}
    192292};
    193293
     
    195295  An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure.
    196296**/
    197 STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
    198   {NULL, 1, 0, NULL, NULL, (VOID**)&MadtInterruptControllerType, NULL, NULL},
    199   {L"Length", 1, 1, NULL, NULL, (VOID**)&MadtInterruptControllerLength, NULL,
    200    NULL},
    201   {L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}
     297STATIC CONST ACPI_PARSER  MadtInterruptControllerHeaderParser[] = {
     298  { NULL,        1, 0, NULL, NULL, (VOID **)&MadtInterruptControllerType,   NULL, NULL },
     299  { L"Length",   1, 1, NULL, NULL, (VOID **)&MadtInterruptControllerLength, NULL,
     300    NULL },
     301  { L"Reserved", 2, 2, NULL, NULL, NULL,                                    NULL, NULL }
    202302};
    203303
     
    225325EFIAPI
    226326ParseAcpiMadt (
    227   IN BOOLEAN Trace,
    228   IN UINT8Ptr,
    229   IN UINT32  AcpiTableLength,
    230   IN UINT8   AcpiTableRevision
     327  IN BOOLEAN  Trace,
     328  IN UINT8    *Ptr,
     329  IN UINT32   AcpiTableLength,
     330  IN UINT8    AcpiTableRevision
    231331  )
    232332{
    233   UINT32 Offset;
    234   UINT8* InterruptContollerPtr;
    235   UINT32 GICDCount;
     333  UINT32  Offset;
     334  UINT8   *InterruptContollerPtr;
     335  UINT32  GICDCount;
    236336
    237337  GICDCount = 0;
     
    265365    // successfully read.
    266366    if ((MadtInterruptControllerType == NULL) ||
    267         (MadtInterruptControllerLength == NULL)) {
     367        (MadtInterruptControllerLength == NULL))
     368    {
    268369      IncrementErrorCount ();
    269370      Print (
    270371        L"ERROR: Insufficient remaining table buffer length to read the " \
    271           L"Interrupt Controller Structure header. Length = %d.\n",
     372        L"Interrupt Controller Structure header. Length = %d.\n",
    272373        AcpiTableLength - Offset
    273374        );
     
    277378    // Validate Interrupt Controller Structure length
    278379    if ((*MadtInterruptControllerLength == 0) ||
    279         ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) {
     380        ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength))
     381    {
    280382      IncrementErrorCount ();
    281383      Print (
    282384        L"ERROR: Invalid Interrupt Controller Structure length. " \
    283           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     385        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    284386        *MadtInterruptControllerLength,
    285387        Offset,
     
    290392
    291393    switch (*MadtInterruptControllerType) {
    292       case EFI_ACPI_6_3_GIC: {
     394      case EFI_ACPI_6_3_GIC:
     395      {
    293396        ParseAcpi (
    294397          TRUE,
     
    302405      }
    303406
    304       case EFI_ACPI_6_3_GICD: {
     407      case EFI_ACPI_6_3_GICD:
     408      {
    305409        if (++GICDCount > 1) {
    306410          IncrementErrorCount ();
    307411          Print (
    308412            L"ERROR: Only one GICD must be present,"
    309               L" GICDCount = %d\n",
     413            L" GICDCount = %d\n",
    310414            GICDCount
    311415            );
    312416        }
     417
    313418        ParseAcpi (
    314419          TRUE,
     
    322427      }
    323428
    324       case EFI_ACPI_6_3_GIC_MSI_FRAME: {
     429      case EFI_ACPI_6_3_GIC_MSI_FRAME:
     430      {
    325431        ParseAcpi (
    326432          TRUE,
     
    334440      }
    335441
    336       case EFI_ACPI_6_3_GICR: {
     442      case EFI_ACPI_6_3_GICR:
     443      {
    337444        ParseAcpi (
    338445          TRUE,
     
    346453      }
    347454
    348       case EFI_ACPI_6_3_GIC_ITS: {
     455      case EFI_ACPI_6_3_GIC_ITS:
     456      {
    349457        ParseAcpi (
    350458          TRUE,
     
    358466      }
    359467
    360       default: {
     468      case EFI_ACPI_6_3_IO_APIC:
     469      {
     470        ParseAcpi (
     471          TRUE,
     472          2,
     473          "IO APIC",
     474          InterruptContollerPtr,
     475          *MadtInterruptControllerLength,
     476          PARSER_PARAMS (IoApic)
     477          );
     478        break;
     479      }
     480
     481      case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE:
     482      {
     483        ParseAcpi (
     484          TRUE,
     485          2,
     486          "INTERRUPT SOURCE OVERRIDE",
     487          InterruptContollerPtr,
     488          *MadtInterruptControllerLength,
     489          PARSER_PARAMS (InterruptSourceOverride)
     490          );
     491        break;
     492      }
     493      case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC:
     494      {
     495        ParseAcpi (
     496          TRUE,
     497          2,
     498          "PROCESSOR LOCAL APIC",
     499          InterruptContollerPtr,
     500          *MadtInterruptControllerLength,
     501          PARSER_PARAMS (ProcessorLocalApic)
     502          );
     503        break;
     504      }
     505      case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC:
     506      {
     507        ParseAcpi (
     508          TRUE,
     509          2,
     510          "PROCESSOR LOCAL X2APIC",
     511          InterruptContollerPtr,
     512          *MadtInterruptControllerLength,
     513          PARSER_PARAMS (ProcessorLocalX2Apic)
     514          );
     515        break;
     516      }
     517
     518      case EFI_ACPI_6_3_LOCAL_X2APIC_NMI:
     519      {
     520        ParseAcpi (
     521          TRUE,
     522          2,
     523          "LOCAL x2APIC NMI",
     524          InterruptContollerPtr,
     525          *MadtInterruptControllerLength,
     526          PARSER_PARAMS (LocalX2ApicNmi)
     527          );
     528        break;
     529      }
     530
     531      default:
     532      {
    361533        IncrementErrorCount ();
    362534        Print (
    363535          L"ERROR: Unknown Interrupt Controller Structure,"
    364             L" Type = %d, Length = %d\n",
     536          L" Type = %d, Length = %d\n",
    365537          *MadtInterruptControllerType,
    366538          *MadtInterruptControllerLength
     
    370542
    371543    InterruptContollerPtr += *MadtInterruptControllerLength;
    372     Offset += *MadtInterruptControllerLength;
     544    Offset                += *MadtInterruptControllerLength;
    373545  } // while
    374546}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h

    r80721 r99404  
    1717/// Level 3 base server system Private Peripheral Inerrupt (PPI) ID assignments
    1818///
    19 #define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTP       30
    20 #define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTPS      29
    21 #define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHV      28
    22 #define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTV       27
    23 #define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHP      26
    24 #define ARM_PPI_ID_GIC_MAINTENANCE_INTERRUPT          25
    25 #define ARM_PPI_ID_CTIIRQ                             24
    26 #define ARM_PPI_ID_PERFORMANCE_MONITORS_INTERRUPT     23
    27 #define ARM_PPI_ID_COMMIRQ                            22
    28 #define ARM_PPI_ID_PMBIRQ                             21
    29 #define ARM_PPI_ID_CNTHPS                             20
    30 #define ARM_PPI_ID_CNTHVS                             19
     19#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTP    30
     20#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTPS   29
     21#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHV   28
     22#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTV    27
     23#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHP   26
     24#define ARM_PPI_ID_GIC_MAINTENANCE_INTERRUPT       25
     25#define ARM_PPI_ID_CTIIRQ                          24
     26#define ARM_PPI_ID_PERFORMANCE_MONITORS_INTERRUPT  23
     27#define ARM_PPI_ID_COMMIRQ                         22
     28#define ARM_PPI_ID_PMBIRQ                          21
     29#define ARM_PPI_ID_CNTHPS                          20
     30#define ARM_PPI_ID_CNTHVS                          19
    3131
    3232///
    3333/// PPI ID allowed ranges
    3434///
    35 #define ARM_PPI_ID_MAX              31
    36 #define ARM_PPI_ID_MIN              16
    37 #define ARM_PPI_ID_EXTENDED_MAX     1119
    38 #define ARM_PPI_ID_EXTENDED_MIN     1056
     35#define ARM_PPI_ID_MAX           31
     36#define ARM_PPI_ID_MIN           16
     37#define ARM_PPI_ID_EXTENDED_MAX  1119
     38#define ARM_PPI_ID_EXTENDED_MIN  1056
    3939
    4040#endif // MADT_PARSER_H_
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c

    r80721 r99404  
    1515
    1616// Local variables
    17 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     17STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    1818
    1919/**
    2020  An ACPI_PARSER array describing the ACPI MCFG Table.
    2121**/
    22 STATIC CONST ACPI_PARSER McfgParser[] = {
     22STATIC CONST ACPI_PARSER  McfgParser[] = {
    2323  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    24   {L"Reserved", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},
     24  { L"Reserved",                   8,36, L"0x%lx", NULL, NULL, NULL, NULL },
    2525};
    2626
     
    2828  An ACPI_PARSER array describing the PCI configuration Space Base Address structure.
    2929**/
    30 STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
    31   {L"Base Address", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL},
    32   {L"PCI Segment Group No.", 2, 8, L"0x%x", NULL, NULL, NULL, NULL},
    33   {L"Start Bus No.", 1, 10, L"0x%x", NULL, NULL, NULL, NULL},
    34   {L"End Bus No.", 1, 11, L"0x%x", NULL, NULL, NULL, NULL},
    35   {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
     30STATIC CONST ACPI_PARSER  PciCfgSpaceBaseAddrParser[] = {
     31  { L"Base Address",          8, 0,  L"0x%lx", NULL, NULL, NULL, NULL },
     32  { L"PCI Segment Group No.", 2, 8,  L"0x%x",  NULL, NULL, NULL, NULL },
     33  { L"Start Bus No.",         1, 10, L"0x%x",  NULL, NULL, NULL, NULL },
     34  { L"End Bus No.",           1, 11, L"0x%x",  NULL, NULL, NULL, NULL },
     35  { L"Reserved",              4, 12, L"0x%x",  NULL, NULL, NULL, NULL }
    3636};
    3737
     
    5151EFIAPI
    5252ParseAcpiMcfg (
    53   IN BOOLEAN Trace,
    54   IN UINT8Ptr,
    55   IN UINT32  AcpiTableLength,
    56   IN UINT8   AcpiTableRevision
     53  IN BOOLEAN  Trace,
     54  IN UINT8    *Ptr,
     55  IN UINT32   AcpiTableLength,
     56  IN UINT8    AcpiTableRevision
    5757  )
    5858{
    59   UINT32 Offset;
    60   UINT32 PciCfgOffset;
    61   UINT8* PciCfgSpacePtr;
     59  UINT32  Offset;
     60  UINT32  PciCfgOffset;
     61  UINT8   *PciCfgSpacePtr;
    6262
    6363  if (!Trace) {
     
    8686                     );
    8787    PciCfgSpacePtr += PciCfgOffset;
    88     Offset += PciCfgOffset;
     88    Offset         += PciCfgOffset;
    8989  }
    9090}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c

    r89983 r99404  
    22  PCCT table parser
    33
    4   Copyright (c) 2020, Arm Limited.
     4  Copyright (c) 2021, Arm Limited.
    55  SPDX-License-Identifier: BSD-2-Clause-Patent
    66
    77  @par Reference(s):
    8     - ACPI 6.3 Specification - January 2019
     8    - ACPI 6.4 Specification - January 2021
    99**/
    1010
     
    1818
    1919// Local variables
    20 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
    21 
    22 STATIC UINT32* PccGlobalFlags;
    23 STATIC UINT8PccSubspaceLength;
    24 STATIC UINT8PccSubspaceType;
    25 STATIC UINT8ExtendedPccSubspaceInterruptFlags;
     20STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
     21
     22STATIC UINT32  *PccGlobalFlags;
     23STATIC UINT8   *PccSubspaceLength;
     24STATIC UINT8   *PccSubspaceType;
     25STATIC UINT8   *ExtendedPccSubspaceInterruptFlags;
    2626
    2727/**
     
    3636EFIAPI
    3737ValidateRangeLength4 (
    38   IN UINT8* Ptr,
    39   IN VOIDContext
    40   )
    41 {
    42   if (*(UINT32*)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
     38  IN UINT8  *Ptr,
     39  IN VOID   *Context
     40  )
     41{
     42  if (*(UINT32 *)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
    4343    IncrementErrorCount ();
    4444    Print (
    4545      L"\nError: Shared memory range length is too short.\n"
    4646      L"Length is %u when it should be greater than or equal to %u",
    47       *(UINT32*)Ptr,
     47      *(UINT32 *)Ptr,
    4848      MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN
    4949      );
     
    6262EFIAPI
    6363ValidateRangeLength8 (
    64   IN UINT8* Ptr,
    65   IN VOIDContext
    66   )
    67 {
    68   if (*(UINT64*)Ptr <= MIN_MEMORY_RANGE_LENGTH) {
     64  IN UINT8  *Ptr,
     65  IN VOID   *Context
     66  )
     67{
     68  if (*(UINT64 *)Ptr <= MIN_MEMORY_RANGE_LENGTH) {
    6969    IncrementErrorCount ();
    7070    Print (
    7171      L"\nError: Shared memory range length is too short.\n"
    7272      L"Length is %u when it should be greater than %u",
    73       *(UINT64*)Ptr,
     73      *(UINT64 *)Ptr,
    7474      MIN_MEMORY_RANGE_LENGTH
    7575      );
     
    7878
    7979/**
    80   This function validates address space for type 0 structure.
    81 
    82   @param [in] Ptr     Pointer to the start of the field data.
    83   @param [in] Context Pointer to context specific information e.g. this
    84                       could be a pointer to the ACPI table header.
    85 **/
    86 STATIC
    87 VOID
    88 EFIAPI
    89 ValidatePccType0Gas (
    90   IN UINT8* Ptr,
    91   IN VOIDContext
    92   )
    93 {
    94   switch (*(UINT8*)Ptr) {
    95 #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
    96     case EFI_ACPI_6_3_SYSTEM_IO:
    97 #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
    98     case EFI_ACPI_6_3_SYSTEM_MEMORY:
     80  This function validates address space for Memory/IO GAS.
     81
     82  @param [in] Ptr     Pointer to the start of the field data.
     83  @param [in] Context Pointer to context specific information e.g. this
     84                      could be a pointer to the ACPI table header.
     85**/
     86STATIC
     87VOID
     88EFIAPI
     89ValidatePccMemoryIoGas (
     90  IN UINT8  *Ptr,
     91  IN VOID   *Context
     92  )
     93{
     94  switch (*(UINT8 *)Ptr) {
     95 #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
     96    case EFI_ACPI_6_4_SYSTEM_IO:
     97 #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
     98    case EFI_ACPI_6_4_SYSTEM_MEMORY:
    9999      return;
    100100    default:
     
    115115EFIAPI
    116116ValidatePccGas (
    117   IN UINT8* Ptr,
    118   IN VOIDContext
    119   )
    120 {
    121   switch (*(UINT8*)Ptr) {
    122 #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
    123     case EFI_ACPI_6_3_SYSTEM_IO:
    124 #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
    125     case EFI_ACPI_6_3_FUNCTIONAL_FIXED_HARDWARE:
    126     case EFI_ACPI_6_3_SYSTEM_MEMORY:
     117  IN UINT8  *Ptr,
     118  IN VOID   *Context
     119  )
     120{
     121  switch (*(UINT8 *)Ptr) {
     122 #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
     123    case EFI_ACPI_6_4_SYSTEM_IO:
     124 #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
     125    case EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE:
     126    case EFI_ACPI_6_4_SYSTEM_MEMORY:
    127127      return;
    128128    default:
     
    143143EFIAPI
    144144ValidatePccDoorbellGas (
    145   IN UINT8* Ptr,
    146   IN VOIDContext
    147   )
    148 {
    149   // For slave subspaces this field is optional, if not present the field
     145  IN UINT8  *Ptr,
     146  IN VOID   *Context
     147  )
     148{
     149  // For responder subspaces this field is optional, if not present the field
    150150  // should just contain zeros.
    151   if (*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
     151  if (*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
    152152    if (IsZeroBuffer (
    153153          Ptr,
    154           sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)
    155           )) {
     154          sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
     155          ))
     156    {
    156157      return;
    157158    }
     
    173174EFIAPI
    174175ValidatePccIntAckGas (
    175   IN UINT8* Ptr,
    176   IN VOIDContext
     176  IN UINT8  *Ptr,
     177  IN VOID   *Context
    177178  )
    178179{
     
    181182  // 12 bytes of the GAS structure indicates the register is not
    182183  // present.
    183   if (((*PccGlobalFlags & EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
    184        EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
     184  if (((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
     185       EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
    185186      ((*ExtendedPccSubspaceInterruptFlags &
    186        EFI_ACPI_6_3_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
    187        EFI_ACPI_6_3_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE)) {
     187        EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
     188       EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE))
     189  {
    188190    if (IsZeroBuffer (
    189191          Ptr,
    190           sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)
    191           )) {
     192          sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
     193          ))
     194    {
    192195      return;
    193196    }
     
    208211EFIAPI
    209212ValidatePccErrStatusGas (
    210   IN UINT8* Ptr,
    211   IN VOIDContext
    212   )
    213 {
    214   // This field is ignored by the OSPM on slave channels.
    215   if (*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
     213  IN UINT8  *Ptr,
     214  IN VOID   *Context
     215  )
     216{
     217  // This field is ignored by the OSPM on responder channels.
     218  if (*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
    216219    return;
    217220  }
     
    231234EFIAPI
    232235ValidatePlatInterrupt (
    233   IN UINT8* Ptr,
    234   IN VOIDContext
    235   )
    236 {
    237   // If a slave subspace is present in the PCCT, then the global Platform
     236  IN UINT8  *Ptr,
     237  IN VOID   *Context
     238  )
     239{
     240  // If a responder subspace is present in the PCCT, then the global Platform
    238241  // Interrupt flag must be set to 1.
    239   if ((*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
    240       ((*PccGlobalFlags & EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
    241         EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT)) {
     242  if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
     243      ((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
     244       EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT))
     245  {
    242246    IncrementErrorCount ();
    243247    Print (
    244248      L"\nError: Global Platform interrupt flag must be set to 1" \
    245         L" if a PCC type 4 structure is present in PCCT."
     249      L" if a PCC type 4 structure is present in PCCT."
    246250      );
    247251  }
     
    251255  An ACPI_PARSER array describing the ACPI PCCT Table.
    252256*/
    253 STATIC CONST ACPI_PARSER PcctParser[] = {
     257STATIC CONST ACPI_PARSER  PcctParser[] = {
    254258  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    255   {L"Flags", 4, 36, NULL, NULL, (VOID**)&PccGlobalFlags, NULL, NULL},
    256   {L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL}
     259  { L"Flags",                      4,  36, NULL, NULL, (VOID **)&PccGlobalFlags, NULL, NULL },
     260  { L"Reserved",                   8,  40, NULL, NULL, NULL,                     NULL, NULL }
    257261};
    258262
     
    261265  structure header.
    262266*/
    263 STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = {
     267STATIC CONST ACPI_PARSER  PccSubspaceHeaderParser[] = {
    264268  PCC_SUBSPACE_HEADER ()
    265269  // ... Type Specific Fields ...
     
    269273  An ACPI_PARSER array describing the Generic Communications Subspace - Type 0
    270274*/
    271 STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
     275STATIC CONST ACPI_PARSER  PccSubspaceType0Parser[] = {
    272276  PCC_SUBSPACE_HEADER (),
    273   {L"Reserved", 6, 2, L"%x %x %x %x %x %x", Dump6Chars, NULL, NULL, NULL},
    274   {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    275   {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
    276     NULL},
    277   {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccType0Gas,
    278     NULL},
    279   {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},
    280   {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL},
    281   {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL},
    282   {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL},
    283   {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL}
     277  { L"Reserved",         6,   2,  L"%x %x %x %x %x %x", Dump6Chars, NULL, NULL,                   NULL },
     278  { L"Base Address",     8,   8,  L"0x%lx",             NULL,       NULL, NULL,                   NULL },
     279  { L"Memory Range Length",8,   16, L"0x%lx",             NULL,      NULL, ValidateRangeLength8,
     280    NULL },
     281  { L"Doorbell Register",12,  24, NULL,                 DumpGas,    NULL, ValidatePccMemoryIoGas,
     282    NULL },
     283  { L"Doorbell Preserve",8,   36, L"0x%lx",             NULL,       NULL, NULL,                   NULL },
     284  { L"Doorbell Write",   8,   44, L"0x%lx",             NULL,       NULL, NULL,                   NULL },
     285  { L"Nominal Latency",  4,   52, L"%u",                NULL,       NULL, NULL,                   NULL },
     286  { L"Maximum Periodic Access Rate",4,   56, L"%u",                NULL,       NULL, NULL,                   NULL },
     287  { L"Minimum Request Turnaround Time",2,   60, L"%u",                NULL,       NULL, NULL,                   NULL }
    284288};
    285289
     
    288292  - Type 1
    289293*/
    290 STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = {
     294STATIC CONST ACPI_PARSER  PccSubspaceType1Parser[] = {
    291295  PCC_SUBSPACE_HEADER (),
    292   {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL},
    293   {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL},
    294   {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL},
    295   {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    296   {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
    297     NULL},
    298   {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL,
    299     ValidatePccGas, NULL},
    300   {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},
    301   {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL},
    302   {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL},
    303   {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL},
    304   {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL}
     296  { L"Platform Interrupt",4,   2,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     297  { L"Platform Interrupt Flags",1,   6,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     298  { L"Reserved",         1,   7,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     299  { L"Base Address",     8,   8,  L"0x%lx", NULL,    NULL, NULL,                 NULL },
     300  { L"Memory Range Length",8,   16, L"0x%lx", NULL,    NULL, ValidateRangeLength8,
     301    NULL },
     302  { L"Doorbell Register",12,  24, NULL,    DumpGas, NULL,
     303    ValidatePccGas,      NULL },
     304  { L"Doorbell Preserve",8,   36, L"0x%lx", NULL,    NULL, NULL,                 NULL },
     305  { L"Doorbell Write",   8,   44, L"0x%lx", NULL,    NULL, NULL,                 NULL },
     306  { L"Nominal Latency",  4,   52, L"%u",    NULL,    NULL, NULL,                 NULL },
     307  { L"Maximum Periodic Access Rate",4,   56, L"%u",    NULL,    NULL, NULL,                 NULL },
     308  { L"Minimum Request Turnaround Time",2,   60, L"%u",    NULL,    NULL, NULL,                 NULL }
    305309};
    306310
     
    309313  - Type 2
    310314*/
    311 STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = {
     315STATIC CONST ACPI_PARSER  PccSubspaceType2Parser[] = {
    312316  PCC_SUBSPACE_HEADER (),
    313   {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL},
    314   {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL},
    315   {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL},
    316   {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    317   {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
    318     NULL},
    319   {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL,
    320     ValidatePccGas, NULL},
    321   {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},
    322   {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL},
    323   {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL},
    324   {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL},
    325   {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL},
    326   {L"Platform Interrupt Ack Register", 12, 62, NULL, DumpGas, NULL,
    327     ValidatePccGas, NULL},
    328   {L"Platform Interrupt Ack Preserve", 8, 74, L"0x%lx", NULL, NULL, NULL, NULL},
    329   {L"Platform Interrupt Ack Write", 8, 82, L"0x%lx", NULL, NULL,
    330     NULL, NULL},
     317  { L"Platform Interrupt",4,   2,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     318  { L"Platform Interrupt Flags",1,   6,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     319  { L"Reserved",         1,   7,  L"0x%x",  NULL,    NULL, NULL,                 NULL },
     320  { L"Base Address",     8,   8,  L"0x%lx", NULL,    NULL, NULL,                 NULL },
     321  { L"Memory Range Length",8,   16, L"0x%lx", NULL,    NULL, ValidateRangeLength8,
     322    NULL },
     323  { L"Doorbell Register",12,  24, NULL,    DumpGas, NULL,
     324    ValidatePccGas,      NULL },
     325  { L"Doorbell Preserve",8,   36, L"0x%lx", NULL,    NULL, NULL,                 NULL },
     326  { L"Doorbell Write",   8,   44, L"0x%lx", NULL,    NULL, NULL,                 NULL },
     327  { L"Nominal Latency",  4,   52, L"%u",    NULL,    NULL, NULL,                 NULL },
     328  { L"Maximum Periodic Access Rate",4,   56, L"%u",    NULL,    NULL, NULL,                 NULL },
     329  { L"Minimum Request Turnaround Time",2,   60, L"%u",    NULL,    NULL, NULL,                 NULL },
     330  { L"Platform Interrupt Ack Register",12,  62, NULL,    DumpGas, NULL,
     331    ValidatePccGas,      NULL },
     332  { L"Platform Interrupt Ack Preserve",8,   74, L"0x%lx", NULL,    NULL, NULL,                 NULL },
     333  { L"Platform Interrupt Ack Write",8,   82, L"0x%lx", NULL,    NULL,
     334    NULL,                NULL },
    331335};
    332336
     
    334338  An ACPI_PARSER array describing the Extended PCC Subspaces - Type 3/4
    335339*/
    336 STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
     340STATIC CONST ACPI_PARSER  PccSubspaceType3Parser[] = {
    337341  PCC_SUBSPACE_HEADER (),
    338   {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL,
    339     ValidatePlatInterrupt, NULL},
    340   {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL,
    341     (VOID**)&ExtendedPccSubspaceInterruptFlags, NULL, NULL},
    342   {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL},
    343   {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
    344   {L"Memory Range Length", 4, 16, L"0x%x", NULL, NULL, ValidateRangeLength4,
    345     NULL},
    346   {L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
    347     ValidatePccDoorbellGas, NULL},
    348   {L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
    349   {L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL},
    350   {L"Nominal Latency", 4, 48, L"%u", NULL, NULL, NULL, NULL},
    351   {L"Maximum Periodic Access Rate", 4, 52, L"%u", NULL, NULL, NULL, NULL},
    352   {L"Minimum Request Turnaround Time", 4, 56, L"%u", NULL, NULL, NULL, NULL},
    353   {L"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL,
    354     ValidatePccIntAckGas, NULL},
    355   {L"Platform Interrupt Ack Preserve", 8, 72, L"0x%lx", NULL, NULL, NULL, NULL},
    356   {L"Platform Interrupt Ack Set", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL},
    357   {L"Reserved", 8, 88, L"0x%lx", NULL, NULL, NULL, NULL},
    358   {L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL,
    359     ValidatePccGas, NULL},
    360   {L"Cmd Complete Check Mask", 8, 108, L"0x%lx", NULL, NULL, NULL, NULL},
    361   {L"Cmd Update Reg Addr", 12, 116, NULL, DumpGas, NULL,
    362     ValidatePccGas, NULL},
    363   {L"Cmd Update Preserve mask", 8, 128, L"0x%lx", NULL, NULL, NULL, NULL},
    364   {L"Cmd Update Set mask", 8, 136, L"0x%lx", NULL, NULL, NULL, NULL},
    365   {L"Error Status Register", 12, 144, NULL, DumpGas, NULL,
    366     ValidatePccErrStatusGas, NULL},
    367   {L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL, NULL, NULL},
     342  { L"Platform Interrupt",                      4,     2,   L"0x%x",  NULL,    NULL,
     343    ValidatePlatInterrupt,                      NULL },
     344  { L"Platform Interrupt Flags",                1,     6,   L"0x%x",  NULL,
     345    (VOID **)&ExtendedPccSubspaceInterruptFlags,NULL,  NULL },
     346  { L"Reserved",                                1,     7,   L"0x%x",  NULL,    NULL,NULL,                  NULL },
     347  { L"Base Address",                            8,     8,   L"0x%lx", NULL,    NULL,NULL,                  NULL },
     348  { L"Memory Range Length",                     4,     16,  L"0x%x",  NULL,    NULL,ValidateRangeLength4,
     349    NULL },
     350  { L"Doorbell Register",                       12,    20,  NULL,     DumpGas, NULL,
     351    ValidatePccDoorbellGas,                     NULL },
     352  { L"Doorbell Preserve",                       8,     32,  L"0x%lx", NULL,    NULL,NULL,                  NULL },
     353  { L"Doorbell Write",                          8,     40,  L"0x%lx", NULL,    NULL,NULL,                  NULL },
     354  { L"Nominal Latency",                         4,     48,  L"%u",    NULL,    NULL,NULL,                  NULL },
     355  { L"Maximum Periodic Access Rate",            4,     52,  L"%u",    NULL,    NULL,NULL,                  NULL },
     356  { L"Minimum Request Turnaround Time",         4,     56,  L"%u",    NULL,    NULL,NULL,                  NULL },
     357  { L"Platform Interrupt Ack Register",         12,    60,  NULL,     DumpGas, NULL,
     358    ValidatePccIntAckGas,                       NULL },
     359  { L"Platform Interrupt Ack Preserve",         8,     72,  L"0x%lx", NULL,    NULL,NULL,                  NULL },
     360  { L"Platform Interrupt Ack Set",              8,     80,  L"0x%lx", NULL,    NULL,NULL,                  NULL },
     361  { L"Reserved",                                8,     88,  L"0x%lx", NULL,    NULL,NULL,                  NULL },
     362  { L"Cmd Complete Check Reg Addr",             12,    96,  NULL,     DumpGas, NULL,
     363    ValidatePccGas,                             NULL },
     364  { L"Cmd Complete Check Mask",                 8,     108, L"0x%lx", NULL,    NULL,NULL,                  NULL },
     365  { L"Cmd Update Reg Addr",                     12,    116, NULL,     DumpGas, NULL,
     366    ValidatePccGas,                             NULL },
     367  { L"Cmd Update Preserve mask",                8,     128, L"0x%lx", NULL,    NULL,NULL,                  NULL },
     368  { L"Cmd Update Set mask",                     8,     136, L"0x%lx", NULL,    NULL,NULL,                  NULL },
     369  { L"Error Status Register",                   12,    144, NULL,     DumpGas, NULL,
     370    ValidatePccErrStatusGas,                    NULL },
     371  { L"Error Status Mask",                       8,     156, L"0x%lx", NULL,    NULL,NULL,                  NULL },
     372};
     373
     374/**
     375  An ACPI_PARSER array describing the HW Registers based Communications
     376  Subspace Structure - Type 5
     377*/
     378STATIC CONST ACPI_PARSER  PccSubspaceType5Parser[] = {
     379  PCC_SUBSPACE_HEADER (),
     380  { L"Version",            2,   2,  L"0x%x",  NULL,    NULL, NULL, NULL },
     381  { L"Base Address",       8,   4,  L"0x%lx", NULL,    NULL, NULL, NULL },
     382  { L"Shared Memory Range Length",8,   12, L"0x%lx", NULL,    NULL, NULL, NULL },
     383  { L"Doorbell Register",  12,  20, NULL,     DumpGas, NULL,
     384    ValidatePccMemoryIoGas,NULL },
     385  { L"Doorbell Preserve",  8,   32, L"0x%lx", NULL,    NULL, NULL, NULL },
     386  { L"Doorbell Write",     8,   40, L"0x%lx", NULL,    NULL, NULL, NULL },
     387  { L"Command Complete Check Register",12,  48, NULL,     DumpGas, NULL,
     388    ValidatePccMemoryIoGas,NULL },
     389  { L"Command Complete Check Mask",8,   60, L"0x%lx", NULL,    NULL, NULL, NULL },
     390  { L"Error Status Register",12,  68, NULL,     DumpGas, NULL,
     391    ValidatePccMemoryIoGas,NULL },
     392  { L"Error Status Mask",  8,   80, L"0x%lx", NULL,    NULL, NULL, NULL },
     393  { L"Nominal Latency",    4,   88, L"0x%x",  NULL,    NULL, NULL, NULL },
     394  { L"Minimum Request Turnaround Time",4,   92, L"0x%x",  NULL,    NULL, NULL, NULL }
    368395};
    369396
     
    377404VOID
    378405DumpPccSubspaceType0 (
    379   IN UINT8* Ptr,
     406  IN UINT8  *Ptr,
    380407  IN UINT8  Length
    381408  )
     
    400427VOID
    401428DumpPccSubspaceType1 (
    402   IN UINT8* Ptr,
     429  IN UINT8  *Ptr,
    403430  IN UINT8  Length
    404431  )
     
    423450VOID
    424451DumpPccSubspaceType2 (
    425   IN UINT8* Ptr,
     452  IN UINT8  *Ptr,
    426453  IN UINT8  Length
    427454  )
     
    446473VOID
    447474DumpPccSubspaceType3 (
    448   IN UINT8* Ptr,
     475  IN UINT8  *Ptr,
    449476  IN UINT8  Length
    450477  )
     
    469496VOID
    470497DumpPccSubspaceType4 (
    471   IN UINT8* Ptr,
     498  IN UINT8  *Ptr,
    472499  IN UINT8  Length
    473500  )
     
    484511
    485512/**
     513  This function parses the PCC Subspace type 5.
     514
     515  @param [in] Ptr     Pointer to the start of the Subspace Structure.
     516  @param [in] Length  Length of the Subspace Structure.
     517**/
     518STATIC
     519VOID
     520DumpPccSubspaceType5 (
     521  IN UINT8  *Ptr,
     522  IN UINT8  Length
     523  )
     524{
     525  ParseAcpi (
     526    TRUE,
     527    2,
     528    "Subspace Type 5",
     529    Ptr,
     530    Length,
     531    PARSER_PARAMS (PccSubspaceType5Parser)
     532    );
     533}
     534
     535/**
    486536  This function parses the ACPI PCCT table including its sub-structures
    487537  of type 0 through 4.
     
    499549EFIAPI
    500550ParseAcpiPcct (
    501   IN BOOLEAN Trace,
    502   IN UINT8Ptr,
    503   IN UINT32  AcpiTableLength,
    504   IN UINT8   AcpiTableRevision
    505   )
    506 {
    507   UINT32 Offset;
    508   UINT8* PccSubspacePtr;
    509   UINTN  SubspaceCount;
     551  IN BOOLEAN  Trace,
     552  IN UINT8    *Ptr,
     553  IN UINT32   AcpiTableLength,
     554  IN UINT8    AcpiTableRevision
     555  )
     556{
     557  UINT32  Offset;
     558  UINT8   *PccSubspacePtr;
     559  UINTN   SubspaceCount;
    510560
    511561  if (!Trace) {
     
    539589    // successfully read.
    540590    if ((PccSubspaceType == NULL) ||
    541         (PccSubspaceLength == NULL)) {
     591        (PccSubspaceLength == NULL))
     592    {
    542593      IncrementErrorCount ();
    543594      Print (
    544595        L"ERROR: Insufficient remaining table buffer length to read the " \
    545           L"structure header. Length = %u.\n",
     596        L"structure header. Length = %u.\n",
    546597        AcpiTableLength - Offset
    547598        );
     
    551602    // Validate Structure length
    552603    if ((*PccSubspaceLength == 0) ||
    553         ((Offset + (*PccSubspaceLength)) > AcpiTableLength)) {
     604        ((Offset + (*PccSubspaceLength)) > AcpiTableLength))
     605    {
    554606      IncrementErrorCount ();
    555607      Print (
    556608        L"ERROR: Invalid Structure length. " \
    557           L"Length = %u. Offset = %u. AcpiTableLength = %u.\n",
     609        L"Length = %u. Offset = %u. AcpiTableLength = %u.\n",
    558610        *PccSubspaceLength,
    559611        Offset,
     
    564616
    565617    switch (*PccSubspaceType) {
    566       case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_GENERIC:
     618      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_GENERIC:
    567619        DumpPccSubspaceType0 (
    568620          PccSubspacePtr,
     
    570622          );
    571623        break;
    572       case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_1_HW_REDUCED_COMMUNICATIONS:
     624      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_1_HW_REDUCED_COMMUNICATIONS:
    573625        DumpPccSubspaceType1 (
    574626          PccSubspacePtr,
     
    576628          );
    577629        break;
    578       case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_2_HW_REDUCED_COMMUNICATIONS:
     630      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_2_HW_REDUCED_COMMUNICATIONS:
    579631        DumpPccSubspaceType2 (
    580632          PccSubspacePtr,
     
    582634          );
    583635        break;
    584       case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_3_EXTENDED_PCC:
     636      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_3_EXTENDED_PCC:
    585637        DumpPccSubspaceType3 (
    586638          PccSubspacePtr,
     
    588640          );
    589641        break;
    590       case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC:
     642      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC:
    591643        DumpPccSubspaceType4 (
     644          PccSubspacePtr,
     645          *PccSubspaceLength
     646          );
     647        break;
     648      case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_5_HW_REGISTERS_COMMUNICATIONS:
     649        DumpPccSubspaceType5 (
    592650          PccSubspacePtr,
    593651          *PccSubspaceLength
     
    598656        Print (
    599657          L"ERROR: Unknown PCC subspace structure:"
    600             L" Type = %u, Length = %u\n",
     658          L" Type = %u, Length = %u\n",
    601659          PccSubspaceType,
    602660          *PccSubspaceLength
     
    605663
    606664    PccSubspacePtr += *PccSubspaceLength;
    607     Offset += *PccSubspaceLength;
     665    Offset         += *PccSubspaceLength;
    608666    SubspaceCount++;
    609667  } // while
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h

    r89983 r99404  
    1212  Minimum value for the 'length' field in subspaces of types 0, 1 and 2.
    1313*/
    14 #define MIN_MEMORY_RANGE_LENGTH                 8
     14#define MIN_MEMORY_RANGE_LENGTH  8
    1515
    1616/**
    1717  Minimum value for the 'length' field in subspaces of types 3 and 4.
    1818*/
    19 #define MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN      16
     19#define MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN  16
    2020
    2121/**
    2222  Maximum number of PCC subspaces.
    2323*/
    24 #define MAX_PCC_SUBSPACES                       256
     24#define MAX_PCC_SUBSPACES  256
    2525
    2626/**
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c

    r89983 r99404  
    22  PPTT table parser
    33
    4   Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.
     4  Copyright (c) 2019 - 2021, 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.4 Specification - January 2021
    99    - ARM Architecture Reference Manual ARMv8 (D.a)
    1010**/
     
    1818
    1919// Local variables
    20 STATIC CONST UINT8*  ProcessorTopologyStructureType;
    21 STATIC CONST UINT8*  ProcessorTopologyStructureLength;
    22 STATIC CONST UINT32* NumberOfPrivateResources;
    23 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     20STATIC CONST UINT8                                    *ProcessorTopologyStructureType;
     21STATIC CONST UINT8                                    *ProcessorTopologyStructureLength;
     22STATIC CONST UINT32                                   *NumberOfPrivateResources;
     23STATIC CONST EFI_ACPI_6_4_PPTT_STRUCTURE_CACHE_FLAGS  *CacheFlags;
     24STATIC ACPI_DESCRIPTION_HEADER_INFO                   AcpiHdrInfo;
     25
     26#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     27
     28/**
     29  Increment the error count and print an error that a required flag is missing.
     30
     31  @param [in] FlagName  Name of the missing flag.
     32**/
     33STATIC
     34VOID
     35EFIAPI
     36LogCacheFlagError (
     37  IN CONST CHAR16  *FlagName
     38  )
     39{
     40  IncrementErrorCount ();
     41  Print (
     42    L"\nERROR: On Arm based systems, all cache properties must be"
     43    L" provided in the cache type structure."
     44    L" Missing '%s' flag.",
     45    FlagName
     46    );
     47}
     48
     49#endif
     50
     51/**
     52  This function validates the Cache Type Structure (Type 1) Cache Flags field.
     53
     54  @param [in] Ptr     Pointer to the start of the field data.
     55  @param [in] Context Pointer to context specific information e.g. this
     56                      could be a pointer to the ACPI table header.
     57**/
     58STATIC
     59VOID
     60EFIAPI
     61ValidateCacheFlags (
     62  IN UINT8  *Ptr,
     63  IN VOID   *Context
     64  )
     65{
     66 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     67  CacheFlags = (EFI_ACPI_6_4_PPTT_STRUCTURE_CACHE_FLAGS *)Ptr;
     68
     69  if (CacheFlags == NULL) {
     70    IncrementErrorCount ();
     71    Print (L"\nERROR: Cache Structure Flags were not successfully read.");
     72    return;
     73  }
     74
     75  if (CacheFlags->SizePropertyValid == EFI_ACPI_6_4_PPTT_CACHE_SIZE_INVALID) {
     76    LogCacheFlagError (L"Size Property Valid");
     77  }
     78
     79  if (CacheFlags->NumberOfSetsValid == EFI_ACPI_6_4_PPTT_NUMBER_OF_SETS_INVALID) {
     80    LogCacheFlagError (L"Number Of Sets Valid");
     81  }
     82
     83  if (CacheFlags->AssociativityValid == EFI_ACPI_6_4_PPTT_ASSOCIATIVITY_INVALID) {
     84    LogCacheFlagError (L"Associativity Valid");
     85  }
     86
     87  if (CacheFlags->AllocationTypeValid == EFI_ACPI_6_4_PPTT_ALLOCATION_TYPE_INVALID) {
     88    LogCacheFlagError (L"Allocation Type Valid");
     89  }
     90
     91  if (CacheFlags->CacheTypeValid == EFI_ACPI_6_4_PPTT_CACHE_TYPE_INVALID) {
     92    LogCacheFlagError (L"Cache Type Valid");
     93  }
     94
     95  if (CacheFlags->WritePolicyValid == EFI_ACPI_6_4_PPTT_WRITE_POLICY_INVALID) {
     96    LogCacheFlagError (L"Write Policy Valid");
     97  }
     98
     99  if (CacheFlags->LineSizeValid == EFI_ACPI_6_4_PPTT_LINE_SIZE_INVALID) {
     100    LogCacheFlagError (L"Line Size Valid");
     101  }
     102
     103  // Cache ID was only introduced in revision 3
     104  if (*(AcpiHdrInfo.Revision) >= 3) {
     105    if (CacheFlags->CacheIdValid == EFI_ACPI_6_4_PPTT_CACHE_ID_INVALID) {
     106      LogCacheFlagError (L"Cache Id Valid");
     107    }
     108  }
     109
     110 #endif
     111}
    24112
    25113/**
     
    35123EFIAPI
    36124ValidateCacheNumberOfSets (
    37   IN UINT8* Ptr,
    38   IN VOID*  Context
    39   )
    40 {
    41   UINT32 NumberOfSets;
    42   NumberOfSets = *(UINT32*)Ptr;
     125  IN UINT8  *Ptr,
     126  IN VOID   *Context
     127  )
     128{
     129  UINT32  NumberOfSets;
     130
     131  NumberOfSets = *(UINT32 *)Ptr;
    43132
    44133  if (NumberOfSets == 0) {
     
    48137  }
    49138
    50 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     139 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    51140  if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) {
    52141    IncrementErrorCount ();
    53142    Print (
    54143      L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache number of "
    55         L"sets must be less than or equal to %d",
     144      L"sets must be less than or equal to %d",
    56145      PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX
    57146      );
     
    63152    Print (
    64153      L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of sets "
    65         L"must be less than or equal to %d. Ignore this message if "
    66         L"ARMv8.3-CCIDX is implemented",
     154      L"must be less than or equal to %d. Ignore this message if "
     155      L"ARMv8.3-CCIDX is implemented",
    67156      PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX
    68157      );
    69158    return;
    70159  }
    71 #endif
    72 
     160
     161 #endif
    73162}
    74163
     
    85174EFIAPI
    86175ValidateCacheAssociativity (
    87   IN UINT8* Ptr,
    88   IN VOID*  Context
    89   )
    90 {
    91   UINT8 Associativity;
    92   Associativity = *(UINT8*)Ptr;
     176  IN UINT8  *Ptr,
     177  IN VOID   *Context
     178  )
     179{
     180  UINT8  Associativity;
     181
     182  Associativity = *(UINT8 *)Ptr;
    93183
    94184  if (Associativity == 0) {
     
    110200EFIAPI
    111201ValidateCacheLineSize (
    112   IN UINT8* Ptr,
    113   IN VOIDContext
    114   )
    115 {
    116 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     202  IN UINT8  *Ptr,
     203  IN VOID   *Context
     204  )
     205{
     206 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    117207  // Reference: ARM Architecture Reference Manual ARMv8 (D.a)
    118208  // Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register
     
    120210  //     (Log2(Number of bytes in cache line)) - 4.
    121211
    122   UINT16 LineSize;
    123   LineSize = *(UINT16*)Ptr;
     212  UINT16  LineSize;
     213  LineSize = *(UINT16 *)Ptr;
    124214
    125215  if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) ||
    126       (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) {
     216      (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX))
     217  {
    127218    IncrementErrorCount ();
    128219    Print (
    129220      L"\nERROR: The cache line size must be between %d and %d bytes"
    130         L" on ARM Platforms.",
     221      L" on ARM Platforms.",
    131222      PPTT_ARM_CACHE_LINE_SIZE_MIN,
    132223      PPTT_ARM_CACHE_LINE_SIZE_MAX
     
    139230    Print (L"\nERROR: The cache line size is not a power of 2.");
    140231  }
    141 #endif
    142 }
    143 
    144 /**
    145   This function validates the Cache Type Structure (Type 1) Attributes field.
     232
     233 #endif
     234}
     235
     236/**
     237  This function validates the Cache Type Structure (Type 1) Cache ID field.
    146238
    147239  @param [in] Ptr     Pointer to the start of the field data.
     
    152244VOID
    153245EFIAPI
     246ValidateCacheId (
     247  IN UINT8  *Ptr,
     248  IN VOID   *Context
     249  )
     250{
     251  UINT32  CacheId;
     252
     253  CacheId = *(UINT32 *)Ptr;
     254
     255  // Cache ID was only introduced in revision 3
     256  if (*(AcpiHdrInfo.Revision) < 3) {
     257    return;
     258  }
     259
     260  if (CacheFlags == NULL) {
     261    IncrementErrorCount ();
     262    Print (L"\nERROR: Cache Structure Flags were not successfully read.");
     263    return;
     264  }
     265
     266  if (CacheFlags->CacheIdValid == EFI_ACPI_6_4_PPTT_CACHE_ID_VALID) {
     267    if (CacheId == 0) {
     268      IncrementErrorCount ();
     269      Print (L"\nERROR: 0 is not a valid Cache ID.");
     270      return;
     271    }
     272  }
     273}
     274
     275/**
     276  This function validates the Cache Type Structure (Type 1) Attributes field.
     277
     278  @param [in] Ptr     Pointer to the start of the field data.
     279  @param [in] Context Pointer to context specific information e.g. this
     280                      could be a pointer to the ACPI table header.
     281**/
     282STATIC
     283VOID
     284EFIAPI
    154285ValidateCacheAttributes (
    155   IN UINT8* Ptr,
    156   IN VOIDContext
     286  IN UINT8  *Ptr,
     287  IN VOID   *Context
    157288  )
    158289{
    159290  // Reference: Advanced Configuration and Power Interface (ACPI) Specification
    160   //            Version 6.2 Errata A, September 2017
    161   // Table 5-153: Cache Type Structure
    162   UINT8 Attributes;
    163   Attributes = *(UINT8*)Ptr;
     291  //            Version 6.4, January 2021
     292  // Table 5-140: Cache Type Structure
     293  UINT8  Attributes;
     294
     295  Attributes = *(UINT8 *)Ptr;
    164296
    165297  if ((Attributes & 0xE0) != 0) {
     
    176308  An ACPI_PARSER array describing the ACPI PPTT Table.
    177309**/
    178 STATIC CONST ACPI_PARSER PpttParser[] = {
     310STATIC CONST ACPI_PARSER  PpttParser[] = {
    179311  PARSE_ACPI_HEADER (&AcpiHdrInfo)
    180312};
     
    183315  An ACPI_PARSER array describing the processor topology structure header.
    184316**/
    185 STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser[] = {
    186   {L"Type", 1, 0, NULL, NULL, (VOID**)&ProcessorTopologyStructureType,
    187    NULL, NULL},
    188   {L"Length", 1, 1, NULL, NULL, (VOID**)&ProcessorTopologyStructureLength,
    189    NULL, NULL},
    190   {L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}
     317STATIC CONST ACPI_PARSER  ProcessorTopologyStructureHeaderParser[] = {
     318  { L"Type",     1, 0, NULL, NULL, (VOID **)&ProcessorTopologyStructureType,
     319    NULL, NULL },
     320  { L"Length",   1, 1, NULL, NULL, (VOID **)&ProcessorTopologyStructureLength,
     321    NULL, NULL },
     322  { L"Reserved", 2, 2, NULL, NULL, NULL,                                      NULL,NULL }
    191323};
    192324
     
    194326  An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
    195327**/
    196 STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = {
    197   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    198   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    199   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    200 
    201   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    202   {L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    203   {L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    204   {L"Number of private resources", 4, 16, L"%d", NULL,
    205    (VOID**)&NumberOfPrivateResources, NULL, NULL}
     328STATIC CONST ACPI_PARSER  ProcessorHierarchyNodeStructureParser[] = {
     329  { L"Type",                        1, 0,  L"0x%x", NULL, NULL, NULL, NULL },
     330  { L"Length",                      1, 1,  L"%d",   NULL, NULL, NULL, NULL },
     331  { L"Reserved",                    2, 2,  L"0x%x", NULL, NULL, NULL, NULL },
     332
     333  { L"Flags",                       4, 4,  L"0x%x", NULL, NULL, NULL, NULL },
     334  { L"Parent",                      4, 8,  L"0x%x", NULL, NULL, NULL, NULL },
     335  { L"ACPI Processor ID",           4, 12, L"0x%x", NULL, NULL, NULL, NULL },
     336  { L"Number of private resources", 4, 16, L"%d",  NULL,
     337    (VOID **)&NumberOfPrivateResources, NULL, NULL }
    206338};
    207339
     
    209341  An ACPI_PARSER array describing the Cache Type Structure - Type 1.
    210342**/
    211 STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
    212   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    213   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    214   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    215 
    216   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    217   {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    218   {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    219   {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL},
    220   {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL},
    221   {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
    222   {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
    223 };
    224 
    225 /**
    226   An ACPI_PARSER array describing the ID Type Structure - Type 2.
    227 **/
    228 STATIC CONST ACPI_PARSER IdStructureParser[] = {
    229   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    230   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
    231   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    232 
    233   {L"VENDOR_ID", 4, 4, NULL, Dump4Chars, NULL, NULL, NULL},
    234   {L"LEVEL_1_ID", 8, 8, L"0x%x", NULL, NULL, NULL, NULL},
    235   {L"LEVEL_2_ID", 8, 16, L"0x%x", NULL, NULL, NULL, NULL},
    236   {L"MAJOR_REV", 2, 24, L"0x%x", NULL, NULL, NULL, NULL},
    237   {L"MINOR_REV", 2, 26, L"0x%x", NULL, NULL, NULL, NULL},
    238   {L"SPIN_REV", 2, 28, L"0x%x", NULL, NULL, NULL, NULL},
     343STATIC CONST ACPI_PARSER  CacheTypeStructureParser[] = {
     344  { L"Type",                1, 0,  L"0x%x", NULL, NULL,                 NULL,                       NULL },
     345  { L"Length",              1, 1,  L"%d",   NULL, NULL,                 NULL,                       NULL },
     346  { L"Reserved",            2, 2,  L"0x%x", NULL, NULL,                 NULL,                       NULL },
     347
     348  { L"Flags",               4, 4,  L"0x%x", NULL, (VOID **)&CacheFlags, ValidateCacheFlags,
     349    NULL },
     350  { L"Next Level of Cache", 4, 8,  L"0x%x", NULL, NULL,                 NULL,                       NULL },
     351  { L"Size",                4, 12, L"0x%x", NULL, NULL,                 NULL,                       NULL },
     352  { L"Number of sets",      4, 16, L"%d",   NULL, NULL,                 ValidateCacheNumberOfSets,  NULL },
     353  { L"Associativity",       1, 20, L"%d",   NULL, NULL,                 ValidateCacheAssociativity, NULL },
     354  { L"Attributes",          1, 21, L"0x%x", NULL, NULL,                 ValidateCacheAttributes,    NULL },
     355  { L"Line size",           2, 22, L"%d",   NULL, NULL,                 ValidateCacheLineSize,      NULL },
     356  { L"Cache ID",            4, 24, L"%d",   NULL, NULL,                 ValidateCacheId,            NULL }
    239357};
    240358
     
    249367VOID
    250368DumpProcessorHierarchyNodeStructure (
    251   IN UINT8* Ptr,
     369  IN UINT8  *Ptr,
    252370  IN UINT8  Length
    253371  )
    254372{
    255   UINT32 Offset;
    256   UINT32 Index;
    257   CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
     373  UINT32  Offset;
     374  UINT32  Index;
     375  CHAR16  Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
    258376
    259377  Offset = ParseAcpi (
     
    282400    Print (
    283401      L"ERROR: Invalid Number of Private Resources. " \
    284         L"PrivateResourceCount = %d. RemainingBufferLength = %d. " \
    285         L"Parsing of this structure aborted.\n",
     402      L"PrivateResourceCount = %d. RemainingBufferLength = %d. " \
     403      L"Parsing of this structure aborted.\n",
    286404      *NumberOfPrivateResources,
    287405      Length - Offset
     
    305423    Print (
    306424      L"0x%x\n",
    307       *((UINT32*)(Ptr + Offset))
     425      *((UINT32 *)(Ptr + Offset))
    308426      );
    309427
     
    322440VOID
    323441DumpCacheTypeStructure (
    324   IN UINT8* Ptr,
     442  IN UINT8  *Ptr,
    325443  IN UINT8  Length
    326444  )
     
    337455
    338456/**
    339   This function parses the ID Structure (Type 2).
    340 
    341   @param [in] Ptr     Pointer to the start of the ID Structure data.
    342   @param [in] Length  Length of the ID Structure.
    343 **/
    344 STATIC
    345 VOID
    346 DumpIDStructure (
    347   IN UINT8* Ptr,
    348   IN UINT8 Length
    349   )
    350 {
    351   ParseAcpi (
    352     TRUE,
    353     2,
    354     "ID Structure",
    355     Ptr,
    356     Length,
    357     PARSER_PARAMS (IdStructureParser)
    358     );
    359 }
    360 
    361 /**
    362457  This function parses the ACPI PPTT table.
    363458  When trace is enabled this function parses the PPTT table and
     
    367462    - Processor hierarchy node structure (Type 0)
    368463    - Cache Type Structure (Type 1)
    369     - ID structure (Type 2)
    370464
    371465  This function also performs validation of the ACPI table fields.
     
    379473EFIAPI
    380474ParseAcpiPptt (
    381   IN BOOLEAN Trace,
    382   IN UINT8Ptr,
    383   IN UINT32  AcpiTableLength,
    384   IN UINT8   AcpiTableRevision
    385   )
    386 {
    387   UINT32 Offset;
    388   UINT8* ProcessorTopologyStructurePtr;
     475  IN BOOLEAN  Trace,
     476  IN UINT8    *Ptr,
     477  IN UINT32   AcpiTableLength,
     478  IN UINT8    AcpiTableRevision
     479  )
     480{
     481  UINT32  Offset;
     482  UINT8   *ProcessorTopologyStructurePtr;
    389483
    390484  if (!Trace) {
     
    417511    // successfully read.
    418512    if ((ProcessorTopologyStructureType == NULL) ||
    419         (ProcessorTopologyStructureLength == NULL)) {
     513        (ProcessorTopologyStructureLength == NULL))
     514    {
    420515      IncrementErrorCount ();
    421516      Print (
    422517        L"ERROR: Insufficient remaining table buffer length to read the " \
    423           L"processor topology structure header. Length = %d.\n",
     518        L"processor topology structure header. Length = %d.\n",
    424519        AcpiTableLength - Offset
    425520        );
     
    429524    // Validate Processor Topology Structure length
    430525    if ((*ProcessorTopologyStructureLength == 0) ||
    431         ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)) {
     526        ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength))
     527    {
    432528      IncrementErrorCount ();
    433529      Print (
    434530        L"ERROR: Invalid Processor Topology Structure length. " \
    435           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     531        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    436532        *ProcessorTopologyStructureLength,
    437533        Offset,
     
    445541
    446542    switch (*ProcessorTopologyStructureType) {
    447       case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR:
     543      case EFI_ACPI_6_4_PPTT_TYPE_PROCESSOR:
    448544        DumpProcessorHierarchyNodeStructure (
    449545          ProcessorTopologyStructurePtr,
     
    451547          );
    452548        break;
    453       case EFI_ACPI_6_2_PPTT_TYPE_CACHE:
     549      case EFI_ACPI_6_4_PPTT_TYPE_CACHE:
    454550        DumpCacheTypeStructure (
    455551          ProcessorTopologyStructurePtr,
     
    457553          );
    458554        break;
    459       case EFI_ACPI_6_2_PPTT_TYPE_ID:
    460         DumpIDStructure (
    461           ProcessorTopologyStructurePtr,
    462           *ProcessorTopologyStructureLength
     555      case EFI_ACPI_6_3_PPTT_TYPE_ID:
     556        IncrementErrorCount ();
     557        Print (
     558          L"ERROR: PPTT Type 2 - Processor ID has been removed and must not be"
     559          L"used.\n"
    463560          );
    464561        break;
     
    467564        Print (
    468565          L"ERROR: Unknown processor topology structure:"
    469             L" Type = %d, Length = %d\n",
     566          L" Type = %d, Length = %d\n",
    470567          *ProcessorTopologyStructureType,
    471568          *ProcessorTopologyStructureLength
     
    474571
    475572    ProcessorTopologyStructurePtr += *ProcessorTopologyStructureLength;
    476     Offset += *ProcessorTopologyStructureLength;
     573    Offset                        += *ProcessorTopologyStructureLength;
    477574  } // while
    478575}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.h

    r80721 r99404  
    1717/// ARMv8.3-CCIDX (Cache extended number of sets)
    1818/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0001
    19 #define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX       (1 << 24)
    20 #define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX        (1 << 21)
     19#define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX  (1 << 24)
     20#define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX   (1 << 21)
    2121
    2222/// Cache parameters allowed by the architecture without
    2323/// ARMv8.3-CCIDX (Cache extended number of sets)
    2424/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0000
    25 #define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX             (1 << 15)
    26 #define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX              (1 << 10)
     25#define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX  (1 << 15)
     26#define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX   (1 << 10)
    2727
    2828/// Common cache parameters
     
    3131/// (Log2(Number of bytes in cache line)) - 4 is used to represent
    3232/// the LineSize bits.
    33 #define PPTT_ARM_CACHE_LINE_SIZE_MAX                  (1 << 11)
    34 #define PPTT_ARM_CACHE_LINE_SIZE_MIN                  (1 << 4)
     33#define PPTT_ARM_CACHE_LINE_SIZE_MAX  (1 << 11)
     34#define PPTT_ARM_CACHE_LINE_SIZE_MIN  (1 << 4)
    3535
    3636#endif // if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c

    r85718 r99404  
    1414
    1515// Local Variables
    16 STATIC CONST UINT64* XsdtAddress;
     16STATIC CONST UINT64  *XsdtAddress;
    1717
    1818/**
     
    2727EFIAPI
    2828ValidateRsdtAddress (
    29   IN UINT8* Ptr,
    30   IN VOIDContext
     29  IN UINT8  *Ptr,
     30  IN VOID   *Context
    3131  )
    3232{
    33 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     33 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    3434  // Reference: Server Base Boot Requirements System Software on ARM Platforms
    3535  // Section: 4.2.1.1 RSDP
     
    3737  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
    3838  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
    39   UINT32 RsdtAddr;
     39  UINT32  RsdtAddr;
    4040
    41   RsdtAddr = *(UINT32*)Ptr;
     41  RsdtAddr = *(UINT32 *)Ptr;
    4242
    4343  if (RsdtAddr != 0) {
     
    4848      );
    4949  }
    50 #endif
     50
     51 #endif
    5152}
    5253
     
    6263EFIAPI
    6364ValidateXsdtAddress (
    64   IN UINT8* Ptr,
    65   IN VOIDContext
     65  IN UINT8  *Ptr,
     66  IN VOID   *Context
    6667  )
    6768{
    68 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     69 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    6970  // Reference: Server Base Boot Requirements System Software on ARM Platforms
    7071  // Section: 4.2.1.1 RSDP
     
    7273  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
    7374  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
    74   UINT64 XsdtAddr;
     75  UINT64  XsdtAddr;
    7576
    76   XsdtAddr = *(UINT64*)Ptr;
     77  XsdtAddr = *(UINT64 *)Ptr;
    7778
    7879  if (XsdtAddr == 0) {
     
    8384      );
    8485  }
    85 #endif
     86
     87 #endif
    8688}
    8789
     
    8991  An array describing the ACPI RSDP Table.
    9092**/
    91 STATIC CONST ACPI_PARSER RsdpParser[] = {
    92   {L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL},
    93   {L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},
    94   {L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL},
    95   {L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL},
    96   {L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL},
    97   {L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL},
    98   {L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID**)&XsdtAddress,
    99    ValidateXsdtAddress, NULL},
    100   {L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL},
    101   {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
     93STATIC CONST ACPI_PARSER  RsdpParser[] = {
     94  { L"Signature",         8, 0,  NULL,        Dump8Chars, NULL,                  NULL,                NULL },
     95  { L"Checksum",          1, 8,  L"0x%x",     NULL,       NULL,                  NULL,                NULL },
     96  { L"Oem ID",            6, 9,  NULL,        Dump6Chars, NULL,                  NULL,                NULL },
     97  { L"Revision",          1, 15, L"%d",       NULL,       NULL,                  NULL,                NULL },
     98  { L"RSDT Address",      4, 16, L"0x%x",     NULL,       NULL,                  ValidateRsdtAddress, NULL },
     99  { L"Length",            4, 20, L"%d",       NULL,       NULL,                  NULL,                NULL },
     100  { L"XSDT Address",      8, 24, L"0x%lx",    NULL,       (VOID **)&XsdtAddress,
     101    ValidateXsdtAddress, NULL },
     102  { L"Extended Checksum", 1, 32, L"0x%x",     NULL,       NULL,                  NULL,                NULL },
     103  { L"Reserved",          3, 33, L"%x %x %x", Dump3Chars, NULL,                  NULL,                NULL }
    102104};
    103105
     
    119121EFIAPI
    120122ParseAcpiRsdp (
    121   IN BOOLEAN Trace,
    122   IN UINT8Ptr,
    123   IN UINT32  AcpiTableLength,
    124   IN UINT8   AcpiTableRevision
     123  IN BOOLEAN  Trace,
     124  IN UINT8    *Ptr,
     125  IN UINT32   AcpiTableLength,
     126  IN UINT8    AcpiTableRevision
    125127  )
    126128{
     
    145147    Print (
    146148      L"ERROR: Insufficient table length. AcpiTableLength = %d." \
    147         L"RSDP parsing aborted.\n",
     149      L"RSDP parsing aborted.\n",
    148150      AcpiTableLength
    149151      );
     
    161163  }
    162164
    163   ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress));
     165  ProcessAcpiTable ((UINT8 *)(UINTN)(*XsdtAddress));
    164166}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c

    r85718 r99404  
    1616
    1717// Local Variables
    18 STATIC CONST UINT64* SlitSystemLocalityCount;
    19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     18STATIC CONST UINT64                  *SlitSystemLocalityCount;
     19STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2020
    2121/**
    2222  An ACPI_PARSER array describing the ACPI SLIT table.
    2323**/
    24 STATIC CONST ACPI_PARSER SlitParser[] = {
     24STATIC CONST ACPI_PARSER  SlitParser[] = {
    2525  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    26   {L"Number of System Localities", 8, 36, L"0x%lx", NULL,
    27    (VOID**)&SlitSystemLocalityCount, NULL, NULL}
     26  { L"Number of System Localities",   8,    36, L"0x%lx", NULL,
     27    (VOID **)&SlitSystemLocalityCount,NULL,  NULL }
    2828};
    2929
     
    3131  Macro to get the value of a System Locality
    3232**/
    33 #define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)
     33#define SLIT_ELEMENT(Ptr, i, j)  *(Ptr + (i * LocalityCount) + j)
    3434
    3535/**
     
    5151EFIAPI
    5252ParseAcpiSlit (
    53   IN BOOLEAN Trace,
    54   IN UINT8Ptr,
    55   IN UINT32  AcpiTableLength,
    56   IN UINT8   AcpiTableRevision
     53  IN BOOLEAN  Trace,
     54  IN UINT8    *Ptr,
     55  IN UINT32   AcpiTableLength,
     56  IN UINT8    AcpiTableRevision
    5757  )
    5858{
    59   UINT32 Offset;
    60   UINT32 Count;
    61   UINT32 Index;
    62   UINT32 LocalityCount;
    63   UINT8* LocalityPtr;
    64   CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi
     59  UINT32  Offset;
     60  UINT32  Count;
     61  UINT32  Index;
     62  UINT32  LocalityCount;
     63  UINT8   *LocalityPtr;
     64  CHAR16  Buffer[80]; // Used for AsciiName param of ParseAcpi
    6565
    6666  if (!Trace) {
     
    104104    Print (
    105105      L"ERROR: The Number of System Localities provided can't be represented " \
    106         L"in the SLIT table. SlitSystemLocalityCount = %ld. " \
    107         L"MaxLocalityCountAllowed = %d.\n",
     106      L"in the SLIT table. SlitSystemLocalityCount = %ld. " \
     107      L"MaxLocalityCountAllowed = %d.\n",
    108108      *SlitSystemLocalityCount,
    109109      MAX_UINT16
     
    119119    Print (
    120120      L"ERROR: Invalid Number of System Localities. " \
    121         L"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",
     121      L"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",
    122122      *SlitSystemLocalityCount,
    123123      AcpiTableLength
     
    145145      Print (L" (%3d) ", Index);
    146146    }
     147
    147148    Print (L"\n");
    148     for (Count = 0; Count< LocalityCount; Count++) {
     149    for (Count = 0; Count < LocalityCount; Count++) {
    149150      Print (L" (%3d) ", Count);
    150151      for (Index = 0; Index < LocalityCount; Index++) {
    151152        Print (L"  %3d  ", SLIT_ELEMENT (LocalityPtr, Count, Index));
    152153      }
     154
    153155      Print (L"\n");
    154156    }
     
    159161    for (Index = 0; Index < LocalityCount; Index++) {
    160162      // Element[x][x] must be equal to 10
    161       if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) {
     163      if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count, Index) != 10)) {
    162164        IncrementErrorCount ();
    163165        Print (
    164166          L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
    165             L" Normalized Value is not 10\n",
     167          L" Normalized Value is not 10\n",
    166168          Count,
    167169          Index,
     
    169171          );
    170172      }
     173
    171174      // Element[i][j] must be equal to Element[j][i]
    172175      if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
    173           SLIT_ELEMENT (LocalityPtr, Index, Count)) {
     176          SLIT_ELEMENT (LocalityPtr, Index, Count))
     177      {
    174178        IncrementErrorCount ();
    175179        Print (
    176180          L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
    177            L"Element[0x%lx][0x%lx] (%3d) do not match.\n",
     181          L"Element[0x%lx][0x%lx] (%3d) do not match.\n",
    178182          Count,
    179183          Index,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c

    r80721 r99404  
    1717
    1818// Local variables
    19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     19STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2020
    2121/**
     
    3030EFIAPI
    3131ValidateInterruptType (
    32   IN UINT8* Ptr,
    33   IN VOIDContext
     32  IN UINT8  *Ptr,
     33  IN VOID   *Context
    3434  )
    3535{
    36 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    37   UINT8 InterruptType;
     36 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     37  UINT8  InterruptType;
    3838
    3939  InterruptType = *Ptr;
    4040
    4141  if (InterruptType !=
    42         EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
     42      EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC)
     43  {
    4344    IncrementErrorCount ();
    4445    Print (
     
    4748      );
    4849  }
    49 #endif
     50
     51 #endif
    5052}
    5153
     
    6163EFIAPI
    6264ValidateIrq (
    63   IN UINT8* Ptr,
    64   IN VOIDContext
     65  IN UINT8  *Ptr,
     66  IN VOID   *Context
    6567  )
    6668{
    67 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
    68   UINT8 Irq;
     69 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     70  UINT8  Irq;
    6971
    7072  Irq = *Ptr;
     
    7779      );
    7880  }
    79 #endif
     81
     82 #endif
    8083}
    8184
     
    8386  An ACPI_PARSER array describing the ACPI SPCR Table.
    8487**/
    85 STATIC CONST ACPI_PARSER SpcrParser[] = {
     88STATIC CONST ACPI_PARSER  SpcrParser[] = {
    8689  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    87   {L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL},
    88   {L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},
    89   {L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL},
    90   {L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL},
    91   {L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL},
    92   {L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL},
    93   {L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL},
    94   {L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL},
    95   {L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL},
    96   {L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL},
    97   {L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL},
    98   {L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL},
     90  { L"Interface Type",             1,   36, L"%d",       NULL,       NULL, NULL,                  NULL },
     91  { L"Reserved",                   3,   37, L"%x %x %x", Dump3Chars, NULL, NULL,                  NULL },
     92  { L"Base Address",               12,  40, NULL,        DumpGas,    NULL, NULL,                  NULL },
     93  { L"Interrupt Type",             1,   52, L"%d",       NULL,       NULL, ValidateInterruptType, NULL },
     94  { L"IRQ",                        1,   53, L"%d",       NULL,       NULL, ValidateIrq,           NULL },
     95  { L"Global System Interrupt",    4,   54, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     96  { L"Baud Rate",                  1,   58, L"%d",       NULL,       NULL, NULL,                  NULL },
     97  { L"Parity",                     1,   59, L"%d",       NULL,       NULL, NULL,                  NULL },
     98  { L"Stop Bits",                  1,   60, L"%d",       NULL,       NULL, NULL,                  NULL },
     99  { L"Flow Control",               1,   61, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     100  { L"Terminal Type",              1,   62, L"%d",       NULL,       NULL, NULL,                  NULL },
     101  { L"Reserved",                   1,   63, L"%x",       NULL,       NULL, NULL,                  NULL },
    99102
    100   {L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL},
    101   {L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL},
    102   {L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL},
    103   {L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL},
    104   {L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL},
    105   {L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL},
    106   {L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL},
    107   {L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL}
     103  { L"PCI Device ID",              2,   64, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     104  { L"PCI Vendor ID",              2,   66, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     105  { L"PCI Bus Number",             1,   68, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     106  { L"PCI Device Number",          1,   69, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     107  { L"PCI Function Number",        1,   70, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     108  { L"PCI Flags",                  4,   71, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     109  { L"PCI Segment",                1,   75, L"0x%x",     NULL,       NULL, NULL,                  NULL },
     110  { L"Reserved",                   4,   76, L"%x",       NULL,       NULL, NULL,                  NULL }
    108111};
    109112
     
    123126EFIAPI
    124127ParseAcpiSpcr (
    125   IN BOOLEAN Trace,
    126   IN UINT8Ptr,
    127   IN UINT32  AcpiTableLength,
    128   IN UINT8   AcpiTableRevision
     128  IN BOOLEAN  Trace,
     129  IN UINT8    *Ptr,
     130  IN UINT32   AcpiTableLength,
     131  IN UINT8    AcpiTableRevision
    129132  )
    130133{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c

    r89983 r99404  
    1717
    1818// Local Variables
    19 STATIC CONST UINT8* SratRAType;
    20 STATIC CONST UINT8* SratRALength;
    21 STATIC CONST UINT8* SratDeviceHandleType;
    22 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     19STATIC CONST UINT8                   *SratRAType;
     20STATIC CONST UINT8                   *SratRALength;
     21STATIC CONST UINT8                   *SratDeviceHandleType;
     22STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    2323
    2424/**
     
    3333EFIAPI
    3434ValidateSratReserved (
    35   IN UINT8* Ptr,
    36   IN VOIDContext
     35  IN UINT8  *Ptr,
     36  IN VOID   *Context
    3737  )
    3838{
    39   if (*(UINT32*)Ptr != 1) {
     39  if (*(UINT32 *)Ptr != 1) {
    4040    IncrementErrorCount ();
    4141    Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n");
     
    5555EFIAPI
    5656ValidateSratDeviceHandleType (
    57   IN UINT8* Ptr,
    58   IN VOIDContext
     57  IN UINT8  *Ptr,
     58  IN VOID   *Context
    5959  )
    6060{
    61   UINT8   DeviceHandleType;
     61  UINT8  DeviceHandleType;
    6262
    6363  DeviceHandleType = *Ptr;
     
    8383EFIAPI
    8484DumpSratPciBdfNumber (
    85   IN CONST CHAR16* Format,
    86   IN UINT8*        Ptr
     85  IN CONST CHAR16  *Format,
     86  IN UINT8         *Ptr
    8787  )
    8888{
    89   CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
     89  CHAR16  Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
    9090
    9191  Print (L"\n");
     
    144144  An ACPI_PARSER array describing the Device Handle - ACPI
    145145**/
    146 STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = {
    147   {L"ACPI_HID", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL},
    148   {L"ACPI_UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    149   {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
     146STATIC CONST ACPI_PARSER  SratDeviceHandleAcpiParser[] = {
     147  { L"ACPI_HID", 8, 0,  L"0x%lx", NULL, NULL, NULL, NULL },
     148  { L"ACPI_UID", 4, 8,  L"0x%x",  NULL, NULL, NULL, NULL },
     149  { L"Reserved", 4, 12, L"0x%x",  NULL, NULL, NULL, NULL }
    150150};
    151151
     
    153153  An ACPI_PARSER array describing the Device Handle - PCI
    154154**/
    155 STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = {
    156   {L"PCI Segment", 2, 0, L"0x%x", NULL, NULL, NULL, NULL},
    157   {L"PCI BDF Number", 2, 2, NULL, DumpSratPciBdfNumber, NULL, NULL, NULL},
    158   {L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12Chars,
    159    NULL, NULL, NULL}
     155STATIC CONST ACPI_PARSER  SratDeviceHandlePciParser[] = {
     156  { L"PCI Segment",    2,  0, L"0x%x",                                    NULL,                 NULL, NULL, NULL },
     157  { L"PCI BDF Number", 2,  2, NULL,                                       DumpSratPciBdfNumber, NULL, NULL, NULL },
     158  { L"Reserved",      12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12Chars,
     159    NULL, NULL, NULL }
    160160};
    161161
     
    171171EFIAPI
    172172DumpSratDeviceHandle (
    173   IN CONST CHAR16* Format,
    174   IN UINT8*        Ptr
    175  )
     173  IN CONST CHAR16  *Format,
     174  IN UINT8         *Ptr
     175  )
    176176{
    177177  if (SratDeviceHandleType == NULL) {
     
    214214EFIAPI
    215215DumpSratApicProximity (
    216  IN CONST CHAR16* Format,
    217  IN UINT8*        Ptr
    218  )
     216  IN CONST CHAR16  *Format,
     217  IN UINT8         *Ptr
     218  )
    219219{
    220   UINT32 ProximityDomain;
     220  UINT32  ProximityDomain;
    221221
    222222  ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16);
     
    228228  An ACPI_PARSER array describing the SRAT Table.
    229229**/
    230 STATIC CONST ACPI_PARSER SratParser[] = {
     230STATIC CONST ACPI_PARSER  SratParser[] = {
    231231  PARSE_ACPI_HEADER (&AcpiHdrInfo),
    232   {L"Reserved", 4, 36, L"0x%x", NULL, NULL, ValidateSratReserved, NULL},
    233   {L"Reserved", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}
     232  { L"Reserved",                   4,  36, L"0x%x",  NULL, NULL, ValidateSratReserved, NULL },
     233  { L"Reserved",                   8,  40, L"0x%lx", NULL, NULL, NULL,                 NULL }
    234234};
    235235
     
    237237  An ACPI_PARSER array describing the Resource Allocation structure header.
    238238**/
    239 STATIC CONST ACPI_PARSER SratResourceAllocationParser[] = {
    240   {L"Type", 1, 0, NULL, NULL, (VOID**)&SratRAType, NULL, NULL},
    241   {L"Length", 1, 1, NULL, NULL, (VOID**)&SratRALength, NULL, NULL}
     239STATIC CONST ACPI_PARSER  SratResourceAllocationParser[] = {
     240  { L"Type",   1, 0, NULL, NULL, (VOID **)&SratRAType,   NULL, NULL },
     241  { L"Length", 1, 1, NULL, NULL, (VOID **)&SratRALength, NULL, NULL }
    242242};
    243243
     
    245245  An ACPI_PARSER array describing the GICC Affinity structure.
    246246**/
    247 STATIC CONST ACPI_PARSER SratGicCAffinityParser[] = {
    248   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    249   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    250 
    251   {L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL},
    252   {L"ACPI Processor UID", 4, 6, L"0x%x", NULL, NULL, NULL, NULL},
    253   {L"Flags", 4, 10, L"0x%x", NULL, NULL, NULL, NULL},
    254   {L"Clock Domain", 4, 14, L"0x%x", NULL, NULL, NULL, NULL}
     247STATIC CONST ACPI_PARSER  SratGicCAffinityParser[] = {
     248  { L"Type",               1, 0,  L"0x%x", NULL, NULL, NULL, NULL },
     249  { L"Length",             1, 1,  L"0x%x", NULL, NULL, NULL, NULL },
     250
     251  { L"Proximity Domain",   4, 2,  L"0x%x", NULL, NULL, NULL, NULL },
     252  { L"ACPI Processor UID", 4, 6,  L"0x%x", NULL, NULL, NULL, NULL },
     253  { L"Flags",              4, 10, L"0x%x", NULL, NULL, NULL, NULL },
     254  { L"Clock Domain",       4, 14, L"0x%x", NULL, NULL, NULL, NULL }
    255255};
    256256
     
    258258  An ACPI_PARSER array describing the GIC ITS Affinity structure.
    259259**/
    260 STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = {
    261   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    262   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    263 
    264   {L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL},
    265   {L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL},
    266   {L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
     260STATIC CONST ACPI_PARSER  SratGicITSAffinityParser[] = {
     261  { L"Type",             1, 0, L"0x%x", NULL, NULL, NULL, NULL },
     262  { L"Length",           1, 1, L"0x%x", NULL, NULL, NULL, NULL },
     263
     264  { L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL },
     265  { L"Reserved",         2, 6, L"0x%x", NULL, NULL, NULL, NULL },
     266  { L"ITS Id",           4, 8, L"0x%x", NULL, NULL, NULL, NULL },
    267267};
    268268
     
    270270  An ACPI_PARSER array describing the Generic Initiator Affinity Structure
    271271**/
    272 STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = {
    273   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    274   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    275 
    276   {L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},
    277   {L"Device Handle Type", 1, 3, L"%d", NULL, (VOID**)&SratDeviceHandleType,
    278    ValidateSratDeviceHandleType, NULL},
    279   {L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    280   {L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL, NULL},
    281   {L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    282   {L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}
     272STATIC CONST ACPI_PARSER  SratGenericInitiatorAffinityParser[] = {
     273  { L"Type",               1,  0,  L"0x%x", NULL,                 NULL,                           NULL, NULL },
     274  { L"Length",             1,  1,  L"0x%x", NULL,                 NULL,                           NULL, NULL },
     275
     276  { L"Reserved",           1,  2,  L"0x%x", NULL,                 NULL,                           NULL, NULL },
     277  { L"Device Handle Type", 1,  3,  L"%d",   NULL,                 (VOID **)&SratDeviceHandleType,
     278    ValidateSratDeviceHandleType, NULL },
     279  { L"Proximity Domain",   4,  4,  L"0x%x", NULL,                 NULL,                           NULL, NULL },
     280  { L"Device Handle",      16, 8,  L"%s",   DumpSratDeviceHandle, NULL,                           NULL, NULL },
     281  { L"Flags",              4,  24, L"0x%x", NULL,                 NULL,                           NULL, NULL },
     282  { L"Reserved",           4,  28, L"0x%x", NULL,                 NULL,                           NULL, NULL }
    283283};
    284284
     
    286286  An ACPI_PARSER array describing the Memory Affinity structure.
    287287**/
    288 STATIC CONST ACPI_PARSER SratMemAffinityParser[] = {
    289   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    290   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    291 
    292   {L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL},
    293   {L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL},
    294   {L"Base Address Low", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    295   {L"Base Address High", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    296   {L"Length Low", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    297   {L"Length High", 4, 20, L"0x%x", NULL, NULL, NULL, NULL},
    298   {L"Reserved", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
    299   {L"Flags", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
    300   {L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}
     288STATIC CONST ACPI_PARSER  SratMemAffinityParser[] = {
     289  { L"Type",              1, 0,  L"0x%x",  NULL, NULL, NULL, NULL },
     290  { L"Length",            1, 1,  L"0x%x",  NULL, NULL, NULL, NULL },
     291
     292  { L"Proximity Domain",  4, 2,  L"0x%x",  NULL, NULL, NULL, NULL },
     293  { L"Reserved",          2, 6,  L"0x%x",  NULL, NULL, NULL, NULL },
     294  { L"Base Address Low",  4, 8,  L"0x%x",  NULL, NULL, NULL, NULL },
     295  { L"Base Address High", 4, 12, L"0x%x",  NULL, NULL, NULL, NULL },
     296  { L"Length Low",        4, 16, L"0x%x",  NULL, NULL, NULL, NULL },
     297  { L"Length High",       4, 20, L"0x%x",  NULL, NULL, NULL, NULL },
     298  { L"Reserved",          4, 24, L"0x%x",  NULL, NULL, NULL, NULL },
     299  { L"Flags",             4, 28, L"0x%x",  NULL, NULL, NULL, NULL },
     300  { L"Reserved",          8, 32, L"0x%lx", NULL, NULL, NULL, NULL }
    301301};
    302302
     
    304304  An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
    305305**/
    306 STATIC CONST ACPI_PARSER SratApciSapicAffinityParser[] = {
    307   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    308   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    309 
    310   {L"Proximity Domain [7:0]", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},
    311   {L"APIC ID", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
    312   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    313   {L"Local SAPIC EID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},
    314   {L"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity,
    315    NULL, NULL, NULL},
    316   {L"Clock Domain", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
     306STATIC CONST ACPI_PARSER  SratApciSapicAffinityParser[] = {
     307  { L"Type",                    1, 0,  L"0x%x", NULL,                  NULL, NULL, NULL },
     308  { L"Length",                  1, 1,  L"0x%x", NULL,                  NULL, NULL, NULL },
     309
     310  { L"Proximity Domain [7:0]",  1, 2,  L"0x%x", NULL,                  NULL, NULL, NULL },
     311  { L"APIC ID",                 1, 3,  L"0x%x", NULL,                  NULL, NULL, NULL },
     312  { L"Flags",                   4, 4,  L"0x%x", NULL,                  NULL, NULL, NULL },
     313  { L"Local SAPIC EID",         1, 8,  L"0x%x", NULL,                  NULL, NULL, NULL },
     314  { L"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity,
     315    NULL, NULL, NULL },
     316  { L"Clock Domain",            4, 12, L"0x%x", NULL,                  NULL, NULL, NULL }
    317317};
    318318
     
    320320  An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure.
    321321**/
    322 STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
    323   {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
    324   {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
    325 
    326   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
    327   {L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
    328   {L"X2APIC ID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
    329   {L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
    330   {L"Clock Domain", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
    331   {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}
     322STATIC CONST ACPI_PARSER  SratX2ApciAffinityParser[] = {
     323  { L"Type",             1, 0,  L"0x%x", NULL, NULL, NULL, NULL },
     324  { L"Length",           1, 1,  L"0x%x", NULL, NULL, NULL, NULL },
     325
     326  { L"Reserved",         2, 2,  L"0x%x", NULL, NULL, NULL, NULL },
     327  { L"Proximity Domain", 4, 4,  L"0x%x", NULL, NULL, NULL, NULL },
     328  { L"X2APIC ID",        4, 8,  L"0x%x", NULL, NULL, NULL, NULL },
     329  { L"Flags",            4, 12, L"0x%x", NULL, NULL, NULL, NULL },
     330  { L"Clock Domain",     4, 16, L"0x%x", NULL, NULL, NULL, NULL },
     331  { L"Reserved",         4, 20, L"0x%x", NULL, NULL, NULL, NULL }
    332332};
    333333
     
    353353EFIAPI
    354354ParseAcpiSrat (
    355   IN BOOLEAN Trace,
    356   IN UINT8Ptr,
    357   IN UINT32  AcpiTableLength,
    358   IN UINT8   AcpiTableRevision
     355  IN BOOLEAN  Trace,
     356  IN UINT8    *Ptr,
     357  IN UINT32   AcpiTableLength,
     358  IN UINT8    AcpiTableRevision
    359359  )
    360360{
    361   UINT32 Offset;
    362   UINT8* ResourcePtr;
    363   UINT32 GicCAffinityIndex;
    364   UINT32 GicITSAffinityIndex;
    365   UINT32 GenericInitiatorAffinityIndex;
    366   UINT32 MemoryAffinityIndex;
    367   UINT32 ApicSapicAffinityIndex;
    368   UINT32 X2ApicAffinityIndex;
    369   CHAR8  Buffer[80]; // Used for AsciiName param of ParseAcpi
    370 
    371   GicCAffinityIndex = 0;
    372   GicITSAffinityIndex = 0;
     361  UINT32  Offset;
     362  UINT8   *ResourcePtr;
     363  UINT32  GicCAffinityIndex;
     364  UINT32  GicITSAffinityIndex;
     365  UINT32  GenericInitiatorAffinityIndex;
     366  UINT32  MemoryAffinityIndex;
     367  UINT32  ApicSapicAffinityIndex;
     368  UINT32  X2ApicAffinityIndex;
     369  CHAR8   Buffer[80]; // Used for AsciiName param of ParseAcpi
     370
     371  GicCAffinityIndex             = 0;
     372  GicITSAffinityIndex           = 0;
    373373  GenericInitiatorAffinityIndex = 0;
    374   MemoryAffinityIndex = 0;
    375   ApicSapicAffinityIndex = 0;
    376   X2ApicAffinityIndex = 0;
     374  MemoryAffinityIndex           = 0;
     375  ApicSapicAffinityIndex        = 0;
     376  X2ApicAffinityIndex           = 0;
    377377
    378378  if (!Trace) {
     
    404404    // successfully read.
    405405    if ((SratRAType == NULL) ||
    406         (SratRALength == NULL)) {
     406        (SratRALength == NULL))
     407    {
    407408      IncrementErrorCount ();
    408409      Print (
    409410        L"ERROR: Insufficient remaining table buffer length to read the " \
    410           L"Static Resource Allocation structure header. Length = %d.\n",
     411        L"Static Resource Allocation structure header. Length = %d.\n",
    411412        AcpiTableLength - Offset
    412413        );
     
    416417    // Validate Static Resource Allocation Structure length
    417418    if ((*SratRALength == 0) ||
    418         ((Offset + (*SratRALength)) > AcpiTableLength)) {
     419        ((Offset + (*SratRALength)) > AcpiTableLength))
     420    {
    419421      IncrementErrorCount ();
    420422      Print (
    421423        L"ERROR: Invalid Static Resource Allocation Structure length. " \
    422           L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
     424        L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
    423425        *SratRALength,
    424426        Offset,
     
    452454          "GIC ITS Affinity Structure [%d]",
    453455          GicITSAffinityIndex++
    454         );
     456          );
    455457        ParseAcpi (
    456458          TRUE,
     
    469471          "Generic Initiator Affinity Structure [%d]",
    470472          GenericInitiatorAffinityIndex++
    471         );
     473          );
    472474        ParseAcpi (
    473475          TRUE,
     
    477479          *SratRALength,
    478480          PARSER_PARAMS (SratGenericInitiatorAffinityParser)
    479         );
     481          );
    480482        break;
    481483
     
    538540
    539541    ResourcePtr += (*SratRALength);
    540     Offset += (*SratRALength);
     542    Offset      += (*SratRALength);
    541543  }
    542544}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c

    r80721 r99404  
    2929EFIAPI
    3030ParseAcpiSsdt (
    31   IN BOOLEAN Trace,
    32   IN UINT8Ptr,
    33   IN UINT32  AcpiTableLength,
    34   IN UINT8   AcpiTableRevision
     31  IN BOOLEAN  Trace,
     32  IN UINT8    *Ptr,
     33  IN UINT32   AcpiTableLength,
     34  IN UINT8    AcpiTableRevision
    3535  )
    3636{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c

    r80721 r99404  
    1616
    1717// Local variables
    18 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
     18STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
    1919
    2020/** An ACPI_PARSER array describing the ACPI XSDT table.
    2121*/
    22 STATIC CONST ACPI_PARSER XsdtParser[] = {
     22STATIC CONST ACPI_PARSER  XsdtParser[] = {
    2323  PARSE_ACPI_HEADER (&AcpiHdrInfo)
    2424};
     
    3131GetAcpiXsdtHeaderInfo (
    3232  VOID
    33 )
     33  )
    3434{
    3535  return &AcpiHdrInfo;
     
    4949EFIAPI
    5050ParseAcpiXsdt (
    51   IN BOOLEAN Trace,
    52   IN UINT8Ptr,
    53   IN UINT32  AcpiTableLength,
    54   IN UINT8   AcpiTableRevision
     51  IN BOOLEAN  Trace,
     52  IN UINT8    *Ptr,
     53  IN UINT32   AcpiTableLength,
     54  IN UINT8    AcpiTableRevision
    5555  )
    5656{
    57   UINT32        Offset;
    58   UINT32        TableOffset;
    59   UINT64*       TablePointer;
    60   UINTN         EntryIndex;
    61   CHAR16        Buffer[32];
     57  UINT32  Offset;
     58  UINT32  TableOffset;
     59  UINT64  *TablePointer;
     60  UINTN   EntryIndex;
     61  CHAR16  Buffer[32];
    6262
    6363  Offset = ParseAcpi (
     
    7373
    7474  if (Trace) {
    75     EntryIndex = 0;
    76     TablePointer = (UINT64*)(Ptr + TableOffset);
     75    EntryIndex   = 0;
     76    TablePointer = (UINT64 *)(Ptr + TableOffset);
    7777    while (Offset < AcpiTableLength) {
    78       CONST UINT32* Signature;
    79       CONST UINT32* Length;
    80       CONST UINT8Revision;
     78      CONST UINT32  *Signature;
     79      CONST UINT32  *Length;
     80      CONST UINT8   *Revision;
    8181
    82       if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
    83         UINT8*      SignaturePtr;
     82      if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
     83        UINT8  *SignaturePtr;
    8484
    8585        ParseAcpiHeader (
    86           (UINT8*)(UINTN)(*TablePointer),
     86          (UINT8 *)(UINTN)(*TablePointer),
    8787          &Signature,
    8888          &Length,
     
    9090          );
    9191
    92         SignaturePtr = (UINT8*)Signature;
     92        SignaturePtr = (UINT8 *)Signature;
    9393
    9494        UnicodeSPrint (
     
    115115
    116116      // Validate the table pointers are not NULL
    117       if ((UINT64*)(UINTN)(*TablePointer) == NULL) {
     117      if ((UINT64 *)(UINTN)(*TablePointer) == NULL) {
    118118        IncrementErrorCount ();
    119119        Print (
     
    123123          );
    124124      }
     125
    125126      Offset += sizeof (UINT64);
    126127      TablePointer++;
     
    129130
    130131  // Process the tables
    131   Offset = TableOffset;
    132   TablePointer = (UINT64*)(Ptr + TableOffset);
     132  Offset       = TableOffset;
     133  TablePointer = (UINT64 *)(Ptr + TableOffset);
    133134  while (Offset < AcpiTableLength) {
    134     if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
    135       ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer));
     135    if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
     136      ProcessAcpiTable ((UINT8 *)(UINTN)(*TablePointer));
    136137    }
     138
    137139    Offset += sizeof (UINT64);
    138140    TablePointer++;
Note: See TracChangeset for help on using the changeset viewer.

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