]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
ShellPkg/AcpiView: Move log reset to main method
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiView.c
index de0851dd5fbae51308def95bd4964f792fb9e680..f1a95b7b8f03b5b3d44fd962bf20f174ccf81c4b 100644 (file)
@@ -1,7 +1,13 @@
 /** @file\r
 \r
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+  @par Glossary:\r
+    - Sbbr or SBBR   - Server Base Boot Requirements\r
+\r
+  @par Reference(s):\r
+    - Arm Server Base Boot Requirements 1.2, September 2019\r
 **/\r
 \r
 #include <Library/PrintLib.h>\r
 #include "AcpiView.h"\r
 #include "UefiShellAcpiViewCommandLib.h"\r
 \r
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r
+#include "Arm/SbbrValidator.h"\r
+#endif\r
+\r
 EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;\r
 \r
 // Report variables\r
@@ -27,6 +37,8 @@ STATIC UINT32             mTableCount;
 STATIC UINT32             mBinTableCount;\r
 STATIC BOOLEAN            mConsistencyCheck;\r
 STATIC BOOLEAN            mColourHighlighting;\r
+STATIC BOOLEAN            mMandatoryTableValidate;\r
+STATIC UINTN              mMandatoryTableSpec;\r
 \r
 /**\r
   An array of acpiview command line parameters.\r
@@ -37,6 +49,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-h", TypeFlag},\r
   {L"-l", TypeFlag},\r
   {L"-s", TypeValue},\r
+  {L"-r", TypeValue},\r
   {NULL, TypeMax}\r
 };\r
 \r
@@ -94,6 +107,60 @@ SetConsistencyChecking (
   mConsistencyCheck = ConsistencyChecking;\r
 }\r
 \r
+/**\r
+  This function returns the ACPI table requirements validation flag.\r
+\r
+  @retval TRUE if check for mandatory table presence should be performed.\r
+**/\r
+BOOLEAN\r
+GetMandatoryTableValidate (\r
+  VOID\r
+  )\r
+{\r
+  return mMandatoryTableValidate;\r
+}\r
+\r
+/**\r
+  This function sets the ACPI table requirements validation flag.\r
+\r
+  @param  Validate    Enable/Disable ACPI table requirements validation.\r
+**/\r
+VOID\r
+SetMandatoryTableValidate (\r
+  BOOLEAN Validate\r
+  )\r
+{\r
+  mMandatoryTableValidate = Validate;\r
+}\r
+\r
+/**\r
+  This function returns the identifier of specification to validate ACPI table\r
+  requirements against.\r
+\r
+  @return   ID of specification listing mandatory tables.\r
+**/\r
+UINTN\r
+GetMandatoryTableSpec (\r
+  VOID\r
+  )\r
+{\r
+  return mMandatoryTableSpec;\r
+}\r
+\r
+/**\r
+  This function sets the identifier of specification to validate ACPI table\r
+  requirements against.\r
+\r
+  @param  Spec      ID of specification listing mandatory tables.\r
+**/\r
+VOID\r
+SetMandatoryTableSpec (\r
+  UINTN Spec\r
+  )\r
+{\r
+  mMandatoryTableSpec = Spec;\r
+}\r
+\r
 /**\r
   This function returns the report options.\r
 \r
@@ -357,6 +424,10 @@ AcpiView (
   EfiConfigurationTable = NULL;\r
   OriginalAttribute = 0;\r
 \r
+  // Reset The error/warning counters\r
+  ResetErrorCount ();\r
+  ResetWarningCount ();\r
+\r
   // Search the table for an entry that matches the ACPI Table Guid\r
   FoundAcpiTable = FALSE;\r
   for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {\r
@@ -381,6 +452,12 @@ AcpiView (
       return EFI_UNSUPPORTED;\r
     }\r
 \r
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r
+    if (GetMandatoryTableValidate ()) {\r
+      ArmSbbrResetTableCounts ();\r
+    }\r
+#endif\r
+\r
     // The RSDP length is 4 bytes starting at offset 20\r
     RsdpLength = *(UINT32*)(RsdpPtr + RSDP_LENGTH_OFFSET);\r
 \r
@@ -409,6 +486,12 @@ AcpiView (
     return EFI_NOT_FOUND;\r
   }\r
 \r
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r
+  if (GetMandatoryTableValidate ()) {\r
+    ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ());\r
+  }\r
+#endif\r
+\r
   ReportOption = GetReportOption ();\r
   if (ReportTableList != ReportOption) {\r
     if (((ReportSelected == ReportOption)  ||\r
@@ -470,6 +553,7 @@ ShellCommandRunAcpiView (
   LIST_ENTRY*        Package;\r
   CHAR16*            ProblemParam;\r
   SHELL_FILE_HANDLE  TmpDumpFileHandle;\r
+  CONST CHAR16*      MandatoryTableSpecStr;\r
 \r
   // Set Defaults\r
   mReportType = ReportAll;\r
@@ -479,15 +563,13 @@ ShellCommandRunAcpiView (
   mSelectedAcpiTableName = NULL;\r
   mSelectedAcpiTableFound = FALSE;\r
   mConsistencyCheck = TRUE;\r
+  mMandatoryTableValidate = FALSE;\r
+  mMandatoryTableSpec = 0;\r
 \r
   ShellStatus = SHELL_SUCCESS;\r
   Package = NULL;\r
   TmpDumpFileHandle = NULL;\r
 \r
-  // Reset The error/warning counters\r
-  ResetErrorCount ();\r
-  ResetWarningCount ();\r
-\r
   Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
   if (EFI_ERROR (Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
@@ -537,6 +619,18 @@ ShellCommandRunAcpiView (
         L"-s"\r
         );\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else if (ShellCommandLineGetFlag (Package, L"-r") &&\r
+               ShellCommandLineGetValue (Package, L"-r") == NULL) {\r
+      ShellPrintHiiEx (\r
+        -1,\r
+        -1,\r
+        NULL,\r
+        STRING_TOKEN (STR_GEN_NO_VALUE),\r
+        gShellAcpiViewHiiHandle,\r
+        L"acpiview",\r
+        L"-r"\r
+        );\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else if ((ShellCommandLineGetFlag (Package, L"-s") &&\r
                 ShellCommandLineGetFlag (Package, L"-l"))) {\r
       ShellPrintHiiEx (\r
@@ -568,6 +662,14 @@ ShellCommandRunAcpiView (
       // Surpress consistency checking if requested\r
       SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));\r
 \r
+      // Evaluate the parameters for mandatory ACPI table presence checks\r
+      SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));\r
+      MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");\r
+\r
+      if (MandatoryTableSpecStr != NULL) {\r
+        SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));\r
+      }\r
+\r
       if (ShellCommandLineGetFlag (Package, L"-l")) {\r
         mReportType = ReportTableList;\r
       } else {\r