public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tomas Pilar (tpilar)" <tomas@nuviainc.com>
To: devel@edk2.groups.io
Cc: Sami Mujawar <Sami.Mujawar@arm.com>,
	Alexei Fedorov <Alexei.Fedorov@arm.com>
Subject: [PATCH 6/8] DynamicTablesPkg/TableHelperLib: User friendly strings
Date: Fri, 31 Jul 2020 17:19:24 +0100	[thread overview]
Message-ID: <20200731161926.341330-7-tomas@nuviainc.com> (raw)
In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com>

Add user friendly strings for CmObjectIds to TableHelperLib
and add debug print invocations to common helper methods.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Signed-off-by: Tomas Pilar <tomas@nuviainc.com>
---
 .../ConfigurationManagerDumpApp.c             | 13 +--
 .../ConfigurationManagerDumpApp.h             |  8 --
 .../ConfigurationManagerDumpApp.inf           |  3 +-
 .../ConfigurationObjectStrings.c              | 50 ----------
 .../Include/Library/TableHelperLib.h          | 12 +++
 .../ConfigurationObjectStrings.c              | 92 +++++++++++++++++++
 .../Common/TableHelperLib/TableHelperLib.inf  |  1 +
 7 files changed, 109 insertions(+), 70 deletions(-)
 delete mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
 delete mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
 create mode 100644 DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c

diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
index 15936c78c1..20977c1b82 100644
--- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
+++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
@@ -1,10 +1,9 @@
 #include <Uefi.h>
 #include <Library/UefiLib.h>
 #include <Library/UefiBootServicesTableLib.h>
+#include <Library/TableHelperLib.h>
 #include <Protocol/ConfigurationManagerProtocol.h>
 
-#include "ConfigurationManagerDumpApp.h"
-
 EDKII_CONFIGURATION_MANAGER_PROTOCOL *mCfgMgr;
 
 EFI_STATUS
@@ -33,10 +32,7 @@ UefiMain(
       continue;
     }
 
-    Print (
-      L"<%s>::<%s>\n",
-      ObjectNameSpaceString[EObjNameSpaceStandard],
-      StdObjectString[ObjectId - EObjNameSpaceStandard]);
+    Print (L"<%s>\n", CmObjectIdName (ObjectId));
 
     Print (
       L"Id=%x Size=0x%x at=%p count=%d\n",
@@ -54,10 +50,7 @@ UefiMain(
       continue;
     }
 
-    Print (
-      L"<%s>::<%s>\n",
-      ObjectNameSpaceString[EObjNameSpaceArm],
-      ArmObjectString[ObjectId - EObjNameSpaceArm]);
+    Print (L"<%s>\n", CmObjectIdName(ObjectId));
 
     Print (
       L"Id=%x Size=0x%x at=%p count=%d\n",
diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
deleted file mode 100644
index 5017d55b4a..0000000000
--- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CONFIGURATION_MANAGER_DUMP_APP_H_
-#define CONFIGURATION_MANAGER_DUMP_APP_H_
-
-extern CHAR16 *ArmObjectString[];
-extern CHAR16 *ObjectNameSpaceString[];
-extern CHAR16 *StdObjectString[];
-
-#endif
diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
index 9f8beb916d..f930ca3dcb 100644
--- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
+++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
@@ -23,8 +23,6 @@
 
 [Sources]
   ConfigurationManagerDumpApp.c
-  ConfigurationManagerDumpApp.h
-  ConfigurationObjectStrings.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -32,6 +30,7 @@
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  TableHelperLib
   UefiLib
   UefiBootServicesTableLib
   UefiApplicationEntryPoint
diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
deleted file mode 100644
index ad8dbb6354..0000000000
--- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
+++ /dev/null
@@ -1,50 +0,0 @@
-
-CHAR16 *ArmObjectString[] = {
-  L"Reserved",
-  L"Boot Architecture Info",
-  L"CPU Info",
-  L"Power Management Profile Info",
-  L"GIC CPU Interface Info",
-  L"GIC Distributor Info",
-  L"GIC MSI Frame Info",
-  L"GIC Redistributor Info",
-  L"GIC ITS Info",
-  L"Serial Console Port Info",
-  L"Serial Debug Port Info",
-  L"Generic Timer Info",
-  L"Platform GT Block Info",
-  L"Generic Timer Block Frame Info",
-  L"Platform Generic Watchdog",
-  L"PCI Configuration Space Info",
-  L"Hypervisor Vendor Id",
-  L"Fixed feature flags for FADT",
-  L"ITS Group",
-  L"Named Component",
-  L"Root Complex",
-  L"SMMUv1 or SMMUv2",
-  L"SMMUv3",
-  L"PMCG",
-  L"GIC ITS Identifier Array",
-  L"ID Mapping Array",
-  L"SMMU Interrupt Array",
-  L"Processor Hierarchy Info",
-  L"Cache Info",
-  L"Processor Node ID Info",
-  L"CM Object Reference",
-  L"Memory Affinity Info",
-  L"Device Handle Acpi",
-  L"Device Handle Pci",
-  L"Generic Initiator Affinity"
-};
-
-CHAR16 *ObjectNameSpaceString[] = {
-  L"Standard Objects Namespace",
-  L"ARM Objects Namespace",
-  L"OEM Objects Namespace"
-};
-
-CHAR16 *StdObjectString[] = {
-  L"Configuration Manager Info",
-  L"ACPI table Info List",
-  L"SMBIOS table Info List"
-};
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTablesPkg/Include/Library/TableHelperLib.h
index 0d3d1bbd60..9269e77377 100644
--- a/DynamicTablesPkg/Include/Library/TableHelperLib.h
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -24,6 +24,18 @@ UINTN
 EFIAPI
 GetNewToken();
 
+/**
+  Returns the user friendly name for the given ObjectId.
+
+  @param[in]  CmObjectId   The id of the configuration manager object
+  @return                  User friendly name for object id.
+**/
+const CHAR16*
+EFIAPI
+CmObjectIdName(
+  IN CONST CM_OBJECT_ID            CmObjectrId
+  );
+
 /**
   Return the count of objects of a given ObjectId.
 
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c
new file mode 100644
index 0000000000..e4c0e77633
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c
@@ -0,0 +1,92 @@
+/** @file
+  ConfigurationObjectStrings.c
+
+  Copyright (c) 2020, ARM Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <ConfigurationManagerObject.h>
+
+const CHAR16 *ArmObjectString[] = {
+  L"Reserved",
+  L"Boot Architecture Info",
+  L"CPU Info",
+  L"Power Management Profile Info",
+  L"GIC CPU Interface Info",
+  L"GIC Distributor Info",
+  L"GIC MSI Frame Info",
+  L"GIC Redistributor Info",
+  L"GIC ITS Info",
+  L"Serial Console Port Info",
+  L"Serial Debug Port Info",
+  L"Generic Timer Info",
+  L"Platform GT Block Info",
+  L"Generic Timer Block Frame Info",
+  L"Platform Generic Watchdog",
+  L"PCI Configuration Space Info",
+  L"Hypervisor Vendor Id",
+  L"Fixed feature flags for FADT",
+  L"ITS Group",
+  L"Named Component",
+  L"Root Complex",
+  L"SMMUv1 or SMMUv2",
+  L"SMMUv3",
+  L"PMCG",
+  L"GIC ITS Identifier Array",
+  L"ID Mapping Array",
+  L"SMMU Interrupt Array",
+  L"Processor Hierarchy Info",
+  L"Cache Info",
+  L"Processor Node ID Info",
+  L"CM Object Reference",
+  L"Memory Affinity Info",
+  L"Device Handle Acpi",
+  L"Device Handle Pci",
+  L"Generic Initiator Affinity"
+};
+
+const CHAR16 *ObjectNameSpaceString[] = {
+  L"Standard Objects Namespace",
+  L"ARM Objects Namespace",
+  L"OEM Objects Namespace"
+};
+
+const CHAR16 *StdObjectString[] = {
+  L"Configuration Manager Info",
+  L"ACPI table Info List",
+  L"SMBIOS table Info List"
+};
+
+const CHAR16* UnknownObject = L"Unknown Object";
+
+/**
+  Returns the user friendly name for the given ObjectId.
+
+  @param[in]  CmObjectId   The id of the configuration manager object
+  @return                  User friendly name for object id.
+**/
+const CHAR16*
+EFIAPI
+CmObjectIdName(
+  IN CONST CM_OBJECT_ID            CmObjectId
+  )
+{
+  switch (GET_CM_NAMESPACE_ID(CmObjectId)) {
+    case EObjNameSpaceStandard:
+      if (CmObjectId < EStdObjMax) {
+        return StdObjectString[CmObjectId - EObjNameSpaceStandard];
+      } else {
+        return UnknownObject;
+      }
+    case EObjNameSpaceArm:
+      if (CmObjectId < EArmObjMax) {
+        return ArmObjectString[CmObjectId - EObjNameSpaceArm];
+      } else {
+        return UnknownObject;
+      }
+    default:
+      return UnknownObject;
+  }
+
+  return UnknownObject;
+}
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
index e12380073e..0fbc1fe5b2 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
@@ -16,6 +16,7 @@
 
 [Sources]
   TableHelper.c
+  ConfigurationObjectStrings.c
 
 [Packages]
   MdePkg/MdePkg.dec
-- 
2.25.1


  parent reply	other threads:[~2020-07-31 16:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 16:19 [PATCH 0/8] ConfigurationManagerProtocol update Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 1/8] DynamicTablesPkg: Include BaseStackCheckLib Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 2/8] DynamicTablesPkg: Fold Namespaces into CmObjectId Enums Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 3/8] DynamicTablesPkg: Add ConfigurationManagerDumpApp Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 4/8] DynamicTablesPkg: Update ConfigurationManagerProtocol Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 5/8] DynamicTablesPkg: Add CfgMgrProtocol helper functions Tomas Pilar (tpilar)
2020-07-31 16:19 ` Tomas Pilar (tpilar) [this message]
2020-07-31 16:19 ` [PATCH 7/8] DynamicTablesPkg: Simplify AddAcpiHeader, CfgMgrGetInfo Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 8/8] DynamicTablesPkg: Remove GET_OBJECT_LIST Tomas Pilar (tpilar)

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=20200731161926.341330-7-tomas@nuviainc.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