]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
Add core FFS3 support, DxeCore.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / FwVol / FwVolRead.c
index 0b53af27d1fd8902b7caea6c8fed7891a43feaa4..52f84919d132b5111be196c53b14eed5e40e69e3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements functions to read firmware file\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -119,7 +119,6 @@ FvGetNextFile (
   UINTN                                       *KeyValue;\r
   LIST_ENTRY                                  *Link;\r
   FFS_FILE_LIST_ENTRY                         *FfsFileEntry;\r
-  UINTN                                       FileLength;\r
 \r
   FvDevice = FV_DEVICE_FROM_THIS (This);\r
 \r
@@ -201,15 +200,14 @@ FvGetNextFile (
   CopyGuid (NameGuid, &FfsFileHeader->Name);\r
   *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);\r
 \r
-  //\r
-  // Read four bytes out of the 3 byte array and throw out extra data\r
-  //\r
-  FileLength = *(UINT32 *)&FfsFileHeader->Size[0] & 0x00FFFFFF;\r
-\r
   //\r
   // we need to substract the header size\r
   //\r
-  *Size = FileLength - sizeof(EFI_FFS_FILE_HEADER);\r
+  if (IS_FFS_FILE2 (FfsFileHeader)) {\r
+    *Size = FFS_FILE2_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
+  } else {\r
+    *Size = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -333,7 +331,11 @@ FvReadFile (
   //\r
   // Skip over file header\r
   //\r
-  SrcPtr = ((UINT8 *)FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
+  if (IS_FFS_FILE2 (FfsHeader)) {\r
+    SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);\r
+  } else {\r
+    SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
+  }\r
 \r
   Status = EFI_SUCCESS;\r
   if (*Buffer == NULL) {\r
@@ -447,7 +449,7 @@ FvReadFileSection (
   }\r
 \r
   //\r
-  // Use FfsEntry to cache Section Extraction Protocol Inforomation\r
+  // Use FfsEntry to cache Section Extraction Protocol Information\r
   //\r
   if (FfsEntry->StreamHandle == 0) {\r
     Status = OpenSectionStream (\r
@@ -470,7 +472,8 @@ FvReadFileSection (
              (SectionType == 0) ? 0 : SectionInstance,\r
              Buffer,\r
              BufferSize,\r
-             AuthenticationStatus\r
+             AuthenticationStatus,\r
+             FvDevice->IsFfs3Fv\r
              );\r
 \r
   //\r