public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chiu, Chasel" <chasel.chiu@intel.com>
To: "Kuo, Ted" <ted.kuo@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Desimone, Nathaniel L" <nathaniel.l.desimone@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>,
	"S, Ashraf Ali" <ashraf.ali.s@intel.com>,
	"Duggapu, Chinni B" <chinni.b.duggapu@intel.com>,
	"Ng, Ray Han Lim" <ray.han.lim.ng@intel.com>,
	"Mohapatra, Susovan" <susovan.mohapatra@intel.com>
Subject: Re: [edk2-devel][PATCH v1] SplitFspBin.py cannot support FSP binary with child FV included
Date: Wed, 19 Jul 2023 18:14:07 +0000	[thread overview]
Message-ID: <BN9PR11MB5483A5B2AC7FEFD37EEC2B3DE639A@BN9PR11MB5483.namprd11.prod.outlook.com> (raw)
In-Reply-To: <f31ad3dd9d7034f7ce89393a4650030b928b462d.1689676521.git.ted.kuo@intel.com>


Hi Ted,

One question below inline.
Another minor feedback is the commit/patch subject format should be "Package: title"

Thanks,
Chasel


> -----Original Message-----
> From: Kuo, Ted <ted.kuo@intel.com>
> Sent: Tuesday, July 18, 2023 7:16 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; S, Ashraf
> Ali <ashraf.ali.s@intel.com>; Duggapu, Chinni B <chinni.b.duggapu@intel.com>;
> Ng, Ray Han Lim <ray.han.lim.ng@intel.com>; Mohapatra, Susovan
> <susovan.mohapatra@intel.com>
> Subject: [edk2-devel][PATCH v1] SplitFspBin.py cannot support FSP binary with
> child FV included
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=4502
> 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 <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
> Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
> Cc: Ray Han Lim Ng <ray.han.lim.ng@intel.com>
> Cc: Susovan Mohapatra <susovan.mohapatra@intel.com>
> Signed-off-by: Ted Kuo <ted.kuo@intel.com>
> ---
>  IntelFsp2Pkg/Tools/SplitFspBin.py | 32 ++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFspBin.py
> index 419e5ba985..2e7550dbb2 100644
> --- a/IntelFsp2Pkg/Tools/SplitFspBin.py
> +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py
> @@ -469,6 +469,7 @@ class FirmwareVolume:
>          else:             self.FvExtHdr = None         self.FfsList  = []+        self.ChildFvList  =
> []      def ParseFv(self):         fvsize = len(self.FvData)@@ -483,8 +484,18 @@ class
> FirmwareVolume:
>                  offset = fvsize             else:                 ffs = FirmwareFile (offset,
> self.FvData[offset:offset + int(ffshdr.Size)])-                ffs.ParseFfs()-
> self.FfsList.append(ffs)+                csoffset = offset + sizeof
> (EFI_FFS_FILE_HEADER)+                cshdr =
> EFI_COMMON_SECTION_HEADER.from_buffer (self.FvData, csoffset)+                #
> check if there is child fv+                if (ffs.FfsHdr.Type ==
> EFI_FV_FILETYPE.FIRMWARE_VOLUME_IMAGE and cshdr.Type ==
> EFI_SECTION_TYPE.RAW):+                    childfvoffset = csoffset + sizeof


Is child FV always with EFI_SECTION_TYPE.RAW? Or it could be other types like EFI_SECTION_TYPE.FIRMWARE_VOLUME_IMAGE?



> (EFI_COMMON_SECTION_HEADER) + int(cshdr.Size)+                    childfvhdr =
> EFI_FIRMWARE_VOLUME_HEADER.from_buffer (self.FvData, childfvoffset)+
> childfv = FirmwareVolume (childfvoffset, self.FvData[childfvoffset:childfvoffset +
> int(childfvhdr.FvLength)])+                    childfv.ParseFv ()+
> self.ChildFvList.append(childfv)+                else:+                    ffs.ParseFfs()+
> self.FfsList.append(ffs)                 offset += int(ffshdr.Size)                 offset =
> AlignPtr(offset) @@ -789,6 +800,13 @@ def SplitFspBin (fspfile, outdir,
> nametemplate):
>              hfsp.write(fv.FvData)         hfsp.close() +def GetImageFromFv (fd,
> parentfvoffset, fv, imglist):+    for ffs in fv.FfsList:+        for sec in ffs.SecList:+
> if sec.SecHdr.Type in [EFI_SECTION_TYPE.TE, EFI_SECTION_TYPE.PE32]:   # TE or
> PE32+                offset = fd.Offset + parentfvoffset + fv.Offset + ffs.Offset +
> sec.Offset + sizeof(sec.SecHdr)+                imglist.append ((offset, len(sec.SecData)
> - sizeof(sec.SecHdr)))+ def RebaseFspBin (FspBinary, FspComponent, FspBase,
> OutputDir, OutputFile):     fd = FirmwareDevice(0, FspBinary)     fd.ParseFd  ()@@ -
> 832,11 +850,11 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase,
> OutputDir, OutputFile):
>          imglist = []         for fvidx in fsp.FvIdxList:             fv = fd.FvList[fvidx]-            for
> ffs in fv.FfsList:-                for sec in ffs.SecList:-                    if sec.SecHdr.Type in
> [EFI_SECTION_TYPE.TE, EFI_SECTION_TYPE.PE32]:   # TE or PE32-
> offset = fd.Offset + fv.Offset + ffs.Offset + sec.Offset + sizeof(sec.SecHdr)-
> imglist.append ((offset, len(sec.SecData) - sizeof(sec.SecHdr)))+
> GetImageFromFv (fd, 0, fv, imglist)+            # get image from child fv+            for
> childfv in fv.ChildFvList:+                print ("Get image from child fv of fv%d, parent
> fv offset: 0x%x" % (fvidx, fv.Offset))+                GetImageFromFv (fd, fv.Offset,
> childfv, imglist)          fcount  = 0         pcount  = 0--
> 2.40.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107061): https://edk2.groups.io/g/devel/message/107061
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]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-07-19 18:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 14:15 [edk2-devel][PATCH v1] SplitFspBin.py cannot support FSP binary with child FV included Kuo, Ted
2023-07-19 18:14 ` Chiu, Chasel [this message]
2023-07-20 10:21   ` Kuo, Ted

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=BN9PR11MB5483A5B2AC7FEFD37EEC2B3DE639A@BN9PR11MB5483.namprd11.prod.outlook.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