]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
ShellPkg: acpiview: Remove duplicate ACPI structure size definitions
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiParser.c
index 2d6ff80e299eebe7853061d3db89332197c0dc0e..3f12a33050a4e4ab3be2187c90ef8dcf0882283d 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
@@ -121,6 +121,10 @@ VerifyChecksum (
   UINT8 Checksum;\r
   UINTN OriginalAttribute;\r
 \r
+  //\r
+  // set local variables to suppress incorrect compiler/analyzer warnings\r
+  //\r
+  OriginalAttribute = 0;\r
   ByteCount = 0;\r
   Checksum = 0;\r
 \r
@@ -290,7 +294,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
@@ -401,6 +405,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
@@ -472,6 +509,10 @@ ParseAcpi (
   BOOLEAN HighLight;\r
   UINTN   OriginalAttribute;\r
 \r
+  //\r
+  // set local variables to suppress incorrect compiler/analyzer warnings\r
+  //\r
+  OriginalAttribute = 0;\r
   Offset = 0;\r
 \r
   // Increment the Indent\r
@@ -502,8 +543,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
@@ -625,7 +673,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
@@ -646,7 +694,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
@@ -680,7 +728,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