mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-07 09:41:30 +00:00
1.the script will parse the the board information which already
generated, $(scenario).xml modified by user, generate scenario
vm configuration and apply to the acrn-hypervisor source code base.
2.parse cpu/memory/ttys/rootfs information from native os and store it to
the source code
3.implemnt scenario_config and it's usage
usage: scenario_cfg_gen.py --board <board_info_file> -scenario <scenario_info_file>
board_info_file : file name of the board info
scenario_info_file : file name of the scenario info
sample:
$ python3 scenario_cfg_gen.py --board ../board-xmls/apl-mrb.xml
--scenario ../config-xmls/scenarios/sdc.xml
Also improvement board config generate usage:
sample:
$ python3 board_cfg_gen.py --board ../board-xmls/apl-mrb.xml
--scenario ../config-xmls/scenarios/sdc.xml
V1-V2:
1). parse board_setting.xml was removed as these configuration will be
stitch into scenario configuration
2). parse console for different formats
3). parse epc sections
4). add logical partition rootfs
5). support to parse clos, while webui set to None type
6). support to parse bootargs, while webui set to nul
7). convert '-' to '_' for pci sub class name while generating source file
Tracked-On: #3602
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Terry Zou <terry.zou@intel.com>
93 lines
2.4 KiB
Python
93 lines
2.4 KiB
Python
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
#
|
|
|
|
import sys
|
|
import board_cfg_lib
|
|
|
|
|
|
DESC = """
|
|
# New board kconfig generated by vm config tool
|
|
# Modified by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
|
|
"""
|
|
|
|
VM_NUM_MAP_TOTAL_HV_RAM_SIZE = {
|
|
# 120M
|
|
2:'0x7800000',
|
|
# 150M
|
|
3:'0x9600000',
|
|
# 180M
|
|
4:'0xB400000',
|
|
# 210M
|
|
5:'0xD200000',
|
|
# 240M
|
|
6:'0xF000000',
|
|
# 270M
|
|
7:'0x10E00000',
|
|
}
|
|
|
|
|
|
def get_addr_for_hv(ram_range, hpa_size):
|
|
"""
|
|
This is get hv address from System RAM as host physical size
|
|
:param ram_range: System RAM mapping
|
|
:param hpa_size: fixed host physical size
|
|
:return: start host physical address
|
|
"""
|
|
ret_start_addr = 0
|
|
tmp_order_key = 0
|
|
|
|
tmp_order_key = sorted(ram_range)
|
|
for start_addr in tmp_order_key:
|
|
mem_range = ram_range[start_addr]
|
|
if mem_range > int(hpa_size, 16):
|
|
ret_start_addr = start_addr
|
|
break
|
|
|
|
return hex(ret_start_addr)
|
|
|
|
|
|
def get_ram_range():
|
|
""" Get System RAM range mapping """
|
|
# read system ram from board_info.xml
|
|
ram_range = {}
|
|
|
|
sys_mem_lines = board_cfg_lib.get_info(
|
|
board_cfg_lib.BOARD_INFO_FILE, "<SYSTEM_RAM_INFO>", "</SYSTEM_RAM_INFO>")
|
|
for line in sys_mem_lines:
|
|
start_addr = int(line.split('-')[0], 16)
|
|
end_addr = int(line.split('-')[1].split(':')[0], 16)
|
|
mem_range = end_addr - start_addr
|
|
ram_range[start_addr] = mem_range
|
|
|
|
return ram_range
|
|
|
|
|
|
def generate_file(config):
|
|
"""Start to generate board.c
|
|
:param config: it is a file pointer of board information for writing to
|
|
"""
|
|
err_dic = {}
|
|
# this dictonary mapped with 'address start':'mem range'
|
|
ram_range = {}
|
|
|
|
if board_cfg_lib.VM_COUNT in list(VM_NUM_MAP_TOTAL_HV_RAM_SIZE.keys()):
|
|
hv_ram_size = VM_NUM_MAP_TOTAL_HV_RAM_SIZE[board_cfg_lib.VM_COUNT]
|
|
else:
|
|
board_cfg_lib.print_red("VM num should not greater than 8", err=True)
|
|
err_dic["baord config: total vm number error"] = "VM num should not greater than 8"
|
|
return err_dic
|
|
|
|
ram_range = get_ram_range()
|
|
hv_start_addr = get_addr_for_hv(ram_range, hv_ram_size)
|
|
|
|
print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config)
|
|
print("{}".format(DESC), file=config)
|
|
|
|
print("CONFIG_HV_RAM_START={}".format(hv_start_addr), file=config)
|
|
|
|
print("CONFIG_HV_RAM_SIZE={}".format(hv_ram_size), file=config)
|
|
|
|
return err_dic
|