From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.3265.1634258339709023916 for ; Thu, 14 Oct 2021 17:39:00 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: tung.lun.loo@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="226593775" X-IronPort-AV: E=Sophos;i="5.85,374,1624345200"; d="scan'208";a="226593775" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2021 17:38:59 -0700 X-IronPort-AV: E=Sophos;i="5.85,374,1624345200"; d="scan'208";a="717908168" Received: from tunglunl-mobl5.gar.corp.intel.com ([10.213.46.65]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2021 17:38:56 -0700 From: "Tung Lun" To: devel@edk2.groups.io Cc: Loo Tung Lun , Maurice Ma , Nate DeSimone , Star Zeng , Chasel Chiu Subject: [PATCH] IntelFsp2Pkg: Add support for config editor to handle multiple UPD Date: Fri, 15 Oct 2021 08:38:44 +0800 Message-Id: <20211015003844.1285-1-tung.lun.loo@intel.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3692 In several use cases in bootloader, there are multiple instances of UPD with same signature header. As such, using previous version of config editor to edit those will result in only overriding the first found instance. This patch provides the flexibility to modify the instance specified. Cc: Maurice Ma Cc: Nate DeSimone Cc: Star Zeng Cc: Chasel Chiu Signed-off-by: Loo Tung Lun --- IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py | 94 +++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py b/IntelFsp2Pkg/T= ools/ConfigEditor/GenYamlCfg.py index b593885807..91c4180085 100644 --- a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py +++ b/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py @@ -1351,24 +1351,20 @@ option format '%s' !" % option) act_cfg['value']=0D option =3D act_cfg['option']=0D =0D - cfg_val =3D ''=0D - bin_val =3D ''=0D for i in option.split(','):=0D if act_cfg['value'] in i:=0D - bin_val =3D i=0D + self.data_diff +=3D \=0D + '\n\nBinary: ' \=0D + + act_cfg['name'] + ': ' \=0D + + i + '\n'=0D elif config_val in i:=0D - cfg_val =3D i=0D - if cfg_val !=3D '' and bin_val !=3D '':=0D - self.data_diff +=3D '\n\nBinary: ' \=0D - + act_cfg['name'] \=0D - + ': ' + bin_val.replace(' ', '') \=0D - + '\nConfig file: ' \=0D - + act_cfg['name'] + ': ' \=0D - + cfg_val.replace(' ', '') + '\n'=0D + self.data_diff +=3D \=0D + '\nConfig file: ' \=0D + + act_cfg['name'] + ': ' + i=0D else:=0D - self.data_diff +=3D '\n\nBinary: ' \=0D + self.data_diff +=3D '\n\nBinary: ' \=0D + act_cfg['name'] + ': ' + act_cfg['value'] \= =0D - + '\nConfig file: ' + act_cfg['name'] \=0D + + '\nConfig file: ' + act_cfg['name'] \=0D + ': ' + config_val + '\n'=0D =0D def set_field_value(self, top, value_bytes, force=3DFalse):=0D @@ -1477,33 +1473,67 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) def get_bin_segment(self, bin_data):=0D cfg_segs =3D self.get_cfg_segment()=0D bin_segs =3D []=0D + fsp_instance =3D []=0D for seg in cfg_segs:=0D key =3D seg[0].encode()=0D + print("key ", key)=0D if key =3D=3D 0:=0D bin_segs.append([seg[0], 0, len(bin_data)])=0D break=0D pos =3D bin_data.find(key)=0D - if pos >=3D 0:=0D - # ensure no other match for the key=0D - next_pos =3D bin_data.find(key, pos + len(seg[0]))=0D - if next_pos >=3D 0:=0D - if key =3D=3D b'$SKLFSP$' or key =3D=3D b'$BSWFSP$':=0D - string =3D ('Warning: Multiple matches for %s in '= =0D - 'binary!\n\nA workaround applied to such= '=0D - 'FSP 1.x binary to use second'=0D - ' match instead of first match!' % key)= =0D - messagebox.showwarning('Warning!', string)=0D - pos =3D next_pos=0D - else:=0D - print("Warning: Multiple matches for '%s' "=0D - "in binary, the 1st instance will be used !"= =0D - % seg[0])=0D - bin_segs.append([seg[0], pos, seg[2]])=0D - self.binseg_dict[seg[0]] =3D pos=0D - else:=0D + while pos !=3D -1:=0D + fsp_instance.append(pos)=0D + pos =3D bin_data.find(key, pos + len(seg[0]))=0D + if len(fsp_instance) <=3D 0:=0D bin_segs.append([seg[0], -1, seg[2]])=0D self.binseg_dict[seg[0]] =3D -1=0D - continue=0D +=0D + elif len(fsp_instance) =3D=3D 1:=0D + bin_segs.append([seg[0], fsp_instance[0], seg[2]])=0D + self.binseg_dict[seg[0]] =3D fsp_instance[0]=0D + fsp_instance.clear()=0D +=0D + else:=0D +=0D + fsp_instance_root =3D tkinter.Tk()=0D +=0D + canvas1 =3D tkinter.Canvas(fsp_instance_root,=0D + width=3D400, height=3D400)=0D + canvas1.pack()=0D +=0D + entry1 =3D tkinter.Entry(fsp_instance_root)=0D + canvas1.create_window(200, 220, window=3Dentry1)=0D +=0D + text =3D "Multiple instances available for " +\=0D + seg[0] + "\n\nThe available instances are\n"=0D + for edx, ins in enumerate(fsp_instance):=0D + text +=3D "\nInstance" + str(edx + 1) + ' :offset ' += \=0D + str(hex(ins))=0D + text +=3D "\n\nPlease enter the instance number between 1 = and "\=0D + + str(len(fsp_instance))=0D + label1 =3D tkinter.Label(=0D + fsp_instance_root,=0D + text=3Dtext, wraplength=3D380, justify=3D'left')=0D + canvas1.create_window(200, 90, window=3Dlabel1)=0D +=0D + def getfspinstance():=0D + x1 =3D entry1.get()=0D + fsp_instance_option =3D int(x1)=0D + if fsp_instance_option <=3D len(fsp_instance):=0D + bin_segs.append([seg[0],=0D + fsp_instance[fsp_instance_option -= 1],=0D + seg[2]])=0D + self.binseg_dict[seg[0]] =3D fsp_instance[=0D + fsp_instance_option - 1]=0D + fsp_instance_root.destroy()=0D +=0D + button2 =3D tkinter.Button(fsp_instance_root,=0D + text=3D'Enter the instance',=0D + command=3Dlambda: getfspinstance(= ))=0D + canvas1.create_window(200, 250, window=3Dbutton2)=0D + fsp_instance_root.wait_window(fsp_instance_root)=0D +=0D + fsp_instance.clear()=0D =0D return bin_segs=0D =0D --=20 2.26.2.windows.1