From 12a9bc29df9669fa0f7bc3b19bf2c9aa129dd450 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 11 Dec 2019 19:16:55 +0800 Subject: [PATCH] acrn-config: add CONFIG_SERIAL_x for new board Add CONFIG_SERIAL_x in $(borad).config, this will help to output console log and help new board debug. Tracked-On: #3854 Signed-off-by: Wei Liu Acked-by: Victor Sun --- .../board_config/new_board_kconfig.py | 13 ++++++--- misc/acrn-config/library/board_cfg_lib.py | 4 ++- misc/acrn-config/target/misc.py | 27 ++++++++++++++++++- misc/acrn-config/xmls/board-xmls/apl-mrb.xml | 6 ++--- .../xmls/board-xmls/apl-up2-n3350.xml | 4 +-- misc/acrn-config/xmls/board-xmls/apl-up2.xml | 4 +-- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/misc/acrn-config/board_config/new_board_kconfig.py b/misc/acrn-config/board_config/new_board_kconfig.py index 75fecaaf1..bb431a67e 100644 --- a/misc/acrn-config/board_config/new_board_kconfig.py +++ b/misc/acrn-config/board_config/new_board_kconfig.py @@ -67,6 +67,7 @@ def get_ram_range(): def get_serial_type(): """ Get the serial type of consle which set by user """ ttys_type = '' + ttys_value = '' # Get ttySx information from board config file ttys_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "", "") @@ -85,11 +86,15 @@ def get_serial_type(): if ttyn in line: # line format: # seri:/dev/ttyS0 type:portio base:0x3F8 irq:4 - # seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 + # seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 bdf:"0:x.y" ttys_type = line.split()[1].split(':')[1] + if ttys_type == "portio": + ttys_value = line.split()[2].split(':')[1] + elif ttys_type == "mmio": + ttys_value = line.split()[-1].split(':')[1] break - return ttys_type + return (ttys_type, ttys_value) def generate_file(config): @@ -118,12 +123,14 @@ def generate_file(config): print("{}".format(DESC), file=config) print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config) - serial_type = get_serial_type() + (serial_type, serial_value) = get_serial_type() if serial_type == "portio": print("CONFIG_SERIAL_LEGACY=y", file=config) + print("CONFIG_SERIAL_PIO_BASE={}".format(serial_value), file=config) if serial_type == "mmio": print("CONFIG_SERIAL_PCI=y", file=config) + print("CONFIG_SERIAL_PCI_BDF={}".format(serial_value), file=config) print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config) print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config) diff --git a/misc/acrn-config/library/board_cfg_lib.py b/misc/acrn-config/library/board_cfg_lib.py index 02d745c93..c31204001 100644 --- a/misc/acrn-config/library/board_cfg_lib.py +++ b/misc/acrn-config/library/board_cfg_lib.py @@ -284,8 +284,10 @@ def get_valid_console(): if used_console_lines: vuart0_valid_console.clear() for console in used_console_lines: + #seri:/dev/ttySx type:mmio base:0x91526000 irq:4 bdf:"00:18.0" + #seri:/dev/ttySy type:portio base:0x2f8 irq:5 tty = console.split('/')[2].split()[0] - ttys_irq = console.split(':')[-1].strip() + ttys_irq = console.split()[3].split(':')[1].strip() NATIVE_CONSOLE_DIC[tty] = ttys_irq vuart0_valid_console.append(tty) if tty: diff --git a/misc/acrn-config/target/misc.py b/misc/acrn-config/target/misc.py index 396a05228..f75b2869b 100644 --- a/misc/acrn-config/target/misc.py +++ b/misc/acrn-config/target/misc.py @@ -48,6 +48,30 @@ def detected_ttys(): return tty_used_list +def irq2bdf(irq_n): + cmd = 'lspci -vv' + res = parser_lib.cmd_execute(cmd) + bdf = '' + irq = 0 + while True: + line = res.stdout.readline().decode('ascii') + if not line: + break + + if ':' not in line: + continue + + if '.' in line.split()[0]: + bdf = line.split()[0] + + if "Interrupt:" in line.strip(): + irq = line.split()[-1] + if irq == irq_n and bdf: + break + + return bdf + + def dump_ttys_info(ttys_list, config): for ttys in ttys_list: ttys_n = ttys.split('/')[-1] @@ -65,7 +89,8 @@ def dump_ttys_info(ttys_list, config): elif ttys_type[serial_type] == 'MMIO': base_path = '{}{}/iomem_base'.format(TTY_PATH, ttys_n) base = read_ttys_node(base_path) - print("\tseri:{} type:mmio base:{} irq:{}".format(ttys, base, irq), file=config) + bdf = irq2bdf(irq) + print('\tseri:{} type:mmio base:{} irq:{} bdf:"{}"'.format(ttys, base, irq, bdf), file=config) def dump_ttys(config): diff --git a/misc/acrn-config/xmls/board-xmls/apl-mrb.xml b/misc/acrn-config/xmls/board-xmls/apl-mrb.xml index 336928fa4..897a4a8d2 100644 --- a/misc/acrn-config/xmls/board-xmls/apl-mrb.xml +++ b/misc/acrn-config/xmls/board-xmls/apl-mrb.xml @@ -278,9 +278,9 @@ - seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 - seri:/dev/ttyS2 type:mmio base:0x80E00000 irq:6 - seri:/dev/ttyS3 type:mmio base:0xB363A000 irq:7 + seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 bdf:"00:18.0" + seri:/dev/ttyS2 type:mmio base:0x80E00000 irq:6 bdf:"00:18.2" + seri:/dev/ttyS3 type:mmio base:0xB363A000 irq:7 bdf:"00:18.2" diff --git a/misc/acrn-config/xmls/board-xmls/apl-up2-n3350.xml b/misc/acrn-config/xmls/board-xmls/apl-up2-n3350.xml index 84bd32d1a..7bc572a07 100644 --- a/misc/acrn-config/xmls/board-xmls/apl-up2-n3350.xml +++ b/misc/acrn-config/xmls/board-xmls/apl-up2-n3350.xml @@ -257,8 +257,8 @@ - seri:/dev/ttyS0 type:mmio base:0x91526000 irq:4 - seri:/dev/ttyS1 type:mmio base:0x91524000 irq:5 + seri:/dev/ttyS0 type:mmio base:0x91526000 irq:4 bdf:"00:18.0" + seri:/dev/ttyS1 type:mmio base:0x91524000 irq:5 bdf:"00:18.1" diff --git a/misc/acrn-config/xmls/board-xmls/apl-up2.xml b/misc/acrn-config/xmls/board-xmls/apl-up2.xml index b955863fe..a07c2467b 100644 --- a/misc/acrn-config/xmls/board-xmls/apl-up2.xml +++ b/misc/acrn-config/xmls/board-xmls/apl-up2.xml @@ -257,8 +257,8 @@ - seri:/dev/ttyS0 type:mmio base:0x91526000 irq:4 - seri:/dev/ttyS1 type:mmio base:0x91524000 irq:5 + seri:/dev/ttyS0 type:mmio base:0x91526000 irq:4 bdf:"00:18.0" + seri:/dev/ttyS1 type:mmio base:0x91524000 irq:5 bdf:"00:18.1"