public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Star Zeng <star.zeng@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH 2/2] MdeModulePkg Core: Support FFS_ATTRIB_DATA_ALIGNMENT_2
Date: Fri, 22 Sep 2017 18:22:02 +0800	[thread overview]
Message-ID: <1506075722-54216-3-git-send-email-star.zeng@intel.com> (raw)
In-Reply-To: <1506075722-54216-1-git-send-email-star.zeng@intel.com>

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>
---
 MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 37 ++++++++++++++++++++++-----------
 MdeModulePkg/Core/Pei/FwVol/FwVol.c     | 35 +++++++++++++++++++++----------
 2 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
index 00e0d7d289ec..c59c384f5c75 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
@@ -1,7 +1,7 @@
 /** @file
   Implements functions to read firmware file
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -16,18 +16,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "FwVolDriver.h"
 
 /**
-Required Alignment             Alignment Value in FFS         Alignment Value in
-(bytes)                        Attributes Field               Firmware Volume Interfaces
-1                                    0                                     0
-16                                   1                                     4
-128                                  2                                     7
-512                                  3                                     9
-1 KB                                 4                                     10
-4 KB                                 5                                     12
-32 KB                                6                                     15
-64 KB                                7                                     16
+Required Alignment   Alignment Value in FFS   FFS_ATTRIB_DATA_ALIGNMENT2   Alignment Value in
+(bytes)              Attributes Field         in FFS Attributes Field      Firmware Volume Interfaces
+1                               0                          0                            0
+16                              1                          0                            4
+128                             2                          0                            7
+512                             3                          0                            9
+1 KB                            4                          0                            10
+4 KB                            5                          0                            12
+32 KB                           6                          0                            15
+64 KB                           7                          0                            16
+128 KB                          0                          1                            17
+256 KB                          1                          1                            18
+512 KB                          2                          1                            19
+1 MB                            3                          1                            20
+2 MB                            4                          1                            21
+4 MB                            5                          1                            22
+8 MB                            6                          1                            23
+16 MB                           7                          1                            24
 **/
 UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
+UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};
 
 /**
   Convert the FFS File Attributes to FV File Attributes
@@ -48,7 +57,11 @@ FfsAttributes2FvFileAttributes (
   DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
   ASSERT (DataAlignment < 8);
 
-  FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];
+  if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];
+  } else {
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];
+  }
 
   if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {
     FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index 0bbb86d95819..c90a70b5f799 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -75,18 +75,27 @@ EFI_PEI_PPI_DESCRIPTOR  mPeiFfs3FvPpiList = {
 };
 
 /**
-Required Alignment             Alignment Value in FFS         Alignment Value in
-(bytes)                        Attributes Field               Firmware Volume Interfaces
-1                                    0                                     0
-16                                   1                                     4
-128                                  2                                     7
-512                                  3                                     9
-1 KB                                 4                                     10
-4 KB                                 5                                     12
-32 KB                                6                                     15
-64 KB                                7                                     16
+Required Alignment   Alignment Value in FFS   FFS_ATTRIB_DATA_ALIGNMENT2   Alignment Value in
+(bytes)              Attributes Field         in FFS Attributes Field      Firmware Volume Interfaces
+1                               0                          0                            0
+16                              1                          0                            4
+128                             2                          0                            7
+512                             3                          0                            9
+1 KB                            4                          0                            10
+4 KB                            5                          0                            12
+32 KB                           6                          0                            15
+64 KB                           7                          0                            16
+128 KB                          0                          1                            17
+256 KB                          1                          1                            18
+512 KB                          2                          1                            19
+1 MB                            3                          1                            20
+2 MB                            4                          1                            21
+4 MB                            5                          1                            22
+8 MB                            6                          1                            23
+16 MB                           7                          1                            24
 **/
 UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
+UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};
 
 /**
   Convert the FFS File Attributes to FV File Attributes
@@ -107,7 +116,11 @@ FfsAttributes2FvFileAttributes (
   DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
   ASSERT (DataAlignment < 8);
 
-  FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];
+  if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];
+  } else {
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];
+  }
 
   if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {
     FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;
-- 
2.7.0.windows.1



  parent reply	other threads:[~2017-09-22 10:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 10:22 [PATCH 0/2] Follow PI 1.6 to support FFS_ATTRIB_DATA_ALIGNMENT_2 Star Zeng
2017-09-22 10:22 ` [PATCH 1/2] MdePkg PiFirmwareFile.h: Add FFS_ATTRIB_DATA_ALIGNMENT_2 definition Star Zeng
2017-09-22 10:22 ` Star Zeng [this message]
2017-09-25 11:08 ` [PATCH 0/2] Follow PI 1.6 to support FFS_ATTRIB_DATA_ALIGNMENT_2 Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506075722-54216-3-git-send-email-star.zeng@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox