diff --git a/misc/config_tools/hv_config/board_defconfig.py b/misc/config_tools/hv_config/board_defconfig.py index f879f20d3..b9dcd2b4b 100644 --- a/misc/config_tools/hv_config/board_defconfig.py +++ b/misc/config_tools/hv_config/board_defconfig.py @@ -5,7 +5,7 @@ import sys import subprocess -import board_cfg_lib +import board_cfg_lib, scenario_cfg_lib import hv_cfg_lib import common @@ -13,23 +13,6 @@ import common DESC = """# Board defconfig generated by acrn-config tool """ -VM_NUM_MAP_TOTAL_HV_RAM_SIZE = { - # 120M - 2:0x7800000, - # 150M - 3:0x9600000, - # 190M - 4:0xBE00000, - # 210M - 5:0xD200000, - # 250M - 6:0xFA00000, - # 300M - 7:0x12C00000, - # 328M - 8:0x14800000, -} - HV_RAM_SIZE_MAX = 0x40000000 MEM_ALIGN = 2 * common.SIZE_M @@ -74,12 +57,12 @@ def get_memory(hv_info, config): # this dictonary mapped with 'address start':'mem range' ram_range = {} - if common.VM_COUNT in list(VM_NUM_MAP_TOTAL_HV_RAM_SIZE.keys()): - hv_ram_size = VM_NUM_MAP_TOTAL_HV_RAM_SIZE[common.VM_COUNT] - else: - common.print_red("VM num should not be greater than 8", err=True) - err_dic["board config: total vm number error"] = "VM num should not be greater than 8" - return err_dic + post_launched_vm_num = 0 + for id in common.VM_TYPES: + if common.VM_TYPES[id] in scenario_cfg_lib.VM_DB and \ + scenario_cfg_lib.VM_DB[common.VM_TYPES[id]]["load_type"] == "POST_LAUNCHED_VM": + post_launched_vm_num += 1 + hv_ram_size = common.HV_BASE_RAM_SIZE + common.POST_LAUNCHED_VM_RAM_SIZE * post_launched_vm_num ivshmem_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED") total_shm_size = 0 diff --git a/misc/config_tools/library/common.py b/misc/config_tools/library/common.py index c3e7a36e5..4a9143f9b 100644 --- a/misc/config_tools/library/common.py +++ b/misc/config_tools/library/common.py @@ -40,6 +40,9 @@ MAX_VM_NUM = 8 MAX_VUART_NUM = 8 +HV_BASE_RAM_SIZE = 0x1400000 +POST_LAUNCHED_VM_RAM_SIZE = 0x1000000 + class MultiItem(): def __init__(self): diff --git a/misc/config_tools/static_allocators/hv_ram.py b/misc/config_tools/static_allocators/hv_ram.py index 662bfdbcd..5c4a76c88 100644 --- a/misc/config_tools/static_allocators/hv_ram.py +++ b/misc/config_tools/static_allocators/hv_ram.py @@ -7,24 +7,7 @@ import sys, os sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library')) -import common, board_cfg_lib - -VM_NUM_MAP_TOTAL_HV_RAM_SIZE = { - # 120M - 2:0x7800000, - # 150M - 3:0x9600000, - # 190M - 4:0xBE00000, - # 210M - 5:0xD200000, - # 250M - 6:0xFA00000, - # 300M - 7:0x12C00000, - # 328M - 8:0x14800000, -} +import common, board_cfg_lib, scenario_cfg_lib HV_RAM_SIZE_MAX = 0x40000000 @@ -34,8 +17,12 @@ def fn(board_etree, scenario_etree, allocation_etree): # this dictonary mapped with 'address start':'mem range' ram_range = {} - vm_count = common.count_nodes("//*[local-name() = 'vm']", scenario_etree) - hv_ram_size = VM_NUM_MAP_TOTAL_HV_RAM_SIZE[vm_count] + post_launched_vm_num = 0 + for id in common.VM_TYPES: + if common.VM_TYPES[id] in scenario_cfg_lib.VM_DB and \ + scenario_cfg_lib.VM_DB[common.VM_TYPES[id]]["load_type"] == "POST_LAUNCHED_VM": + post_launched_vm_num += 1 + hv_ram_size = common.HV_BASE_RAM_SIZE + common.POST_LAUNCHED_VM_RAM_SIZE * post_launched_vm_num ivshmem_enabled = common.get_text("//IVSHMEM_ENABLED", scenario_etree) total_shm_size = 0