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 <irq>
is specified in "SOS_COM#_IRQ" for SOS VM's legacy vuart 0.

Tracked-On: #6610
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
This commit is contained in:
Yang,Yu-chu 2021-09-16 16:27:59 -07:00 committed by wenlingz
parent c8e2060d37
commit 4ca2b3a860
5 changed files with 27 additions and 19 deletions

View File

@ -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.

View File

@ -142,7 +142,7 @@ Read more about the available scheduling options in :ref:`cpu_sharing`.</xs:docu
<xs:simpleType name="SerialConsoleType">
<xs:restriction base="xs:string">
<xs:pattern value=".*ttyS[0-3]" />
<xs:pattern value=".*ttyS[\d]+" />
</xs:restriction>
</xs:simpleType>

View File

@ -50,29 +50,9 @@ 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 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)
vm_node_list = scenario_etree.xpath("//vm")
for vm_node in vm_node_list:
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
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():
if native_ttys[hv_debug_console]['irq'] < LEGACY_IRQ_MAX:
legacy_vuart_irq = native_ttys[hv_debug_console]['irq']
if legacy_vuart_irq in irq_list:
remove_irq(irq_list, legacy_vuart_irq)
else:
legacy_vuart_irq = alloc_irq(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:
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'
@ -85,6 +65,31 @@ def alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree):
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)
vm_node_list = scenario_etree.xpath("//vm")
for vm_node in vm_node_list:
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 = ''
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():
if native_ttys[hv_debug_console]['irq'] < LEGACY_IRQ_MAX:
legacy_vuart_irq = native_ttys[hv_debug_console]['irq']
if legacy_vuart_irq in irq_list:
remove_irq(irq_list, legacy_vuart_irq)
else:
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_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)

View File

@ -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"""

View File

@ -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: