public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Krzysztof Koch" <krzysztof.koch@arm.com>
To: <devel@edk2.groups.io>
Cc: <ray.ni@intel.com>, <zhichao.gao@intel.com>,
	<Sami.Mujawar@arm.com>, <Matteo.Carlini@arm.com>,
	<Laura.Moretta@arm.com>, <nd@arm.com>
Subject: [PATCH v1 1/3] ShellPkg: acpiview: Add -r parameter for table requirements validation
Date: Wed, 25 Mar 2020 09:39:22 +0000	[thread overview]
Message-ID: <20200325093924.22884-2-krzysztof.koch@arm.com> (raw)
In-Reply-To: <20200325093924.22884-1-krzysztof.koch@arm.com>

Define a new command line parameter '-r' to enable checking if all
mandatory ACPI tables listed in a specification are present.

The -r parameter takes an integer value to specify which specification
the validation should be performed against.

The parameter is used to set two Acpiview variables. An interface to
access these variables is implemented in this patch.

The new functionality is aimed at Arm-based platforms, however,
there are no restriction on extending it to other architectures.
For the 32-bit and 64-bit Arm architectures, the possible values for
the -r parameter are:
  0: Arm Server Base Boot Requirements 1.0, March 2016
  1: Arm Server Base Boot Requirements 1.1, May 2018
  2: Arm Server Base Boot Requirements 1.2, September 2019

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---

Notes:
    v1:
    - add '-r' parameter for table requirements validaiton [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      | 82 +++++++++++++++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h                      | 44 ++++++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni | 14 +++-
 3 files changed, 136 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index de0851dd5fbae51308def95bd4964f792fb9e680..49c2e87c430d7fb57793f6405ebee91cb8f6cbaa 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -27,6 +27,8 @@ 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.
@@ -37,6 +39,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-h", TypeFlag},
   {L"-l", TypeFlag},
   {L"-s", TypeValue},
+  {L"-r", TypeValue},
   {NULL, TypeMax}
 };
 
@@ -94,6 +97,60 @@ SetConsistencyChecking (
   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.
 
@@ -470,6 +527,7 @@ ShellCommandRunAcpiView (
   LIST_ENTRY*        Package;
   CHAR16*            ProblemParam;
   SHELL_FILE_HANDLE  TmpDumpFileHandle;
+  CONST CHAR16*      MandatoryTableSpecStr;
 
   // Set Defaults
   mReportType = ReportAll;
@@ -479,6 +537,8 @@ ShellCommandRunAcpiView (
   mSelectedAcpiTableName = NULL;
   mSelectedAcpiTableFound = FALSE;
   mConsistencyCheck = TRUE;
+  mMandatoryTableValidate = FALSE;
+  mMandatoryTableSpec = 0;
 
   ShellStatus = SHELL_SUCCESS;
   Package = NULL;
@@ -537,6 +597,18 @@ ShellCommandRunAcpiView (
         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 (
@@ -568,6 +640,14 @@ ShellCommandRunAcpiView (
       // 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")) {
         mReportType = ReportTableList;
       } else {
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index b5cb274ecbf77f7ccb81d78f852caa0f50854312..be65564c86a67a03e71b11f3b2ecde7a21016736 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for AcpiView
 
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -112,6 +112,48 @@ 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/UefiShellAcpiViewCommandLib.uni b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
index 1f07b7ae20d474be67a433ff3774a508a5289318..7cd43d0518fd0a23dc547a5cab0d08b62602a113 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
@@ -1,6 +1,6 @@
 // /**
 //
-// 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
 //
 // Module Name:
@@ -30,7 +30,7 @@
 "Display ACPI Table information.\r\n"
 ".SH SYNOPSIS\r\n"
 " \r\n"
-"ACPIVIEW [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h]]\r\n"
+"ACPIVIEW [[-?] | [[[[-l] | [-s AcpiTable [-d]]] [-q] [-h]] [-r Spec]]]\r\n"
 " \r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
@@ -41,6 +41,12 @@
 "  -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"
@@ -118,6 +124,10 @@
 "  * To display contents of all ACPI tables:\r\n"
 "    fs0:\> acpiview\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:\> acpiview -r 2\r\n"
+" \r\n"
 ".SH RETURNVALUES\r\n"
 " \r\n"
 "RETURN VALUES:\r\n"
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


  reply	other threads:[~2020-03-25  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  9:39 [PATCH v1 0/3] Check if required ACPI tables are installed Krzysztof Koch
2020-03-25  9:39 ` Krzysztof Koch [this message]
2020-03-25  9:39 ` [PATCH v1 2/3] ShellPkg: acpiview: Add library for SBBR ACPI requirements validation Krzysztof Koch
2020-03-25  9:39 ` [PATCH v1 3/3] ShellPkg: acpiview: Check if SBBR mandatory ACPI tables are installed Krzysztof Koch
2020-04-03 10:41 ` [PATCH v1 0/3] Check if required " Sami Mujawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325093924.22884-2-krzysztof.koch@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox