]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
ShellPkg/AcpiView: Refactor configuration
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiParser.c
index 94bafa22ef4c427f2e27cad3d8d96b1bd44e4633..02f6d771c7e1a9b8faa577b38e51c9de350d24fd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   ACPI parser\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
 \r
@@ -10,6 +10,7 @@
 #include <Library/UefiBootServicesTableLib.h>\r
 #include "AcpiParser.h"\r
 #include "AcpiView.h"\r
+#include "AcpiViewConfig.h"\r
 \r
 STATIC UINT32   gIndent;\r
 STATIC UINT32   mTableErrorCount;\r
@@ -294,7 +295,7 @@ DumpUint64 (
 \r
   Val = *(UINT32*)(Ptr + sizeof (UINT32));\r
 \r
-  Val <<= 32;\r
+  Val = LShiftU64(Val,32);\r
   Val |= (UINT64)*(UINT32*)Ptr;\r
 \r
   Print (Format, Val);\r
@@ -405,6 +406,39 @@ Dump8Chars (
     );\r
 }\r
 \r
+/**\r
+  This function traces 12 characters which can be optionally\r
+  formated using the format string if specified.\r
+\r
+  If no format string is specified the Format must be NULL.\r
+\r
+  @param [in] Format  Optional format string for tracing the data.\r
+  @param [in] Ptr     Pointer to the start of the buffer.\r
+**/\r
+VOID\r
+EFIAPI\r
+Dump12Chars (\r
+  IN CONST CHAR16* Format OPTIONAL,\r
+  IN       UINT8*  Ptr\r
+  )\r
+{\r
+  Print (\r
+    (Format != NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c",\r
+    Ptr[0],\r
+    Ptr[1],\r
+    Ptr[2],\r
+    Ptr[3],\r
+    Ptr[4],\r
+    Ptr[5],\r
+    Ptr[6],\r
+    Ptr[7],\r
+    Ptr[8],\r
+    Ptr[9],\r
+    Ptr[10],\r
+    Ptr[11]\r
+    );\r
+}\r
+\r
 /**\r
   This function indents and prints the ACPI table Field Name.\r
 \r
@@ -510,8 +544,15 @@ ParseAcpi (
 \r
   for (Index = 0; Index < ParserItems; Index++) {\r
     if ((Offset + Parser[Index].Length) > Length) {\r
+\r
+      // For fields outside the buffer length provided, reset any pointers\r
+      // which were supposed to be updated by this function call\r
+      if (Parser[Index].ItemPtr != NULL) {\r
+        *Parser[Index].ItemPtr = NULL;\r
+      }\r
+\r
       // We don't parse past the end of the max length specified\r
-      break;\r
+      continue;\r
     }\r
 \r
     if (GetConsistencyChecking () &&\r
@@ -633,7 +674,7 @@ DumpGas (
   IN UINT8*        Ptr\r
   )\r
 {\r
-  DumpGasStruct (Ptr, 2, GAS_LENGTH);\r
+  DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE));\r
 }\r
 \r
 /**\r
@@ -654,7 +695,7 @@ DumpAcpiHeader (
            0,\r
            "ACPI Table Header",\r
            Ptr,\r
-           ACPI_DESCRIPTION_HEADER_LENGTH,\r
+           sizeof (EFI_ACPI_DESCRIPTION_HEADER),\r
            PARSER_PARAMS (AcpiHeaderParser)\r
            );\r
 }\r
@@ -688,7 +729,7 @@ ParseAcpiHeader (
                   0,\r
                   NULL,\r
                   Ptr,\r
-                  ACPI_DESCRIPTION_HEADER_LENGTH,\r
+                  sizeof (EFI_ACPI_DESCRIPTION_HEADER),\r
                   PARSER_PARAMS (AcpiHeaderParser)\r
                   );\r
 \r