]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/AcpiView: APMT Parser
authorJeff Brasen <jbrasen@nvidia.com>
Fri, 4 Nov 2022 16:04:48 +0000 (10:04 -0600)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 13 Dec 2022 16:50:27 +0000 (16:50 +0000)
Add a new parser for the Arm Performance Monitoring Unit Table.
The APMT table describes the properties of PMU support
implemented by components in an Arm-based system.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c [new file with mode: 0644]
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni

index db8c88f6dfa435bb0a929c1e6fc4311a8c5e4c2b..6a1de4e12b098fa904ede25acab5b6da4f55712d 100644 (file)
@@ -531,6 +531,27 @@ ParseAcpiAest (
   IN UINT8    AcpiTableRevision\r
   );\r
 \r
+/**\r
+  This function parses the ACPI APMT table.\r
+  When trace is enabled this function parses the APMT table and\r
+  traces the ACPI table fields.\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
+ParseAcpiApmt (\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 BGRT table.\r
   When trace is enabled this function parses the BGRT table and\r
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c
new file mode 100644 (file)
index 0000000..ad64adb
--- /dev/null
@@ -0,0 +1,106 @@
+/** @file\r
+  APMT table parser\r
+\r
+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.\r
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+  @par Reference(s):\r
+    - ACPI 6.2 Specification - Errata A, September 2017\r
+**/\r
+\r
+#include <IndustryStandard/Acpi.h>\r
+#include <IndustryStandard/ArmPerformanceMonitoringUnitTable.h>\r
+#include <Library/UefiLib.h>\r
+#include "AcpiParser.h"\r
+#include "AcpiTableParser.h"\r
+\r
+// Local variables\r
+STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;\r
+STATIC CONST UINT16                  *NodeLength;\r
+\r
+/**\r
+  An ACPI_PARSER array describing the ACPI APMT Table.\r
+**/\r
+STATIC CONST ACPI_PARSER  ApmtParser[] = {\r
+  PARSE_ACPI_HEADER (&AcpiHdrInfo)\r
+};\r
+\r
+/**\r
+  An ACPI_PARSER array describing the ACPI Arm PMU Node.\r
+**/\r
+STATIC CONST ACPI_PARSER  ArmPmuNodeParser[] = {\r
+  { L"Length",                   2, 0,  L"0x%x",  NULL, (VOID **)&NodeLength, NULL, NULL },\r
+  { L"Node flags",               1, 2,  L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Node type",                1, 3,  L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Identifier",               4, 4,  L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Node Instance primary",    8, 8,  L"0x%lx", NULL, NULL,                 NULL, NULL },\r
+  { L"Node Instance secondary",  4, 16, L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Base address 0",           8, 20, L"0x%lx", NULL, NULL,                 NULL, NULL },\r
+  { L"Base address 1",           8, 28, L"0x%lx", NULL, NULL,                 NULL, NULL },\r
+  { L"Overflow interrupt",       4, 36, L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Reserved1",                4, 40, L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Overflow interrupt flags", 4, 44, L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Processor affinity",       4, 48, L"0x%x",  NULL, NULL,                 NULL, NULL },\r
+  { L"Implementation ID",        4, 52, L"0x%x",  NULL, NULL,                 NULL, NULL }\r
+};\r
+\r
+/**\r
+  This function parses the ACPI APMT table.\r
+  When trace is enabled this function parses the APMT table and\r
+  traces the ACPI table fields.\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
+ParseAcpiApmt (\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
+  ParseAcpi (\r
+    Trace,\r
+    0,\r
+    "APMT",\r
+    Ptr,\r
+    AcpiTableLength,\r
+    PARSER_PARAMS (ApmtParser)\r
+    );\r
+  Offset = sizeof (EFI_ACPI_DESCRIPTION_HEADER);\r
+\r
+  while (Offset < AcpiTableLength) {\r
+    ParseAcpi (\r
+      Trace,\r
+      2,\r
+      "Arm PMU node",\r
+      Ptr + Offset,\r
+      (AcpiTableLength - Offset),\r
+      PARSER_PARAMS (ArmPmuNodeParser)\r
+      );\r
+    if (NodeLength == NULL) {\r
+      Print (\r
+        L"ERROR: Insufficient remaining table buffer length to read the " \\r
+        L"Node structure. Length = %d.\n",\r
+        (AcpiTableLength - Offset)\r
+        );\r
+      IncrementErrorCount ();\r
+      break;\r
+    }\r
+\r
+    Offset += *NodeLength;\r
+  }\r
+}\r
index 09bdddb56e5bd70dec44bdbdcba88373f93daa66..53f06fc7571977628bf9823ff401801fa970f185 100644 (file)
@@ -48,6 +48,7 @@ STATIC
 CONST\r
 ACPI_TABLE_PARSER  ParserList[] = {\r
   { EFI_ACPI_6_3_ARM_ERROR_SOURCE_TABLE_SIGNATURE,                                                       ParseAcpiAest },\r
+  { EFI_ACPI_6_4_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_SIGNATURE,                                        ParseAcpiApmt },\r
   { EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE,                                                 ParseAcpiBgrt },\r
   { EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE,                                                           ParseAcpiDbg2 },\r
   { EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,\r
index 63fc5a1281a894841dac704484c3d4f9481edb46..b03ec1a31b5d9df5be553041d6f398e14b5862ce 100644 (file)
@@ -28,6 +28,7 @@
   AcpiViewConfig.c\r
   AcpiViewConfig.h\r
   Parsers/Aest/AestParser.c\r
+  Parsers/Apmt/ApmtParser.c\r
   Parsers/Bgrt/BgrtParser.c\r
   Parsers/Dbg2/Dbg2Parser.c\r
   Parsers/Dsdt/DsdtParser.c\r
index 393110e0ee98d54b3be0309c2d297a121c258570..e4a9dd5b4021cdea48c214d4f3db9dc8c5d6e103 100644 (file)
@@ -80,6 +80,7 @@
 "     Extra A. Particular types:\r\n"\r
 "       AEST  - Arm Error Source Table\r\n"\r
 "       APIC  - Multiple APIC Description Table (MADT)\r\n"\r
+"       APMT  - Arm Performance Monitoring Unit Table\r\n"\r
 "       BGRT  - Boot Graphics Resource Table\r\n"\r
 "       DBG2  - Debug Port Table 2\r\n"\r
 "       DSDT  - Differentiated System Description Table\r\n"\r