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 v3 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c
Date: Mon,  1 Apr 2024 08:45:16 -0500	[thread overview]
Message-ID: <20240401134518.743481-2-Sam.Kaynor@arm.com> (raw)
In-Reply-To: <20240401134518.743481-1-Sam.Kaynor@arm.com>

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

Implemented the dumping of the UEFI RT Properties Table using Dmem.c

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

Notes:
    v3:
    - fixed build errors
    - properly using Address variable

 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c                         | 59 ++++++++++++++++++++
 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 22 +++++++-
 2 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
index a609971f345e..65e92562ccd5 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
@@ -84,8 +84,60 @@ DisplayMmioMemory (
   return (ShellStatus);
 }
 
+/**
+  Display the RtPropertiesTable entries
+
+  @param[in] Address    The pointer to the RtPropertiesTable.
+**/
+SHELL_STATUS
+DisplayRtProperties (
+  IN UINT64 Address
+  )
+{
+  EFI_RT_PROPERTIES_TABLE *RtPropertiesTable;
+  UINT32                  RtServices;
+  SHELL_STATUS            ShellStatus;
+  EFI_STATUS              Status;
+
+  ShellStatus = SHELL_SUCCESS;
+
+  RtPropertiesTable = (EFI_RT_PROPERTIES_TABLE *)Address;
+
+  RtServices = (UINT32)RtPropertiesTable->RuntimeServicesSupported;
+  Status = ShellPrintHiiEx (
+    -1,
+    -1,
+    NULL,
+    STRING_TOKEN (STR_DMEM_RT_PROPERTIES),
+    gShellDebug1HiiHandle,
+    EFI_RT_PROPERTIES_TABLE_VERSION,
+    (RtServices & EFI_RT_SUPPORTED_GET_TIME) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_SET_TIME) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_GET_WAKEUP_TIME) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_SET_WAKEUP_TIME) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_GET_VARIABLE) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_SET_VARIABLE) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_CONVERT_POINTER) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_RESET_SYSTEM) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_UPDATE_CAPSULE) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES) ? 1 : 0,
+    (RtServices & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO) ? 1 : 0
+    );
+
+  if (EFI_ERROR (Status)) {
+    ShellStatus = SHELL_ABORTED;
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"RtPropertiesTable");
+  }
+
+  return (ShellStatus);
+}
+
 STATIC CONST SHELL_PARAM_ITEM  ParamList[] = {
   { L"-mmio", TypeFlag },
+  { L"-verbose", TypeFlag },
   { NULL,     TypeMax  }
 };
 
@@ -308,6 +360,13 @@ ShellCommandRunDmem (
             ConformanceProfileTableAddress
             );
         }
+
+        if (ShellCommandLineGetFlag (Package, L"-verbose")) {
+          if (ShellStatus == SHELL_SUCCESS) {
+            ShellStatus = DisplayRtProperties (RtPropertiesTableAddress);
+          }
+        }
+
       } else {
         ShellStatus = DisplayMmioMemory (Address, (UINTN)Size);
       }
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
index 4041f0cd483e..299b0ba44f31 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
@@ -126,8 +126,26 @@
                                                   "Memory Range Capsule          %016LX\r\n"
                                                   "Hii Database Export Buffer    %016LX\r\n"
                                                   "Conformance Profile Table     %016LX\r\n"
-
-
+#string STR_DMEM_RT_PROPERTIES    #language en-US "\r\nRT Properties Table\r\n"
+                                                  "----------------------------------------\r\n"
+                                                  "Version           0x%01LX\r\n"
+                                                  "Runtime Services Supported:\r\n"
+                                                  "  GET_TIME                         %d\r\n"
+                                                  "  GET_WAKEUP_TIME                  %d\r\n"
+                                                  "  SET_TIME                         %d\r\n"
+                                                  "  SET_WAKEUP_TIME                  %d\r\n"
+                                                  "  GET_VARIABLE                     %d\r\n"
+                                                  "  GET_NEXT_VARIABLE_NAME           %d\r\n"
+                                                  "  SET_VARIABLE                     %d\r\n"
+                                                  "  SET_VIRTUAL_ADDRESS_MAP          %d\r\n"
+                                                  "  CONVERT_POINTERS                 %d\r\n"
+                                                  "  GET_NEXT_HIGH_MONOTONIC_COUNT    %d\r\n"
+                                                  "  RESET_SYSTEM                     %d\r\n"
+                                                  "  UPDATE_CAPSULE                   %d\r\n"
+                                                  "  QUERY_CAPSULE_CAPABILITIES       %d\r\n"
+                                                  "  QUERY_VARIABLE_INFO              %d\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"
 
 #string STR_LOAD_PCI_ROM_RES      #language en-US "Image '%B%s%N' load result: %r\r\n"
 #string STR_LOADPCIROM_CORRUPT    #language en-US "%H%s%N: File '%B%s%N' Image %d is corrupt.\r\n"
-- 
2.34.1


  reply	other threads:[~2024-04-01 13:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 13:45 [edk2-devel] [PATCH v3 0/3] Adding support for verbose UEFI Table dumping to Dmem.c Sam Kaynor
2024-04-01 13:45 ` Sam Kaynor [this message]
2024-04-01 22:42   ` [edk2-devel] [PATCH v3 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Stuart Yoder
2024-04-01 13:45 ` [edk2-devel] [PATCH v3 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor
2024-04-01 13:45 ` [edk2-devel] [PATCH v3 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles " Sam Kaynor

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=20240401134518.743481-2-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