Date
1 - 2 of 2
[PATCH] config_tools: board_inspector: parse bdf for ioport serial controler
Zhao, Yuanyuan
Check 'device' info of board.xml if an ioport type serial controler have
a bdf and update 'TTYS_INFO'. Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...> --- .../board_inspector/extractors/98-seri.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 misc/config_tools/board_inspector/extractors/98-seri.py diff --git a/misc/config_tools/board_inspector/extractors/98-seri.py b/misc/config_tools/board_inspector/extractors/98-seri.py new file mode 100644 index 000000000..ffe7c4d2f --- /dev/null +++ b/misc/config_tools/board_inspector/extractors/98-seri.py @@ -0,0 +1,47 @@ +# Copyright (C) 2022 Intel Corporation. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +import os, re + +from extractors.helpers import add_child, get_node +from lxml import etree + +def get_seri_bdf_info(board_etree): + devices = board_etree.xpath(f"//device[@description]") + seri_device = {} + for d in devices: + des = d.get("description") + if 'Serial controller' in des: + io_port = get_node(d, f"resource[@type='io_port']") + if io_port is not None: + bdf = des.split(' ', 1)[0] + base = io_port.get("min") + seri_device[base] = bdf + return seri_device + +def extract(args, board_etree): + bdf_info = get_seri_bdf_info(board_etree) + seri_nodes = get_node(board_etree, f"//TTYS_INFO") + if bdf_info is not None and seri_nodes is not None: + nodes = seri_nodes.xpath("text()") + seri_info = "" + print(f"nodes {nodes}") + for node in nodes[0].split('\n', 100): + print(f"node {node}") + if 'portio' in node: + base = node.split('base:', 1)[1].split(' ', 1)[0] + bdf = bdf_info.get(base) + if bdf is not None: + bdf = bdf_info[base] + seri_info = seri_info + node + ' ' + bdf + '\n' + else: + seri_info = seri_info + node + '\n' + elif node != '\t': + seri_info = seri_info + node + '\n' + father = seri_nodes.getparent() + father.remove(seri_nodes) + seri_nodes = get_node(board_etree, f"//TTYS_INFO") + add_child(father, "TTYS_INFO", seri_info) + -- 2.25.1 |
|
Junjie Mao
toggle quoted message
Show quoted text
-----Original Message-----You don't need to guess the PCI device providing a serial port; refer to /sys/class/tty/ttyS* instead. +It is not recommended to extend the use of the outputs of the legacy board inspector. Those nodes are kept only for backward compatibility purposes. For serial info, you can consult /sys/class/tty/ttyS*, under which you can find the base addresses, the PCI devices providing the port, the interrupt line (useful for COM ports). + if bdf_info is not None and seri_nodes is not None:Simply rewrite the text of the TTYS_INFO node. In fact I'm not in favor of touching those nodes in the extractors; instead a cleaner and more scalable approach is enhance the /device-classes/ttys/serial nodes by adding more info (e.g. base addresses, PCI BDF, interrupt line, etc.) there. That will involve a few cleanup in the xform scripts, though. --- Best Regards Junjie Mao + |
|