Skip to content

Commit a2430f1

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: refine board name with undline_name api
Sometimes character '-' or space need to be converted to '_' to make string format uniformed. Add this common api to satisfy such requirment and refine the code for board name generating. Tracked-On: #3852 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent 95b9ba3 commit a2430f1

File tree

6 files changed

+43
-38
lines changed

6 files changed

+43
-38
lines changed

misc/acrn-config/board_config/pci_devices_h.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,6 @@ def parser_pci():
6161
return (pci_dev_dic, pci_bar_dic, sub_name_count)
6262

6363

64-
65-
def undline_name(name):
66-
"""
67-
This convert name which has contain '-' to '_'
68-
:param name: name which contain '-' and ' '
69-
:return: name_str which contain'_'
70-
"""
71-
# convert '-' to '_' in name string
72-
name_str = "_".join(name.split('-')).upper()
73-
74-
# stitch '_' while ' ' in name string
75-
if ' ' in name_str:
76-
name_str = "_".join(name_str.split()).upper()
77-
78-
return name_str
79-
80-
8164
def write_pbdf(i_cnt, bdf, subname, config):
8265
"""
8366
Parser and generate pbdf
@@ -91,7 +74,7 @@ def write_pbdf(i_cnt, bdf, subname, config):
9174
tmp_sub_name = "_".join(subname.split()).upper()
9275
else:
9376
if '-' in subname:
94-
tmp_sub_name = undline_name(subname) + "_" + str(i_cnt)
77+
tmp_sub_name = board_cfg_lib.undline_name(subname) + "_" + str(i_cnt)
9578
else:
9679
tmp_sub_name = "_".join(subname.split()).upper() + "_" + str(i_cnt)
9780

misc/acrn-config/board_config/ve820_c.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@
1111
LOW_MEM_TO_PCI_HOLE = 0x20000000
1212

1313

14-
def undline_board_name(board_name):
15-
"""
16-
This convert board name which has contain '-' to '_'
17-
:param board_name:
18-
:return:
19-
"""
20-
name_list = board_name
21-
if '-' in board_name:
22-
name_list = "_".join(board_name.split('-'))
23-
24-
return name_list
25-
26-
2714
def ve820_per_launch(config, hpa_size):
2815
"""
2916
Start to generate board.c
@@ -33,7 +20,7 @@ def ve820_per_launch(config, hpa_size):
3320
if err_dic:
3421
return err_dic
3522

36-
board_name = undline_board_name(board_name)
23+
board_name = board_cfg_lib.undline_name(board_name)
3724

3825
low_mem_to_pci_hole_len = '0xA0000000'
3926
low_mem_to_pci_hole = '0x20000000'
@@ -46,9 +33,9 @@ def ve820_per_launch(config, hpa_size):
4633
print("#include <e820.h>", file=config)
4734
print("#include <vm.h>", file=config)
4835
print("", file=config)
49-
print("#define VE820_ENTRIES_{}\t{}U".format(board_name.upper(), 5), file=config)
36+
print("#define VE820_ENTRIES_{}\t{}U".format(board_name, 5), file=config)
5037
print("static const struct e820_entry ve820_entry[{}] = {{".format(
51-
"VE820_ENTRIES_{}".format(board_name.upper())), file=config)
38+
"VE820_ENTRIES_{}".format(board_name)), file=config)
5239
print("\t{\t/* usable RAM under 1MB */", file=config)
5340
print("\t\t.baseaddr = 0x0UL,", file=config)
5441
print("\t\t.length = 0xF0000UL,\t\t/* 960KB */", file=config)
@@ -96,7 +83,7 @@ def ve820_per_launch(config, hpa_size):
9683
print("*/", file=config)
9784
print("void create_prelaunched_vm_e820(struct acrn_vm *vm)", file=config)
9885
print("{", file=config)
99-
print("\tvm->e820_entry_num = VE820_ENTRIES_{};".format(board_name.upper()), file=config)
86+
print("\tvm->e820_entry_num = VE820_ENTRIES_{};".format(board_name), file=config)
10087
print("\tvm->e820_entries = ve820_entry;", file=config)
10188
print("}", file=config)
10289

misc/acrn-config/launch_config/com.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def tap_uos_net(names, vmid, config):
2121
uos_type = names['uos_types'][vmid]
2222
board_name = names['board_name']
2323

24+
vm_name = launch_cfg_lib.undline_name(uos_type).lower()
2425
if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
2526
if board_name in ("apl-mrb", "apl-up2"):
2627
print('if [ ! -f "/data/$3/$3.img" ]; then', file=config)
@@ -35,7 +36,7 @@ def tap_uos_net(names, vmid, config):
3536
print("", file=config)
3637

3738
if uos_type in ("VXWORKS", "ZEPHYR", "WINDOWS"):
38-
print("vm_name={}_vm$1".format(uos_type), file=config)
39+
print("vm_name={}_vm$1".format(vm_name), file=config)
3940

4041
if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
4142
if board_name in ("apl-mrb", "apl-up2"):
@@ -231,7 +232,7 @@ def log_level_set(uos_type, config):
231232

232233

233234
def launch_begin(board_name, uos_type, config):
234-
launch_uos = '_'.join(uos_type.lower().split())
235+
launch_uos = launch_cfg_lib.undline_name(board_name).lower()
235236
run_container(board_name, uos_type, config)
236237
print("function launch_{}()".format(launch_uos), file=config)
237238
print("{", file=config)
@@ -274,7 +275,7 @@ def uos_launch(names, args, vmid, config):
274275
board_name = names['board_name']
275276
gvt_args = args['gvt_args'][vmid]
276277
uos_type = names['uos_types'][vmid]
277-
launch_uos = '_'.join(uos_type.lower().split())
278+
launch_uos = launch_cfg_lib.undline_name(board_name).lower()
278279

279280
if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS") and not is_nuc_clr(names, vmid):
280281

misc/acrn-config/library/board_cfg_lib.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,12 @@ def get_processor_info():
460460
break
461461

462462
return tmp_list
463+
464+
465+
def undline_name(name):
466+
"""
467+
This convert name which has contain '-' to '_'
468+
:param name: name which contain '-' and ' '
469+
:return: name_str which contain'_'
470+
"""
471+
return common.undline_name(name)

misc/acrn-config/library/common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,19 @@ def get_max_clos(board_file):
622622
clos_max = int(line.split(':')[1])
623623

624624
return (cache_support, clos_max)
625+
626+
627+
def undline_name(name):
628+
"""
629+
This convert name which has contain '-' to '_'
630+
:param name: name which contain '-' and ' '
631+
:return: name_str which contain'_'
632+
"""
633+
# convert '-' to '_' in name string
634+
name_str = "_".join(name.split('-')).upper()
635+
636+
# stitch '_' while ' ' in name string
637+
if ' ' in name_str:
638+
name_str = "_".join(name_str.split()).upper()
639+
640+
return name_str

misc/acrn-config/library/launch_cfg_lib.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,12 @@ def get_pt_dev():
585585
cap_pt = PASSTHRU_DEVS
586586

587587
return cap_pt
588+
589+
590+
def undline_name(name):
591+
"""
592+
This convert name which has contain '-' to '_'
593+
:param name: name which contain '-' and ' '
594+
:return: name_str which contain'_'
595+
"""
596+
return common.undline_name(name)

0 commit comments

Comments
 (0)