]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Cache FvImage at buffer with its required alignment.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Dec 2007 10:25:56 +0000 (10:25 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Dec 2007 10:25:56 +0000 (10:25 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4372 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c

index 0529d36d7944d0db7574b12da16c14daf67dc4b3..bb49686875f1665107199a9bfbbbb1378e7e1452 100644 (file)
@@ -1084,7 +1084,6 @@ Returns:
             if (FvFoundInHobFv2 (FvHandle, &NameGuid)) {\r
               continue;\r
             }\r
-            \r
             //\r
             // Found a firmware volume image. Produce a firmware volume block\r
             // protocol for it so it gets dispatched from. This is usually a \r
index 16b7d8c10c762b16122ac4518a0a5b31bebfac37..2490979a70a333eafc9acaede66b06b838f18a33 100644 (file)
@@ -82,6 +82,7 @@ Revision History
 #include <Library/CacheMaintenanceLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/PeCoffLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 #include "DebugImageInfo.h"\r
 #include "Library.h"\r
index 981c12d7f8c85834fb59933f38f1324292ba96f9..ce6d55f654d3c709ff06e2d48c2f5edc79dfcc90 100644 (file)
@@ -87,6 +87,7 @@
   DxeCoreEntryPoint\r
   PeCoffLib\r
   ExtractGuidedSectionLib\r
+  MemoryAllocationLib\r
 \r
 [Guids]\r
   gEfiEventLegacyBootGuid                       # ALWAYS_CONSUMED\r
index 1a98e97e9a6738d1b9f013bdab597103f9c635e3..67dd803861d7ba8e73f5b04e566283ca0fd83569 100644 (file)
@@ -412,11 +412,14 @@ Returns:
   UINTN                                                 Instance;\r
   UINT8                                                 *CopyBuffer;\r
   UINTN                                                 SectionSize;\r
+  EFI_FIRMWARE_VOLUME_HEADER                            *FvHeader;\r
+  UINT32                                                FvAlignment;  \r
+  \r
   \r
-\r
   OldTpl = CoreRaiseTpl (TPL_NOTIFY);\r
   Instance = SectionInstance + 1;\r
-  \r
+  FvHeader = NULL;\r
+  FvAlignment = 0;\r
   //\r
   // Locate target stream\r
   //\r
@@ -469,8 +472,19 @@ Returns:
   } else {\r
     //\r
     // Callee allocated buffer.  Allocate buffer and return size.\r
+    // For FvImage, the buffer is allocated at its required alignment.\r
     //\r
-    *Buffer = CoreAllocateBootServicesPool (CopySize);\r
+    if (*SectionType == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) {\r
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) CopyBuffer;\r
+      FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
+      //\r
+      // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
+      // \r
+      if (FvAlignment < 8) {\r
+        FvAlignment = 8;\r
+      }\r
+    }\r
+    *Buffer = AllocateAlignedPool ((UINTN) CopySize, (UINTN) FvAlignment);\r
     if (*Buffer == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto GetSection_Done;\r