* [PATCH v1 1/3] ShellPkg: acpiview: Add -r parameter for table requirements validation
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
2020-03-25 9:39 ` [PATCH v1 2/3] ShellPkg: acpiview: Add library for SBBR ACPI " Krzysztof Koch
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Koch @ 2020-03-25 9:39 UTC (permalink / raw)
To: devel; +Cc: ray.ni, zhichao.gao, Sami.Mujawar, Matteo.Carlini, Laura.Moretta,
nd
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)'
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] ShellPkg: acpiview: Add library for SBBR ACPI requirements validation
2020-03-25 9:39 [PATCH v1 0/3] Check if required ACPI tables are installed Krzysztof Koch
2020-03-25 9:39 ` [PATCH v1 1/3] ShellPkg: acpiview: Add -r parameter for table requirements validation Krzysztof Koch
@ 2020-03-25 9:39 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Koch @ 2020-03-25 9:39 UTC (permalink / raw)
To: devel; +Cc: ray.ni, zhichao.gao, Sami.Mujawar, Matteo.Carlini, Laura.Moretta,
nd
For Arm-based platforms, define and implement an interface for Server
Base Boot Requirements (SBBR) compliance checks. The library is
responsible for validating that all mandatory ACPI tables are installed
on the platform.
Internally, the library maintains a data structure which tracks
instance counts for ACPI tables which are labeled as 'mandatory' in any
SBBR specification version. The provided interface allows:
- resetting all instance counts to 0
- incremementing the instance count for a table with a given signature
- validating the instance counts against the requirements in SBBR
The ACPI table requirements for each SBBR spec version are represented
internally as a list of table signatures.
Every missing mandatory table (for the input SBBR version) is reported
to the user as a separate error. If all requirements are met, an info
message is displayed.
Reference(s):
- Arm Server Base Boot Requirements 1.2, September 2019
- Arm Server Base Boot Requirements 1.1, May 2018
- Arm Server Base Boot Requirements 1.0, March 2016
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---
Notes:
v1:
- add library for SBBR ACPI requirements validation [Krzysztof]
ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c | 222 ++++++++++++++++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h | 91 ++++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 6 +-
3 files changed, 318 insertions(+), 1 deletion(-)
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
new file mode 100644
index 0000000000000000000000000000000000000000..d3284417fa5f4da1c29ba56b8587f1119c776278
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
@@ -0,0 +1,222 @@
+/** @file
+ Arm Server Base Boot Requirements ACPI table requirement validator.
+
+ Copyright (c) 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Glossary:
+ - Sbbr or SBBR - Server Base Boot Requirements
+ - Sbsa or SBSA - Server Base System Architecture
+
+ @par Reference(s):
+ - Arm Server Base Boot Requirements 1.2, September 2019
+ - Arm Server Base Boot Requirements 1.1, May 2018
+ - Arm Server Base Boot Requirements 1.0, March 2016
+ - Arm Server Base System Architecture 6.0
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include "AcpiParser.h"
+#include "Arm/SbbrValidator.h"
+
+/**
+ SBBR specification version strings
+**/
+STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] = {
+ "1.0", // ArmSbbrVersion_1_0
+ "1.1", // ArmSbbrVersion_1_1
+ "1.2" // ArmSbbrVersion_1_2
+};
+
+/**
+ SBBR 1.0 mandatory ACPI tables
+**/
+STATIC CONST UINT32 ArmSbbr10Mandatory[] = {
+ EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
+};
+
+/**
+ SBBR 1.1 mandatory ACPI tables
+**/
+STATIC CONST UINT32 ArmSbbr11Mandatory[] = {
+ EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE
+};
+
+/**
+ SBBR 1.2 mandatory ACPI tables
+**/
+STATIC CONST UINT32 ArmSbbr12Mandatory[] = {
+ EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE
+};
+
+/**
+ Mandatory ACPI tables for every SBBR specification version.
+**/
+STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = {
+ { ArmSbbr10Mandatory, ARRAY_SIZE (ArmSbbr10Mandatory) }, // SBBR v1.0
+ { ArmSbbr11Mandatory, ARRAY_SIZE (ArmSbbr11Mandatory) }, // SBBR v1.1
+ { ArmSbbr12Mandatory, ARRAY_SIZE (ArmSbbr12Mandatory) } // SBBR v1.2
+};
+
+/**
+ Data structure to track instance counts for all ACPI tables which are
+ defined as 'mandatory' in any SBBR version.
+**/
+STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = {
+ {EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, 0},
+ {EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0}
+};
+
+/**
+ Reset the platform ACPI table instance count for all SBBR-mandatory tables.
+**/
+VOID
+EFIAPI
+ArmSbbrResetTableCounts (
+ VOID
+ )
+{
+ UINT32 Table;
+
+ for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) {
+ ArmSbbrTableCounts[Table].Count = 0;
+ }
+}
+
+/**
+ Increment instance count for SBBR-mandatory ACPI table with the given
+ signature.
+
+ @param [in] Signature ACPI table signature.
+
+ @retval TRUE Count incremented successfully.
+ @retval FALSE Table with the input signature not found.
+**/
+BOOLEAN
+EFIAPI
+ArmSbbrIncrementTableCount (
+ UINT32 Signature
+ )
+{
+ UINT32 Table;
+
+ for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) {
+ if (Signature == ArmSbbrTableCounts[Table].Signature) {
+ ArmSbbrTableCounts[Table].Count++;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ Validate that all ACPI tables required by the given SBBR specification
+ version are installed on the platform.
+
+ @param [in] Version SBBR spec version to validate against.
+
+ @retval EFI_SUCCESS All required tables are present.
+ @retval EFI_INVALID_PARAMETER Invalid SBBR version.
+ @retval EFI_NOT_FOUND One or more mandatory tables are missing.
+ @retval EFI_UNSUPPORTED Mandatory ACPI table does not have its
+ instance count tracked.
+**/
+EFI_STATUS
+EFIAPI
+ArmSbbrReqsValidate (
+ ARM_SBBR_VERSION Version
+ )
+{
+ UINT32 Table;
+ UINT32 Index;
+ UINT32 MandatoryTable;
+ CONST UINT8* SignaturePtr;
+ BOOLEAN IsArmSbbrViolated;
+
+ if (Version >= ArmSbbrVersionMax) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IsArmSbbrViolated = FALSE;
+
+ // Go through the list of mandatory tables for the input SBBR version
+ for (Table = 0; Table < ArmSbbrReqs[Version].TableCount; Table++) {
+ MandatoryTable = ArmSbbrReqs[Version].Tables[Table];
+ SignaturePtr = (CONST UINT8*)(UINTN)&MandatoryTable;
+
+ // Locate the instance count for the table with the given signature
+ Index = 0;
+ while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) &&
+ (ArmSbbrTableCounts[Index].Signature != MandatoryTable)) {
+ Index++;
+ }
+
+ if (Index >= ARRAY_SIZE (ArmSbbrTableCounts)) {
+ IncrementErrorCount ();
+ Print (
+ L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table's instance count not " \
+ L"found\n",
+ ArmSbbrVersions[Version],
+ SignaturePtr[0],
+ SignaturePtr[1],
+ SignaturePtr[2],
+ SignaturePtr[3]
+ );
+ return EFI_UNSUPPORTED;
+ }
+
+ if (ArmSbbrTableCounts[Index].Count == 0) {
+ IsArmSbbrViolated = TRUE;
+ IncrementErrorCount ();
+ Print (
+ L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table is missing",
+ ArmSbbrVersions[Version],
+ SignaturePtr[0],
+ SignaturePtr[1],
+ SignaturePtr[2],
+ SignaturePtr[3]
+ );
+ }
+ }
+
+ if (!IsArmSbbrViolated) {
+ Print (
+ L"\nINFO: SBBR v%a: All mandatory ACPI tables are installed",
+ ArmSbbrVersions[Version]
+ );
+ }
+
+ Print (L"\n");
+
+ return IsArmSbbrViolated ? EFI_NOT_FOUND : EFI_SUCCESS;
+}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
new file mode 100644
index 0000000000000000000000000000000000000000..3135f74fcb6c2d41d8abccc6067c0d6d40f3d089
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
@@ -0,0 +1,91 @@
+/** @file
+ Header file for SbbrValidator.c
+
+ Copyright (c) 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Glossary:
+ - Sbbr or SBBR - Server Base Boot Requirements
+ - Sbsa or SBSA - Server Base System Architecture
+
+ @par Reference(s):
+ - Arm Server Base Boot Requirements 1.2, September 2019
+ - Arm Server Base Boot Requirements 1.1, May 2018
+ - Arm Server Base Boot Requirements 1.0, March 2016
+ - Arm Server Base System Architecture 6.0
+**/
+
+#ifndef SBBR_VALIDATOR_H_
+#define SBBR_VALIDATOR_H_
+
+#include <IndustryStandard/Acpi.h>
+
+/**
+ Arm SBBR specification versions.
+**/
+typedef enum {
+ ArmSbbrVersion_1_0 = 0,
+ ArmSbbrVersion_1_1 = 1,
+ ArmSbbrVersion_1_2 = 2,
+ ArmSbbrVersionMax = 3
+} ARM_SBBR_VERSION;
+
+/**
+ The ACPI table instance counter.
+**/
+typedef struct AcpiTableCounter {
+ CONST UINT32 Signature; /// ACPI table signature
+ UINT32 Count; /// Instance count
+} ACPI_TABLE_COUNTER;
+
+/**
+ ACPI table SBBR requirements.
+**/
+typedef struct AcpiSbbrReq {
+ CONST UINT32* Tables; /// List of required tables
+ CONST UINT32 TableCount; /// Number of elements in Tables
+} ACPI_SBBR_REQ;
+
+/**
+ Reset the platform ACPI table instance count for all SBBR-mandatory tables.
+**/
+VOID
+EFIAPI
+ArmSbbrResetTableCounts (
+ VOID
+ );
+
+/**
+ Increment instance count for SBBR-mandatory ACPI table with the given
+ signature.
+
+ @param [in] Signature ACPI table signature.
+
+ @retval TRUE Count incremented successfully.
+ @retval FALSE Table with the input signature not found.
+**/
+BOOLEAN
+EFIAPI
+ArmSbbrIncrementTableCount (
+ UINT32 Signature
+ );
+
+/**
+ Validate that all ACPI tables required by the given SBBR specification
+ version are installed on the platform.
+
+ @param [in] Version SBBR spec version to validate against.
+
+ @retval EFI_SUCCESS All required tables are present.
+ @retval EFI_INVALID_PARAMETER Invalid SBBR version.
+ @retval EFI_NOT_FOUND One or more mandatory tables are missing.
+ @retval EFI_UNSUPPORTED Mandatory ACPI table does not have its
+ instance count tracked.
+**/
+EFI_STATUS
+EFIAPI
+ArmSbbrReqsValidate (
+ ARM_SBBR_VERSION Version
+ );
+
+#endif // SBBR_VALIDATOR_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index ea504c934aeebaa452a380e6ea169586e467642a..d21ecd40a8cf8f2d99613fde2ddb2a66702e6ad3 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -1,7 +1,7 @@
## @file
# Provides Shell 'acpiview' command functions
#
-# 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
#
@@ -47,6 +47,10 @@ [Sources.common]
Parsers/Madt/MadtParser.h
Parsers/Pptt/PpttParser.h
+[Sources.ARM, Sources.AARCH64]
+ Arm/SbbrValidator.h
+ Arm/SbbrValidator.c
+
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] ShellPkg: acpiview: Check if SBBR mandatory ACPI tables are installed
2020-03-25 9:39 [PATCH v1 0/3] Check if required ACPI tables are installed Krzysztof Koch
2020-03-25 9:39 ` [PATCH v1 1/3] ShellPkg: acpiview: Add -r parameter for table requirements validation Krzysztof Koch
2020-03-25 9:39 ` [PATCH v1 2/3] ShellPkg: acpiview: Add library for SBBR ACPI " Krzysztof Koch
@ 2020-03-25 9:39 ` Krzysztof Koch
2020-04-03 10:41 ` [PATCH v1 0/3] Check if required " Sami Mujawar
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Koch @ 2020-03-25 9:39 UTC (permalink / raw)
To: devel; +Cc: ray.ni, zhichao.gao, Sami.Mujawar, Matteo.Carlini, Laura.Moretta,
nd
For Arm-based platforms, count the instances of installed tables for
each ACPI table listed as 'mandatory' in any Server Base Boot
Requirements (SBBR) specification.
Validate that the all the mandatory SBBR tables present. Report an error
for each missing table.
This new feature is optional and can be enabled with the -r command line
parameter.
Reference(s):
- Arm Server Base Boot Requirements 1.2, September 2019
- Arm Server Base Boot Requirements 1.1, May 2018
- Arm Server Base Boot Requirements 1.0, March 2016
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---
Notes:
v1:
- check if SBBR mandatory ACPI tables are installed [Krzysztof]
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c | 16 ++++++++++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 22 ++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
index 501967c4dde680809c56e5d79ed744a1013a69e1..d5b9eee5232399c4df50d0f9598810413759fed6 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
@@ -3,6 +3,12 @@
Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Glossary:
+ - Sbbr or SBBR - Server Base Boot Requirements
+
+ @par Reference(s):
+ - Arm Server Base Boot Requirements 1.2, September 2019
**/
#include <Uefi.h>
@@ -12,6 +18,10 @@
#include "AcpiTableParser.h"
#include "AcpiView.h"
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+#include "Arm/SbbrValidator.h"
+#endif
+
/**
A list of registered ACPI table parsers.
**/
@@ -216,6 +226,12 @@ ProcessAcpiTable (
}
}
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+ if (GetMandatoryTableValidate ()) {
+ ArmSbbrIncrementTableCount (*AcpiTableSignature);
+ }
+#endif
+
Status = GetParser (*AcpiTableSignature, &ParserProc);
if (EFI_ERROR (Status)) {
// No registered parser found, do default handling.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 49c2e87c430d7fb57793f6405ebee91cb8f6cbaa..84ffb3595750a3e7d65fdb82c0f90bc2d76c659e 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -2,6 +2,12 @@
Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Glossary:
+ - Sbbr or SBBR - Server Base Boot Requirements
+
+ @par Reference(s):
+ - Arm Server Base Boot Requirements 1.2, September 2019
**/
#include <Library/PrintLib.h>
@@ -16,6 +22,10 @@
#include "AcpiView.h"
#include "UefiShellAcpiViewCommandLib.h"
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+#include "Arm/SbbrValidator.h"
+#endif
+
EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
// Report variables
@@ -438,6 +448,12 @@ AcpiView (
return EFI_UNSUPPORTED;
}
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+ if (GetMandatoryTableValidate ()) {
+ ArmSbbrResetTableCounts ();
+ }
+#endif
+
// The RSDP length is 4 bytes starting at offset 20
RsdpLength = *(UINT32*)(RsdpPtr + RSDP_LENGTH_OFFSET);
@@ -466,6 +482,12 @@ AcpiView (
return EFI_NOT_FOUND;
}
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+ if (GetMandatoryTableValidate ()) {
+ ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ());
+ }
+#endif
+
ReportOption = GetReportOption ();
if (ReportTableList != ReportOption) {
if (((ReportSelected == ReportOption) ||
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 0/3] Check if required ACPI tables are installed
2020-03-25 9:39 [PATCH v1 0/3] Check if required ACPI tables are installed Krzysztof Koch
` (2 preceding siblings ...)
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 ` Sami Mujawar
3 siblings, 0 replies; 5+ messages in thread
From: Sami Mujawar @ 2020-04-03 10:41 UTC (permalink / raw)
To: Krzysztof Koch, devel@edk2.groups.io
Cc: ray.ni@intel.com, zhichao.gao@intel.com, Matteo Carlini,
Laura Moretta, nd
For this patch series.
Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com>
Regards,
Sami Mujawar
-----Original Message-----
From: Krzysztof Koch <krzysztof.koch@arm.com>
Sent: 25 March 2020 09:39 AM
To: devel@edk2.groups.io
Cc: ray.ni@intel.com; zhichao.gao@intel.com; Sami Mujawar <Sami.Mujawar@arm.com>; Matteo Carlini <Matteo.Carlini@arm.com>; Laura Moretta <Laura.Moretta@arm.com>; nd <nd@arm.com>
Subject: [PATCH v1 0/3] Check if required ACPI tables are installed
This patch series adds a new capability to the Acpiview UEFI shell tool.
Using the -r command line parameter, it is now possible to choose a specification which lists mandatory ACPI tables. The parameter value is then consumed by a library which validates ACPI tables identified on the platform against these requirements.
The -r parameter is architecture agnostic. However, as of now, the possible values for the parameter are only defined in the context of the Arm architecture.
For Arm-based platforms, it is now possible to validate that Server Base Boot Requirements (SBBR) mandatory ACPI tables are present on the platform.
Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/617_sbbr_validate_acpi_table_counts_v1
Krzysztof Koch (3):
ShellPkg: acpiview: Add -r parameter for table requirements validation
ShellPkg: acpiview: Add library for SBBR ACPI requirements validation
ShellPkg: acpiview: Check if SBBR mandatory ACPI tables are installed
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c | 16 ++
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 104 ++++++++-
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h | 44 +++-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c | 222 ++++++++++++++++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h | 91 ++++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 6 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni | 14 +-
7 files changed, 492 insertions(+), 5 deletions(-) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply [flat|nested] 5+ messages in thread