public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Standalone AcpiView Application
@ 2020-05-21 18:44 Tomas Pilar (tpilar)
  2020-05-21 18:44 ` [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

This patchset adds a new application module to the 
ShellPkg with the functionality of the 'acpiview' command.

The existing code is tidied and a clean boundary between
the UEFI shell command wrapper and the acpiview functionality
is created. Then, a new application wrapper is added.

The motivation for a standalone AcpiView application lies
in the desire to test implementation of the Acpi tables on 
a wide selection of platforms, particularly platforms still
in development, platforms that might have an older implementation
of the UEFI shell or platforms that might not include the 'acpiview'
command in the internal build of the UEFI shell. Furthermore,
this application can then be integrated in larger firmware
testing frameworks.

---

v2: Patch formatting

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>

Tomas Pilar (6):
  ShellPkg/AcpiView: Move log reset to main method
  ShellPkg/AcpiView: Refactor configuration
  ShellPkg/AcpiView: Move table count reset
  ShellPkg/AcpiView: Move parameter parsing
  ShellPkg/AcpiView: Refactor DumpAcpiTableToFile
  ShellPkg/AcpiView: Add application wrapper

 ShellPkg/Application/AcpiViewApp/AcpiViewApp.c                               | 189 ++++++++++++++++++++++++++++
 ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf                             |  31 +++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c                    |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c               |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      | 469 +++++-----------------------------------------------------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                      | 113 +++--------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c                | 246 +++++++++++++++++++++++++++++++++++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h                | 177 +++++++++++++++++++++++++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 276 ++++++++++++++++++++++++++++++++++++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h   |  27 +++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf |  32 ++---
 ShellPkg/ShellPkg.dsc                                                        |   6 +-
 17 files changed, 1017 insertions(+), 556 deletions(-)
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h

-- 
2.24.1.windows.2



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:40   ` Gao, Zhichao
  2020-05-21 18:44 ` [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

The error and warning counters are reset in the AcpiView main method.
This improves reusability of the main method.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 84ffb3595750..f1a95b7b8f03 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -424,6 +424,10 @@ AcpiView (
   EfiConfigurationTable = NULL;
   OriginalAttribute = 0;
 
+  // Reset The error/warning counters
+  ResetErrorCount ();
+  ResetWarningCount ();
+
   // Search the table for an entry that matches the ACPI Table Guid
   FoundAcpiTable = FALSE;
   for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
@@ -566,10 +570,6 @@ ShellCommandRunAcpiView (
   Package = NULL;
   TmpDumpFileHandle = NULL;
 
-  // Reset The error/warning counters
-  ResetErrorCount ();
-  ResetWarningCount ();
-
   Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
   if (EFI_ERROR (Status)) {
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
  2020-05-21 18:44 ` [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:40   ` Gao, Zhichao
  2020-05-21 18:44 ` [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

A new file and header (AcpiViewConfig.[ch]) is created
that houses the user configuration. This declutters the
core code and improves modularity of the design.

The module level symbols for verbosity, table selection, and
highlighting are refactored into the new file.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c                    |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c               |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      | 237 +++++++++----------------------------------------------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                      |  95 ---------------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c                | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h                | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c       |   1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf |  32 ++++-----
 12 files changed, 479 insertions(+), 315 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 3f12a33050a4..02f6d771c7e1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -10,6 +10,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include "AcpiParser.h"
 #include "AcpiView.h"
+#include "AcpiViewConfig.h"
 
 STATIC UINT32   gIndent;
 STATIC UINT32   mTableErrorCount;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
index d5b9eee52323..4b618f131eac 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
@@ -17,6 +17,7 @@
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
 #include "AcpiView.h"
+#include "AcpiViewConfig.h"
 
 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
 #include "Arm/SbbrValidator.h"
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index f1a95b7b8f03..2f7395c23bce 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -20,6 +20,7 @@
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
 #include "AcpiView.h"
+#include "AcpiViewConfig.h"
 #include "UefiShellAcpiViewCommandLib.h"
 
 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
@@ -28,17 +29,8 @@
 
 EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 
-// Report variables
-STATIC UINT32             mSelectedAcpiTable;
-STATIC CONST CHAR16*      mSelectedAcpiTableName;
-STATIC BOOLEAN            mSelectedAcpiTableFound;
-STATIC EREPORT_OPTION     mReportType;
 STATIC UINT32             mTableCount;
 STATIC UINT32             mBinTableCount;
-STATIC BOOLEAN            mConsistencyCheck;
-STATIC BOOLEAN            mColourHighlighting;
-STATIC BOOLEAN            mMandatoryTableValidate;
-STATIC UINTN              mMandatoryTableSpec;
 
 /**
   An array of acpiview command line parameters.
@@ -53,142 +45,6 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {NULL, TypeMax}
 };
 
-/**
-  This function returns the colour highlighting status.
-
-  @retval TRUE if colour highlighting is enabled.
-**/
-BOOLEAN
-GetColourHighlighting (
-  VOID
-  )
-{
-  return mColourHighlighting;
-}
-
-/**
-  This function sets the colour highlighting status.
-
-  @param  Highlight       The Highlight status.
-
-**/
-VOID
-SetColourHighlighting (
-  BOOLEAN Highlight
-  )
-{
-  mColourHighlighting = Highlight;
-}
-
-/**
-  This function returns the consistency checking status.
-
-  @retval TRUE if consistency checking is enabled.
-**/
-BOOLEAN
-GetConsistencyChecking (
-  VOID
-  )
-{
-  return mConsistencyCheck;
-}
-
-/**
-  This function sets the consistency checking status.
-
-  @param  ConsistencyChecking   The consistency checking status.
-
-**/
-VOID
-SetConsistencyChecking (
-  BOOLEAN ConsistencyChecking
-  )
-{
-  mConsistencyCheck = ConsistencyChecking;
-}
-
-/**
-  This function returns the ACPI table requirements validation flag.
-
-  @retval TRUE if check for mandatory table presence should be performed.
-**/
-BOOLEAN
-GetMandatoryTableValidate (
-  VOID
-  )
-{
-  return mMandatoryTableValidate;
-}
-
-/**
-  This function sets the ACPI table requirements validation flag.
-
-  @param  Validate    Enable/Disable ACPI table requirements validation.
-**/
-VOID
-SetMandatoryTableValidate (
-  BOOLEAN Validate
-  )
-{
-  mMandatoryTableValidate = Validate;
-}
-
-/**
-  This function returns the identifier of specification to validate ACPI table
-  requirements against.
-
-  @return   ID of specification listing mandatory tables.
-**/
-UINTN
-GetMandatoryTableSpec (
-  VOID
-  )
-{
-  return mMandatoryTableSpec;
-}
-
-/**
-  This function sets the identifier of specification to validate ACPI table
-  requirements against.
-
-  @param  Spec      ID of specification listing mandatory tables.
-**/
-VOID
-SetMandatoryTableSpec (
-  UINTN Spec
-  )
-{
-  mMandatoryTableSpec = Spec;
-}
-
-/**
-  This function returns the report options.
-
-  @retval Returns the report option.
-**/
-STATIC
-EREPORT_OPTION
-GetReportOption (
-  VOID
-  )
-{
-  return mReportType;
-}
-
-/**
-  This function returns the selected ACPI table.
-
-  @retval Returns signature of the selected ACPI table.
-**/
-STATIC
-UINT32
-GetSelectedAcpiTable (
-  VOID
-  )
-{
-  return mSelectedAcpiTable;
-}
-
 /**
   This function dumps the ACPI table to a file.
 
@@ -205,19 +61,21 @@ DumpAcpiTableToFile (
   IN CONST UINTN   Length
   )
 {
-  EFI_STATUS         Status;
-  CHAR16             FileNameBuffer[MAX_FILE_NAME_LEN];
-  SHELL_FILE_HANDLE  DumpFileHandle;
-  UINTN              TransferBytes;
+  EFI_STATUS          Status;
+  CHAR16              FileNameBuffer[MAX_FILE_NAME_LEN];
+  SHELL_FILE_HANDLE   DumpFileHandle;
+  UINTN               TransferBytes;
+  SELECTED_ACPI_TABLE SelectedTable;
 
   DumpFileHandle = NULL;
   TransferBytes = Length;
+  GetSelectedAcpiTable (&SelectedTable);
 
   UnicodeSPrint (
     FileNameBuffer,
     sizeof (FileNameBuffer),
     L".\\%s%04d.bin",
-    mSelectedAcpiTableName,
+    SelectedTable.Name,
     mBinTableCount++
     );
 
@@ -273,10 +131,11 @@ ProcessTableReportOptions (
   IN CONST UINT32  Length
   )
 {
-  UINTN   OriginalAttribute;
-  UINT8*  SignaturePtr;
-  BOOLEAN Log;
-  BOOLEAN HighLight;
+  UINTN               OriginalAttribute;
+  UINT8              *SignaturePtr;
+  BOOLEAN             Log;
+  BOOLEAN             HighLight;
+  SELECTED_ACPI_TABLE SelectedTable;
 
   //
   // set local variables to suppress incorrect compiler/analyzer warnings
@@ -285,15 +144,16 @@ ProcessTableReportOptions (
   SignaturePtr = (UINT8*)(UINTN)&Signature;
   Log = FALSE;
   HighLight = GetColourHighlighting ();
+  GetSelectedAcpiTable (&SelectedTable);
 
   switch (GetReportOption ()) {
     case ReportAll:
       Log = TRUE;
       break;
     case ReportSelected:
-      if (Signature == GetSelectedAcpiTable ()) {
+      if (Signature == SelectedTable.Type) {
         Log = TRUE;
-        mSelectedAcpiTableFound = TRUE;
+        SelectedTable.Found = TRUE;
       }
       break;
     case ReportTableList:
@@ -321,8 +181,8 @@ ProcessTableReportOptions (
         );
       break;
     case ReportDumpBinFile:
-      if (Signature == GetSelectedAcpiTable ()) {
-        mSelectedAcpiTableFound = TRUE;
+      if (Signature == SelectedTable.Type) {
+        SelectedTable.Found = TRUE;
         DumpAcpiTableToFile (TablePtr, Length);
       }
       break;
@@ -356,37 +216,7 @@ ProcessTableReportOptions (
   return Log;
 }
 
-/**
-  This function converts a string to ACPI table signature.
-
-  @param [in] Str   Pointer to the string to be converted to the
-                    ACPI table signature.
 
-  @retval The ACPI table signature.
-**/
-STATIC
-UINT32
-ConvertStrToAcpiSignature (
-  IN  CONST CHAR16* Str
-  )
-{
-  UINT8 Index;
-  CHAR8 Ptr[4];
-
-  ZeroMem (Ptr, sizeof (Ptr));
-  Index = 0;
-
-  // Convert to Upper case and convert to ASCII
-  while ((Index < 4) && (Str[Index] != 0)) {
-    if (Str[Index] >= L'a' && Str[Index] <= L'z') {
-      Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
-    } else {
-      Ptr[Index] = (CHAR8)Str[Index];
-    }
-    Index++;
-  }
-  return *(UINT32*)Ptr;
-}
 
 /**
   This function iterates the configuration table entries in the
@@ -417,6 +247,7 @@ AcpiView (
   UINT8                    RsdpRevision;
   PARSE_ACPI_TABLE_PROC    RsdpParserProc;
   BOOLEAN                  Trace;
+  SELECTED_ACPI_TABLE      SelectedTable;
 
   //
   // set local variables to suppress incorrect compiler/analyzer warnings
@@ -428,6 +259,9 @@ AcpiView (
   ResetErrorCount ();
   ResetWarningCount ();
 
+  // Retrieve the user selection of ACPI table to process
+  GetSelectedAcpiTable (&SelectedTable);
+
   // Search the table for an entry that matches the ACPI Table Guid
   FoundAcpiTable = FALSE;
   for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
@@ -496,7 +330,7 @@ AcpiView (
   if (ReportTableList != ReportOption) {
     if (((ReportSelected == ReportOption)  ||
          (ReportDumpBinFile == ReportOption)) &&
-        (!mSelectedAcpiTableFound)) {
+        (!SelectedTable.Found)) {
       Print (L"\nRequested ACPI Table not found.\n");
     } else if (GetConsistencyChecking () &&
                (ReportDumpBinFile != ReportOption)) {
@@ -554,17 +388,12 @@ ShellCommandRunAcpiView (
   CHAR16*            ProblemParam;
   SHELL_FILE_HANDLE  TmpDumpFileHandle;
   CONST CHAR16*      MandatoryTableSpecStr;
+  CONST CHAR16       *SelectedTableName;
 
   // Set Defaults
-  mReportType = ReportAll;
   mTableCount = 0;
   mBinTableCount = 0;
-  mSelectedAcpiTable = 0;
-  mSelectedAcpiTableName = NULL;
-  mSelectedAcpiTableFound = FALSE;
-  mConsistencyCheck = TRUE;
-  mMandatoryTableValidate = FALSE;
-  mMandatoryTableSpec = 0;
+  AcpiConfigSetDefaults ();
 
   ShellStatus = SHELL_SUCCESS;
   Package = NULL;
@@ -671,25 +500,23 @@ ShellCommandRunAcpiView (
       }
 
       if (ShellCommandLineGetFlag (Package, L"-l")) {
-        mReportType = ReportTableList;
+        SetReportOption (ReportTableList);
       } else {
-        mSelectedAcpiTableName = ShellCommandLineGetValue (Package, L"-s");
-        if (mSelectedAcpiTableName != NULL) {
-          mSelectedAcpiTable = (UINT32)ConvertStrToAcpiSignature (
-                                         mSelectedAcpiTableName
-                                         );
-          mReportType = ReportSelected;
+        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
+        if (SelectedTableName != NULL) {
+          SelectAcpiTable (SelectedTableName);
+          SetReportOption (ReportSelected);
 
           if (ShellCommandLineGetFlag (Package, L"-d"))  {
             // Create a temporary file to check if the media is writable.
             CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
-            mReportType = ReportDumpBinFile;
+            SetReportOption (ReportDumpBinFile);
 
             UnicodeSPrint (
               FileNameBuffer,
               sizeof (FileNameBuffer),
               L".\\%s%04d.tmp",
-              mSelectedAcpiTableName,
+              SelectedTableName,
               mBinTableCount
               );
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index be65564c86a6..92d64a88814d 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -23,17 +23,6 @@
 **/
 #define RSDP_LENGTH_OFFSET   20
 
-/**
-  The EREPORT_OPTION enum describes ACPI table Reporting options.
-**/
-typedef enum ReportOption {
-  ReportAll,            ///< Report All tables.
-  ReportSelected,       ///< Report Selected table.
-  ReportTableList,      ///< Report List of tables.
-  ReportDumpBinFile,    ///< Dump selected table to a file.
-  ReportMax,
-} EREPORT_OPTION;
-
 /**
   This function resets the ACPI table error counter to Zero.
 **/
@@ -70,90 +59,6 @@ GetWarningCount (
   VOID
   );
 
-/**
-  This function returns the colour highlighting status.
-
-  @retval TRUE if colour highlighting is enabled.
-**/
-BOOLEAN
-GetColourHighlighting (
-  VOID
-  );
-
-/**
-  This function sets the colour highlighting status.
-
-  @param  Highlight       The Highlight status.
-
-**/
-VOID
-SetColourHighlighting (
-  BOOLEAN Highlight
-  );
-
-/**
-  This function returns the consistency checking status.
-
-  @retval TRUE if consistency checking is enabled.
-**/
-BOOLEAN
-GetConsistencyChecking (
-  VOID
-  );
-
-/**
-  This function sets the consistency checking status.
-
-  @param  ConsistencyChecking   The consistency checking status.
-
-**/
-VOID
-SetConsistencyChecking (
-  BOOLEAN ConsistencyChecking
-  );
-
-/**
-  This function returns the ACPI table requirements validation flag.
-
-  @retval TRUE if check for mandatory table presence should be performed.
-**/
-BOOLEAN
-GetMandatoryTableValidate (
-  VOID
-  );
-
-/**
-  This function sets the ACPI table requirements validation flag.
-
-  @param  Validate    Enable/Disable ACPI table requirements validation.
-**/
-VOID
-SetMandatoryTableValidate (
-  BOOLEAN Validate
-  );
-
-/**
-  This function returns the identifier of specification to validate ACPI table
-  requirements against.
-
-  @return   ID of specification listing mandatory tables.
-**/
-UINTN
-GetMandatoryTableSpec (
-  VOID
-  );
-
-/**
-  This function sets the identifier of specification to validate ACPI table
-  requirements against.
-
-  @param  Spec      ID of specification listing mandatory tables.
-**/
-VOID
-SetMandatoryTableSpec (
-  UINTN Spec
-  );
-
 /**
   This function processes the table reporting options for the ACPI table.
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
new file mode 100644
index 000000000000..6f6d1a9d52c1
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
@@ -0,0 +1,246 @@
+/** @file
+  State and accessors for 'acpiview' configuration.
+
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+
+#include "AcpiViewConfig.h"
+
+// Report variables
+STATIC BOOLEAN        mConsistencyCheck;
+STATIC BOOLEAN        mColourHighlighting;
+STATIC EREPORT_OPTION mReportType;
+STATIC BOOLEAN        mMandatoryTableValidate;
+STATIC UINTN          mMandatoryTableSpec;
+
+// User selection of which ACPI table should be checked
+SELECTED_ACPI_TABLE mSelectedAcpiTable;
+
+/**
+ Reset the AcpiView user configuration to defaults
+**/
+VOID
+EFIAPI
+AcpiConfigSetDefaults (
+  VOID
+  )
+{
+  mReportType = ReportAll;
+  mSelectedAcpiTable.Type = 0;
+  mSelectedAcpiTable.Name = NULL;
+  mSelectedAcpiTable.Found = FALSE;
+  mConsistencyCheck = TRUE;
+  mMandatoryTableValidate = FALSE;
+  mMandatoryTableSpec = 0;
+}
+
+/**
+  This function converts a string to ACPI table signature.
+
+  @param [in] Str   Pointer to the string to be converted to the
+                    ACPI table signature.
+
+  @retval The ACPI table signature.
+**/
+STATIC
+UINT32
+ConvertStrToAcpiSignature (
+  IN CONST CHAR16 *Str
+  )
+{
+  UINT8 Index;
+  CHAR8 Ptr[4];
+
+  ZeroMem (Ptr, sizeof (Ptr));
+  Index = 0;
+
+  // Convert to Upper case and convert to ASCII
+  while ((Index < 4) && (Str[Index] != 0)) {
+    if (Str[Index] >= L'a' && Str[Index] <= L'z') {
+      Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
+    } else {
+      Ptr[Index] = (CHAR8)Str[Index];
+    }
+    Index++;
+  }
+  return *(UINT32 *) Ptr;
+}
+
+/**
+  This function selects an ACPI table in current context.
+  The string name of the table is converted into UINT32
+  table signature.
+
+  @param [in] TableName The name of the ACPI table to select.
+**/
+VOID
+EFIAPI
+SelectAcpiTable (
+  IN CONST CHAR16 *TableName
+  )
+{
+  ASSERT (TableName != NULL);
+
+  mSelectedAcpiTable.Name = TableName;
+  mSelectedAcpiTable.Type = ConvertStrToAcpiSignature (mSelectedAcpiTable.Name);
+}
+
+/**
+  This function returns the selected ACPI table.
+
+  @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
+**/
+VOID
+EFIAPI
+GetSelectedAcpiTable (
+  OUT SELECTED_ACPI_TABLE *SelectedAcpiTable
+  )
+{
+  *SelectedAcpiTable = mSelectedAcpiTable;
+}
+
+/**
+  This function returns the colour highlighting status.
+
+  @retval TRUE Colour highlighting is enabled.
+**/
+BOOLEAN
+EFIAPI
+GetColourHighlighting (
+  VOID
+  )
+{
+  return mColourHighlighting;
+}
+
+/**
+  This function sets the colour highlighting status.
+
+  @param [in] Highlight The highlight status.
+**/
+VOID
+EFIAPI
+SetColourHighlighting (
+  BOOLEAN Highlight
+  )
+{
+  mColourHighlighting = Highlight;
+}
+
+/**
+  This function returns the consistency checking status.
+
+  @retval TRUE Consistency checking is enabled.
+**/
+BOOLEAN
+EFIAPI
+GetConsistencyChecking (
+  VOID
+  )
+{
+  return mConsistencyCheck;
+}
+
+/**
+  This function sets the consistency checking status.
+
+  @param [in] ConsistencyChecking   The consistency checking status.
+**/
+VOID
+EFIAPI
+SetConsistencyChecking (
+  BOOLEAN ConsistencyChecking
+  )
+{
+  mConsistencyCheck = ConsistencyChecking;
+}
+
+/**
+  This function returns the report options.
+
+  @return The current report option.
+**/
+EREPORT_OPTION
+EFIAPI
+GetReportOption (
+  VOID
+  )
+{
+  return mReportType;
+}
+
+/**
+  This function sets the report options.
+
+  @param [in] ReportType The report option to set.
+**/
+VOID
+EFIAPI
+SetReportOption (
+  EREPORT_OPTION ReportType
+  )
+{
+  mReportType = ReportType;
+}
+
+/**
+  This function returns the ACPI table requirements validation flag.
+
+  @retval TRUE Check for mandatory table presence should be performed.
+**/
+BOOLEAN
+EFIAPI
+GetMandatoryTableValidate (
+  VOID
+  )
+{
+  return mMandatoryTableValidate;
+}
+
+/**
+  This function sets the ACPI table requirements validation flag.
+
+  @param [in] Validate Enable/Disable ACPI table requirements validation.
+**/
+VOID
+EFIAPI
+SetMandatoryTableValidate (
+  BOOLEAN Validate
+  )
+{
+  mMandatoryTableValidate = Validate;
+}
+
+/**
+  This function returns the identifier of specification to validate ACPI table
+  requirements against.
+
+  @return ID of specification listing mandatory tables.
+**/
+UINTN
+EFIAPI
+GetMandatoryTableSpec (
+  VOID
+  )
+{
+  return mMandatoryTableSpec;
+}
+
+/**
+  This function sets the identifier of specification to validate ACPI table
+  requirements against.
+
+  @param [in] Spec ID of specification listing mandatory tables.
+**/
+VOID
+EFIAPI
+SetMandatoryTableSpec (
+  UINTN Spec
+  )
+{
+  mMandatoryTableSpec = Spec;
+}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
new file mode 100644
index 000000000000..fc99624e41dc
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
@@ -0,0 +1,177 @@
+/** @file
+  Header file for 'acpiview' configuration.
+
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef ACPI_VIEW_CONFIG_H_
+#define ACPI_VIEW_CONFIG_H_
+
+/**
+  This function returns the colour highlighting status.
+
+  @retval TRUE Colour highlighting is enabled.
+**/
+BOOLEAN
+EFIAPI
+GetColourHighlighting (
+  VOID
+  );
+
+/**
+  This function sets the colour highlighting status.
+
+  @param [in] Highlight The highlight status.
+**/
+VOID
+EFIAPI
+SetColourHighlighting (
+  BOOLEAN Highlight
+  );
+
+/**
+  This function returns the consistency checking status.
+
+  @retval TRUE Consistency checking is enabled.
+**/
+BOOLEAN
+EFIAPI
+GetConsistencyChecking (
+  VOID
+  );
+
+/**
+  This function sets the consistency checking status.
+
+  @param [in] ConsistencyChecking   The consistency checking status.
+**/
+VOID
+EFIAPI
+SetConsistencyChecking (
+  BOOLEAN ConsistencyChecking
+  );
+
+/**
+  This function returns the ACPI table requirements validation flag.
+
+  @retval TRUE Check for mandatory table presence should be performed.
+**/
+BOOLEAN
+EFIAPI
+GetMandatoryTableValidate (
+  VOID
+  );
+
+/**
+  This function sets the ACPI table requirements validation flag.
+
+  @param [in] Validate Enable/Disable ACPI table requirements validation.
+**/
+VOID
+EFIAPI
+SetMandatoryTableValidate (
+  BOOLEAN Validate
+  );
+
+/**
+  This function returns the identifier of specification to validate ACPI table
+  requirements against.
+
+  @return ID of specification listing mandatory tables.
+**/
+UINTN
+EFIAPI
+GetMandatoryTableSpec (
+  VOID
+  );
+
+/**
+  This function sets the identifier of specification to validate ACPI table
+  requirements against.
+
+  @param [in] Spec ID of specification listing mandatory tables.
+**/
+VOID
+EFIAPI
+SetMandatoryTableSpec (
+  UINTN Spec
+  );
+
+/**
+  The EREPORT_OPTION enum describes ACPI table Reporting options.
+**/
+typedef enum {
+  ReportAll,          ///< Report All tables.
+  ReportSelected,     ///< Report Selected table.
+  ReportTableList,    ///< Report List of tables.
+  ReportDumpBinFile,  ///< Dump selected table to a file.
+  ReportMax,
+} EREPORT_OPTION;
+
+/**
+  This function returns the report options.
+
+  @return The current report option.
+**/
+EREPORT_OPTION
+EFIAPI
+GetReportOption (
+  VOID
+  );
+
+/**
+  This function sets the report options.
+
+  @param [in] ReportType The report option to set.
+**/
+VOID
+EFIAPI
+SetReportOption (
+  EREPORT_OPTION ReportType
+  );
+
+/**
+  A structure holding the user selection detailing which
+  ACPI table is to be examined by the AcpiView code.
+**/
+typedef struct {
+  UINT32              Type;    ///< 32bit signature of the selected ACPI table.
+  CONST CHAR16*       Name;    ///< User friendly name of the selected ACPI table.
+  BOOLEAN             Found;   ///< The selected table has been found in the system.
+} SELECTED_ACPI_TABLE;
+
+/**
+  This function returns the selected ACPI table.
+
+  @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
+**/
+VOID
+EFIAPI
+GetSelectedAcpiTable (
+  OUT SELECTED_ACPI_TABLE* SelectedAcpiTable
+  );
+
+/**
+  This function selects an ACPI table in current context.
+  The string name of the table is converted into UINT32
+  table signature.
+
+  @param [in] TableName The name of the ACPI table to select.
+**/
+VOID
+EFIAPI
+SelectAcpiTable (
+  CONST CHAR16* TableName
+  );
+
+/**
+  Reset the AcpiView user configuration to defaults.
+**/
+VOID
+EFIAPI
+AcpiConfigSetDefaults (
+  VOID
+  );
+
+#endif // ACPI_VIEW_CONFIG_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
index bdd30ff45c61..d02fc4929d6f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
@@ -12,6 +12,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
+#include "AcpiViewConfig.h"
 
 // "The number of GT Block Timers must be less than or equal to 8"
 #define GT_BLOCK_TIMER_COUNT_MAX 8
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index 9a006a01448b..f7447947b230 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -13,6 +13,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
+#include "AcpiViewConfig.h"
 
 // Local variables
 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index f85d2b36532c..15aa2392b60c 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -15,6 +15,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
+#include "AcpiViewConfig.h"
 #include "MadtParser.h"
 
 // Local Variables
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index 0db272c16af0..acd2b81bb325 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -13,6 +13,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiView.h"
+#include "AcpiViewConfig.h"
 #include "PpttParser.h"
 
 // Local variables
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index 6f66be68cc0b..b9b67820b89f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -13,6 +13,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
+#include "AcpiViewConfig.h"
 
 // Local Variables
 STATIC CONST UINT8* SratRAType;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index d21ecd40a8cf..92de2391b09f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -19,15 +19,14 @@ [Defines]
   DESTRUCTOR                     = UefiShellAcpiViewCommandLibDestructor
 
 [Sources.common]
-  UefiShellAcpiViewCommandLib.uni
-  UefiShellAcpiViewCommandLib.c
-  UefiShellAcpiViewCommandLib.h
-  AcpiParser.h
-  AcpiTableParser.h
-  AcpiView.h
   AcpiParser.c
+  AcpiParser.h
   AcpiTableParser.c
+  AcpiTableParser.h
   AcpiView.c
+  AcpiView.h
+  AcpiViewConfig.c
+  AcpiViewConfig.h
   Parsers/Bgrt/BgrtParser.c
   Parsers/Dbg2/Dbg2Parser.c
   Parsers/Dsdt/DsdtParser.c
@@ -36,40 +35,43 @@ [Sources.common]
   Parsers/Gtdt/GtdtParser.c
   Parsers/Iort/IortParser.c
   Parsers/Madt/MadtParser.c
+  Parsers/Madt/MadtParser.h
   Parsers/Mcfg/McfgParser.c
   Parsers/Pptt/PpttParser.c
+  Parsers/Pptt/PpttParser.h
   Parsers/Rsdp/RsdpParser.c
   Parsers/Slit/SlitParser.c
   Parsers/Spcr/SpcrParser.c
   Parsers/Srat/SratParser.c
   Parsers/Ssdt/SsdtParser.c
   Parsers/Xsdt/XsdtParser.c
-  Parsers/Madt/MadtParser.h
-  Parsers/Pptt/PpttParser.h
+  UefiShellAcpiViewCommandLib.c
+  UefiShellAcpiViewCommandLib.h
+  UefiShellAcpiViewCommandLib.uni
 
 [Sources.ARM, Sources.AARCH64]
   Arm/SbbrValidator.h
   Arm/SbbrValidator.c
 
 [Packages]
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   ShellPkg/ShellPkg.dec
-  MdeModulePkg/MdeModulePkg.dec
 
 [LibraryClasses]
-  MemoryAllocationLib
   BaseLib
   BaseMemoryLib
   DebugLib
+  FileHandleLib
+  HiiLib
+  MemoryAllocationLib
+  PcdLib
+  PrintLib
   ShellCommandLib
   ShellLib
+  UefiBootServicesTableLib
   UefiLib
   UefiRuntimeServicesTableLib
-  UefiBootServicesTableLib
-  PcdLib
-  HiiLib
-  PrintLib
-  FileHandleLib
 
 
 [FixedPcd]
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
  2020-05-21 18:44 ` [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
  2020-05-21 18:44 ` [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:40   ` [edk2-devel] " Gao, Zhichao
  2020-05-21 18:44 ` [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

The table count module level symbols are now reset when
executing the core method, rather than the shell command
wrapper.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 2f7395c23bce..c9654e52c434 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -255,6 +255,10 @@ AcpiView (
   EfiConfigurationTable = NULL;
   OriginalAttribute = 0;
 
+  // Reset Table counts
+  mTableCount = 0;
+  mBinTableCount = 0;
+
   // Reset The error/warning counters
   ResetErrorCount ();
   ResetWarningCount ();
@@ -390,9 +394,7 @@ ShellCommandRunAcpiView (
   CONST CHAR16*      MandatoryTableSpecStr;
   CONST CHAR16       *SelectedTableName;
 
-  // Set Defaults
-  mTableCount = 0;
-  mBinTableCount = 0;
+  // Set configuration defaults
   AcpiConfigSetDefaults ();
 
   ShellStatus = SHELL_SUCCESS;
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (2 preceding siblings ...)
  2020-05-21 18:44 ` [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:40   ` [edk2-devel] " Gao, Zhichao
  2020-05-21 18:44 ` [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
  2020-05-21 18:44 ` [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

Parsing command line parameters is done in the shell
command wrapper. This declutters the core code and improves
modular design.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                    | 205 -----------------------------------------------------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                    |  18 +++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h |  10 +++-
 4 files changed, 240 insertions(+), 211 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index c9654e52c434..a3160ed6f0a2 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -32,19 +32,6 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 STATIC UINT32             mTableCount;
 STATIC UINT32             mBinTableCount;
 
-/**
-  An array of acpiview command line parameters.
-**/
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
-  {L"-q", TypeFlag},
-  {L"-d", TypeFlag},
-  {L"-h", TypeFlag},
-  {L"-l", TypeFlag},
-  {L"-s", TypeValue},
-  {L"-r", TypeValue},
-  {NULL, TypeMax}
-};
-
 /**
   This function dumps the ACPI table to a file.
 
@@ -228,7 +215,6 @@ ProcessTableReportOptions (
           Returns EFI_UNSUPPORTED if the RSDP version is less than 2.
           Returns EFI_SUCCESS     if successful.
 **/
-STATIC
 EFI_STATUS
 EFIAPI
 AcpiView (
@@ -372,194 +358,3 @@ AcpiView (
   }
   return EFI_SUCCESS;
 }
-
-/**
-  Function for 'acpiview' command.
-
-  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
-  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAcpiView (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE* SystemTable
-  )
-{
-  EFI_STATUS         Status;
-  SHELL_STATUS       ShellStatus;
-  LIST_ENTRY*        Package;
-  CHAR16*            ProblemParam;
-  SHELL_FILE_HANDLE  TmpDumpFileHandle;
-  CONST CHAR16*      MandatoryTableSpecStr;
-  CONST CHAR16       *SelectedTableName;
-
-  // Set configuration defaults
-  AcpiConfigSetDefaults ();
-
-  ShellStatus = SHELL_SUCCESS;
-  Package = NULL;
-  TmpDumpFileHandle = NULL;
-
-  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
-  if (EFI_ERROR (Status)) {
-    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GEN_PROBLEM),
-        gShellAcpiViewHiiHandle,
-        L"acpiview",
-        ProblemParam
-        );
-      FreePool (ProblemParam);
-    } else {
-      Print (L"acpiview: Error processing input parameter(s)\n");
-    }
-    ShellStatus = SHELL_INVALID_PARAMETER;
-  } else {
-    if (ShellCommandLineGetCount (Package) > 1) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GEN_TOO_MANY),
-        gShellAcpiViewHiiHandle,
-        L"acpiview"
-        );
-      ShellStatus = SHELL_INVALID_PARAMETER;
-    } else if (ShellCommandLineGetFlag (Package, L"-?")) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GET_HELP_ACPIVIEW),
-        gShellAcpiViewHiiHandle,
-        L"acpiview"
-        );
-    } else if (ShellCommandLineGetFlag (Package, L"-s") &&
-               ShellCommandLineGetValue (Package, L"-s") == NULL) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GEN_NO_VALUE),
-        gShellAcpiViewHiiHandle,
-        L"acpiview",
-        L"-s"
-        );
-      ShellStatus = SHELL_INVALID_PARAMETER;
-    } else if (ShellCommandLineGetFlag (Package, L"-r") &&
-               ShellCommandLineGetValue (Package, L"-r") == NULL) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GEN_NO_VALUE),
-        gShellAcpiViewHiiHandle,
-        L"acpiview",
-        L"-r"
-        );
-      ShellStatus = SHELL_INVALID_PARAMETER;
-    } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
-                ShellCommandLineGetFlag (Package, L"-l"))) {
-      ShellPrintHiiEx (
-        -1,
-        -1,
-        NULL,
-        STRING_TOKEN (STR_GEN_TOO_MANY),
-        gShellAcpiViewHiiHandle,
-        L"acpiview"
-        );
-      ShellStatus = SHELL_INVALID_PARAMETER;
-    } else if (ShellCommandLineGetFlag (Package, L"-d") &&
-               !ShellCommandLineGetFlag (Package, L"-s")) {
-        ShellPrintHiiEx (
-          -1,
-          -1,
-          NULL,
-          STRING_TOKEN (STR_GEN_MISSING_OPTION),
-          gShellAcpiViewHiiHandle,
-          L"acpiview",
-          L"-s",
-          L"-d"
-          );
-        ShellStatus = SHELL_INVALID_PARAMETER;
-    } else {
-      // Turn on colour highlighting if requested
-      SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
-
-      // Surpress consistency checking if requested
-      SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));
-
-      // Evaluate the parameters for mandatory ACPI table presence checks
-      SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));
-      MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");
-
-      if (MandatoryTableSpecStr != NULL) {
-        SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));
-      }
-
-      if (ShellCommandLineGetFlag (Package, L"-l")) {
-        SetReportOption (ReportTableList);
-      } else {
-        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
-        if (SelectedTableName != NULL) {
-          SelectAcpiTable (SelectedTableName);
-          SetReportOption (ReportSelected);
-
-          if (ShellCommandLineGetFlag (Package, L"-d"))  {
-            // Create a temporary file to check if the media is writable.
-            CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
-            SetReportOption (ReportDumpBinFile);
-
-            UnicodeSPrint (
-              FileNameBuffer,
-              sizeof (FileNameBuffer),
-              L".\\%s%04d.tmp",
-              SelectedTableName,
-              mBinTableCount
-              );
-
-            Status = ShellOpenFileByName (
-                       FileNameBuffer,
-                       &TmpDumpFileHandle,
-                       EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
-                       EFI_FILE_MODE_CREATE,
-                       0
-                       );
-
-            if (EFI_ERROR (Status)) {
-              ShellStatus = SHELL_INVALID_PARAMETER;
-              TmpDumpFileHandle = NULL;
-              ShellPrintHiiEx (
-                -1,
-                -1,
-                NULL,
-                STRING_TOKEN (STR_GEN_READONLY_MEDIA),
-                gShellAcpiViewHiiHandle,
-                L"acpiview"
-                );
-              goto Done;
-            }
-            // Delete Temporary file.
-            ShellDeleteFile (&TmpDumpFileHandle);
-          } // -d
-        } // -s
-      }
-
-      // Parse ACPI Table information
-      Status = AcpiView (SystemTable);
-      if (EFI_ERROR (Status)) {
-        ShellStatus = SHELL_NOT_FOUND;
-      }
-    }
-  }
-
-Done:
-  if (Package != NULL) {
-    ShellCommandLineFreeVarList (Package);
-  }
-  return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index 92d64a88814d..d5b95f5ee707 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -64,7 +64,7 @@ GetWarningCount (
 
   @param [in] Signature The ACPI table Signature.
   @param [in] TablePtr  Pointer to the ACPI table data.
-  @param [in] Length    The length fo the ACPI table.
+  @param [in] Length    The length of the ACPI table.
 
   @retval Returns TRUE if the ACPI table should be traced.
 **/
@@ -75,4 +75,20 @@ ProcessTableReportOptions (
   IN CONST UINT32  Length
   );
 
+/**
+  This function iterates the configuration table entries in the
+  system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
+
+  @param [in] SystemTable Pointer to the EFI system table.
+
+  @retval EFI_NOT_FOUND   The RSDP pointer was not found.
+  @retval EFI_UNSUPPORTED The RSDP version was less than 2.
+  @retval EFI_SUCCESS     The command was successful.
+**/
+EFI_STATUS
+EFIAPI
+AcpiView (
+  IN EFI_SYSTEM_TABLE* SystemTable
+  );
+
 #endif // ACPIVIEW_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index e0d5a8108552..c3942ad24e5b 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,24 +1,44 @@
 /** @file
   Main file for 'acpiview' Shell command function.
 
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.<BR>
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include <Guid/ShellLibHiiGuid.h>
 #include <IndustryStandard/Acpi.h>
+
+#include <Library/BaseMemoryLib.h>
 #include <Library/HiiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
 #include <Library/ShellCommandLib.h>
-#include <Library/UefiLib.h>
+#include <Library/ShellLib.h>
 #include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
 #include <Uefi.h>
+
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
 #include "AcpiView.h"
+#include "AcpiViewConfig.h"
 #include "UefiShellAcpiViewCommandLib.h"
 
 CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
 
+/**
+  An array of acpiview command line parameters.
+**/
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+  {L"-q", TypeFlag},
+  {L"-d", TypeFlag},
+  {L"-h", TypeFlag},
+  {L"-l", TypeFlag},
+  {L"-s", TypeValue},
+  {L"-r", TypeValue},
+  {NULL, TypeMax}
+};
+
 /**
   A list of available table parsers.
 */
@@ -92,6 +112,200 @@ ShellCommandGetManFileNameAcpiView (
   return gShellAcpiViewFileName;
 }
 
+/**
+  Function for 'acpiview' command.
+
+  @param[in] ImageHandle  Handle to the Image (NULL if internal).
+  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
+
+  @retval SHELL_INVALID_PARAMETER The command line invocation could not be parsed
+  @retval SHELL_NOT_FOUND         The command failed
+  @retval SHELL_SUCCESS           The command was successful
+**/
+SHELL_STATUS
+EFIAPI
+ShellCommandRunAcpiView (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE* SystemTable
+  )
+{
+  EFI_STATUS         Status;
+  SHELL_STATUS       ShellStatus;
+  LIST_ENTRY*        Package;
+  CHAR16*            ProblemParam;
+  SHELL_FILE_HANDLE  TmpDumpFileHandle;
+  CONST CHAR16*      MandatoryTableSpecStr;
+  CONST CHAR16*      SelectedTableName;
+
+  // Set configuration defaults
+  AcpiConfigSetDefaults ();
+
+  ShellStatus = SHELL_SUCCESS;
+  Package = NULL;
+  TmpDumpFileHandle = NULL;
+
+  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
+  if (EFI_ERROR (Status)) {
+    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GEN_PROBLEM),
+        gShellAcpiViewHiiHandle,
+        L"acpiview",
+        ProblemParam
+        );
+      FreePool (ProblemParam);
+    } else {
+      Print (L"acpiview: Error processing input parameter(s)\n");
+    }
+    ShellStatus = SHELL_INVALID_PARAMETER;
+  } else {
+    if (ShellCommandLineGetCount (Package) > 1) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GEN_TOO_MANY),
+        gShellAcpiViewHiiHandle,
+        L"acpiview"
+        );
+      ShellStatus = SHELL_INVALID_PARAMETER;
+    } else if (ShellCommandLineGetFlag (Package, L"-?")) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GET_HELP_ACPIVIEW),
+        gShellAcpiViewHiiHandle,
+        L"acpiview"
+        );
+    } else if (ShellCommandLineGetFlag (Package, L"-s") &&
+               ShellCommandLineGetValue (Package, L"-s") == NULL) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GEN_NO_VALUE),
+        gShellAcpiViewHiiHandle,
+        L"acpiview",
+        L"-s"
+        );
+      ShellStatus = SHELL_INVALID_PARAMETER;
+    } else if (ShellCommandLineGetFlag (Package, L"-r") &&
+               ShellCommandLineGetValue (Package, L"-r") == NULL) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GEN_NO_VALUE),
+        gShellAcpiViewHiiHandle,
+        L"acpiview",
+        L"-r"
+        );
+      ShellStatus = SHELL_INVALID_PARAMETER;
+    } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
+                ShellCommandLineGetFlag (Package, L"-l"))) {
+      ShellPrintHiiEx (
+        -1,
+        -1,
+        NULL,
+        STRING_TOKEN (STR_GEN_TOO_MANY),
+        gShellAcpiViewHiiHandle,
+        L"acpiview"
+        );
+      ShellStatus = SHELL_INVALID_PARAMETER;
+    } else if (ShellCommandLineGetFlag (Package, L"-d") &&
+               !ShellCommandLineGetFlag (Package, L"-s")) {
+        ShellPrintHiiEx (
+          -1,
+          -1,
+          NULL,
+          STRING_TOKEN (STR_GEN_MISSING_OPTION),
+          gShellAcpiViewHiiHandle,
+          L"acpiview",
+          L"-s",
+          L"-d"
+          );
+        ShellStatus = SHELL_INVALID_PARAMETER;
+    } else {
+      // Turn on colour highlighting if requested
+      SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
+
+      // Surpress consistency checking if requested
+      SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));
+
+      // Evaluate the parameters for mandatory ACPI table presence checks
+      SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));
+      MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");
+
+      if (MandatoryTableSpecStr != NULL) {
+        SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));
+      }
+
+      if (ShellCommandLineGetFlag (Package, L"-l")) {
+        SetReportOption (ReportTableList);
+      } else {
+        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
+        if (SelectedTableName != NULL) {
+          SelectAcpiTable (SelectedTableName);
+          SetReportOption (ReportSelected);
+
+          if (ShellCommandLineGetFlag (Package, L"-d"))  {
+            // Create a temporary file to check if the media is writable.
+            CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
+            SetReportOption (ReportDumpBinFile);
+
+            UnicodeSPrint (
+              FileNameBuffer,
+              sizeof (FileNameBuffer),
+              L".\\%s0000.tmp",
+              SelectedTableName
+              );
+
+            Status = ShellOpenFileByName (
+                       FileNameBuffer,
+                       &TmpDumpFileHandle,
+                       EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
+                       EFI_FILE_MODE_CREATE,
+                       0
+                       );
+
+            if (EFI_ERROR (Status)) {
+              ShellStatus = SHELL_INVALID_PARAMETER;
+              TmpDumpFileHandle = NULL;
+              ShellPrintHiiEx (
+                -1,
+                -1,
+                NULL,
+                STRING_TOKEN (STR_GEN_READONLY_MEDIA),
+                gShellAcpiViewHiiHandle,
+                L"acpiview"
+                );
+              goto Done;
+            }
+            // Delete Temporary file.
+            ShellDeleteFile (&TmpDumpFileHandle);
+          } // -d
+        } // -s
+      }
+
+      // Parse ACPI Table information
+      Status = AcpiView (SystemTable);
+      if (EFI_ERROR (Status)) {
+        ShellStatus = SHELL_NOT_FOUND;
+      }
+    }
+  }
+
+Done:
+  if (Package != NULL) {
+    ShellCommandLineFreeVarList (Package);
+  }
+  return ShellStatus;
+}
+
 /**
   Constructor for the Shell AcpiView Command library.
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
index c1cf7a57af7a..a3a29164004d 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for 'acpiview' Shell command functions.
 
-  Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.<BR>
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -13,8 +13,12 @@ extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;
 /**
   Function for 'acpiview' command.
 
-  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
-  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
+  @param[in] ImageHandle  Handle to the Image (NULL if internal).
+  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
+
+  @retval SHELL_INVALID_PARAMETER The command line invocation could not be parsed
+  @retval SHELL_NOT_FOUND         The command failed
+  @retval SHELL_SUCCESS           The command was successful
 **/
 SHELL_STATUS
 EFIAPI
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (3 preceding siblings ...)
  2020-05-21 18:44 ` [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:41   ` [edk2-devel] " Gao, Zhichao
  2020-05-21 18:44 ` [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

Method is refactored into two parts. A new method is
created that dumps arbitrary buffers into a newly created
file. This method is called from core code after the core code
determined the appropriate filename to be used.

This improves the modular design.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                    | 35 +----------------------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h | 17 +++++++++++++++++
 3 files changed, 76 insertions(+), 34 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index a3160ed6f0a2..e866b84c6844 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -48,13 +48,10 @@ DumpAcpiTableToFile (
   IN CONST UINTN   Length
   )
 {
-  EFI_STATUS          Status;
   CHAR16              FileNameBuffer[MAX_FILE_NAME_LEN];
-  SHELL_FILE_HANDLE   DumpFileHandle;
   UINTN               TransferBytes;
   SELECTED_ACPI_TABLE SelectedTable;
 
-  DumpFileHandle = NULL;
   TransferBytes = Length;
   GetSelectedAcpiTable (&SelectedTable);
 
@@ -66,39 +63,9 @@ DumpAcpiTableToFile (
     mBinTableCount++
     );
 
-  Status = ShellOpenFileByName (
-             FileNameBuffer,
-             &DumpFileHandle,
-             EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
-             0
-             );
-  if (EFI_ERROR (Status)) {
-    ShellPrintHiiEx (
-      -1,
-      -1,
-      NULL,
-      STRING_TOKEN (STR_GEN_READONLY_MEDIA),
-      gShellAcpiViewHiiHandle,
-      L"acpiview"
-      );
-    return FALSE;
-  }
-
   Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer);
 
-  Status = ShellWriteFile (
-             DumpFileHandle,
-             &TransferBytes,
-             (VOID*)Ptr
-             );
-  if (EFI_ERROR (Status)) {
-    Print (L"ERROR: Failed to dump table to binary file.\n");
-    TransferBytes = 0;
-  } else {
-    Print (L"DONE.\n");
-  }
-
-  ShellCloseFile (&DumpFileHandle);
+  TransferBytes = DumpFile (FileNameBuffer, Ptr, Length);
   return (Length == TransferBytes);
 }
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index c3942ad24e5b..adf3cce6cfe2 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -98,6 +98,64 @@ RegisterAllParsers (
   return Status;
 }
 
+/**
+  Dump a buffer to a file
+
+  @param[in] FileName   The filename that shall be created to contain the buffer
+  @param[in] Buffer     Pointer to buffer that shall be dumped
+  @param[in] BufferSize The size of buffer to be dumped in bytes
+
+  @return The number of bytes that were written
+**/
+UINTN
+EFIAPI
+DumpFile (
+  IN CONST CHAR16* FileNameBuffer,
+  IN CONST VOID*   Buffer,
+  IN CONST UINTN   BufferSize
+  )
+{
+  EFI_STATUS          Status;
+  SHELL_FILE_HANDLE   DumpFileHandle;
+  UINTN               TransferBytes;
+
+  Status = ShellOpenFileByName (
+             FileNameBuffer,
+             &DumpFileHandle,
+             EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
+             0
+             );
+
+  if (EFI_ERROR (Status)) {
+    ShellPrintHiiEx (
+      -1,
+      -1,
+      NULL,
+      STRING_TOKEN (STR_GEN_READONLY_MEDIA),
+      gShellAcpiViewHiiHandle,
+      L"acpiview"
+      );
+    return 0;
+  }
+
+  TransferBytes = BufferSize;
+  Status = ShellWriteFile (
+             DumpFileHandle,
+             &TransferBytes,
+             (VOID *) Buffer
+             );
+
+  if (EFI_ERROR (Status)) {
+    Print (L"ERROR: Failed to write binary file.\n");
+    TransferBytes = 0;
+  } else {
+    Print (L"DONE.\n");
+  }
+
+  ShellCloseFile (&DumpFileHandle);
+  return TransferBytes;
+}
+
 /**
   Return the file name of the help text file if not using HII.
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
index a3a29164004d..9dd39cf4b3f0 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
@@ -10,6 +10,23 @@
 
 extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;
 
+/**
+  Dump a buffer to a file
+
+  @param[in] FileName   The filename that shall be created to contain the buffer
+  @param[in] Buffer     Pointer to buffer that shall be dumped
+  @param[in] BufferSize The size of buffer to be dumped in bytes
+
+  @return The number of bytes that were written
+**/
+UINTN
+EFIAPI
+DumpFile (
+  IN CONST CHAR16* FileNameBuffer,
+  IN CONST VOID*   Buffer,
+  IN CONST UINTN   BufferSize
+  );
+
 /**
   Function for 'acpiview' command.
 
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper
  2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (4 preceding siblings ...)
  2020-05-21 18:44 ` [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
@ 2020-05-21 18:44 ` Tomas Pilar (tpilar)
  2020-06-12  2:41   ` [edk2-devel] " Gao, Zhichao
  5 siblings, 1 reply; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-05-21 18:44 UTC (permalink / raw)
  To: devel; +Cc: nd, Ray Ni, Zhichao Gao

Simple application wrapper that invokes the shell
command wrapper for acpiview.

This allows the AcpiView functionality to be used
on platforms with older specifications of the UEFI
shell or where the 'acpiview' command is not built in
due to platform build configuration.

Furthermore, this app can be integrated into more comprehensive
testing frameworks as a single component of a more thorough
specification compliance validation strategy.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 ShellPkg/Application/AcpiViewApp/AcpiViewApp.c   | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf |  31 ++++++++++++
 ShellPkg/ShellPkg.dsc                            |   6 ++-
 3 files changed, 225 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
new file mode 100644
index 000000000000..f83111629c21
--- /dev/null
+++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
@@ -0,0 +1,189 @@
+/** @file
+  Main file for AcpiViewApp application
+
+  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/ShellParameters.h>
+
+/**
+  Execute the AcpiView command from UefiShellAcpiViewCommandLib.
+  This function is pulled in directly from the library source.
+**/
+SHELL_STATUS
+EFIAPI
+ShellCommandRunAcpiView (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE* SystemTable
+  );
+
+CHAR16 mAcpiViewAppHelp[] =
+  u"\r\n"
+  "Display ACPI Table information.\r\n"
+  "\r\n"
+  "AcpiViewApp.efi [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h]]\r\n"
+  " \r\n"
+  "  -l - Display list of installed ACPI Tables.\r\n"
+  "  -s - Display only the specified AcpiTable type and only support single\r\n"
+  "       invocation option.\r\n"
+  "         AcpiTable    : The required ACPI Table type.\r\n"
+  "  -d - Generate a binary file dump of the specified AcpiTable.\r\n"
+  "  -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
+  "  -h - Enable colour highlighting.\r\n"
+  "  -? - Show help.\r\n"
+  " \r\n"
+  "  This program is provided to allow examination of ACPI table values from "
+  "the\r\n"
+  "  UEFI Shell. This can help with investigations, especially at that "
+  "stage\r\n"
+  "  where the tables are not enabling an OS to boot.\r\n"
+  "  The program is not exhaustive, and only encapsulates detailed knowledge "
+  "of a\r\n"
+  "  limited number of table types.\r\n"
+  " \r\n"
+  "  Default behaviour is to display the content of all tables installed.\r\n"
+  "  'Known' table types (listed in NOTES below) will be parsed and "
+  "displayed\r\n"
+  "  with descriptions and field values. Where appropriate a degree of\r\n"
+  "  consistency checking is done and errors may be reported in the output.\r\n"
+  "  Other table types will be displayed as an array of Hexadecimal bytes.\r\n"
+  " \r\n"
+  "  To facilitate debugging, the -s and -d options can be used to generate "
+  "a\r\n"
+  "  binary file image of a table that can be copied elsewhere for "
+  "investigation\r\n"
+  "  using tools such as those provided by acpica.org. This is especially\r\n"
+  "  relevant for AML type tables like DSDT and SSDT.\r\n"
+  " \r\n"
+  "NOTES:\r\n"
+  "  1. The AcpiTable parameter can match any installed table type.\r\n"
+  "     Tables without specific handling will be displayed as a raw hex dump "
+  "(or\r\n"
+  "     dumped to a file if -d is used).\r\n"
+  "  2. -s option supports to display the specified AcpiTable type that is "
+  "present\r\n"
+  "     in the system. For normal type AcpiTable, it would display the data of "
+  "the\r\n"
+  "     AcpiTable and AcpiTable header. The following type may contain header "
+  "type\r\n"
+  "     other than AcpiTable header. The actual header can refer to the ACPI "
+  "spec\r\n"
+  "     6.3\r\n"
+  "     Extra A. Particular types:\r\n"
+  "       APIC  - Multiple APIC Description Table (MADT)\r\n"
+  "       BGRT  - Boot Graphics Resource Table\r\n"
+  "       DBG2  - Debug Port Table 2\r\n"
+  "       DSDT  - Differentiated System Description Table\r\n"
+  "       FACP  - Fixed ACPI Description Table (FADT)\r\n"
+  "       GTDT  - Generic Timer Description Table\r\n"
+  "       IORT  - IO Remapping Table\r\n"
+  "       MCFG  - Memory Mapped Config Space Base Address Description Table\r\n"
+  "       PPTT  - Processor Properties Topology Table\r\n"
+  "       RSDP  - Root System Description Pointer\r\n"
+  "       SLIT  - System Locality Information Table\r\n"
+  "       SPCR  - Serial Port Console Redirection Table\r\n"
+  "       SRAT  - System Resource Affinity Table\r\n"
+  "       SSDT  - Secondary SystemDescription Table\r\n"
+  "       XSDT  - Extended System Description Table\r\n"
+  " \r\n"
+  "  Table details correspond to those in 'Advanced Configuration and Power\r\n"
+  "  Interface Specification' Version 6.3 [January 2019]\r\n"
+  "  (https://uefi.org/specifications)\r\n"
+  "  "
+  " \r\n"
+  "  NOTE: The nature of the ACPI standard means that almost all tables in "
+  "6.1\r\n"
+  "        will be 'backwards compatible' with prior version of the "
+  "specification\r\n"
+  "        in terms of structure, so formatted output should be correct. The "
+  "main\r\n"
+  "        exception will be that previously 'reserved' fields will be "
+  "reported\r\n"
+  "        with new names, where they have been added in later versions of "
+  "the\r\n"
+  "        specification.\r\n"
+  " \r\n"
+  " \r\n"
+  "EXAMPLES:\r\n"
+  "  * To display a list of the installed table types:\r\n"
+  "    fs0:\\> AcpiViewApp.efi -l\r\n"
+  " \r\n"
+  "  * To parse and display a specific table type:\r\n"
+  "    fs0:\\> AcpiViewApp.efi -s GTDT\r\n"
+  " \r\n"
+  "  * To save a binary dump of the contents of a table to a file\r\n"
+  "    in the current working directory:\r\n"
+  "    fs0:\\> AcpiViewApp.efi -s DSDT -d\r\n"
+  " \r\n"
+  "  * To display contents of all ACPI tables:\r\n"
+  "    fs0:\\> AcpiViewApp.efi\r\n"
+  " \r\n";
+
+/**
+  Determine if the user wants to display by checking for presence
+  of '/?' or '--help' on command line. We cannot override '-?' shell
+  command line handling.
+
+  @retval EFI_SUCCESS             No help was printed
+  @retval EFI_INVALID_PARAMETER   Help was printed
+**/
+STATIC
+EFI_STATUS
+CheckForHelpRequest (
+  EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUS                    Status;
+  EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
+  UINTN                         Index;
+
+  Status = gBS->HandleProtocol (
+    ImageHandle, 
+    &gEfiShellParametersProtocolGuid,
+    (VOID **)&ShellParameters
+    );
+  if (EFI_ERROR(Status)) {
+    return Status;
+  }
+
+  for (Index = 1; Index < ShellParameters->Argc; Index++) {
+    if ((StrCmp (ShellParameters->Argv[Index], L"/?") == 0) ||
+        (StrCmp (ShellParameters->Argv[Index], L"--help") == 0))  {
+      Print (mAcpiViewAppHelp);
+      return EFI_INVALID_PARAMETER;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Application Entry Point wrapper around the shell command
+
+  @param[in] ImageHandle  Handle to the Image (NULL if internal).
+  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
+**/
+EFI_STATUS
+EFIAPI
+AcpiViewAppMain (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS Status;
+
+  Status = CheckForHelpRequest (ImageHandle);
+
+  // Do not run code if help was printed
+  if (Status != EFI_INVALID_PARAMETER) {
+    Status = ShellCommandRunAcpiView (gImageHandle, SystemTable);
+  }
+
+  return Status;
+}
diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
new file mode 100644
index 000000000000..28e724fa1909
--- /dev/null
+++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
@@ -0,0 +1,31 @@
+##  @file
+#  EFI application that displays and verifies ACPI tables
+#
+#  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = AcpiViewApp
+  FILE_GUID                      = 46361B5B-AF17-41FF-95F9-E1BCE08435B9
+  MODULE_TYPE                    = UEFI_APPLICATION
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = AcpiViewAppMain
+
+[Sources.common]
+  AcpiViewApp.c
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  ShellPkg/ShellPkg.dec
+
+[LibraryClasses]
+  UefiBootServicesTableLib
+  UefiLib
+  BaseLib
+  UefiApplicationEntryPoint
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index b7ee856b3a16..1ed82ee7aca3 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -2,7 +2,7 @@
 # Shell Package
 #
 # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
-# Copyright (c) 2018, Arm Limited. All rights reserved.<BR>
+# Copyright (c) 2018 - 2020, Arm Limited. All rights reserved.<BR>
 # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #    SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -143,6 +143,10 @@ [Components]
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
   ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
+  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf {
+    <LibraryClasses>
+      NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+  }
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.24.1.windows.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method
  2020-05-21 18:44 ` [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
@ 2020-06-12  2:40   ` Gao, Zhichao
  0 siblings, 0 replies; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:40 UTC (permalink / raw)
  To: Tomas Pilar, devel@edk2.groups.io; +Cc: nd@arm.com, Ni, Ray

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: Tomas Pilar <Tomas.Pilar@arm.com>
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method
> 
> The error and warning counters are reset in the AcpiView main method.
> This improves reusability of the main method.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> index 84ffb3595750..f1a95b7b8f03 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> @@ -424,6 +424,10 @@ AcpiView (
>    EfiConfigurationTable = NULL;
>    OriginalAttribute = 0;
> 
> +  // Reset The error/warning counters
> +  ResetErrorCount ();
> +  ResetWarningCount ();
> +
>    // Search the table for an entry that matches the ACPI Table Guid
>    FoundAcpiTable = FALSE;
>    for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { @@ -
> 566,10 +570,6 @@ ShellCommandRunAcpiView (
>    Package = NULL;
>    TmpDumpFileHandle = NULL;
> 
> -  // Reset The error/warning counters
> -  ResetErrorCount ();
> -  ResetWarningCount ();
> -
>    Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam,
> TRUE);
>    if (EFI_ERROR (Status)) {
>      if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
> --
> 2.24.1.windows.2
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration
  2020-05-21 18:44 ` [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
@ 2020-06-12  2:40   ` Gao, Zhichao
  0 siblings, 0 replies; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:40 UTC (permalink / raw)
  To: Tomas Pilar, devel@edk2.groups.io; +Cc: nd@arm.com, Ni, Ray

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: Tomas Pilar <Tomas.Pilar@arm.com>
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration
> 
> A new file and header (AcpiViewConfig.[ch]) is created that houses the user
> configuration. This declutters the core code and improves modularity of the
> design.
> 
> The module level symbols for verbosity, table selection, and highlighting are
> refactored into the new file.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c                    |   1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c               |   1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      | 237
> +++++++++----------------------------------------------------------
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                      |  95 ------
> ---------------------
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c                | 246
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h                | 177
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c       |
> 1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c       |
> 1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
> |   1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c       |
> 1 +
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c       |
> 1 +
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i
> nf |  32 ++++-----
>  12 files changed, 479 insertions(+), 315 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> index 3f12a33050a4..02f6d771c7e1 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> @@ -10,6 +10,7 @@
>  #include <Library/UefiBootServicesTableLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiView.h"
> +#include "AcpiViewConfig.h"
> 
>  STATIC UINT32   gIndent;
>  STATIC UINT32   mTableErrorCount;
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
> index d5b9eee52323..4b618f131eac 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
> @@ -17,6 +17,7 @@
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
>  #include "AcpiView.h"
> +#include "AcpiViewConfig.h"
> 
>  #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)  #include
> "Arm/SbbrValidator.h"
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> index f1a95b7b8f03..2f7395c23bce 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> @@ -20,6 +20,7 @@
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
>  #include "AcpiView.h"
> +#include "AcpiViewConfig.h"
>  #include "UefiShellAcpiViewCommandLib.h"
> 
>  #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) @@ -28,17 +29,8
> @@
> 
>  EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
> 
> -// Report variables
> -STATIC UINT32             mSelectedAcpiTable;
> -STATIC CONST CHAR16*      mSelectedAcpiTableName;
> -STATIC BOOLEAN            mSelectedAcpiTableFound;
> -STATIC EREPORT_OPTION     mReportType;
>  STATIC UINT32             mTableCount;
>  STATIC UINT32             mBinTableCount;
> -STATIC BOOLEAN            mConsistencyCheck;
> -STATIC BOOLEAN            mColourHighlighting;
> -STATIC BOOLEAN            mMandatoryTableValidate;
> -STATIC UINTN              mMandatoryTableSpec;
> 
>  /**
>    An array of acpiview command line parameters.
> @@ -53,142 +45,6 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
>    {NULL, TypeMax}
>  };
> 
> -/**
> -  This function returns the colour highlighting status.
> -
> -  @retval TRUE if colour highlighting is enabled.
> -**/
> -BOOLEAN
> -GetColourHighlighting (
> -  VOID
> -  )
> -{
> -  return mColourHighlighting;
> -}
> -
> -/**
> -  This function sets the colour highlighting status.
> -
> -  @param  Highlight       The Highlight status.
> -
> -**/
> -VOID
> -SetColourHighlighting (
> -  BOOLEAN Highlight
> -  )
> -{
> -  mColourHighlighting = Highlight;
> -}
> -
> -/**
> -  This function returns the consistency checking status.
> -
> -  @retval TRUE if consistency checking is enabled.
> -**/
> -BOOLEAN
> -GetConsistencyChecking (
> -  VOID
> -  )
> -{
> -  return mConsistencyCheck;
> -}
> -
> -/**
> -  This function sets the consistency checking status.
> -
> -  @param  ConsistencyChecking   The consistency checking status.
> -
> -**/
> -VOID
> -SetConsistencyChecking (
> -  BOOLEAN ConsistencyChecking
> -  )
> -{
> -  mConsistencyCheck = ConsistencyChecking; -}
> -
> -/**
> -  This function returns the ACPI table requirements validation flag.
> -
> -  @retval TRUE if check for mandatory table presence should be performed.
> -**/
> -BOOLEAN
> -GetMandatoryTableValidate (
> -  VOID
> -  )
> -{
> -  return mMandatoryTableValidate;
> -}
> -
> -/**
> -  This function sets the ACPI table requirements validation flag.
> -
> -  @param  Validate    Enable/Disable ACPI table requirements validation.
> -**/
> -VOID
> -SetMandatoryTableValidate (
> -  BOOLEAN Validate
> -  )
> -{
> -  mMandatoryTableValidate = Validate;
> -}
> -
> -/**
> -  This function returns the identifier of specification to validate ACPI table
> -  requirements against.
> -
> -  @return   ID of specification listing mandatory tables.
> -**/
> -UINTN
> -GetMandatoryTableSpec (
> -  VOID
> -  )
> -{
> -  return mMandatoryTableSpec;
> -}
> -
> -/**
> -  This function sets the identifier of specification to validate ACPI table
> -  requirements against.
> -
> -  @param  Spec      ID of specification listing mandatory tables.
> -**/
> -VOID
> -SetMandatoryTableSpec (
> -  UINTN Spec
> -  )
> -{
> -  mMandatoryTableSpec = Spec;
> -}
> -
> -/**
> -  This function returns the report options.
> -
> -  @retval Returns the report option.
> -**/
> -STATIC
> -EREPORT_OPTION
> -GetReportOption (
> -  VOID
> -  )
> -{
> -  return mReportType;
> -}
> -
> -/**
> -  This function returns the selected ACPI table.
> -
> -  @retval Returns signature of the selected ACPI table.
> -**/
> -STATIC
> -UINT32
> -GetSelectedAcpiTable (
> -  VOID
> -  )
> -{
> -  return mSelectedAcpiTable;
> -}
> -
>  /**
>    This function dumps the ACPI table to a file.
> 
> @@ -205,19 +61,21 @@ DumpAcpiTableToFile (
>    IN CONST UINTN   Length
>    )
>  {
> -  EFI_STATUS         Status;
> -  CHAR16             FileNameBuffer[MAX_FILE_NAME_LEN];
> -  SHELL_FILE_HANDLE  DumpFileHandle;
> -  UINTN              TransferBytes;
> +  EFI_STATUS          Status;
> +  CHAR16              FileNameBuffer[MAX_FILE_NAME_LEN];
> +  SHELL_FILE_HANDLE   DumpFileHandle;
> +  UINTN               TransferBytes;
> +  SELECTED_ACPI_TABLE SelectedTable;
> 
>    DumpFileHandle = NULL;
>    TransferBytes = Length;
> +  GetSelectedAcpiTable (&SelectedTable);
> 
>    UnicodeSPrint (
>      FileNameBuffer,
>      sizeof (FileNameBuffer),
>      L".\\%s%04d.bin",
> -    mSelectedAcpiTableName,
> +    SelectedTable.Name,
>      mBinTableCount++
>      );
> 
> @@ -273,10 +131,11 @@ ProcessTableReportOptions (
>    IN CONST UINT32  Length
>    )
>  {
> -  UINTN   OriginalAttribute;
> -  UINT8*  SignaturePtr;
> -  BOOLEAN Log;
> -  BOOLEAN HighLight;
> +  UINTN               OriginalAttribute;
> +  UINT8              *SignaturePtr;
> +  BOOLEAN             Log;
> +  BOOLEAN             HighLight;
> +  SELECTED_ACPI_TABLE SelectedTable;
> 
>    //
>    // set local variables to suppress incorrect compiler/analyzer warnings @@ -
> 285,15 +144,16 @@ ProcessTableReportOptions (
>    SignaturePtr = (UINT8*)(UINTN)&Signature;
>    Log = FALSE;
>    HighLight = GetColourHighlighting ();
> +  GetSelectedAcpiTable (&SelectedTable);
> 
>    switch (GetReportOption ()) {
>      case ReportAll:
>        Log = TRUE;
>        break;
>      case ReportSelected:
> -      if (Signature == GetSelectedAcpiTable ()) {
> +      if (Signature == SelectedTable.Type) {
>          Log = TRUE;
> -        mSelectedAcpiTableFound = TRUE;
> +        SelectedTable.Found = TRUE;
>        }
>        break;
>      case ReportTableList:
> @@ -321,8 +181,8 @@ ProcessTableReportOptions (
>          );
>        break;
>      case ReportDumpBinFile:
> -      if (Signature == GetSelectedAcpiTable ()) {
> -        mSelectedAcpiTableFound = TRUE;
> +      if (Signature == SelectedTable.Type) {
> +        SelectedTable.Found = TRUE;
>          DumpAcpiTableToFile (TablePtr, Length);
>        }
>        break;
> @@ -356,37 +216,7 @@ ProcessTableReportOptions (
>    return Log;
>  }
> 
> -/**
> -  This function converts a string to ACPI table signature.
> -
> -  @param [in] Str   Pointer to the string to be converted to the
> -                    ACPI table signature.
> 
> -  @retval The ACPI table signature.
> -**/
> -STATIC
> -UINT32
> -ConvertStrToAcpiSignature (
> -  IN  CONST CHAR16* Str
> -  )
> -{
> -  UINT8 Index;
> -  CHAR8 Ptr[4];
> -
> -  ZeroMem (Ptr, sizeof (Ptr));
> -  Index = 0;
> -
> -  // Convert to Upper case and convert to ASCII
> -  while ((Index < 4) && (Str[Index] != 0)) {
> -    if (Str[Index] >= L'a' && Str[Index] <= L'z') {
> -      Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
> -    } else {
> -      Ptr[Index] = (CHAR8)Str[Index];
> -    }
> -    Index++;
> -  }
> -  return *(UINT32*)Ptr;
> -}
> 
>  /**
>    This function iterates the configuration table entries in the @@ -417,6 +247,7
> @@ AcpiView (
>    UINT8                    RsdpRevision;
>    PARSE_ACPI_TABLE_PROC    RsdpParserProc;
>    BOOLEAN                  Trace;
> +  SELECTED_ACPI_TABLE      SelectedTable;
> 
>    //
>    // set local variables to suppress incorrect compiler/analyzer warnings @@ -
> 428,6 +259,9 @@ AcpiView (
>    ResetErrorCount ();
>    ResetWarningCount ();
> 
> +  // Retrieve the user selection of ACPI table to process
> + GetSelectedAcpiTable (&SelectedTable);
> +
>    // Search the table for an entry that matches the ACPI Table Guid
>    FoundAcpiTable = FALSE;
>    for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { @@ -
> 496,7 +330,7 @@ AcpiView (
>    if (ReportTableList != ReportOption) {
>      if (((ReportSelected == ReportOption)  ||
>           (ReportDumpBinFile == ReportOption)) &&
> -        (!mSelectedAcpiTableFound)) {
> +        (!SelectedTable.Found)) {
>        Print (L"\nRequested ACPI Table not found.\n");
>      } else if (GetConsistencyChecking () &&
>                 (ReportDumpBinFile != ReportOption)) { @@ -554,17 +388,12 @@
> ShellCommandRunAcpiView (
>    CHAR16*            ProblemParam;
>    SHELL_FILE_HANDLE  TmpDumpFileHandle;
>    CONST CHAR16*      MandatoryTableSpecStr;
> +  CONST CHAR16       *SelectedTableName;
> 
>    // Set Defaults
> -  mReportType = ReportAll;
>    mTableCount = 0;
>    mBinTableCount = 0;
> -  mSelectedAcpiTable = 0;
> -  mSelectedAcpiTableName = NULL;
> -  mSelectedAcpiTableFound = FALSE;
> -  mConsistencyCheck = TRUE;
> -  mMandatoryTableValidate = FALSE;
> -  mMandatoryTableSpec = 0;
> +  AcpiConfigSetDefaults ();
> 
>    ShellStatus = SHELL_SUCCESS;
>    Package = NULL;
> @@ -671,25 +500,23 @@ ShellCommandRunAcpiView (
>        }
> 
>        if (ShellCommandLineGetFlag (Package, L"-l")) {
> -        mReportType = ReportTableList;
> +        SetReportOption (ReportTableList);
>        } else {
> -        mSelectedAcpiTableName = ShellCommandLineGetValue (Package, L"-s");
> -        if (mSelectedAcpiTableName != NULL) {
> -          mSelectedAcpiTable = (UINT32)ConvertStrToAcpiSignature (
> -                                         mSelectedAcpiTableName
> -                                         );
> -          mReportType = ReportSelected;
> +        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
> +        if (SelectedTableName != NULL) {
> +          SelectAcpiTable (SelectedTableName);
> +          SetReportOption (ReportSelected);
> 
>            if (ShellCommandLineGetFlag (Package, L"-d"))  {
>              // Create a temporary file to check if the media is writable.
>              CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
> -            mReportType = ReportDumpBinFile;
> +            SetReportOption (ReportDumpBinFile);
> 
>              UnicodeSPrint (
>                FileNameBuffer,
>                sizeof (FileNameBuffer),
>                L".\\%s%04d.tmp",
> -              mSelectedAcpiTableName,
> +              SelectedTableName,
>                mBinTableCount
>                );
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> index be65564c86a6..92d64a88814d 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> @@ -23,17 +23,6 @@
>  **/
>  #define RSDP_LENGTH_OFFSET   20
> 
> -/**
> -  The EREPORT_OPTION enum describes ACPI table Reporting options.
> -**/
> -typedef enum ReportOption {
> -  ReportAll,            ///< Report All tables.
> -  ReportSelected,       ///< Report Selected table.
> -  ReportTableList,      ///< Report List of tables.
> -  ReportDumpBinFile,    ///< Dump selected table to a file.
> -  ReportMax,
> -} EREPORT_OPTION;
> -
>  /**
>    This function resets the ACPI table error counter to Zero.
>  **/
> @@ -70,90 +59,6 @@ GetWarningCount (
>    VOID
>    );
> 
> -/**
> -  This function returns the colour highlighting status.
> -
> -  @retval TRUE if colour highlighting is enabled.
> -**/
> -BOOLEAN
> -GetColourHighlighting (
> -  VOID
> -  );
> -
> -/**
> -  This function sets the colour highlighting status.
> -
> -  @param  Highlight       The Highlight status.
> -
> -**/
> -VOID
> -SetColourHighlighting (
> -  BOOLEAN Highlight
> -  );
> -
> -/**
> -  This function returns the consistency checking status.
> -
> -  @retval TRUE if consistency checking is enabled.
> -**/
> -BOOLEAN
> -GetConsistencyChecking (
> -  VOID
> -  );
> -
> -/**
> -  This function sets the consistency checking status.
> -
> -  @param  ConsistencyChecking   The consistency checking status.
> -
> -**/
> -VOID
> -SetConsistencyChecking (
> -  BOOLEAN ConsistencyChecking
> -  );
> -
> -/**
> -  This function returns the ACPI table requirements validation flag.
> -
> -  @retval TRUE if check for mandatory table presence should be performed.
> -**/
> -BOOLEAN
> -GetMandatoryTableValidate (
> -  VOID
> -  );
> -
> -/**
> -  This function sets the ACPI table requirements validation flag.
> -
> -  @param  Validate    Enable/Disable ACPI table requirements validation.
> -**/
> -VOID
> -SetMandatoryTableValidate (
> -  BOOLEAN Validate
> -  );
> -
> -/**
> -  This function returns the identifier of specification to validate ACPI table
> -  requirements against.
> -
> -  @return   ID of specification listing mandatory tables.
> -**/
> -UINTN
> -GetMandatoryTableSpec (
> -  VOID
> -  );
> -
> -/**
> -  This function sets the identifier of specification to validate ACPI table
> -  requirements against.
> -
> -  @param  Spec      ID of specification listing mandatory tables.
> -**/
> -VOID
> -SetMandatoryTableSpec (
> -  UINTN Spec
> -  );
> -
>  /**
>    This function processes the table reporting options for the ACPI table.
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
> new file mode 100644
> index 000000000000..6f6d1a9d52c1
> --- /dev/null
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
> @@ -0,0 +1,246 @@
> +/** @file
> +  State and accessors for 'acpiview' configuration.
> +
> +  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +
> +#include "AcpiViewConfig.h"
> +
> +// Report variables
> +STATIC BOOLEAN        mConsistencyCheck;
> +STATIC BOOLEAN        mColourHighlighting;
> +STATIC EREPORT_OPTION mReportType;
> +STATIC BOOLEAN        mMandatoryTableValidate;
> +STATIC UINTN          mMandatoryTableSpec;
> +
> +// User selection of which ACPI table should be checked
> +SELECTED_ACPI_TABLE mSelectedAcpiTable;
> +
> +/**
> + Reset the AcpiView user configuration to defaults **/ VOID EFIAPI
> +AcpiConfigSetDefaults (
> +  VOID
> +  )
> +{
> +  mReportType = ReportAll;
> +  mSelectedAcpiTable.Type = 0;
> +  mSelectedAcpiTable.Name = NULL;
> +  mSelectedAcpiTable.Found = FALSE;
> +  mConsistencyCheck = TRUE;
> +  mMandatoryTableValidate = FALSE;
> +  mMandatoryTableSpec = 0;
> +}
> +
> +/**
> +  This function converts a string to ACPI table signature.
> +
> +  @param [in] Str   Pointer to the string to be converted to the
> +                    ACPI table signature.
> +
> +  @retval The ACPI table signature.
> +**/
> +STATIC
> +UINT32
> +ConvertStrToAcpiSignature (
> +  IN CONST CHAR16 *Str
> +  )
> +{
> +  UINT8 Index;
> +  CHAR8 Ptr[4];
> +
> +  ZeroMem (Ptr, sizeof (Ptr));
> +  Index = 0;
> +
> +  // Convert to Upper case and convert to ASCII
> +  while ((Index < 4) && (Str[Index] != 0)) {
> +    if (Str[Index] >= L'a' && Str[Index] <= L'z') {
> +      Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
> +    } else {
> +      Ptr[Index] = (CHAR8)Str[Index];
> +    }
> +    Index++;
> +  }
> +  return *(UINT32 *) Ptr;
> +}
> +
> +/**
> +  This function selects an ACPI table in current context.
> +  The string name of the table is converted into UINT32
> +  table signature.
> +
> +  @param [in] TableName The name of the ACPI table to select.
> +**/
> +VOID
> +EFIAPI
> +SelectAcpiTable (
> +  IN CONST CHAR16 *TableName
> +  )
> +{
> +  ASSERT (TableName != NULL);
> +
> +  mSelectedAcpiTable.Name = TableName;
> +  mSelectedAcpiTable.Type = ConvertStrToAcpiSignature
> +(mSelectedAcpiTable.Name); }
> +
> +/**
> +  This function returns the selected ACPI table.
> +
> +  @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
> +**/
> +VOID
> +EFIAPI
> +GetSelectedAcpiTable (
> +  OUT SELECTED_ACPI_TABLE *SelectedAcpiTable
> +  )
> +{
> +  *SelectedAcpiTable = mSelectedAcpiTable; }
> +
> +/**
> +  This function returns the colour highlighting status.
> +
> +  @retval TRUE Colour highlighting is enabled.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetColourHighlighting (
> +  VOID
> +  )
> +{
> +  return mColourHighlighting;
> +}
> +
> +/**
> +  This function sets the colour highlighting status.
> +
> +  @param [in] Highlight The highlight status.
> +**/
> +VOID
> +EFIAPI
> +SetColourHighlighting (
> +  BOOLEAN Highlight
> +  )
> +{
> +  mColourHighlighting = Highlight;
> +}
> +
> +/**
> +  This function returns the consistency checking status.
> +
> +  @retval TRUE Consistency checking is enabled.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetConsistencyChecking (
> +  VOID
> +  )
> +{
> +  return mConsistencyCheck;
> +}
> +
> +/**
> +  This function sets the consistency checking status.
> +
> +  @param [in] ConsistencyChecking   The consistency checking status.
> +**/
> +VOID
> +EFIAPI
> +SetConsistencyChecking (
> +  BOOLEAN ConsistencyChecking
> +  )
> +{
> +  mConsistencyCheck = ConsistencyChecking; }
> +
> +/**
> +  This function returns the report options.
> +
> +  @return The current report option.
> +**/
> +EREPORT_OPTION
> +EFIAPI
> +GetReportOption (
> +  VOID
> +  )
> +{
> +  return mReportType;
> +}
> +
> +/**
> +  This function sets the report options.
> +
> +  @param [in] ReportType The report option to set.
> +**/
> +VOID
> +EFIAPI
> +SetReportOption (
> +  EREPORT_OPTION ReportType
> +  )
> +{
> +  mReportType = ReportType;
> +}
> +
> +/**
> +  This function returns the ACPI table requirements validation flag.
> +
> +  @retval TRUE Check for mandatory table presence should be performed.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetMandatoryTableValidate (
> +  VOID
> +  )
> +{
> +  return mMandatoryTableValidate;
> +}
> +
> +/**
> +  This function sets the ACPI table requirements validation flag.
> +
> +  @param [in] Validate Enable/Disable ACPI table requirements validation.
> +**/
> +VOID
> +EFIAPI
> +SetMandatoryTableValidate (
> +  BOOLEAN Validate
> +  )
> +{
> +  mMandatoryTableValidate = Validate;
> +}
> +
> +/**
> +  This function returns the identifier of specification to validate
> +ACPI table
> +  requirements against.
> +
> +  @return ID of specification listing mandatory tables.
> +**/
> +UINTN
> +EFIAPI
> +GetMandatoryTableSpec (
> +  VOID
> +  )
> +{
> +  return mMandatoryTableSpec;
> +}
> +
> +/**
> +  This function sets the identifier of specification to validate ACPI
> +table
> +  requirements against.
> +
> +  @param [in] Spec ID of specification listing mandatory tables.
> +**/
> +VOID
> +EFIAPI
> +SetMandatoryTableSpec (
> +  UINTN Spec
> +  )
> +{
> +  mMandatoryTableSpec = Spec;
> +}
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
> new file mode 100644
> index 000000000000..fc99624e41dc
> --- /dev/null
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
> @@ -0,0 +1,177 @@
> +/** @file
> +  Header file for 'acpiview' configuration.
> +
> +  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#ifndef ACPI_VIEW_CONFIG_H_
> +#define ACPI_VIEW_CONFIG_H_
> +
> +/**
> +  This function returns the colour highlighting status.
> +
> +  @retval TRUE Colour highlighting is enabled.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetColourHighlighting (
> +  VOID
> +  );
> +
> +/**
> +  This function sets the colour highlighting status.
> +
> +  @param [in] Highlight The highlight status.
> +**/
> +VOID
> +EFIAPI
> +SetColourHighlighting (
> +  BOOLEAN Highlight
> +  );
> +
> +/**
> +  This function returns the consistency checking status.
> +
> +  @retval TRUE Consistency checking is enabled.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetConsistencyChecking (
> +  VOID
> +  );
> +
> +/**
> +  This function sets the consistency checking status.
> +
> +  @param [in] ConsistencyChecking   The consistency checking status.
> +**/
> +VOID
> +EFIAPI
> +SetConsistencyChecking (
> +  BOOLEAN ConsistencyChecking
> +  );
> +
> +/**
> +  This function returns the ACPI table requirements validation flag.
> +
> +  @retval TRUE Check for mandatory table presence should be performed.
> +**/
> +BOOLEAN
> +EFIAPI
> +GetMandatoryTableValidate (
> +  VOID
> +  );
> +
> +/**
> +  This function sets the ACPI table requirements validation flag.
> +
> +  @param [in] Validate Enable/Disable ACPI table requirements validation.
> +**/
> +VOID
> +EFIAPI
> +SetMandatoryTableValidate (
> +  BOOLEAN Validate
> +  );
> +
> +/**
> +  This function returns the identifier of specification to validate
> +ACPI table
> +  requirements against.
> +
> +  @return ID of specification listing mandatory tables.
> +**/
> +UINTN
> +EFIAPI
> +GetMandatoryTableSpec (
> +  VOID
> +  );
> +
> +/**
> +  This function sets the identifier of specification to validate ACPI
> +table
> +  requirements against.
> +
> +  @param [in] Spec ID of specification listing mandatory tables.
> +**/
> +VOID
> +EFIAPI
> +SetMandatoryTableSpec (
> +  UINTN Spec
> +  );
> +
> +/**
> +  The EREPORT_OPTION enum describes ACPI table Reporting options.
> +**/
> +typedef enum {
> +  ReportAll,          ///< Report All tables.
> +  ReportSelected,     ///< Report Selected table.
> +  ReportTableList,    ///< Report List of tables.
> +  ReportDumpBinFile,  ///< Dump selected table to a file.
> +  ReportMax,
> +} EREPORT_OPTION;
> +
> +/**
> +  This function returns the report options.
> +
> +  @return The current report option.
> +**/
> +EREPORT_OPTION
> +EFIAPI
> +GetReportOption (
> +  VOID
> +  );
> +
> +/**
> +  This function sets the report options.
> +
> +  @param [in] ReportType The report option to set.
> +**/
> +VOID
> +EFIAPI
> +SetReportOption (
> +  EREPORT_OPTION ReportType
> +  );
> +
> +/**
> +  A structure holding the user selection detailing which
> +  ACPI table is to be examined by the AcpiView code.
> +**/
> +typedef struct {
> +  UINT32              Type;    ///< 32bit signature of the selected ACPI table.
> +  CONST CHAR16*       Name;    ///< User friendly name of the selected ACPI
> table.
> +  BOOLEAN             Found;   ///< The selected table has been found in the system.
> +} SELECTED_ACPI_TABLE;
> +
> +/**
> +  This function returns the selected ACPI table.
> +
> +  @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
> +**/
> +VOID
> +EFIAPI
> +GetSelectedAcpiTable (
> +  OUT SELECTED_ACPI_TABLE* SelectedAcpiTable
> +  );
> +
> +/**
> +  This function selects an ACPI table in current context.
> +  The string name of the table is converted into UINT32
> +  table signature.
> +
> +  @param [in] TableName The name of the ACPI table to select.
> +**/
> +VOID
> +EFIAPI
> +SelectAcpiTable (
> +  CONST CHAR16* TableName
> +  );
> +
> +/**
> +  Reset the AcpiView user configuration to defaults.
> +**/
> +VOID
> +EFIAPI
> +AcpiConfigSetDefaults (
> +  VOID
> +  );
> +
> +#endif // ACPI_VIEW_CONFIG_H_
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
> index bdd30ff45c61..d02fc4929d6f 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPars
> +++ er.c
> @@ -12,6 +12,7 @@
>  #include <Library/UefiLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
> +#include "AcpiViewConfig.h"
> 
>  // "The number of GT Block Timers must be less than or equal to 8"
>  #define GT_BLOCK_TIMER_COUNT_MAX 8
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
> index 9a006a01448b..f7447947b230 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPars
> +++ er.c
> @@ -13,6 +13,7 @@
>  #include <Library/UefiLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
> +#include "AcpiViewConfig.h"
> 
>  // Local variables
>  STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
> index f85d2b36532c..15aa2392b60c 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPars
> +++ er.c
> @@ -15,6 +15,7 @@
>  #include <Library/UefiLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
> +#include "AcpiViewConfig.h"
>  #include "MadtParser.h"
> 
>  // Local Variables
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
> index 0db272c16af0..acd2b81bb325 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPars
> +++ er.c
> @@ -13,6 +13,7 @@
>  #include <Library/UefiLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiView.h"
> +#include "AcpiViewConfig.h"
>  #include "PpttParser.h"
> 
>  // Local variables
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
> index 6f66be68cc0b..b9b67820b89f 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars
> +++ er.c
> @@ -13,6 +13,7 @@
>  #include <Library/UefiLib.h>
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
> +#include "AcpiViewConfig.h"
> 
>  // Local Variables
>  STATIC CONST UINT8* SratRAType;
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.inf
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.inf
> index d21ecd40a8cf..92de2391b09f 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.inf
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.inf
> @@ -19,15 +19,14 @@ [Defines]
>    DESTRUCTOR                     = UefiShellAcpiViewCommandLibDestructor
> 
>  [Sources.common]
> -  UefiShellAcpiViewCommandLib.uni
> -  UefiShellAcpiViewCommandLib.c
> -  UefiShellAcpiViewCommandLib.h
> -  AcpiParser.h
> -  AcpiTableParser.h
> -  AcpiView.h
>    AcpiParser.c
> +  AcpiParser.h
>    AcpiTableParser.c
> +  AcpiTableParser.h
>    AcpiView.c
> +  AcpiView.h
> +  AcpiViewConfig.c
> +  AcpiViewConfig.h
>    Parsers/Bgrt/BgrtParser.c
>    Parsers/Dbg2/Dbg2Parser.c
>    Parsers/Dsdt/DsdtParser.c
> @@ -36,40 +35,43 @@ [Sources.common]
>    Parsers/Gtdt/GtdtParser.c
>    Parsers/Iort/IortParser.c
>    Parsers/Madt/MadtParser.c
> +  Parsers/Madt/MadtParser.h
>    Parsers/Mcfg/McfgParser.c
>    Parsers/Pptt/PpttParser.c
> +  Parsers/Pptt/PpttParser.h
>    Parsers/Rsdp/RsdpParser.c
>    Parsers/Slit/SlitParser.c
>    Parsers/Spcr/SpcrParser.c
>    Parsers/Srat/SratParser.c
>    Parsers/Ssdt/SsdtParser.c
>    Parsers/Xsdt/XsdtParser.c
> -  Parsers/Madt/MadtParser.h
> -  Parsers/Pptt/PpttParser.h
> +  UefiShellAcpiViewCommandLib.c
> +  UefiShellAcpiViewCommandLib.h
> +  UefiShellAcpiViewCommandLib.uni
> 
>  [Sources.ARM, Sources.AARCH64]
>    Arm/SbbrValidator.h
>    Arm/SbbrValidator.c
> 
>  [Packages]
> +  MdeModulePkg/MdeModulePkg.dec
>    MdePkg/MdePkg.dec
>    ShellPkg/ShellPkg.dec
> -  MdeModulePkg/MdeModulePkg.dec
> 
>  [LibraryClasses]
> -  MemoryAllocationLib
>    BaseLib
>    BaseMemoryLib
>    DebugLib
> +  FileHandleLib
> +  HiiLib
> +  MemoryAllocationLib
> +  PcdLib
> +  PrintLib
>    ShellCommandLib
>    ShellLib
> +  UefiBootServicesTableLib
>    UefiLib
>    UefiRuntimeServicesTableLib
> -  UefiBootServicesTableLib
> -  PcdLib
> -  HiiLib
> -  PrintLib
> -  FileHandleLib
> 
> 
>  [FixedPcd]
> --
> 2.24.1.windows.2
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset
  2020-05-21 18:44 ` [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
@ 2020-06-12  2:40   ` Gao, Zhichao
  0 siblings, 0 replies; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:40 UTC (permalink / raw)
  To: devel@edk2.groups.io, Tomas.Pilar@arm.com; +Cc: nd@arm.com, Ni, Ray

It is highly suggested to use the lower-case static and const. Except that:
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas Pilar
> (tpilar)
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset
> 
> The table count module level symbols are now reset when executing the core
> method, rather than the shell command wrapper.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> index 2f7395c23bce..c9654e52c434 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> @@ -255,6 +255,10 @@ AcpiView (
>    EfiConfigurationTable = NULL;
>    OriginalAttribute = 0;
> 
> +  // Reset Table counts
> +  mTableCount = 0;
> +  mBinTableCount = 0;
> +
>    // Reset The error/warning counters
>    ResetErrorCount ();
>    ResetWarningCount ();
> @@ -390,9 +394,7 @@ ShellCommandRunAcpiView (
>    CONST CHAR16*      MandatoryTableSpecStr;
>    CONST CHAR16       *SelectedTableName;
> 
> -  // Set Defaults
> -  mTableCount = 0;
> -  mBinTableCount = 0;
> +  // Set configuration defaults
>    AcpiConfigSetDefaults ();
> 
>    ShellStatus = SHELL_SUCCESS;
> --
> 2.24.1.windows.2
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing
  2020-05-21 18:44 ` [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
@ 2020-06-12  2:40   ` Gao, Zhichao
  0 siblings, 0 replies; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:40 UTC (permalink / raw)
  To: devel@edk2.groups.io, Tomas.Pilar@arm.com; +Cc: nd@arm.com, Ni, Ray

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas Pilar
> (tpilar)
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing
> 
> Parsing command line parameters is done in the shell command wrapper. This
> declutters the core code and improves modular design.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                    | 205 ------
> -----------------------------------------------------------
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                    |  18
> +++++-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
> | 218
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.
> h |  10 +++-
>  4 files changed, 240 insertions(+), 211 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> index c9654e52c434..a3160ed6f0a2 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> @@ -32,19 +32,6 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
>  STATIC UINT32             mTableCount;
>  STATIC UINT32             mBinTableCount;
> 
> -/**
> -  An array of acpiview command line parameters.
> -**/
> -STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
> -  {L"-q", TypeFlag},
> -  {L"-d", TypeFlag},
> -  {L"-h", TypeFlag},
> -  {L"-l", TypeFlag},
> -  {L"-s", TypeValue},
> -  {L"-r", TypeValue},
> -  {NULL, TypeMax}
> -};
> -
>  /**
>    This function dumps the ACPI table to a file.
> 
> @@ -228,7 +215,6 @@ ProcessTableReportOptions (
>            Returns EFI_UNSUPPORTED if the RSDP version is less than 2.
>            Returns EFI_SUCCESS     if successful.
>  **/
> -STATIC
>  EFI_STATUS
>  EFIAPI
>  AcpiView (
> @@ -372,194 +358,3 @@ AcpiView (
>    }
>    return EFI_SUCCESS;
>  }
> -
> -/**
> -  Function for 'acpiview' command.
> -
> -  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
> -  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
> -**/
> -SHELL_STATUS
> -EFIAPI
> -ShellCommandRunAcpiView (
> -  IN EFI_HANDLE        ImageHandle,
> -  IN EFI_SYSTEM_TABLE* SystemTable
> -  )
> -{
> -  EFI_STATUS         Status;
> -  SHELL_STATUS       ShellStatus;
> -  LIST_ENTRY*        Package;
> -  CHAR16*            ProblemParam;
> -  SHELL_FILE_HANDLE  TmpDumpFileHandle;
> -  CONST CHAR16*      MandatoryTableSpecStr;
> -  CONST CHAR16       *SelectedTableName;
> -
> -  // Set configuration defaults
> -  AcpiConfigSetDefaults ();
> -
> -  ShellStatus = SHELL_SUCCESS;
> -  Package = NULL;
> -  TmpDumpFileHandle = NULL;
> -
> -  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam,
> TRUE);
> -  if (EFI_ERROR (Status)) {
> -    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GEN_PROBLEM),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview",
> -        ProblemParam
> -        );
> -      FreePool (ProblemParam);
> -    } else {
> -      Print (L"acpiview: Error processing input parameter(s)\n");
> -    }
> -    ShellStatus = SHELL_INVALID_PARAMETER;
> -  } else {
> -    if (ShellCommandLineGetCount (Package) > 1) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GEN_TOO_MANY),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview"
> -        );
> -      ShellStatus = SHELL_INVALID_PARAMETER;
> -    } else if (ShellCommandLineGetFlag (Package, L"-?")) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GET_HELP_ACPIVIEW),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview"
> -        );
> -    } else if (ShellCommandLineGetFlag (Package, L"-s") &&
> -               ShellCommandLineGetValue (Package, L"-s") == NULL) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GEN_NO_VALUE),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview",
> -        L"-s"
> -        );
> -      ShellStatus = SHELL_INVALID_PARAMETER;
> -    } else if (ShellCommandLineGetFlag (Package, L"-r") &&
> -               ShellCommandLineGetValue (Package, L"-r") == NULL) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GEN_NO_VALUE),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview",
> -        L"-r"
> -        );
> -      ShellStatus = SHELL_INVALID_PARAMETER;
> -    } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
> -                ShellCommandLineGetFlag (Package, L"-l"))) {
> -      ShellPrintHiiEx (
> -        -1,
> -        -1,
> -        NULL,
> -        STRING_TOKEN (STR_GEN_TOO_MANY),
> -        gShellAcpiViewHiiHandle,
> -        L"acpiview"
> -        );
> -      ShellStatus = SHELL_INVALID_PARAMETER;
> -    } else if (ShellCommandLineGetFlag (Package, L"-d") &&
> -               !ShellCommandLineGetFlag (Package, L"-s")) {
> -        ShellPrintHiiEx (
> -          -1,
> -          -1,
> -          NULL,
> -          STRING_TOKEN (STR_GEN_MISSING_OPTION),
> -          gShellAcpiViewHiiHandle,
> -          L"acpiview",
> -          L"-s",
> -          L"-d"
> -          );
> -        ShellStatus = SHELL_INVALID_PARAMETER;
> -    } else {
> -      // Turn on colour highlighting if requested
> -      SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
> -
> -      // Surpress consistency checking if requested
> -      SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));
> -
> -      // Evaluate the parameters for mandatory ACPI table presence checks
> -      SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));
> -      MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");
> -
> -      if (MandatoryTableSpecStr != NULL) {
> -        SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));
> -      }
> -
> -      if (ShellCommandLineGetFlag (Package, L"-l")) {
> -        SetReportOption (ReportTableList);
> -      } else {
> -        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
> -        if (SelectedTableName != NULL) {
> -          SelectAcpiTable (SelectedTableName);
> -          SetReportOption (ReportSelected);
> -
> -          if (ShellCommandLineGetFlag (Package, L"-d"))  {
> -            // Create a temporary file to check if the media is writable.
> -            CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
> -            SetReportOption (ReportDumpBinFile);
> -
> -            UnicodeSPrint (
> -              FileNameBuffer,
> -              sizeof (FileNameBuffer),
> -              L".\\%s%04d.tmp",
> -              SelectedTableName,
> -              mBinTableCount
> -              );
> -
> -            Status = ShellOpenFileByName (
> -                       FileNameBuffer,
> -                       &TmpDumpFileHandle,
> -                       EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
> -                       EFI_FILE_MODE_CREATE,
> -                       0
> -                       );
> -
> -            if (EFI_ERROR (Status)) {
> -              ShellStatus = SHELL_INVALID_PARAMETER;
> -              TmpDumpFileHandle = NULL;
> -              ShellPrintHiiEx (
> -                -1,
> -                -1,
> -                NULL,
> -                STRING_TOKEN (STR_GEN_READONLY_MEDIA),
> -                gShellAcpiViewHiiHandle,
> -                L"acpiview"
> -                );
> -              goto Done;
> -            }
> -            // Delete Temporary file.
> -            ShellDeleteFile (&TmpDumpFileHandle);
> -          } // -d
> -        } // -s
> -      }
> -
> -      // Parse ACPI Table information
> -      Status = AcpiView (SystemTable);
> -      if (EFI_ERROR (Status)) {
> -        ShellStatus = SHELL_NOT_FOUND;
> -      }
> -    }
> -  }
> -
> -Done:
> -  if (Package != NULL) {
> -    ShellCommandLineFreeVarList (Package);
> -  }
> -  return ShellStatus;
> -}
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> index 92d64a88814d..d5b95f5ee707 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> @@ -64,7 +64,7 @@ GetWarningCount (
> 
>    @param [in] Signature The ACPI table Signature.
>    @param [in] TablePtr  Pointer to the ACPI table data.
> -  @param [in] Length    The length fo the ACPI table.
> +  @param [in] Length    The length of the ACPI table.
> 
>    @retval Returns TRUE if the ACPI table should be traced.
>  **/
> @@ -75,4 +75,20 @@ ProcessTableReportOptions (
>    IN CONST UINT32  Length
>    );
> 
> +/**
> +  This function iterates the configuration table entries in the
> +  system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
> +
> +  @param [in] SystemTable Pointer to the EFI system table.
> +
> +  @retval EFI_NOT_FOUND   The RSDP pointer was not found.
> +  @retval EFI_UNSUPPORTED The RSDP version was less than 2.
> +  @retval EFI_SUCCESS     The command was successful.
> +**/
> +EFI_STATUS
> +EFIAPI
> +AcpiView (
> +  IN EFI_SYSTEM_TABLE* SystemTable
> +  );
> +
>  #endif // ACPIVIEW_H_
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> index e0d5a8108552..c3942ad24e5b 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.c
> @@ -1,24 +1,44 @@
>  /** @file
>    Main file for 'acpiview' Shell command function.
> 
> -  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.<BR>
> +  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
>  #include <Guid/ShellLibHiiGuid.h>
>  #include <IndustryStandard/Acpi.h>
> +
> +#include <Library/BaseMemoryLib.h>
>  #include <Library/HiiLib.h>
> +#include <Library/MemoryAllocationLib.h> #include <Library/PrintLib.h>
>  #include <Library/ShellCommandLib.h>
> -#include <Library/UefiLib.h>
> +#include <Library/ShellLib.h>
>  #include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
>  #include <Uefi.h>
> +
>  #include "AcpiParser.h"
>  #include "AcpiTableParser.h"
>  #include "AcpiView.h"
> +#include "AcpiViewConfig.h"
>  #include "UefiShellAcpiViewCommandLib.h"
> 
>  CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
> 
> +/**
> +  An array of acpiview command line parameters.
> +**/
> +STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
> +  {L"-q", TypeFlag},
> +  {L"-d", TypeFlag},
> +  {L"-h", TypeFlag},
> +  {L"-l", TypeFlag},
> +  {L"-s", TypeValue},
> +  {L"-r", TypeValue},
> +  {NULL, TypeMax}
> +};
> +
>  /**
>    A list of available table parsers.
>  */
> @@ -92,6 +112,200 @@ ShellCommandGetManFileNameAcpiView (
>    return gShellAcpiViewFileName;
>  }
> 
> +/**
> +  Function for 'acpiview' command.
> +
> +  @param[in] ImageHandle  Handle to the Image (NULL if internal).
> +  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
> +
> +  @retval SHELL_INVALID_PARAMETER The command line invocation could not
> be parsed
> +  @retval SHELL_NOT_FOUND         The command failed
> +  @retval SHELL_SUCCESS           The command was successful
> +**/
> +SHELL_STATUS
> +EFIAPI
> +ShellCommandRunAcpiView (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE* SystemTable
> +  )
> +{
> +  EFI_STATUS         Status;
> +  SHELL_STATUS       ShellStatus;
> +  LIST_ENTRY*        Package;
> +  CHAR16*            ProblemParam;
> +  SHELL_FILE_HANDLE  TmpDumpFileHandle;
> +  CONST CHAR16*      MandatoryTableSpecStr;
> +  CONST CHAR16*      SelectedTableName;
> +
> +  // Set configuration defaults
> +  AcpiConfigSetDefaults ();
> +
> +  ShellStatus = SHELL_SUCCESS;
> +  Package = NULL;
> +  TmpDumpFileHandle = NULL;
> +
> +  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam,
> + TRUE);  if (EFI_ERROR (Status)) {
> +    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GEN_PROBLEM),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview",
> +        ProblemParam
> +        );
> +      FreePool (ProblemParam);
> +    } else {
> +      Print (L"acpiview: Error processing input parameter(s)\n");
> +    }
> +    ShellStatus = SHELL_INVALID_PARAMETER;  } else {
> +    if (ShellCommandLineGetCount (Package) > 1) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GEN_TOO_MANY),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview"
> +        );
> +      ShellStatus = SHELL_INVALID_PARAMETER;
> +    } else if (ShellCommandLineGetFlag (Package, L"-?")) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GET_HELP_ACPIVIEW),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview"
> +        );
> +    } else if (ShellCommandLineGetFlag (Package, L"-s") &&
> +               ShellCommandLineGetValue (Package, L"-s") == NULL) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GEN_NO_VALUE),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview",
> +        L"-s"
> +        );
> +      ShellStatus = SHELL_INVALID_PARAMETER;
> +    } else if (ShellCommandLineGetFlag (Package, L"-r") &&
> +               ShellCommandLineGetValue (Package, L"-r") == NULL) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GEN_NO_VALUE),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview",
> +        L"-r"
> +        );
> +      ShellStatus = SHELL_INVALID_PARAMETER;
> +    } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
> +                ShellCommandLineGetFlag (Package, L"-l"))) {
> +      ShellPrintHiiEx (
> +        -1,
> +        -1,
> +        NULL,
> +        STRING_TOKEN (STR_GEN_TOO_MANY),
> +        gShellAcpiViewHiiHandle,
> +        L"acpiview"
> +        );
> +      ShellStatus = SHELL_INVALID_PARAMETER;
> +    } else if (ShellCommandLineGetFlag (Package, L"-d") &&
> +               !ShellCommandLineGetFlag (Package, L"-s")) {
> +        ShellPrintHiiEx (
> +          -1,
> +          -1,
> +          NULL,
> +          STRING_TOKEN (STR_GEN_MISSING_OPTION),
> +          gShellAcpiViewHiiHandle,
> +          L"acpiview",
> +          L"-s",
> +          L"-d"
> +          );
> +        ShellStatus = SHELL_INVALID_PARAMETER;
> +    } else {
> +      // Turn on colour highlighting if requested
> +      SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
> +
> +      // Surpress consistency checking if requested
> +      SetConsistencyChecking (!ShellCommandLineGetFlag (Package,
> + L"-q"));
> +
> +      // Evaluate the parameters for mandatory ACPI table presence checks
> +      SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));
> +      MandatoryTableSpecStr = ShellCommandLineGetValue (Package,
> + L"-r");
> +
> +      if (MandatoryTableSpecStr != NULL) {
> +        SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));
> +      }
> +
> +      if (ShellCommandLineGetFlag (Package, L"-l")) {
> +        SetReportOption (ReportTableList);
> +      } else {
> +        SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
> +        if (SelectedTableName != NULL) {
> +          SelectAcpiTable (SelectedTableName);
> +          SetReportOption (ReportSelected);
> +
> +          if (ShellCommandLineGetFlag (Package, L"-d"))  {
> +            // Create a temporary file to check if the media is writable.
> +            CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
> +            SetReportOption (ReportDumpBinFile);
> +
> +            UnicodeSPrint (
> +              FileNameBuffer,
> +              sizeof (FileNameBuffer),
> +              L".\\%s0000.tmp",
> +              SelectedTableName
> +              );
> +
> +            Status = ShellOpenFileByName (
> +                       FileNameBuffer,
> +                       &TmpDumpFileHandle,
> +                       EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
> +                       EFI_FILE_MODE_CREATE,
> +                       0
> +                       );
> +
> +            if (EFI_ERROR (Status)) {
> +              ShellStatus = SHELL_INVALID_PARAMETER;
> +              TmpDumpFileHandle = NULL;
> +              ShellPrintHiiEx (
> +                -1,
> +                -1,
> +                NULL,
> +                STRING_TOKEN (STR_GEN_READONLY_MEDIA),
> +                gShellAcpiViewHiiHandle,
> +                L"acpiview"
> +                );
> +              goto Done;
> +            }
> +            // Delete Temporary file.
> +            ShellDeleteFile (&TmpDumpFileHandle);
> +          } // -d
> +        } // -s
> +      }
> +
> +      // Parse ACPI Table information
> +      Status = AcpiView (SystemTable);
> +      if (EFI_ERROR (Status)) {
> +        ShellStatus = SHELL_NOT_FOUND;
> +      }
> +    }
> +  }
> +
> +Done:
> +  if (Package != NULL) {
> +    ShellCommandLineFreeVarList (Package);
> +  }
> +  return ShellStatus;
> +}
> +
>  /**
>    Constructor for the Shell AcpiView Command library.
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> index c1cf7a57af7a..a3a29164004d 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.h
> @@ -1,7 +1,7 @@
>  /** @file
>    Header file for 'acpiview' Shell command functions.
> 
> -  Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.<BR>
> +  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -13,8 +13,12 @@ extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;
>  /**
>    Function for 'acpiview' command.
> 
> -  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
> -  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
> +  @param[in] ImageHandle  Handle to the Image (NULL if internal).
> +  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
> +
> +  @retval SHELL_INVALID_PARAMETER The command line invocation could not
> be parsed
> +  @retval SHELL_NOT_FOUND         The command failed
> +  @retval SHELL_SUCCESS           The command was successful
>  **/
>  SHELL_STATUS
>  EFIAPI
> --
> 2.24.1.windows.2
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile
  2020-05-21 18:44 ` [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
@ 2020-06-12  2:41   ` Gao, Zhichao
  0 siblings, 0 replies; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:41 UTC (permalink / raw)
  To: devel@edk2.groups.io, Tomas.Pilar@arm.com; +Cc: nd@arm.com, Ni, Ray

See below.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas Pilar
> (tpilar)
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2 5/6] ShellPkg/AcpiView: Refactor
> DumpAcpiTableToFile
> 
> Method is refactored into two parts. A new method is created that dumps
> arbitrary buffers into a newly created file. This method is called from core code
> after the core code determined the appropriate filename to be used.
> 
> This improves the modular design.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                    | 35 +------
> ----------------------------
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
> | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.
> h | 17 +++++++++++++++++
>  3 files changed, 76 insertions(+), 34 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> index a3160ed6f0a2..e866b84c6844 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> @@ -48,13 +48,10 @@ DumpAcpiTableToFile (
>    IN CONST UINTN   Length
>    )
>  {
> -  EFI_STATUS          Status;
>    CHAR16              FileNameBuffer[MAX_FILE_NAME_LEN];
> -  SHELL_FILE_HANDLE   DumpFileHandle;
>    UINTN               TransferBytes;
>    SELECTED_ACPI_TABLE SelectedTable;
> 
> -  DumpFileHandle = NULL;
>    TransferBytes = Length;

I think the assignment of TransferBytes can be removed.
Without this, Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

>    GetSelectedAcpiTable (&SelectedTable);
> 
> @@ -66,39 +63,9 @@ DumpAcpiTableToFile (
>      mBinTableCount++
>      );
> 
> -  Status = ShellOpenFileByName (
> -             FileNameBuffer,
> -             &DumpFileHandle,
> -             EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
> EFI_FILE_MODE_CREATE,
> -             0
> -             );
> -  if (EFI_ERROR (Status)) {
> -    ShellPrintHiiEx (
> -      -1,
> -      -1,
> -      NULL,
> -      STRING_TOKEN (STR_GEN_READONLY_MEDIA),
> -      gShellAcpiViewHiiHandle,
> -      L"acpiview"
> -      );
> -    return FALSE;
> -  }
> -
>    Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer);
> 
> -  Status = ShellWriteFile (
> -             DumpFileHandle,
> -             &TransferBytes,
> -             (VOID*)Ptr
> -             );
> -  if (EFI_ERROR (Status)) {
> -    Print (L"ERROR: Failed to dump table to binary file.\n");
> -    TransferBytes = 0;
> -  } else {
> -    Print (L"DONE.\n");
> -  }
> -
> -  ShellCloseFile (&DumpFileHandle);
> +  TransferBytes = DumpFile (FileNameBuffer, Ptr, Length);
>    return (Length == TransferBytes);
>  }
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> index c3942ad24e5b..adf3cce6cfe2 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.c
> @@ -98,6 +98,64 @@ RegisterAllParsers (
>    return Status;
>  }
> 
> +/**
> +  Dump a buffer to a file
> +
> +  @param[in] FileName   The filename that shall be created to contain the buffer
> +  @param[in] Buffer     Pointer to buffer that shall be dumped
> +  @param[in] BufferSize The size of buffer to be dumped in bytes
> +
> +  @return The number of bytes that were written **/ UINTN EFIAPI
> +DumpFile (
> +  IN CONST CHAR16* FileNameBuffer,
> +  IN CONST VOID*   Buffer,
> +  IN CONST UINTN   BufferSize
> +  )
> +{
> +  EFI_STATUS          Status;
> +  SHELL_FILE_HANDLE   DumpFileHandle;
> +  UINTN               TransferBytes;
> +
> +  Status = ShellOpenFileByName (
> +             FileNameBuffer,
> +             &DumpFileHandle,
> +             EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
> EFI_FILE_MODE_CREATE,
> +             0
> +             );
> +
> +  if (EFI_ERROR (Status)) {
> +    ShellPrintHiiEx (
> +      -1,
> +      -1,
> +      NULL,
> +      STRING_TOKEN (STR_GEN_READONLY_MEDIA),
> +      gShellAcpiViewHiiHandle,
> +      L"acpiview"
> +      );
> +    return 0;
> +  }
> +
> +  TransferBytes = BufferSize;
> +  Status = ShellWriteFile (
> +             DumpFileHandle,
> +             &TransferBytes,
> +             (VOID *) Buffer
> +             );
> +
> +  if (EFI_ERROR (Status)) {
> +    Print (L"ERROR: Failed to write binary file.\n");
> +    TransferBytes = 0;
> +  } else {
> +    Print (L"DONE.\n");
> +  }
> +
> +  ShellCloseFile (&DumpFileHandle);
> +  return TransferBytes;
> +}
> +
>  /**
>    Return the file name of the help text file if not using HII.
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> index a3a29164004d..9dd39cf4b3f0 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.h
> @@ -10,6 +10,23 @@
> 
>  extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;
> 
> +/**
> +  Dump a buffer to a file
> +
> +  @param[in] FileName   The filename that shall be created to contain the buffer
> +  @param[in] Buffer     Pointer to buffer that shall be dumped
> +  @param[in] BufferSize The size of buffer to be dumped in bytes
> +
> +  @return The number of bytes that were written **/ UINTN EFIAPI
> +DumpFile (
> +  IN CONST CHAR16* FileNameBuffer,
> +  IN CONST VOID*   Buffer,
> +  IN CONST UINTN   BufferSize
> +  );
> +
>  /**
>    Function for 'acpiview' command.
> 
> --
> 2.24.1.windows.2
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper
  2020-05-21 18:44 ` [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
@ 2020-06-12  2:41   ` Gao, Zhichao
  2020-06-15 11:57     ` Tomas Pilar (tpilar)
  0 siblings, 1 reply; 14+ messages in thread
From: Gao, Zhichao @ 2020-06-12  2:41 UTC (permalink / raw)
  To: devel@edk2.groups.io, Tomas.Pilar@arm.com; +Cc: nd@arm.com, Ni, Ray

(1)
There is one more easy with to add the help info.
Put the help string in the uni file that has the same name with the module file name.
See below example from TftpApp.inf:

//
// String token ID of help message text.
// Shell supports to find help message in the resource section of an application image if
// .MAN file is not found. This global variable is added to make build tool recognizes
// that the help string is consumed by user and then build tool will add the string into
// the resource section. Thus the application can use '-?' option to show help message in
// Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);

(2)
I suggest to add the UefiShellAcpiViewCommandLib header file to make it visible for other module. The application support to build in other module. It is better to put the lib visible in the inf config file. Consumers can be clearly aware of which libs are required. When introduce new lib:
  a. add header file for the published interface
  b. add lib & header file in the package dec file
  c. add lib in the package dsc file [Components] for build only
  d. add the lib in the [LibraryClasses] for the package that would consume the lib

(3)
One white space in the end of line. It would break the Patchchecker.py. See below.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas Pilar
> (tpilar)
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper
> 
> Simple application wrapper that invokes the shell command wrapper for acpiview.
> 
> This allows the AcpiView functionality to be used on platforms with older
> specifications of the UEFI shell or where the 'acpiview' command is not built in
> due to platform build configuration.
> 
> Furthermore, this app can be integrated into more comprehensive testing
> frameworks as a single component of a more thorough specification compliance
> validation strategy.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Application/AcpiViewApp/AcpiViewApp.c   | 189
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++
>  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf |  31 ++++++++++++
>  ShellPkg/ShellPkg.dsc                            |   6 ++-
>  3 files changed, 225 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> new file mode 100644
> index 000000000000..f83111629c21
> --- /dev/null
> +++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> @@ -0,0 +1,189 @@
> +/** @file
> +  Main file for AcpiViewApp application
> +
> +  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +
> +#include <Protocol/ShellParameters.h>
> +
> +/**
> +  Execute the AcpiView command from UefiShellAcpiViewCommandLib.
> +  This function is pulled in directly from the library source.
> +**/
> +SHELL_STATUS
> +EFIAPI
> +ShellCommandRunAcpiView (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE* SystemTable
> +  );
> +
> +CHAR16 mAcpiViewAppHelp[] =
> +  u"\r\n"
> +  "Display ACPI Table information.\r\n"
> +  "\r\n"
> +  "AcpiViewApp.efi [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h]]\r\n"
> +  " \r\n"
> +  "  -l - Display list of installed ACPI Tables.\r\n"
> +  "  -s - Display only the specified AcpiTable type and only support single\r\n"
> +  "       invocation option.\r\n"
> +  "         AcpiTable    : The required ACPI Table type.\r\n"
> +  "  -d - Generate a binary file dump of the specified AcpiTable.\r\n"
> +  "  -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
> +  "  -h - Enable colour highlighting.\r\n"
> +  "  -? - Show help.\r\n"
> +  " \r\n"
> +  "  This program is provided to allow examination of ACPI table values from "
> +  "the\r\n"
> +  "  UEFI Shell. This can help with investigations, especially at that "
> +  "stage\r\n"
> +  "  where the tables are not enabling an OS to boot.\r\n"
> +  "  The program is not exhaustive, and only encapsulates detailed knowledge "
> +  "of a\r\n"
> +  "  limited number of table types.\r\n"
> +  " \r\n"
> +  "  Default behaviour is to display the content of all tables installed.\r\n"
> +  "  'Known' table types (listed in NOTES below) will be parsed and "
> +  "displayed\r\n"
> +  "  with descriptions and field values. Where appropriate a degree of\r\n"
> +  "  consistency checking is done and errors may be reported in the output.\r\n"
> +  "  Other table types will be displayed as an array of Hexadecimal bytes.\r\n"
> +  " \r\n"
> +  "  To facilitate debugging, the -s and -d options can be used to generate "
> +  "a\r\n"
> +  "  binary file image of a table that can be copied elsewhere for "
> +  "investigation\r\n"
> +  "  using tools such as those provided by acpica.org. This is especially\r\n"
> +  "  relevant for AML type tables like DSDT and SSDT.\r\n"
> +  " \r\n"
> +  "NOTES:\r\n"
> +  "  1. The AcpiTable parameter can match any installed table type.\r\n"
> +  "     Tables without specific handling will be displayed as a raw hex dump "
> +  "(or\r\n"
> +  "     dumped to a file if -d is used).\r\n"
> +  "  2. -s option supports to display the specified AcpiTable type that is "
> +  "present\r\n"
> +  "     in the system. For normal type AcpiTable, it would display the data of "
> +  "the\r\n"
> +  "     AcpiTable and AcpiTable header. The following type may contain header "
> +  "type\r\n"
> +  "     other than AcpiTable header. The actual header can refer to the ACPI "
> +  "spec\r\n"
> +  "     6.3\r\n"
> +  "     Extra A. Particular types:\r\n"
> +  "       APIC  - Multiple APIC Description Table (MADT)\r\n"
> +  "       BGRT  - Boot Graphics Resource Table\r\n"
> +  "       DBG2  - Debug Port Table 2\r\n"
> +  "       DSDT  - Differentiated System Description Table\r\n"
> +  "       FACP  - Fixed ACPI Description Table (FADT)\r\n"
> +  "       GTDT  - Generic Timer Description Table\r\n"
> +  "       IORT  - IO Remapping Table\r\n"
> +  "       MCFG  - Memory Mapped Config Space Base Address Description
> Table\r\n"
> +  "       PPTT  - Processor Properties Topology Table\r\n"
> +  "       RSDP  - Root System Description Pointer\r\n"
> +  "       SLIT  - System Locality Information Table\r\n"
> +  "       SPCR  - Serial Port Console Redirection Table\r\n"
> +  "       SRAT  - System Resource Affinity Table\r\n"
> +  "       SSDT  - Secondary SystemDescription Table\r\n"
> +  "       XSDT  - Extended System Description Table\r\n"
> +  " \r\n"
> +  "  Table details correspond to those in 'Advanced Configuration and Power\r\n"
> +  "  Interface Specification' Version 6.3 [January 2019]\r\n"
> +  "  (https://uefi.org/specifications)\r\n"
> +  "  "
> +  " \r\n"
> +  "  NOTE: The nature of the ACPI standard means that almost all tables in "
> +  "6.1\r\n"
> +  "        will be 'backwards compatible' with prior version of the "
> +  "specification\r\n"
> +  "        in terms of structure, so formatted output should be correct. The "
> +  "main\r\n"
> +  "        exception will be that previously 'reserved' fields will be "
> +  "reported\r\n"
> +  "        with new names, where they have been added in later versions of "
> +  "the\r\n"
> +  "        specification.\r\n"
> +  " \r\n"
> +  " \r\n"
> +  "EXAMPLES:\r\n"
> +  "  * To display a list of the installed table types:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -l\r\n"
> +  " \r\n"
> +  "  * To parse and display a specific table type:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -s GTDT\r\n"
> +  " \r\n"
> +  "  * To save a binary dump of the contents of a table to a file\r\n"
> +  "    in the current working directory:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -s DSDT -d\r\n"
> +  " \r\n"
> +  "  * To display contents of all ACPI tables:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi\r\n"
> +  " \r\n";
> +
> +/**
> +  Determine if the user wants to display by checking for presence
> +  of '/?' or '--help' on command line. We cannot override '-?' shell
> +  command line handling.
> +
> +  @retval EFI_SUCCESS             No help was printed
> +  @retval EFI_INVALID_PARAMETER   Help was printed
> +**/
> +STATIC
> +EFI_STATUS
> +CheckForHelpRequest (
> +  EFI_HANDLE ImageHandle
> +  )
> +{
> +  EFI_STATUS                    Status;
> +  EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
> +  UINTN                         Index;
> +
> +  Status = gBS->HandleProtocol (
> +    ImageHandle,

Please remove the white space in the end of above line.

Thanks,
Zhichao

> +    &gEfiShellParametersProtocolGuid,
> +    (VOID **)&ShellParameters
> +    );
> +  if (EFI_ERROR(Status)) {
> +    return Status;
> +  }
> +
> +  for (Index = 1; Index < ShellParameters->Argc; Index++) {
> +    if ((StrCmp (ShellParameters->Argv[Index], L"/?") == 0) ||
> +        (StrCmp (ShellParameters->Argv[Index], L"--help") == 0))  {
> +      Print (mAcpiViewAppHelp);
> +      return EFI_INVALID_PARAMETER;
> +    }
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +
> +/**
> +  Application Entry Point wrapper around the shell command
> +
> +  @param[in] ImageHandle  Handle to the Image (NULL if internal).
> +  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
> +**/
> +EFI_STATUS
> +EFIAPI
> +AcpiViewAppMain (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS Status;
> +
> +  Status = CheckForHelpRequest (ImageHandle);
> +
> +  // Do not run code if help was printed  if (Status !=
> + EFI_INVALID_PARAMETER) {
> +    Status = ShellCommandRunAcpiView (gImageHandle, SystemTable);  }
> +
> +  return Status;
> +}
> diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> new file mode 100644
> index 000000000000..28e724fa1909
> --- /dev/null
> +++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> @@ -0,0 +1,31 @@
> +##  @file
> +#  EFI application that displays and verifies ACPI tables # #
> +Copyright (c) 2020, ARM Limited. All rights reserved.<BR> # #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # # ##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = AcpiViewApp
> +  FILE_GUID                      = 46361B5B-AF17-41FF-95F9-E1BCE08435B9
> +  MODULE_TYPE                    = UEFI_APPLICATION
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = AcpiViewAppMain
> +
> +[Sources.common]
> +  AcpiViewApp.c
> +
> +[Packages]
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +  ShellPkg/ShellPkg.dec
> +
> +[LibraryClasses]
> +  UefiBootServicesTableLib
> +  UefiLib
> +  BaseLib
> +  UefiApplicationEntryPoint
> diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc index
> b7ee856b3a16..1ed82ee7aca3 100644
> --- a/ShellPkg/ShellPkg.dsc
> +++ b/ShellPkg/ShellPkg.dsc
> @@ -2,7 +2,7 @@
>  # Shell Package
>  #
>  # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR> -#
> Copyright (c) 2018, Arm Limited. All rights reserved.<BR>
> +# Copyright (c) 2018 - 2020, Arm Limited. All rights reserved.<BR>
>  # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.<BR>  #
>  #    SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -143,6 +143,10 @@ [Components]
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>    }
>    ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> +  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf {
> +    <LibraryClasses>
> +
> + NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCom
> + mandLib.inf
> +  }
> 
>  [BuildOptions]
>    *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> --
> 2.24.1.windows.2
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper
  2020-06-12  2:41   ` [edk2-devel] " Gao, Zhichao
@ 2020-06-15 11:57     ` Tomas Pilar (tpilar)
  0 siblings, 0 replies; 14+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-15 11:57 UTC (permalink / raw)
  To: Gao, Zhichao, devel@edk2.groups.io; +Cc: nd, Ni, Ray

Thank you Zhichao, this is really useful, I was wondering how to hook into the shell help framework. 

Regarding the lower case const and static, I am entirely happy to change them, but I have a couple of patch series outstanding and don't want to add unnecessary merge conflicts, so I'll do a single formatting patch at the end that changes all instances of const and static in the UefiShellAcpiViewCommandLib and one for AcpiViewApp. I hope that is acceptable.

I am respinning the patches now.

Cheers,
Tom

-----Original Message-----
From: Gao, Zhichao <zhichao.gao@intel.com> 
Sent: 12 June 2020 03:42
To: devel@edk2.groups.io; Tomas Pilar <Tomas.Pilar@arm.com>
Cc: nd <nd@arm.com>; Ni, Ray <ray.ni@intel.com>
Subject: RE: [edk2-devel] [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper

(1)
There is one more easy with to add the help info.
Put the help string in the uni file that has the same name with the module file name.
See below example from TftpApp.inf:

//
// String token ID of help message text.
// Shell supports to find help message in the resource section of an application image if // .MAN file is not found. This global variable is added to make build tool recognizes // that the help string is consumed by user and then build tool will add the string into // the resource section. Thus the application can use '-?' option to show help message in // Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);

(2)
I suggest to add the UefiShellAcpiViewCommandLib header file to make it visible for other module. The application support to build in other module. It is better to put the lib visible in the inf config file. Consumers can be clearly aware of which libs are required. When introduce new lib:
  a. add header file for the published interface
  b. add lib & header file in the package dec file
  c. add lib in the package dsc file [Components] for build only
  d. add the lib in the [LibraryClasses] for the package that would consume the lib

(3)
One white space in the end of line. It would break the Patchchecker.py. See below.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas 
> Pilar
> (tpilar)
> Sent: Friday, May 22, 2020 2:44 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao 
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2 6/6] ShellPkg/AcpiView: Add 
> application wrapper
> 
> Simple application wrapper that invokes the shell command wrapper for acpiview.
> 
> This allows the AcpiView functionality to be used on platforms with 
> older specifications of the UEFI shell or where the 'acpiview' command 
> is not built in due to platform build configuration.
> 
> Furthermore, this app can be integrated into more comprehensive 
> testing frameworks as a single component of a more thorough 
> specification compliance validation strategy.
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
> ---
>  ShellPkg/Application/AcpiViewApp/AcpiViewApp.c   | 189
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++
>  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf |  31 ++++++++++++
>  ShellPkg/ShellPkg.dsc                            |   6 ++-
>  3 files changed, 225 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> new file mode 100644
> index 000000000000..f83111629c21
> --- /dev/null
> +++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
> @@ -0,0 +1,189 @@
> +/** @file
> +  Main file for AcpiViewApp application
> +
> +  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +
> +#include <Protocol/ShellParameters.h>
> +
> +/**
> +  Execute the AcpiView command from UefiShellAcpiViewCommandLib.
> +  This function is pulled in directly from the library source.
> +**/
> +SHELL_STATUS
> +EFIAPI
> +ShellCommandRunAcpiView (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE* SystemTable
> +  );
> +
> +CHAR16 mAcpiViewAppHelp[] =
> +  u"\r\n"
> +  "Display ACPI Table information.\r\n"
> +  "\r\n"
> +  "AcpiViewApp.efi [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h]]\r\n"
> +  " \r\n"
> +  "  -l - Display list of installed ACPI Tables.\r\n"
> +  "  -s - Display only the specified AcpiTable type and only support single\r\n"
> +  "       invocation option.\r\n"
> +  "         AcpiTable    : The required ACPI Table type.\r\n"
> +  "  -d - Generate a binary file dump of the specified AcpiTable.\r\n"
> +  "  -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
> +  "  -h - Enable colour highlighting.\r\n"
> +  "  -? - Show help.\r\n"
> +  " \r\n"
> +  "  This program is provided to allow examination of ACPI table values from "
> +  "the\r\n"
> +  "  UEFI Shell. This can help with investigations, especially at that "
> +  "stage\r\n"
> +  "  where the tables are not enabling an OS to boot.\r\n"
> +  "  The program is not exhaustive, and only encapsulates detailed knowledge "
> +  "of a\r\n"
> +  "  limited number of table types.\r\n"
> +  " \r\n"
> +  "  Default behaviour is to display the content of all tables installed.\r\n"
> +  "  'Known' table types (listed in NOTES below) will be parsed and "
> +  "displayed\r\n"
> +  "  with descriptions and field values. Where appropriate a degree of\r\n"
> +  "  consistency checking is done and errors may be reported in the output.\r\n"
> +  "  Other table types will be displayed as an array of Hexadecimal bytes.\r\n"
> +  " \r\n"
> +  "  To facilitate debugging, the -s and -d options can be used to generate "
> +  "a\r\n"
> +  "  binary file image of a table that can be copied elsewhere for "
> +  "investigation\r\n"
> +  "  using tools such as those provided by acpica.org. This is especially\r\n"
> +  "  relevant for AML type tables like DSDT and SSDT.\r\n"
> +  " \r\n"
> +  "NOTES:\r\n"
> +  "  1. The AcpiTable parameter can match any installed table type.\r\n"
> +  "     Tables without specific handling will be displayed as a raw hex dump "
> +  "(or\r\n"
> +  "     dumped to a file if -d is used).\r\n"
> +  "  2. -s option supports to display the specified AcpiTable type that is "
> +  "present\r\n"
> +  "     in the system. For normal type AcpiTable, it would display the data of "
> +  "the\r\n"
> +  "     AcpiTable and AcpiTable header. The following type may contain header "
> +  "type\r\n"
> +  "     other than AcpiTable header. The actual header can refer to the ACPI "
> +  "spec\r\n"
> +  "     6.3\r\n"
> +  "     Extra A. Particular types:\r\n"
> +  "       APIC  - Multiple APIC Description Table (MADT)\r\n"
> +  "       BGRT  - Boot Graphics Resource Table\r\n"
> +  "       DBG2  - Debug Port Table 2\r\n"
> +  "       DSDT  - Differentiated System Description Table\r\n"
> +  "       FACP  - Fixed ACPI Description Table (FADT)\r\n"
> +  "       GTDT  - Generic Timer Description Table\r\n"
> +  "       IORT  - IO Remapping Table\r\n"
> +  "       MCFG  - Memory Mapped Config Space Base Address Description
> Table\r\n"
> +  "       PPTT  - Processor Properties Topology Table\r\n"
> +  "       RSDP  - Root System Description Pointer\r\n"
> +  "       SLIT  - System Locality Information Table\r\n"
> +  "       SPCR  - Serial Port Console Redirection Table\r\n"
> +  "       SRAT  - System Resource Affinity Table\r\n"
> +  "       SSDT  - Secondary SystemDescription Table\r\n"
> +  "       XSDT  - Extended System Description Table\r\n"
> +  " \r\n"
> +  "  Table details correspond to those in 'Advanced Configuration and Power\r\n"
> +  "  Interface Specification' Version 6.3 [January 2019]\r\n"
> +  "  (https://uefi.org/specifications)\r\n"
> +  "  "
> +  " \r\n"
> +  "  NOTE: The nature of the ACPI standard means that almost all tables in "
> +  "6.1\r\n"
> +  "        will be 'backwards compatible' with prior version of the "
> +  "specification\r\n"
> +  "        in terms of structure, so formatted output should be correct. The "
> +  "main\r\n"
> +  "        exception will be that previously 'reserved' fields will be "
> +  "reported\r\n"
> +  "        with new names, where they have been added in later versions of "
> +  "the\r\n"
> +  "        specification.\r\n"
> +  " \r\n"
> +  " \r\n"
> +  "EXAMPLES:\r\n"
> +  "  * To display a list of the installed table types:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -l\r\n"
> +  " \r\n"
> +  "  * To parse and display a specific table type:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -s GTDT\r\n"
> +  " \r\n"
> +  "  * To save a binary dump of the contents of a table to a file\r\n"
> +  "    in the current working directory:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi -s DSDT -d\r\n"
> +  " \r\n"
> +  "  * To display contents of all ACPI tables:\r\n"
> +  "    fs0:\\> AcpiViewApp.efi\r\n"
> +  " \r\n";
> +
> +/**
> +  Determine if the user wants to display by checking for presence
> +  of '/?' or '--help' on command line. We cannot override '-?' shell
> +  command line handling.
> +
> +  @retval EFI_SUCCESS             No help was printed
> +  @retval EFI_INVALID_PARAMETER   Help was printed
> +**/
> +STATIC
> +EFI_STATUS
> +CheckForHelpRequest (
> +  EFI_HANDLE ImageHandle
> +  )
> +{
> +  EFI_STATUS                    Status;
> +  EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
> +  UINTN                         Index;
> +
> +  Status = gBS->HandleProtocol (
> +    ImageHandle,

Please remove the white space in the end of above line.

Thanks,
Zhichao

> +    &gEfiShellParametersProtocolGuid,
> +    (VOID **)&ShellParameters
> +    );
> +  if (EFI_ERROR(Status)) {
> +    return Status;
> +  }
> +
> +  for (Index = 1; Index < ShellParameters->Argc; Index++) {
> +    if ((StrCmp (ShellParameters->Argv[Index], L"/?") == 0) ||
> +        (StrCmp (ShellParameters->Argv[Index], L"--help") == 0))  {
> +      Print (mAcpiViewAppHelp);
> +      return EFI_INVALID_PARAMETER;
> +    }
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +
> +/**
> +  Application Entry Point wrapper around the shell command
> +
> +  @param[in] ImageHandle  Handle to the Image (NULL if internal).
> +  @param[in] SystemTable  Pointer to the System Table (NULL if internal).
> +**/
> +EFI_STATUS
> +EFIAPI
> +AcpiViewAppMain (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS Status;
> +
> +  Status = CheckForHelpRequest (ImageHandle);
> +
> +  // Do not run code if help was printed  if (Status !=
> + EFI_INVALID_PARAMETER) {
> +    Status = ShellCommandRunAcpiView (gImageHandle, SystemTable);  }
> +
> +  return Status;
> +}
> diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> new file mode 100644
> index 000000000000..28e724fa1909
> --- /dev/null
> +++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
> @@ -0,0 +1,31 @@
> +##  @file
> +#  EFI application that displays and verifies ACPI tables # # 
> +Copyright (c) 2020, ARM Limited. All rights reserved.<BR> # #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # # ##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = AcpiViewApp
> +  FILE_GUID                      = 46361B5B-AF17-41FF-95F9-E1BCE08435B9
> +  MODULE_TYPE                    = UEFI_APPLICATION
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = AcpiViewAppMain
> +
> +[Sources.common]
> +  AcpiViewApp.c
> +
> +[Packages]
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +  ShellPkg/ShellPkg.dec
> +
> +[LibraryClasses]
> +  UefiBootServicesTableLib
> +  UefiLib
> +  BaseLib
> +  UefiApplicationEntryPoint
> diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc index
> b7ee856b3a16..1ed82ee7aca3 100644
> --- a/ShellPkg/ShellPkg.dsc
> +++ b/ShellPkg/ShellPkg.dsc
> @@ -2,7 +2,7 @@
>  # Shell Package
>  #
>  # Copyright (c) 2007 - 2019, Intel Corporation. All rights 
> reserved.<BR> -# Copyright (c) 2018, Arm Limited. All rights 
> reserved.<BR>
> +# Copyright (c) 2018 - 2020, Arm Limited. All rights reserved.<BR>
>  # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All 
> rights reserved.<BR>  #
>  #    SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -143,6 +143,10 @@ [Components]
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>    }
>    ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> +  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf {
> +    <LibraryClasses>
> +
> + NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewC
> + NULL|om
> + mandLib.inf
> +  }
> 
>  [BuildOptions]
>    *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> --
> 2.24.1.windows.2
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-06-15 11:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-21 18:44 [PATCH v2 0/6] Standalone AcpiView Application Tomas Pilar (tpilar)
2020-05-21 18:44 ` [PATCH v2 1/6] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
2020-06-12  2:40   ` Gao, Zhichao
2020-05-21 18:44 ` [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
2020-06-12  2:40   ` Gao, Zhichao
2020-05-21 18:44 ` [PATCH v2 3/6] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
2020-06-12  2:40   ` [edk2-devel] " Gao, Zhichao
2020-05-21 18:44 ` [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
2020-06-12  2:40   ` [edk2-devel] " Gao, Zhichao
2020-05-21 18:44 ` [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
2020-06-12  2:41   ` [edk2-devel] " Gao, Zhichao
2020-05-21 18:44 ` [PATCH v2 6/6] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
2020-06-12  2:41   ` [edk2-devel] " Gao, Zhichao
2020-06-15 11:57     ` Tomas Pilar (tpilar)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox