public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sam Kaynor" <sam.kaynor@arm.com>
To: devel@edk2.groups.io
Cc: Ray Ni <ray.ni@intel.com>, Zhichao Gao <zhichao.gao@intel.com>
Subject: [edk2-devel] [PATCH v7 5/5] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles in Dmem.c
Date: Wed,  1 May 2024 09:58:29 -0500	[thread overview]
Message-ID: <20240501145829.202293-6-Sam.Kaynor@arm.com> (raw)
In-Reply-To: <20240501145829.202293-1-Sam.Kaynor@arm.com>

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 patches

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com>
Tested-by: Stuart Yoder <stuart.yoder@arm.com>
Reviewed-by: Stuart Yoder <stuart.yoder@arm.com>
---

Notes:
    v7:
    - Added output for EBBR 2.2 Guid
    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 |  4 ++
 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c                         | 73 ++++++++++++++++++++
 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni |  5 ++
 3 files changed, 82 insertions(+)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
index 3741dac5d94c..140e9dc64418 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
@@ -139,3 +139,7 @@ [Guids]
   gEfiJsonConfigDataTableGuid     ## SOMETIMES_CONSUMES ## SystemTable
   gEfiJsonCapsuleDataTableGuid    ## SOMETIMES_CONSUMES ## SystemTable
   gEfiJsonCapsuleResultTableGuid  ## SOMETIMES_CONSUMES ## SystemTable
+  gEfiConfProfilesTableGuid       ## SOMETIMES_CONSUMES ## SystemTable
+  gEfiConfProfilesUefiSpecGuid    ## SOMETIMES_CONSUMES ## GUID
+  gEfiConfProfilesEbbrSpec21Guid  ## SOMETIMES_CONSUMES ## GUID
+  gEfiConfProfilesEbbrSpec22Guid  ## SOMETIMES_CONSUMES ## GUID
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
index a4f404c1cdbd..f3c01d141118 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,71 @@ 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, &gEfiConfProfilesEbbrSpec21Guid)) {
+        GuidName = L"EBBR_2.1";
+      }
+
+      if (CompareGuid (EntryGuid, &gEfiConfProfilesEbbrSpec22Guid)) {
+        GuidName = L"EBBR_2.2";
+      }
+
+      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 +526,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 +574,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


  parent reply	other threads:[~2024-05-01 14:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 14:58 [edk2-devel] [PATCH v7 0/5] Adding support for veborse UEFI Table dumping to Dmem.c Sam Kaynor
2024-05-01 14:58 ` [edk2-devel] [PATCH v7 1/5] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor
2024-05-01 14:58 ` [edk2-devel] [PATCH v7 2/5] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor
2024-05-01 14:58 ` [edk2-devel] [PATCH v7 3/5] MdePkg: Adding support for EFI_CONFORMANCE_PROFILE_TABLE Sam Kaynor
2024-05-01 14:58 ` [edk2-devel] [PATCH v7 4/5] MdePkg: Adding EBBR EFI_CONFORMANCE_PROFILE_TABLE GUIDs Sam Kaynor
2024-05-01 14:58 ` Sam Kaynor [this message]
2024-05-06  2:48 ` [edk2-devel] 回复: [PATCH v7 0/5] Adding support for veborse UEFI Table dumping to Dmem.c gaoliming via groups.io
2024-05-09 20:51   ` [edk2-devel] " Sam Kaynor
2024-05-10  0:47     ` 回复: " gaoliming via groups.io

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=20240501145829.202293-6-Sam.Kaynor@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