]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/FvLib.c
Sync EDKII BaseTools to BaseTools project r1971
[mirror_edk2.git] / BaseTools / Source / C / Common / FvLib.c
index 292b077f34899cfcec818a3db9675889290a5a81..1b289d83cd62a921497968abd10f713201399689 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, 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
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -110,6 +110,7 @@ Returns:
   }\r
 \r
   *FvHeader = mFvHeader;\r
+  *FvLength = mFvLength;\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -200,7 +201,7 @@ Returns:
   //\r
   // Get next file, compensate for 8 byte alignment if necessary.\r
   //\r
-  *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3));\r
+  *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);\r
 \r
   //\r
   // Verify file is in this FV.\r
@@ -703,8 +704,8 @@ Returns:
     // Verify file data checksum\r
     //\r
     FileLength          = GetLength (FfsHeader->Size);\r
-    Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength);\r
-    Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
+    Checksum            = CalculateSum8 ((UINT8 *) (FfsHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));\r
+    Checksum            = Checksum + FfsHeader->IntegrityCheck.Checksum.File;\r
     if (Checksum != 0) {\r
       Error (NULL, 0, 0006, "invalid FFS file checksum", "Ffs file with Guid %s", FileGuidString);\r
       return EFI_ABORTED;\r
@@ -712,7 +713,7 @@ Returns:
   } else {\r
     //\r
     // File does not have a checksum\r
-    // Verify contents are 0x5A as spec'd\r
+    // Verify contents are 0xAA as spec'd\r
     //\r
     if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
       Error (NULL, 0, 0006, "invalid fixed FFS file header checksum", "Ffs file with Guid %s", FileGuidString);\r