acrn-config: move the MACRO of IVSHMEM shared region name to ivshmem_cfg.h

The MACRO of IVSHMEM shared region name is relevant to scenario, move
the MACRO from pci_devices.h which should be consistent for different
scenarios to ivshmem_cfg.h which is the configuration for IVSHMEM and
could vary in sceanrios.

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-11 14:38:09 +08:00 committed by wenlingz
parent bed82b3736
commit 67426ed69c
3 changed files with 28 additions and 28 deletions

View File

@ -62,16 +62,5 @@ def generate_file(config):
i_cnt += 1
ivshmem_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
raw_shmem_regions = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "IVSHMEM", "IVSHMEM_REGION")
if ivshmem_enabled == 'y':
shmem_cnt = 0
for raw_shmem_region in raw_shmem_regions:
if raw_shmem_region and raw_shmem_region.strip != '':
name = raw_shmem_region.split(',')[0].strip()
print("", file=config)
print("#define IVSHMEM_SHM_REGION_%-21d"%shmem_cnt, end="", file=config)
print('"{}"'.format(name), file=config)
shmem_cnt += 1
# write the end to the pci devices
print("{0}".format(PCI_END_HEADER), file=config)

View File

@ -36,6 +36,13 @@ def write_shmem_regions(config):
shmem_regions.append((raw_shm_splited[0].strip(), raw_shm_splited[1].strip(), raw_shm_splited[2].strip().split(':')))
shmem_dev_num += len(raw_shm_splited[2].strip().split(':'))
if len(shmem_regions) > 0:
shmem_cnt = 0
print("", file=config)
for shmem_region in shmem_regions:
print("#define IVSHMEM_SHM_REGION_%d\t"%shmem_cnt, end="", file=config)
print('"{}"'.format(shmem_region[0]), file=config)
shmem_cnt += 1
print("", file=config)
print("/*", file=config)
print(" * The IVSHMEM_SHM_SIZE is the sum of all memory regions.", file=config)
@ -59,22 +66,27 @@ def write_shmem_regions(config):
print("#define IVSHMEM_DEV_NUM\t\t{}UL".format(shmem_dev_num), file=config)
print("", file=config)
print("/* All user defined memory regions */", file=config)
print("\nstruct ivshmem_shm_region mem_regions[] = {", file=config)
shmem_cnt = 0
for shmem in shmem_regions:
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)
if len(shmem_regions) == 0:
print("#define IVSHMEM_SHM_REGIONS", file=config)
else:
print("#define IVSHMEM_SHM_REGIONS \\", file=config)
shmem_cnt = 0
for shmem in shmem_regions:
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)
except:
int_m_size = 0
print('\t\t.size = {}UL,\t\t/* {}M */ \\'.format(shmem[1], int_m_size), file=config)
if shmem_cnt < len(shmem_regions) - 1:
print("\t}, \\", file=config)
else:
int_m_size = int(int(shmem[1], 16)/0x100000)
except:
int_m_size = 0
print('\t\t.size = {}UL,\t\t/* {}M */'.format(shmem[1], int_m_size), file=config)
print("\t},", file=config)
shmem_cnt += 1
print("};", file=config)
print("\t},", file=config)
shmem_cnt += 1
print("", file=config)
@ -90,7 +102,6 @@ def generate_file(scenario_items, config):
if vm_info.shmem.shmem_enabled == 'y':
print("#include <ivshmem.h>", file=config)
print("#include <pgtable.h>", file=config)
print("#include <pci_devices.h>", file=config)
write_shmem_regions(config)
print("{0}".format(IVSHMEM_END_DEFINE), file=config)

View File

@ -53,7 +53,7 @@ def generate_file(vm_info, config):
print("#include <mmu.h>", file=config)
print("#include <page.h>", file=config)
if vm_info.shmem.shmem_enabled == 'y':
print("#include <ivshmem.h>", file=config)
print("#include <ivshmem_cfg.h>", file=config)
for vm_i, pci_bdf_devs_list in vm_info.cfg_pci.pci_devs.items():
if not pci_bdf_devs_list:
continue