Exemple #1
0
def fn(board_etree, scenario_etree, allocation_etree):
    # this dictonary mapped with 'address start':'mem range'
    ram_range = {}

    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_node("//IVSHMEM_ENABLED/text()",
                                      scenario_etree)
    total_shm_size = 0
    if ivshmem_enabled == 'y':
        raw_shmem_regions = scenario_etree.xpath("//IVSHMEM_REGION/text()")
        for raw_shm in raw_shmem_regions:
            if raw_shm.strip() == '':
                continue
            raw_shm_splited = raw_shm.split(',')
            if len(raw_shm_splited) == 3 and raw_shm_splited[0].strip() != '' \
                    and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1:
                try:
                    size = raw_shm_splited[1].strip()
                    int_size = int(size) * 0x100000
                    total_shm_size += int_size
                except Exception as e:
                    print(e)
    hv_ram_size += 2 * max(total_shm_size, 0x200000)
    assert (hv_ram_size <= HV_RAM_SIZE_MAX)

    # reseve 16M memory for hv sbuf, ramoops, etc.
    reserved_ram = 0x1000000
    # We recommend to put hv ram start address high than 0x10000000 to
    # reduce memory conflict with GRUB/SOS Kernel.
    hv_start_offset = 0x10000000
    total_size = reserved_ram + hv_ram_size
    for start_addr in list(board_cfg_lib.USED_RAM_RANGE):
        if hv_start_offset <= start_addr < 0x80000000:
            del board_cfg_lib.USED_RAM_RANGE[start_addr]
    ram_range = board_cfg_lib.get_ram_range()
    avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(total_size),
                                                   hv_start_offset)
    hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
    hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
    board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = total_size

    common.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)
Exemple #2
0
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]

    ivshmem_enabled = common.get_text("//IVSHMEM_ENABLED", scenario_etree)
    total_shm_size = 0
    if ivshmem_enabled == 'y':
        raw_shmem_regions = scenario_etree.xpath("//IVSHMEM_REGION/text()")
        for raw_shm in raw_shmem_regions:
            if raw_shm.strip() == '':
                continue
            raw_shm_splited = raw_shm.split(',')
            if len(raw_shm_splited) == 3 and raw_shm_splited[0].strip() != '' \
                    and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1:
                try:
                    size = raw_shm_splited[1].strip()
                    int_size = int(size) * 0x100000
                    total_shm_size += int_size
                except Exception as e:
                    print(e)
    hv_ram_size += total_shm_size
    assert (hv_ram_size <= HV_RAM_SIZE_MAX)

    # reseve 16M memory for hv sbuf, ramoops, etc.
    reserved_ram = 0x1000000
    # We recommend to put hv ram start address high than 0x10000000 to
    # reduce memory conflict with GRUB/SOS Kernel.
    hv_start_offset = 0x10000000
    total_size = reserved_ram + hv_ram_size
    for start_addr in list(board_cfg_lib.USED_RAM_RANGE):
        if hv_start_offset <= start_addr < 0x80000000:
            del board_cfg_lib.USED_RAM_RANGE[start_addr]
    ram_range = board_cfg_lib.get_ram_range()
    avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(total_size),
                                                   hv_start_offset)
    hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
    hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
    board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = total_size

    common.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)
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

    # reseve 16M memory for hv sbuf, ramoops, etc.
    reserved_ram = 0x1000000
    # We recommend to put hv ram start address high than 0x10000000 to
    # reduce memory conflict with GRUB/SOS Kernel.
    hv_start_offset = 0x10000000
    total_size = reserved_ram + hv_ram_size
    for start_addr in list(board_cfg_lib.USED_RAM_RANGE):
        if hv_start_offset <= start_addr < 0x80000000:
            del board_cfg_lib.USED_RAM_RANGE[start_addr]
    ram_range = board_cfg_lib.get_ram_range()
    avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(total_size), hv_start_offset)
    hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
    hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
    board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = total_size

    if not hv_info.mem.hv_ram_start:
        print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
    else:
        print("CONFIG_HV_RAM_START={}".format(hv_info.mem.hv_ram_start), file=config)
    if not hv_info.mem.hv_ram_size:
        print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
    else:
        print("CONFIG_HV_RAM_SIZE={}".format(hv_info.mem.hv_ram_size), file=config)

    print("CONFIG_PLATFORM_RAM_SIZE={}".format(hv_info.mem.platform_ram_size), file=config)
    print("CONFIG_LOW_RAM_SIZE={}".format(hv_info.mem.low_ram_size), file=config)
    print("CONFIG_SOS_RAM_SIZE={}".format(hv_info.mem.sos_ram_size), file=config)
    print("CONFIG_UOS_RAM_SIZE={}".format(hv_info.mem.uos_ram_size), file=config)
    print("CONFIG_STACK_SIZE={}".format(hv_info.mem.stack_size), file=config)
    print("CONFIG_IVSHMEM_ENABLED={}".format(hv_info.mem.ivshmem_enable), file=config)
Exemple #4
0
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

    ivshmem_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE,
                                             "FEATURES", "IVSHMEM",
                                             "IVSHMEM_ENABLED")
    total_shm_size = 0
    if ivshmem_enabled == 'y':
        raw_shmem_regions = common.get_hv_item_tag(common.SCENARIO_INFO_FILE,
                                                   "FEATURES", "IVSHMEM",
                                                   "IVSHMEM_REGION")
        for raw_shm in raw_shmem_regions:
            if raw_shm is None or raw_shm.strip() == '':
                continue
            raw_shm_splited = raw_shm.split(',')
            if len(raw_shm_splited) == 3 and raw_shm_splited[0].strip() != '' \
                    and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1:
                try:
                    size = raw_shm_splited[1].strip()
                    int_size = int(size) * 0x100000
                    total_shm_size += int_size
                except Exception as e:
                    print(e)

    hv_ram_size += total_shm_size
    if hv_ram_size > HV_RAM_SIZE_MAX:
        common.print_red("requested RAM size should be smaller then {}".format(
            HV_RAM_SIZE_MAX),
                         err=True)
        err_dic["board config: total vm number error"] = \
            "requested RAM size should be smaller then {}".format(HV_RAM_SIZE_MAX)
        return err_dic

    # reseve 16M memory for hv sbuf, ramoops, etc.
    reserved_ram = 0x1000000
    # We recommend to put hv ram start address high than 0x10000000 to
    # reduce memory conflict with GRUB/SOS Kernel.
    hv_start_offset = 0x10000000
    total_size = reserved_ram + hv_ram_size
    for start_addr in list(board_cfg_lib.USED_RAM_RANGE):
        if hv_start_offset <= start_addr < 0x80000000:
            del board_cfg_lib.USED_RAM_RANGE[start_addr]
    ram_range = board_cfg_lib.get_ram_range()
    avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(total_size),
                                                   hv_start_offset)
    hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
    hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
    board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = total_size

    if not hv_info.mem.hv_ram_start:
        print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
    else:
        print("CONFIG_HV_RAM_START={}".format(hv_info.mem.hv_ram_start),
              file=config)
    if not hv_info.mem.hv_ram_size:
        print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
    else:
        print("CONFIG_HV_RAM_SIZE={}".format(hv_info.mem.hv_ram_size),
              file=config)

    print("CONFIG_PLATFORM_RAM_SIZE={}".format(hv_info.mem.platform_ram_size),
          file=config)
    print("CONFIG_LOW_RAM_SIZE={}".format(hv_info.mem.low_ram_size),
          file=config)
    print("CONFIG_SOS_RAM_SIZE={}".format(hv_info.mem.sos_ram_size),
          file=config)
    print("CONFIG_UOS_RAM_SIZE={}".format(hv_info.mem.uos_ram_size),
          file=config)
    print("CONFIG_STACK_SIZE={}".format(hv_info.mem.stack_size), file=config)
    print("CONFIG_IVSHMEM_ENABLED={}".format(hv_info.mem.ivshmem_enable),
          file=config)
def get_memory(hv_info, config):

    # this dictonary mapped with 'address start':'mem range'
    ram_range = {}

    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
    if ivshmem_enabled == 'y':
        raw_shmem_regions = common.get_hv_item_tag(common.SCENARIO_INFO_FILE,
                                                   "FEATURES", "IVSHMEM",
                                                   "IVSHMEM_REGION")
        for raw_shm in raw_shmem_regions:
            if raw_shm is None or raw_shm.strip() == '':
                continue
            raw_shm_splited = raw_shm.split(',')
            if len(raw_shm_splited) == 3 and raw_shm_splited[0].strip() != '' \
                    and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1:
                try:
                    size = raw_shm_splited[1].strip()
                    int_size = int(size) * 0x100000
                    total_shm_size += int_size
                except Exception as e:
                    print(e)

    hv_ram_size += 2 * max(total_shm_size, 0x200000)
    if hv_ram_size > HV_RAM_SIZE_MAX:
        common.print_red("requested RAM size should be smaller then {}".format(
            HV_RAM_SIZE_MAX),
                         err=True)
        err_dic["board config: total vm number error"] = \
            "requested RAM size should be smaller then {}".format(HV_RAM_SIZE_MAX)
        return err_dic

    # reseve 16M memory for hv sbuf, ramoops, etc.
    reserved_ram = 0x1000000
    # We recommend to put hv ram start address high than 0x10000000 to
    # reduce memory conflict with GRUB/SOS Kernel.
    hv_start_offset = 0x10000000
    total_size = reserved_ram + hv_ram_size
    for start_addr in list(board_cfg_lib.USED_RAM_RANGE):
        if hv_start_offset <= start_addr < 0x80000000:
            del board_cfg_lib.USED_RAM_RANGE[start_addr]
    ram_range = board_cfg_lib.get_ram_range()
    avl_start_addr = board_cfg_lib.find_avl_memory(ram_range, str(total_size),
                                                   hv_start_offset)
    hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
    hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
    board_cfg_lib.USED_RAM_RANGE[hv_start_addr] = total_size

    if not hv_info.mem.hv_ram_start:
        print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
    else:
        print("CONFIG_HV_RAM_START={}".format(hv_info.mem.hv_ram_start),
              file=config)
    if not hv_info.mem.hv_ram_size:
        print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
    else:
        print("CONFIG_HV_RAM_SIZE={}".format(hv_info.mem.hv_ram_size),
              file=config)

    print("CONFIG_PLATFORM_RAM_SIZE={}".format(hv_info.mem.platform_ram_size),
          file=config)
    print("CONFIG_LOW_RAM_SIZE={}".format(hv_info.mem.low_ram_size),
          file=config)
    print("CONFIG_STACK_SIZE={}".format(hv_info.mem.stack_size), file=config)
    print("CONFIG_IVSHMEM_ENABLED={}".format(hv_info.mem.ivshmem_enable),
          file=config)