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 CDDB6AC0DF4 for ; Thu, 20 Jul 2023 10:20:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WPkZ9JFkD+hgZZaerRtt5qKzBuAZRYkmAx1Ha9g55+w=; 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=1689848409; v=1; b=at3vqRTa/wYtC9lPPVu2DxkcV44lCLHwxapKf4Be+xpep/t7cab3w9qpMOyxytOdahgg1qr+ yEYp+uoYhVNczipdzBja24PmzCvgt9OJjM1cqvnu00Z+1wux7pFqo6/AhW6fq/3bWiph5aHDAx+ BufyLuJVXJttx5zGGwhs0nks= X-Received: by 127.0.0.2 with SMTP id deKDYY7687511x9XQ9FEmS1P; Thu, 20 Jul 2023 03:20:09 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.9706.1689848408344872767 for ; Thu, 20 Jul 2023 03:20:08 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="365578822" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="365578822" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 03:20:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="970995651" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="970995651" X-Received: from tedkuo1-desk1.gar.corp.intel.com ([10.5.215.137]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 03:20:05 -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 v2] IntelFsp2Pkg: Support child FV in SplitFspBin.py Date: Thu, 20 Jul 2023 18:19:58 +0800 Message-Id: <72954adb273dbf636be248eaee8a35477eae3c50.1689848378.git.ted.kuo@intel.com> 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: CP3hMKZDDPuUkvOu81gejrlwx7686176AA= 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=at3vqRTa; 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 | 44 ++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFs= pBin.py index 419e5ba985..558eaf401a 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,30 @@ 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 + # check if there is child fv=0D + childfvfound =3D 0=0D + if (ffs.FfsHdr.Type =3D=3D EFI_FV_FILETYPE.FIRMWARE_VOLUME= _IMAGE):=0D + csoffset =3D offset + sizeof (EFI_FFS_FILE_HEADER)=0D + csoffset =3D AlignPtr(csoffset, 4)=0D + # find fv section=0D + while csoffset < (offset + int(ffs.FfsHdr.Size)):=0D + cshdr =3D EFI_COMMON_SECTION_HEADER.from_buffer (s= elf.FvData, csoffset)=0D + if (cshdr.Type =3D=3D EFI_SECTION_TYPE.FIRMWARE_VO= LUME_IMAGE):=0D + childfvfound =3D 1=0D + break=0D + else:=0D + # check next section=0D + csoffset +=3D int(cshdr.Size)=0D + csoffset =3D AlignPtr(csoffset, 4)=0D + if (childfvfound):=0D + childfvoffset =3D csoffset + sizeof (EFI_COMMON_SECTIO= N_HEADER)=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 +812,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 +862,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 (#107093): https://edk2.groups.io/g/devel/message/107093 Mute This Topic: https://groups.io/mt/100252890/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-