]> xenbits.xensource.com Git - people/aperard/ovmf.git/commitdiff
ShellPkg/AcpiView: RAS2 Parser
authorCarsten Haitzler <carsten.haitzler@foss.arm.com>
Thu, 29 Aug 2024 14:06:08 +0000 (15:06 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 12 Sep 2024 08:51:25 +0000 (08:51 +0000)
Add a new parser for the RAS2 Table as specified in ACPI6.5

Signed-off-by: Carsten Haitzler <carsten.haitzler@foss.arm.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c [new file with mode: 0644]
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf

index 6427ea7d8a5d4ec1cc5238f16414fc317016f244..32816242fc23eeba406460af8485e575251e8953 100644 (file)
@@ -1006,6 +1006,29 @@ ParseAcpiPptt (
   IN UINT8    AcpiTableRevision\r
   );\r
 \r
+/**\r
+  This function parses the ACPI RAS2 table.\r
+  When trace is enabled this function parses the RAS2 table and\r
+  traces the ACPI table fields.\r
+\r
+  This function parses the RAS2 ACPI table along with PCC Entries\r
+\r
+  This function also performs validation of the ACPI table fields.\r
+\r
+  @param [in] Trace              If TRUE, trace the ACPI fields.\r
+  @param [in] Ptr                Pointer to the start of the buffer.\r
+  @param [in] AcpiTableLength    Length of the ACPI table.\r
+  @param [in] AcpiTableRevision  Revision of the ACPI table.\r
+**/\r
+VOID\r
+EFIAPI\r
+ParseAcpiRas2 (\r
+  IN BOOLEAN  Trace,\r
+  IN UINT8    *Ptr,\r
+  IN UINT32   AcpiTableLength,\r
+  IN UINT8    AcpiTableRevision\r
+  );\r
+\r
 /**\r
   This function parses the ACPI RSDP table.\r
 \r
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c
new file mode 100644 (file)
index 0000000..9c61b96
--- /dev/null
@@ -0,0 +1,118 @@
+/** @file\r
+  RAS2 table parser\r
+\r
+  Copyright (c) 2024, Arm Limited. All rights reserved.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+  @par Reference(s):\r
+    - ACPI 6.5 Specification - August 2022\r
+**/\r
+\r
+#include <Library/PrintLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include "AcpiParser.h"\r
+#include "AcpiView.h"\r
+\r
+// Maximum Memory Domain matrix print size.\r
+#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX  10\r
+\r
+// Local variables\r
+STATIC CONST UINT16  *Ras2PccDescriptors;\r
+\r
+STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;\r
+\r
+/**\r
+  An ACPI_PARSER array describing the ACPI RAS2 Table.\r
+*/\r
+STATIC CONST ACPI_PARSER  Ras2Parser[] = {\r
+  PARSE_ACPI_HEADER (&AcpiHdrInfo),\r
+  { L"Reserved",                   2,  36, L"0x%x", NULL, NULL,                         NULL, NULL },\r
+  { L"PCC Descriptors",            2,  38, L"%d",   NULL, (VOID **)&Ras2PccDescriptors, NULL, NULL }\r
+};\r
+\r
+/**\r
+  An ACPI_PARSER array describing the RAS2 PCC ID Entry\r
+*/\r
+STATIC CONST ACPI_PARSER  Ras2StructurePccDescriptor[] = {\r
+  { L"PCC ID",       1, 0, L"0x%x", NULL, NULL, NULL, NULL },\r
+  { L"Reserved",     1, 1, L"0x%x", NULL, NULL, NULL, NULL },\r
+  { L"Reserved",     1, 2, L"0x%x", NULL, NULL, NULL, NULL },\r
+  { L"Feature Type", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },\r
+  { L"Instance",     4, 4, L"0x%x", NULL, NULL, NULL, NULL }\r
+};\r
+\r
+STATIC\r
+VOID\r
+DumpPccEntry (\r
+  IN UINT8   *Ptr,\r
+  IN UINT32  Length\r
+  )\r
+{\r
+  ParseAcpi (\r
+    TRUE,\r
+    2,\r
+    "PCC Descriptor Entry",\r
+    Ptr,\r
+    Length,\r
+    PARSER_PARAMS (Ras2StructurePccDescriptor)\r
+    );\r
+}\r
+\r
+/**\r
+  This function parses the ACPI RAS2 table.\r
+  When trace is enabled this function parses the RAS2 table and\r
+  traces the ACPI table fields.\r
+\r
+  This function parses the following RAS2 structures:\r
+    - Pcc Instries\r
+    - Entry Pcc ID\r
+    - Entry Feature Type\r
+    - Entry Pcc Instance\r
+\r
+  This function also performs validation of the ACPI table fields.\r
+\r
+  @param [in] Trace              If TRUE, trace the ACPI fields.\r
+  @param [in] Ptr                Pointer to the start of the buffer.\r
+  @param [in] AcpiTableLength    Length of the ACPI table.\r
+  @param [in] AcpiTableRevision  Revision of the ACPI table.\r
+**/\r
+VOID\r
+EFIAPI\r
+ParseAcpiRas2 (\r
+  IN BOOLEAN  Trace,\r
+  IN UINT8    *Ptr,\r
+  IN UINT32   AcpiTableLength,\r
+  IN UINT8    AcpiTableRevision\r
+  )\r
+{\r
+  UINT32  Offset;\r
+\r
+  if (!Trace) {\r
+    return;\r
+  }\r
+\r
+  // Parse ACPI Header + RAS2 "fixed" fields\r
+  Offset = ParseAcpi (\r
+             Trace,\r
+             0,\r
+             "RAS2",\r
+             Ptr,\r
+             AcpiTableLength,\r
+             PARSER_PARAMS (Ras2Parser)\r
+             );\r
+\r
+  // Table is too small to contain data\r
+  if (Offset >= AcpiTableLength) {\r
+    return;\r
+  }\r
+\r
+  // Loop over rest of table for PCC Entries and dump them\r
+  while (Offset <= (AcpiTableLength - sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR))) {\r
+    DumpPccEntry (\r
+      Ptr + Offset,\r
+      sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR)\r
+      );\r
+    Offset += sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR);\r
+  } // while\r
+}\r
index 4f4254ac40d54eda3db2529114f2a4d9ebb1387e..5e73a39095433473ad1e73531e76f437edc7f04b 100644 (file)
@@ -71,6 +71,7 @@ ACPI_TABLE_PARSER  ParserList[] = {
     ParseAcpiPcct },\r
   { EFI_ACPI_6_4_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,\r
     ParseAcpiPptt },\r
+  { EFI_ACPI_6_5_ACPI_RAS2_FEATURE_TABLE_SIGNATURE,                                                      ParseAcpiRas2 },\r
   { RSDP_TABLE_INFO,                                                                                     ParseAcpiRsdp },\r
   { EFI_ACPI_6_2_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE,                                            ParseAcpiSlit },\r
   { EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,                                        ParseAcpiSpcr },\r
index 54dddd0ee26d5ad558b44b0ea8cc11554d8ed445..7ef8b0afb7b2f6337293877555257e559a0c66ea 100644 (file)
@@ -50,6 +50,7 @@
   Parsers/Pcct/PcctParser.h\r
   Parsers/Pptt/PpttParser.c\r
   Parsers/Pptt/PpttParser.h\r
+  Parsers/Ras2/Ras2Parser.c\r
   Parsers/Rsdp/RsdpParser.c\r
   Parsers/Slit/SlitParser.c\r
   Parsers/Spcr/SpcrParser.c\r