[edk2-devel] [PATCH v1 3/5] ShellPkg: add a Graph option to the Parser Flags

Joey Gouly joey.gouly at arm.com
Fri May 7 10:38:02 UTC 2021


From: Marc Moisson-Franckhauser <marc.moisson-franckhauser at arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This option informs the parser to generate a dot graph of a table.
This can be useful to understand or debug a table, such as the PPTT
table.

Signed-off-by: Marc Moisson-Franckhauser <marc.moisson-franckhauser at arm.com>
Signed-off-by: Joey Gouly <joey.gouly at arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h                    |  2 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h                |  3 ++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      |  9 +++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 24 +++++++++++++++++---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni |  9 ++++++--
 5 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index b078c0b99335ba28f7589cac6b0a4190d9a6c3b5..9a67fe084327434bf21b37b3089779468edfb0f1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -20,11 +20,13 @@
   Flags for the parser.
 */
 #define PARSE_FLAGS_TRACE               BIT0
+#define PARSE_FLAGS_GRAPH               BIT1
 
 /**
   Helper macros to test parser flags.
 */
 #define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+#define IS_GRAPH_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_GRAPH) != 0)
 
 /**
   This function increments the ACPI table error counter.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
index 2db4a65415d8f9e70686cb2cc432862ab4e4c2dd..262302a15cbbe04a228fd55e523930fb76bcf6a8 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for 'acpiview' configuration.
 
-  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -106,6 +106,7 @@ typedef enum {
   ReportSelected,     ///< Report Selected table.
   ReportTableList,    ///< Report List of tables.
   ReportDumpBinFile,  ///< Dump selected table to a file.
+  ReportDotGraph,     ///< Create Dot Graph for selected compatible table.
   ReportMax,
 } EREPORT_OPTION;
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index db7b2e2a30525cc85a333b93f5eb97ec3a517b37..1155b2f3f411247c866f635fb666dd76455f18a4 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -192,6 +192,12 @@ ProcessTableReportOptions (
         DumpAcpiTableToFile (TablePtr, Length);
       }
       break;
+    case ReportDotGraph:
+      if (Signature == SelectedTable->Type) {
+        SelectedTable->Found = TRUE;
+        ParseFlags |= PARSE_FLAGS_GRAPH;
+      }
+      break;
     case ReportMax:
       // We should never be here.
       // This case is only present to prevent compiler warning.
@@ -340,7 +346,8 @@ AcpiView (
 
   ReportOption = GetReportOption ();
   if (ReportTableList != ReportOption) {
-    if (((ReportSelected == ReportOption)  ||
+    if (((ReportSelected == ReportOption) ||
+         (ReportDotGraph == ReportOption) ||
          (ReportDumpBinFile == ReportOption)) &&
         (!SelectedTable->Found)) {
       Print (L"\nRequested ACPI Table not found.\n");
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index b30ed3fc8597b229dd15b6ad4f2aab2e3d0ca583..d837b390938f3c3bc5cb90c1161e2feeb1ed6a6b 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,7 +1,7 @@
 /** @file
   Main file for 'acpiview' Shell command function.
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -34,6 +34,7 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-q", TypeFlag},
   {L"-d", TypeFlag},
+  {L"-g", TypeFlag},
   {L"-h", TypeFlag},
   {L"-l", TypeFlag},
   {L"-s", TypeValue},
@@ -293,6 +294,18 @@ ShellCommandRunAcpiView (
           L"-d"
           );
         ShellStatus = SHELL_INVALID_PARAMETER;
+    } else if (ShellCommandLineGetFlag (Package, L"-g") &&
+               !ShellCommandLineGetFlag (Package, L"-s")) {
+        ShellPrintHiiEx (
+          -1,
+          -1,
+          NULL,
+          STRING_TOKEN (STR_GEN_MISSING_OPTION),
+          gShellAcpiViewHiiHandle,
+          L"acpiview",
+          L"-s",
+          L"-g"
+          );
     } else {
       // Turn on colour highlighting if requested
       SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
@@ -316,10 +329,15 @@ ShellCommandRunAcpiView (
           SelectAcpiTable (SelectedTableName);
           SetReportOption (ReportSelected);
 
-          if (ShellCommandLineGetFlag (Package, L"-d"))  {
+          if (ShellCommandLineGetFlag (Package, L"-d") ||
+              ShellCommandLineGetFlag (Package, L"-g"))  {
             // Create a temporary file to check if the media is writable.
             CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
-            SetReportOption (ReportDumpBinFile);
+            if (ShellCommandLineGetFlag (Package, L"-d")) {
+              SetReportOption (ReportDumpBinFile);
+            } else {
+              SetReportOption (ReportDotGraph);
+            }
 
             UnicodeSPrint (
               FileNameBuffer,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
index 393110e0ee98d54b3be0309c2d297a121c258570..51f2bea10f7b768e5e67f930237207193cba4246 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
@@ -1,6 +1,6 @@
 // /**
 //
-// Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+// Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 // Module Name:
@@ -30,7 +30,7 @@
 "Display ACPI Table information.\r\n"
 ".SH SYNOPSIS\r\n"
 " \r\n"
-"ACPIVIEW [[-?] | [[[[-l] | [-s AcpiTable [-d]]] [-q] [-h]] [-r Spec]]]\r\n"
+"ACPIVIEW [[-?] | [[[[-l] | [-s AcpiTable [-d] [-g]]] [-q] [-h]] [-r Spec]]]\r\n"
 " \r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
@@ -39,6 +39,7 @@
 "       invocation option.\r\n"
 "         AcpiTable    : The required ACPI Table type.\r\n"
 "  -d - Generate a binary file dump of the specified AcpiTable.\r\n"
+"  -g - Generate a dot graph of the specified AcpiTable.\r\n"
 "  -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
 "  -h - Enable colour highlighting.\r\n"
 "  -r - Validate that all required ACPI tables are installed\r\n"
@@ -123,6 +124,10 @@
 "    in the current working directory:\r\n"
 "    fs0:\> acpiview -s DSDT -d\r\n"
 " \r\n"
+"  * To save a dot graph in the current working directory\r\n"
+"    representing the processor architecture described in the PPTT table:\r\n"
+"    fs0:\> acpiview -s PPTT -g\r\n"
+" \r\n"
 "  * To display contents of all ACPI tables:\r\n"
 "    fs0:\> acpiview\r\n"
 " \r\n"
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74810): https://edk2.groups.io/g/devel/message/74810
Mute This Topic: https://groups.io/mt/82651825/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list