- Status = ProduceFVBProtocolOnBuffer (\r
- (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,\r
- (UINT64)BufferSize,\r
- FvHandle,\r
- AuthenticationStatus,\r
- NULL\r
- );\r
+ if (FvAlignment < 8) {\r
+ FvAlignment = 8;\r
+ }\r
+\r
+ //\r
+ // Check FvImage alignment.\r
+ //\r
+ if ((UINTN) FvHeader % FvAlignment != 0) {\r
+ //\r
+ // Allocate the aligned buffer for the FvImage.\r
+ //\r
+ AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r
+ if (AlignedBuffer == NULL) {\r
+ FreePool (Buffer);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ } else {\r
+ //\r
+ // Move FvImage into the aligned buffer and release the original buffer.\r
+ //\r
+ CopyMem (AlignedBuffer, Buffer, BufferSize);\r
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;\r
+ CoreFreePool (Buffer);\r
+ Buffer = NULL;\r
+ }\r
+ }\r