acrn-config: make ivshmem size configured in decimal and MB

make ivshmem size configured in decimal and MB in config tool
UI and XMLs to simplify input from users.

Tracked-On: #4853

Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Shuang Zheng 2020-09-15 10:29:36 +08:00 committed by wenlingz
parent ce2a82479b
commit 08ca320130
5 changed files with 15 additions and 33 deletions

View File

@ -93,10 +93,7 @@ def get_memory(hv_info, config):
and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1:
try:
size = raw_shm_splited[1].strip()
if size.isdecimal():
int_size = int(size)
else:
int_size = int(size, 16)
int_size = int(size) * 0x100000
total_shm_size += int_size
except Exception as e:
print(e)

View File

@ -34,7 +34,7 @@ KNOWN_HIDDEN_PDEVS_BOARD_DB = {
TSN_DEVS = ["8086:4b30", "8086:4b31", "8086:4b32", "8086:4ba0", "8086:4ba1", "8086:4ba2",
"8086:4bb0", "8086:4bb1", "8086:4bb2", "8086:a0ac", "8086:43ac", "8086:43a2"]
GPIO_DEVS = ["8086:4b88", "8086:4b89"]
TPM_PASSTHRU_BOARD = ['whl-ipc-i5', 'whl-ipc-i7', 'tgl-rvp', 'ehl-crb-b']
TPM_PASSTHRU_BOARD = ['whl-ipc-i5', 'whl-ipc-i7', 'tgl-rvp']
KNOWN_CAPS_PCI_DEVS_DB = {
"VMSIX":TSN_DEVS + GPIO_DEVS,
@ -496,10 +496,10 @@ def parse_mem():
name = shm_splited[0].strip()
size = shm_splited[1].strip()
if size.isdecimal():
int_size = int(size)
else:
int_size = int(size, 16)
try:
int_size = int(size) * 0x100000
except:
int_size = 0
ram_range = get_ram_range()
tmp_bar_dict = {}
hv_start_offset = 0x80000000

View File

@ -591,13 +591,9 @@ def set_shm_regions(launch_item_values, scenario_info):
shm_splited = shmem_region.split(',')
name = shm_splited[0].strip()
size = shm_splited[1].strip()
if size.isdecimal():
int_size = int(size)
else:
int_size = int(size, 16)
vm_id_list = [x.strip() for x in shm_splited[2].split(':')]
if str(vm_id) in vm_id_list:
launch_item_values[shm_region_key].append(','.join([name, str(int_size)]))
launch_item_values[shm_region_key].append(','.join([name, size]))
except Exception as e:
print(e)
@ -609,9 +605,7 @@ def check_shm_regions(launch_shm_regions, scenario_info):
for uos_id, shm_regions in launch_shm_regions.items():
shm_region_key = 'uos:id={},shm_regions,shm_region'.format(uos_id)
for shm_region in shm_regions:
print(shm_region)
print(launch_item_values[shm_region_key])
if shm_region_key not in launch_item_values.keys() or shm_region not in launch_item_values[shm_region_key]:
ERR_LIST[shm_region_key] = "shm {} should be configured in scenario setting and the size should be decimal" \
" and spaces should not exist.".format(shm_region)
"in MB and spaces should not exist.".format(shm_region)
return

View File

@ -724,7 +724,7 @@ def share_mem_check(shmem_regions, raw_shmem_regions, vm_type_info, prime_item,
try:
curr_vm_id = int(shm_i)
except:
ERR_LIST[key] = "share memory region should be configured with format like this: hv:/shm_region_0, 0x200000, 0:2"
ERR_LIST[key] = "share memory region should be configured with format like this: hv:/shm_region_0, 2, 0:2"
return
name = shm_str_splited[0].strip()
size = shm_str_splited[1].strip()
@ -759,12 +759,9 @@ def share_mem_check(shmem_regions, raw_shmem_regions, vm_type_info, prime_item,
int_size = 0
try:
if size.isdecimal():
int_size = int(size)
else:
int_size = int(size, 16)
int_size = int(size) * 0x100000
except:
ERR_LIST[key] = "The size of share Memory region should be decimal or hexadecimal."
ERR_LIST[key] = "The size of share Memory region should be decimal."
return
if int_size < 0x200000 or int_size > 0x20000000:
ERR_LIST[key] = "The size of share Memory region should be in [2MB, 512MB]."

View File

@ -54,10 +54,7 @@ def write_shmem_regions(config):
int_size = 0
size = shmem_region[1]
try:
if size.isdecimal():
int_size = int(size)
else:
int_size = int(size, 16)
int_size = int(size) * 0x100000
except Exception as e:
print('the format of shm size error: ', str(e))
total_shm_size += int_size
@ -75,13 +72,10 @@ def write_shmem_regions(config):
print("\t{ \\", file=config)
print('\t\t.name = IVSHMEM_SHM_REGION_{}, \\'.format(shmem_cnt), file=config)
try:
if shmem[1].isdecimal():
int_m_size = int(int(shmem[1])/0x100000)
else:
int_m_size = int(int(shmem[1], 16)/0x100000)
int_size = int(shmem[1]) * 0x100000
except:
int_m_size = 0
print('\t\t.size = {}UL,\t\t/* {}M */ \\'.format(shmem[1], int_m_size), file=config)
int_size = 0
print('\t\t.size = {}UL,\t\t/* {}M */ \\'.format(hex(int_size), shmem[1]), file=config)
if shmem_cnt < len(shmem_regions) - 1:
print("\t}, \\", file=config)
else: