mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-10 12:32:45 +00:00
acrn-config: re-generate TTYS_INFO in native board
Currently, MMIO PCI BDF of ttyS was indexed by IRQ, but it may found the wrong BDF when the IRQ was shared and it is not expected. So, the patch uses the MMIO base to query /proc/iomem to find BDF, the waring will get if BDF is not present in iomem. Tracked-On: #4862 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
e41c17653f
commit
5403fd720d
@ -36,7 +36,7 @@ def get_valid_ttys_for_vuart(ttys_n):
|
||||
vuart0_valid.clear()
|
||||
for tty_line in ttys_lines:
|
||||
tmp_dic = {}
|
||||
#seri:/dev/ttySx type:mmio base:0x91526000 irq:4 bdf:"00:18.0"
|
||||
#seri:/dev/ttySx type:mmio base:0x91526000 irq:4 [bdf:"00:18.0"]
|
||||
#seri:/dev/ttySy type:portio base:0x2f8 irq:5
|
||||
tty = tty_line.split('/')[2].split()[0]
|
||||
ttys_irq = tty_line.split()[3].split(':')[1].strip()
|
||||
|
@ -97,12 +97,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 bdf:"0:x.y"
|
||||
# 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:-1][0]
|
||||
if 'bdf' in line:
|
||||
ttys_value = line.split()[-1].split('"')[1:-1][0]
|
||||
else:
|
||||
common.print_yel("You have chosen a MMIO PCI serial that BDF does not existed for HV console.", warn=True)
|
||||
break
|
||||
|
||||
return (ttys_type, ttys_value)
|
||||
@ -156,7 +159,8 @@ def get_serial_console(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)
|
||||
if serial_value:
|
||||
print('CONFIG_SERIAL_PCI_BDF="{}"'.format(serial_value), file=config)
|
||||
|
||||
|
||||
def get_miscfg(hv_info, config):
|
||||
|
@ -51,29 +51,33 @@ def detected_ttys():
|
||||
return tty_used_list
|
||||
|
||||
|
||||
def irq2bdf(irq_n):
|
||||
cmd = 'lspci -vv'
|
||||
res = parser_lib.cmd_execute(cmd)
|
||||
def is_bdf_format(bdf):
|
||||
is_bdf = False
|
||||
|
||||
if len(bdf) == 7 and len(bdf.split(':')[0]) == 2 and len(bdf.split(':')[1].split('.')[0]) == 2 and len(bdf.split(".")[1]) == 1:
|
||||
is_bdf = True
|
||||
|
||||
return is_bdf
|
||||
|
||||
|
||||
def iomem2bdf(base):
|
||||
bdf = ''
|
||||
irq = 0
|
||||
while True:
|
||||
line = res.stdout.readline().decode('ascii')
|
||||
if not line:
|
||||
break
|
||||
base_iomem = base.strip('0x').lower()
|
||||
with open(MEM_PATH[0], 'rt') as mem_info:
|
||||
|
||||
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:
|
||||
while True:
|
||||
line = mem_info.readline().strip('\n')
|
||||
if not line:
|
||||
break
|
||||
|
||||
return bdf
|
||||
if base_iomem in line and '0000:' in line:
|
||||
bdf = line.split(" ")[-1].lstrip("0000").lstrip(":")
|
||||
if not is_bdf_format(bdf):
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
return bdf
|
||||
|
||||
def dump_ttys_info(ttys_list, config):
|
||||
for ttys in ttys_list:
|
||||
@ -92,8 +96,11 @@ 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)
|
||||
bdf = irq2bdf(irq)
|
||||
print('\tseri:{} type:mmio base:{} irq:{} bdf:"{}"'.format(ttys, base, irq, bdf), file=config)
|
||||
bdf = iomem2bdf(base)
|
||||
if bdf:
|
||||
print('\tseri:{} type:mmio base:{} irq:{} bdf:"{}"'.format(ttys, base, irq, bdf), file=config)
|
||||
else:
|
||||
print('\tseri:{} type:mmio base:{} irq:{}'.format(ttys, base, irq), file=config)
|
||||
|
||||
|
||||
def dump_ttys(config):
|
||||
|
Loading…
Reference in New Issue
Block a user