public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Standalone AcpiView Application
@ 2020-06-23 13:42 Tomas Pilar (tpilar)
  2020-06-23 13:42 ` [PATCH v4 1/7] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:42 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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.

---
v4: Minor formatting.
v3: Fix pointer dereference in GetSelectedTable. Create library
    interface for the UefiShellAcpiViewCommandLib and convert to
    named library. Tidy help text shell hook in standalone app.
v2: Patch formatting

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

Tomas Pilar (7):
  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: Add AcpiViewCommandLib
  ShellPkg/AcpiView: Add application wrapper

 .../Application/AcpiViewApp/AcpiViewApp.c     |  40 ++
 .../Application/AcpiViewApp/AcpiViewApp.inf   |  34 ++
 .../Application/AcpiViewApp/AcpiViewApp.uni   | 122 +++++
 ShellPkg/Include/Library/AcpiViewCommandLib.h |  46 ++
 .../UefiShellAcpiViewCommandLib/AcpiParser.c  |   1 +
 .../AcpiTableParser.c                         |   1 +
 .../UefiShellAcpiViewCommandLib/AcpiView.c    | 474 ++----------------
 .../UefiShellAcpiViewCommandLib/AcpiView.h    | 113 +----
 .../AcpiViewConfig.c                          | 246 +++++++++
 .../AcpiViewConfig.h                          | 177 +++++++
 .../Parsers/Gtdt/GtdtParser.c                 |   1 +
 .../Parsers/Iort/IortParser.c                 |   1 +
 .../Parsers/Madt/MadtParser.c                 |   1 +
 .../Parsers/Pptt/PpttParser.c                 |   1 +
 .../Parsers/Srat/SratParser.c                 |   1 +
 .../UefiShellAcpiViewCommandLib.c             | 279 ++++++++++-
 .../UefiShellAcpiViewCommandLib.h             |  26 -
 .../UefiShellAcpiViewCommandLib.inf           |  33 +-
 ShellPkg/ShellPkg.dec                         |   3 +
 ShellPkg/ShellPkg.dsc                         |   4 +-
 20 files changed, 1019 insertions(+), 585 deletions(-)
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.uni
 create mode 100644 ShellPkg/Include/Library/AcpiViewCommandLib.h
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
 delete mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h

-- 
2.24.1.windows.2



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

* [PATCH v4 1/7] ShellPkg/AcpiView: Move log reset to main method
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
@ 2020-06-23 13:42 ` Tomas Pilar (tpilar)
  2020-06-23 13:42 ` [PATCH v4 2/7] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:42 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: 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] 8+ messages in thread

* [PATCH v4 2/7] ShellPkg/AcpiView: Refactor configuration
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
  2020-06-23 13:42 ` [PATCH v4 1/7] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
@ 2020-06-23 13:42 ` Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 3/7] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:42 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 .../UefiShellAcpiViewCommandLib/AcpiParser.c  |   1 +
 .../AcpiTableParser.c                         |   1 +
 .../UefiShellAcpiViewCommandLib/AcpiView.c    | 237 +++--------------
 .../UefiShellAcpiViewCommandLib/AcpiView.h    |  95 -------
 .../AcpiViewConfig.c                          | 246 ++++++++++++++++++
 .../AcpiViewConfig.h                          | 177 +++++++++++++
 .../Parsers/Gtdt/GtdtParser.c                 |   1 +
 .../Parsers/Iort/IortParser.c                 |   1 +
 .../Parsers/Madt/MadtParser.c                 |   1 +
 .../Parsers/Pptt/PpttParser.c                 |   1 +
 .../Parsers/Srat/SratParser.c                 |   1 +
 .../UefiShellAcpiViewCommandLib.inf           |  32 +--
 12 files changed, 479 insertions(+), 315 deletions(-)
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h

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..b068dd4d2722 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..759a915928c7
--- /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..2db4a65415d8
--- /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] 8+ messages in thread

* [PATCH v4 3/7] ShellPkg/AcpiView: Move table count reset
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
  2020-06-23 13:42 ` [PATCH v4 1/7] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
  2020-06-23 13:42 ` [PATCH v4 2/7] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
@ 2020-06-23 13:43 ` Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 4/7] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:43 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: 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 b068dd4d2722..40778374af45 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] 8+ messages in thread

* [PATCH v4 4/7] ShellPkg/AcpiView: Move parameter parsing
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (2 preceding siblings ...)
  2020-06-23 13:43 ` [PATCH v4 3/7] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
@ 2020-06-23 13:43 ` Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 5/7] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:43 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 .../UefiShellAcpiViewCommandLib/AcpiView.c    | 205 ----------------
 .../UefiShellAcpiViewCommandLib/AcpiView.h    |  18 +-
 .../UefiShellAcpiViewCommandLib.c             | 218 +++++++++++++++++-
 .../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 40778374af45..e524fcb0b27a 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] 8+ messages in thread

* [PATCH v4 5/7] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (3 preceding siblings ...)
  2020-06-23 13:43 ` [PATCH v4 4/7] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
@ 2020-06-23 13:43 ` Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 6/7] ShellPkg: Add AcpiViewCommandLib Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 7/7] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:43 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 .../UefiShellAcpiViewCommandLib/AcpiView.c    | 38 +-----------
 .../UefiShellAcpiViewCommandLib.c             | 59 +++++++++++++++++++
 .../UefiShellAcpiViewCommandLib.h             | 17 +++++-
 3 files changed, 76 insertions(+), 38 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index e524fcb0b27a..d2240b2e89d5 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -27,8 +27,6 @@
 #include "Arm/SbbrValidator.h"
 #endif
 
-EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
-
 STATIC UINT32             mTableCount;
 STATIC UINT32             mBinTableCount;
 
@@ -48,14 +46,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);
 
   UnicodeSPrint (
@@ -66,39 +60,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 = ShellDumpBufferToFile (FileNameBuffer, Ptr, Length);
   return (Length == TransferBytes);
 }
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index c3942ad24e5b..e6a65d5bc5f7 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -25,6 +25,7 @@
 #include "UefiShellAcpiViewCommandLib.h"
 
 CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
+EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 
 /**
   An array of acpiview command line parameters.
@@ -98,6 +99,64 @@ RegisterAllParsers (
   return Status;
 }
 
+/**
+  Dump a buffer to a file. Print error message if a file cannot be created.
+
+  @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
+ShellDumpBufferToFile (
+  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..b1b1ffe63e28 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
@@ -8,7 +8,22 @@
 #ifndef UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
 #define UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
 
-extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;
+/**
+  Dump a buffer to a file. Print error message if a file cannot be created.
+
+  @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
+ShellDumpBufferToFile (
+  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] 8+ messages in thread

* [PATCH v4 6/7] ShellPkg: Add AcpiViewCommandLib
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (4 preceding siblings ...)
  2020-06-23 13:43 ` [PATCH v4 5/7] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
@ 2020-06-23 13:43 ` Tomas Pilar (tpilar)
  2020-06-23 13:43 ` [PATCH v4 7/7] ShellPkg/AcpiView: Add application wrapper Tomas Pilar (tpilar)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:43 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, nd, Ray Ni, Zhichao Gao

The UefiShellAcpiViewCommandLib is converted from NULL library to a
named library so that it may be used in modules other than shell.
The library interface exposes the main method for to AcpiView
functionality as well as a helper method to dump a buffer to a file.

The Shell module is still built by pulling UefiShellAcpiViewCommandLib
as a NULL library to preserve the modularity of shell builds.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 .../Library/AcpiViewCommandLib.h}                 | 15 ++++++++-------
 .../UefiShellAcpiViewCommandLib/AcpiView.c        |  2 +-
 .../UefiShellAcpiViewCommandLib.c                 |  2 +-
 .../UefiShellAcpiViewCommandLib.inf               |  3 +--
 ShellPkg/ShellPkg.dec                             |  3 +++
 ShellPkg/ShellPkg.dsc                             |  3 ++-
 6 files changed, 16 insertions(+), 12 deletions(-)
 rename ShellPkg/{Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h => Include/Library/AcpiViewCommandLib.h} (72%)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h b/ShellPkg/Include/Library/AcpiViewCommandLib.h
similarity index 72%
rename from ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
rename to ShellPkg/Include/Library/AcpiViewCommandLib.h
index b1b1ffe63e28..11cf96c6e0d7 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
+++ b/ShellPkg/Include/Library/AcpiViewCommandLib.h
@@ -1,12 +1,13 @@
 /** @file
-  Header file for 'acpiview' Shell command functions.
+  Library providing 'acpiview' functionality to display and
+  validate installed ACPI tables.
 
   Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
-#ifndef UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
-#define UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
+#ifndef ACPI_VIEW_COMMAND_LIB_H_
+#define ACPI_VIEW_COMMAND_LIB_H_
 
 /**
   Dump a buffer to a file. Print error message if a file cannot be created.
@@ -26,14 +27,14 @@ ShellDumpBufferToFile (
   );
 
 /**
-  Function for 'acpiview' command.
+  Display and validate ACPI tables.
 
   @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
+  @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
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index d2240b2e89d5..9a5b013fb234 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -17,11 +17,11 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/AcpiViewCommandLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
 #include "AcpiView.h"
 #include "AcpiViewConfig.h"
-#include "UefiShellAcpiViewCommandLib.h"
 
 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
 #include "Arm/SbbrValidator.h"
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index e6a65d5bc5f7..d2f26ff89f12 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -16,13 +16,13 @@
 #include <Library/ShellLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiLib.h>
+#include <Library/AcpiViewCommandLib.h>
 #include <Uefi.h>
 
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
 #include "AcpiView.h"
 #include "AcpiViewConfig.h"
-#include "UefiShellAcpiViewCommandLib.h"
 
 CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
 EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 92de2391b09f..91459f9ec632 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -14,7 +14,7 @@ [Defines]
   FILE_GUID                      = FB5B305E-84F5-461F-940D-82D345757AFA
   MODULE_TYPE                    = UEFI_APPLICATION
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = NULL|UEFI_APPLICATION UEFI_DRIVER
+  LIBRARY_CLASS                  = AcpiViewCommandLib|UEFI_APPLICATION UEFI_DRIVER
   CONSTRUCTOR                    = UefiShellAcpiViewCommandLibConstructor
   DESTRUCTOR                     = UefiShellAcpiViewCommandLibDestructor
 
@@ -46,7 +46,6 @@ [Sources.common]
   Parsers/Ssdt/SsdtParser.c
   Parsers/Xsdt/XsdtParser.c
   UefiShellAcpiViewCommandLib.c
-  UefiShellAcpiViewCommandLib.h
   UefiShellAcpiViewCommandLib.uni
 
 [Sources.ARM, Sources.AARCH64]
diff --git a/ShellPkg/ShellPkg.dec b/ShellPkg/ShellPkg.dec
index c17e358d15ed..d0843d338126 100644
--- a/ShellPkg/ShellPkg.dec
+++ b/ShellPkg/ShellPkg.dec
@@ -34,6 +34,9 @@ [LibraryClasses]
   ## @libraryclass   provides BCFG command
   BcfgCommandLib|Include/Library/BcfgCommandLib.h
 
+  ## @libraryclass   provides the AcpiView command
+  AcpiViewCommandLib|Include/Library/AcpiViewCommandLib.h
+
 [Guids]
   gEfiShellEnvironment2ExtGuid    = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}
   gEfiShellPkgTokenSpaceGuid      = {0x171e9188, 0x31d3, 0x40f5, {0xb1, 0x0c, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd}}
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index b7ee856b3a16..5d2d96ab071c 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
@@ -50,6 +50,7 @@ [LibraryClasses.common]
 
   PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
   BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+  AcpiViewCommandLib|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
 
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
-- 
2.24.1.windows.2



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

* [PATCH v4 7/7] ShellPkg/AcpiView: Add application wrapper
  2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
                   ` (5 preceding siblings ...)
  2020-06-23 13:43 ` [PATCH v4 6/7] ShellPkg: Add AcpiViewCommandLib Tomas Pilar (tpilar)
@ 2020-06-23 13:43 ` Tomas Pilar (tpilar)
  6 siblings, 0 replies; 8+ messages in thread
From: Tomas Pilar (tpilar) @ 2020-06-23 13:43 UTC (permalink / raw)
  To: devel; +Cc: Sami.Mujawar, 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>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
 .../Application/AcpiViewApp/AcpiViewApp.c     |  40 ++++++
 .../Application/AcpiViewApp/AcpiViewApp.inf   |  34 +++++
 .../Application/AcpiViewApp/AcpiViewApp.uni   | 122 ++++++++++++++++++
 ShellPkg/ShellPkg.dsc                         |   1 +
 4 files changed, 197 insertions(+)
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
 create mode 100644 ShellPkg/Application/AcpiViewApp/AcpiViewApp.uni

diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
new file mode 100644
index 000000000000..2f650c9d92d2
--- /dev/null
+++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.c
@@ -0,0 +1,40 @@
+/** @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 <Library/ShellLib.h>
+#include <Library/AcpiViewCommandLib.h>
+
+#include <Protocol/ShellParameters.h>
+
+//
+// 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_ACPIVIEW);
+
+/**
+  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
+  )
+{
+  return ShellCommandRunAcpiView (gImageHandle, SystemTable);
+}
diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
new file mode 100644
index 000000000000..2ed1d185339d
--- /dev/null
+++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
@@ -0,0 +1,34 @@
+##  @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
+  UEFI_HII_RESOURCE_SECTION      = TRUE
+
+[Sources.common]
+  AcpiViewApp.c
+  AcpiViewApp.uni
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  ShellPkg/ShellPkg.dec
+
+[LibraryClasses]
+  UefiBootServicesTableLib
+  UefiLib
+  BaseLib
+  UefiApplicationEntryPoint
+  AcpiViewCommandLib
diff --git a/ShellPkg/Application/AcpiViewApp/AcpiViewApp.uni b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.uni
new file mode 100644
index 000000000000..c56f21084356
--- /dev/null
+++ b/ShellPkg/Application/AcpiViewApp/AcpiViewApp.uni
@@ -0,0 +1,122 @@
+// @file
+//
+// Standalone EFI application that displays and verifies ACPI tables
+//
+// Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+
+/=#
+
+#langdef   en-US "english"
+
+#string STR_GET_HELP_ACPIVIEW   #language en-US ""
+".TH acpiview 0 "Display ACPI information."\r\n"
+".SH NAME\r\n"
+"Display ACPI Table information.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"ACPIVIEWAPP.EFI [[-?] | [[[[-l] | [-s AcpiTable [-d]]] [-q] [-h]] [-r Spec]]]\r\n"
+" \r\n"
+".SH OPTIONS\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"
+"  -r - Validate that all required ACPI tables are installed\r\n"
+"         Spec  : Specification to validate against.\r\n"
+"                 For Arm, the possible values are:\r\n"
+"                   0 - Server Base Boot Requirements v1.0\r\n"
+"                   1 - Server Base Boot Requirements v1.1\r\n"
+"                   2 - Server Base Boot Requirements v1.2\r\n"
+"  -? - Show help.\r\n"
+" \r\n"
+".SH DESCRIPTION\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"
+".SH STANDARDS\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.3\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"
+".SH EXAMPLES\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"
+"  * To check if all Server Base Boot Requirements (SBBR) v1.2 mandatory\r\n"
+"    ACPI tables are installed (Arm only):\r\n"
+"    fs0:\> acpiviewapp.efi -r 2\r\n"
+" \r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+"  SHELL_SUCCESS             Data was displayed as requested.\r\n"
+"  SHELL_INVALID_PARAMETER   ACPI Table parsing failed.\r\n"
+" \r\n"
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index 5d2d96ab071c..86e9f1e0040d 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -144,6 +144,7 @@ [Components]
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
   ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
+  ShellPkg/Application/AcpiViewApp/AcpiViewApp.inf
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.24.1.windows.2



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

end of thread, other threads:[~2020-06-23 13:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-23 13:42 [PATCH v4 0/7] Standalone AcpiView Application Tomas Pilar (tpilar)
2020-06-23 13:42 ` [PATCH v4 1/7] ShellPkg/AcpiView: Move log reset to main method Tomas Pilar (tpilar)
2020-06-23 13:42 ` [PATCH v4 2/7] ShellPkg/AcpiView: Refactor configuration Tomas Pilar (tpilar)
2020-06-23 13:43 ` [PATCH v4 3/7] ShellPkg/AcpiView: Move table count reset Tomas Pilar (tpilar)
2020-06-23 13:43 ` [PATCH v4 4/7] ShellPkg/AcpiView: Move parameter parsing Tomas Pilar (tpilar)
2020-06-23 13:43 ` [PATCH v4 5/7] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Tomas Pilar (tpilar)
2020-06-23 13:43 ` [PATCH v4 6/7] ShellPkg: Add AcpiViewCommandLib Tomas Pilar (tpilar)
2020-06-23 13:43 ` [PATCH v4 7/7] ShellPkg/AcpiView: Add application wrapper 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