From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E975EAC192E for ; Tue, 18 Jul 2023 14:17:03 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KK1BW+TC+04J0DhsTgNo49Yw+a0N/Bvs+vp1LWstJ/Y=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-IronPort-AV:X-IronPort-AV:X-Received:X-ExtLoop1:X-IronPort-AV:X-IronPort-AV:X-Received:From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1689689822; v=1; b=noqjcel4Bds6WksbSevhDsS4o8K/uzfvRnL79ZSFFGdacqBpPRdyqylRYroIKuQ/xHK+vprX zs6/0DiynadUH9KMw+6ZMC6rmhrLooDd6jyoELhDRNrehfbc88czvmESCveEEgUMAhN5whLbGXF t8WyclYK5AwmnCo/pIGGe7qU= X-Received: by 127.0.0.2 with SMTP id kSYrYY7687511xGq5nIGj3s0; Tue, 18 Jul 2023 07:17:02 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.8826.1689689821653226847 for ; Tue, 18 Jul 2023 07:17:02 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="356161639" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="356161639" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 07:16:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="837295882" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="837295882" X-Received: from tedkuo1-desk1.gar.corp.intel.com ([10.5.215.137]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 07:16:52 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S , Chinni B Duggapu , Ray Han Lim Ng , Susovan Mohapatra Subject: [edk2-devel][PATCH v1] SplitFspBin.py cannot support FSP binary with child FV included Date: Tue, 18 Jul 2023 22:15:50 +0800 Message-Id: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ted.kuo@intel.com X-Gm-Message-State: m3EFykSpf52yWtSbVD07PjHhx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=noqjcel4; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io https://bugzilla.tianocore.org/show_bug.cgi?id=3D4502 Update SplitFspBin.py to support child FV in FSP binary. Without the patch, the tool won't be able to rebase the images in child FV in FSP binary. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Cc: Chinni B Duggapu Cc: Ray Han Lim Ng Cc: Susovan Mohapatra Signed-off-by: Ted Kuo --- IntelFsp2Pkg/Tools/SplitFspBin.py | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFs= pBin.py index 419e5ba985..2e7550dbb2 100644 --- a/IntelFsp2Pkg/Tools/SplitFspBin.py +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py @@ -469,6 +469,7 @@ class FirmwareVolume: else:=0D self.FvExtHdr =3D None=0D self.FfsList =3D []=0D + self.ChildFvList =3D []=0D =0D def ParseFv(self):=0D fvsize =3D len(self.FvData)=0D @@ -483,8 +484,18 @@ class FirmwareVolume: offset =3D fvsize=0D else:=0D ffs =3D FirmwareFile (offset, self.FvData[offset:offset + = int(ffshdr.Size)])=0D - ffs.ParseFfs()=0D - self.FfsList.append(ffs)=0D + csoffset =3D offset + sizeof (EFI_FFS_FILE_HEADER)=0D + cshdr =3D EFI_COMMON_SECTION_HEADER.from_buffer (self.FvDa= ta, csoffset)=0D + # check if there is child fv=0D + if (ffs.FfsHdr.Type =3D=3D EFI_FV_FILETYPE.FIRMWARE_VOLUME= _IMAGE and cshdr.Type =3D=3D EFI_SECTION_TYPE.RAW):=0D + childfvoffset =3D csoffset + sizeof (EFI_COMMON_SECTIO= N_HEADER) + int(cshdr.Size)=0D + childfvhdr =3D EFI_FIRMWARE_VOLUME_HEADER.from_buffer = (self.FvData, childfvoffset)=0D + childfv =3D FirmwareVolume (childfvoffset, self.FvData= [childfvoffset:childfvoffset + int(childfvhdr.FvLength)])=0D + childfv.ParseFv ()=0D + self.ChildFvList.append(childfv)=0D + else:=0D + ffs.ParseFfs()=0D + self.FfsList.append(ffs)=0D offset +=3D int(ffshdr.Size)=0D offset =3D AlignPtr(offset)=0D =0D @@ -789,6 +800,13 @@ def SplitFspBin (fspfile, outdir, nametemplate): hfsp.write(fv.FvData)=0D hfsp.close()=0D =0D +def GetImageFromFv (fd, parentfvoffset, fv, imglist):=0D + for ffs in fv.FfsList:=0D + for sec in ffs.SecList:=0D + if sec.SecHdr.Type in [EFI_SECTION_TYPE.TE, EFI_SECTION_TYPE.P= E32]: # TE or PE32=0D + offset =3D fd.Offset + parentfvoffset + fv.Offset + ffs.Of= fset + sec.Offset + sizeof(sec.SecHdr)=0D + imglist.append ((offset, len(sec.SecData) - sizeof(sec.Sec= Hdr)))=0D +=0D def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile)= :=0D fd =3D FirmwareDevice(0, FspBinary)=0D fd.ParseFd ()=0D @@ -832,11 +850,11 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, O= utputDir, OutputFile): imglist =3D []=0D for fvidx in fsp.FvIdxList:=0D fv =3D fd.FvList[fvidx]=0D - for ffs in fv.FfsList:=0D - for sec in ffs.SecList:=0D - if sec.SecHdr.Type in [EFI_SECTION_TYPE.TE, EFI_SECTIO= N_TYPE.PE32]: # TE or PE32=0D - offset =3D fd.Offset + fv.Offset + ffs.Offset + se= c.Offset + sizeof(sec.SecHdr)=0D - imglist.append ((offset, len(sec.SecData) - sizeof= (sec.SecHdr)))=0D + GetImageFromFv (fd, 0, fv, imglist)=0D + # get image from child fv=0D + for childfv in fv.ChildFvList:=0D + print ("Get image from child fv of fv%d, parent fv offset:= 0x%x" % (fvidx, fv.Offset))=0D + GetImageFromFv (fd, fv.Offset, childfv, imglist)=0D =0D fcount =3D 0=0D pcount =3D 0=0D --=20 2.40.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107019): https://edk2.groups.io/g/devel/message/107019 Mute This Topic: https://groups.io/mt/100216127/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-