Changeset 105670 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFsp2Pkg/Tools/ConfigEditor
- Timestamp:
- Aug 14, 2024 1:16:30 PM (6 months ago)
- svn:sync-xref-src-repo-rev:
- 164367
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-159268 /vendor/edk2/current 103735-103757,103769-103776,129194-164365
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
r99404 r105670 1016 1016 return 1017 1017 1018 # VFR Format Page modification 1019 def page_construct(self): 1020 self.left.bind("<<TreeviewSelect>>", self.on_config_page_select_change) 1021 1018 1022 def search_bar(self): 1019 1023 # get data from text box … … 1166 1170 # Put CFG items into related page list 1167 1171 self.page_list[page_id] = self.cfg_data_obj.get_cfg_list(page_id) 1168 self.page_list[page_id].sort(key=lambda x: x['order']) 1172 if self.mode == 'fsp': 1173 self.page_list[page_id].sort(key=lambda x: x['order']) 1169 1174 page_name = self.cfg_data_obj.get_page_title(page_id) 1170 1175 child = self.left.insert( … … 1200 1205 disp_list.append(item) 1201 1206 row = 0 1202 disp_list.sort(key=lambda x: x['order']) 1203 for item in disp_list: 1204 self.add_config_item(item, row) 1205 row += 2 1206 if self.invalid_values: 1207 string = 'The following contails invalid options/values \n\n' 1208 for i in self.invalid_values: 1209 string += i + ": " + str(self.invalid_values[i]) + "\n" 1210 reply = messagebox.showwarning('Warning!', string) 1211 if reply == 'ok': 1212 self.invalid_values.clear() 1207 if self.mode == 'fsp': 1208 disp_list.sort(key=lambda x: x['order']) 1209 for item in disp_list: 1210 self.add_config_item(item, row) 1211 row += 2 1212 if self.invalid_values: 1213 string = 'The following contails invalid options/values \n\n' 1214 for i in self.invalid_values: 1215 string += i + ": " + str(self.invalid_values[i]) + "\n" 1216 reply = messagebox.showwarning('Warning!', string) 1217 if reply == 'ok': 1218 self.invalid_values.clear() 1219 elif self.mode == 'vfr': 1220 for item in disp_list: 1221 self.add_vfr_config_item(item, row) 1222 row += 2 1213 1223 1214 1224 fsp_version = '' … … 1220 1230 gen_cfg_data.__dict__ = marshal.load(pkl_file) 1221 1231 gen_cfg_data.prepare_marshal(False) 1222 elif file_name.endswith('.yaml') :1232 elif file_name.endswith('.yaml') or file_name.endswith('.yml'): 1223 1233 if gen_cfg_data.load_yaml(file_name) != 0: 1224 1234 raise Exception(gen_cfg_data.get_last_error()) 1225 1235 else: 1226 1236 raise Exception('Unsupported file "%s" !' % file_name) 1237 1238 self.mode = gen_cfg_data.yaml_type 1227 1239 # checking fsp version 1228 if gen_cfg_data.detect_fsp(): 1229 self.fsp_version = '2.X' 1230 else: 1231 self.fsp_version = '1.X' 1240 if gen_cfg_data.yaml_type == 'fsp': 1241 if gen_cfg_data.detect_fsp(): 1242 self.fsp_version = '2.X' 1243 else: 1244 self.fsp_version = '1.X' 1232 1245 1233 1246 return gen_cfg_data … … 1253 1266 question = 'All configuration will be reloaded from BIN file, \ 1254 1267 continue ?' 1255 elif ftype == 'yaml' :1268 elif ftype == 'yaml' or ftype == 'yml': 1256 1269 question = '' 1257 1270 elif ftype == 'bsf': … … 1264 1277 return None 1265 1278 1266 if ftype == 'yaml' :1267 if self.mode == ' FSP':1279 if ftype == 'yaml' or ftype == 'yml': 1280 if self.mode == 'fsp': 1268 1281 file_type = 'YAML' 1269 1282 file_ext = 'yaml' 1270 1283 else: 1271 1284 file_type = 'YAML or PKL' 1272 file_ext = 'pkl *.yaml '1285 file_ext = 'pkl *.yaml *.yml' 1273 1286 else: 1274 1287 file_type = ftype.upper() … … 1365 1378 1366 1379 self.cfg_data_obj = self.load_config_data(path) 1367 1368 self.update_last_dir(path)1369 self.org_cfg_data_bin = self.cfg_data_obj.generate_binary_array()1370 1380 self.build_config_page_tree(self.cfg_data_obj.get_cfg_page()['root'], 1371 1381 '') 1372 1382 1373 msg_string = 'Click YES if it is FULL FSP '\ 1374 + self.fsp_version + ' Binary' 1375 reply = messagebox.askquestion('Form', msg_string) 1376 if reply == 'yes': 1377 self.load_from_bin() 1378 1379 for menu in self.menu_string: 1380 self.file_menu.entryconfig(menu, state="normal") 1383 self.update_last_dir(path) 1384 if self.cfg_data_obj.yaml_type == 'fsp': 1385 self.org_cfg_data_bin = self.cfg_data_obj.generate_binary_array() 1386 1387 1388 msg_string = 'Click YES if it is FULL FSP '\ 1389 + self.fsp_version + ' Binary' 1390 reply = messagebox.askquestion('Form', msg_string) 1391 if reply == 'yes': 1392 self.load_from_bin() 1393 1394 for menu in self.menu_string: 1395 self.file_menu.entryconfig(menu, state="normal") 1381 1396 1382 1397 return 0 … … 1406 1421 1407 1422 self.update_config_data_on_page() 1408 new_data = self.cfg_data_obj.generate_binary_array() 1409 self.cfg_data_obj.generate_delta_file_from_bin(path, 1423 if self.mode == "fsp": 1424 new_data = self.cfg_data_obj.generate_binary_array() 1425 self.cfg_data_obj.generate_delta_file_from_bin(path, 1410 1426 self.org_cfg_data_bin, 1411 1427 new_data, full) … … 1527 1543 self.set_config_item_value(item, new_value) 1528 1544 1545 #YAML VFR Part Start 1546 def update_vfr_config_data_from_widget(self, widget, args): 1547 1548 item = self.get_config_data_item_from_widget(widget) 1549 1550 #YAML VFR Part End 1551 1529 1552 def evaluate_condition(self, item): 1530 1553 try: … … 1535 1558 result = 1 1536 1559 return result 1560 1561 #YAML VFR Part Start 1562 def add_vfr_config_item(self, item, row): 1563 parent = self.right_grid 1564 widget = None 1565 if item['type'] == 'string': 1566 value = '' 1567 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1568 txt_val = tkinter.StringVar() 1569 widget = tkinter.Entry(parent, textvariable=txt_val) 1570 txt_val.set(value) 1571 1572 elif item['type'] == 'text': 1573 value = '' 1574 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1575 txt_val = tkinter.StringVar() 1576 widget = tkinter.Entry(parent, textvariable=txt_val) 1577 txt_val.set(value) 1578 elif item['type'] == 'label': 1579 value = '' 1580 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1581 txt_val = tkinter.StringVar() 1582 widget = tkinter.Entry(parent, textvariable=txt_val) 1583 txt_val.set(value) 1584 1585 elif item['type'] == 'checkbox': 1586 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1587 widget = tkinter.Checkbutton(parent, text= item['prompt'].split("#")[0], variable= 1) 1588 1589 elif item['type'] == 'subtitle': 1590 value = '' 1591 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1592 txt_val = tkinter.StringVar() 1593 widget = tkinter.Entry(parent, textvariable=txt_val) 1594 txt_val.set(value) 1595 1596 elif item['type'] == 'oneof': 1597 OPTIONS = [] 1598 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1599 for key in item: 1600 if key.startswith("option"): 1601 if type(item[key]) == type([]): 1602 for option_data in item[key]: 1603 OPTIONS.append(option_data['text']) 1604 else: 1605 OPTIONS.append(item[key]["text"]) 1606 txt_val = tkinter.StringVar() 1607 txt_val.set(OPTIONS[0]) # set default value 1608 widget = tkinter.OptionMenu(parent, txt_val, *OPTIONS) 1609 txt_val.set(OPTIONS[0]) 1610 1611 elif item['type'] == 'numeric': 1612 value = 0 1613 for key in item.keys(): 1614 if key == "value": 1615 value = item['value'] 1616 elif key == 'default': 1617 for dict_key in item['default']: 1618 if dict_key == "value": 1619 value = item['default']['value'] 1620 else: 1621 continue 1622 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1623 txt_val = tkinter.StringVar() 1624 widget = tkinter.Entry(parent, textvariable=txt_val) 1625 txt_val.set(value) 1626 1627 elif item['type'] == 'orderedlist': 1628 OPTIONS = [] 1629 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1630 for key in item: 1631 if key.startswith("option"): 1632 if type(item[key]) == type([]): 1633 for option_data in item[key]: 1634 OPTIONS.append(option_data['text']) 1635 else: 1636 OPTIONS.append(item[key]["text"]) 1637 txt_val = tkinter.StringVar() 1638 txt_val.set(OPTIONS[0]) # default value 1639 widget = tkinter.OptionMenu(parent, txt_val, *OPTIONS) 1640 txt_val.set(OPTIONS[0]) 1641 1642 elif item['type'] == 'date': 1643 value = '' 1644 for key in item.keys(): 1645 if key == "value": 1646 value = item['value'] 1647 elif key == 'default': 1648 for dict_key in item['default']: 1649 if dict_key == "value": 1650 value = item['default']['value'] 1651 else: 1652 continue 1653 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1654 txt_val = tkinter.StringVar() 1655 widget = tkinter.Entry(parent, textvariable=txt_val) 1656 txt_val.set(value) 1657 elif item['type'] == 'time': 1658 value = '' 1659 for key in item.keys(): 1660 if key == "value": 1661 value = item['value'] 1662 elif key == 'default': 1663 for dict_key in item['default']: 1664 if dict_key == "value": 1665 value = item['default']['value'] 1666 else: 1667 continue 1668 name = tkinter.Label(parent, text=item['prompt'].split("#")[0], anchor="w") 1669 txt_val = tkinter.StringVar() 1670 widget = tkinter.Entry(parent, textvariable=txt_val) 1671 txt_val.set(value) 1672 1673 1674 if widget: 1675 if item['type'] == 'string' or item['type'] == 'text' or item['type'] == 'numeric' or item['type'] == "oneof"\ 1676 or item['type'] == 'date' or item['type'] == 'time' or item['type'] == 'orderedlist' or item['type'] == 'label':# or item['type'] == 'goto'or item['type'] == 'checkbox': 1677 1678 if 'help' in item.keys(): 1679 create_tool_tip(widget, item['help'].split("#")[0]) 1680 1681 name.grid(row=row, column=0, padx=5, pady=5, sticky="nsew") 1682 widget.grid(row=row + 1, rowspan=1, column=0, 1683 padx=5, pady=5, sticky="nsew") 1684 1685 #YAML VFR Part End 1537 1686 1538 1687 def add_config_item(self, item, row): … … 1612 1761 1613 1762 def update_config_data_on_page(self): 1614 self.walk_widgets_in_layout(self.right_grid, 1763 1764 if self.mode == "fsp": 1765 self.walk_widgets_in_layout(self.right_grid, 1615 1766 self.update_config_data_from_widget) 1616 1767 elif self.mode == "vfr": 1768 self.walk_widgets_in_layout(self.right_grid, 1769 self.update_vfr_config_data_from_widget) 1770 else: 1771 print("WARNING: Invalid config file!!") 1617 1772 1618 1773 if __name__ == '__main__': -
trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py
r99404 r105670 227 227 CONFIGS = 'configs' 228 228 VARIABLE = 'variable' 229 FORMSET = 'formset' 229 230 230 231 def __init__(self): … … 236 237 self.def_dict = {} 237 238 self.yaml_path = '' 239 self.yaml_type = 'fsp' 238 240 self.lines = [] 239 241 self.full_lines = [] … … 419 421 key = '' 420 422 temp_chk = {} 423 temp_data = [] 421 424 422 425 while True: … … 426 429 427 430 curr_line = line.strip() 431 if curr_line == "## DO NOT REMOVE -- YAML Mode": 432 self.yaml_type = "vfr" 433 428 434 if curr_line == '' or curr_line[0] == '#': 429 435 continue … … 483 489 484 490 marker1 = curr_line[0] 485 marker2 = curr_line[-1]486 491 start = 1 if marker1 == '-' else 0 487 492 pos = curr_line.find(': ') 493 if marker1 == '-': 494 marker2 = curr_line[curr_line.find(":")] 495 pos = -1 496 else: 497 marker2 = curr_line[-1] 498 488 499 if pos > 0: 489 500 child = None … … 517 528 key = '$ACTION_%04X' % self.index 518 529 self.index += 1 519 if key in curr: 520 if key not in temp_chk: 521 # check for duplicated keys at same level 522 temp_chk[key] = 1 530 531 if self.yaml_type =='fsp': 532 if key in curr: 533 if key not in temp_chk: 534 # check for duplicated keys at same level 535 temp_chk[key] = 1 536 else: 537 raise Exception("Duplicated item '%s:%s' found !" 538 % (parent_name, key)) 539 540 curr[key] = child 541 if self.yaml_type == 'vfr': 542 if key in curr.keys(): 543 if type(curr[key]) == type([]): 544 temp_data = curr[key] 545 else: 546 temp_data.append(curr[key]) 547 548 temp_data.append(child) 549 if level < 5: 550 curr[key] = temp_data 551 temp_data = [] 523 552 else: 524 raise Exception("Duplicated item '%s:%s' found !" 525 % (parent_name, key)) 526 527 curr[key] = child 553 if level < 5: 554 curr[key] = child 528 555 if self.var_dict is None and key == CFG_YAML.VARIABLE: 529 556 self.var_dict = child … … 538 565 # apply template for the main configs 539 566 self.allow_template = True 567 if self.tmp_tree and key == CFG_YAML.FORMSET: 568 self.allow_template = True 540 569 else: 541 570 child = None … … 551 580 self.load_file(opt_file) 552 581 yaml_tree = self.parse() 553 self.tmp_tree = yaml_tree[CFG_YAML.TEMPLATE] 554 self.cfg_tree = yaml_tree[CFG_YAML.CONFIGS] 582 for key in yaml_tree.keys(): 583 if key.lower() == "configs": 584 self.yaml_type = 'fsp' 585 self.tmp_tree = yaml_tree[CFG_YAML.TEMPLATE] 586 self.cfg_tree = yaml_tree[CFG_YAML.CONFIGS] 587 break 588 else: 589 self.cfg_tree = yaml_tree 590 break 591 592 if self.yaml_type == 'vfr': 593 formset_found = True 594 for key in yaml_tree.keys(): 595 if key == CFG_YAML.FORMSET: 596 self.cfg_tree = yaml_tree[CFG_YAML.FORMSET] 597 formset_found = False 598 break 599 600 if formset_found == True: 601 self.cfg_tree = yaml_tree 602 elif self.yaml_type == 'fsp': 603 self.tmp_tree = yaml_tree[CFG_YAML.TEMPLATE] 604 self.cfg_tree = yaml_tree[CFG_YAML.CONFIGS] 605 555 606 return self.cfg_tree 556 607 … … 595 646 self._cfg_page = {'root': {'title': '', 'child': []}} 596 647 self._cur_page = '' 648 self._main_page = '' 597 649 self._var_dict = {} 598 650 self._def_dict = {} 599 651 self._yaml_path = '' 652 self.yaml_type = '' 653 #Added to overcome duplicate formid 654 self.form_page_map = {} 655 self.formset_level = 0 600 656 601 657 @staticmethod … … 761 817 762 818 def get_cfg_list(self, page_id=None): 819 cfgs = [] 763 820 if page_id is None: 764 821 # return full list 765 822 return self._cfg_list 766 823 else: 767 # build a new list for items under a page ID 768 cfgs = [i for i in self._cfg_list if i['cname'] and 769 (i['page'] == page_id)] 824 if self.yaml_type == 'fsp': 825 # build a new list for items under a page ID 826 cfgs = [i for i in self._cfg_list if i['cname'] and 827 (i['page'] == page_id)] 828 #VFR YAML Support Start 829 elif self.yaml_type =='vfr': 830 for cfg in self._cfg_list: 831 for i in cfg: 832 if (i['page'] == page_id): 833 cfgs.append(i) 834 #VFR YAML Support End 770 835 return cfgs 771 836 … … 1003 1068 if len(path) == level: 1004 1069 return root 1070 if type(root) == type([]): 1071 for temp_root in root: 1072 return _locate_cfg_item(temp_root, path, level) 1005 1073 next_root = root.get(path[level], None) 1006 1074 if next_root is None: … … 1159 1227 self.set_cur_page(item.get('page', '')) 1160 1228 1161 if name [0] == '$':1229 if name != '' and name[0] == '$': 1162 1230 # skip all virtual node 1163 1231 return 0 … … 1189 1257 length = length * 8 1190 1258 1191 if n ot name.isidentifier():1259 if name != '' and not name.isidentifier(): 1192 1260 raise Exception("Invalid config name '%s' for '%s' !" % 1193 1261 (name, '.'.join(path))) … … 1288 1356 raise SystemExit("Error: Bits length not aligned for %s !" % 1289 1357 str(path)) 1358 1359 #EDK2 VFR YAML Support start 1360 1361 def build_formset_list(self, form_name='', top=None, parent_form='',path =[]): 1362 1363 if self.formset_level == 1: 1364 self._cfg_page['root']['title'] = 'Platform' 1365 self._cfg_page['root']['child'].append({form_name: {'title': form_name, 1366 'child': []}}) 1367 self._main_page = form_name 1368 1369 if top is None: 1370 top = self._cfg_tree 1371 form_name = "Formset" 1372 self._cfg_page['root']['title'] = 'Formset' 1373 1374 is_leaf = True 1375 1376 if form_name == "form" or form_name == "formid": 1377 self._cur_page = top["title"].split('#')[0] 1378 self.form_page_map[top['formid'].split('#')[0]] = self._cur_page 1379 for driver in self._cfg_page['root']['child']: 1380 if list(driver.keys())[0] == self._main_page: 1381 driver[self._main_page]['child'].append({self._cur_page: {'title': self._cur_page, 'child': []}}) 1382 1383 if form_name == "formmap": 1384 self._cur_page = top["formid"].split('#')[0] 1385 self.form_page_map[top['FormId'].split('#')[0]] = self._cur_page 1386 self._cfg_page['root']['child'].append({self._cur_page: {'title': self._cur_page, 1387 'child': []}}) 1388 1389 1390 form_data = {} 1391 temp_data = [] 1392 1393 for key in top: 1394 if key == 'include': 1395 form_data['type'] = key 1396 form_data["page"] = self._cur_page 1397 continue 1398 if type(top[key]) is list and self.formset_level <= 3: 1399 self.formset_level += 1 1400 path.append(key) 1401 for data in top[key]: 1402 self.build_formset_list(key, data, key, path) 1403 path.pop() 1404 self.formset_level -= 1 1405 elif type(top[key]) is OrderedDict and (self.formset_level <= 3): 1406 if parent_form != '': 1407 self.formset_level += 1 1408 path.append(key) 1409 self.build_formset_list(key, top[key], form_name, path) 1410 path.pop() 1411 self.formset_level -= 1 1412 else: 1413 self.formset_level += 1 1414 path.append(key) 1415 self.build_formset_list(key, top[key], key, path) 1416 path.pop() 1417 self.formset_level -= 1 1418 1419 else: 1420 form_data["page"] = self._cur_page 1421 form_data[key] = top[key] 1422 form_data['path'] = ".".join(path) 1423 if form_name != 'form' or form_name != "formid": 1424 form_data["type"] = form_name 1425 else: 1426 form_data["type"] = " " 1427 count = 0 1428 if self._cfg_list != []: 1429 for cfg_name in self._cfg_list: 1430 for list_data in cfg_name: 1431 if key == list_data['type']: 1432 count +=1 1433 if count > 1: 1434 temp_data = cfg_name 1435 1436 if len(temp_data) != 0 or len(form_data)!=0: 1437 temp_data.append(form_data) 1438 self._cfg_list.append(temp_data) 1439 return 1440 1441 #EDK2 VFR YAML Support End 1290 1442 1291 1443 def get_field_value(self, top=None): … … 2197 2349 self._cfg_tree = cfg_yaml.load_yaml(cfg_file) 2198 2350 self._def_dict = cfg_yaml.def_dict 2351 self.yaml_type = cfg_yaml.yaml_type 2199 2352 self._yaml_path = os.path.dirname(cfg_file) 2200 self.build_cfg_list() 2201 self.build_var_dict() 2202 self.update_def_value() 2353 if self.yaml_type == 'vfr': 2354 self.build_formset_list() 2355 elif self.yaml_type == 'fsp': 2356 self.build_cfg_list() 2357 self.build_var_dict() 2358 self.update_def_value() 2203 2359 return 0 2204 2360 … … 2339 2495 gen_cfg_data.override_default_value(dlt_file) 2340 2496 2341 gen_cfg_data.detect_fsp() 2497 if gen_cfg_data.yaml_type == 'fsp': 2498 gen_cfg_data.detect_fsp() 2342 2499 2343 2500 if command == "GENBIN":
Note:
See TracChangeset
for help on using the changeset viewer.