]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg FwVolDxe: Support FFS_ATTRIB_DATA_ALIGNMENT_2
authorStar Zeng <star.zeng@intel.com>
Mon, 25 Sep 2017 10:08:56 +0000 (18:08 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 26 Sep 2017 10:01:11 +0000 (18:01 +0800)
Follow PI 1.6 spec to support FFS_ATTRIB_DATA_ALIGNMENT_2 for
FFS alignment extended to support maximum 16MB.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolWrite.c

index 0d9021914f3331857fff87ca0a02c5224a282854..987c92c16be3634b68f05351f5c6c1c25460d919 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements functions to read firmware file.\r
 \r
 /** @file\r
   Implements functions to read firmware file.\r
 \r
-  Copyright (c) 2006 - 2016, 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
 \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
 #include "FwVolDriver.h"\r
 \r
 /**\r
-Required Alignment             Alignment Value in FFS         Alignment Value in\r
-(bytes)                        Attributes Field               Firmware Volume Interfaces\r
-1                                    0                                     0\r
-16                                   1                                     4\r
-128                                  2                                     7\r
-512                                  3                                     9\r
-1 KB                                 4                                     10\r
-4 KB                                 5                                     12\r
-32 KB                                6                                     15\r
-64 KB                                7                                     16\r
+Required Alignment   Alignment Value in FFS   FFS_ATTRIB_DATA_ALIGNMENT2   Alignment Value in\r
+(bytes)              Attributes Field         in FFS Attributes Field      Firmware Volume Interfaces\r
+1                               0                          0                            0\r
+16                              1                          0                            4\r
+128                             2                          0                            7\r
+512                             3                          0                            9\r
+1 KB                            4                          0                            10\r
+4 KB                            5                          0                            12\r
+32 KB                           6                          0                            15\r
+64 KB                           7                          0                            16\r
+128 KB                          0                          1                            17\r
+256 KB                          1                          1                            18\r
+512 KB                          2                          1                            19\r
+1 MB                            3                          1                            20\r
+2 MB                            4                          1                            21\r
+4 MB                            5                          1                            22\r
+8 MB                            6                          1                            23\r
+16 MB                           7                          1                            24\r
 **/\r
 UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};\r
 **/\r
 UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};\r
+UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};\r
 \r
 /**\r
   Convert the FFS File Attributes to FV File Attributes.\r
 \r
 /**\r
   Convert the FFS File Attributes to FV File Attributes.\r
@@ -49,7 +58,11 @@ FfsAttributes2FvFileAttributes (
   DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);\r
   ASSERT (DataAlignment < 8);\r
 \r
   DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);\r
   ASSERT (DataAlignment < 8);\r
 \r
-  FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];\r
+  if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {\r
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];\r
+  } else {\r
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];\r
+  }\r
 \r
   if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {\r
     FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;\r
 \r
   if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {\r
     FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;\r
index 99385e0f579b3eebe04df6aa011404c45493fcb5..e95b75326c6edf71379d9e2489876ddb5d7b0d22 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements write firmware file.\r
 \r
 /** @file\r
   Implements write firmware file.\r
 \r
-  Copyright (c) 2006 - 2015, 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
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -202,9 +202,11 @@ FvFileAttrib2FfsFileAttrib (
 {\r
   UINT8 FvFileAlignment;\r
   UINT8 FfsFileAlignment;\r
 {\r
   UINT8 FvFileAlignment;\r
   UINT8 FfsFileAlignment;\r
+  UINT8 FfsFileAlignment2;\r
 \r
   FvFileAlignment   = (UINT8) (FvFileAttrib & EFI_FV_FILE_ATTRIB_ALIGNMENT);\r
   FfsFileAlignment  = 0;\r
 \r
   FvFileAlignment   = (UINT8) (FvFileAttrib & EFI_FV_FILE_ATTRIB_ALIGNMENT);\r
   FfsFileAlignment  = 0;\r
+  FfsFileAlignment2 = 0;\r
 \r
   switch (FvFileAlignment) {\r
   case 0:\r
 \r
   switch (FvFileAlignment) {\r
   case 0:\r
@@ -289,9 +291,42 @@ FvFileAttrib2FfsFileAttrib (
   case 16:\r
     FfsFileAlignment = 7;\r
     break;\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
   }\r
 \r
-  *FfsFileAttrib = (UINT8) (FfsFileAlignment << 3);\r
+  *FfsFileAttrib = (UINT8) ((FfsFileAlignment << 3) | (FfsFileAlignment2 << 1));\r
 \r
   return ;\r
 }\r
 \r
   return ;\r
 }\r