[edk2-devel] [PATCH v3 6/7] ShellPkg: Add AcpiViewCommandLib

Tomas Pilar (tpilar) posted 7 patches 5 years, 7 months ago
There is a newer version of this series
[edk2-devel] [PATCH v3 6/7] ShellPkg: Add AcpiViewCommandLib
Posted by Tomas Pilar (tpilar) 5 years, 7 months ago
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>
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 1b6721e6734f..5a46d896c52b 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



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

View/Reply Online (#61293): https://edk2.groups.io/g/devel/message/61293
Mute This Topic: https://groups.io/mt/74894925/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 6/7] ShellPkg: Add AcpiViewCommandLib
Posted by Gao, Zhichao 5 years, 7 months ago
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tomas Pilar
> (tpilar)
> Sent: Monday, June 15, 2020 10:04 PM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [edk2-devel] [PATCH v3 6/7] ShellPkg: Add AcpiViewCommandLib
> 
> 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>
> 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/UefiShellAcpiViewCommandLi
> b.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/UefiShellAcpiViewCommandLi
> b.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 1b6721e6734f..5a46d896c52b 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/UefiShellAcpiViewCommandLi
> b.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> index e6a65d5bc5f7..d2f26ff89f12 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.c
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.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/UefiShellAcpiViewCommandLi
> b.inf
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.inf
> index 92de2391b09f..91459f9ec632 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi
> b.inf
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
> +++ andLib.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/BasePeCo
> ffGetEntryPointLib.inf
> 
> BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCom
> mandLib.inf
> +
> + AcpiViewCommandLib|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiSh
> + ellAcpiViewCommandLib.inf
>    IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> 
> 
> UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootMa
> nagerLib.inf
> --
> 2.24.1.windows.2
> 
> 
> 
> 


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

View/Reply Online (#61575): https://edk2.groups.io/g/devel/message/61575
Mute This Topic: https://groups.io/mt/74894925/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-