]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: Add GT Frame Number validation to GTDT parser
authorKrzysztof Koch <krzysztof.koch@arm.com>
Thu, 16 May 2019 08:43:35 +0000 (01:43 -0700)
committerJaben Carsey <jaben.carsey@intel.com>
Fri, 17 May 2019 15:09:21 +0000 (08:09 -0700)
The ACPI 6.2 specification mandates that the Generic Timer (GT) Block
Timer Structures must have a frame number in the range 0-7.

Update the GTDT parser to warn if this condition is violated.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c

index f31c4a2761751c58d4b1d3eb75084e24ec318e7f..1b7e56486c8fb98a8fe063ae5fa25d86500a58a9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   GTDT table parser\r
 \r
 /** @file\r
   GTDT table parser\r
 \r
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.\r
+  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Reference(s):\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Reference(s):\r
@@ -38,6 +38,21 @@ ValidateGtBlockTimerCount (
   IN VOID*  Context\r
   );\r
 \r
   IN VOID*  Context\r
   );\r
 \r
+/**\r
+  This function validates the GT Frame Number.\r
+\r
+  @param [in] Ptr     Pointer to the start of the field data.\r
+  @param [in] Context Pointer to context specific information e.g. this\r
+                      could be a pointer to the ACPI table header.\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+ValidateGtFrameNumber (\r
+  IN UINT8* Ptr,\r
+  IN VOID*  Context\r
+  );\r
+\r
 /**\r
   An ACPI_PARSER array describing the ACPI GTDT Table.\r
 **/\r
 /**\r
   An ACPI_PARSER array describing the ACPI GTDT Table.\r
 **/\r
@@ -92,7 +107,7 @@ STATIC CONST ACPI_PARSER GtBlockParser[] = {
   An ACPI_PARSER array describing the GT Block timer.\r
 **/\r
 STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {\r
   An ACPI_PARSER array describing the GT Block timer.\r
 **/\r
 STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {\r
-  {L"Frame Number", 1, 0, L"%d", NULL, NULL, NULL, NULL},\r
+  {L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL},\r
   {L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},\r
   {L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},\r
   {L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL,\r
   {L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},\r
   {L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},\r
   {L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL,\r
@@ -145,6 +160,34 @@ ValidateGtBlockTimerCount (
   }\r
 }\r
 \r
   }\r
 }\r
 \r
+/**\r
+  This function validates the GT Frame Number.\r
+\r
+  @param [in] Ptr     Pointer to the start of the field data.\r
+  @param [in] Context Pointer to context specific information e.g. this\r
+                      could be a pointer to the ACPI table header.\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+ValidateGtFrameNumber (\r
+  IN UINT8* Ptr,\r
+  IN VOID*  Context\r
+  )\r
+{\r
+  UINT8 FrameNumber;\r
+\r
+  FrameNumber = *(UINT8*)Ptr;\r
+\r
+  if (FrameNumber > 7) {\r
+    IncrementErrorCount ();\r
+    Print (\r
+      L"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-7.",\r
+      FrameNumber\r
+      );\r
+  }\r
+}\r
+\r
 /**\r
   This function parses the Platform GT Block.\r
 \r
 /**\r
   This function parses the Platform GT Block.\r
 \r