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

Thanks,
Zhichao

> -----Original Message-----
> From: Tomas Pilar <tomas.pi...@arm.com>
> Sent: Monday, June 15, 2020 10:04 PM
> To: devel@edk2.groups.io
> Cc: n...@arm.com; Ni, Ray <ray...@intel.com>; Gao, Zhichao
> <zhichao....@intel.com>
> Subject: [PATCH v3 7/7] 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...@intel.com>
> Cc: Zhichao Gao <zhichao....@intel.com>
> Signed-off-by: Tomas Pilar <tomas.pi...@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
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61576): https://edk2.groups.io/g/devel/message/61576
Mute This Topic: https://groups.io/mt/74894927/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to