Bugzilla: 3773 (https://bugzilla.tianocore.org/show_bug.cgi?id=3773)

Rewrite SBBR validation into the validator framework. This decouples the
SBBR validations from the internal workings of the Acpiview application.

Signed-off-by: Chris Jones <christopher.jo...@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h               
   | 91 ------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf   
   |  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.c       
   |  3 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.h       
   | 31 ++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/{ => 
Validators}/Arm/SbbrValidator.c | 97 +++++++++++++++++++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.h    
   | 49 ++++++++++
 6 files changed, 178 insertions(+), 97 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
deleted file mode 100644
index 
b6d46af776f081834cd3c396e6310d0f6b961659..0000000000000000000000000000000000000000
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @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 
04913451289ebaf013e8290e46b462a554c9d825..41c222e75cdc46ec110a8aeae22e8a70d7c8769d
 100644
--- 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -58,8 +58,8 @@ [Sources.common]
   UefiShellAcpiViewCommandLib.uni
 
 [Sources.ARM, Sources.AARCH64]
-  Arm/SbbrValidator.h
-  Arm/SbbrValidator.c
+  Validators/Arm/SbbrValidator.h
+  Validators/Arm/SbbrValidator.c
 
 [Packages]
   MdeModulePkg/MdeModulePkg.dec
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.c
index 
8e12e19f2b67e1c4305585ed1384f82c401ec49e..48551ff66df12fb6a567cfb2c023c14131c03c25
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.c
@@ -13,6 +13,9 @@
   List of all validators that can be run.
 **/
 ACPI_VALIDATOR  mValidatorList[] = {
+  { ValidatorIdSbbr10,       Sbbr10Validate       },
+  { ValidatorIdSbbr11,       Sbbr11Validate       },
+  { ValidatorIdSbbr12,       Sbbr12Validate       },
   { ValidatorIdAcpiStandard, AcpiStandardValidate }
 };
 
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.h
index 
b7c5512ec673318ba2f15a8b986d33bdea6ec458..d2db02a803eaaad2cf896677662b4ffb403decd5
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/AcpiValidation.h
@@ -12,8 +12,11 @@
   ID's for all known validators.
 **/
 typedef enum {
-  ValidatorIdAcpiStandard = 0,     ///< Platform agnostic ACPI spec checks.
-  ValidatorIdMax          = 1
+  ValidatorIdSbbr10       = 0,   ///< Arm SBBR 1.0 specification checks
+  ValidatorIdSbbr11       = 1,   ///< Arm SBBR 1.1 specification checks
+  ValidatorIdSbbr12       = 2,   ///< Arm SBBR 1.2 specification checks
+  ValidatorIdAcpiStandard = 3,   ///< Platform agnostic ACPI spec checks.
+  ValidatorIdMax          = 4
 } VALIDATOR_ID;
 
 /**
@@ -50,4 +53,28 @@ AcpiStandardValidate (
   VOID
   );
 
+/**
+  Definition in Arm/SbbrValidator.c
+**/
+VOID
+EFIAPI
+Sbbr10Validate (
+  );
+
+/**
+  Definition in Arm/SbbrValidator.c
+**/
+VOID
+EFIAPI
+Sbbr11Validate (
+  );
+
+/**
+  Definition in Arm/SbbrValidator.c
+**/
+VOID
+EFIAPI
+Sbbr12Validate (
+  );
+
 #endif
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.c
similarity index 74%
rename from ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
rename to 
ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.c
index 
5b0e578af942adc8374f51fa4a53b52d1c0a7d61..d72b3ae861e9ca862819edd631c757b2368a7a79
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.c
@@ -1,7 +1,7 @@
 /** @file
   Arm Server Base Boot Requirements ACPI table requirement validator.
 
-  Copyright (c) 2020, ARM Limited. All rights reserved.
+  Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Glossary:
@@ -18,7 +18,9 @@
 #include <Library/DebugLib.h>
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
-#include "Arm/SbbrValidator.h"
+#include "AcpiViewConfig.h"
+#include "Validators/AcpiDataStore.h"
+#include "SbbrValidator.h"
 
 /**
   SBBR specification version strings
@@ -221,3 +223,94 @@ ArmSbbrReqsValidate (
 
   return IsArmSbbrViolated ? EFI_NOT_FOUND : EFI_SUCCESS;
 }
+
+/**
+  Validate that the mandatory ACPI tables have been installed according to the
+  SBBR specification.
+
+  @param [in]  Version      SBBR spec version to validate against.
+**/
+VOID
+EFIAPI
+ValidateSbbrMandatoryTables (
+  ARM_SBBR_VERSION  Version
+  )
+{
+  EFI_STATUS      Status;
+  META_DATA_NODE  *TableListHead;
+  META_DATA_NODE  *TableList;
+  UINT32          Signature;
+
+  Status = GetMetaDataListHead (MetaDataInstalledTables, &TableListHead);
+  if (EFI_ERROR (Status)) {
+    IncrementErrorCount ();
+    Print (
+      L"\nERROR: Cannot get list of installed tables."
+      L" Status = 0x%x.",
+      Status
+      );
+    return;
+  }
+
+  TableList = (META_DATA_NODE *)GetFirstNode (&TableListHead->Link);
+
+  while (!IsNull (&TableListHead->Link, &TableList->Link)) {
+    Signature = *(UINT32 *)TableList->Data;
+    ArmSbbrIncrementTableCount (Signature);
+
+    TableList = (META_DATA_NODE *)GetNextNode (
+                                    &TableListHead->Link,
+                                    &TableList->Link
+                                    );
+  }
+
+  Status = ArmSbbrReqsValidate (Version);
+  if (EFI_ERROR (Status)) {
+    Print (L"\nERROR: Failed to validate SBBR mandatory tables.\n");
+    return;
+  }
+
+  ArmSbbrResetTableCounts ();
+}
+
+/**
+  Validate that the mandatory ACPI tables have been installed according to the
+  SBBR 1.0 specification.
+**/
+VOID
+EFIAPI
+Sbbr10Validate (
+  )
+{
+  if (GetReportOption () != ReportSelected) {
+    ValidateSbbrMandatoryTables (ArmSbbrVersion_1_0);
+  }
+}
+
+/**
+  Validate that the mandatory ACPI tables have been installed according to the
+  SBBR 1.1 specification.
+**/
+VOID
+EFIAPI
+Sbbr11Validate (
+  )
+{
+  if (GetReportOption () != ReportSelected) {
+    ValidateSbbrMandatoryTables (ArmSbbrVersion_1_1);
+  }
+}
+
+/**
+  Validate that the mandatory ACPI tables have been installed according to the
+  SBBR 1.2 specification.
+**/
+VOID
+EFIAPI
+Sbbr12Validate (
+  )
+{
+  if (GetReportOption () != ReportSelected) {
+    ValidateSbbrMandatoryTables (ArmSbbrVersion_1_2);
+  }
+}
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.h
new file mode 100644
index 
0000000000000000000000000000000000000000..4a7fc766c0e603c27924ecfa42a5603c018f3cdd
--- /dev/null
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Validators/Arm/SbbrValidator.h
@@ -0,0 +1,49 @@
+/** @file
+  Header file for SbbrValidator.c
+
+  Copyright (c) 2021, 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;
+
+#endif // SBBR_VALIDATOR_H_
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84921): https://edk2.groups.io/g/devel/message/84921
Mute This Topic: https://groups.io/mt/87748597/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to