From nobody Thu Dec 26 01:26:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1506586904805976.7783995595682; Thu, 28 Sep 2017 01:21:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 41D3021F2AF77; Thu, 28 Sep 2017 01:18:28 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D379521F2AF75 for ; Thu, 28 Sep 2017 01:18:26 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2017 01:21:40 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.121]) by orsmga003.jf.intel.com with ESMTP; 28 Sep 2017 01:21:39 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,449,1500966000"; d="scan'208";a="1019357423" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Thu, 28 Sep 2017 16:21:37 +0800 Message-Id: <1506586897-15388-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: PI 1.6 to support FV extended header contain FV used size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Yunhua Feng 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 Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 19 ++++++++++++++++= +-- BaseTools/Source/C/GenFv/GenFvInternalLib.h | 3 ++- BaseTools/Source/C/Include/Common/PiFirmwareVolume.h | 6 ++++++ BaseTools/Source/Python/GenFds/FdfParser.py | 2 +- BaseTools/Source/Python/GenFds/Fv.py | 20 ++++++++++++++++= +++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source= /C/GenFv/GenFvInternalLib.c index 01c862e..5b219b3 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -42,10 +42,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION 0xEB000000 #define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION 0x14000000 =20 BOOLEAN mArm =3D FALSE; STATIC UINT32 MaxFfsAlignment =3D 0; +BOOLEAN VtfFileFlag =3D FALSE; =20 EFI_GUID mEfiFirmwareVolumeTopFileGuid =3D EFI_FFS_VOLUME_TOP_FILE_= GUID; EFI_GUID mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV]; EFI_GUID mZeroGuid =3D {0x0, 0x0, 0x0, {0x0, 0x= 0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}; EFI_GUID mDefaultCapsuleGuid =3D {0x3B6686BD, 0x0D76, 0x4= 030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 }}; @@ -598,10 +599,11 @@ Returns: { EFI_FFS_FILE_HEADER *PadFile; UINTN PadFileSize; UINT32 NextFfsHeaderSize; UINT32 CurFfsHeaderSize; + EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *FvUsedSize; =20 CurFfsHeaderSize =3D sizeof (EFI_FFS_FILE_HEADER); // // Verify input parameters. // @@ -703,10 +705,25 @@ Returns: =20 if (ExtHeader !=3D NULL) { // // Copy Fv Extension Header and Set Fv Extension header offset // + if (ExtHeader->ExtHeaderSize > sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER)= ) { + FvUsedSize =3D malloc(sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE= _TYPE)); + if (FvUsedSize =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + memcpy(FvUsedSize, ExtHeader + 1, sizeof(EFI_FIRMWARE_VOLUME_EXT_ENT= RY_USED_SIZE_TYPE)); + if (FvUsedSize->Hdr.ExtEntryType =3D=3D EFI_FV_EXT_TYPE_USED_SIZE_TY= PE) { + if (VtfFileFlag) { + FvUsedSize->UsedSize =3D mFvTotalSize; + } else { + FvUsedSize->UsedSize =3D mFvTakenSize; + } + memcpy(ExtHeader + 1, FvUsedSize, sizeof(EFI_FIRMWARE_VOLUME_EXT_E= NTRY_USED_SIZE_TYPE)); + } + } memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, ExtHeader->Ext= HeaderSize); ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = =3D (UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize) - (UINTN) FvIma= ge->FileImage); // // Make next file start at QWord Boundry // @@ -3057,16 +3074,14 @@ Returns: UINTN FfsFileSize; UINTN FvExtendHeaderSize; UINT32 FfsAlignment; UINT32 FfsHeaderSize; EFI_FFS_FILE_HEADER FfsHeader; - BOOLEAN VtfFileFlag; UINTN VtfFileSize; =20 FvExtendHeaderSize =3D 0; VtfFileSize =3D 0; - VtfFileFlag =3D FALSE; fpin =3D NULL; Index =3D 0; =20 // // Compute size for easy access later diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h b/BaseTools/Source= /C/GenFv/GenFvInternalLib.h index f039fa4..9b1abe7 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h @@ -1,10 +1,10 @@ /** @file This file contains describes the public interfaces to the GenFvImage Libra= ry. The basic purpose of the library is to create Firmware Volume images. =20 -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -256,10 +256,11 @@ extern FV_INFO mFvDataInfo; extern CAP_INFO mCapDataInfo; extern EFI_GUID mEfiFirmwareFileSystem2Guid; extern EFI_GUID mEfiFirmwareFileSystem3Guid; extern UINT32 mFvTotalSize; extern UINT32 mFvTakenSize; +extern BOOLEAN VtfFileFlag; =20 extern EFI_PHYSICAL_ADDRESS mFvBaseAddress[]; extern UINT32 mFvBaseAddressNumber; // // Local function prototypes diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h b/BaseToo= ls/Source/C/Include/Common/PiFirmwareVolume.h index b5c2b03..c3089e8 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h @@ -152,6 +152,12 @@ typedef struct { // // UINT8 Data[1]; // } EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE; =20 +#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 diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 499d0a6..b95afc7 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2309,11 +2309,11 @@ class FdfParser: if name not in ("ERASE_POLARITY", "MEMORY_MAPPED", \ "STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WRI= TE_ENABLED_CAP", \ "WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENA= BLED_CAP", \ "READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_= CAP", \ "READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LO= CK_STATUS", \ - "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"): + "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "FvU= sedSizeEnable"): self.__UndoToken() return False =20 if not self.__IsToken( "=3D"): raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 4b03adc..9d4196c 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -49,10 +49,14 @@ class FV (FvClassObject): self.FvAddressFileName =3D None self.CapsuleName =3D None self.FvBaseAddress =3D None self.FvForceRebase =3D None self.FvRegionInFD =3D None + self.ExtEntryType =3D 0x3 + self.ExtEntrySize =3D 8 + self.UsedSize =3D 0 + self.UsedSizeEnable =3D False =20 ## AddToBuffer() # # Generate Fv and add it to the Buffer # @@ -305,10 +309,14 @@ class FV (FvClassObject): self.FvInfFile.writelines("EFI_ERASE_POLARITY =3D " + \ ' %s' %ErasePloarity + \ T_CHAR_LF) if not (self.FvAttributeDict =3D=3D None): for FvAttribute in self.FvAttributeDict.keys() : + if FvAttribute =3D=3D "FvUsedSizeEnable": + if self.FvAttributeDict[FvAttribute].upper() in ('TRUE= ', '1') : + self.UsedSizeEnable =3D True + continue self.FvInfFile.writelines("EFI_" + \ FvAttribute + \ ' =3D ' + \ self.FvAttributeDict[FvAttribute= ] + \ T_CHAR_LF ) @@ -320,16 +328,26 @@ class FV (FvClassObject): =20 # # Generate FV extension header file # if self.FvNameGuid =3D=3D None or self.FvNameGuid =3D=3D '': - if len(self.FvExtEntryType) > 0: + if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable: GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entr= ies declared for %s with no FvNameGuid declaration." % (self.UiFvName)) =20 if self.FvNameGuid <> None and self.FvNameGuid <> '': TotalSize =3D 16 + 4 Buffer =3D '' + if self.UsedSizeEnable: + TotalSize +=3D (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 +=3D pack('HHL', (self.ExtEntrySize), (self.ExtEntr= yType), (self.UsedSize)) + if self.FvNameString =3D=3D 'TRUE': # # Create EXT entry for FV UI name # This GUID is used: A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C # --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel