From 4ca2b3a860aeb91bbc9dad3dda3cd4af571888a1 Mon Sep 17 00:00:00 2001 From: "Yang,Yu-chu" Date: Thu, 16 Sep 2021 16:27:59 -0700 Subject: [PATCH] config-tools: allow SERIAL_CONSOLE to use any native ttyS# Remove the restriction that SERIAL_CONSOLE needs to be ttys0, ttys1, ttys2 or ttys3. 1. Lossen the restriction in xsd. 2. Rewrite the document. 3. Refine the intx.py. Refine the logic which take effect if the is specified in "SOS_COM#_IRQ" for SOS VM's legacy vuart 0. Tracked-On: #6610 Signed-off-by: Yang,Yu-chu --- misc/config_tools/schema/config.xsd | 4 +-- misc/config_tools/schema/types.xsd | 2 +- misc/config_tools/static_allocators/intx.py | 35 +++++++++++-------- .../static_allocators/lib/error.py | 3 ++ misc/config_tools/static_allocators/pio.py | 2 +- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd index 36b44fb28..cd56386cd 100644 --- a/misc/config_tools/schema/config.xsd +++ b/misc/config_tools/schema/config.xsd @@ -29,8 +29,8 @@ This option impacts the content of ``vm.(legacy_vuart id="0").base`` when :optio which specifies the PIO base for Service VM legacy vUART 0 (used for the console). The PIO base for the Service VM's legacy vUART 0 is determined using these rules: -- If :option:`hv.DEBUG_OPTIONS.SERIAL_CONSOLE` is ``ttys0``, ``ttys1``, ``ttys2``, or ``ttys3`` and it is a PIO in the - native environment, the PIO base of the Service VM legacy vUART 0 would be the same as the PIO base +- If :option:`hv.DEBUG_OPTIONS.SERIAL_CONSOLE` is any available ttyS# in the native environment, + the PIO base of the Service VM legacy vUART 0 would be the same as the PIO base corresponding to :option:`hv.DEBUG_OPTIONS.SERIAL_CONSOLE` in the native environment. - Otherwise, a PIO base would be assigned to the Service VM legacy vUART 0 from the available PIO list. diff --git a/misc/config_tools/schema/types.xsd b/misc/config_tools/schema/types.xsd index f00c7eb25..f0cb41e3c 100644 --- a/misc/config_tools/schema/types.xsd +++ b/misc/config_tools/schema/types.xsd @@ -142,7 +142,7 @@ Read more about the available scheduling options in :ref:`cpu_sharing`. - + diff --git a/misc/config_tools/static_allocators/intx.py b/misc/config_tools/static_allocators/intx.py index c24231d22..16f800938 100644 --- a/misc/config_tools/static_allocators/intx.py +++ b/misc/config_tools/static_allocators/intx.py @@ -50,6 +50,23 @@ def create_vuart_irq_node(etree, vm_id, vm_type, vuart_id, irq): common.append_node(f"./legacy_vuart[@id = '{vuart_id}']/irq", irq, allocation_vm_node) +def assign_legacy_vuart_irqs(vm_node, legacy_vuart_id, irq_list): + legacy_vuart_node_irq_text = common.get_node(f"legacy_vuart[@id = '{legacy_vuart_id}']/irq/text()", vm_node) + legacy_vuart_irq = '' + if legacy_vuart_node_irq_text == 'COM1_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM1_IRQ' \ + or legacy_vuart_node_irq_text == 'COM3_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM3_IRQ': + legacy_vuart_irq = '4' + if legacy_vuart_irq in irq_list: + remove_irq(irq_list, legacy_vuart_irq) + elif legacy_vuart_node_irq_text == 'COM2_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM2_IRQ' \ + or legacy_vuart_node_irq_text == 'COM4_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM4_IRQ': + legacy_vuart_irq = '3' + if legacy_vuart_irq in irq_list: + remove_irq(irq_list, legacy_vuart_irq) + else: + legacy_vuart_irq = alloc_irq(irq_list) + return legacy_vuart_irq + def alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree): native_ttys = lib.lib.get_native_ttys() hv_debug_console = lib.lib.parse_hv_console(scenario_etree) @@ -59,7 +76,7 @@ def alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree): vm_type = common.get_node("./vm_type/text()", vm_node) irq_list = get_native_valid_irq() if vm_type == "SOS_VM" else [f"{d}" for d in list(range(1,15))] legacy_vuart_id_list = vm_node.xpath("legacy_vuart[base != 'INVALID_COM_BASE']/@id") - legacy_vuart_irq = -1 + legacy_vuart_irq = '' for legacy_vuart_id in legacy_vuart_id_list: if legacy_vuart_id == '0' and vm_type == "SOS_VM": if hv_debug_console in native_ttys.keys(): @@ -68,23 +85,11 @@ def alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree): if legacy_vuart_irq in irq_list: remove_irq(irq_list, legacy_vuart_irq) else: - legacy_vuart_irq = alloc_irq(irq_list) + legacy_vuart_irq = assign_legacy_vuart_irqs(vm_node, legacy_vuart_id, irq_list) else: raise lib.error.ResourceError(f"{hv_debug_console} is not in the native environment! The ttyS available are: {native_ttys.keys()}") else: - legacy_vuart_node_irq_text = common.get_node(f"legacy_vuart[@id = '{legacy_vuart_id}']/irq/text()", vm_node) - if legacy_vuart_node_irq_text == 'COM1_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM1_IRQ' \ - or legacy_vuart_node_irq_text == 'COM3_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM3_IRQ': - legacy_vuart_irq = '4' - if legacy_vuart_irq in irq_list: - remove_irq(irq_list, legacy_vuart_irq) - elif legacy_vuart_node_irq_text == 'COM2_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM2_IRQ' \ - or legacy_vuart_node_irq_text == 'COM4_IRQ' or legacy_vuart_node_irq_text == 'SOS_COM4_IRQ': - legacy_vuart_irq = '3' - if legacy_vuart_irq in irq_list: - remove_irq(irq_list, legacy_vuart_irq) - else: - legacy_vuart_irq = alloc_irq(irq_list) + legacy_vuart_irq = assign_legacy_vuart_irqs(vm_node, legacy_vuart_id, irq_list) create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), vm_type, legacy_vuart_id, legacy_vuart_irq) diff --git a/misc/config_tools/static_allocators/lib/error.py b/misc/config_tools/static_allocators/lib/error.py index b4e3d0200..fcd395413 100644 --- a/misc/config_tools/static_allocators/lib/error.py +++ b/misc/config_tools/static_allocators/lib/error.py @@ -7,3 +7,6 @@ class ResourceError(Exception): """Raise this error when it is out of resource""" + +class SettingError(Exception): + """Raise this error when manual scenario configuration has a conflict with board information""" \ No newline at end of file diff --git a/misc/config_tools/static_allocators/pio.py b/misc/config_tools/static_allocators/pio.py index a1b97fe10..cbeeff3db 100644 --- a/misc/config_tools/static_allocators/pio.py +++ b/misc/config_tools/static_allocators/pio.py @@ -7,7 +7,7 @@ import sys, os, logging sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) -import common, lib.lib +import common, lib.lib, lib.error def alloc_pio(pio_list): try: