misc: rename common.py to avoid private library conflict

The offline tool use a utility libary and use "common" to named it, this
name conflict with some customer's local library, so we rename it to a
better and clear name.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@intel.com>
This commit is contained in:
Chenli Wei 2022-11-02 19:47:08 +08:00 committed by acrnsi-robot
parent 25445eefe7
commit 6d57f8254b
34 changed files with 601 additions and 585 deletions

View File

@ -8,9 +8,9 @@
import os, sys import os, sys
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common import acrn_config_utilities
VM_CONFIGS_PATH = os.path.join(common.SOURCE_ROOT_DIR, 'misc', 'config_tools') VM_CONFIGS_PATH = os.path.join(acrn_config_utilities.SOURCE_ROOT_DIR, 'misc', 'config_tools')
TEMPLATE_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'acpi_template', 'template') TEMPLATE_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'acpi_template', 'template')
ACPI_TABLE_LIST = [('rsdp.asl', 'rsdp.aml'), ('xsdt.asl', 'xsdt.aml'), ('facp.asl', 'facp.aml'), ACPI_TABLE_LIST = [('rsdp.asl', 'rsdp.aml'), ('xsdt.asl', 'xsdt.aml'), ('facp.asl', 'facp.aml'),

View File

@ -7,9 +7,10 @@
import sys, os, re, argparse, shutil, ctypes import sys, os, re, argparse, shutil, ctypes
from acpi_const import * from acpi_const import *
import board_cfg_lib, common import board_cfg_lib, acrn_config_utilities
import collections import collections
import lxml.etree import lxml.etree
from acrn_config_utilities import get_node
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'board_inspector')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'board_inspector'))
from acpiparser._utils import TableHeader from acpiparser._utils import TableHeader
@ -575,7 +576,7 @@ def collect_dependent_devices(board_etree, device_node):
result.add(device) result.add(device)
for node in device.findall("dependency"): for node in device.findall("dependency"):
if node.get("type") in types_in_scope: if node.get("type") in types_in_scope:
peer_device = common.get_node(f"//device[acpi_object='{node.text}']", board_etree) peer_device = get_node(f"//device[acpi_object='{node.text}']", board_etree)
if peer_device is not None: if peer_device is not None:
queue.append(peer_device) queue.append(peer_device)
@ -669,8 +670,8 @@ def gen_dsdt(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
bus_number = int(m.group(1), 16) bus_number = int(m.group(1), 16)
bdf = f"{bus_number:02x}:{device_number:02x}.{function_number}" bdf = f"{bus_number:02x}:{device_number:02x}.{function_number}"
address = hex((device_number << 16) | (function_number)) address = hex((device_number << 16) | (function_number))
device_node = common.get_node(f"//bus[@address='{hex(bus_number)}']/device[@address='{address}']", board_etree) device_node = get_node(f"//bus[@address='{hex(bus_number)}']/device[@address='{address}']", board_etree)
alloc_node = common.get_node(f"/acrn-config/vm[@id='{vm_id}']/device[@name='PTDEV_{bdf}']", allocation_etree) alloc_node = get_node(f"/acrn-config/vm[@id='{vm_id}']/device[@name='PTDEV_{bdf}']", allocation_etree)
if device_node is not None and alloc_node is not None: if device_node is not None and alloc_node is not None:
assert int(alloc_node.find("bus").text, 16) == 0, "Virtual PCI devices must be on bus 0." assert int(alloc_node.find("bus").text, 16) == 0, "Virtual PCI devices must be on bus 0."
vdev = int(alloc_node.find("dev").text, 16) vdev = int(alloc_node.find("dev").text, 16)
@ -686,8 +687,8 @@ def gen_dsdt(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
objects.add_device_object(tree) objects.add_device_object(tree)
# The _PRT remapping package, if necessary # The _PRT remapping package, if necessary
intr_pin_node = common.get_node("resource[@type='interrupt_pin']", device_node) intr_pin_node = get_node("resource[@type='interrupt_pin']", device_node)
virq_node = common.get_node("pt_intx", alloc_node) virq_node = get_node("pt_intx", alloc_node)
if intr_pin_node is not None and virq_node is not None: if intr_pin_node is not None and virq_node is not None:
pin_id = interrupt_pin_ids[intr_pin_node.get("pin")] pin_id = interrupt_pin_ids[intr_pin_node.get("pin")]
vaddr = (vdev << 16) | 0xffff vaddr = (vdev << 16) | 0xffff
@ -724,12 +725,12 @@ def gen_dsdt(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
# as the guest physical address of the passed through TPM2. Thus, it works for now to reuse the host TPM2 device # as the guest physical address of the passed through TPM2. Thus, it works for now to reuse the host TPM2 device
# object without updating the addresses of operation regions or resource descriptors. It is, however, necessary to # object without updating the addresses of operation regions or resource descriptors. It is, however, necessary to
# introduce a pass to translate such address to arbitrary guest physical ones in the future. # introduce a pass to translate such address to arbitrary guest physical ones in the future.
has_tpm2 = common.get_node(f"//vm[@id='{vm_id}']//TPM2/text()", scenario_etree) has_tpm2 = get_node(f"//vm[@id='{vm_id}']//TPM2/text()", scenario_etree)
if has_tpm2 == "y": if has_tpm2 == "y":
# TPM2 devices should have "MSFT0101" as hardware id or compatible ID # TPM2 devices should have "MSFT0101" as hardware id or compatible ID
template = common.get_node("//device[@id='MSFT0101']/aml_template", board_etree) template = get_node("//device[@id='MSFT0101']/aml_template", board_etree)
if template is None: if template is None:
template = common.get_node("//device[compatible_id='MSFT0101']/aml_template", board_etree) template = get_node("//device[compatible_id='MSFT0101']/aml_template", board_etree)
if template is not None: if template is not None:
tree = parse_tree("DefDevice", bytes.fromhex(template.text)) tree = parse_tree("DefDevice", bytes.fromhex(template.text))
objects.add_device_object(tree) objects.add_device_object(tree)
@ -768,9 +769,9 @@ def gen_dsdt(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
def gen_rtct(board_etree, scenario_etree, allocation_etree, vm_id, dest_path): def gen_rtct(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
def cpu_id_to_lapic_id(cpu_id): def cpu_id_to_lapic_id(cpu_id):
return common.get_node(f"//thread[cpu_id = '{cpu_id}']/apic_id/text()", board_etree) return get_node(f"//thread[cpu_id = '{cpu_id}']/apic_id/text()", board_etree)
vm_node = common.get_node(f"//vm[@id='{vm_id}']", scenario_etree) vm_node = get_node(f"//vm[@id='{vm_id}']", scenario_etree)
if vm_node is None: if vm_node is None:
return False return False
@ -810,7 +811,7 @@ def gen_rtct(board_etree, scenario_etree, allocation_etree, vm_id, dest_path):
# Look for the cache blocks that are visible to this VM and have software SRAM in it. Those software SRAM will be # Look for the cache blocks that are visible to this VM and have software SRAM in it. Those software SRAM will be
# exposed to the VM in RTCT. # exposed to the VM in RTCT.
for cache in board_etree.xpath(f"//caches/cache[count(processors/processor[contains('{vcpus}', .)]) and capability[@id = 'Software SRAM']]"): for cache in board_etree.xpath(f"//caches/cache[count(processors/processor[contains('{vcpus}', .)]) and capability[@id = 'Software SRAM']]"):
ssram_cap = common.get_node("capability[@id = 'Software SRAM']", cache) ssram_cap = get_node("capability[@id = 'Software SRAM']", cache)
ssram_entry = create_object( ssram_entry = create_object(
rtct.RTCTSubtableSoftwareSRAM_v2, rtct.RTCTSubtableSoftwareSRAM_v2,
@ -851,7 +852,7 @@ def main(args):
err_dic = {} err_dic = {}
(err_dic, params) = common.get_param(args) (err_dic, params) = acrn_config_utilities.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
@ -872,7 +873,7 @@ def main(args):
if out is None or out == '': if out is None or out == '':
DEST_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'scenarios', scenario_name) DEST_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'scenarios', scenario_name)
else: else:
DEST_ACPI_PATH = os.path.join(common.SOURCE_ROOT_DIR, out, 'scenarios', scenario_name) DEST_ACPI_PATH = os.path.join(acrn_config_utilities.SOURCE_ROOT_DIR, out, 'scenarios', scenario_name)
if os.path.isdir(DEST_ACPI_PATH): if os.path.isdir(DEST_ACPI_PATH):
for config in os.listdir(DEST_ACPI_PATH): for config in os.listdir(DEST_ACPI_PATH):
@ -914,10 +915,10 @@ def main(args):
except: except:
PASSTHROUGH_RTCT = False PASSTHROUGH_RTCT = False
kern_args = common.get_leaf_tag_map(scenario, "os_config", "bootargs") kern_args = acrn_config_utilities.get_leaf_tag_map(scenario, "os_config", "bootargs")
kern_type = common.get_leaf_tag_map(scenario, "os_config", "kern_type") kern_type = acrn_config_utilities.get_leaf_tag_map(scenario, "os_config", "kern_type")
for vm_id, passthru_devices in dict_passthru_devices.items(): for vm_id, passthru_devices in dict_passthru_devices.items():
bootargs_node= common.get_node(f"//vm[@id='{vm_id}']/os_config/bootargs", scenario_etree) bootargs_node= get_node(f"//vm[@id='{vm_id}']/os_config/bootargs", scenario_etree)
if bootargs_node is not None and kern_args[int(vm_id)].find('reboot=acpi') == -1 and kern_type[int(vm_id)] in ['KERNEL_BZIMAGE']: if bootargs_node is not None and kern_args[int(vm_id)].find('reboot=acpi') == -1 and kern_type[int(vm_id)] in ['KERNEL_BZIMAGE']:
emsg = "you need to specify 'reboot=acpi' in scenario file's bootargs for VM{}".format(vm_id) emsg = "you need to specify 'reboot=acpi' in scenario file's bootargs for VM{}".format(vm_id)
print(emsg) print(emsg)
@ -940,7 +941,7 @@ def main(args):
apic_ids = [] apic_ids = []
for id in dict_pcpu_list[vm_id]: for id in dict_pcpu_list[vm_id]:
apic_id = common.get_node(f"//processors//thread[cpu_id='{id}']/apic_id/text()", board_etree) apic_id = get_node(f"//processors//thread[cpu_id='{id}']/apic_id/text()", board_etree)
if apic_id is None: if apic_id is None:
emsg = 'some or all of the processors//thread/cpu_id tags are missing in board xml file for cpu {}, please run board_inspector.py to regenerate the board xml file!'.format(id) emsg = 'some or all of the processors//thread/cpu_id tags are missing in board xml file for cpu {}, please run board_inspector.py to regenerate the board xml file!'.format(id)
print(emsg) print(emsg)

View File

@ -14,7 +14,8 @@ from acpi_const import *
import acpiparser.tpm2 import acpiparser.tpm2
import inspectorlib.cdata import inspectorlib.cdata
import acpiparser.rtct import acpiparser.rtct
import common import acrn_config_utilities
from acrn_config_utilities import get_node
def move_rtct_ssram_and_bin_entries(rtct, new_base_addr, new_area_max_size): def move_rtct_ssram_and_bin_entries(rtct, new_base_addr, new_area_max_size):
''' '''
@ -75,11 +76,11 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat
rtct = acpiparser.rtct.RTCT(os.path.join(dest_vm_acpi_path, acpi_table[0])) rtct = acpiparser.rtct.RTCT(os.path.join(dest_vm_acpi_path, acpi_table[0]))
outfile = os.path.join(dest_vm_acpi_bin_path, acpi_table[1]) outfile = os.path.join(dest_vm_acpi_bin_path, acpi_table[1])
# move the guest ssram area to the area next to ACPI region # move the guest ssram area to the area next to ACPI region
pre_rt_vms = common.get_node("//vm[load_order ='PRE_LAUNCHED_VM' and vm_type ='RTVM']", scenario_etree) pre_rt_vms = get_node("//vm[load_order ='PRE_LAUNCHED_VM' and vm_type ='RTVM']", scenario_etree)
vm_id = pre_rt_vms.get("id") vm_id = pre_rt_vms.get("id")
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
ssram_start_gpa = common.get_node("./ssram/start_gpa/text()", allocation_vm_node) ssram_start_gpa = get_node("./ssram/start_gpa/text()", allocation_vm_node)
ssram_max_size = common.get_node("./ssram/max_size/text()", allocation_vm_node) ssram_max_size = get_node("./ssram/max_size/text()", allocation_vm_node)
move_rtct_ssram_and_bin_entries(rtct, int(ssram_start_gpa, 16), int(ssram_max_size, 16)) move_rtct_ssram_and_bin_entries(rtct, int(ssram_start_gpa, 16), int(ssram_max_size, 16))
fp = open(outfile, mode='wb') fp = open(outfile, mode='wb')
fp.write(rtct) fp.write(rtct)
@ -105,11 +106,11 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat
return rmsg return rmsg
def tpm2_acpi_gen(acpi_bin, board_etree, scenario_etree, allocation_etree): def tpm2_acpi_gen(acpi_bin, board_etree, scenario_etree, allocation_etree):
tpm2_enabled = common.get_node("//vm[@id = '0']/mmio_resources/TPM2/text()", scenario_etree) tpm2_enabled = get_node("//vm[@id = '0']/mmio_resources/TPM2/text()", scenario_etree)
if tpm2_enabled is not None and tpm2_enabled == 'y': if tpm2_enabled is not None and tpm2_enabled == 'y':
tpm2_node = common.get_node("//device[@id = 'MSFT0101' or compatible_id = 'MSFT0101']", board_etree) tpm2_node = get_node("//device[@id = 'MSFT0101' or compatible_id = 'MSFT0101']", board_etree)
if tpm2_node is not None: if tpm2_node is not None:
_data_len = 0x4c if common.get_node("//capability[@id = 'log_area']", board_etree) is not None else 0x40 _data_len = 0x4c if get_node("//capability[@id = 'log_area']", board_etree) is not None else 0x40
_data = bytearray(_data_len) _data = bytearray(_data_len)
ctype_data = acpiparser.tpm2.TPM2(_data) ctype_data = acpiparser.tpm2.TPM2(_data)
ctype_data.header.signature = "TPM2".encode() ctype_data.header.signature = "TPM2".encode()
@ -121,13 +122,13 @@ def tpm2_acpi_gen(acpi_bin, board_etree, scenario_etree, allocation_etree):
ctype_data.header.creatorid = "INTL".encode() ctype_data.header.creatorid = "INTL".encode()
ctype_data.header.creatorrevision = 0x20190703 ctype_data.header.creatorrevision = 0x20190703
ctype_data.address_of_control_area = 0xFED40040 ctype_data.address_of_control_area = 0xFED40040
ctype_data.start_method = int(common.get_node("//capability[@id = 'start_method']/value/text()", tpm2_node), 16) ctype_data.start_method = int(get_node("//capability[@id = 'start_method']/value/text()", tpm2_node), 16)
start_method_parameters = tpm2_node.xpath("//parameter/text()") start_method_parameters = tpm2_node.xpath("//parameter/text()")
for i in range(len(start_method_parameters)): for i in range(len(start_method_parameters)):
ctype_data.start_method_specific_parameters[i] = int(start_method_parameters[i], 16) ctype_data.start_method_specific_parameters[i] = int(start_method_parameters[i], 16)
if common.get_node("//capability[@id = 'log_area']", board_etree) is not None: if get_node("//capability[@id = 'log_area']", board_etree) is not None:
ctype_data.log_area_minimum_length = int(common.get_node("//log_area_minimum_length/text()", allocation_etree), 16) ctype_data.log_area_minimum_length = int(get_node("//log_area_minimum_length/text()", allocation_etree), 16)
ctype_data.log_area_start_address = int(common.get_node("//log_area_start_address/text()", allocation_etree), 16) ctype_data.log_area_start_address = int(get_node("//log_area_start_address/text()", allocation_etree), 16)
ctype_data.header.checksum = (~(sum(inspectorlib.cdata.to_bytes(ctype_data))) + 1) & 0xFF ctype_data.header.checksum = (~(sum(inspectorlib.cdata.to_bytes(ctype_data))) + 1) & 0xFF
acpi_bin.seek(ACPI_TPM2_ADDR_OFFSET) acpi_bin.seek(ACPI_TPM2_ADDR_OFFSET)
acpi_bin.write(inspectorlib.cdata.to_bytes(ctype_data)) acpi_bin.write(inspectorlib.cdata.to_bytes(ctype_data))
@ -253,14 +254,14 @@ def main(args):
board_etree = lxml.etree.parse(args.board) board_etree = lxml.etree.parse(args.board)
scenario_etree = lxml.etree.parse(args.scenario) scenario_etree = lxml.etree.parse(args.scenario)
scenario_name = common.get_node("//@scenario", scenario_etree) scenario_name = get_node("//@scenario", scenario_etree)
if args.asl is None: if args.asl is None:
DEST_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'scenarios', scenario_name) DEST_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'scenarios', scenario_name)
else: else:
DEST_ACPI_PATH = os.path.join(common.SOURCE_ROOT_DIR, args.asl, 'scenarios', scenario_name) DEST_ACPI_PATH = os.path.join(acrn_config_utilities.SOURCE_ROOT_DIR, args.asl, 'scenarios', scenario_name)
if args.out is None: if args.out is None:
hypervisor_out = os.path.join(common.SOURCE_ROOT_DIR, 'build', 'hypervisor') hypervisor_out = os.path.join(acrn_config_utilities.SOURCE_ROOT_DIR, 'build', 'hypervisor')
else: else:
hypervisor_out = args.out hypervisor_out = args.out
DEST_ACPI_BIN_PATH = os.path.join(hypervisor_out, 'acpi') DEST_ACPI_BIN_PATH = os.path.join(hypervisor_out, 'acpi')

View File

@ -4,7 +4,7 @@
# #
import board_cfg_lib import board_cfg_lib
import common import acrn_config_utilities
PLATFORM_HEADER = r"""/* DO NOT MODIFY THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! PLATFORM_HEADER = r"""/* DO NOT MODIFY THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
*/ */
@ -89,7 +89,7 @@ def multi_info_parser(config, default_platform, msg_s, msg_e):
write_direct = ['PM1A_EVT_ACCESS_SIZE', 'PM1A_EVT_ADDRESS', 'PM1A_CNT_ADDRESS'] write_direct = ['PM1A_EVT_ACCESS_SIZE', 'PM1A_EVT_ADDRESS', 'PM1A_CNT_ADDRESS']
pm_ac_sz = OverridAccessSize() pm_ac_sz = OverridAccessSize()
multi_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, msg_s, msg_e) multi_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, msg_s, msg_e)
msg_name = msg_s.split('_')[0].strip('<') msg_name = msg_s.split('_')[0].strip('<')
@ -138,7 +138,7 @@ def write_direct_info_parser(config, msg_s, msg_e):
:param msg_s: it is a pattern of key stings what start to match from board information :param msg_s: it is a pattern of key stings what start to match from board information
:param msg_e: it is a pattern of key stings what end to match from board information :param msg_e: it is a pattern of key stings what end to match from board information
""" """
vector_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, msg_s, msg_e) vector_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, msg_s, msg_e)
msg_name = msg_s.split('_')[0].strip('<') msg_name = msg_s.split('_')[0].strip('<')
# Set defaults if not present in target xml file # Set defaults if not present in target xml file
@ -193,7 +193,7 @@ def drhd_info_parser(config):
prev_num = 0 prev_num = 0
drhd_lines = board_cfg_lib.get_info( drhd_lines = board_cfg_lib.get_info(
common.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>") acrn_config_utilities.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>")
# write DRHD # write DRHD
print("/* DRHD of DMAR */", file=config) print("/* DRHD of DMAR */", file=config)

View File

@ -6,9 +6,10 @@
import sys import sys
import enum import enum
import board_cfg_lib import board_cfg_lib
import common import acrn_config_utilities
import lxml.etree import lxml.etree
import os import os
from acrn_config_utilities import get_node
class RDT(enum.Enum): class RDT(enum.Enum):
L2 = 0 L2 = 0
@ -33,7 +34,7 @@ MSR_IA32_L3_MASK_END = 0x00000D0F
def gen_dmar_structure(config): def gen_dmar_structure(config):
"""Generate dmar structure information""" """Generate dmar structure information"""
dmar_info_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>") dmar_info_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>")
drhd_cnt = 0 drhd_cnt = 0
drhd_dev_scope_cnt = [] drhd_dev_scope_cnt = []
dev_scope_type = [] dev_scope_type = []
@ -124,7 +125,7 @@ def populate_mba_delay_mask(rdt_res, mba_delay_list, config):
idx += 1 idx += 1
def get_rdt_enabled(): def get_rdt_enabled():
scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE) scenario_etree = lxml.etree.parse(acrn_config_utilities.SCENARIO_INFO_FILE)
enable = scenario_etree.xpath(f"//RDT_ENABLED/text()") enable = scenario_etree.xpath(f"//RDT_ENABLED/text()")
if enable[0] == "y": if enable[0] == "y":
return "true" return "true"
@ -132,7 +133,7 @@ def get_rdt_enabled():
return "false" return "false"
def get_cdp_enabled(): def get_cdp_enabled():
scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE) scenario_etree = lxml.etree.parse(acrn_config_utilities.SCENARIO_INFO_FILE)
enable = scenario_etree.xpath(f"//CDP_ENABLED/text()") enable = scenario_etree.xpath(f"//CDP_ENABLED/text()")
if enable[0] == "y": if enable[0] == "y":
return "true" return "true"
@ -153,13 +154,13 @@ def gen_rdt_str(cache, config):
err_dic = {} err_dic = {}
cat_mask_list = {} cat_mask_list = {}
board_etree = lxml.etree.parse(common.BOARD_INFO_FILE) board_etree = lxml.etree.parse(acrn_config_utilities.BOARD_INFO_FILE)
mask_length = common.get_node(f"./capability[@id='CAT']/capacity_mask_length/text()", cache) mask_length = get_node(f"./capability[@id='CAT']/capacity_mask_length/text()", cache)
clos_number = common.get_node(f"./capability[@id='CAT']/clos_number/text()", cache) clos_number = get_node(f"./capability[@id='CAT']/clos_number/text()", cache)
bitmask = (1 << int(mask_length)) - 1 bitmask = (1 << int(mask_length)) - 1
cache_level = common.get_node(f"./@level", cache) cache_level = get_node(f"./@level", cache)
cache_id = common.get_node(f"./@id", cache) cache_id = get_node(f"./@id", cache)
processor_list = board_etree.xpath(f"//cache[@level = '{cache_level}' and @id = '{cache_id}']/processors/processor/text()") processor_list = board_etree.xpath(f"//cache[@level = '{cache_level}' and @id = '{cache_id}']/processors/processor/text()")
capability_list = board_etree.xpath(f"//cache[@level = '{cache_level}' and @id = '{cache_id}']/capability/@id") capability_list = board_etree.xpath(f"//cache[@level = '{cache_level}' and @id = '{cache_id}']/capability/@id")
@ -192,7 +193,7 @@ def gen_rdt_str(cache, config):
print("\t\t\t.is_cdp_enabled = {0},".format(cdp_enable), file=config) print("\t\t\t.is_cdp_enabled = {0},".format(cdp_enable), file=config)
print("\t\t},", file=config) print("\t\t},", file=config)
elif capability_id == "MBA": elif capability_id == "MBA":
max_throttling_value = common.get_node(f"./capability/max_throttling_value/text()", cache) max_throttling_value = get_node(f"./capability/max_throttling_value/text()", cache)
rdt_res = "mba" rdt_res = "mba"
clos_config_array = "platform_mba_clos_array" clos_config_array = "platform_mba_clos_array"
print("\t{", file=config) print("\t{", file=config)
@ -207,7 +208,7 @@ def gen_rdt_str(cache, config):
cpu_mask = 0 cpu_mask = 0
for processor in processor_list: for processor in processor_list:
core_id = common.get_node(f"//thread[apic_id = '{processor}']/cpu_id/text()", board_etree) core_id = get_node(f"//thread[apic_id = '{processor}']/cpu_id/text()", board_etree)
if core_id is None: if core_id is None:
continue continue
else: else:
@ -218,7 +219,7 @@ def gen_rdt_str(cache, config):
return err_dic; return err_dic;
def get_mask_list(cache_level, cache_id): def get_mask_list(cache_level, cache_id):
allocation_dir = os.path.split(common.SCENARIO_INFO_FILE)[0] + "/configs/allocation.xml" allocation_dir = os.path.split(acrn_config_utilities.SCENARIO_INFO_FILE)[0] + "/configs/allocation.xml"
allocation_etree = lxml.etree.parse(allocation_dir) allocation_etree = lxml.etree.parse(allocation_dir)
if cache_level == "3": if cache_level == "3":
clos_list = allocation_etree.xpath(f"//clos_mask[@id = 'l3']/clos/text()") clos_list = allocation_etree.xpath(f"//clos_mask[@id = 'l3']/clos/text()")
@ -235,9 +236,9 @@ def gen_clos_array(cache_list, config):
print("struct rdt_info res_infos[RDT_INFO_NUMBER];", file=config) print("struct rdt_info res_infos[RDT_INFO_NUMBER];", file=config)
else: else:
for idx, cache in enumerate(cache_list): for idx, cache in enumerate(cache_list):
cache_level = common.get_node(f"./@level", cache) cache_level = get_node(f"./@level", cache)
cache_id = common.get_node(f"./@id", cache) cache_id = get_node(f"./@id", cache)
clos_number = common.get_node(f"./capability/clos_number/text()", cache) clos_number = get_node(f"./capability/clos_number/text()", cache)
if cache_level == "2": if cache_level == "2":
cat_mask_list = get_mask_list(cache_level, cache_id) cat_mask_list = get_mask_list(cache_level, cache_id)
@ -264,7 +265,7 @@ def gen_clos_array(cache_list, config):
print("};\n", file=config) print("};\n", file=config)
res_present[RDT.MBA.value] = 1 res_present[RDT.MBA.value] = 1
else: else:
err_dic['board config: generate board.c failed'] = "The input of {} was corrupted!".format(common.BOARD_INFO_FILE) err_dic['board config: generate board.c failed'] = "The input of {} was corrupted!".format(acrn_config_utilities.BOARD_INFO_FILE)
return err_dic return err_dic
if res_present[RDT.L2.value] == 0: if res_present[RDT.L2.value] == 0:
@ -284,9 +285,9 @@ def gen_rdt_res(config):
err_dic = {} err_dic = {}
res_present = [0, 0, 0] res_present = [0, 0, 0]
scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE) scenario_etree = lxml.etree.parse(acrn_config_utilities.SCENARIO_INFO_FILE)
allocation_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE) allocation_etree = lxml.etree.parse(acrn_config_utilities.SCENARIO_INFO_FILE)
board_etree = lxml.etree.parse(common.BOARD_INFO_FILE) board_etree = lxml.etree.parse(acrn_config_utilities.BOARD_INFO_FILE)
cache_list = board_etree.xpath(f"//cache[capability/@id = 'CAT' or capability/@id = 'MBA']") cache_list = board_etree.xpath(f"//cache[capability/@id = 'CAT' or capability/@id = 'MBA']")
gen_clos_array(cache_list, config) gen_clos_array(cache_list, config)
@ -385,9 +386,9 @@ def gen_px_cx(config):
:param config: it is a file pointer of board information for writing to :param config: it is a file pointer of board information for writing to
""" """
cpu_brand_lines = board_cfg_lib.get_info( cpu_brand_lines = board_cfg_lib.get_info(
common.BOARD_INFO_FILE, "<CPU_BRAND>", "</CPU_BRAND>") acrn_config_utilities.BOARD_INFO_FILE, "<CPU_BRAND>", "</CPU_BRAND>")
cx_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<CX_INFO>", "</CX_INFO>") cx_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<CX_INFO>", "</CX_INFO>")
px_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>") px_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>")
gen_single_data(cx_lines, 'c', config) gen_single_data(cx_lines, 'c', config)
gen_single_data(px_lines, 'p', config) gen_single_data(px_lines, 'p', config)
@ -409,7 +410,7 @@ def gen_px_cx(config):
def gen_pci_hide(config): def gen_pci_hide(config):
"""Generate hide pci information for this platform""" """Generate hide pci information for this platform"""
scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE) scenario_etree = lxml.etree.parse(acrn_config_utilities.SCENARIO_INFO_FILE)
hidden_pdev_list = [x.replace('.', ':') for x in scenario_etree.xpath(f"//HIDDEN_PDEV/text()")] hidden_pdev_list = [x.replace('.', ':') for x in scenario_etree.xpath(f"//HIDDEN_PDEV/text()")]
if board_cfg_lib.BOARD_NAME in list(board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB.keys()) and board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] != 0: if board_cfg_lib.BOARD_NAME in list(board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB.keys()) and board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] != 0:
@ -456,21 +457,21 @@ def gen_known_caps_pci_devs(config):
print("};", file=config) print("};", file=config)
def gen_cpufreq_limits(config): def gen_cpufreq_limits(config):
allocation_dir = os.path.split(common.SCENARIO_INFO_FILE)[0] + "/configs/allocation.xml" allocation_dir = os.path.split(acrn_config_utilities.SCENARIO_INFO_FILE)[0] + "/configs/allocation.xml"
allocation_etree = lxml.etree.parse(allocation_dir) allocation_etree = lxml.etree.parse(allocation_dir)
cpu_list = board_cfg_lib.get_processor_info() cpu_list = board_cfg_lib.get_processor_info()
max_cpu_num = len(cpu_list) max_cpu_num = len(cpu_list)
print("\nstruct acrn_cpufreq_limits cpufreq_limits[MAX_PCPU_NUM] = {", file=config) print("\nstruct acrn_cpufreq_limits cpufreq_limits[MAX_PCPU_NUM] = {", file=config)
for cpu_id in range(max_cpu_num): for cpu_id in range(max_cpu_num):
limit_node = common.get_node(f"//cpufreq/CPU[@id='{cpu_id}']/limits", allocation_etree) limit_node = get_node(f"//cpufreq/CPU[@id='{cpu_id}']/limits", allocation_etree)
if limit_node != None: if limit_node != None:
limit_guaranteed_lvl = common.get_node("./limit_guaranteed_lvl/text()", limit_node) limit_guaranteed_lvl = get_node("./limit_guaranteed_lvl/text()", limit_node)
limit_highest_lvl = common.get_node("./limit_highest_lvl/text()", limit_node) limit_highest_lvl = get_node("./limit_highest_lvl/text()", limit_node)
limit_lowest_lvl = common.get_node("./limit_lowest_lvl/text()", limit_node) limit_lowest_lvl = get_node("./limit_lowest_lvl/text()", limit_node)
limit_nominal_pstate = common.get_node("./limit_nominal_pstate/text()", limit_node) limit_nominal_pstate = get_node("./limit_nominal_pstate/text()", limit_node)
limit_highest_pstate = common.get_node("./limit_highest_pstate/text()", limit_node) limit_highest_pstate = get_node("./limit_highest_pstate/text()", limit_node)
limit_lowest_pstate = common.get_node("./limit_lowest_pstate/text()", limit_node) limit_lowest_pstate = get_node("./limit_lowest_pstate/text()", limit_node)
print("\t{", file=config) print("\t{", file=config)
print(f"\t\t.guaranteed_hwp_lvl = {limit_guaranteed_lvl},", file=config) print(f"\t\t.guaranteed_hwp_lvl = {limit_guaranteed_lvl},", file=config)

View File

@ -12,9 +12,9 @@ import board_c
import board_info_h import board_info_h
import pci_devices_h import pci_devices_h
import acpi_platform_h import acpi_platform_h
import common import acrn_config_utilities
ACRN_PATH = common.SOURCE_ROOT_DIR ACRN_PATH = acrn_config_utilities.SOURCE_ROOT_DIR
ACRN_CONFIG_DEF = ACRN_PATH + "misc/config_tools/data/" ACRN_CONFIG_DEF = ACRN_PATH + "misc/config_tools/data/"
ACRN_DEFAULT_ACPI = ACRN_PATH + "hypervisor/include/arch/x86/asm/default_acpi_info.h" ACRN_DEFAULT_ACPI = ACRN_PATH + "hypervisor/include/arch/x86/asm/default_acpi_info.h"
@ -29,32 +29,32 @@ def main(args):
""" """
err_dic = {} err_dic = {}
(err_dic, params) = common.get_param(args) (err_dic, params) = acrn_config_utilities.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
# check env # check env
err_dic = common.prepare() err_dic = acrn_config_utilities.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
common.BOARD_INFO_FILE = params['--board'] acrn_config_utilities.BOARD_INFO_FILE = params['--board']
common.SCENARIO_INFO_FILE = params['--scenario'] acrn_config_utilities.SCENARIO_INFO_FILE = params['--scenario']
common.get_vm_num(params['--scenario']) acrn_config_utilities.get_vm_num(params['--scenario'])
common.get_load_order() acrn_config_utilities.get_load_order()
if common.VM_COUNT > common.MAX_VM_NUM: if acrn_config_utilities.VM_COUNT > acrn_config_utilities.MAX_VM_NUM:
err_dic['vm count'] = "The number of VMs in the scenario XML file should be no greater than " \ err_dic['vm count'] = "The number of VMs in the scenario XML file should be no greater than " \
"hv.CAPACITIES.MAX_VM_NUM. Its current value is {}.".format(common.MAX_VM_NUM) "hv.CAPACITIES.MAX_VM_NUM. Its current value is {}.".format(acrn_config_utilities.MAX_VM_NUM)
return err_dic return err_dic
# check if this is the scenario config which matched board info # check if this is the scenario config which matched board info
# get board name # get board name
(err_dic, board) = common.get_board_name() (err_dic, board) = acrn_config_utilities.get_board_name()
if err_dic: if err_dic:
return err_dic return err_dic
(err_dic, scenario) = common.get_scenario_name() (err_dic, scenario) = acrn_config_utilities.get_scenario_name()
if err_dic: if err_dic:
return err_dic return err_dic
board_cfg_lib.BOARD_NAME = board board_cfg_lib.BOARD_NAME = board
@ -70,8 +70,8 @@ def main(args):
board_fix_dir = os.path.join(output, "boards/") board_fix_dir = os.path.join(output, "boards/")
scen_board_dir = os.path.join(output, "scenarios/" + scenario + "/") scen_board_dir = os.path.join(output, "scenarios/" + scenario + "/")
common.mkdir(board_fix_dir) acrn_config_utilities.mkdir(board_fix_dir)
common.mkdir(scen_board_dir) acrn_config_utilities.mkdir(scen_board_dir)
config_pci = board_fix_dir + GEN_FILE[0] config_pci = board_fix_dir + GEN_FILE[0]
config_board = board_fix_dir + GEN_FILE[1] config_board = board_fix_dir + GEN_FILE[1]
@ -110,7 +110,7 @@ def ui_entry_api(board_info, scenario_info, out=''):
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out] arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out]
err_dic = common.prepare() err_dic = acrn_config_utilities.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
@ -125,5 +125,5 @@ if __name__ == '__main__':
err_dic = main(ARGS) err_dic = main(ARGS)
if err_dic: if err_dic:
for err_k, err_v in err_dic.items(): for err_k, err_v in err_dic.items():
common.print_red("{}: {}".format(err_k, err_v), err=True) acrn_config_utilities.print_red("{}: {}".format(err_k, err_v), err=True)
sys.exit(1 if err_dic else 0) sys.exit(1 if err_dic else 0)

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import common import acrn_config_utilities
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib import scenario_cfg_lib
@ -31,7 +31,7 @@ def find_hi_mmio_window(config):
mmio_max = 0 mmio_max = 0
is_hi_mmio = False is_hi_mmio = False
iomem_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>") iomem_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>")
for line in iomem_lines: for line in iomem_lines:
if "PCI Bus" not in line: if "PCI Bus" not in line:
@ -39,12 +39,12 @@ def find_hi_mmio_window(config):
line_start_addr = int(line.split('-')[0], 16) line_start_addr = int(line.split('-')[0], 16)
line_end_addr = int(line.split('-')[1].split()[0], 16) line_end_addr = int(line.split('-')[1].split()[0], 16)
if line_start_addr < common.SIZE_4G and line_end_addr < common.SIZE_4G: if line_start_addr < acrn_config_utilities.SIZE_4G and line_end_addr < acrn_config_utilities.SIZE_4G:
continue continue
elif line_start_addr < common.SIZE_4G and line_end_addr >= common.SIZE_4G: elif line_start_addr < acrn_config_utilities.SIZE_4G and line_end_addr >= acrn_config_utilities.SIZE_4G:
i_cnt += 1 i_cnt += 1
is_hi_mmio = True is_hi_mmio = True
mmio_min = common.SIZE_4G mmio_min = acrn_config_utilities.SIZE_4G
mmio_max = line_end_addr mmio_max = line_end_addr
continue continue
@ -59,8 +59,8 @@ def find_hi_mmio_window(config):
print("", file=config) print("", file=config)
if is_hi_mmio: if is_hi_mmio:
print("#define HI_MMIO_START\t\t\t0x%xUL" % common.round_down(mmio_min, common.SIZE_G), file=config) print("#define HI_MMIO_START\t\t\t0x%xUL" % acrn_config_utilities.round_down(mmio_min, acrn_config_utilities.SIZE_G), file=config)
print("#define HI_MMIO_END\t\t\t0x%xUL" % common.round_up(mmio_max, common.SIZE_G), file=config) print("#define HI_MMIO_END\t\t\t0x%xUL" % acrn_config_utilities.round_up(mmio_max, acrn_config_utilities.SIZE_G), file=config)
else: else:
print("#define HI_MMIO_START\t\t\t~0UL", file=config) print("#define HI_MMIO_START\t\t\t~0UL", file=config)
print("#define HI_MMIO_END\t\t\t0UL", file=config) print("#define HI_MMIO_END\t\t\t0UL", file=config)
@ -91,8 +91,8 @@ def generate_file(config):
# generate HI_MMIO_START/HI_MMIO_END # generate HI_MMIO_START/HI_MMIO_END
find_hi_mmio_window(config) find_hi_mmio_window(config)
p2sb = common.get_leaf_tag_map_bool(common.SCENARIO_INFO_FILE, "mmio_resources", "p2sb") p2sb = acrn_config_utilities.get_leaf_tag_map_bool(acrn_config_utilities.SCENARIO_INFO_FILE, "mmio_resources", "p2sb")
if (common.LOAD_ORDER.get(0) == "PRE_LAUNCHED_VM" if (acrn_config_utilities.LOAD_ORDER.get(0) == "PRE_LAUNCHED_VM"
and board_cfg_lib.is_p2sb_passthru_possible() and board_cfg_lib.is_p2sb_passthru_possible()
and p2sb.get(0, False)): and p2sb.get(0, False)):
print("", file=config) print("", file=config)
@ -100,7 +100,7 @@ def generate_file(config):
hpa = board_cfg_lib.find_p2sb_bar_addr() hpa = board_cfg_lib.find_p2sb_bar_addr()
print("#define P2SB_BAR_ADDR\t\t\t0x{:X}UL".format(hpa), file=config) print("#define P2SB_BAR_ADDR\t\t\t0x{:X}UL".format(hpa), file=config)
gpa = common.hpa2gpa(0, hpa, 0x1000000) gpa = acrn_config_utilities.hpa2gpa(0, hpa, 0x1000000)
print("#define P2SB_BAR_ADDR_GPA\t\t0x{:X}UL".format(gpa), file=config) print("#define P2SB_BAR_ADDR_GPA\t\t0x{:X}UL".format(gpa), file=config)
print("#define P2SB_BAR_SIZE\t\t\t0x1000000UL", file=config) print("#define P2SB_BAR_SIZE\t\t\t0x1000000UL", file=config)

View File

@ -5,7 +5,6 @@
import collections import collections
import board_cfg_lib import board_cfg_lib
import common
PCI_HEADER = r""" PCI_HEADER = r"""
#ifndef PCI_DEVICES_H_ #ifndef PCI_DEVICES_H_

View File

@ -6,7 +6,7 @@
import re import re
from collections import namedtuple from collections import namedtuple
import common import acrn_config_utilities
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib import scenario_cfg_lib
@ -17,20 +17,20 @@ VBAR_INFO_DEFINE="""#ifndef VBAR_BASE_H_
VBAR_INFO_ENDIF="""#endif /* VBAR_BASE_H_ */""" VBAR_INFO_ENDIF="""#endif /* VBAR_BASE_H_ */"""
# Constants for ivshmem # Constants for ivshmem
BAR0_SHEMEM_SIZE = 4*common.SIZE_K BAR0_SHEMEM_SIZE = 4*acrn_config_utilities.SIZE_K
BAR1_SHEMEM_SIZE = 4*common.SIZE_K BAR1_SHEMEM_SIZE = 4*acrn_config_utilities.SIZE_K
BAR0_SHEMEM_ALIGNMENT = 4*common.SIZE_K BAR0_SHEMEM_ALIGNMENT = 4*acrn_config_utilities.SIZE_K
BAR1_SHEMEM_ALIGNMENT = 4*common.SIZE_K BAR1_SHEMEM_ALIGNMENT = 4*acrn_config_utilities.SIZE_K
BAR2_SHEMEM_ALIGNMENT = 2*common.SIZE_M BAR2_SHEMEM_ALIGNMENT = 2*acrn_config_utilities.SIZE_M
# Constants for pci vuart # Constants for pci vuart
PCI_VUART_VBAR0_SIZE = 4*common.SIZE_K PCI_VUART_VBAR0_SIZE = 4*acrn_config_utilities.SIZE_K
PCI_VUART_VBAR1_SIZE = 4*common.SIZE_K PCI_VUART_VBAR1_SIZE = 4*acrn_config_utilities.SIZE_K
PCI_VUART_VBAR0_ALIGNMENT = 4*common.SIZE_K PCI_VUART_VBAR0_ALIGNMENT = 4*acrn_config_utilities.SIZE_K
PCI_VUART_VBAR1_ALIGNMENT = 4*common.SIZE_K PCI_VUART_VBAR1_ALIGNMENT = 4*acrn_config_utilities.SIZE_K
# Constants for vmsix bar # Constants for vmsix bar
VMSIX_VBAR_SIZE = 4*common.SIZE_K VMSIX_VBAR_SIZE = 4*acrn_config_utilities.SIZE_K
VMSIX_VBAR_ALIGNMENT = VMSIX_VBAR_SIZE VMSIX_VBAR_ALIGNMENT = VMSIX_VBAR_SIZE
@ -98,13 +98,13 @@ def write_vbar(i_cnt, bdf, pci_bar_dic, bar_attr, \
if board_cfg_lib.is_matched_board(('ehl-crb-b')): if board_cfg_lib.is_matched_board(('ehl-crb-b')):
for vm_i in pci_devs_per_vm: for vm_i in pci_devs_per_vm:
if bdf in pci_devs_per_vm[vm_i]: if bdf in pci_devs_per_vm[vm_i]:
if scenario_cfg_lib.VM_DB[common.VM_TYPES[vm_i]]['load_type'] == "PRE_LAUNCHED_VM": if scenario_cfg_lib.VM_DB[acrn_config_utilities.VM_TYPES[vm_i]]['load_type'] == "PRE_LAUNCHED_VM":
is_vmsix = True is_vmsix = True
bar_len += 1 bar_len += 1
# For pre-launched VM, the windows range is form 2G to 4G # For pre-launched VM, the windows range is form 2G to 4G
free = get_free_mmio([MmioWindow(start=common.SIZE_2G, end=common.SIZE_4G-1)], \ free = get_free_mmio([MmioWindow(start=acrn_config_utilities.SIZE_2G, end=acrn_config_utilities.SIZE_4G-1)], \
mmiolist_per_vm[vm_i], VMSIX_VBAR_ALIGNMENT + VMSIX_VBAR_SIZE) mmiolist_per_vm[vm_i], VMSIX_VBAR_ALIGNMENT + VMSIX_VBAR_SIZE)
free_vbar_start_addr = common.round_up(free.start, VMSIX_VBAR_ALIGNMENT) free_vbar_start_addr = acrn_config_utilities.round_up(free.start, VMSIX_VBAR_ALIGNMENT)
free_vbar_end_addr = free_vbar_start_addr + VMSIX_VBAR_SIZE - 1 free_vbar_end_addr = free_vbar_start_addr + VMSIX_VBAR_SIZE - 1
free = MmioWindow(free_vbar_start_addr, free_vbar_end_addr) free = MmioWindow(free_vbar_start_addr, free_vbar_end_addr)
mmiolist_per_vm[vm_i].append(free) mmiolist_per_vm[vm_i].append(free)
@ -137,7 +137,7 @@ def write_vbar(i_cnt, bdf, pci_bar_dic, bar_attr, \
def find_next_bar(bar_val, bar_list): def find_next_bar(bar_val, bar_list):
pci_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>") pci_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>")
idx = bar_list[-1] idx = bar_list[-1]
for line in pci_lines: for line in pci_lines:
if bar_val.split('x')[1] in line: if bar_val.split('x')[1] in line:
@ -154,12 +154,12 @@ def find_next_bar(bar_val, bar_list):
def write_vuart_vbar(mmiolist_per_vm, sos_mmio_range, config): def write_vuart_vbar(mmiolist_per_vm, sos_mmio_range, config):
# get legacy vuart information # get legacy vuart information
vuart0_setting = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 0) vuart0_setting = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 0)
vuart1_setting = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 1) vuart1_setting = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 1)
# get pci vuart information # get pci vuart information
vuarts = common.get_vuart_info(common.SCENARIO_INFO_FILE) vuarts = acrn_config_utilities.get_vuart_info(acrn_config_utilities.SCENARIO_INFO_FILE)
for vm_id in vuarts.keys(): for vm_id in vuarts.keys():
vm_type = common.VM_TYPES[vm_id] vm_type = acrn_config_utilities.VM_TYPES[vm_id]
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "POST_LAUNCHED_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "POST_LAUNCHED_VM":
continue continue
for vuart_id in vuarts[vm_id].keys(): for vuart_id in vuarts[vm_id].keys():
@ -179,29 +179,29 @@ def write_vuart_vbar(mmiolist_per_vm, sos_mmio_range, config):
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM":
free_bar0 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], \ free_bar0 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], \
PCI_VUART_VBAR0_SIZE + PCI_VUART_VBAR0_ALIGNMENT) PCI_VUART_VBAR0_SIZE + PCI_VUART_VBAR0_ALIGNMENT)
free_bar0_start_addr = common.round_up(free_bar0.start, PCI_VUART_VBAR0_ALIGNMENT) free_bar0_start_addr = acrn_config_utilities.round_up(free_bar0.start, PCI_VUART_VBAR0_ALIGNMENT)
free_bar0_end_addr = free_bar0_start_addr + PCI_VUART_VBAR0_SIZE - 1 free_bar0_end_addr = free_bar0_start_addr + PCI_VUART_VBAR0_SIZE - 1
free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr) free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr)
mmiolist_per_vm[vm_id].append(free_bar0) mmiolist_per_vm[vm_id].append(free_bar0)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
free_bar1 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], \ free_bar1 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], \
PCI_VUART_VBAR1_SIZE + PCI_VUART_VBAR1_ALIGNMENT) PCI_VUART_VBAR1_SIZE + PCI_VUART_VBAR1_ALIGNMENT)
free_bar1_start_addr = common.round_up(free_bar1.start, PCI_VUART_VBAR1_ALIGNMENT) free_bar1_start_addr = acrn_config_utilities.round_up(free_bar1.start, PCI_VUART_VBAR1_ALIGNMENT)
free_bar1_end_addr = free_bar1_start_addr + PCI_VUART_VBAR1_SIZE - 1 free_bar1_end_addr = free_bar1_start_addr + PCI_VUART_VBAR1_SIZE - 1
free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr) free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr)
mmiolist_per_vm[vm_id].append(free_bar1) mmiolist_per_vm[vm_id].append(free_bar1)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
elif scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM": elif scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM":
free_bar0 = get_free_mmio([MmioWindow(start=common.SIZE_2G, end=common.SIZE_4G-1)], \ free_bar0 = get_free_mmio([MmioWindow(start=acrn_config_utilities.SIZE_2G, end=acrn_config_utilities.SIZE_4G-1)], \
mmiolist_per_vm[vm_id], PCI_VUART_VBAR0_SIZE + PCI_VUART_VBAR0_ALIGNMENT) mmiolist_per_vm[vm_id], PCI_VUART_VBAR0_SIZE + PCI_VUART_VBAR0_ALIGNMENT)
free_bar0_start_addr = common.round_up(free_bar0.start, PCI_VUART_VBAR0_ALIGNMENT) free_bar0_start_addr = acrn_config_utilities.round_up(free_bar0.start, PCI_VUART_VBAR0_ALIGNMENT)
free_bar0_end_addr = free_bar0_start_addr + PCI_VUART_VBAR0_SIZE - 1 free_bar0_end_addr = free_bar0_start_addr + PCI_VUART_VBAR0_SIZE - 1
free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr) free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr)
mmiolist_per_vm[vm_id].append(free_bar0) mmiolist_per_vm[vm_id].append(free_bar0)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
free_bar1 = get_free_mmio([MmioWindow(start=common.SIZE_2G, end=common.SIZE_4G-1)], \ free_bar1 = get_free_mmio([MmioWindow(start=acrn_config_utilities.SIZE_2G, end=acrn_config_utilities.SIZE_4G-1)], \
mmiolist_per_vm[vm_id], PCI_VUART_VBAR1_SIZE + PCI_VUART_VBAR1_ALIGNMENT) mmiolist_per_vm[vm_id], PCI_VUART_VBAR1_SIZE + PCI_VUART_VBAR1_ALIGNMENT)
free_bar1_start_addr = common.round_up(free_bar1.start, PCI_VUART_VBAR1_ALIGNMENT) free_bar1_start_addr = acrn_config_utilities.round_up(free_bar1.start, PCI_VUART_VBAR1_ALIGNMENT)
free_bar1_end_addr = free_bar1_start_addr + PCI_VUART_VBAR1_SIZE - 1 free_bar1_end_addr = free_bar1_start_addr + PCI_VUART_VBAR1_SIZE - 1
free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr) free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr)
mmiolist_per_vm[vm_id].append(free_bar1) mmiolist_per_vm[vm_id].append(free_bar1)
@ -213,8 +213,8 @@ def write_vuart_vbar(mmiolist_per_vm, sos_mmio_range, config):
def write_ivshmem_vbar(mmiolist_per_vm, sos_mmio_range, config): def write_ivshmem_vbar(mmiolist_per_vm, sos_mmio_range, config):
for vm_id,vm_type in common.VM_TYPES.items(): for vm_id,vm_type in acrn_config_utilities.VM_TYPES.items():
ivshmem_region = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, ivshmem_region = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE,
"FEATURES", "IVSHMEM", "IVSHMEM_REGION") "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
shmem_regions = scenario_cfg_lib.get_shmem_regions(ivshmem_region) shmem_regions = scenario_cfg_lib.get_shmem_regions(ivshmem_region)
if vm_id not in shmem_regions: if vm_id not in shmem_regions:
@ -235,21 +235,21 @@ def write_ivshmem_vbar(mmiolist_per_vm, sos_mmio_range, config):
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM":
# vbar[0] for shared memory is 4k # vbar[0] for shared memory is 4k
free_bar0 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR0_SHEMEM_ALIGNMENT + BAR0_SHEMEM_SIZE) free_bar0 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR0_SHEMEM_ALIGNMENT + BAR0_SHEMEM_SIZE)
free_bar0_start_addr = common.round_up(free_bar0.start, BAR0_SHEMEM_ALIGNMENT) free_bar0_start_addr = acrn_config_utilities.round_up(free_bar0.start, BAR0_SHEMEM_ALIGNMENT)
free_bar0_end_addr = free_bar0_start_addr + BAR0_SHEMEM_SIZE - 1 free_bar0_end_addr = free_bar0_start_addr + BAR0_SHEMEM_SIZE - 1
free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr) free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr)
mmiolist_per_vm[vm_id].append(free_bar0) mmiolist_per_vm[vm_id].append(free_bar0)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
# vbar[1] for shared memory is 4K # vbar[1] for shared memory is 4K
free_bar1 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR1_SHEMEM_ALIGNMENT + BAR1_SHEMEM_SIZE) free_bar1 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR1_SHEMEM_ALIGNMENT + BAR1_SHEMEM_SIZE)
free_bar1_start_addr = common.round_up(free_bar1.start, BAR1_SHEMEM_ALIGNMENT) free_bar1_start_addr = acrn_config_utilities.round_up(free_bar1.start, BAR1_SHEMEM_ALIGNMENT)
free_bar1_end_addr = free_bar1_start_addr + BAR1_SHEMEM_SIZE - 1 free_bar1_end_addr = free_bar1_start_addr + BAR1_SHEMEM_SIZE - 1
free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr) free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr)
mmiolist_per_vm[vm_id].append(free_bar1) mmiolist_per_vm[vm_id].append(free_bar1)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
# vbar[2] for shared memory is specified size in MB # vbar[2] for shared memory is specified size in MB
free_bar2 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR2_SHEMEM_ALIGNMENT + int_size) free_bar2 = get_free_mmio(sos_mmio_range, mmiolist_per_vm[vm_id], BAR2_SHEMEM_ALIGNMENT + int_size)
free_bar2_start_addr = common.round_up(free_bar2.start, BAR2_SHEMEM_ALIGNMENT) + 0xC free_bar2_start_addr = acrn_config_utilities.round_up(free_bar2.start, BAR2_SHEMEM_ALIGNMENT) + 0xC
free_bar2_end_addr = free_bar2_start_addr + int_size - 1 free_bar2_end_addr = free_bar2_start_addr + int_size - 1
free_bar2 = MmioWindow(free_bar2_start_addr, free_bar2_end_addr) free_bar2 = MmioWindow(free_bar2_start_addr, free_bar2_end_addr)
mmiolist_per_vm[vm_id].append(free_bar2) mmiolist_per_vm[vm_id].append(free_bar2)
@ -261,24 +261,24 @@ def write_ivshmem_vbar(mmiolist_per_vm, sos_mmio_range, config):
print("", file=config) print("", file=config)
idx += 1 idx += 1
elif scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM": elif scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM":
mmioRange = [MmioWindow(start=common.SIZE_2G, end=common.SIZE_4G-1)] mmioRange = [MmioWindow(start=acrn_config_utilities.SIZE_2G, end=acrn_config_utilities.SIZE_4G-1)]
# vbar[0] for shared memory is 4k # vbar[0] for shared memory is 4k
free_bar0 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR0_SHEMEM_ALIGNMENT + BAR0_SHEMEM_SIZE) free_bar0 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR0_SHEMEM_ALIGNMENT + BAR0_SHEMEM_SIZE)
free_bar0_start_addr = common.round_up(free_bar0.start, BAR0_SHEMEM_ALIGNMENT) free_bar0_start_addr = acrn_config_utilities.round_up(free_bar0.start, BAR0_SHEMEM_ALIGNMENT)
free_bar0_end_addr = free_bar0_start_addr + BAR0_SHEMEM_SIZE - 1 free_bar0_end_addr = free_bar0_start_addr + BAR0_SHEMEM_SIZE - 1
free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr) free_bar0 = MmioWindow(free_bar0_start_addr, free_bar0_end_addr)
mmiolist_per_vm[vm_id].append(free_bar0) mmiolist_per_vm[vm_id].append(free_bar0)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
# vbar[1] for shared memory is 4K # vbar[1] for shared memory is 4K
free_bar1 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR1_SHEMEM_ALIGNMENT + BAR1_SHEMEM_SIZE) free_bar1 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR1_SHEMEM_ALIGNMENT + BAR1_SHEMEM_SIZE)
free_bar1_start_addr = common.round_up(free_bar1.start, BAR1_SHEMEM_ALIGNMENT) free_bar1_start_addr = acrn_config_utilities.round_up(free_bar1.start, BAR1_SHEMEM_ALIGNMENT)
free_bar1_end_addr = free_bar1_start_addr + BAR1_SHEMEM_SIZE - 1 free_bar1_end_addr = free_bar1_start_addr + BAR1_SHEMEM_SIZE - 1
free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr) free_bar1 = MmioWindow(free_bar1_start_addr, free_bar1_end_addr)
mmiolist_per_vm[vm_id].append(free_bar1) mmiolist_per_vm[vm_id].append(free_bar1)
mmiolist_per_vm[vm_id].sort() mmiolist_per_vm[vm_id].sort()
# vbar[2] for shared memory is specified size in MB # vbar[2] for shared memory is specified size in MB
free_bar2 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR2_SHEMEM_ALIGNMENT + int_size) free_bar2 = get_free_mmio(mmioRange, mmiolist_per_vm[vm_id], BAR2_SHEMEM_ALIGNMENT + int_size)
free_bar2_start_addr = common.round_up(free_bar2.start, BAR2_SHEMEM_ALIGNMENT) + 0xC free_bar2_start_addr = acrn_config_utilities.round_up(free_bar2.start, BAR2_SHEMEM_ALIGNMENT) + 0xC
free_bar2_end_addr = free_bar2_start_addr + int_size - 1 free_bar2_end_addr = free_bar2_start_addr + int_size - 1
free_bar2 = MmioWindow(free_bar2_start_addr, free_bar2_end_addr) free_bar2 = MmioWindow(free_bar2_start_addr, free_bar2_end_addr)
mmiolist_per_vm[vm_id].append(free_bar2) mmiolist_per_vm[vm_id].append(free_bar2)
@ -302,7 +302,7 @@ def is_mmio_window_used(devinfo, keywords):
def get_mmio_windows_with_key(keywords): def get_mmio_windows_with_key(keywords):
keyword_mmiolist = [] keyword_mmiolist = []
exclusive_mmiolist = [] exclusive_mmiolist = []
iomem_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>") iomem_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>")
for line in iomem_lines: for line in iomem_lines:
mmio_range = line.split(':')[0] mmio_range = line.split(':')[0]
@ -373,7 +373,7 @@ def generate_file(config):
# list of all vmsix supported device list in bdf format # list of all vmsix supported device list in bdf format
bdf_list = board_cfg_lib.get_known_caps_pci_devs().get('VMSIX', []) bdf_list = board_cfg_lib.get_known_caps_pci_devs().get('VMSIX', [])
# list of all PRE_LAUNCHED_VMs' vmsix supported passthrough devices in bdf format # list of all PRE_LAUNCHED_VMs' vmsix supported passthrough devices in bdf format
pci_items = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "pci_devs", "pci_dev") pci_items = acrn_config_utilities.get_leaf_tag_map(acrn_config_utilities.SCENARIO_INFO_FILE, "pci_devs", "pci_dev")
pci_devs = scenario_cfg_lib.get_pt_pci_devs(pci_items) pci_devs = scenario_cfg_lib.get_pt_pci_devs(pci_items)
pci_devs_per_vm = get_devs_per_vm_with_key(pci_devs, bdf_list) pci_devs_per_vm = get_devs_per_vm_with_key(pci_devs, bdf_list)
# list Service VM vmsix supported devices without other PRE_LAUNCHED_VMs' in bdf format # list Service VM vmsix supported devices without other PRE_LAUNCHED_VMs' in bdf format
@ -383,12 +383,12 @@ def generate_file(config):
] ]
for vm_i in pci_devs_per_vm: for vm_i in pci_devs_per_vm:
vm_type = common.VM_TYPES[vm_i] vm_type = acrn_config_utilities.VM_TYPES[vm_i]
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM":
pci_devs_per_vm[vm_i] = sos_bdf_list pci_devs_per_vm[vm_i] = sos_bdf_list
mmiolist_per_vm = {} mmiolist_per_vm = {}
for vm_i,vm_type in common.VM_TYPES.items(): for vm_i,vm_type in acrn_config_utilities.VM_TYPES.items():
if vm_i not in mmiolist_per_vm.keys(): if vm_i not in mmiolist_per_vm.keys():
mmiolist_per_vm[vm_i] = [] mmiolist_per_vm[vm_i] = []
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM":
@ -414,10 +414,10 @@ def generate_file(config):
# start to generate board_info.h # start to generate board_info.h
print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config) print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config)
print(VBAR_INFO_DEFINE, file=config) print(VBAR_INFO_DEFINE, file=config)
common.get_vm_types() acrn_config_utilities.get_vm_types()
pre_vm = False pre_vm = False
sos_vm = False sos_vm = False
for vm_type in common.VM_TYPES.values(): for vm_type in acrn_config_utilities.VM_TYPES.values():
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM":
pre_vm = True pre_vm = True
if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "SERVICE_VM":
@ -427,7 +427,7 @@ def generate_file(config):
print(VBAR_INFO_ENDIF, file=config) print(VBAR_INFO_ENDIF, file=config)
return return
ivshmem_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") ivshmem_enabled = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
if ivshmem_enabled == 'y': if ivshmem_enabled == 'y':
write_ivshmem_vbar(mmiolist_per_vm, matching_mmios, config) write_ivshmem_vbar(mmiolist_per_vm, matching_mmios, config)

View File

@ -7,13 +7,13 @@ import sys
import subprocess # nosec import subprocess # nosec
import board_cfg_lib, scenario_cfg_lib import board_cfg_lib, scenario_cfg_lib
import hv_cfg_lib import hv_cfg_lib
import common import acrn_config_utilities
DESC = """# Board defconfig generated by acrn-config tool DESC = """# Board defconfig generated by acrn-config tool
""" """
MEM_ALIGN = 2 * common.SIZE_M MEM_ALIGN = 2 * acrn_config_utilities.SIZE_M
def get_serial_type(): def get_serial_type():
@ -23,7 +23,7 @@ def get_serial_type():
pci_mmio = False pci_mmio = False
# Get ttySx information from board config file # Get ttySx information from board config file
ttys_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>") ttys_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
# Get ttySx from scenario config file which selected by user # Get ttySx from scenario config file which selected by user
(err_dic, ttyn) = board_cfg_lib.parser_hv_console() (err_dic, ttyn) = board_cfg_lib.parser_hv_console()
@ -110,7 +110,7 @@ def get_capacities(hv_info, config):
print("CONFIG_MAX_PT_IRQ_ENTRIES={}".format(hv_info.cap.max_pt_irq_entries), file=config) print("CONFIG_MAX_PT_IRQ_ENTRIES={}".format(hv_info.cap.max_pt_irq_entries), file=config)
max_msix_table_num = 0 max_msix_table_num = 0
if not hv_info.cap.max_msix_table_num: if not hv_info.cap.max_msix_table_num:
native_max_msix_line = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<MAX_MSIX_TABLE_NUM>", "</MAX_MSIX_TABLE_NUM>") native_max_msix_line = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<MAX_MSIX_TABLE_NUM>", "</MAX_MSIX_TABLE_NUM>")
max_msix_table_num = native_max_msix_line[0].strip() max_msix_table_num = native_max_msix_line[0].strip()
else: else:
max_msix_table_num = hv_info.cap.max_msix_table_num max_msix_table_num = hv_info.cap.max_msix_table_num
@ -132,8 +132,8 @@ def generate_file(hv_info, config):
err_dic = {} err_dic = {}
# add config scenario name # add config scenario name
(err_dic, scenario_name) = common.get_scenario_name() (err_dic, scenario_name) = acrn_config_utilities.get_scenario_name()
(err_dic, board_name) = common.get_board_name() (err_dic, board_name) = acrn_config_utilities.get_board_name()
print("{}".format(DESC), file=config) print("{}".format(DESC), file=config)
if hv_info.log.release == 'y': if hv_info.log.release == 'y':

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import common import acrn_config_utilities
import hv_cfg_lib import hv_cfg_lib
class LogLevel: class LogLevel:
@ -15,9 +15,9 @@ class LogLevel:
self.console = 0 self.console = 0
def get_info(self): def get_info(self):
self.npk = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "NPK_LOGLEVEL") self.npk = acrn_config_utilities.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "NPK_LOGLEVEL")
self.mem = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "MEM_LOGLEVEL") self.mem = acrn_config_utilities.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "MEM_LOGLEVEL")
self.console = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "CONSOLE_LOGLEVEL") self.console = acrn_config_utilities.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "CONSOLE_LOGLEVEL")
def check_item(self): def check_item(self):
hv_cfg_lib.hv_range_check(self.npk, "DEBUG_OPTIONS", "NPK_LOGLEVEL", hv_cfg_lib.RANGE_DB['LOG_LEVEL']) hv_cfg_lib.hv_range_check(self.npk, "DEBUG_OPTIONS", "NPK_LOGLEVEL", hv_cfg_lib.RANGE_DB['LOG_LEVEL'])
@ -33,7 +33,7 @@ class LogOpt:
self.level = LogLevel(self.hv_file) self.level = LogLevel(self.hv_file)
def get_info(self): def get_info(self):
self.release = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "RELEASE") self.release = acrn_config_utilities.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "RELEASE")
self.level.get_info() self.level.get_info()
def check_item(self): def check_item(self):
@ -53,12 +53,12 @@ class CapHv:
self.max_msix_table_num = 0 self.max_msix_table_num = 0
def get_info(self): def get_info(self):
self.max_emu_mmio_regions = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_EMULATED_MMIO") self.max_emu_mmio_regions = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_EMULATED_MMIO")
self.max_pt_irq_entries = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PT_IRQ_ENTRIES") self.max_pt_irq_entries = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PT_IRQ_ENTRIES")
self.max_ioapic_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_NUM") self.max_ioapic_num = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_NUM")
self.max_ioapic_lines = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_LINES") self.max_ioapic_lines = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_LINES")
self.max_pci_dev_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PCI_DEV_NUM") self.max_pci_dev_num = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PCI_DEV_NUM")
self.max_msix_table_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_MSIX_TABLE_NUM") self.max_msix_table_num = acrn_config_utilities.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_MSIX_TABLE_NUM")
def check_item(self): def check_item(self):
hv_cfg_lib.hv_range_check(self.max_emu_mmio_regions, "CAPACITIES", "MAX_EMULATED_MMIO", hv_cfg_lib.RANGE_DB['EMULATED_MMIO_REGIONS']) hv_cfg_lib.hv_range_check(self.max_emu_mmio_regions, "CAPACITIES", "MAX_EMULATED_MMIO", hv_cfg_lib.RANGE_DB['EMULATED_MMIO_REGIONS'])
@ -86,19 +86,19 @@ class Features:
self.ssram_enabled = '' self.ssram_enabled = ''
def get_info(self): def get_info(self):
self.multiboot2 = common.get_hv_item_tag(self.hv_file, "FEATURES", "MULTIBOOT2_ENABLED") self.multiboot2 = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "MULTIBOOT2_ENABLED")
self.rdt_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "RDT_ENABLED") self.rdt_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "RDT_ENABLED")
self.cdp_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CDP_ENABLED") self.cdp_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CDP_ENABLED")
self.cat_max_mask = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CLOS_MASK") self.cat_max_mask = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CLOS_MASK")
self.mba_delay = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "MBA_DELAY") self.mba_delay = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "MBA_DELAY")
self.scheduler = common.get_hv_item_tag(self.hv_file, "FEATURES", "SCHEDULER") self.scheduler = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "SCHEDULER")
self.reloc = common.get_hv_item_tag(self.hv_file, "FEATURES", "RELOC_ENABLED") self.reloc = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "RELOC_ENABLED")
self.hyperv_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "HYPERV_ENABLED") self.hyperv_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "HYPERV_ENABLED")
self.acpi_parse_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "ACPI_PARSE_ENABLED") self.acpi_parse_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "ACPI_PARSE_ENABLED")
self.l1d_flush_vmentry_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "L1D_VMENTRY_ENABLED") self.l1d_flush_vmentry_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "L1D_VMENTRY_ENABLED")
self.mce_on_psc_workaround_disabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "MCE_ON_PSC_DISABLED") self.mce_on_psc_workaround_disabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "MCE_ON_PSC_DISABLED")
self.iommu_enforce_snp = common.get_hv_item_tag(self.hv_file, "FEATURES", "IOMMU_ENFORCE_SNP") self.iommu_enforce_snp = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "IOMMU_ENFORCE_SNP")
self.ssram_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "SSRAM", "SSRAM_ENABLED") self.ssram_enabled = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "SSRAM", "SSRAM_ENABLED")
def check_item(self): def check_item(self):
hv_cfg_lib.ny_support_check(self.multiboot2, "FEATURES", "MULTIBOOT2_ENABLED") hv_cfg_lib.ny_support_check(self.multiboot2, "FEATURES", "MULTIBOOT2_ENABLED")
@ -129,10 +129,10 @@ class Memory:
self.ivshmem_region = [] self.ivshmem_region = []
def get_info(self): def get_info(self):
self.stack_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "STACK_SIZE") self.stack_size = acrn_config_utilities.get_hv_item_tag(self.hv_file, "MEMORY", "STACK_SIZE")
self.hv_ram_start = common.get_hv_item_tag(self.hv_file, "MEMORY", "HV_RAM_START") self.hv_ram_start = acrn_config_utilities.get_hv_item_tag(self.hv_file, "MEMORY", "HV_RAM_START")
self.ivshmem_enable = common.get_hv_item_tag(self.hv_file, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") self.ivshmem_enable = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
self.ivshmem_region = common.get_hv_item_tag(self.hv_file, "FEATURES", "IVSHMEM", "IVSHMEM_REGION") self.ivshmem_region = acrn_config_utilities.get_hv_item_tag(self.hv_file, "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
def check_item(self): def check_item(self):
hv_cfg_lib.hv_size_check(self.stack_size, "MEMORY", "STACK_SIZE") hv_cfg_lib.hv_size_check(self.stack_size, "MEMORY", "STACK_SIZE")

View File

@ -183,7 +183,7 @@ def get_xml_attrib(config_file, attrib):
if 'board=' in line or 'scenario=' in line: if 'board=' in line or 'scenario=' in line:
if attrib not in line: if attrib not in line:
err_dic['common error'] = "The {} attribute is not in xml file".format(attrib) err_dic['acrn_config_utilities error'] = "The {} attribute is not in xml file".format(attrib)
return (err_dic, value) return (err_dic, value)
attrib_list = line.split() attrib_list = line.split()

View File

@ -5,7 +5,7 @@
import re import re
import sys import sys
import common import acrn_config_utilities
import collections import collections
BOARD_NAME = '' BOARD_NAME = ''
@ -23,7 +23,7 @@ VALID_LEGACY_IRQ = []
ERR_LIST = {} ERR_LIST = {}
USED_RAM_RANGE = {} USED_RAM_RANGE = {}
HEADER_LICENSE = common.open_license() + "\n" HEADER_LICENSE = acrn_config_utilities.open_license() + "\n"
# The data base contains hide pci device # The data base contains hide pci device
KNOWN_HIDDEN_PDEVS_BOARD_DB = { KNOWN_HIDDEN_PDEVS_BOARD_DB = {
@ -84,8 +84,8 @@ def handle_bios_info(config):
Handle bios information Handle bios information
:param config: it is a file pointer of bios information for writing to :param config: it is a file pointer of bios information for writing to
""" """
bios_lines = get_info(common.BOARD_INFO_FILE, "<BIOS_INFO>", "</BIOS_INFO>") bios_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<BIOS_INFO>", "</BIOS_INFO>")
board_lines = get_info(common.BOARD_INFO_FILE, "<BASE_BOARD_INFO>", "</BASE_BOARD_INFO>") board_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<BASE_BOARD_INFO>", "</BASE_BOARD_INFO>")
print("/*", file=config) print("/*", file=config)
if not bios_lines or not board_lines: if not bios_lines or not board_lines:
@ -216,7 +216,7 @@ def parser_hv_console():
""" """
ttys_n = '' ttys_n = ''
err_dic = {} err_dic = {}
ttys = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "DEBUG_OPTIONS", "SERIAL_CONSOLE") ttys = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
if not ttys or ttys == None: if not ttys or ttys == None:
return (err_dic, ttys_n) return (err_dic, ttys_n)
@ -237,7 +237,7 @@ def get_processor_info():
""" """
processor_list = [] processor_list = []
tmp_list = [] tmp_list = []
processor_info = get_info(common.BOARD_INFO_FILE, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>") processor_info = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>")
if not processor_info: if not processor_info:
key = "CPU PROCESSOR_INFO error:" key = "CPU PROCESSOR_INFO error:"
@ -285,7 +285,7 @@ def get_total_mem():
""" """
scale_to_mb = 1 scale_to_mb = 1
total_mem_mb = scale_to_mb total_mem_mb = scale_to_mb
mem_lines = get_info(common.BOARD_INFO_FILE, "<TOTAL_MEM_INFO>", "</TOTAL_MEM_INFO>") mem_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<TOTAL_MEM_INFO>", "</TOTAL_MEM_INFO>")
for mem_line in mem_lines: for mem_line in mem_lines:
mem_info_list = mem_line.split() mem_info_list = mem_line.split()
@ -354,7 +354,7 @@ def get_p_state_count():
Get cpu p-state count Get cpu p-state count
:return: p-state count :return: p-state count
""" """
px_info = get_info(common.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>") px_info = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>")
if px_info != None: if px_info != None:
for line in px_info: for line in px_info:
if re.search("{.*}", line) == None: if re.search("{.*}", line) == None:
@ -368,7 +368,7 @@ def get_p_state_index_from_ratio(ratio):
:return: p-state index; If no px_info found in board file, return 0; :return: p-state index; If no px_info found in board file, return 0;
""" """
closest_index = 0 closest_index = 0
px_info = get_info(common.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>") px_info = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PX_INFO>", "</PX_INFO>")
if px_info != None: if px_info != None:
for line in px_info: for line in px_info:
if re.search("{.*}", line) == None: if re.search("{.*}", line) == None:
@ -434,11 +434,11 @@ def get_size(line):
# get size string from format, Region n: Memory at x ... [size=NK] # get size string from format, Region n: Memory at x ... [size=NK]
size_str = line.split()[-1].strip(']').split('=')[1] size_str = line.split()[-1].strip(']').split('=')[1]
if 'G' in size_str: if 'G' in size_str:
size = int(size_str.strip('G')) * common.SIZE_G size = int(size_str.strip('G')) * acrn_config_utilities.SIZE_G
elif 'M' in size_str: elif 'M' in size_str:
size = int(size_str.strip('M')) * common.SIZE_M size = int(size_str.strip('M')) * acrn_config_utilities.SIZE_M
elif 'K' in size_str: elif 'K' in size_str:
size = int(size_str.strip('K')) * common.SIZE_K size = int(size_str.strip('K')) * acrn_config_utilities.SIZE_K
else: else:
size = int(size_str) size = int(size_str)
@ -449,7 +449,7 @@ def remap_bar_addr_to_high(bar_addr, line):
"""Generate vbar address""" """Generate vbar address"""
global HI_MMIO_OFFSET global HI_MMIO_OFFSET
size = get_size(line) size = get_size(line)
cur_addr = common.round_up(bar_addr, size) cur_addr = acrn_config_utilities.round_up(bar_addr, size)
HI_MMIO_OFFSET = cur_addr + size HI_MMIO_OFFSET = cur_addr + size
return cur_addr return cur_addr
@ -463,7 +463,7 @@ def parser_pci():
bar_addr = bar_num = '0' bar_addr = bar_num = '0'
cal_sub_pci_name = [] cal_sub_pci_name = []
pci_lines = get_info(common.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>") pci_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>")
for line in pci_lines: for line in pci_lines:
tmp_bar_mem = Bar_Mem() tmp_bar_mem = Bar_Mem()
@ -479,7 +479,7 @@ def parser_pci():
continue continue
bar_num = line.split()[1].strip(':') bar_num = line.split()[1].strip(':')
if bar_addr >= common.SIZE_4G or bar_addr < common.SIZE_2G: if bar_addr >= acrn_config_utilities.SIZE_4G or bar_addr < acrn_config_utilities.SIZE_2G:
if not tmp_bar_attr.remappable: if not tmp_bar_attr.remappable:
continue continue
@ -521,7 +521,7 @@ def parser_pci():
def parse_mem(): def parse_mem():
raw_shmem_regions = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_REGION") raw_shmem_regions = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
global USED_RAM_RANGE global USED_RAM_RANGE
for shm_name, shm_bar_dic in PCI_DEV_BAR_DESC.shm_bar_dic.items(): for shm_name, shm_bar_dic in PCI_DEV_BAR_DESC.shm_bar_dic.items():
@ -547,15 +547,15 @@ def parse_mem():
hv_start_offset = 0x80000000 hv_start_offset = 0x80000000
ret_start_addr = find_avl_memory(ram_range, str(0x200100), hv_start_offset) ret_start_addr = find_avl_memory(ram_range, str(0x200100), hv_start_offset)
bar_mem_0 = Bar_Mem() bar_mem_0 = Bar_Mem()
bar_mem_0.addr = hex(common.round_up(int(ret_start_addr, 16), 0x200000)) bar_mem_0.addr = hex(acrn_config_utilities.round_up(int(ret_start_addr, 16), 0x200000))
USED_RAM_RANGE[int(bar_mem_0.addr, 16)] = 0x100 USED_RAM_RANGE[int(bar_mem_0.addr, 16)] = 0x100
tmp_bar_dict[0] = bar_mem_0 tmp_bar_dict[0] = bar_mem_0
ram_range = get_ram_range() ram_range = get_ram_range()
hv_start_offset2 = 0x100000000 hv_start_offset2 = 0x100000000
ret_start_addr2 = find_avl_memory(ram_range, str(int_size + 0x200000), hv_start_offset2) ret_start_addr2 = find_avl_memory(ram_range, str(int_size + 0x200000), hv_start_offset2)
bar_mem_2 = Bar_Mem() bar_mem_2 = Bar_Mem()
bar_mem_2.addr = hex(common.round_up(int(ret_start_addr2, 16), 0x200000) + 0xC) bar_mem_2.addr = hex(acrn_config_utilities.round_up(int(ret_start_addr2, 16), 0x200000) + 0xC)
USED_RAM_RANGE[common.round_up(int(ret_start_addr2, 16), 0x20000)] = int_size USED_RAM_RANGE[acrn_config_utilities.round_up(int(ret_start_addr2, 16), 0x20000)] = int_size
tmp_bar_dict[2] = bar_mem_2 tmp_bar_dict[2] = bar_mem_2
PCI_DEV_BAR_DESC.shm_bar_dic[str(idx)+'_'+name] = tmp_bar_dict PCI_DEV_BAR_DESC.shm_bar_dic[str(idx)+'_'+name] = tmp_bar_dict
idx += 1 idx += 1
@ -565,7 +565,7 @@ def is_rdt_supported():
""" """
Returns True if platform supports RDT else False Returns True if platform supports RDT else False
""" """
(rdt_resources, rdt_res_clos_max, _) = clos_info_parser(common.BOARD_INFO_FILE) (rdt_resources, rdt_res_clos_max, _) = clos_info_parser(acrn_config_utilities.BOARD_INFO_FILE)
if len(rdt_resources) == 0 or len(rdt_res_clos_max) == 0: if len(rdt_resources) == 0 or len(rdt_res_clos_max) == 0:
return False return False
else: else:
@ -576,7 +576,7 @@ def is_rdt_enabled():
""" """
Returns True if RDT enabled else False Returns True if RDT enabled else False
""" """
rdt_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "RDT", "RDT_ENABLED") rdt_enabled = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "FEATURES", "RDT", "RDT_ENABLED")
if is_rdt_supported() and rdt_enabled == 'y': if is_rdt_supported() and rdt_enabled == 'y':
return True return True
return False return False
@ -587,7 +587,7 @@ def is_cdp_enabled():
Returns True if platform supports RDT/CDP else False Returns True if platform supports RDT/CDP else False
""" """
rdt_enabled = is_rdt_enabled() rdt_enabled = is_rdt_enabled()
cdp_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "RDT", "CDP_ENABLED") cdp_enabled = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "FEATURES", "RDT", "CDP_ENABLED")
if rdt_enabled and cdp_enabled == 'y': if rdt_enabled and cdp_enabled == 'y':
return True return True
@ -605,7 +605,7 @@ def get_rdt_select_opt():
def get_common_clos_max(): def get_common_clos_max():
common_clos_max = 0 common_clos_max = 0
(res_info, rdt_res_clos_max, clos_max_mask_list) = clos_info_parser(common.BOARD_INFO_FILE) (res_info, rdt_res_clos_max, clos_max_mask_list) = clos_info_parser(acrn_config_utilities.BOARD_INFO_FILE)
if is_rdt_enabled() and not is_cdp_enabled(): if is_rdt_enabled() and not is_cdp_enabled():
common_clos_max = min(rdt_res_clos_max) common_clos_max = min(rdt_res_clos_max)
@ -628,7 +628,7 @@ def get_sub_pci_name(i_cnt, bar_attr):
tmp_sub_name = "_".join(bar_attr.name.split()).upper() tmp_sub_name = "_".join(bar_attr.name.split()).upper()
else: else:
if '-' in bar_attr.name: if '-' in bar_attr.name:
tmp_sub_name = common.undline_name(bar_attr.name) + "_" + str(i_cnt) tmp_sub_name = acrn_config_utilities.undline_name(bar_attr.name) + "_" + str(i_cnt)
else: else:
tmp_sub_name = "_".join(bar_attr.name.split()).upper() + "_" + str(i_cnt) tmp_sub_name = "_".join(bar_attr.name.split()).upper() + "_" + str(i_cnt)
@ -636,7 +636,7 @@ def get_sub_pci_name(i_cnt, bar_attr):
def get_known_caps_pci_devs(): def get_known_caps_pci_devs():
known_caps_pci_devs = {} known_caps_pci_devs = {}
vpid_lines = get_info(common.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>") vpid_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>")
for dev,known_dev in KNOWN_CAPS_PCI_DEVS_DB.items(): for dev,known_dev in KNOWN_CAPS_PCI_DEVS_DB.items():
if dev not in known_caps_pci_devs: if dev not in known_caps_pci_devs:
known_caps_pci_devs[dev] = [] known_caps_pci_devs[dev] = []
@ -653,8 +653,8 @@ def get_known_caps_pci_devs():
def is_tpm_passthru(): def is_tpm_passthru():
tpm_passthru = False tpm_passthru = False
(_, board) = common.get_board_name() (_, board) = acrn_config_utilities.get_board_name()
tpm2_passthru_enabled = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "mmio_resources", "TPM2") tpm2_passthru_enabled = acrn_config_utilities.get_leaf_tag_map(acrn_config_utilities.SCENARIO_INFO_FILE, "mmio_resources", "TPM2")
if board in TPM_PASSTHRU_BOARD and tpm2_passthru_enabled and 'y' in tpm2_passthru_enabled.values(): if board in TPM_PASSTHRU_BOARD and tpm2_passthru_enabled and 'y' in tpm2_passthru_enabled.values():
tpm_passthru = True tpm_passthru = True
@ -692,7 +692,7 @@ def get_ram_range():
ram_range = {} ram_range = {}
io_mem_lines = get_info( io_mem_lines = get_info(
common.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>") acrn_config_utilities.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>")
for line in io_mem_lines: for line in io_mem_lines:
if 'System RAM' not in line: if 'System RAM' not in line:
@ -732,7 +732,7 @@ def get_ram_range():
def is_p2sb_passthru_possible(): def is_p2sb_passthru_possible():
p2sb_passthru = False p2sb_passthru = False
(_, board) = common.get_board_name() (_, board) = acrn_config_utilities.get_board_name()
if board in P2SB_PASSTHRU_BOARD: if board in P2SB_PASSTHRU_BOARD:
p2sb_passthru = True p2sb_passthru = True
@ -741,22 +741,22 @@ def is_p2sb_passthru_possible():
def is_matched_board(boardlist): def is_matched_board(boardlist):
(_, board) = common.get_board_name() (_, board) = acrn_config_utilities.get_board_name()
return board in boardlist return board in boardlist
def find_p2sb_bar_addr(): def find_p2sb_bar_addr():
if not is_matched_board(('ehl-crb-b')): if not is_matched_board(('ehl-crb-b')):
common.print_red('find_p2sb_bar_addr() can only be called for board ehl-crb-b', err=True) acrn_config_utilities.print_red('find_p2sb_bar_addr() can only be called for board ehl-crb-b', err=True)
sys.exit(1) sys.exit(1)
iomem_lines = get_info(common.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>") iomem_lines = get_info(acrn_config_utilities.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>")
for line in iomem_lines: for line in iomem_lines:
if 'INTC1020:' in line: if 'INTC1020:' in line:
start_addr = int(line.split('-')[0], 16) & 0xFF000000 start_addr = int(line.split('-')[0], 16) & 0xFF000000
return start_addr return start_addr
common.print_red('p2sb device is not found in board file %s!\n' % common.BOARD_INFO_FILE, err=True) acrn_config_utilities.print_red('p2sb device is not found in board file %s!\n' % acrn_config_utilities.BOARD_INFO_FILE, err=True)
sys.exit(1) sys.exit(1)

View File

@ -5,7 +5,7 @@
import os import os
import sys import sys
import common import acrn_config_utilities
import getopt import getopt
import board_cfg_lib import board_cfg_lib
@ -56,7 +56,7 @@ def is_numeric_check(str_value, prime_item, item):
def range_check(str_value, prime_item, item, range_val): def range_check(str_value, prime_item, item, range_val):
value = common.num2int(str_value) value = acrn_config_utilities.num2int(str_value)
if value < range_val['min'] or value > range_val['max']: if value < range_val['min'] or value > range_val['max']:
key = 'hv,{},{}'.format(prime_item, item) key = 'hv,{},{}'.format(prime_item, item)
ERR_LIST[key] = "{} should be in range[{},{}]".format(item, range_val['min'], range_val['max']) ERR_LIST[key] = "{} should be in range[{},{}]".format(item, range_val['min'], range_val['max'])
@ -102,7 +102,7 @@ def hv_ram_start_check(hv_ram_start, prime_item, item):
def ir_entries_check(str_num, cap, cap_ir_entries): def ir_entries_check(str_num, cap, cap_ir_entries):
hv_size_check(str_num, cap, cap_ir_entries) hv_size_check(str_num, cap, cap_ir_entries)
val = common.num2int(str_num) val = acrn_config_utilities.num2int(str_num)
if val % 2 != 0: if val % 2 != 0:
key = 'hv,{},{}'.format(cap, cap_ir_entries) key = 'hv,{},{}'.format(cap, cap_ir_entries)
ERR_LIST[key] = "{} should be a value of 2^n".format(cap_ir_entries) ERR_LIST[key] = "{} should be a value of 2^n".format(cap_ir_entries)
@ -173,7 +173,7 @@ def is_contiguous_bit_set(value):
def cat_max_mask_check(cat_mask_list, feature, cat_str, max_mask_str): def cat_max_mask_check(cat_mask_list, feature, cat_str, max_mask_str):
(res_info, rdt_res_clos_max, clos_max_mask_list) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE) (res_info, rdt_res_clos_max, clos_max_mask_list) = board_cfg_lib.clos_info_parser(acrn_config_utilities.BOARD_INFO_FILE)
if not board_cfg_lib.is_rdt_enabled() or ("L2" not in res_info and "L3" not in res_info): if not board_cfg_lib.is_rdt_enabled() or ("L2" not in res_info and "L3" not in res_info):
return return
@ -189,11 +189,11 @@ def cat_max_mask_check(cat_mask_list, feature, cat_str, max_mask_str):
return return
clos_max_mask_str = clos_max_mask_list[0].strip('"').strip("'") clos_max_mask_str = clos_max_mask_list[0].strip('"').strip("'")
clos_max_mask = common.num2int(clos_max_mask_str) clos_max_mask = acrn_config_utilities.num2int(clos_max_mask_str)
for val_str in cat_mask_list: for val_str in cat_mask_list:
if empty_check(val_str, feature, cat_str, max_mask_str): if empty_check(val_str, feature, cat_str, max_mask_str):
return return
value = common.num2int(val_str) value = acrn_config_utilities.num2int(val_str)
if value < 0 or value > clos_max_mask: if value < 0 or value > clos_max_mask:
key = 'hv,{},{},{}'.format(feature, cat_str, max_mask_str) key = 'hv,{},{},{}'.format(feature, cat_str, max_mask_str)
ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, clos_max_mask_str) ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, clos_max_mask_str)
@ -207,7 +207,7 @@ def cat_max_mask_check(cat_mask_list, feature, cat_str, max_mask_str):
def mba_delay_check(mba_delay_list, feature, mba_str, max_mask_str): def mba_delay_check(mba_delay_list, feature, mba_str, max_mask_str):
(res_info, rdt_res_clos_max, clos_max_mask_list) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE) (res_info, rdt_res_clos_max, clos_max_mask_list) = board_cfg_lib.clos_info_parser(acrn_config_utilities.BOARD_INFO_FILE)
if not board_cfg_lib.is_rdt_enabled() or "MBA" not in res_info: if not board_cfg_lib.is_rdt_enabled() or "MBA" not in res_info:
return return
@ -220,11 +220,11 @@ def mba_delay_check(mba_delay_list, feature, mba_str, max_mask_str):
mba_idx = res_info.index("MBA") mba_idx = res_info.index("MBA")
mba_delay_str = clos_max_mask_list[mba_idx].strip('"').strip("'") mba_delay_str = clos_max_mask_list[mba_idx].strip('"').strip("'")
mba_delay = common.num2int(mba_delay_str) mba_delay = acrn_config_utilities.num2int(mba_delay_str)
for val_str in mba_delay_list: for val_str in mba_delay_list:
if empty_check(val_str, feature, mba_str, max_mask_str): if empty_check(val_str, feature, mba_str, max_mask_str):
return return
value = common.num2int(val_str) value = acrn_config_utilities.num2int(val_str)
if value > mba_delay: if value > mba_delay:
key = 'hv,{},{},{}'.format(feature, mba_str, max_mask_str) key = 'hv,{},{},{}'.format(feature, mba_str, max_mask_str)
ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, mba_delay_str) ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, mba_delay_str)
@ -232,7 +232,7 @@ def mba_delay_check(mba_delay_list, feature, mba_str, max_mask_str):
def max_msix_table_num_check(max_msix_table_num, cap_str, max_msi_num_str): def max_msix_table_num_check(max_msix_table_num, cap_str, max_msi_num_str):
native_max_msix_line = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<MAX_MSIX_TABLE_NUM>", "</MAX_MSIX_TABLE_NUM>") native_max_msix_line = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<MAX_MSIX_TABLE_NUM>", "</MAX_MSIX_TABLE_NUM>")
if not native_max_msix_line and not max_msix_table_num: if not native_max_msix_line and not max_msix_table_num:
empty_check(max_msix_table_num, cap_str, max_msi_num_str) empty_check(max_msix_table_num, cap_str, max_msi_num_str)
return return

View File

@ -7,7 +7,7 @@ import os
import getopt import getopt
import re import re
import common import acrn_config_utilities
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib import scenario_cfg_lib
import lxml import lxml
@ -81,7 +81,7 @@ def get_param(args):
if arg_str not in args: if arg_str not in args:
usage(args[0]) usage(args[0])
err_dic['common error: wrong parameter'] = "wrong usage" err_dic['acrn_config_utilities error: wrong parameter'] = "wrong usage"
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
args_list = args[1:] args_list = args[1:]
@ -131,7 +131,7 @@ def launch_vm_cnt(config_file):
post_vm_count = 0 post_vm_count = 0
# get post vm number # get post vm number
root = common.get_config_root(config_file) root = acrn_config_utilities.get_config_root(config_file)
for item in root: for item in root:
if item.tag == "user_vm": if item.tag == "user_vm":
post_vm_count += 1 post_vm_count += 1
@ -147,7 +147,7 @@ def get_post_num_list():
post_vm_list = [] post_vm_list = []
# get post vm number # get post vm number
root = common.get_config_root(common.LAUNCH_INFO_FILE) root = acrn_config_utilities.get_config_root(acrn_config_utilities.LAUNCH_INFO_FILE)
for item in root: for item in root:
if item.tag == "user_vm": if item.tag == "user_vm":
post_vm_list.append(int(item.attrib['id'])) post_vm_list.append(int(item.attrib['id']))
@ -163,7 +163,7 @@ def post_vm_cnt(config_file):
""" """
post_launch_cnt = 0 post_launch_cnt = 0
for load_order in common.LOAD_ORDER.values(): for load_order in acrn_config_utilities.LOAD_ORDER.values():
if load_order == "POST_LAUNCHED_VM": if load_order == "POST_LAUNCHED_VM":
post_launch_cnt += 1 post_launch_cnt += 1
@ -175,15 +175,15 @@ def get_post_vm_cnt():
Get board name from launch.xml at fist line Get board name from launch.xml at fist line
:param scenario_file: it is a file what contains scenario information for script to read from :param scenario_file: it is a file what contains scenario information for script to read from
""" """
launch_vm_count = launch_vm_cnt(common.LAUNCH_INFO_FILE) launch_vm_count = launch_vm_cnt(acrn_config_utilities.LAUNCH_INFO_FILE)
post_vm_count = post_vm_cnt(common.SCENARIO_INFO_FILE) post_vm_count = post_vm_cnt(acrn_config_utilities.SCENARIO_INFO_FILE)
return (launch_vm_count, post_vm_count) return (launch_vm_count, post_vm_count)
def get_sos_vmid(): def get_sos_vmid():
sos_id = '' sos_id = ''
for vm_i,load_order in common.LOAD_ORDER.items(): for vm_i,load_order in acrn_config_utilities.LOAD_ORDER.items():
if load_order == "SERVICE_VM": if load_order == "SERVICE_VM":
sos_id = vm_i sos_id = vm_i
break break
@ -193,7 +193,7 @@ def get_sos_vmid():
def get_bdf_from_tag(config_file, branch_tag, tag_str): def get_bdf_from_tag(config_file, branch_tag, tag_str):
bdf_list = {} bdf_list = {}
bdf_list = common.get_leaf_tag_map(config_file, branch_tag, tag_str) bdf_list = acrn_config_utilities.get_leaf_tag_map(config_file, branch_tag, tag_str)
# split b:d:f from pci description # split b:d:f from pci description
for idx, bdf_v in bdf_list.items(): for idx, bdf_v in bdf_list.items():
@ -223,13 +223,13 @@ def get_user_vm_type():
""" """
Get User VM name from launch.xml at fist line Get User VM name from launch.xml at fist line
""" """
user_vm_types = common.get_leaf_tag_map(common.LAUNCH_INFO_FILE, "user_vm_type") user_vm_types = acrn_config_utilities.get_leaf_tag_map(acrn_config_utilities.LAUNCH_INFO_FILE, "user_vm_type")
return user_vm_types return user_vm_types
def get_user_vm_names(): def get_user_vm_names():
user_vm_names = common.get_leaf_tag_map(common.LAUNCH_INFO_FILE, "vm_name") user_vm_names = acrn_config_utilities.get_leaf_tag_map(acrn_config_utilities.LAUNCH_INFO_FILE, "vm_name")
return user_vm_names return user_vm_names
@ -410,7 +410,7 @@ def get_pt_dev():
def get_vuart1_from_scenario(vmid): def get_vuart1_from_scenario(vmid):
"""Get the vmid's vuart1 base""" """Get the vmid's vuart1 base"""
vuart1 = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 1) vuart1 = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 1)
return vuart1[vmid]['base'] return vuart1[vmid]['base']
@ -431,7 +431,7 @@ def pt_devs_check_audio(audio_map, audio_codec_map):
def check_block_mount(virtio_blk_dic): def check_block_mount(virtio_blk_dic):
(blk_dev_list, num) = board_cfg_lib.get_rootfs(common.BOARD_INFO_FILE) (blk_dev_list, num) = board_cfg_lib.get_rootfs(acrn_config_utilities.BOARD_INFO_FILE)
for vmid in list(virtio_blk_dic.keys()): for vmid in list(virtio_blk_dic.keys()):
mount_flags = [] mount_flags = []
for blk in virtio_blk_dic[vmid]: for blk in virtio_blk_dic[vmid]:
@ -494,7 +494,7 @@ def bdf_duplicate_check(bdf_dic):
def get_gpu_bdf(): def get_gpu_bdf():
pci_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>") pci_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PCI_DEVICE>", "</PCI_DEVICE>")
for line in pci_lines: for line in pci_lines:
if "VGA compatible controller" in line: if "VGA compatible controller" in line:
@ -506,7 +506,7 @@ def get_gpu_bdf():
def get_vpid_by_bdf(bdf): def get_vpid_by_bdf(bdf):
vpid = '' vpid = ''
vpid_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>") vpid_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>")
for vpid_line in vpid_lines: for vpid_line in vpid_lines:
if bdf in vpid_line: if bdf in vpid_line:
@ -572,9 +572,9 @@ def is_linux_like(user_vm_type):
def set_shm_regions(launch_item_values, scenario_info): def set_shm_regions(launch_item_values, scenario_info):
try: try:
raw_shmem_regions = common.get_hv_item_tag(scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_REGION") raw_shmem_regions = acrn_config_utilities.get_hv_item_tag(scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
load_orders = common.get_leaf_tag_map(scenario_info, "load_order") load_orders = acrn_config_utilities.get_leaf_tag_map(scenario_info, "load_order")
shm_enabled = common.get_hv_item_tag(scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") shm_enabled = acrn_config_utilities.get_hv_item_tag(scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
except: except:
return return
@ -604,12 +604,12 @@ def set_shm_regions(launch_item_values, scenario_info):
def set_pci_vuarts(launch_item_values, scenario_info): def set_pci_vuarts(launch_item_values, scenario_info):
try: try:
launch_item_values['user_vm,console_vuart'] = DM_VUART0 launch_item_values['user_vm,console_vuart'] = DM_VUART0
load_orders = common.get_leaf_tag_map(scenario_info, 'load_order') load_orders = acrn_config_utilities.get_leaf_tag_map(scenario_info, 'load_order')
sos_vm_id = 0 sos_vm_id = 0
for vm_id,load_order in load_orders.items(): for vm_id,load_order in load_orders.items():
if load_order in ['SERVICE_VM']: if load_order in ['SERVICE_VM']:
sos_vm_id = vm_id sos_vm_id = vm_id
for vm in list(common.get_config_root(scenario_info)): for vm in list(acrn_config_utilities.get_config_root(scenario_info)):
if vm.tag == 'vm' and load_orders[int(vm.attrib['id'])] == 'POST_LAUNCHED_VM': if vm.tag == 'vm' and load_orders[int(vm.attrib['id'])] == 'POST_LAUNCHED_VM':
user_vmid = int(vm.attrib['id']) - sos_vm_id user_vmid = int(vm.attrib['id']) - sos_vm_id
pci_vuart_key = 'user_vm:id={},communication_vuarts,communication_vuart'.format(user_vmid) pci_vuart_key = 'user_vm:id={},communication_vuarts,communication_vuart'.format(user_vmid)
@ -639,7 +639,7 @@ def check_shm_regions(launch_shm_regions, scenario_info):
def check_console_vuart(launch_console_vuart, vuart0, scenario_info): def check_console_vuart(launch_console_vuart, vuart0, scenario_info):
vuarts = common.get_vuart_info(scenario_info) vuarts = acrn_config_utilities.get_vuart_info(scenario_info)
for user_vmid, console_vuart_enable in launch_console_vuart.items(): for user_vmid, console_vuart_enable in launch_console_vuart.items():
key = 'user_vm:id={},console_vuart'.format(user_vmid) key = 'user_vm:id={},console_vuart'.format(user_vmid)
@ -654,8 +654,8 @@ def check_console_vuart(launch_console_vuart, vuart0, scenario_info):
def check_communication_vuart(launch_communication_vuarts, scenario_info): def check_communication_vuart(launch_communication_vuarts, scenario_info):
vuarts = common.get_vuart_info(scenario_info) vuarts = acrn_config_utilities.get_vuart_info(scenario_info)
vuart1_setting = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 1) vuart1_setting = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 1)
for user_vmid, vuart_list in launch_communication_vuarts.items(): for user_vmid, vuart_list in launch_communication_vuarts.items():
vuart_key = 'user_vm:id={},communication_vuarts,communication_vuart'.format(user_vmid) vuart_key = 'user_vm:id={},communication_vuarts,communication_vuart'.format(user_vmid)

View File

@ -7,10 +7,11 @@
import sys, os import sys, os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common import acrn_config_utilities
import re import re
from collections import defaultdict from collections import defaultdict
from collections import namedtuple from collections import namedtuple
from acrn_config_utilities import get_node
policy_owner = namedtuple("policy_owner", ["vm_name", "vcpu", "cache_type"]) policy_owner = namedtuple("policy_owner", ["vm_name", "vcpu", "cache_type"])
@ -74,9 +75,9 @@ class RdtPolicy:
l2_mask = None l2_mask = None
l3_mask = None l3_mask = None
for policy in policy_list: for policy in policy_list:
cache_level = common.get_node("../CACHE_LEVEL/text()", policy) cache_level = get_node("../CACHE_LEVEL/text()", policy)
cache_id = common.get_node("../CACHE_ID/text()", policy) cache_id = get_node("../CACHE_ID/text()", policy)
clos_mask = common.get_node("./CLOS_MASK/text()", policy) clos_mask = get_node("./CLOS_MASK/text()", policy)
if cache_level == "2": if cache_level == "2":
l2_mask = clos_mask l2_mask = clos_mask
cache2_id = cache_id cache2_id = cache_id
@ -137,19 +138,19 @@ def gen_policy_owner_list(scenario_etree):
policy_owner_list = [] policy_owner_list = []
vm_list = scenario_etree.xpath("//POLICY/VM") vm_list = scenario_etree.xpath("//POLICY/VM")
for vm in vm_list: for vm in vm_list:
vm_name = common.get_node("./text()", vm) vm_name = get_node("./text()", vm)
vcpu = common.get_node("../VCPU/text()", vm) vcpu = get_node("../VCPU/text()", vm)
cache_type = common.get_node("../TYPE/text()", vm) cache_type = get_node("../TYPE/text()", vm)
policy_owner_list.append(policy_owner(vm_name, int(vcpu), cache_type)) policy_owner_list.append(policy_owner(vm_name, int(vcpu), cache_type))
return policy_owner_list return policy_owner_list
def vm_vcat_enable(scenario_etree, vm_name): def vm_vcat_enable(scenario_etree, vm_name):
vcat_enable = common.get_node(f"//VCAT_ENABLED/text()", scenario_etree) vcat_enable = get_node(f"//VCAT_ENABLED/text()", scenario_etree)
virtual_cat_support = common.get_node(f"//vm[name = '{vm_name}']/virtual_cat_support/text()", scenario_etree) virtual_cat_support = get_node(f"//vm[name = '{vm_name}']/virtual_cat_support/text()", scenario_etree)
return (vcat_enable == "y") and (virtual_cat_support == "y") return (vcat_enable == "y") and (virtual_cat_support == "y")
def cdp_enable(scenario_etree): def cdp_enable(scenario_etree):
cdp_enable = common.get_node(f"//CDP_ENABLED/text()", scenario_etree) cdp_enable = get_node(f"//CDP_ENABLED/text()", scenario_etree)
return cdp_enable == "y" return cdp_enable == "y"
def convert_cdp_to_normal(cdp_policy_list): def convert_cdp_to_normal(cdp_policy_list):

View File

@ -4,11 +4,11 @@
# #
import math import math
import common import acrn_config_utilities
import board_cfg_lib import board_cfg_lib
import launch_cfg_lib import launch_cfg_lib
HEADER_LICENSE = common.open_license() HEADER_LICENSE = acrn_config_utilities.open_license()
SERVICE_VM_UART1_VALID_NUM = "" SERVICE_VM_UART1_VALID_NUM = ""
NATIVE_TTYS_DIC = {} NATIVE_TTYS_DIC = {}
@ -130,8 +130,8 @@ def get_pci_vuart_num(vuarts):
vuarts_num = {} vuarts_num = {}
# get legacy vuart information # get legacy vuart information
vuart0_setting = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 0) vuart0_setting = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 0)
vuart1_setting = common.get_vuart_info_id(common.SCENARIO_INFO_FILE, 1) vuart1_setting = acrn_config_utilities.get_vuart_info_id(acrn_config_utilities.SCENARIO_INFO_FILE, 1)
for vm_i,vuart_list in vuarts.items(): for vm_i,vuart_list in vuarts.items():
vuarts_num[vm_i] = 0 vuarts_num[vm_i] = 0
for vuart_id in vuart_list: for vuart_id in vuart_list:
@ -139,7 +139,7 @@ def get_pci_vuart_num(vuarts):
vuarts_num[vm_i] += 1 vuarts_num[vm_i] += 1
for vm_i in vuart0_setting: for vm_i in vuart0_setting:
load_order = common.LOAD_ORDER[vm_i] load_order = acrn_config_utilities.LOAD_ORDER[vm_i]
# Skip post-launched vm's pci base vuart0 # Skip post-launched vm's pci base vuart0
if "POST_LAUNCHED_VM" == load_order and 0 in vuarts[vm_i].keys() \ if "POST_LAUNCHED_VM" == load_order and 0 in vuarts[vm_i].keys() \
and vuarts[vm_i][0]['base'] != "INVALID_PCI_BASE": and vuarts[vm_i][0]['base'] != "INVALID_PCI_BASE":
@ -160,23 +160,23 @@ def get_pci_vuart_num(vuarts):
def get_pci_dev_num_per_vm(): def get_pci_dev_num_per_vm():
pci_dev_num_per_vm = {} pci_dev_num_per_vm = {}
pci_items = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "pci_devs", "pci_dev") pci_items = acrn_config_utilities.get_leaf_tag_map(acrn_config_utilities.SCENARIO_INFO_FILE, "pci_devs", "pci_dev")
pci_devs = get_pt_pci_devs(pci_items) pci_devs = get_pt_pci_devs(pci_items)
pt_pci_num = get_pt_pci_num(pci_devs) pt_pci_num = get_pt_pci_num(pci_devs)
ivshmem_region = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, ivshmem_region = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE,
"FEATURES", "IVSHMEM", "IVSHMEM_REGION") "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
shmem_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, shmem_enabled = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE,
"FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
shmem_regions = get_shmem_regions(ivshmem_region) shmem_regions = get_shmem_regions(ivshmem_region)
shmem_num = get_shmem_num(shmem_regions) shmem_num = get_shmem_num(shmem_regions)
vuarts = common.get_vuart_info(common.SCENARIO_INFO_FILE) vuarts = acrn_config_utilities.get_vuart_info(acrn_config_utilities.SCENARIO_INFO_FILE)
vuarts_num = get_pci_vuart_num(vuarts) vuarts_num = get_pci_vuart_num(vuarts)
for vm_i,load_order in common.LOAD_ORDER.items(): for vm_i,load_order in acrn_config_utilities.LOAD_ORDER.items():
if "POST_LAUNCHED_VM" == load_order: if "POST_LAUNCHED_VM" == load_order:
shmem_num_i = 0 shmem_num_i = 0
vuart_num = vuarts_num[vm_i] vuart_num = vuarts_num[vm_i]
@ -273,7 +273,7 @@ def guest_flag_check(guest_flags, branch_tag, leaf_tag):
for vm_i, flags in guest_flags.items(): for vm_i, flags in guest_flags.items():
for guest_flag in flags: for guest_flag in flags:
if guest_flag and guest_flag not in common.GUEST_FLAG: if guest_flag and guest_flag not in acrn_config_utilities.GUEST_FLAG:
key = "vm:id={},{},{}".format(vm_i, branch_tag, leaf_tag) key = "vm:id={},{},{}".format(vm_i, branch_tag, leaf_tag)
ERR_LIST[key] = "Unknow guest flag" ERR_LIST[key] = "Unknow guest flag"
@ -288,16 +288,16 @@ def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
use_cpus = [] use_cpus = []
cpu_sharing_enabled = True cpu_sharing_enabled = True
cpu_sharing = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "SCHEDULER") cpu_sharing = acrn_config_utilities.get_hv_item_tag(acrn_config_utilities.SCENARIO_INFO_FILE, "FEATURES", "SCHEDULER")
if cpu_sharing == "SCHED_NOOP": if cpu_sharing == "SCHED_NOOP":
cpu_sharing_enabled = False cpu_sharing_enabled = False
# validate cpu_affinity config with scenario file # validate cpu_affinity config with scenario file
sos_vmid = launch_cfg_lib.get_sos_vmid() sos_vmid = launch_cfg_lib.get_sos_vmid()
scenario_cpu_aff = common.get_leaf_tag_map(scenario_file, "cpu_affinity", "pcpu_id") scenario_cpu_aff = acrn_config_utilities.get_leaf_tag_map(scenario_file, "cpu_affinity", "pcpu_id")
scenario_vm_names = {v: k for k, v in common.get_leaf_tag_map(scenario_file, 'name').items()} scenario_vm_names = {v: k for k, v in acrn_config_utilities.get_leaf_tag_map(scenario_file, 'name').items()}
if launch_file: if launch_file:
launch_vm_names = common.get_leaf_tag_map(launch_file, 'vm_name') launch_vm_names = acrn_config_utilities.get_leaf_tag_map(launch_file, 'vm_name')
for vm_id, cpu_ids in cpu_affinity.items(): for vm_id, cpu_ids in cpu_affinity.items():
launch_vm_name = launch_vm_names[vm_id - sos_vmid] launch_vm_name = launch_vm_names[vm_id - sos_vmid]
if launch_vm_name not in scenario_vm_names: if launch_vm_name not in scenario_vm_names:
@ -325,10 +325,10 @@ def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
else: else:
use_cpus.append(cpu) use_cpus.append(cpu)
sos_vm_cpus = [] service_vm_cpus = []
pre_launch_cpus = [] pre_launch_cpus = []
post_launch_cpus = [] post_launch_cpus = []
for vm_i, load_order in common.LOAD_ORDER.items(): for vm_i, load_order in acrn_config_utilities.LOAD_ORDER.items():
if vm_i not in cpu_affinity.keys(): if vm_i not in cpu_affinity.keys():
continue continue
elif VM_DB[load_order]['load_type'] == "PRE_LAUNCHED_VM": elif VM_DB[load_order]['load_type'] == "PRE_LAUNCHED_VM":
@ -339,7 +339,7 @@ def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
post_launch_cpus.extend(cpus) post_launch_cpus.extend(cpus)
elif VM_DB[load_order]['load_type'] == "SERVICE_VM": elif VM_DB[load_order]['load_type'] == "SERVICE_VM":
cpus = [x for x in cpu_affinity[vm_i] if not None] cpus = [x for x in cpu_affinity[vm_i] if not None]
sos_vm_cpus.extend(cpus) service_vm_cpus.extend(cpus)
# duplicate cpus assign the same VM check # duplicate cpus assign the same VM check
cpus_vm_i = cpu_affinity[vm_i] cpus_vm_i = cpu_affinity[vm_i]
@ -350,7 +350,7 @@ def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
return err_dic return err_dic
if pre_launch_cpus: if pre_launch_cpus:
if "SERVICE_VM" in common.LOAD_ORDER and not sos_vm_cpus: if "SERVICE_VM" in acrn_config_utilities.LOAD_ORDER and not service_vm_cpus:
key = "Service VM cpu_affinity" key = "Service VM cpu_affinity"
err_dic[key] = "Should assign CPU id for Service VM" err_dic[key] = "Should assign CPU id for Service VM"
@ -507,7 +507,7 @@ def pci_devs_check(pci_bdf_devs, branch_tag, tag_str):
:param item: vm pci_devs item in xml :param item: vm pci_devs item in xml
:return: None :return: None
""" """
(bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE) (bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(acrn_config_utilities.BOARD_INFO_FILE)
for id_key, pci_bdf_devs_list in pci_bdf_devs.items(): for id_key, pci_bdf_devs_list in pci_bdf_devs.items():
for pci_bdf_dev in pci_bdf_devs_list: for pci_bdf_dev in pci_bdf_devs_list:
if pci_bdf_dev and pci_bdf_dev not in bdf_desc_map.keys(): if pci_bdf_dev and pci_bdf_dev not in bdf_desc_map.keys():
@ -523,7 +523,7 @@ def get_vuart1_vmid(vm_vuart1):
""" """
vm_id_dic = {} vm_id_dic = {}
new_vm_id_dic = {} new_vm_id_dic = {}
for i in list(common.LOAD_ORDER.keys()): for i in list(acrn_config_utilities.LOAD_ORDER.keys()):
for key in vm_vuart1[i].keys(): for key in vm_vuart1[i].keys():
if key == "target_vm_id": if key == "target_vm_id":
vm_id_dic[i] = vm_vuart1[i][key] vm_id_dic[i] = vm_vuart1[i][key]
@ -547,13 +547,13 @@ def cpus_assignment(cpus_per_vm, index):
:return: cpu assignment string :return: cpu assignment string
""" """
vm_cpu_bmp = {} vm_cpu_bmp = {}
if "SERVICE_VM" == common.LOAD_ORDER[index]: if "SERVICE_VM" == acrn_config_utilities.LOAD_ORDER[index]:
if index not in cpus_per_vm or cpus_per_vm[index] == [None]: if index not in cpus_per_vm or cpus_per_vm[index] == [None]:
sos_extend_all_cpus = board_cfg_lib.get_processor_info() sos_extend_all_cpus = board_cfg_lib.get_processor_info()
pre_all_cpus = [] pre_all_cpus = []
for vmid, cpu_list in cpus_per_vm.items(): for vmid, cpu_list in cpus_per_vm.items():
if vmid in common.LOAD_ORDER: if vmid in acrn_config_utilities.LOAD_ORDER:
load_order = common.LOAD_ORDER[vmid] load_order = acrn_config_utilities.LOAD_ORDER[vmid]
load_type = '' load_type = ''
if load_order in VM_DB: if load_order in VM_DB:
load_type = VM_DB[load_order]['load_type'] load_type = VM_DB[load_order]['load_type']
@ -605,7 +605,7 @@ def clos_assignment(clos_per_vm, index):
def avl_vuart_ui_select(scenario_info): def avl_vuart_ui_select(scenario_info):
tmp_vuart = {} tmp_vuart = {}
for vm_i,load_order in common.LOAD_ORDER.items(): for vm_i,load_order in acrn_config_utilities.LOAD_ORDER.items():
if "SERVICE_VM" == VM_DB[load_order]['load_type']: if "SERVICE_VM" == VM_DB[load_order]['load_type']:
key = "vm={},legacy_vuart=0,base".format(vm_i) key = "vm={},legacy_vuart=0,base".format(vm_i)
@ -624,7 +624,7 @@ def avl_vuart_ui_select(scenario_info):
def get_first_post_vm(): def get_first_post_vm():
i = 0 i = 0
for vm_i,load_order in common.LOAD_ORDER.items(): for vm_i,load_order in acrn_config_utilities.LOAD_ORDER.items():
if "POST_LAUNCHED_VM" == VM_DB[load_order]['load_type']: if "POST_LAUNCHED_VM" == VM_DB[load_order]['load_type']:
i = vm_i i = vm_i
break break
@ -635,13 +635,13 @@ def get_first_post_vm():
def avl_pci_devs(): def avl_pci_devs():
pci_dev_list = [] pci_dev_list = []
(bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE) (bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(acrn_config_utilities.BOARD_INFO_FILE)
pci_dev_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['ethernet']) pci_dev_list = acrn_config_utilities.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['ethernet'])
tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['sata']) tmp_pci_list = acrn_config_utilities.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['sata'])
pci_dev_list.extend(tmp_pci_list) pci_dev_list.extend(tmp_pci_list)
tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['nvme']) tmp_pci_list = acrn_config_utilities.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['nvme'])
pci_dev_list.extend(tmp_pci_list) pci_dev_list.extend(tmp_pci_list)
tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['usb']) tmp_pci_list = acrn_config_utilities.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['usb'])
pci_dev_list.extend(tmp_pci_list) pci_dev_list.extend(tmp_pci_list)
pci_dev_list.insert(0, '') pci_dev_list.insert(0, '')
@ -678,7 +678,7 @@ def check_vuart(v0_vuart, v1_vuart):
target_id_keys = list(vm_target_id_dic.keys()) target_id_keys = list(vm_target_id_dic.keys())
i = 0 i = 0
for vm_i,t_vm_id in vm_target_id_dic.items(): for vm_i,t_vm_id in vm_target_id_dic.items():
if t_vm_id.isnumeric() and int(t_vm_id) not in common.LOAD_ORDER.keys(): if t_vm_id.isnumeric() and int(t_vm_id) not in acrn_config_utilities.LOAD_ORDER.keys():
key = "vm:id={},legacy_vuart:id=1,target_vm_id".format(vm_i) key = "vm:id={},legacy_vuart:id=1,target_vm_id".format(vm_i)
ERR_LIST[key] = "target_vm_id which specified does not exist" ERR_LIST[key] = "target_vm_id which specified does not exist"
@ -760,8 +760,8 @@ def check_vuart_id_count(vm_pci_vuarts, legacy_vuart0, legacy_vuart1):
if legacy_vuart_base1 != INVALID_COM_BASE: if legacy_vuart_base1 != INVALID_COM_BASE:
vuart_cnt += 1 vuart_cnt += 1
if vuart_cnt > common.MAX_VUART_NUM: if vuart_cnt > acrn_config_utilities.MAX_VUART_NUM:
raise XmlError("enables more than {} vuarts, total number: {}".format(common.MAX_VUART_NUM, vuart_cnt)) raise XmlError("enables more than {} vuarts, total number: {}".format(acrn_config_utilities.MAX_VUART_NUM, vuart_cnt))
def check_against_coexistence(vm_pci_vuarts, vm_legacy_vuart, legacy_vuart_idx): def check_against_coexistence(vm_pci_vuarts, vm_legacy_vuart, legacy_vuart_idx):
@ -808,10 +808,10 @@ def get_target_vm_id(vuart, vm_id):
"target_vm_id should be present and numeric: {!r}".format( "target_vm_id should be present and numeric: {!r}".format(
target_vm_id_str)) target_vm_id_str))
if target_vm_id not in common.LOAD_ORDER: if target_vm_id not in acrn_config_utilities.LOAD_ORDER:
raise XmlError( raise XmlError(
'invalid target_vm_id: target_vm_id={!r}, vm_ids={}'.format( 'invalid target_vm_id: target_vm_id={!r}, vm_ids={}'.format(
target_vm_id, common.LOAD_ORDER.keys())) target_vm_id, acrn_config_utilities.LOAD_ORDER.keys()))
if target_vm_id == vm_id: if target_vm_id == vm_id:
raise XmlError( raise XmlError(
@ -950,7 +950,7 @@ def is_target_vm_available(target_vm_id, vm_visited, legacy_vuart1_visited):
raise TypeError('legacy_vuart1_visited should be a dict: {}, {!r}' \ raise TypeError('legacy_vuart1_visited should be a dict: {}, {!r}' \
.format(type(legacy_vuart1_visited), legacy_vuart1_visited)) .format(type(legacy_vuart1_visited), legacy_vuart1_visited))
if target_vm_id not in common.LOAD_ORDER: if target_vm_id not in acrn_config_utilities.LOAD_ORDER:
raise TargetError("target vm {} is not present".format(target_vm_id)) raise TargetError("target vm {} is not present".format(target_vm_id))
if target_vm_id in vm_visited: if target_vm_id in vm_visited:
pass pass
@ -1151,7 +1151,7 @@ def check_p2sb(enable_p2sb):
ERR_LIST[key] = "Can only specify p2sb passthru for VM0" ERR_LIST[key] = "Can only specify p2sb passthru for VM0"
return return
if p2sb and not VM_DB[common.LOAD_ORDER[0]]['load_type'] == "PRE_LAUNCHED_VM": if p2sb and not VM_DB[acrn_config_utilities.LOAD_ORDER[0]]['load_type'] == "PRE_LAUNCHED_VM":
ERR_LIST["vm:id=0,p2sb"] = "p2sb passthru can only be enabled for Pre-launched VM" ERR_LIST["vm:id=0,p2sb"] = "p2sb passthru can only be enabled for Pre-launched VM"
return return
@ -1176,7 +1176,7 @@ def check_pt_intx(phys_gsi, virt_gsi):
ERR_LIST["pt_intx"] = "only board ehl-crb-b/generic_board is supported" ERR_LIST["pt_intx"] = "only board ehl-crb-b/generic_board is supported"
return return
if not VM_DB[common.LOAD_ORDER[0]]['load_type'] == "PRE_LAUNCHED_VM": if not VM_DB[acrn_config_utilities.LOAD_ORDER[0]]['load_type'] == "PRE_LAUNCHED_VM":
ERR_LIST["pt_intx"] = "pt_intx can only be specified for pre-launched VM" ERR_LIST["pt_intx"] = "pt_intx can only be specified for pre-launched VM"
return return
@ -1213,7 +1213,7 @@ def get_valid_ttys_for_sos_vuart(ttys_n):
""" """
vuart0_valid = [] vuart0_valid = []
vuart1_valid = ['ttyS0', 'ttyS1', 'ttyS2', 'ttyS3'] vuart1_valid = ['ttyS0', 'ttyS1', 'ttyS2', 'ttyS3']
ttys_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>") ttys_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
if ttys_lines: if ttys_lines:
vuart0_valid.clear() vuart0_valid.clear()
for tty_line in ttys_lines: for tty_line in ttys_lines:
@ -1231,7 +1231,7 @@ def get_valid_ttys_for_sos_vuart(ttys_n):
vuart1_valid.remove(tty) vuart1_valid.remove(tty)
if not vuart1_valid: if not vuart1_valid:
common.print_yel("ttyS are fully used. ttyS0 is used for hv_console, ttyS1 is used for vuart1!", warn=True) acrn_config_utilities.print_yel("ttyS are fully used. ttyS0 is used for hv_console, ttyS1 is used for vuart1!", warn=True)
vuart1_valid = ['ttyS0', 'ttyS1', 'ttyS2', 'ttyS3'] vuart1_valid = ['ttyS0', 'ttyS1', 'ttyS2', 'ttyS3']
if ttys_n in vuart1_valid: if ttys_n in vuart1_valid:
vuart1_valid.remove(ttys_n) vuart1_valid.remove(ttys_n)

View File

@ -13,7 +13,7 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '
from scenario_item import HwInfo, VmInfo from scenario_item import HwInfo, VmInfo
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib import scenario_cfg_lib
import common import acrn_config_utilities
import hv_cfg_lib import hv_cfg_lib
import board_defconfig import board_defconfig
from hv_item import HvInfo from hv_item import HvInfo
@ -24,7 +24,7 @@ try:
except ImportError: except ImportError:
pass pass
ACRN_PATH = common.SOURCE_ROOT_DIR ACRN_PATH = acrn_config_utilities.SOURCE_ROOT_DIR
ACRN_CONFIG_DEF = ACRN_PATH + 'misc/config_tools/data/' ACRN_CONFIG_DEF = ACRN_PATH + 'misc/config_tools/data/'
GEN_FILE = ["vm_configurations.h", "vm_configurations.c", "pci_dev.c", ".config", "ivshmem_cfg.h", "pt_intx.c"] GEN_FILE = ["vm_configurations.h", "vm_configurations.c", "pci_dev.c", ".config", "ivshmem_cfg.h", "pt_intx.c"]
@ -42,13 +42,13 @@ def get_scenario_item_values(board_info, scenario_info):
hv_info = HvInfo(scenario_info) hv_info = HvInfo(scenario_info)
# get vm count # get vm count
common.BOARD_INFO_FILE = board_info acrn_config_utilities.BOARD_INFO_FILE = board_info
common.SCENARIO_INFO_FILE = scenario_info acrn_config_utilities.SCENARIO_INFO_FILE = scenario_info
common.get_vm_num(scenario_info) acrn_config_utilities.get_vm_num(scenario_info)
common.get_load_order() acrn_config_utilities.get_load_order()
# per scenario # per scenario
guest_flags = copy.deepcopy(common.GUEST_FLAG) guest_flags = copy.deepcopy(acrn_config_utilities.GUEST_FLAG)
guest_flags.remove('0UL') guest_flags.remove('0UL')
scenario_item_values['vm,vm_type'] = scenario_cfg_lib.LOAD_VM_TYPE scenario_item_values['vm,vm_type'] = scenario_cfg_lib.LOAD_VM_TYPE
scenario_item_values["vm,cpu_affinity"] = hw_info.get_processor_val() scenario_item_values["vm,cpu_affinity"] = hw_info.get_processor_val()
@ -100,7 +100,7 @@ def validate_scenario_schema(scenario_info):
XMLSchema does not process XInclude. XMLSchema does not process XInclude.
Use lxml to expand the schema which is feed to XMLSchema as a string. Use lxml to expand the schema which is feed to XMLSchema as a string.
""" """
xsd_doc = etree.parse(common.SCENARIO_SCHEMA_FILE) xsd_doc = etree.parse(acrn_config_utilities.SCENARIO_SCHEMA_FILE)
xsd_doc.xinclude() xsd_doc.xinclude()
my_schema = xmlschema.XMLSchema11(etree.tostring(xsd_doc, encoding="unicode")) my_schema = xmlschema.XMLSchema11(etree.tostring(xsd_doc, encoding="unicode"))
@ -124,7 +124,7 @@ def validate_scenario_schema(scenario_info):
scenario_cfg_lib.ERR_LIST[key] = element + reason scenario_cfg_lib.ERR_LIST[key] = element + reason
def apply_data_checks(board_info, scenario_info): def apply_data_checks(board_info, scenario_info):
xsd_doc = etree.parse(common.DATACHECK_SCHEMA_FILE) xsd_doc = etree.parse(acrn_config_utilities.DATACHECK_SCHEMA_FILE)
xsd_doc.xinclude() xsd_doc.xinclude()
datachecks_schema = xmlschema.XMLSchema11(etree.tostring(xsd_doc, encoding="unicode")) datachecks_schema = xmlschema.XMLSchema11(etree.tostring(xsd_doc, encoding="unicode"))
@ -160,8 +160,8 @@ def validate_scenario_setting(board_info, scenario_info):
:param scenario_info: scenario file :param scenario_info: scenario file
:return: return a dictionary that contains errors :return: return a dictionary that contains errors
""" """
common.BOARD_INFO_FILE = board_info acrn_config_utilities.BOARD_INFO_FILE = board_info
common.SCENARIO_INFO_FILE = scenario_info acrn_config_utilities.SCENARIO_INFO_FILE = scenario_info
hv_info = HvInfo(scenario_info) hv_info = HvInfo(scenario_info)
hv_info.get_info() hv_info.get_info()
@ -187,31 +187,31 @@ def main(args):
""" """
err_dic = {} err_dic = {}
(err_dic, params) = common.get_param(args) (err_dic, params) = acrn_config_utilities.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
# check env # check env
err_dic = common.prepare() err_dic = acrn_config_utilities.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
common.BOARD_INFO_FILE = params['--board'] acrn_config_utilities.BOARD_INFO_FILE = params['--board']
common.SCENARIO_INFO_FILE = params['--scenario'] acrn_config_utilities.SCENARIO_INFO_FILE = params['--scenario']
common.get_vm_num(params['--scenario']) acrn_config_utilities.get_vm_num(params['--scenario'])
common.get_load_order() acrn_config_utilities.get_load_order()
# get board name # get board name
(err_dic, board_name) = common.get_board_name() (err_dic, board_name) = acrn_config_utilities.get_board_name()
# get scenario name # get scenario name
(err_dic, scenario) = common.get_scenario_name() (err_dic, scenario) = acrn_config_utilities.get_scenario_name()
if err_dic: if err_dic:
return err_dic return err_dic
if common.VM_COUNT > common.MAX_VM_NUM: if acrn_config_utilities.VM_COUNT > acrn_config_utilities.MAX_VM_NUM:
err_dic['vm count'] = "Number of VMs in scenario xml file should be no greater than hv/CAPACITIES/MAX_VM_NUM ! " \ err_dic['vm count'] = "Number of VMs in scenario xml file should be no greater than hv/CAPACITIES/MAX_VM_NUM ! " \
"Now this value is {}.".format(common.MAX_VM_NUM) "Now this value is {}.".format(acrn_config_utilities.MAX_VM_NUM)
return err_dic return err_dic
if params['--out']: if params['--out']:
@ -223,8 +223,8 @@ def main(args):
scen_output = ACRN_CONFIG_DEF + "/" + scenario + "/" scen_output = ACRN_CONFIG_DEF + "/" + scenario + "/"
scen_board = scen_output + "/" scen_board = scen_output + "/"
common.mkdir(scen_board) acrn_config_utilities.mkdir(scen_board)
common.mkdir(scen_output) acrn_config_utilities.mkdir(scen_output)
vm_config_h = scen_output + GEN_FILE[0] vm_config_h = scen_output + GEN_FILE[0]
vm_config_c = scen_output + GEN_FILE[1] vm_config_c = scen_output + GEN_FILE[1]
@ -237,7 +237,7 @@ def main(args):
get_scenario_item_values(params['--board'], params['--scenario']) get_scenario_item_values(params['--board'], params['--scenario'])
(err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario']) (err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario'])
if err_dic: if err_dic:
common.print_red("Scenario xml file validation failed:", err=True) acrn_config_utilities.print_red("Scenario xml file validation failed:", err=True)
return err_dic return err_dic
# generate board defconfig # generate board defconfig
@ -262,7 +262,7 @@ def ui_entry_api(board_info, scenario_info, out=''):
arg_list = ['scenario_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out] arg_list = ['scenario_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out]
err_dic = common.prepare() err_dic = acrn_config_utilities.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
@ -277,5 +277,5 @@ if __name__ == '__main__':
err_dic = main(ARGS) err_dic = main(ARGS)
if err_dic: if err_dic:
for err_k, err_v in err_dic.items(): for err_k, err_v in err_dic.items():
common.print_red("{}: {}".format(err_k, err_v), err=True) acrn_config_utilities.print_red("{}: {}".format(err_k, err_v), err=True)
sys.exit(1 if err_dic else 0) sys.exit(1 if err_dic else 0)

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import common import acrn_config_utilities
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib import scenario_cfg_lib
@ -30,7 +30,7 @@ class HwInfo:
Get root devices from board info Get root devices from board info
:return: root devices list :return: root devices list
""" """
(self.root_dev_val, num) = common.get_rootfs(self.board_info) (self.root_dev_val, num) = acrn_config_utilities.get_rootfs(self.board_info)
return self.root_dev_val return self.root_dev_val
def get_ttys_val(self): def get_ttys_val(self):
@ -86,18 +86,18 @@ class CfgOsKern:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.kern_name = common.get_leaf_tag_map(self.scenario_info, "os_config", "name") self.kern_name = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "os_config", "name")
self.kern_type = common.get_leaf_tag_map( self.kern_type = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "kern_type") self.scenario_info, "os_config", "kern_type")
self.kern_mod = common.get_leaf_tag_map( self.kern_mod = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "kern_mod") self.scenario_info, "os_config", "kern_mod")
self.kern_args = common.get_leaf_tag_map( self.kern_args = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "bootargs") self.scenario_info, "os_config", "bootargs")
self.kern_load_addr = common.get_leaf_tag_map( self.kern_load_addr = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "kern_load_addr") self.scenario_info, "os_config", "kern_load_addr")
self.kern_entry_addr = common.get_leaf_tag_map( self.kern_entry_addr = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "kern_entry_addr") self.scenario_info, "os_config", "kern_entry_addr")
self.ramdisk_mod = common.get_leaf_tag_map( self.ramdisk_mod = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "os_config", "ramdisk_mod") self.scenario_info, "os_config", "ramdisk_mod")
def check_item(self): def check_item(self):
@ -130,9 +130,9 @@ class VuartInfo:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.v0_vuart = common.get_vuart_info_id(self.scenario_info, 0) self.v0_vuart = acrn_config_utilities.get_vuart_info_id(self.scenario_info, 0)
self.v1_vuart = common.get_vuart_info_id(self.scenario_info, 1) self.v1_vuart = acrn_config_utilities.get_vuart_info_id(self.scenario_info, 1)
self.pci_vuarts = common.get_vuart_info(self.scenario_info) self.pci_vuarts = acrn_config_utilities.get_vuart_info(self.scenario_info)
def check_item(self): def check_item(self):
""" """
@ -157,13 +157,13 @@ class MemInfo:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.mem_start_hpa = common.get_leaf_tag_map( self.mem_start_hpa = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "memory", "start_hpa") self.scenario_info, "memory", "start_hpa")
self.mem_size = common.get_leaf_tag_map( self.mem_size = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "memory", "size") self.scenario_info, "memory", "size")
self.mem_start_hpa2 = common.get_leaf_tag_map( self.mem_start_hpa2 = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "memory", "start_hpa2") self.scenario_info, "memory", "start_hpa2")
self.mem_size_hpa2 = common.get_leaf_tag_map( self.mem_size_hpa2 = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "memory", "size_hpa2") self.scenario_info, "memory", "size_hpa2")
def check_item(self): def check_item(self):
@ -197,7 +197,7 @@ class CfgPci:
Get pci devices items Get pci devices items
:return: None :return: None
""" """
pci_items = common.get_leaf_tag_map(self.scenario_info, "pci_devs", "pci_dev") pci_items = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "pci_devs", "pci_dev")
self.pci_devs = scenario_cfg_lib.get_pt_pci_devs(pci_items) self.pci_devs = scenario_cfg_lib.get_pt_pci_devs(pci_items)
@ -224,8 +224,8 @@ class EpcSection:
self.scenario_info = scenario_info self.scenario_info = scenario_info
def get_info(self): def get_info(self):
self.base = common.get_leaf_tag_map(self.scenario_info, "epc_section", "base") self.base = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "epc_section", "base")
self.size = common.get_leaf_tag_map(self.scenario_info, "epc_section", "size") self.size = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "epc_section", "size")
class ShareMem: class ShareMem:
@ -245,7 +245,7 @@ class ShareMem:
:return: :return:
""" """
self.raw_shmem_regions = ivshmem_regions self.raw_shmem_regions = ivshmem_regions
self.shmem_enabled = common.get_hv_item_tag(self.scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") self.shmem_enabled = acrn_config_utilities.get_hv_item_tag(self.scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
self.shmem_regions = scenario_cfg_lib.get_shmem_regions(ivshmem_regions) self.shmem_regions = scenario_cfg_lib.get_shmem_regions(ivshmem_regions)
self.shmem_num = scenario_cfg_lib.get_shmem_num(self.shmem_regions) self.shmem_num = scenario_cfg_lib.get_shmem_num(self.shmem_regions)
@ -255,7 +255,7 @@ class ShareMem:
:return: :return:
''' '''
if self.shmem_enabled == 'y': if self.shmem_enabled == 'y':
vm_type_info = common.get_leaf_tag_map(self.scenario_info, "vm_type") vm_type_info = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "vm_type")
scenario_cfg_lib.share_mem_check(self.shmem_regions, self.raw_shmem_regions, vm_type_info, scenario_cfg_lib.share_mem_check(self.shmem_regions, self.raw_shmem_regions, vm_type_info,
"FEATURES", "IVSHMEM", "IVSHMEM_REGION") "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
@ -285,8 +285,8 @@ class MmioResourcesInfo:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.p2sb = common.get_leaf_tag_map_bool(self.scenario_info, "mmio_resources", "p2sb") self.p2sb = acrn_config_utilities.get_leaf_tag_map_bool(self.scenario_info, "mmio_resources", "p2sb")
self.tpm2 = common.get_leaf_tag_map_bool(self.scenario_info, "mmio_resources", "TPM2") self.tpm2 = acrn_config_utilities.get_leaf_tag_map_bool(self.scenario_info, "mmio_resources", "TPM2")
def check_item(self): def check_item(self):
""" """
@ -309,7 +309,7 @@ class PtIntxInfo:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.phys_gsi, self.virt_gsi = common.get_pt_intx_table(self.scenario_info) self.phys_gsi, self.virt_gsi = acrn_config_utilities.get_pt_intx_table(self.scenario_info)
def check_item(self): def check_item(self):
""" """
@ -331,7 +331,7 @@ class VmInfo:
def __init__(self, board_file, scenario_file): def __init__(self, board_file, scenario_file):
self.board_info = board_file self.board_info = board_file
self.scenario_info = scenario_file self.scenario_info = scenario_file
common.get_vm_num(self.scenario_info) acrn_config_utilities.get_vm_num(self.scenario_info)
self.epc_section = EpcSection(self.scenario_info) self.epc_section = EpcSection(self.scenario_info)
self.mem_info = MemInfo(self.scenario_info) self.mem_info = MemInfo(self.scenario_info)
@ -349,13 +349,13 @@ class VmInfo:
Get all items which belong to this class Get all items which belong to this class
:return: None :return: None
""" """
self.name = common.get_leaf_tag_map(self.scenario_info, "name") self.name = acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "name")
self.load_vm= common.get_leaf_tag_map(self.scenario_info, "vm_type") self.load_vm= acrn_config_utilities.get_leaf_tag_map(self.scenario_info, "vm_type")
self.guest_flags = common.get_leaf_tag_map( self.guest_flags = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "guest_flags", "guest_flag") self.scenario_info, "guest_flags", "guest_flag")
self.cpus_per_vm = common.get_leaf_tag_map( self.cpus_per_vm = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "cpu_affinity", "pcpu_id") self.scenario_info, "cpu_affinity", "pcpu_id")
self.clos_per_vm = common.get_leaf_tag_map( self.clos_per_vm = acrn_config_utilities.get_leaf_tag_map(
self.scenario_info, "clos", "vcpu_clos") self.scenario_info, "clos", "vcpu_clos")
self.epc_section.get_info() self.epc_section.get_info()

View File

@ -9,7 +9,8 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '
import argparse import argparse
import lxml.etree import lxml.etree
import common import acrn_config_utilities
from acrn_config_utilities import get_node
#vuart devices name is configured to start from /dev/ttyS8 #vuart devices name is configured to start from /dev/ttyS8
START_VUART_DEV_NAME_NO = 8 START_VUART_DEV_NAME_NO = 8
@ -19,19 +20,19 @@ UART_IRQ_BAUD = " irq 0 uart 16550A baud_base 115200"
def find_non_standard_uart(vm, scenario_etree, allocation_etree): def find_non_standard_uart(vm, scenario_etree, allocation_etree):
uart_list = [] uart_list = []
vmname = common.get_node("./name/text()", vm) vmname = get_node("./name/text()", vm)
connection_list0 = scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name = '{vmname}']") connection_list0 = scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name = '{vmname}']")
connection_list1 = allocation_etree.xpath(f"//vuart_connection[endpoint/vm_name = '{vmname}']") connection_list1 = allocation_etree.xpath(f"//vuart_connection[endpoint/vm_name = '{vmname}']")
for connection in (connection_list0 + connection_list1): for connection in (connection_list0 + connection_list1):
type = common.get_node(f"./type/text()", connection) type = get_node(f"./type/text()", connection)
if (type != "legacy") : if (type != "legacy") :
continue continue
port = common.get_node(f".//endpoint[vm_name = '{vmname}']/io_port/text()", connection) port = get_node(f".//endpoint[vm_name = '{vmname}']/io_port/text()", connection)
if port not in stadard_uart_port: if port not in stadard_uart_port:
target_vm_name = common.get_node(f".//endpoint[vm_name != '{vmname}']/vm_name/text()", connection) target_vm_name = get_node(f".//endpoint[vm_name != '{vmname}']/vm_name/text()", connection)
target_vm_id = common.get_node(f"//vm[name = '{target_vm_name}']/@id", scenario_etree) target_vm_id = get_node(f"//vm[name = '{target_vm_name}']/@id", scenario_etree)
uart_list.append({"io_port" : port, "target_vm_id" : target_vm_id}) uart_list.append({"io_port" : port, "target_vm_id" : target_vm_id})
return uart_list return uart_list
@ -47,7 +48,7 @@ def main(args):
vm_list = scenario_etree.xpath("//vm[load_order = 'SERVICE_VM']") vm_list = scenario_etree.xpath("//vm[load_order = 'SERVICE_VM']")
for vm in vm_list: for vm in vm_list:
vuart_list = find_non_standard_uart(vm, scenario_etree, allocation_etree) vuart_list = find_non_standard_uart(vm, scenario_etree, allocation_etree)
vmname = common.get_node("./name/text()", vm) vmname = get_node("./name/text()", vm)
if len(vuart_list) != 0: if len(vuart_list) != 0:
with open(args.out, "w+") as config_f: with open(args.out, "w+") as config_f:
for uart_start_num, vuart in enumerate(vuart_list, start=START_VUART_DEV_NAME_NO): for uart_start_num, vuart in enumerate(vuart_list, start=START_VUART_DEV_NAME_NO):

View File

@ -7,7 +7,8 @@
import sys, os, re import sys, os, re
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, lib.error, lib.lib import acrn_config_utilities, lib.error, lib.lib
from acrn_config_utilities import get_node
# Constants for device name prefix # Constants for device name prefix
IVSHMEM = "IVSHMEM" IVSHMEM = "IVSHMEM"
@ -78,7 +79,7 @@ def get_devs_bdf_native(board_etree):
dev_list = [] dev_list = []
for node in nodes: for node in nodes:
address = node.get('address') address = node.get('address')
bus = int(common.get_node("../@address", node), 16) bus = int(get_node("../@address", node), 16)
dev = int(address, 16) >> 16 dev = int(address, 16) >> 16
func = int(address, 16) & 0xffff func = int(address, 16) & 0xffff
@ -108,18 +109,18 @@ def create_device_node(allocation_etree, vm_id, devdict):
for dev in devdict: for dev in devdict:
dev_name = dev dev_name = dev
bdf = devdict.get(dev) bdf = devdict.get(dev)
vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if vm_node is None: if vm_node is None:
vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
dev_node = common.get_node(f"./device[@name = '{dev_name}']", vm_node) dev_node = get_node(f"./device[@name = '{dev_name}']", vm_node)
if dev_node is None: if dev_node is None:
dev_node = common.append_node("./device", None, vm_node, name = dev_name) dev_node = acrn_config_utilities.append_node("./device", None, vm_node, name = dev_name)
if common.get_node(f"./bus", dev_node) is None: if get_node(f"./bus", dev_node) is None:
common.append_node(f"./bus", f"{bdf.bus:#04x}", dev_node) acrn_config_utilities.append_node(f"./bus", f"{bdf.bus:#04x}", dev_node)
if common.get_node(f"./dev", dev_node) is None: if get_node(f"./dev", dev_node) is None:
common.append_node(f"./dev", f"{bdf.dev:#04x}", dev_node) acrn_config_utilities.append_node(f"./dev", f"{bdf.dev:#04x}", dev_node)
if common.get_node(f"./func", dev_node) is None: if get_node(f"./func", dev_node) is None:
common.append_node(f"./func", f"{bdf.func:#04x}", dev_node) acrn_config_utilities.append_node(f"./func", f"{bdf.func:#04x}", dev_node)
def create_igd_sbdf(board_etree, allocation_etree): def create_igd_sbdf(board_etree, allocation_etree):
""" """
@ -127,14 +128,14 @@ def create_igd_sbdf(board_etree, allocation_etree):
doesn't exist. doesn't exist.
""" """
bus = "0x0" bus = "0x0"
device_node = common.get_node(f"//bus[@type='pci' and @address='{bus}']/device[@address='0x20000' and vendor='0x8086' and class='0x030000']", board_etree) device_node = get_node(f"//bus[@type='pci' and @address='{bus}']/device[@address='0x20000' and vendor='0x8086' and class='0x030000']", board_etree)
if device_node is None: if device_node is None:
common.append_node("/acrn-config/hv/MISC_CFG/IGD_SBDF", '0xFFFF', allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MISC_CFG/IGD_SBDF", '0xFFFF', allocation_etree)
else: else:
address = device_node.get('address') address = device_node.get('address')
dev = int(address, 16) >> 16 dev = int(address, 16) >> 16
func = int(address, 16) & 0xffff func = int(address, 16) & 0xffff
common.append_node("/acrn-config/hv/MISC_CFG/IGD_SBDF", f"{(int(bus, 16) << 8) | (dev << 3) | func:#06x}", allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MISC_CFG/IGD_SBDF", f"{(int(bus, 16) << 8) | (dev << 3) | func:#06x}", allocation_etree)
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
create_igd_sbdf(board_etree, allocation_etree) create_igd_sbdf(board_etree, allocation_etree)
@ -143,7 +144,7 @@ def fn(board_etree, scenario_etree, allocation_etree):
vm_id = vm_node.get('id') vm_id = vm_node.get('id')
devdict = {} devdict = {}
used = [] used = []
load_order = common.get_node("./load_order/text()", vm_node) load_order = get_node("./load_order/text()", vm_node)
if load_order is not None and lib.lib.is_post_launched_vm(load_order): if load_order is not None and lib.lib.is_post_launched_vm(load_order):
continue continue
@ -151,7 +152,7 @@ def fn(board_etree, scenario_etree, allocation_etree):
native_used = get_devs_bdf_native(board_etree) native_used = get_devs_bdf_native(board_etree)
passthrough_used = get_devs_bdf_passthrough(scenario_etree) passthrough_used = get_devs_bdf_passthrough(scenario_etree)
used = [bdf for bdf in native_used if bdf not in passthrough_used] used = [bdf for bdf in native_used if bdf not in passthrough_used]
if common.get_node("//@board", scenario_etree) == "tgl-rvp": if get_node("//@board", scenario_etree) == "tgl-rvp":
used.append(lib.lib.BusDevFunc(bus = 0, dev = 1, func = 0)) used.append(lib.lib.BusDevFunc(bus = 0, dev = 1, func = 0))
insert_vuart_to_dev_dict(vm_node, devdict, used) insert_vuart_to_dev_dict(vm_node, devdict, used)

View File

@ -5,31 +5,32 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import logging import logging
import common import acrn_config_utilities
from acrn_config_utilities import get_node
def powerof2_roundup(value): def powerof2_roundup(value):
return 0 if value == 0 else (1 << (value - 1).bit_length()) return 0 if value == 0 else (1 << (value - 1).bit_length())
# Make sure all PT IRQs work w/ interrupt remapping or post interrupt # Make sure all PT IRQs work w/ interrupt remapping or post interrupt
def create_max_ir_entries(scenario_etree, allocation_etree): def create_max_ir_entries(scenario_etree, allocation_etree):
pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree) pt_irq_entries = get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree)
if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256): if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
ir_entries = powerof2_roundup(int(pt_irq_entries)) ir_entries = powerof2_roundup(int(pt_irq_entries))
else: else:
ir_entries = 256 ir_entries = 256
common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree)
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address") pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
calc_pci_bus_nums = (max(map(lambda x: int(x, 16), pci_bus_nums)) + 1) calc_pci_bus_nums = (max(map(lambda x: int(x, 16), pci_bus_nums)) + 1)
user_def_pci_bus_nums = common.get_node(f"//MAX_PCI_BUS_NUM/text()", scenario_etree) user_def_pci_bus_nums = get_node(f"//MAX_PCI_BUS_NUM/text()", scenario_etree)
if user_def_pci_bus_nums == '0': if user_def_pci_bus_nums == '0':
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(calc_pci_bus_nums), allocation_etree) acrn_config_utilities.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(calc_pci_bus_nums), allocation_etree)
else: else:
if calc_pci_bus_nums > int(user_def_pci_bus_nums): if calc_pci_bus_nums > int(user_def_pci_bus_nums):
logging.error(f"MAX_PCI_BUS_NUM should be greater than {calc_pci_bus_nums}") logging.error(f"MAX_PCI_BUS_NUM should be greater than {calc_pci_bus_nums}")
sys.exit(1) sys.exit(1)
else: else:
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(int(user_def_pci_bus_nums)), allocation_etree) acrn_config_utilities.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(int(user_def_pci_bus_nums)), allocation_etree)
create_max_ir_entries(scenario_etree, allocation_etree) create_max_ir_entries(scenario_etree, allocation_etree)

View File

@ -7,21 +7,22 @@
import sys, os import sys, os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common import acrn_config_utilities
import rdt import rdt
import re import re
from collections import defaultdict from collections import defaultdict
from itertools import combinations from itertools import combinations
from collections import namedtuple from collections import namedtuple
from acrn_config_utilities import get_node
def create_clos_node(scenario_etree, vm_id, index_list): def create_clos_node(scenario_etree, vm_id, index_list):
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", scenario_etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", scenario_etree)
if allocation_vm_node is None: if allocation_vm_node is None:
allocation_vm_node = common.append_node("/acrn-config/vm", None, scenario_etree, id = vm_id) allocation_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, scenario_etree, id = vm_id)
if common.get_node("./clos", allocation_vm_node) is None: if get_node("./clos", allocation_vm_node) is None:
clos_node = common.append_node("./clos", None, allocation_vm_node) clos_node = acrn_config_utilities.append_node("./clos", None, allocation_vm_node)
for index in index_list: for index in index_list:
common.append_node(f"./vcpu_clos", str(index), clos_node) acrn_config_utilities.append_node(f"./vcpu_clos", str(index), clos_node)
def get_clos_id(rdt_list, policy_owner): def get_clos_id(rdt_list, policy_owner):
for index,rdt in enumerate(rdt_list): for index,rdt in enumerate(rdt_list):
@ -32,7 +33,7 @@ def get_clos_id(rdt_list, policy_owner):
def alloc_clos_index(board_etree, scenario_etree, allocation_etree, mask_list): def alloc_clos_index(board_etree, scenario_etree, allocation_etree, mask_list):
vm_node_list = scenario_etree.xpath("//vm") vm_node_list = scenario_etree.xpath("//vm")
for vm_node in vm_node_list: for vm_node in vm_node_list:
vm_name = common.get_node("./name/text()", vm_node) vm_name = get_node("./name/text()", vm_node)
vcpu_list = scenario_etree.xpath(f"//POLICY[VM = '{vm_name}']/VCPU/text()") vcpu_list = scenario_etree.xpath(f"//POLICY[VM = '{vm_name}']/VCPU/text()")
index_list = [] index_list = []
for vcpu in sorted([int(x) for x in set(vcpu_list)]): for vcpu in sorted([int(x) for x in set(vcpu_list)]):
@ -41,16 +42,16 @@ def alloc_clos_index(board_etree, scenario_etree, allocation_etree, mask_list):
else: else:
index = get_clos_id(mask_list, rdt.policy_owner(vm_name, vcpu, "Unified")) index = get_clos_id(mask_list, rdt.policy_owner(vm_name, vcpu, "Unified"))
index_list.append(index) index_list.append(index)
create_clos_node(allocation_etree, common.get_node("./@id", vm_node), index_list) create_clos_node(allocation_etree, get_node("./@id", vm_node), index_list)
def create_mask_list_node(board_etree, scenario_etree, allocation_etree, rdt_policy_list): def create_mask_list_node(board_etree, scenario_etree, allocation_etree, rdt_policy_list):
allocation_hv_node = common.get_node(f"//hv", allocation_etree) allocation_hv_node = get_node(f"//hv", allocation_etree)
if allocation_hv_node is None: if allocation_hv_node is None:
allocation_hv_node = common.append_node(f"/acrn-config/hv", None, allocation_etree) allocation_hv_node = acrn_config_utilities.append_node(f"/acrn-config/hv", None, allocation_etree)
if common.get_node("./clos_mask[@id = l3]", allocation_hv_node) is None: if get_node("./clos_mask[@id = l3]", allocation_hv_node) is None:
clos_mask = common.append_node("./clos_mask", None, allocation_hv_node, id="l3") clos_mask = acrn_config_utilities.append_node("./clos_mask", None, allocation_hv_node, id="l3")
length = common.get_node(f"//cache[@level='3']/capability/capacity_mask_length/text()", board_etree) length = get_node(f"//cache[@level='3']/capability/capacity_mask_length/text()", board_etree)
if length is not None: if length is not None:
default_l3_value = hex((1 << int(length)) - 1) default_l3_value = hex((1 << int(length)) - 1)
else: else:
@ -60,22 +61,22 @@ def create_mask_list_node(board_etree, scenario_etree, allocation_etree, rdt_pol
value = str(rdt_policy_list[i].l3policy.get_clos_mask()) value = str(rdt_policy_list[i].l3policy.get_clos_mask())
else: else:
value = default_l3_value value = default_l3_value
common.append_node(f"./clos", value, clos_mask) acrn_config_utilities.append_node(f"./clos", value, clos_mask)
for index,cache2 in enumerate(rdt.L2Policy.cache2_id_list): for index,cache2 in enumerate(rdt.L2Policy.cache2_id_list):
length = common.get_node(f"//cache[@level='2' and @id = '{cache2}']/capability/capacity_mask_length/text()", board_etree) length = get_node(f"//cache[@level='2' and @id = '{cache2}']/capability/capacity_mask_length/text()", board_etree)
if length is not None: if length is not None:
default_l2_value = hex((1 << int(length)) - 1) default_l2_value = hex((1 << int(length)) - 1)
else: else:
default_l2_value = "0xffff" default_l2_value = "0xffff"
if common.get_node("./clos_mask[@id = '{cache2}']", allocation_hv_node) is None: if get_node("./clos_mask[@id = '{cache2}']", allocation_hv_node) is None:
clos_mask = common.append_node("./clos_mask", None, allocation_hv_node, id=cache2) clos_mask = acrn_config_utilities.append_node("./clos_mask", None, allocation_hv_node, id=cache2)
for i in range(0, len(rdt_policy_list)): for i in range(0, len(rdt_policy_list)):
if rdt_policy_list[i].l2policy.get_clos_mask(index) is not None: if rdt_policy_list[i].l2policy.get_clos_mask(index) is not None:
value = str(rdt_policy_list[i].l2policy.get_clos_mask(index)) value = str(rdt_policy_list[i].l2policy.get_clos_mask(index))
else: else:
value = default_l2_value value = default_l2_value
common.append_node(f"./clos", value, clos_mask) acrn_config_utilities.append_node(f"./clos", value, clos_mask)
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
policy_list = rdt.get_policy_list(scenario_etree) policy_list = rdt.get_policy_list(scenario_etree)

View File

@ -7,13 +7,14 @@
import sys, os import sys, os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, board_cfg_lib import acrn_config_utilities, board_cfg_lib
from acrn_config_utilities import get_node
def sos_cpu_affinity(etree): def sos_cpu_affinity(etree):
if common.get_node("//vm[load_order = 'SERVICE_VM']", etree) is None: if get_node("//vm[load_order = 'SERVICE_VM']", etree) is None:
return None return None
if common.get_node("//vm[load_order = 'SERVICE_VM' and count(cpu_affinity//pcpu_id)]", etree) is not None: if get_node("//vm[load_order = 'SERVICE_VM' and count(cpu_affinity//pcpu_id)]", etree) is not None:
return None return None
sos_extend_all_cpus = board_cfg_lib.get_processor_info() sos_extend_all_cpus = board_cfg_lib.get_processor_info()
@ -25,12 +26,12 @@ def sos_cpu_affinity(etree):
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
cpus_for_sos = sos_cpu_affinity(scenario_etree) cpus_for_sos = sos_cpu_affinity(scenario_etree)
if cpus_for_sos: if cpus_for_sos:
if common.get_node("//vm[load_order = 'SERVICE_VM']", scenario_etree) is not None: if get_node("//vm[load_order = 'SERVICE_VM']", scenario_etree) is not None:
vm_id = common.get_node("//vm[load_order = 'SERVICE_VM']/@id", scenario_etree) vm_id = get_node("//vm[load_order = 'SERVICE_VM']/@id", scenario_etree)
allocation_sos_vm_node = common.get_node(f"/acrn-config/vm[@id='{vm_id}']", allocation_etree) allocation_service_vm_node = get_node(f"/acrn-config/vm[@id='{vm_id}']", allocation_etree)
if allocation_sos_vm_node is None: if allocation_service_vm_node is None:
allocation_sos_vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) allocation_service_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
if common.get_node("./load_order", allocation_sos_vm_node) is None: if get_node("./load_order", allocation_service_vm_node) is None:
common.append_node("./load_order", "SERVICE_VM", allocation_sos_vm_node) acrn_config_utilities.append_node("./load_order", "SERVICE_VM", allocation_service_vm_node)
for pcpu_id in sorted([int(x) for x in cpus_for_sos]): for pcpu_id in sorted([int(x) for x in cpus_for_sos]):
common.append_node("./cpu_affinity/pcpu_id", str(pcpu_id), allocation_sos_vm_node) acrn_config_utilities.append_node("./cpu_affinity/pcpu_id", str(pcpu_id), allocation_service_vm_node)

View File

@ -5,7 +5,8 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import common, board_cfg_lib import acrn_config_utilities, board_cfg_lib
from acrn_config_utilities import get_node
# CPU frequency dependency # CPU frequency dependency
# Some CPU cores may share the same clock domain/group with others, which makes them always run at # Some CPU cores may share the same clock domain/group with others, which makes them always run at
@ -26,19 +27,19 @@ def get_dependency(board_etree):
cpus = board_etree.xpath("//processors//thread") cpus = board_etree.xpath("//processors//thread")
dep_ret = [] dep_ret = []
for cpu in cpus: for cpu in cpus:
cpu_id = common.get_node("./cpu_id/text()", cpu) cpu_id = get_node("./cpu_id/text()", cpu)
psd_cpus = [cpu_id] psd_cpus = [cpu_id]
psd_cpus_list = common.get_node("./freqdomain_cpus/text()", cpu) psd_cpus_list = get_node("./freqdomain_cpus/text()", cpu)
if psd_cpus_list != None: if psd_cpus_list != None:
psd_cpus = psd_cpus_list.split(' ') psd_cpus = psd_cpus_list.split(' ')
apic_id = int(common.get_node("./apic_id/text()", cpu)[2:], base=16) apic_id = int(get_node("./apic_id/text()", cpu)[2:], base=16)
is_hybrid = (len(board_etree.xpath("//processors//capability[@id='hybrid']")) != 0) is_hybrid = (len(board_etree.xpath("//processors//capability[@id='hybrid']")) != 0)
core_type = common.get_node("./core_type/text()", cpu) core_type = get_node("./core_type/text()", cpu)
for other_cpu in cpus: for other_cpu in cpus:
other_cpu_id = common.get_node("./cpu_id/text()", other_cpu) other_cpu_id = get_node("./cpu_id/text()", other_cpu)
if cpu_id != other_cpu_id: if cpu_id != other_cpu_id:
other_apic_id = int(common.get_node("./apic_id/text()", other_cpu)[2:], base=16) other_apic_id = int(get_node("./apic_id/text()", other_cpu)[2:], base=16)
other_core_type = common.get_node("./core_type/text()", other_cpu) other_core_type = get_node("./core_type/text()", other_cpu)
# threads at same core # threads at same core
if (apic_id & ~1) == (other_apic_id & ~1): if (apic_id & ~1) == (other_apic_id & ~1):
psd_cpus.append(other_cpu_id) psd_cpus.append(other_cpu_id)
@ -92,11 +93,11 @@ def alloc_limits(board_etree, scenario_etree, allocation_etree):
cpus = board_etree.xpath("//processors//thread") cpus = board_etree.xpath("//processors//thread")
for cpu in cpus: for cpu in cpus:
cpu_id = common.get_node("./cpu_id/text()", cpu) cpu_id = get_node("./cpu_id/text()", cpu)
if cpu_has_hwp: if cpu_has_hwp:
guaranteed_performance_lvl = common.get_node("./guaranteed_performance_lvl/text()", cpu) guaranteed_performance_lvl = get_node("./guaranteed_performance_lvl/text()", cpu)
highest_performance_lvl = common.get_node("./highest_performance_lvl/text()", cpu) highest_performance_lvl = get_node("./highest_performance_lvl/text()", cpu)
lowest_performance_lvl = common.get_node("./lowest_performance_lvl/text()", cpu) lowest_performance_lvl = get_node("./lowest_performance_lvl/text()", cpu)
if cpu_id in rtvm_cpus: if cpu_id in rtvm_cpus:
# for CPUs in RTVM, fix to base performance # for CPUs in RTVM, fix to base performance
limit_lowest_lvl = guaranteed_performance_lvl limit_lowest_lvl = guaranteed_performance_lvl
@ -115,11 +116,11 @@ def alloc_limits(board_etree, scenario_etree, allocation_etree):
limit_highest_lvl = 0xff limit_highest_lvl = 0xff
limit_guaranteed_lvl = 0xff limit_guaranteed_lvl = 0xff
cpu_node = common.append_node(f"//hv/cpufreq/CPU", None, allocation_etree, id = cpu_id) cpu_node = acrn_config_utilities.append_node(f"//hv/cpufreq/CPU", None, allocation_etree, id = cpu_id)
limit_node = common.append_node("./limits", None, cpu_node) limit_node = acrn_config_utilities.append_node("./limits", None, cpu_node)
common.append_node("./limit_guaranteed_lvl", limit_guaranteed_lvl, limit_node) acrn_config_utilities.append_node("./limit_guaranteed_lvl", limit_guaranteed_lvl, limit_node)
common.append_node("./limit_highest_lvl", limit_highest_lvl, limit_node) acrn_config_utilities.append_node("./limit_highest_lvl", limit_highest_lvl, limit_node)
common.append_node("./limit_lowest_lvl", limit_lowest_lvl, limit_node) acrn_config_utilities.append_node("./limit_lowest_lvl", limit_lowest_lvl, limit_node)
limit_highest_pstate = 0 limit_highest_pstate = 0
limit_nominal_pstate = 0 limit_nominal_pstate = 0
@ -152,39 +153,39 @@ def alloc_limits(board_etree, scenario_etree, allocation_etree):
limit_nominal_pstate = 0 limit_nominal_pstate = 0
limit_lowest_pstate = p_count -1 limit_lowest_pstate = p_count -1
common.append_node("./limit_nominal_pstate", str(limit_nominal_pstate), limit_node) acrn_config_utilities.append_node("./limit_nominal_pstate", str(limit_nominal_pstate), limit_node)
common.append_node("./limit_highest_pstate", str(limit_highest_pstate), limit_node) acrn_config_utilities.append_node("./limit_highest_pstate", str(limit_highest_pstate), limit_node)
common.append_node("./limit_lowest_pstate", str(limit_lowest_pstate), limit_node) acrn_config_utilities.append_node("./limit_lowest_pstate", str(limit_lowest_pstate), limit_node)
# Let CPUs in the same frequency dependency group have the same limits. So that RTVM's frequency can be fixed # Let CPUs in the same frequency dependency group have the same limits. So that RTVM's frequency can be fixed
dep_info = get_dependency(board_etree) dep_info = get_dependency(board_etree)
for alloc_cpu in allocation_etree.xpath("//cpufreq/CPU"): for alloc_cpu in allocation_etree.xpath("//cpufreq/CPU"):
dependency_cpus = dep_info[int(alloc_cpu.attrib['id'])] dependency_cpus = dep_info[int(alloc_cpu.attrib['id'])]
if common.get_node("./limits", alloc_cpu) != None: if get_node("./limits", alloc_cpu) != None:
highest_lvl = int(common.get_node(".//limit_highest_lvl/text()", alloc_cpu)) highest_lvl = int(get_node(".//limit_highest_lvl/text()", alloc_cpu))
lowest_lvl = int(common.get_node(".//limit_lowest_lvl/text()", alloc_cpu)) lowest_lvl = int(get_node(".//limit_lowest_lvl/text()", alloc_cpu))
highest_pstate = int(common.get_node(".//limit_highest_pstate/text()", alloc_cpu)) highest_pstate = int(get_node(".//limit_highest_pstate/text()", alloc_cpu))
lowest_pstate = int(common.get_node(".//limit_lowest_pstate/text()", alloc_cpu)) lowest_pstate = int(get_node(".//limit_lowest_pstate/text()", alloc_cpu))
for dep_cpu_id in dependency_cpus: for dep_cpu_id in dependency_cpus:
dep_highest_lvl = int(common.get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_highest_lvl/text()", allocation_etree)) dep_highest_lvl = int(get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_highest_lvl/text()", allocation_etree))
dep_lowest_lvl = int(common.get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_lowest_lvl/text()", allocation_etree)) dep_lowest_lvl = int(get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_lowest_lvl/text()", allocation_etree))
if highest_lvl > dep_highest_lvl: if highest_lvl > dep_highest_lvl:
highest_lvl = dep_highest_lvl highest_lvl = dep_highest_lvl
if lowest_lvl < dep_lowest_lvl: if lowest_lvl < dep_lowest_lvl:
lowest_lvl = dep_lowest_lvl lowest_lvl = dep_lowest_lvl
dep_highest_pstate = int(common.get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_highest_pstate/text()", allocation_etree)) dep_highest_pstate = int(get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_highest_pstate/text()", allocation_etree))
dep_lowest_pstate = int(common.get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_lowest_pstate/text()", allocation_etree)) dep_lowest_pstate = int(get_node(f"//cpufreq/CPU[@id={dep_cpu_id}]//limit_lowest_pstate/text()", allocation_etree))
if highest_pstate < dep_highest_pstate: if highest_pstate < dep_highest_pstate:
highest_pstate = dep_highest_pstate highest_pstate = dep_highest_pstate
if lowest_pstate > dep_lowest_pstate: if lowest_pstate > dep_lowest_pstate:
lowest_pstate = dep_lowest_pstate lowest_pstate = dep_lowest_pstate
common.update_text("./limits/limit_highest_lvl", str(highest_lvl), alloc_cpu, True) acrn_config_utilities.update_text("./limits/limit_highest_lvl", str(highest_lvl), alloc_cpu, True)
common.update_text("./limits/limit_lowest_lvl", str(lowest_lvl), alloc_cpu, True) acrn_config_utilities.update_text("./limits/limit_lowest_lvl", str(lowest_lvl), alloc_cpu, True)
common.update_text("./limits/limit_highest_pstate", str(highest_pstate), alloc_cpu, True) acrn_config_utilities.update_text("./limits/limit_highest_pstate", str(highest_pstate), alloc_cpu, True)
common.update_text("./limits/limit_lowest_pstate", str(lowest_pstate), alloc_cpu, True) acrn_config_utilities.update_text("./limits/limit_lowest_pstate", str(lowest_pstate), alloc_cpu, True)
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
common.append_node("/acrn-config/hv/cpufreq", None, allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/cpufreq", None, allocation_etree)
alloc_limits(board_etree, scenario_etree, allocation_etree) alloc_limits(board_etree, scenario_etree, allocation_etree)

View File

@ -7,8 +7,9 @@
import sys, os, re import sys, os, re
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, lib.error, lib.lib, math import acrn_config_utilities, lib.error, lib.lib, math
from collections import namedtuple from collections import namedtuple
from acrn_config_utilities import get_node
# VMSIX devices list # VMSIX devices list
TSN_DEVS = [("0x8086", "0x4b30"), ("0x8086", "0x4b31"), ("0x8086", "0x4b32"), ("0x8086", "0x4ba0"), TSN_DEVS = [("0x8086", "0x4b30"), ("0x8086", "0x4b31"), ("0x8086", "0x4b32"), ("0x8086", "0x4ba0"),
@ -58,7 +59,7 @@ PRE_LAUNCHED_VM_HIGH_MEM_END = 512 * SIZE_G
# Constants for ivshmem # Constants for ivshmem
BAR0_SHEMEM_SIZE = 4 * SIZE_K BAR0_SHEMEM_SIZE = 4 * SIZE_K
BAR1_SHEMEM_SIZE = 4 * SIZE_K BAR1_SHEMEM_SIZE = 4 * SIZE_K
BAR2_SHEMEM_ALIGNMENT = 2 * common.SIZE_M BAR2_SHEMEM_ALIGNMENT = 2 * acrn_config_utilities.SIZE_M
# Constants for pci vuart # Constants for pci vuart
PCI_VUART_VBAR0_SIZE = 4 * SIZE_K PCI_VUART_VBAR0_SIZE = 4 * SIZE_K
@ -123,10 +124,10 @@ def insert_vuart_to_dev_dict(scenario_etree, vm_id, devdict_32bits):
devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE
devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE
vm_name = common.get_node(f"//vm[@id = '{vm_id}']/name/text()", scenario_etree) vm_name = get_node(f"//vm[@id = '{vm_id}']/name/text()", scenario_etree)
communication_vuarts = scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name/text() = '{vm_name}']") communication_vuarts = scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name/text() = '{vm_name}']")
for vuart_id, vuart in enumerate(communication_vuarts, start=1): for vuart_id, vuart in enumerate(communication_vuarts, start=1):
connection_type = common.get_node(f"./type/text()", vuart) connection_type = get_node(f"./type/text()", vuart)
if connection_type == "pci": if connection_type == "pci":
devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE
devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE
@ -159,7 +160,7 @@ def insert_pt_devs_to_dev_dict(board_etree, vm_node_etree, devdict_32bits, devdi
dev = int(bdf.split(":")[1].split('.')[0], 16) dev = int(bdf.split(":")[1].split('.')[0], 16)
func = int(bdf.split(":")[1].split('.')[1], 16) func = int(bdf.split(":")[1].split('.')[1], 16)
bdf = lib.lib.BusDevFunc(bus=bus, dev=dev, func=func) bdf = lib.lib.BusDevFunc(bus=bus, dev=dev, func=func)
pt_dev_node = common.get_node(f"//bus[@type = 'pci' and @address = '{hex(bus)}']/device[@address = '{hex((dev << 16) | func)}']", board_etree) pt_dev_node = get_node(f"//bus[@type = 'pci' and @address = '{hex(bus)}']/device[@address = '{hex((dev << 16) | func)}']", board_etree)
if pt_dev_node is not None: if pt_dev_node is not None:
insert_vmsix_to_dev_dict(pt_dev_node, devdict_32bits) insert_vmsix_to_dev_dict(pt_dev_node, devdict_32bits)
pt_dev_resources = pt_dev_node.xpath(".//resource[@type = 'memory' and @len != '0x0' and @id and @width]") pt_dev_resources = pt_dev_node.xpath(".//resource[@type = 'memory' and @len != '0x0' and @id and @width]")
@ -184,7 +185,7 @@ def get_pt_devs_io_port(board_etree, vm_node_etree):
dev = int(bdf.split(":")[1].split('.')[0], 16) dev = int(bdf.split(":")[1].split('.')[0], 16)
func = int(bdf.split(":")[1].split('.')[1], 16) func = int(bdf.split(":")[1].split('.')[1], 16)
bdf = lib.lib.BusDevFunc(bus=bus, dev=dev, func=func) bdf = lib.lib.BusDevFunc(bus=bus, dev=dev, func=func)
pt_dev_node = common.get_node(f"//bus[@type = 'pci' and @address = '{hex(bus)}']/device[@address = '{hex((dev << 16) | func)}']", board_etree) pt_dev_node = get_node(f"//bus[@type = 'pci' and @address = '{hex(bus)}']/device[@address = '{hex((dev << 16) | func)}']", board_etree)
if pt_dev_node is not None: if pt_dev_node is not None:
pt_dev_resources = pt_dev_node.xpath(".//resource[@type = 'io_port' and @id[starts-with(., 'bar')]]") pt_dev_resources = pt_dev_node.xpath(".//resource[@type = 'io_port' and @id[starts-with(., 'bar')]]")
for pt_dev_resource in pt_dev_resources: for pt_dev_resource in pt_dev_resources:
@ -200,8 +201,8 @@ def insert_vmsix_to_dev_dict(pt_dev_node, devdict):
2. Find the first unused region index for the vmsix bar. 2. Find the first unused region index for the vmsix bar.
3. Allocate an unused mmio window for this bar. 3. Allocate an unused mmio window for this bar.
""" """
vendor = common.get_node("./vendor/text()", pt_dev_node) vendor = get_node("./vendor/text()", pt_dev_node)
identifier = common.get_node("./identifier/text()", pt_dev_node) identifier = get_node("./identifier/text()", pt_dev_node)
if vendor is None or identifier is None: if vendor is None or identifier is None:
return return
@ -222,8 +223,8 @@ def insert_vmsix_to_dev_dict(pt_dev_node, devdict):
next_bar_region = unused_bar_index.pop(0) next_bar_region = unused_bar_index.pop(0)
except IndexError: except IndexError:
raise lib.error.ResourceError(f"Cannot allocate a bar index for vmsix supported device: {vendor}:{identifier}, used bar idx list: {used_bar_index}") raise lib.error.ResourceError(f"Cannot allocate a bar index for vmsix supported device: {vendor}:{identifier}, used bar idx list: {used_bar_index}")
address = common.get_node("./@address", pt_dev_node) address = get_node("./@address", pt_dev_node)
bus = common.get_node(f"../@address", pt_dev_node) bus = get_node(f"../@address", pt_dev_node)
if bus is not None and address is not None: if bus is not None and address is not None:
bdf = lib.lib.BusDevFunc(bus=int(bus, 16), dev=int(address, 16) >> 16, func=int(address, 16) & 0xffff) bdf = lib.lib.BusDevFunc(bus=int(bus, 16), dev=int(address, 16) >> 16, func=int(address, 16) & 0xffff)
dev_name = str(bdf) dev_name = str(bdf)
@ -349,44 +350,44 @@ def create_device_node(allocation_etree, vm_id, devdict):
bar_region = dev[1].split('bar')[-1] bar_region = dev[1].split('bar')[-1]
bar_base = devdict.get(dev) bar_base = devdict.get(dev)
vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if vm_node is None: if vm_node is None:
vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
dev_node = common.get_node(f"./device[@name = '{dev_name}']", vm_node) dev_node = get_node(f"./device[@name = '{dev_name}']", vm_node)
if dev_node is None: if dev_node is None:
dev_node = common.append_node("./device", None, vm_node, name = dev_name) dev_node = acrn_config_utilities.append_node("./device", None, vm_node, name = dev_name)
if common.get_node(f"./bar[@id='{bar_region}']", dev_node) is None: if get_node(f"./bar[@id='{bar_region}']", dev_node) is None:
common.append_node(f"./bar", hex(bar_base), dev_node, id = bar_region) acrn_config_utilities.append_node(f"./bar", hex(bar_base), dev_node, id = bar_region)
if IVSHMEM in dev_name and bar_region == '2': if IVSHMEM in dev_name and bar_region == '2':
common.update_text(f"./bar[@id = '2']", hex(bar_base | PREFETCHABLE_BIT | MEMORY_BAR_LOCATABLE_64BITS), dev_node, True) acrn_config_utilities.update_text(f"./bar[@id = '2']", hex(bar_base | PREFETCHABLE_BIT | MEMORY_BAR_LOCATABLE_64BITS), dev_node, True)
def create_vuart_node(allocation_etree, vm_id, devdict): def create_vuart_node(allocation_etree, vm_id, devdict):
for dev in devdict: for dev in devdict:
vuart_id = dev[0][-1] vuart_id = dev[0][-1]
bar_base = devdict.get(dev) bar_base = devdict.get(dev)
vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if vm_node is None: if vm_node is None:
vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
vuart_node = common.get_node(f"./legacy_vuart[@id = '{vuart_id}']", vm_node) vuart_node = get_node(f"./legacy_vuart[@id = '{vuart_id}']", vm_node)
if vuart_node is None: if vuart_node is None:
vuart_node = common.append_node("./legacy_vuart", None, vm_node, id = vuart_id) vuart_node = acrn_config_utilities.append_node("./legacy_vuart", None, vm_node, id = vuart_id)
if common.get_node(f"./base", vuart_node) is None: if get_node(f"./base", vuart_node) is None:
common.append_node(f"./base", hex(bar_base), vuart_node) acrn_config_utilities.append_node(f"./base", hex(bar_base), vuart_node)
def create_native_pci_hole_node(allocation_etree, low_mem, high_mem): def create_native_pci_hole_node(allocation_etree, low_mem, high_mem):
common.append_node("/acrn-config/hv/MMIO/MMIO32_START", hex(low_mem[0].start).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO32_START", hex(low_mem[0].start).upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/MMIO32_END", hex(low_mem[-1].end + 1).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO32_END", hex(low_mem[-1].end + 1).upper(), allocation_etree)
if len(high_mem): if len(high_mem):
common.append_node("/acrn-config/hv/MMIO/MMIO64_START", hex(high_mem[0].start).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO64_START", hex(high_mem[0].start).upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/MMIO64_END", hex(high_mem[-1].end + 1).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO64_END", hex(high_mem[-1].end + 1).upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/HI_MMIO_START", hex(high_mem[0].start).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/HI_MMIO_START", hex(high_mem[0].start).upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/HI_MMIO_END", hex(high_mem[0].end + 1).upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/HI_MMIO_END", hex(high_mem[0].end + 1).upper(), allocation_etree)
else: else:
common.append_node("/acrn-config/hv/MMIO/MMIO64_START", "~0".upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO64_START", "~0".upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/MMIO64_END", "~0", allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/MMIO64_END", "~0", allocation_etree)
common.append_node("/acrn-config/hv/MMIO/HI_MMIO_START", "~0".upper(), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/HI_MMIO_START", "~0".upper(), allocation_etree)
common.append_node("/acrn-config/hv/MMIO/HI_MMIO_END", "0", allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MMIO/HI_MMIO_END", "0", allocation_etree)
def get_free_addr(windowslist, used, size, alignment): def get_free_addr(windowslist, used, size, alignment):
if not size: if not size:
@ -396,11 +397,11 @@ def get_free_addr(windowslist, used, size, alignment):
alignment = max(alignment, size) alignment = max(alignment, size)
for w in windowslist: for w in windowslist:
new_w_start = common.round_up(w.start, alignment) new_w_start = acrn_config_utilities.round_up(w.start, alignment)
window = AddrWindow(start = new_w_start, end = new_w_start + size - 1) window = AddrWindow(start = new_w_start, end = new_w_start + size - 1)
for u in used: for u in used:
if window.overlaps(u): if window.overlaps(u):
new_u_end = common.round_up(u.end + 1, alignment) new_u_end = acrn_config_utilities.round_up(u.end + 1, alignment)
window = AddrWindow(start = new_u_end, end = new_u_end + size - 1) window = AddrWindow(start = new_u_end, end = new_u_end + size - 1)
continue continue
if window.overlaps(w): if window.overlaps(w):
@ -439,7 +440,7 @@ def allocate_pci_bar(board_etree, scenario_etree, allocation_etree):
used_low_mem = [] used_low_mem = []
used_high_mem = [] used_high_mem = []
load_order = common.get_node("./load_order/text()", vm_node) load_order = get_node("./load_order/text()", vm_node)
if load_order is not None and lib.lib.is_pre_launched_vm(load_order): if load_order is not None and lib.lib.is_pre_launched_vm(load_order):
low_mem = [AddrWindow(start = PRE_LAUNCHED_VM_LOW_MEM_START, end = PRE_LAUNCHED_VM_LOW_MEM_END - 1)] low_mem = [AddrWindow(start = PRE_LAUNCHED_VM_LOW_MEM_START, end = PRE_LAUNCHED_VM_LOW_MEM_END - 1)]
high_mem = [AddrWindow(start = PRE_LAUNCHED_VM_HIGH_MEM_START, end = PRE_LAUNCHED_VM_HIGH_MEM_END - 1)] high_mem = [AddrWindow(start = PRE_LAUNCHED_VM_HIGH_MEM_START, end = PRE_LAUNCHED_VM_HIGH_MEM_END - 1)]
@ -474,7 +475,7 @@ def allocate_io_port(board_etree, scenario_etree, allocation_etree):
io_port_range_list = [] io_port_range_list = []
used_io_port_list = [] used_io_port_list = []
load_order = common.get_node("./load_order/text()", vm_node) load_order = get_node("./load_order/text()", vm_node)
if load_order is not None and lib.lib.is_service_vm(load_order): if load_order is not None and lib.lib.is_service_vm(load_order):
io_port_range_list = io_port_range_list_native io_port_range_list = io_port_range_list_native
io_port_passthrough = get_pt_devs_io_port_passthrough(board_etree, scenario_etree) io_port_passthrough = get_pt_devs_io_port_passthrough(board_etree, scenario_etree)
@ -491,9 +492,9 @@ def allocate_io_port(board_etree, scenario_etree, allocation_etree):
def allocate_ssram_region(board_etree, scenario_etree, allocation_etree): def allocate_ssram_region(board_etree, scenario_etree, allocation_etree):
# Guest physical address of the SW SRAM allocated to a pre-launched VM # Guest physical address of the SW SRAM allocated to a pre-launched VM
ssram_area_max_size = 0 ssram_area_max_size = 0
enabled = common.get_node("//SSRAM_ENABLED/text()", scenario_etree) enabled = get_node("//SSRAM_ENABLED/text()", scenario_etree)
if enabled == "y": if enabled == "y":
pre_rt_vms = common.get_node("//vm[load_order = 'PRE_LAUNCHED_VM' and vm_type = 'RTVM']", scenario_etree) pre_rt_vms = get_node("//vm[load_order = 'PRE_LAUNCHED_VM' and vm_type = 'RTVM']", scenario_etree)
if pre_rt_vms is not None: if pre_rt_vms is not None:
vm_id = pre_rt_vms.get("id") vm_id = pre_rt_vms.get("id")
l3_sw_sram = board_etree.xpath("//cache[@level='3']/capability[@id='Software SRAM']") l3_sw_sram = board_etree.xpath("//cache[@level='3']/capability[@id='Software SRAM']")
@ -502,32 +503,32 @@ def allocate_ssram_region(board_etree, scenario_etree, allocation_etree):
top = 0 top = 0
base = 0 base = 0
for ssram in board_etree.xpath("//cache/capability[@id='Software SRAM']"): for ssram in board_etree.xpath("//cache/capability[@id='Software SRAM']"):
entry_base = int(common.get_node("./start/text()", ssram), 16) entry_base = int(get_node("./start/text()", ssram), 16)
entry_size = int(common.get_node("./size/text()", ssram)) entry_size = int(get_node("./size/text()", ssram))
top = (entry_base + entry_size) if top < (entry_base + entry_size) else top top = (entry_base + entry_size) if top < (entry_base + entry_size) else top
base = entry_base if base == 0 or entry_base < base else base base = entry_base if base == 0 or entry_base < base else base
ssram_area_max_size = math.ceil((top - base)/0x1000) * 0x1000 ssram_area_max_size = math.ceil((top - base)/0x1000) * 0x1000
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if allocation_vm_node is None: if allocation_vm_node is None:
allocation_vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) allocation_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
common.append_node("./ssram/start_gpa", hex(PRE_RTVM_SW_SRAM_END_GPA - ssram_area_max_size + 1), allocation_vm_node) acrn_config_utilities.append_node("./ssram/start_gpa", hex(PRE_RTVM_SW_SRAM_END_GPA - ssram_area_max_size + 1), allocation_vm_node)
common.append_node("./ssram/end_gpa", hex(PRE_RTVM_SW_SRAM_END_GPA), allocation_vm_node) acrn_config_utilities.append_node("./ssram/end_gpa", hex(PRE_RTVM_SW_SRAM_END_GPA), allocation_vm_node)
common.append_node("./ssram/max_size", str(ssram_area_max_size), allocation_vm_node) acrn_config_utilities.append_node("./ssram/max_size", str(ssram_area_max_size), allocation_vm_node)
def allocate_log_area(board_etree, scenario_etree, allocation_etree): def allocate_log_area(board_etree, scenario_etree, allocation_etree):
tpm2_enabled = common.get_node(f"//vm[@id = '0']/mmio_resources/TPM2/text()", scenario_etree) tpm2_enabled = get_node(f"//vm[@id = '0']/mmio_resources/TPM2/text()", scenario_etree)
if tpm2_enabled is None or tpm2_enabled == 'n': if tpm2_enabled is None or tpm2_enabled == 'n':
return return
if common.get_node("//capability[@id='log_area']", board_etree) is not None: if get_node("//capability[@id='log_area']", board_etree) is not None:
log_area_min_len_native = int(common.get_node(f"//log_area_minimum_length/text()", board_etree), 16) log_area_min_len_native = int(get_node(f"//log_area_minimum_length/text()", board_etree), 16)
log_area_start_address = common.round_up(VIRT_ACPI_NVS_ADDR, 0x10000) + RESERVED_NVS_AREA log_area_start_address = acrn_config_utilities.round_up(VIRT_ACPI_NVS_ADDR, 0x10000) + RESERVED_NVS_AREA
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '0']", allocation_etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '0']", allocation_etree)
if allocation_vm_node is None: if allocation_vm_node is None:
allocation_vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = '0') allocation_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = '0')
common.append_node("./log_area_start_address", hex(log_area_start_address).upper(), allocation_vm_node) acrn_config_utilities.append_node("./log_area_start_address", hex(log_area_start_address).upper(), allocation_vm_node)
common.append_node("./log_area_minimum_length", hex(log_area_min_len_native).upper(), allocation_vm_node) acrn_config_utilities.append_node("./log_area_minimum_length", hex(log_area_min_len_native).upper(), allocation_vm_node)
def pt_dev_io_port_passthrough(board_etree, scenario_etree, allocation_etree): def pt_dev_io_port_passthrough(board_etree, scenario_etree, allocation_etree):
vm_nodes = scenario_etree.xpath("//vm") vm_nodes = scenario_etree.xpath("//vm")

View File

@ -7,8 +7,9 @@
import sys, os, re import sys, os, re
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, lib.error, lib.lib import acrn_config_utilities, lib.error, lib.lib
from collections import namedtuple from collections import namedtuple
from acrn_config_utilities import get_node
class GuestFlagPolicy(namedtuple("GuestFlagPolycy", ["condition", "guest_flag"])): class GuestFlagPolicy(namedtuple("GuestFlagPolycy", ["condition", "guest_flag"])):
pass pass
@ -30,10 +31,10 @@ policies = [
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
for vm_node in scenario_etree.xpath("//vm"): for vm_node in scenario_etree.xpath("//vm"):
vm_id = vm_node.get('id') vm_id = vm_node.get('id')
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if allocation_vm_node is None: if allocation_vm_node is None:
allocation_vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id) allocation_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = vm_id)
for policy in policies: for policy in policies:
if vm_node.xpath(policy.condition): if vm_node.xpath(policy.condition):
common.append_node("./guest_flags/guest_flag", str(policy.guest_flag), allocation_vm_node) acrn_config_utilities.append_node("./guest_flags/guest_flag", str(policy.guest_flag), allocation_vm_node)
common.append_node("./guest_flags/guest_flag",'GUEST_FLAG_STATIC_VM', allocation_vm_node) acrn_config_utilities.append_node("./guest_flags/guest_flag",'GUEST_FLAG_STATIC_VM', allocation_vm_node)

View File

@ -7,19 +7,20 @@
import sys, os import sys, os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, board_cfg_lib, scenario_cfg_lib import acrn_config_utilities, board_cfg_lib, scenario_cfg_lib
from acrn_config_utilities import get_node
HV_RAM_SIZE_MAX = 0x40000000 HV_RAM_SIZE_MAX = 0x40000000
MEM_ALIGN = 2 * common.SIZE_M MEM_ALIGN = 2 * acrn_config_utilities.SIZE_M
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
# this dictonary mapped with 'address start':'mem range' # this dictonary mapped with 'address start':'mem range'
ram_range = {} ram_range = {}
max_vm_num = int(common.get_node(f"//hv/CAPACITIES/MAX_VM_NUM/text()", scenario_etree)) max_vm_num = int(get_node(f"//hv/CAPACITIES/MAX_VM_NUM/text()", scenario_etree))
max_trusty_vm = len(scenario_etree.xpath(f"//vm[./secure_world_support/text() = 'y']")) max_trusty_vm = len(scenario_etree.xpath(f"//vm[./secure_world_support/text() = 'y']"))
hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * max_vm_num + max_trusty_vm * common.TRUSTY_RAM_SIZE hv_ram_size = acrn_config_utilities.HV_BASE_RAM_SIZE + acrn_config_utilities.VM_RAM_SIZE * max_vm_num + max_trusty_vm * acrn_config_utilities.TRUSTY_RAM_SIZE
ivshmem_list = scenario_etree.xpath("//IVSHMEM_SIZE/text()") ivshmem_list = scenario_etree.xpath("//IVSHMEM_SIZE/text()")
total_shm_size = 0 total_shm_size = 0
for ram_size in ivshmem_list: for ram_size in ivshmem_list:
@ -41,7 +42,7 @@ def fn(board_etree, scenario_etree, allocation_etree):
avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(hv_ram_size), hv_start_offset) avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(hv_ram_size), hv_start_offset)
hv_start_addr = int(avl_start_addr, 16) hv_start_addr = int(avl_start_addr, 16)
hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN) hv_start_addr = acrn_config_utilities.round_up(hv_start_addr, MEM_ALIGN)
board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = hv_ram_size board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = hv_ram_size
common.append_node("/acrn-config/hv/MEMORY/HV_RAM_START", hex(hv_start_addr), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MEMORY/HV_RAM_START", hex(hv_start_addr), allocation_etree)
common.append_node("/acrn-config/hv/MEMORY/HV_RAM_SIZE", hex(hv_ram_size), allocation_etree) acrn_config_utilities.append_node("/acrn-config/hv/MEMORY/HV_RAM_SIZE", hex(hv_ram_size), allocation_etree)

View File

@ -7,10 +7,11 @@
import sys, os import sys, os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, board_cfg_lib, lib.error, lib.lib import acrn_config_utilities, board_cfg_lib, lib.error, lib.lib
import re import re
from collections import defaultdict from collections import defaultdict
from itertools import combinations from itertools import combinations
from acrn_config_utilities import get_node
LEGACY_IRQ_MAX = 16 LEGACY_IRQ_MAX = 16
@ -20,7 +21,7 @@ def get_native_valid_irq():
:return: native available irq list :return: native available irq list
""" """
val_irq = [] val_irq = []
irq_info_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<AVAILABLE_IRQ_INFO>", "</AVAILABLE_IRQ_INFO>") irq_info_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<AVAILABLE_IRQ_INFO>", "</AVAILABLE_IRQ_INFO>")
for irq_string in irq_info_lines: for irq_string in irq_info_lines:
val_irq = [int(x.strip()) for x in irq_string.split(',')] val_irq = [int(x.strip()) for x in irq_string.split(',')]
return val_irq return val_irq
@ -48,15 +49,15 @@ def remove_irq(irq_list, irq):
raise ValueError("Cannot remove irq:{} from available irq list:{}, {}". format(irq, e, irq_list)) from e raise ValueError("Cannot remove irq:{} from available irq list:{}, {}". format(irq, e, irq_list)) from e
def create_vuart_irq_node(etree, vm_id, load_order, vuart_id, irq): def create_vuart_irq_node(etree, vm_id, load_order, vuart_id, irq):
allocation_vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", etree) allocation_vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", etree)
if allocation_vm_node is None: if allocation_vm_node is None:
allocation_vm_node = common.append_node("/acrn-config/vm", None, etree, id = vm_id) allocation_vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, etree, id = vm_id)
if common.get_node("./load_order", allocation_vm_node) is None: if get_node("./load_order", allocation_vm_node) is None:
common.append_node("./load_order", load_order, allocation_vm_node) acrn_config_utilities.append_node("./load_order", load_order, allocation_vm_node)
if common.get_node(f"./legacy_vuart[@id = '{vuart_id}']", allocation_vm_node) is None: if get_node(f"./legacy_vuart[@id = '{vuart_id}']", allocation_vm_node) is None:
common.append_node("./legacy_vuart", None, allocation_vm_node, id = vuart_id) acrn_config_utilities.append_node("./legacy_vuart", None, allocation_vm_node, id = vuart_id)
common.append_node(f"./legacy_vuart[@id = '{vuart_id}']/irq", irq, allocation_vm_node) acrn_config_utilities.append_node(f"./legacy_vuart[@id = '{vuart_id}']/irq", irq, allocation_vm_node)
def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree): def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
native_ttys = lib.lib.get_native_ttys() native_ttys = lib.lib.get_native_ttys()
@ -65,7 +66,7 @@ def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
vm_node_list = scenario_etree.xpath("//vm") vm_node_list = scenario_etree.xpath("//vm")
for vm_node in vm_node_list: for vm_node in vm_node_list:
load_order = common.get_node("./load_order/text()", vm_node) load_order = get_node("./load_order/text()", vm_node)
irq_list = get_native_valid_irq() if load_order == "SERVICE_VM" else [f"{d}" for d in list(range(5,15))] irq_list = get_native_valid_irq() if load_order == "SERVICE_VM" else [f"{d}" for d in list(range(5,15))]
if load_order == "SERVICE_VM": if load_order == "SERVICE_VM":
@ -75,34 +76,34 @@ def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
remove_irq(irq_list, 4) remove_irq(irq_list, 4)
vuart_id = 1 vuart_id = 1
legacy_vuart_irq = "0" legacy_vuart_irq = "0"
vmname = common.get_node("./name/text()", vm_node) vmname = get_node("./name/text()", vm_node)
vuart_connections = scenario_etree.xpath("//vuart_connection") vuart_connections = scenario_etree.xpath("//vuart_connection")
for connection in vuart_connections: for connection in vuart_connections:
endpoint_list = connection.xpath(".//endpoint") endpoint_list = connection.xpath(".//endpoint")
for endpoint in endpoint_list: for endpoint in endpoint_list:
vm_name = common.get_node("./vm_name/text()", endpoint) vm_name = get_node("./vm_name/text()", endpoint)
if vm_name == vmname: if vm_name == vmname:
vuart_type = common.get_node("./type/text()", connection) vuart_type = get_node("./type/text()", connection)
if vuart_type == "legacy": if vuart_type == "legacy":
io_port = common.get_node("./io_port/text()", endpoint) io_port = get_node("./io_port/text()", endpoint)
legacy_vuart_irq = alloc_standard_irq(io_port) legacy_vuart_irq = alloc_standard_irq(io_port)
if legacy_vuart_irq == "0" and load_order != "SERVICE_VM": if legacy_vuart_irq == "0" and load_order != "SERVICE_VM":
legacy_vuart_irq = alloc_irq(irq_list) legacy_vuart_irq = alloc_irq(irq_list)
else: else:
legacy_vuart_irq = alloc_irq(irq_list) legacy_vuart_irq = alloc_irq(irq_list)
create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq) create_vuart_irq_node(allocation_etree, get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq)
vuart_id = vuart_id + 1 vuart_id = vuart_id + 1
# Allocate irq for S5 vuart, we have to use the irq of COM2 # Allocate irq for S5 vuart, we have to use the irq of COM2
if load_order != "SERVICE_VM": if load_order != "SERVICE_VM":
legacy_vuart_irq = alloc_standard_irq("0x2F8") legacy_vuart_irq = alloc_standard_irq("0x2F8")
create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq) create_vuart_irq_node(allocation_etree, get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq)
vuart_id = vuart_id + 1 vuart_id = vuart_id + 1
user_vm_list = scenario_etree.xpath(f"//vm[load_order != 'SERVICE_VM']/name/text()") user_vm_list = scenario_etree.xpath(f"//vm[load_order != 'SERVICE_VM']/name/text()")
service_vm_id = common.get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree) service_vm_id = get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree)
service_vm_name = common.get_node(f"//vm[load_order = 'SERVICE_VM']/name/text()", scenario_etree) service_vm_name = get_node(f"//vm[load_order = 'SERVICE_VM']/name/text()", scenario_etree)
service_vuart_list = scenario_etree.xpath(f"//endpoint[vm_name = '{service_vm_name}']") service_vuart_list = scenario_etree.xpath(f"//endpoint[vm_name = '{service_vm_name}']")
if service_vm_id is not None: if service_vm_id is not None:
for index in range(0, len(user_vm_list)): for index in range(0, len(user_vm_list)):
@ -130,7 +131,7 @@ def get_irqs_of_device(device_node):
else: else:
# Interrupts from another device # Interrupts from another device
index = res.get("index", "0") index = res.get("index", "0")
irq = common.get_node(f"//device[acpi_object='{source}']/resource[@id='res{index}' and @type='irq']/@int", device_node.getroottree()) irq = get_node(f"//device[acpi_object='{source}']/resource[@id='res{index}' and @type='irq']/@int", device_node.getroottree())
if irq is not None: if irq is not None:
irqs.add(int(irq)) irqs.add(int(irq))
@ -152,7 +153,7 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
load_order = vm.find("load_order").text load_order = vm.find("load_order").text
vm_id = int(vm.get("id")) vm_id = int(vm.get("id"))
if lib.lib.is_pre_launched_vm(load_order): if lib.lib.is_pre_launched_vm(load_order):
pt_intx_text = common.get_node("pt_intx/text()", vm) pt_intx_text = get_node("pt_intx/text()", vm)
if pt_intx_text is not None: if pt_intx_text is not None:
pt_intx_mapping = dict(eval(f"[{pt_intx_text.replace(')(', '), (')}]")) pt_intx_mapping = dict(eval(f"[{pt_intx_text.replace(')(', '), (')}]"))
for irq in pt_intx_mapping.keys(): for irq in pt_intx_mapping.keys():
@ -160,7 +161,7 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
for pci_dev in vm.xpath("pci_devs/pci_dev/text()"): for pci_dev in vm.xpath("pci_devs/pci_dev/text()"):
bdf = lib.lib.BusDevFunc.from_str(pci_dev.split(" ")[0]) bdf = lib.lib.BusDevFunc.from_str(pci_dev.split(" ")[0])
address = hex((bdf.dev << 16) | (bdf.func)) address = hex((bdf.dev << 16) | (bdf.func))
device_node = common.get_node(f"//bus[@address='{hex(bdf.bus)}']/device[@address='{address}']", board_etree) device_node = get_node(f"//bus[@address='{hex(bdf.bus)}']/device[@address='{address}']", board_etree)
if device_node in device_nodes: if device_node in device_nodes:
irqs = get_irqs_of_device(device_node) irqs = get_irqs_of_device(device_node)
for irq in irqs: for irq in irqs:
@ -168,7 +169,7 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
device_nodes.discard(device_node) device_nodes.discard(device_node)
# Raise error when any pre-launched VM with LAPIC passthrough requires any interrupt line. # Raise error when any pre-launched VM with LAPIC passthrough requires any interrupt line.
lapic_passthru_flag = common.get_node("lapic_passthrough[text() = 'y']", vm) lapic_passthru_flag = get_node("lapic_passthrough[text() = 'y']", vm)
if lapic_passthru_flag is not None and irq_allocation[vm_id]: if lapic_passthru_flag is not None and irq_allocation[vm_id]:
for irq, devices in irq_allocation[vm_id].items(): for irq, devices in irq_allocation[vm_id].items():
print(f"Interrupt line {irq} is used by the following device(s).") print(f"Interrupt line {irq} is used by the following device(s).")
@ -226,10 +227,10 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
# stated in the scenario configuration. # stated in the scenario configuration.
# #
for vm_id, alloc in irq_allocation.items(): for vm_id, alloc in irq_allocation.items():
vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if vm_node is None: if vm_node is None:
vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id = str(vm_id)) vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id = str(vm_id))
pt_intx_text = common.get_node(f"//vm[@id='{vm_id}']/pt_intx/text()", scenario_etree) pt_intx_text = get_node(f"//vm[@id='{vm_id}']/pt_intx/text()", scenario_etree)
pt_intx_mapping = dict(eval(f"[{pt_intx_text.replace(')(', '), (')}]")) if pt_intx_text is not None else {} pt_intx_mapping = dict(eval(f"[{pt_intx_text.replace(')(', '), (')}]")) if pt_intx_text is not None else {}
for irq, devs in alloc.items(): for irq, devs in alloc.items():
for dev in devs: for dev in devs:
@ -237,13 +238,13 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
continue continue
bdf = dev.split(" ")[0] bdf = dev.split(" ")[0]
dev_name = f"PTDEV_{bdf}" dev_name = f"PTDEV_{bdf}"
dev_node = common.get_node(f"device[@name = '{dev_name}']", vm_node) dev_node = get_node(f"device[@name = '{dev_name}']", vm_node)
if dev_node is None: if dev_node is None:
dev_node = common.append_node("./device", None, vm_node, name = dev_name) dev_node = acrn_config_utilities.append_node("./device", None, vm_node, name = dev_name)
pt_intx_node = common.get_node(f"pt_intx", dev_node) pt_intx_node = get_node(f"pt_intx", dev_node)
virq = pt_intx_mapping.get(irq, irq) virq = pt_intx_mapping.get(irq, irq)
if pt_intx_node is None: if pt_intx_node is None:
common.append_node(f"./pt_intx", f"({irq}, {virq})", dev_node) acrn_config_utilities.append_node(f"./pt_intx", f"({irq}, {virq})", dev_node)
else: else:
pt_intx_node.text += f" ({irq}, {virq})" pt_intx_node.text += f" ({irq}, {virq})"

View File

@ -8,8 +8,9 @@
import sys, os, re import sys, os, re
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, board_cfg_lib import acrn_config_utilities, board_cfg_lib
from collections import namedtuple from collections import namedtuple
from acrn_config_utilities import get_node
PRE_LAUNCHED_VMS_TYPE = ["SAFETY_VM", "PRE_RT_VM", "PRE_STD_VM"] PRE_LAUNCHED_VMS_TYPE = ["SAFETY_VM", "PRE_RT_VM", "PRE_STD_VM"]
POST_LAUNCHED_VMS_TYPE = ["POST_STD_VM", "POST_RT_VM"] POST_LAUNCHED_VMS_TYPE = ["POST_STD_VM", "POST_RT_VM"]
@ -60,7 +61,7 @@ def parse_hv_console(scenario_etree):
4. "None" 4. "None"
""" """
ttys_n = '' ttys_n = ''
ttys = common.get_node("//SERIAL_CONSOLE/text()", scenario_etree) ttys = get_node("//SERIAL_CONSOLE/text()", scenario_etree)
if not ttys or ttys == None or ttys == 'None': if not ttys or ttys == None or ttys == 'None':
return ttys_n return ttys_n
@ -74,7 +75,7 @@ def parse_hv_console(scenario_etree):
def get_native_ttys(): def get_native_ttys():
native_ttys = {} native_ttys = {}
ttys_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>") ttys_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
if ttys_lines: if ttys_lines:
for tty_line in ttys_lines: for tty_line in ttys_lines:
tmp_dic = {} tmp_dic = {}
@ -98,18 +99,18 @@ def get_ivshmem_regions_by_tree(etree):
ivshmem_regions = etree.xpath("//IVSHMEM_REGION") ivshmem_regions = etree.xpath("//IVSHMEM_REGION")
shmem_regions = {} shmem_regions = {}
for idx in range(len(ivshmem_regions)): for idx in range(len(ivshmem_regions)):
provided_by = common.get_node("./PROVIDED_BY/text()", ivshmem_regions[idx]) provided_by = get_node("./PROVIDED_BY/text()", ivshmem_regions[idx])
if provided_by != "Hypervisor": if provided_by != "Hypervisor":
continue continue
shm_name = common.get_node("./NAME/text()", ivshmem_regions[idx]) shm_name = get_node("./NAME/text()", ivshmem_regions[idx])
if shm_name is None: if shm_name is None:
continue continue
shm_size = common.get_node("./IVSHMEM_SIZE/text()", ivshmem_regions[idx]) shm_size = get_node("./IVSHMEM_SIZE/text()", ivshmem_regions[idx])
shm_vm_list = ivshmem_regions[idx].xpath(".//IVSHMEM_VM") shm_vm_list = ivshmem_regions[idx].xpath(".//IVSHMEM_VM")
for shm_vm in shm_vm_list: for shm_vm in shm_vm_list:
vm_name = common.get_node("./VM_NAME/text()", shm_vm) vm_name = get_node("./VM_NAME/text()", shm_vm)
vm_id = common.get_node(f"//vm[name = '{vm_name}']/@id", etree) vm_id = get_node(f"//vm[name = '{vm_name}']/@id", etree)
vbdf = common.get_node("./VBDF/text()", shm_vm) vbdf = get_node("./VBDF/text()", shm_vm)
if vm_id not in shmem_regions: if vm_id not in shmem_regions:
shmem_regions[vm_id] = {} shmem_regions[vm_id] = {}
shmem_regions[vm_id][shm_name] = {'id' : str(idx), 'size' : shm_size, 'vbdf' : vbdf} shmem_regions[vm_id][shm_name] = {'id' : str(idx), 'size' : shm_size, 'vbdf' : vbdf}

View File

@ -9,15 +9,15 @@ import sys, os
import lxml.etree import lxml.etree
import argparse import argparse
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common import acrn_config_utilities
from importlib import import_module from importlib import import_module
def main(args): def main(args):
# Initialize configuration libraries for backward compatibility # Initialize configuration libraries for backward compatibility
common.BOARD_INFO_FILE = args.board acrn_config_utilities.BOARD_INFO_FILE = args.board
common.SCENARIO_INFO_FILE = args.scenario acrn_config_utilities.SCENARIO_INFO_FILE = args.scenario
common.get_vm_num(args.scenario) acrn_config_utilities.get_vm_num(args.scenario)
common.get_load_order() acrn_config_utilities.get_load_order()
scripts_path = os.path.dirname(os.path.realpath(__file__)) scripts_path = os.path.dirname(os.path.realpath(__file__))
current = os.path.basename(__file__) current = os.path.basename(__file__)

View File

@ -9,15 +9,16 @@ import os
import sys import sys
import logging import logging
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, math, logging import acrn_config_utilities, math, logging
from acrn_config_utilities import get_node
class RamRange(): class RamRange():
ram_range = {} ram_range = {}
@classmethod @classmethod
def import_memory_info(cls, board_etree, allocation_etree): def import_memory_info(cls, board_etree, allocation_etree):
hv_start = int(common.get_node("/acrn-config/hv/MEMORY/HV_RAM_START/text()", allocation_etree), 16) hv_start = int(get_node("/acrn-config/hv/MEMORY/HV_RAM_START/text()", allocation_etree), 16)
hv_size = int(common.get_node("/acrn-config/hv/MEMORY/HV_RAM_SIZE/text()", allocation_etree), 16) hv_size = int(get_node("/acrn-config/hv/MEMORY/HV_RAM_SIZE/text()", allocation_etree), 16)
for memory_range in board_etree.xpath("/acrn-config/memory/range[not(@id) or @id = 'RAM']"): for memory_range in board_etree.xpath("/acrn-config/memory/range[not(@id) or @id = 'RAM']"):
start = int(memory_range.get("start"), base=16) start = int(memory_range.get("start"), base=16)
size = int(memory_range.get("size"), base=10) size = int(memory_range.get("size"), base=10)
@ -45,7 +46,7 @@ class RamRange():
size_hpa = [] size_hpa = []
hpa_info = {} hpa_info = {}
size_node = common.get_node("./memory/size", vm_node_info) size_node = get_node("./memory/size", vm_node_info)
if size_node is not None: if size_node is not None:
size_byte = int(size_node.text) * 0x100000 size_byte = int(size_node.text) * 0x100000
hpa_info[0] = size_byte hpa_info[0] = size_byte
@ -137,26 +138,26 @@ def write_hpa_info(allocation_etree, mem_info_list, vm_node_index_list):
for i in range(len(vm_node_index_list)): for i in range(len(vm_node_index_list)):
vm_id = vm_node_index_list[i] vm_id = vm_node_index_list[i]
hpa_info = mem_info_list[i] hpa_info = mem_info_list[i]
vm_node = common.get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree) vm_node = get_node(f"/acrn-config/vm[@id = '{vm_id}']", allocation_etree)
if vm_node is None: if vm_node is None:
vm_node = common.append_node("/acrn-config/vm", None, allocation_etree, id=vm_id) vm_node = acrn_config_utilities.append_node("/acrn-config/vm", None, allocation_etree, id=vm_id)
memory_node = common.get_node("./memory", vm_node) memory_node = get_node("./memory", vm_node)
if memory_node is None: if memory_node is None:
memory_node = common.append_node(f"./memory", None, vm_node) memory_node = acrn_config_utilities.append_node(f"./memory", None, vm_node)
region_index = 1 region_index = 1
start_key = sorted(hpa_info) start_key = sorted(hpa_info)
for start_hpa in start_key: for start_hpa in start_key:
hpa_region_node = common.get_node(f"./hpa_region[@id='{region_index}']", memory_node) hpa_region_node = get_node(f"./hpa_region[@id='{region_index}']", memory_node)
if hpa_region_node is None: if hpa_region_node is None:
hpa_region_node = common.append_node("./hpa_region", None, memory_node, id=str(region_index).encode('UTF-8')) hpa_region_node = acrn_config_utilities.append_node("./hpa_region", None, memory_node, id=str(region_index).encode('UTF-8'))
start_hpa_node = common.get_node("./start_hpa", hpa_region_node) start_hpa_node = get_node("./start_hpa", hpa_region_node)
if start_hpa_node is None: if start_hpa_node is None:
common.append_node("./start_hpa", hex(start_hpa), hpa_region_node) acrn_config_utilities.append_node("./start_hpa", hex(start_hpa), hpa_region_node)
size_hpa_node = common.get_node("./size_hpa", hpa_region_node) size_hpa_node = get_node("./size_hpa", hpa_region_node)
if size_hpa_node is None: if size_hpa_node is None:
common.append_node("./size_hpa", hex(hpa_info[start_hpa]), hpa_region_node) acrn_config_utilities.append_node("./size_hpa", hex(hpa_info[start_hpa]), hpa_region_node)
region_index = region_index + 1 region_index = region_index + 1
def alloc_vm_memory(board_etree, scenario_etree, allocation_etree): def alloc_vm_memory(board_etree, scenario_etree, allocation_etree):
@ -175,7 +176,7 @@ def allocate_hugepages(board_etree, scenario_etree, allocation_etree):
post_launch_vms = scenario_etree.xpath("//vm[load_order = 'POST_LAUNCHED_VM']") post_launch_vms = scenario_etree.xpath("//vm[load_order = 'POST_LAUNCHED_VM']")
if len(post_launch_vms) > 0: if len(post_launch_vms) > 0:
for post_launch_vm in post_launch_vms: for post_launch_vm in post_launch_vms:
size = common.get_node("./memory/size/text()", post_launch_vm) size = get_node("./memory/size/text()", post_launch_vm)
if size is not None: if size is not None:
mb, gb = math.modf(int(size)/1024) mb, gb = math.modf(int(size)/1024)
hugepages_1gb = int(hugepages_1gb + gb) hugepages_1gb = int(hugepages_1gb + gb)
@ -186,10 +187,10 @@ def allocate_hugepages(board_etree, scenario_etree, allocation_etree):
logging.debug(f"The sum {post_vms_memory} of memory configured in post launch VMs should not be larger than " \ logging.debug(f"The sum {post_vms_memory} of memory configured in post launch VMs should not be larger than " \
f"the calculated total hugepages {total_hugepages} of service VMs. Please update the configuration in post launch VMs") f"the calculated total hugepages {total_hugepages} of service VMs. Please update the configuration in post launch VMs")
allocation_service_vm_node = common.get_node("/acrn-config/vm[load_order = 'SERVICE_VM']", allocation_etree) allocation_service_vm_node = get_node("/acrn-config/vm[load_order = 'SERVICE_VM']", allocation_etree)
if allocation_service_vm_node is not None: if allocation_service_vm_node is not None:
common.append_node("./hugepages/gb", int(hugepages_1gb), allocation_service_vm_node) acrn_config_utilities.append_node("./hugepages/gb", int(hugepages_1gb), allocation_service_vm_node)
common.append_node("./hugepages/mb", int(hugepages_2mb), allocation_service_vm_node) acrn_config_utilities.append_node("./hugepages/mb", int(hugepages_2mb), allocation_service_vm_node)
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
alloc_vm_memory(board_etree, scenario_etree, allocation_etree) alloc_vm_memory(board_etree, scenario_etree, allocation_etree)

View File

@ -7,7 +7,7 @@
import sys, os, logging import sys, os, logging
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
import common, lib.lib, lib.error import lib.lib, lib.error
def fn(board_etree, scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree):
# With the console vUART explicitly specified as COM port and communication vUART with explicit I/O port base # With the console vUART explicitly specified as COM port and communication vUART with explicit I/O port base

View File

@ -6,32 +6,33 @@
# #
import sys import sys
import common, lib.error import acrn_config_utilities, lib.error
from acrn_config_utilities import get_node
# The COM1 was used for console vUART, so we alloc io_port frome COM2~COM4 # The COM1 was used for console vUART, so we alloc io_port frome COM2~COM4
service_port_list = list(range(0x9000, 0x9100, 8)) service_port_list = list(range(0x9000, 0x9100, 8))
def create_s5_vuart_connection(allocation_etree, service_vm_name, service_vm_port, user_vm_name, user_vm_port): def create_s5_vuart_connection(allocation_etree, service_vm_name, service_vm_port, user_vm_name, user_vm_port):
vuart_connections_node = common.get_node(f"/acrn-config/hv/vuart_connections", allocation_etree) vuart_connections_node = get_node(f"/acrn-config/hv/vuart_connections", allocation_etree)
if vuart_connections_node is None: if vuart_connections_node is None:
vuart_connections_node = common.append_node("/acrn-config/hv/vuart_connections", None, allocation_etree) vuart_connections_node = acrn_config_utilities.append_node("/acrn-config/hv/vuart_connections", None, allocation_etree)
connection_name = service_vm_name + "_" + user_vm_name connection_name = service_vm_name + "_" + user_vm_name
vuart_connection_node = common.append_node(f"./vuart_connection", None, vuart_connections_node) vuart_connection_node = acrn_config_utilities.append_node(f"./vuart_connection", None, vuart_connections_node)
common.append_node(f"./name", connection_name, vuart_connection_node) acrn_config_utilities.append_node(f"./name", connection_name, vuart_connection_node)
common.append_node(f"./type", "legacy", vuart_connection_node) acrn_config_utilities.append_node(f"./type", "legacy", vuart_connection_node)
service_vm_endpoint = common.append_node(f"./endpoint", None, vuart_connection_node) service_vm_endpoint = acrn_config_utilities.append_node(f"./endpoint", None, vuart_connection_node)
common.append_node(f"./vm_name", service_vm_name, service_vm_endpoint) acrn_config_utilities.append_node(f"./vm_name", service_vm_name, service_vm_endpoint)
common.append_node(f"./io_port", service_vm_port, service_vm_endpoint) acrn_config_utilities.append_node(f"./io_port", service_vm_port, service_vm_endpoint)
user_vm_endpoint = common.append_node(f"./endpoint", None, vuart_connection_node) user_vm_endpoint = acrn_config_utilities.append_node(f"./endpoint", None, vuart_connection_node)
common.append_node(f"./vm_name", user_vm_name, user_vm_endpoint) acrn_config_utilities.append_node(f"./vm_name", user_vm_name, user_vm_endpoint)
common.append_node(f"./io_port", user_vm_port, user_vm_endpoint) acrn_config_utilities.append_node(f"./io_port", user_vm_port, user_vm_endpoint)
def get_console_vuart_port(scenario_etree, vm_name): def get_console_vuart_port(scenario_etree, vm_name):
port = common.get_node(f"//vm[name = '{vm_name}']/console_vuart/text()", scenario_etree) port = get_node(f"//vm[name = '{vm_name}']/console_vuart/text()", scenario_etree)
if port == "COM Port 1": if port == "COM Port 1":
port = "0x3F8U" port = "0x3F8U"
@ -68,16 +69,16 @@ def alloc_free_port(scenario_etree, load_order, vm_name):
def alloc_vuart_connection_info(board_etree, scenario_etree, allocation_etree): def alloc_vuart_connection_info(board_etree, scenario_etree, allocation_etree):
user_vm_list = scenario_etree.xpath(f"//vm[load_order != 'SERVICE_VM']") user_vm_list = scenario_etree.xpath(f"//vm[load_order != 'SERVICE_VM']")
service_vm_id = common.get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree) service_vm_id = get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree)
service_vm_name = common.get_node(f"//vm[load_order = 'SERVICE_VM']/name/text()", scenario_etree) service_vm_name = get_node(f"//vm[load_order = 'SERVICE_VM']/name/text()", scenario_etree)
if (service_vm_id is None) or (service_vm_name is None): if (service_vm_id is None) or (service_vm_name is None):
return return
for index,vm_node in enumerate(user_vm_list): for index,vm_node in enumerate(user_vm_list):
vm_id = common.get_node("./@id", vm_node) vm_id = get_node("./@id", vm_node)
load_order = common.get_node("./load_order/text()", vm_node) load_order = get_node("./load_order/text()", vm_node)
user_vm_name = common.get_node(f"./name/text()", vm_node) user_vm_name = get_node(f"./name/text()", vm_node)
service_vm_port = alloc_free_port(scenario_etree, "SERVICE_VM", user_vm_name) service_vm_port = alloc_free_port(scenario_etree, "SERVICE_VM", user_vm_name)
user_vm_port = alloc_free_port(scenario_etree, load_order, user_vm_name) user_vm_port = alloc_free_port(scenario_etree, load_order, user_vm_name)