]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolWrite.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / FwVolDxe / FwVolWrite.c
index ac3cf0abd883dc050f40765602b26d251e87178d..adb910e9602e6dd0a858495536dd9b614498b2a8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements write firmware file.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, 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
@@ -17,9 +17,9 @@
 #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
@@ -60,9 +60,9 @@ SetHeaderChecksum (
 }\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
@@ -130,7 +130,7 @@ GetRequiredAlignment (
 }\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
@@ -141,7 +141,7 @@ GetRequiredAlignment (
 \r
 **/\r
 UINTN\r
-CaculatePadFileSize (\r
+CalculatePadFileSize (\r
   IN FV_DEVICE            *FvDevice,\r
   IN EFI_PHYSICAL_ADDRESS StartAddress,\r
   IN UINTN                BufferSize,\r
@@ -202,9 +202,11 @@ FvFileAttrib2FfsFileAttrib (
 {\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
@@ -289,9 +291,42 @@ FvFileAttrib2FfsFileAttrib (
   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
@@ -330,7 +365,7 @@ FvLocateFreeSpaceEntry (
   // 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
@@ -400,7 +435,7 @@ FvLocatePadFile (
         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
@@ -477,7 +512,7 @@ FvSearchSuitablePadFile (
       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
@@ -546,14 +581,14 @@ FvSearchSuitableFreeSpace (
     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
@@ -675,7 +710,7 @@ FvcWrite (
   UINTN                               RemainingLength;\r
   UINTN                               WriteLength;\r
   UINT8                               *TmpBuffer;\r
-  \r
+\r
   LOffset = 0;\r
   RemainingLength = CalculateRemainingLength (FvDevice, Offset, &Lba, &LOffset);\r
   if ((UINTN) (*NumBytes) > RemainingLength) {\r
@@ -782,7 +817,7 @@ FvCreateNewFile (
 \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
@@ -956,7 +991,7 @@ FvCreateNewFile (
   FreeSpaceEntry->Length -= (BufferSize - HeaderSize);\r
 \r
   //\r
-  // Caculate File Checksum\r
+  // Calculate File Checksum\r
   //\r
   SetFileChecksum (FileHeader, ActualFileSize);\r
 \r
@@ -1428,8 +1463,8 @@ FvWriteFile (
 \r
     if (FileData[Index1].Type == EFI_FV_FILETYPE_FFS_PAD) {\r
       //\r
-      // According to PI spec, on EFI_FV_FILETYPE_FFS_PAD: \r
-      // "Standard firmware file system services will not return the handle of any pad files, \r
+      // According to PI spec, on EFI_FV_FILETYPE_FFS_PAD:\r
+      // "Standard firmware file system services will not return the handle of any pad files,\r
       // nor will they permit explicit creation of such files."\r
       //\r
       return EFI_INVALID_PARAMETER;\r
@@ -1513,7 +1548,7 @@ FvWriteFile (
 \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