IntelFsp2Pkg: Add search function for Config Editor
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3482 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 <maurice.ma@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com> Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
be282b1493
commit
cac83b6f3b
@@ -583,6 +583,8 @@ class CGenYamlCfg:
|
||||
self._mode = ''
|
||||
self._debug = False
|
||||
self._macro_dict = {}
|
||||
self.bin_offset = []
|
||||
self.binseg_dict = {}
|
||||
self.initialize()
|
||||
|
||||
def initialize(self):
|
||||
@@ -1301,10 +1303,15 @@ option format '%s' !" % option)
|
||||
if 'indx' not in cfgs:
|
||||
return
|
||||
act_cfg = self.get_item_by_index(cfgs['indx'])
|
||||
if force or act_cfg['value'] == '':
|
||||
actual_offset = act_cfg['offset'] - struct_info['offset']
|
||||
set_value = 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 = False
|
||||
if set_value and force or act_cfg['value'] == '':
|
||||
value = get_bits_from_bytes(full_bytes,
|
||||
act_cfg['offset'] -
|
||||
struct_info['offset'],
|
||||
actual_offset,
|
||||
act_cfg['length'])
|
||||
act_val = act_cfg['value']
|
||||
if act_val == '':
|
||||
@@ -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]] = 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]] = -1
|
||||
continue
|
||||
|
||||
return bin_segs
|
||||
|
||||
@@ -1433,8 +1442,17 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
||||
# get cfg bin length
|
||||
cfg_bins = bytearray()
|
||||
bin_segs = self.get_bin_segment(bin_data)
|
||||
Dummy_offset = 0
|
||||
for each in bin_segs:
|
||||
cfg_bins.extend(bin_data[each[1]:each[1] + each[2]])
|
||||
if each[1] != -1:
|
||||
self.bin_offset.append([Dummy_offset, each[1], each[2]])
|
||||
cfg_bins.extend(bin_data[each[1]:each[1] + each[2]])
|
||||
else:
|
||||
string = 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 += each[2]
|
||||
return cfg_bins
|
||||
|
||||
def save_current_to_bin(self):
|
||||
@@ -1447,12 +1465,15 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
||||
cfg_off = 0
|
||||
for each in bin_segs:
|
||||
length = each[2]
|
||||
bin_data[each[1]:each[1] + length] = cfg_bins[cfg_off:
|
||||
cfg_off
|
||||
+ length]
|
||||
cfg_off += length
|
||||
print('Patched the loaded binary successfully !')
|
||||
if each[1] != -1:
|
||||
bin_data[each[1]:each[1] + length] = cfg_bins[cfg_off:
|
||||
cfg_off
|
||||
+ length]
|
||||
cfg_off += length
|
||||
else:
|
||||
cfg_off += length
|
||||
|
||||
print('Patched the loaded binary successfully !')
|
||||
return bin_data
|
||||
|
||||
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)
|
||||
|
||||
def generate_binary(self, bin_file_name, path=''):
|
||||
|
Reference in New Issue
Block a user