//\r
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r
//\r
- // Get FvHeader alignment\r
+ // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume\r
+ // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from\r
+ // its initial linked location and maintain its alignment.\r
//\r
- FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
- //\r
- // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value. \r
- //\r
- if (FvAlignment < 8) {\r
- FvAlignment = 8;\r
- }\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
- Status = EFI_OUT_OF_RESOURCES;\r
- } else {\r
+ if ((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {\r
//\r
- // Move FvImage into the aligned buffer and release the original buffer.\r
+ // Get FvHeader alignment\r
//\r
- CopyMem (AlignedBuffer, Buffer, BufferSize);\r
- CoreFreePool (Buffer);\r
- Buffer = NULL;\r
+ FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
//\r
- // Produce a FVB protocol for the file\r
+ // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.\r
//\r
- 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
+ // 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
+ //\r
+ // Produce a FVB protocol for the file\r
+ //\r
+ Status = ProduceFVBProtocolOnBuffer (\r
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+ (UINT64)BufferSize,\r
+ FvHandle,\r
+ AuthenticationStatus,\r
+ NULL\r
+ );\r
}\r
\r
if (EFI_ERROR (Status)) {\r