From nobody Sun May 19 13:07:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82062+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82062+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634258341; cv=none; d=zohomail.com; s=zohoarc; b=WyO8hjUkeiIx/0nDwuYnTM827jIXgPV49+a0UycwHyA8aPLTKMlKlk5/n1du+vpYniiCNF0Pil1TLvHOnmcIHI/kJy2KltuL9MxagdlGYjCC80PPJPYfMQQtfZ2EHPA9bcvzg5uoG1jpjxwikmUwo3GgCf0aDnE7+l9vhWtCaz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634258341; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=0h5HLNGJVkChSYc1G139m7knjtmvDsHiBdYHdA6aXWI=; b=PzoFb+mKyZAeUokMVGOQdttHzYFZOrqtj0nSiBp9k9/ohCz7bf/fAtBDYAIMuGy0DFIPZ9xvieqcwiDIendNpsdiUfeHDbnN9jzx4/nvjDT8TGFYP3Qs5vXGZKOS22gXASE+DORzPc4dyKSXNfajuhdQnoiKYH5zBa4i3DYWncU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82062+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634258341137302.9787653243899; Thu, 14 Oct 2021 17:39:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kEDVYY1788612xZ0lfMzmPZx; Thu, 14 Oct 2021 17:39:00 -0700 X-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 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" X-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" X-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: [edk2-devel] [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> 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,tung.lun.loo@intel.com X-Gm-Message-State: vSksopSzFYR2W8hvc2yDAvzJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634258340; bh=UfbQ2OghT6sq8xV8AIwV0sGiGv/goAVqVGqvWf7cZzo=; h=Cc:Date:From:Reply-To:Subject:To; b=W28UJgR3V3bBp2FcSGi1hn7rwbcrnpZugR9xDCT3g5wCL7V4FAbKR79ARP2YLGzmuBu 4pjIJp5sfpTJRP6vRSQD1lH6eMrzE0EUBL5bXDamJqDqejcnox86+glRGSj4dCJekfQl0 LEWRx09etQWvfL9Km9i2sWIOEdO9BbXUdjs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634258342253100002 Content-Type: text/plain; charset="utf-8" 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'] option =3D act_cfg['option'] =20 - cfg_val =3D '' - bin_val =3D '' for i in option.split(','): if act_cfg['value'] in i: - bin_val =3D i + self.data_diff +=3D \ + '\n\nBinary: ' \ + + act_cfg['name'] + ': ' \ + + i + '\n' elif config_val in i: - cfg_val =3D i - if cfg_val !=3D '' and bin_val !=3D '': - self.data_diff +=3D '\n\nBinary: ' \ - + act_cfg['name'] \ - + ': ' + bin_val.replace(' ', '') \ - + '\nConfig file: ' \ - + act_cfg['name'] + ': ' \ - + cfg_val.replace(' ', '') + '\n' + self.data_diff +=3D \ + '\nConfig file: ' \ + + act_cfg['name'] + ': ' + i else: - self.data_diff +=3D '\n\nBinary: ' \ + self.data_diff +=3D '\n\nBinary: ' \ + act_cfg['name'] + ': ' + act_cfg['value'] \ - + '\nConfig file: ' + act_cfg['name'] \ + + '\nConfig file: ' + act_cfg['name'] \ + ': ' + config_val + '\n' =20 def set_field_value(self, top, value_bytes, force=3DFalse): @@ -1477,33 +1473,67 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) def get_bin_segment(self, bin_data): cfg_segs =3D self.get_cfg_segment() bin_segs =3D [] + fsp_instance =3D [] for seg in cfg_segs: key =3D seg[0].encode() + print("key ", key) if key =3D=3D 0: bin_segs.append([seg[0], 0, len(bin_data)]) break pos =3D bin_data.find(key) - if pos >=3D 0: - # ensure no other match for the key - next_pos =3D bin_data.find(key, pos + len(seg[0])) - if next_pos >=3D 0: - if key =3D=3D b'$SKLFSP$' or key =3D=3D b'$BSWFSP$': - string =3D ('Warning: Multiple matches for %s in ' - 'binary!\n\nA workaround applied to such= ' - 'FSP 1.x binary to use second' - ' match instead of first match!' % key) - messagebox.showwarning('Warning!', string) - pos =3D next_pos - else: - print("Warning: Multiple matches for '%s' " - "in binary, the 1st instance will be used !" - % seg[0]) - bin_segs.append([seg[0], pos, seg[2]]) - self.binseg_dict[seg[0]] =3D pos - else: + while pos !=3D -1: + fsp_instance.append(pos) + pos =3D bin_data.find(key, pos + len(seg[0])) + if len(fsp_instance) <=3D 0: bin_segs.append([seg[0], -1, seg[2]]) self.binseg_dict[seg[0]] =3D -1 - continue + + elif len(fsp_instance) =3D=3D 1: + bin_segs.append([seg[0], fsp_instance[0], seg[2]]) + self.binseg_dict[seg[0]] =3D fsp_instance[0] + fsp_instance.clear() + + else: + + fsp_instance_root =3D tkinter.Tk() + + canvas1 =3D tkinter.Canvas(fsp_instance_root, + width=3D400, height=3D400) + canvas1.pack() + + entry1 =3D tkinter.Entry(fsp_instance_root) + canvas1.create_window(200, 220, window=3Dentry1) + + text =3D "Multiple instances available for " +\ + seg[0] + "\n\nThe available instances are\n" + for edx, ins in enumerate(fsp_instance): + text +=3D "\nInstance" + str(edx + 1) + ' :offset ' +\ + str(hex(ins)) + text +=3D "\n\nPlease enter the instance number between 1 = and "\ + + str(len(fsp_instance)) + label1 =3D tkinter.Label( + fsp_instance_root, + text=3Dtext, wraplength=3D380, justify=3D'left') + canvas1.create_window(200, 90, window=3Dlabel1) + + def getfspinstance(): + x1 =3D entry1.get() + fsp_instance_option =3D int(x1) + if fsp_instance_option <=3D len(fsp_instance): + bin_segs.append([seg[0], + fsp_instance[fsp_instance_option -= 1], + seg[2]]) + self.binseg_dict[seg[0]] =3D fsp_instance[ + fsp_instance_option - 1] + fsp_instance_root.destroy() + + button2 =3D tkinter.Button(fsp_instance_root, + text=3D'Enter the instance', + command=3Dlambda: getfspinstance(= )) + canvas1.create_window(200, 250, window=3Dbutton2) + fsp_instance_root.wait_window(fsp_instance_root) + + fsp_instance.clear() =20 return bin_segs =20 --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82062): https://edk2.groups.io/g/devel/message/82062 Mute This Topic: https://groups.io/mt/86328919/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-