]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / Common / FvLib.c
index 341204852c6b7fa773458a28ca69139ae16f2289..f133d358d5c8f02b7fedbd82ec6e71e5acf05378 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -707,8 +707,13 @@ Returns:
     //\r
     FileLength          = GetLength (FfsHeader->Size);\r
     OccupiedFileLength  = (FileLength + 0x07) & (-1 << 3);\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
     Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);\r
     Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
+#else\r
+    Checksum            = CalculateSum8 ((UINT8 *) ((UINTN)FfsHeader + sizeof (EFI_FFS_FILE_HEADER)), FileLength - TailSize - sizeof (EFI_FFS_FILE_HEADER));\r
+    Checksum            =  Checksum + (UINT8)FfsHeader->IntegrityCheck.Checksum.File;\r
+#endif\r
     if (Checksum != 0) {\r
       Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");\r
       return EFI_ABORTED;\r
@@ -716,10 +721,10 @@ Returns:
   } else {\r
     //\r
     // File does not have a checksum\r
-    // Verify contents are 0x5A as spec'd\r
+    // Verify contents are 0x5A(Framework) and 0xAA(PI 1.0) as spec'd\r
     //\r
     if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
-      Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");\r
+      Error (NULL, 0, 0, FileGuidString, "invalid fixed file checksum");\r
       return EFI_ABORTED;\r
     }\r
   }\r