REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352

Implemented dumping of the UEFI Conformance Profiles Table using Dmem.c
Uses header file for GUIDs added in previous patch

Cc: Ray Ni <ray...@intel.com>
Cc: Zhichao Gao <zhichao....@intel.com>
Signed-off-by: Sam Kaynor <sam.kay...@arm.com>
---

Notes:
    v6:
    - Moved MdePkg changes to separate patch
    v5:
    - corrected style error (spaces before '(')
    v3:
    - fixed build errors
    - properly using Address variable
    - removed unecessary comment in header file

 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf |  
3 +
 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c                         | 
69 ++++++++++++++++++++
 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni |  
5 ++
 3 files changed, 77 insertions(+)

diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
index 3741dac5d94c..172ac2862ba1 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
@@ -139,3 +139,6 @@ [Guids]
   gEfiJsonConfigDataTableGuid     ## SOMETIMES_CONSUMES ## SystemTable
   gEfiJsonCapsuleDataTableGuid    ## SOMETIMES_CONSUMES ## SystemTable
   gEfiJsonCapsuleResultTableGuid  ## SOMETIMES_CONSUMES ## SystemTable
+  gEfiConfProfilesTableGuid       ## SOMETIMES_CONSUMES ## SystemTable
+  gEfiConfProfilesUefiSpecGuid    ## SOMETIMES_CONSUMES ## GUID
+  gEfiConfProfilesEbbrSpecGuid    ## SOMETIMES_CONSUMES ## GUID
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
index a4f404c1cdbd..53ee2b01f918 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
@@ -19,6 +19,7 @@
 #include <Guid/SystemResourceTable.h>
 #include <Guid/DebugImageInfoTable.h>
 #include <Guid/ImageAuthentication.h>
+#include <Guid/ConformanceProfiles.h>
 
 /**
   Make a printable character.
@@ -269,7 +270,67 @@ DisplayImageExecutionEntries (
   return (ShellStatus);
 }
 
+/**
+  Display the ConformanceProfileTable entries
 
+  @param[in] Address    The pointer to the ConformanceProfileTable.
+**/
+SHELL_STATUS
+DisplayConformanceProfiles (
+  IN UINT64 Address
+  )
+{
+  SHELL_STATUS    ShellStatus;
+  EFI_STATUS      Status;
+  EFI_GUID        *EntryGuid;
+  CHAR16          *GuidName;
+  EFI_CONFORMANCE_PROFILES_TABLE            *ConfProfTable;
+
+  ShellStatus = SHELL_SUCCESS;
+
+  if (Address != 0) {
+    ConfProfTable = (EFI_CONFORMANCE_PROFILES_TABLE *)Address;
+
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), 
gShellDebug1HiiHandle);
+
+    EntryGuid = (EFI_GUID *) (ConfProfTable + 1);
+
+    for (int Profile = 0; Profile < ConfProfTable->NumberOfProfiles; 
Profile++, EntryGuid++) {
+      GuidName = L"Unknown_Profile";
+
+      if (CompareGuid (EntryGuid, &gEfiConfProfilesEbbrSpecGuid)) {
+        GuidName = L"EBBR_2.1";
+      }
+
+      Status = ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_DMEM_CONF_PRO_ROW),
+        gShellDebug1HiiHandle,
+        GuidName,
+        EntryGuid
+        );
+    }
+    if (EFI_ERROR (Status)) {
+      ShellStatus = SHELL_ABORTED;
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), 
gShellDebug1HiiHandle, L"ComformanceProfilesTable");
+    }
+  } else {
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), 
gShellDebug1HiiHandle);
+    ShellPrintHiiEx (
+      -1,
+      -1,
+      NULL,
+      STRING_TOKEN (STR_DMEM_CONF_PRO_ROW),
+      gShellDebug1HiiHandle,
+      L"EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID",
+      &gEfiConfProfilesUefiSpecGuid
+      );
+  }
+
+  return (ShellStatus);
+}
 
 STATIC CONST SHELL_PARAM_ITEM  ParamList[] = {
   { L"-mmio", TypeFlag },
@@ -461,6 +522,11 @@ ShellCommandRunDmem (
               HiiDatabaseExportBufferAddress = (UINT64) 
(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
               continue;
             }
+
+            if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, 
&gEfiConfProfilesTableGuid)) {
+              ConformanceProfileTableAddress = (UINT64) 
(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
+              continue;
+            }
           }
 
           ShellPrintHiiEx (
@@ -504,6 +570,9 @@ ShellCommandRunDmem (
           if (ShellStatus == SHELL_SUCCESS) {
             ShellStatus = DisplayImageExecutionEntries 
(ImageExecutionTableAddress);
           }
+          if (ShellStatus == SHELL_SUCCESS) {
+            ShellStatus = DisplayConformanceProfiles 
(ConformanceProfileTableAddress);
+          }
         }
 
       } else {
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
index 3b730164ddce..6ef923e4fd5e 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
@@ -147,6 +147,11 @@
 #string STR_DMEM_IMG_EXE_TABLE    #language en-US "\r\nImage Execution 
Table\r\n"
                                                   
"----------------------------------------\r\n"
 #string STR_DMEM_IMG_EXE_ENTRY    #language en-US "%20s: %s\r\n"
+#string STR_DMEM_CONF_PRO_TABLE   #language en-US "\r\nConformance Profile 
Table\r\n"
+                                                  
"----------------------------------------\r\n"
+                                                  "Version     0x1\r\n"
+                                                  "Profile GUIDs:\r\n"
+#string STR_DMEM_CONF_PRO_ROW     #language en-US "    %s    %g\r\n"
 #string STR_DMEM_ERR_NOT_FOUND    #language en-US "\r\n%H%s%N: Table address 
not found.\r\n"
 #string STR_DMEM_ERR_GET_FAIL     #language en-US "\r\n%H%s%N: Unable to get 
table information.\r\n"
 
-- 
2.34.1

Reply via email to