From nobody Sun Apr 28 06:48:43 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+77703+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+77703+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1626135174; cv=none; d=zohomail.com; s=zohoarc; b=C1FDsqNl3eqlCK1VrMYl3HpDsTOeILHaruLEYWl1+CJIYsPYwyqg7trc8OjU8OLZt/FaSsi7nq7vckwEgmrypI0eptXDEX+G4tyjobehwyDTLQEpF2Iyj3Xksu+N82Fw5WHUOBAuFK96Jz4aZ/sbrpYgNd5bsIkzsMQXQI44YnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626135174; 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=vg7YzUSsmNCDDY9Ml98ugDh92jD+stWCfdW6dqmfm4k=; b=Ap/4ny6wLW9ywrsXyOiqPmwNblfUU45ugX7FGYr73jgkWWJlZqilv4xVoZNUXvt6mBMaKmHKT6jFBlsS6rA5cinOuh1Hlo26xFbpyEtnTs8EcIAap7T4DkkR3tVNmOG+pDrjkusXNjhWjljbugqR23RhoS+xZFb8AnOkcLDO02w= 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+77703+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 1626135174534987.515980243937; Mon, 12 Jul 2021 17:12:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IxP7YY1788612x0JO0WYR9H0; Mon, 12 Jul 2021 17:12:53 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.2383.1626135141109087447 for ; Mon, 12 Jul 2021 17:12:21 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10043"; a="197346505" X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="197346505" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 17:12:18 -0700 X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="493609842" X-Received: from tunglunl-mobl1.gar.corp.intel.com ([10.215.149.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 17:12:15 -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 v2] IntelFsp2Pkg: Add search function for Config Editor Date: Tue, 13 Jul 2021 08:12:08 +0800 Message-Id: <20210713001208.1332-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: myh0TiRU8SdmkeXWF195uVKGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1626135173; bh=J6Z/MTCQrEUd2Eg5jUXQd543iX7oO+Lgj5lvmIZn9so=; h=Cc:Date:From:Reply-To:Subject:To; b=uRp1X9FZ1UVHu8qSyGdf6P7O2fkAnwKMRnUiquglA+1o+dMlwGbKBwwAtx75/LGpgxj KbGzBnJmUMRN2J5CAOXg0YNCQtr2dsPc/58iv3qHIKTVVOlviugO0PRWCd7oZWV60wMyP TC2hPmw1CtTu9d06vepleVuCYpT8UbQ7RvM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1626135176143100002 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3482 This patch adds a search function in the Config Editor GUI at the top right corner. Once users key in the words to search, it will look for the option containing the string in the same page and display it. It also includes a README for this function. Cc: Maurice Ma Cc: Nate DeSimone Cc: Star Zeng Cc: Chasel Chiu Signed-off-by: Loo Tung Lun Reviewed-by: Chasel Chiu --- IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py | 41 ++++++++++++= +++++++++++++++++++++++++++-- IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py | 44 ++++++++++++= +++++++++++++++++++++----------- IntelFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md | 4 ++++ 3 files changed, 76 insertions(+), 13 deletions(-) diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py b/IntelFsp2Pkg= /Tools/ConfigEditor/ConfigEditor.py index a7f79bbc96..008c7d7a16 100644 --- a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py +++ b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py @@ -811,6 +811,8 @@ class application(tkinter.Frame): self.org_cfg_data_bin =3D None self.in_left =3D state() self.in_right =3D state() + self.search_text =3D '' + self.binseg_dict =3D {} =20 # Check if current directory contains a file with a .yaml extension # if not default self.last_dir to a Platform directory where it is @@ -835,6 +837,23 @@ class application(tkinter.Frame): =20 root.geometry("1200x800") =20 + # Search string + fram =3D tkinter.Frame(root) + # adding label to search box + tkinter.Label(fram, text=3D'Text to find:').pack(side=3Dtkinter.LE= FT) + # adding of single line text box + self.edit =3D tkinter.Entry(fram, width=3D30) + # positioning of text box + self.edit.pack( + side=3Dtkinter.LEFT, fill=3Dtkinter.BOTH, expand=3D1, padx=3D(= 4, 4)) + # setting focus + self.edit.focus_set() + # adding of search button + butt =3D tkinter.Button(fram, text=3D'Search', relief=3Dtkinter.GR= OOVE, + command=3Dself.search_bar) + butt.pack(side=3Dtkinter.RIGHT, padx=3D(4, 4)) + fram.pack(side=3Dtkinter.TOP, anchor=3Dtkinter.SE) + paned =3D ttk.Panedwindow(root, orient=3Dtkinter.HORIZONTAL) paned.pack(fill=3Dtkinter.BOTH, expand=3DTrue, padx=3D(4, 4)) =20 @@ -943,6 +962,12 @@ class application(tkinter.Frame): "Unsupported file '%s' !" % path) return =20 + def search_bar(self): + # get data from text box + self.search_text =3D self.edit.get() + # Clear the page and update it according to search value + self.refresh_config_data_page() + def set_object_name(self, widget, name): self.conf_list[id(widget)] =3D name =20 @@ -976,14 +1001,18 @@ class application(tkinter.Frame): 'units') =20 def update_visibility_for_widget(self, widget, args): - visible =3D True item =3D self.get_config_data_item_from_widget(widget, True) if item is None: return visible elif not item: return visible - + if self.cfg_data_obj.binseg_dict: + str_split =3D item['path'].split('.') + if self.cfg_data_obj.binseg_dict[str_split[-2]] =3D=3D -1: + visible =3D False + widget.grid_remove() + return visible result =3D 1 if item['condition']: result =3D self.evaluate_condition(item) @@ -999,6 +1028,12 @@ class application(tkinter.Frame): widget.grid() widget.configure(state=3D'normal') =20 + if visible and self.search_text !=3D '': + name =3D item['name'] + if name.lower().find(self.search_text.lower()) =3D=3D -1: + visible =3D False + widget.grid_remove() + return visible =20 def update_widgets_visibility_on_page(self): @@ -1134,6 +1169,7 @@ class application(tkinter.Frame): self.fsp_version =3D '2.X' else: self.fsp_version =3D '1.X' + return gen_cfg_data =20 def about(self): @@ -1377,6 +1413,7 @@ class application(tkinter.Frame): return None else: path =3D name + item =3D self.cfg_data_obj.get_item_by_path(path) return item =20 diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py b/IntelFsp2Pkg/T= ools/ConfigEditor/GenYamlCfg.py index 25fd9c547e..611a9a9c72 100644 --- a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py +++ b/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py @@ -583,6 +583,8 @@ class CGenYamlCfg: self._mode =3D '' self._debug =3D False self._macro_dict =3D {} + self.bin_offset =3D [] + self.binseg_dict =3D {} self.initialize() =20 def initialize(self): @@ -1301,10 +1303,15 @@ option format '%s' !" % option) if 'indx' not in cfgs: return act_cfg =3D self.get_item_by_index(cfgs['indx']) - if force or act_cfg['value'] =3D=3D '': + actual_offset =3D act_cfg['offset'] - struct_info['offset'] + set_value =3D True + for each in self.bin_offset: + if actual_offset in range(each[0], (each[0] + each[2]) * 8= ): + if each[1] < 0: + set_value =3D False + if set_value and force or act_cfg['value'] =3D=3D '': value =3D get_bits_from_bytes(full_bytes, - act_cfg['offset'] - - struct_info['offset'], + actual_offset, act_cfg['length']) act_val =3D act_cfg['value'] if act_val =3D=3D '': @@ -1423,9 +1430,11 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) "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: - raise Exception("Could not find '%s' in binary !" - % seg[0]) + bin_segs.append([seg[0], -1, seg[2]]) + self.binseg_dict[seg[0]] =3D -1 + continue =20 return bin_segs =20 @@ -1433,8 +1442,17 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) # get cfg bin length cfg_bins =3D bytearray() bin_segs =3D self.get_bin_segment(bin_data) + Dummy_offset =3D 0 for each in bin_segs: - cfg_bins.extend(bin_data[each[1]:each[1] + each[2]]) + if each[1] !=3D -1: + self.bin_offset.append([Dummy_offset, each[1], each[2]]) + cfg_bins.extend(bin_data[each[1]:each[1] + each[2]]) + else: + string =3D each[0] + ' is not availabe.' + messagebox.showinfo('', string) + self.bin_offset.append([Dummy_offset, each[1], each[2]]) + cfg_bins.extend(bytearray(each[2])) + Dummy_offset +=3D each[2] return cfg_bins =20 def save_current_to_bin(self): @@ -1447,12 +1465,15 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) cfg_off =3D 0 for each in bin_segs: length =3D each[2] - bin_data[each[1]:each[1] + length] =3D cfg_bins[cfg_off: - cfg_off - + length] - cfg_off +=3D length - print('Patched the loaded binary successfully !') + if each[1] !=3D -1: + bin_data[each[1]:each[1] + length] =3D cfg_bins[cfg_off: + cfg_off + + length] + cfg_off +=3D length + else: + cfg_off +=3D length =20 + print('Patched the loaded binary successfully !') return bin_data =20 def load_default_from_bin(self, bin_data): @@ -1469,6 +1490,7 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) if not top: raise Exception("Invalid configuration path '%s' !" % path) + return self.get_field_value(top) =20 def generate_binary(self, bin_file_name, path=3D''): diff --git a/IntelFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md b/Int= elFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md index 08a815133c..da21df2432 100644 --- a/IntelFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md +++ b/IntelFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md @@ -40,6 +40,10 @@ This option generates a new configuration delta file for= the newly changed value ## 8. Save Full Config Data to Delta File This option saves all the changed configuration values into a Delta file. =20 +## 9. Search feature +This feature helps the user to easily find any configuration item they are= looking for in ConfigEditor. +A text search box is available on the Top Right Corner of ConfigEditor. To= use this feature the user should type the name or a key word of the item t= hey want to search in the text box and then click on the "Search" button. T= his will display all the items which contains that particular word searched= by the user. + ## Running Configuration Editor: =20 **python ConfigEditor.py** --=20 2.28.0.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 (#77703): https://edk2.groups.io/g/devel/message/77703 Mute This Topic: https://groups.io/mt/84168193/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-