acrn-hypervisor/misc/acrn-config/scenario_config/pci_dev_c.py
Wei Liu 28d1b909e6 acrn-config: generate a scenario patch and apply to acrn-hypervisor
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>
2019-09-16 09:34:37 +08:00

51 lines
2.2 KiB
Python

# Copyright (C) 2019 Intel Corporation. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
import scenario_cfg_lib
PCI_DEV_TYPE = ['PCI_DEV_TYPE_HVEMUL', 'PCI_DEV_TYPE_PTDEV']
def generate_file(config):
"""
Generate pci_dev.c while logical_partition scenario
:param config: it is pointer for for file write to
:return: None
"""
print("{}".format(scenario_cfg_lib.HEADER_LICENSE), file=config)
print("#include <vm_config.h>", file=config)
print("#include <pci_devices.h>", file=config)
print("#include <vpci.h>", file=config)
print("", file=config)
print("/* The vbar_base info of pt devices is included in device MACROs which defined in",
file=config)
print(" * arch/x86/configs/$(CONFIG_BOARD)/pci_devices.h.", file=config)
print(" * The memory range of vBAR should exactly match with the e820 layout of VM.",
file=config)
print(" */", file=config)
for i in range(scenario_cfg_lib.VM_COUNT):
print("struct acrn_vm_pci_dev_config " +
"vm{}_pci_devs[VM{}_CONFIG_PCI_DEV_NUM] = {{".format(i, i), file=config)
print("\t{", file=config)
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[0]), file=config)
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},", file=config)
print("\t\t.vdev_ops = &vhostbridge_ops,", file=config)
print("\t},", file=config)
print("\t{", file=config)
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U},", file=config)
print("\t\tVM{}_STORAGE_CONTROLLER".format(i), file=config)
print("\t},", file=config)
if i != 0:
print("#if defined(VM{}_NETWORK_CONTROLLER)".format(i), file=config)
print("\t{", file=config)
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U},", file=config)
print("\t\tVM{}_NETWORK_CONTROLLER".format(i), file=config)
print("\t},", file=config)
if i != 0:
print("#endif", file=config)
print("};", file=config)
print("", file=config)