public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Krzysztof Koch" <krzysztof.koch@arm.com>
To: <devel@edk2.groups.io>
Cc: <jaben.carsey@intel.com>, <ray.ni@intel.com>,
	<zhichao.gao@intel.com>, <Sami.Mujawar@arm.com>,
	<Matteo.Carlini@arm.com>, <nd@arm.com>
Subject: [PATCH v1 6/6] ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation
Date: Thu, 18 Jul 2019 13:31:42 +0100	[thread overview]
Message-ID: <20190718123142.5696-7-krzysztof.koch@arm.com> (raw)
In-Reply-To: <20190718123142.5696-1-krzysztof.koch@arm.com>

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>
---

Notes:
    v1:
    - refactor PMCG node mapping count validation [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 32 ++++++++++++++------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index 93f78e1a9786ed53f6b5529f478b72a220b4f8df..4d29ca2818804fb472bec0f632a87cd3c8a7cd48 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -47,6 +47,28 @@ ValidateItsIdMappingCount (
   IN VOID*  Context
   );
 
+/**
+  This function validates the ID Mapping array count for the Performance
+  Monitoring Counter Group (PMCG) node.
+
+  @param [in] Ptr     Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+                      could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidatePmcgIdMappingCount (
+  IN UINT8* Ptr,
+  IN VOID*  Context
+  )
+{
+  if (*(UINT32*)Ptr > 1) {
+    IncrementErrorCount ();
+    Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");
+  }
+}
+
 /**
   This function validates the ID Mapping array offset for the ITS node.
 
@@ -204,7 +226,7 @@ STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
   An ACPI_PARSER array describing the IORT PMCG node.
 **/
 STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
-  PARSE_IORT_NODE_HEADER (NULL, NULL),
+  PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL),
   {L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
   {L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
@@ -567,14 +589,6 @@ DumpIortNodePmcg (
   if (*IortIdMappingCount != 0) {
     DumpIortNodeIdMappings (Ptr, MappingCount, MappingOffset);
   }
-
-  if (*IortIdMappingCount > 1) {
-    IncrementErrorCount ();
-    Print (
-      L"ERROR: ID mapping must not be greater than 1. Id Mapping Count =%d\n",
-      *IortIdMappingCount
-      );
-  }
 }
 
 /**
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



  parent reply	other threads:[~2019-07-18 12:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 12:31 [PATCH v1 0/6] Acpiview table parsers code style enhancements and refactoring Krzysztof Koch
2019-07-18 12:31 ` [PATCH v1 1/6] ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct() Krzysztof Koch
2019-07-18 15:32   ` [edk2-devel] " Alexei Fedorov
2019-07-19  1:14   ` Gao, Zhichao
     [not found]     ` <VE1PR08MB47831B4BE6619A6C85953A6E84CB0@VE1PR08MB4783.eurprd08.prod.outlook.com>
     [not found]       ` <3CE959C139B4C44DBEA1810E3AA6F9000B808FFA@SHSMSX101.ccr.corp.intel.com>
2019-07-19 10:40         ` Krzysztof Koch
2019-07-22  0:38           ` Gao, Zhichao
2019-07-18 12:31 ` [PATCH v1 2/6] ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() call Krzysztof Koch
2019-07-18 15:31   ` [edk2-devel] " Alexei Fedorov
2019-07-18 12:31 ` [PATCH v1 3/6] ShellPkg: acpiview: RSDP: Make code consistent with other parsers Krzysztof Koch
2019-07-18 15:31   ` [edk2-devel] " Alexei Fedorov
2019-07-18 12:31 ` [PATCH v1 4/6] ShellPkg: acpiview: SRAT: Minor code style enhancements Krzysztof Koch
2019-07-18 15:31   ` [edk2-devel] " Alexei Fedorov
2019-07-18 12:31 ` [PATCH v1 5/6] ShellPkg: acpiview: MADT: Split structure length validation Krzysztof Koch
2019-07-18 15:31   ` [edk2-devel] " Alexei Fedorov
2019-07-18 12:31 ` Krzysztof Koch [this message]
2019-07-18 15:30   ` [edk2-devel] [PATCH v1 6/6] ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation Alexei Fedorov
2019-07-18 12:58 ` [PATCH v1 0/6] Acpiview table parsers code style enhancements and refactoring Sami Mujawar
2019-07-18 14:48 ` [edk2-devel] " Carsey, Jaben
2019-07-19  1:09 ` Gao, Zhichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190718123142.5696-7-krzysztof.koch@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox