mirror of https://github.com/acidanthera/audk.git
BaseTools: PI 1.6 to support FV extended header contain FV used size
Per PI 1.6 we added an FV Extended Header entry that would contain the size of the FV that was in use. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
c46bced224
commit
9425b34925
|
@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
BOOLEAN mArm = FALSE;
|
||||
STATIC UINT32 MaxFfsAlignment = 0;
|
||||
BOOLEAN VtfFileFlag = FALSE;
|
||||
|
||||
EFI_GUID mEfiFirmwareVolumeTopFileGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;
|
||||
EFI_GUID mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV];
|
||||
|
@ -600,7 +601,9 @@ Returns:
|
|||
UINTN PadFileSize;
|
||||
UINT32 NextFfsHeaderSize;
|
||||
UINT32 CurFfsHeaderSize;
|
||||
UINT32 Index;
|
||||
|
||||
Index = 0;
|
||||
CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
|
||||
//
|
||||
// Verify input parameters.
|
||||
|
@ -705,6 +708,19 @@ Returns:
|
|||
//
|
||||
// Copy Fv Extension Header and Set Fv Extension header offset
|
||||
//
|
||||
if (ExtHeader->ExtHeaderSize > sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER)) {
|
||||
for (Index = sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER); Index < ExtHeader->ExtHeaderSize;) {
|
||||
if (((EFI_FIRMWARE_VOLUME_EXT_ENTRY *)((UINT8 *)ExtHeader + Index))-> ExtEntryType == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {
|
||||
if (VtfFileFlag) {
|
||||
((EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *)((UINT8 *)ExtHeader + Index))->UsedSize = mFvTotalSize;
|
||||
} else {
|
||||
((EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *)((UINT8 *)ExtHeader + Index))->UsedSize = mFvTakenSize;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Index += ((EFI_FIRMWARE_VOLUME_EXT_ENTRY *)((UINT8 *)ExtHeader + Index))-> ExtEntrySize;
|
||||
}
|
||||
}
|
||||
memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, ExtHeader->ExtHeaderSize);
|
||||
((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = (UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize) - (UINTN) FvImage->FileImage);
|
||||
//
|
||||
|
@ -3059,12 +3075,10 @@ Returns:
|
|||
UINT32 FfsAlignment;
|
||||
UINT32 FfsHeaderSize;
|
||||
EFI_FFS_FILE_HEADER FfsHeader;
|
||||
BOOLEAN VtfFileFlag;
|
||||
UINTN VtfFileSize;
|
||||
|
||||
FvExtendHeaderSize = 0;
|
||||
VtfFileSize = 0;
|
||||
VtfFileFlag = FALSE;
|
||||
fpin = NULL;
|
||||
Index = 0;
|
||||
|
||||
|
|
|
@ -154,4 +154,10 @@ typedef struct {
|
|||
//
|
||||
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
|
||||
|
||||
#define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
|
||||
typedef struct {
|
||||
EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
|
||||
UINT32 UsedSize;
|
||||
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2311,7 +2311,7 @@ class FdfParser:
|
|||
"WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENABLED_CAP", \
|
||||
"READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_CAP", \
|
||||
"READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LOCK_STATUS", \
|
||||
"WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"):
|
||||
"WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "FvUsedSizeEnable"):
|
||||
self.__UndoToken()
|
||||
return False
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ class FV (FvClassObject):
|
|||
self.FvBaseAddress = None
|
||||
self.FvForceRebase = None
|
||||
self.FvRegionInFD = None
|
||||
self.UsedSizeEnable = False
|
||||
|
||||
## AddToBuffer()
|
||||
#
|
||||
|
@ -307,6 +308,10 @@ class FV (FvClassObject):
|
|||
T_CHAR_LF)
|
||||
if not (self.FvAttributeDict == None):
|
||||
for FvAttribute in self.FvAttributeDict.keys() :
|
||||
if FvAttribute == "FvUsedSizeEnable":
|
||||
if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :
|
||||
self.UsedSizeEnable = True
|
||||
continue
|
||||
self.FvInfFile.writelines("EFI_" + \
|
||||
FvAttribute + \
|
||||
' = ' + \
|
||||
|
@ -322,12 +327,22 @@ class FV (FvClassObject):
|
|||
# Generate FV extension header file
|
||||
#
|
||||
if self.FvNameGuid == None or self.FvNameGuid == '':
|
||||
if len(self.FvExtEntryType) > 0:
|
||||
if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable:
|
||||
GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))
|
||||
|
||||
if self.FvNameGuid <> None and self.FvNameGuid <> '':
|
||||
TotalSize = 16 + 4
|
||||
Buffer = ''
|
||||
if self.UsedSizeEnable:
|
||||
TotalSize += (4 + 4)
|
||||
## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
|
||||
#typedef struct
|
||||
# {
|
||||
# EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
|
||||
# UINT32 UsedSize;
|
||||
# } EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;
|
||||
Buffer += pack('HHL', 8, 3, 0)
|
||||
|
||||
if self.FvNameString == 'TRUE':
|
||||
#
|
||||
# Create EXT entry for FV UI name
|
||||
|
|
Loading…
Reference in New Issue