Skip to content

Commit c0e1a5d

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: add serial config in new $(board).config
Enhance the $(board).config for new board. Serial config should be set in $(board).config for new board. Tracked-On: #3854 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent 9ddf276 commit c0e1a5d

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

misc/acrn-config/board_config/board_cfg_gen.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
GEN_FILE = ["pci_devices.h", "board.c", "_acpi_info.h", "misc_cfg.h", "ve820.c", ".config"]
2323

2424

25+
def need_gen_new_board_config(board_name):
26+
27+
# 1. if it is old board, they are already have the $(board_name).config, return and no need to generate it.
28+
29+
if board_name in board_cfg_lib.BOARD_NAMES:
30+
return False
31+
else:
32+
return True
33+
34+
2535
def main(args):
2636
"""
2737
This is main function to start generate source code related with board
@@ -103,7 +113,7 @@ def main(args):
103113
return err_dic
104114

105115
# generate new board_name.config
106-
if board not in board_cfg_lib.BOARD_NAMES:
116+
if need_gen_new_board_config(board):
107117
with open(config_board_kconfig, 'w+') as config:
108118
err_dic = new_board_kconfig.generate_file(config)
109119
if err_dic:

misc/acrn-config/board_config/new_board_kconfig.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ def get_ram_range():
6464
return ram_range
6565

6666

67+
def get_serial_type():
68+
""" Get the serial type of consle which set by user """
69+
ttys_type = ''
70+
71+
# Get ttySx information from board config file
72+
ttys_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
73+
74+
scenario_name = board_cfg_lib.get_scenario_name()
75+
if scenario_name == "logical_partition":
76+
ttyn = 'ttyS0'
77+
else:
78+
# Get ttySx from scenario config file which selected by user
79+
(err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
80+
if err_dic:
81+
board_cfg_lib.ERR_LIST.update(err_dic)
82+
83+
# query the serial type from board config file
84+
for line in ttys_lines:
85+
if ttyn in line:
86+
# line format:
87+
# seri:/dev/ttyS0 type:portio base:0x3F8 irq:4
88+
# seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4
89+
ttys_type = line.split()[1].split(':')[1]
90+
break
91+
92+
return ttys_type
93+
94+
6795
def generate_file(config):
6896
"""Start to generate board.c
6997
:param config: it is a file pointer of board information for writing to
@@ -87,11 +115,17 @@ def generate_file(config):
87115
avl_start_addr = find_avl_memory(ram_range, str(total_size))
88116
hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
89117

90-
print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config)
91118
print("{}".format(DESC), file=config)
119+
print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config)
92120

93-
print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
121+
serial_type = get_serial_type()
122+
123+
if serial_type == "portio":
124+
print("CONFIG_SERIAL_LEGACY=y", file=config)
125+
if serial_type == "mmio":
126+
print("CONFIG_SERIAL_PCI=y", file=config)
94127

128+
print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
95129
print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
96130

97131
return err_dic

misc/acrn-config/library/board_cfg_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def get_scenario_name():
7171
Get scenario name from scenario.xml at fist line
7272
:param scenario_info: it is a file what contains board information for script to read from
7373
"""
74-
(err_dic, board) = common.get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
75-
return (err_dic, board)
74+
(err_dic, scenario) = common.get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
75+
return (err_dic, scenario)
7676

7777

7878
def is_config_file_match():

0 commit comments

Comments
 (0)