]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation
authorKrzysztof Koch <krzysztof.koch@arm.com>
Mon, 22 Jul 2019 22:50:26 +0000 (15:50 -0700)
committerJaben Carsey <jaben.carsey@intel.com>
Wed, 31 Jul 2019 16:53:00 +0000 (09:53 -0700)
Move Performance Monitoring Counter Group (PMCG) node ID mapping count
validation from the core IORT acpiview parser logic to a dedicated
function. Now, the pointer to the validation function is passed to the
IortNodePmcgParser[] ACPI_PARSER array.

This check does not affect the flow of IORT parsing and is limited to
a single table field in scope, therefore, it is better to keep it away
from the code responsible for traversing the table.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c

index 0461205b4f8bc02aa11ab1db1d0deb73bce053b7..7c850b3813d5204775e2cc247cabf42358b25769 100644 (file)
@@ -53,6 +53,28 @@ ValidateItsIdMappingCount (
   }\r
 }\r
 \r
+/**\r
+  This function validates the ID Mapping array count for the Performance\r
+  Monitoring Counter Group (PMCG) node.\r
+\r
+  @param [in] Ptr     Pointer to the start of the field data.\r
+  @param [in] Context Pointer to context specific information e.g. this\r
+                      could be a pointer to the ACPI table header.\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+ValidatePmcgIdMappingCount (\r
+  IN UINT8* Ptr,\r
+  IN VOID*  Context\r
+  )\r
+{\r
+  if (*(UINT32*)Ptr > 1) {\r
+    IncrementErrorCount ();\r
+    Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");\r
+  }\r
+}\r
+\r
 /**\r
   This function validates the ID Mapping array offset for the ITS node.\r
 \r
@@ -216,7 +238,7 @@ STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
   An ACPI_PARSER array describing the IORT PMCG node.\r
 **/\r
 STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {\r
-  PARSE_IORT_NODE_HEADER (NULL, NULL),\r
+  PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL),\r
   {L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},\r
   {L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},\r
   {L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},\r
@@ -537,14 +559,6 @@ DumpIortNodePmcg (
   if (*IortIdMappingCount != 0) {\r
     DumpIortNodeIdMappings (Ptr, MappingCount, MappingOffset);\r
   }\r
-\r
-  if (*IortIdMappingCount > 1) {\r
-    IncrementErrorCount ();\r
-    Print (\r
-      L"ERROR: ID mapping must not be greater than 1. Id Mapping Count =%d\n",\r
-      *IortIdMappingCount\r
-      );\r
-  }\r
 }\r
 \r
 /**\r