/** @file\r
Implements write firmware file.\r
\r
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
#include "FwVolDriver.h"\r
\r
/**\r
- Caculate the checksum for the FFS header.\r
+ Calculate the checksum for the FFS header.\r
\r
- @param FfsHeader FFS File Header which needs to caculate the checksum\r
+ @param FfsHeader FFS File Header which needs to calculate the checksum\r
\r
**/\r
VOID\r
}\r
\r
/**\r
- Caculate the checksum for the FFS File.\r
+ Calculate the checksum for the FFS File.\r
\r
- @param FfsHeader FFS File Header which needs to caculate the checksum\r
+ @param FfsHeader FFS File Header which needs to calculate the checksum\r
@param ActualFileSize The whole Ffs File Length.\r
\r
**/\r
}\r
\r
/**\r
- Caculate the leading Pad file size to meet the alignment requirement.\r
+ Calculate the leading Pad file size to meet the alignment requirement.\r
\r
@param FvDevice Cached Firmware Volume.\r
@param StartAddress The starting address to write the FFS File.\r
\r
**/\r
UINTN\r
-CaculatePadFileSize (\r
+CalculatePadFileSize (\r
IN FV_DEVICE *FvDevice,\r
IN EFI_PHYSICAL_ADDRESS StartAddress,\r
IN UINTN BufferSize,\r
{\r
UINT8 FvFileAlignment;\r
UINT8 FfsFileAlignment;\r
+ UINT8 FfsFileAlignment2;\r
\r
FvFileAlignment = (UINT8) (FvFileAttrib & EFI_FV_FILE_ATTRIB_ALIGNMENT);\r
FfsFileAlignment = 0;\r
+ FfsFileAlignment2 = 0;\r
\r
switch (FvFileAlignment) {\r
case 0:\r
case 16:\r
FfsFileAlignment = 7;\r
break;\r
+\r
+ case 17:\r
+ FfsFileAlignment = 0;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 18:\r
+ FfsFileAlignment = 1;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 19:\r
+ FfsFileAlignment = 2;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 20:\r
+ FfsFileAlignment = 3;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 21:\r
+ FfsFileAlignment = 4;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 22:\r
+ FfsFileAlignment = 5;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 23:\r
+ FfsFileAlignment = 6;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
+ case 24:\r
+ FfsFileAlignment = 7;\r
+ FfsFileAlignment2 = 1;\r
+ break;\r
}\r
\r
- *FfsFileAttrib = (UINT8) (FfsFileAlignment << 3);\r
+ *FfsFileAttrib = (UINT8) ((FfsFileAlignment << 3) | (FfsFileAlignment2 << 1));\r
\r
return ;\r
}\r
// required the file size\r
//\r
while ((LIST_ENTRY *) FreeSpaceListEntry != &FvDevice->FreeSpaceHeader) {\r
- PadFileSize = CaculatePadFileSize (\r
+ PadFileSize = CalculatePadFileSize (\r
FvDevice,\r
(EFI_PHYSICAL_ADDRESS) (UINTN) FreeSpaceListEntry->StartingAddress,\r
Size,\r
PadAreaLength = FFS_FILE_SIZE (FileHeader) - HeaderSize;\r
}\r
\r
- PadFileSize = CaculatePadFileSize (\r
+ PadFileSize = CalculatePadFileSize (\r
FvDevice,\r
(EFI_PHYSICAL_ADDRESS) (UINTN) FileHeader + HeaderSize,\r
Size,\r
TotalSize = 0;\r
\r
for (Index = 0; Index < NumOfFiles; Index++) {\r
- PadSize[Index] = CaculatePadFileSize (\r
+ PadSize[Index] = CalculatePadFileSize (\r
FvDevice,\r
(EFI_PHYSICAL_ADDRESS) (UINTN) FileHeader + HeaderSize + TotalSize,\r
BufferSize[Index],\r
StartAddr = FreeSpaceListEntry->StartingAddress;\r
\r
//\r
- // Caculate the totalsize we need\r
+ // Calculate the totalsize we need\r
//\r
for (Index = 0; Index < NumOfFiles; Index++) {\r
//\r
// Perhaps we don't need an EFI_FFS_FILE_HEADER, the first file\r
// have had its leading pad file.\r
//\r
- PadSize[Index] = CaculatePadFileSize (\r
+ PadSize[Index] = CalculatePadFileSize (\r
FvDevice,\r
(EFI_PHYSICAL_ADDRESS) (UINTN) StartAddr + TotalSize,\r
BufferSize[Index],\r
\r
//\r
// First find a free space that can hold this image.\r
- // Check alignment, FFS at least must be aligned at 8-byte boundry\r
+ // Check alignment, FFS at least must be aligned at 8-byte boundary\r
//\r
RequiredAlignment = GetRequiredAlignment (FileAttributes);\r
\r
FreeSpaceEntry->Length -= (BufferSize - HeaderSize);\r
\r
//\r
- // Caculate File Checksum\r
+ // Calculate File Checksum\r
//\r
SetFileChecksum (FileHeader, ActualFileSize);\r
\r
\r
for (Index1 = 0; Index1 < NumberOfFiles; Index1++) {\r
//\r
- // Making Buffersize QWORD boundry, and add file tail.\r
+ // Making Buffersize QWORD boundary, and add file tail.\r
//\r
HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
ActualSize = FileData[Index1].BufferSize + HeaderSize;\r