+/**\r
+ Check FV alignment.\r
+\r
+ @param BaseAddress The base address of the Firmware Volume.\r
+ @param Length The size of the Firmware Volume in bytes.\r
+\r
+ @retval TRUE FvImage buffer is at its required alignment.\r
+ @retval FALSE FvImage buffer is not at its required alignment.\r
+\r
+**/\r
+BOOLEAN\r
+InternalCheckFvAlignment (\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
+ IN UINT64 Length\r
+ )\r
+{\r
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ UINT32 FvAlignment;\r
+\r
+ FvAlignment = 0;\r
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+\r
+ //\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
+ if ((FwVolHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {\r
+ //\r
+ // Get FvHeader alignment\r
+ //\r
+ FvAlignment = 1 << ((FwVolHeader->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
+ if ((UINTN)BaseAddress % FvAlignment != 0) {\r
+ //\r
+ // FvImage buffer is not at its required alignment.\r
+ //\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n",\r
+ BaseAddress,\r
+ Length,\r
+ FvAlignment\r
+ ));\r
+ return FALSE;\r
+ }\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r