def generate_file(hv_info, config): """Start to generate board.c :param config: it is a file pointer of board information for writing to """ err_dic = {} # add config scenario name (err_dic, scenario_name) = common.get_scenario_name() (err_dic, board_name) = common.get_board_name() print("{}".format(DESC), file=config) if hv_info.log.release == 'y': print("CONFIG_RELEASE=y", file=config) print('CONFIG_BOARD="{}"'.format(board_name), file=config) get_memory(hv_info, config) get_miscfg(hv_info, config) get_features(hv_info, config) get_capacities(hv_info, config) get_serial_console(config) get_log_opt(hv_info, config) if is_rdt_supported(): print("CONFIG_RDT_ENABLED=y", file=config) else: print("CONFIG_RDT_ENABLED=n", file=config) print("CONFIG_ENFORCE_VALIDATED_ACPI_INFO=y", file=config) return err_dic
def get_names(): names = {} # get User Vm name user_vm_types = launch_cfg_lib.get_user_vm_type() names['user_vm_types'] = user_vm_types # get user_vm name user_vm_names = launch_cfg_lib.get_user_vm_names() names['user_vm_names'] = user_vm_names # get board name (err_dic, board_name) = common.get_board_name() if err_dic: return (err_dic, names) names['board_name'] = board_name # get scenario name (err_dic, scenario_name) = common.get_scenario_name() if err_dic: return (err_dic, names) names['scenario_name'] = scenario_name return (err_dic, names)
def is_p2sb_passthru_possible(): p2sb_passthru = False (_, board) = common.get_board_name() if board in P2SB_PASSTHRU_BOARD: p2sb_passthru = True return p2sb_passthru
def is_tpm_passthru(): tpm_passthru = False (_, board) = common.get_board_name() if board in TPM_PASSTHRU_BOARD: tpm_passthru = True return tpm_passthru
def is_tpm_passthru(): tpm_passthru = False (_, board) = common.get_board_name() tpm2_passthru_enabled = common.get_leaf_tag_map_bool( common.SCENARIO_INFO_FILE, "mmio_resources", "TPM2") if board in TPM_PASSTHRU_BOARD and tpm2_passthru_enabled and tpm2_passthru_enabled == 'y': tpm_passthru = True return tpm_passthru
def main(args): """ This is main function to start generate source code related with board :param args: it is a command line args for the script """ err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = params['--board'] common.SCENARIO_INFO_FILE = params['--scenario'] common.get_vm_num(params['--scenario']) common.get_vm_types() # get board name (err_dic, board_name) = common.get_board_name() # get scenario name (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic if common.VM_COUNT > common.MAX_VM_NUM: err_dic[ 'vm count'] = "The vm count in config xml should be less or equal {}!".format( common.MAX_VM_NUM) return err_dic # check if this is the scenario config which matched board info (err_dic, status) = common.is_config_file_match() if not status: err_dic[ 'scenario config'] = "The board xml and scenario xml should be matched!" return err_dic if params['--out']: if os.path.isabs(params['--out']): scenario_dir = os.path.join(params['--out'], scenario + '/') config_hv = os.path.join(params['--out'], board_name + GEN_FILE[3]) else: scenario_dir = os.path.join(ACRN_PATH + params['--out'], scenario + '/') config_hv = os.path.join(ACRN_PATH + params['--out'], board_name + GEN_FILE[3]) else: scenario_dir = os.path.join(ACRN_CONFIG_DEF, scenario + '/') config_hv = os.path.join(ACRN_CONFIGS, board_name + GEN_FILE[3]) common.print_yel("{}".format("Override board defconfig...", warn=True)) common.mkdir(scenario_dir) vm_config_h = scenario_dir + GEN_FILE[0] vm_config_c = scenario_dir + GEN_FILE[1] pci_config_c = scenario_dir + GEN_FILE[2] # parse the scenario.xml get_scenario_item_values(params['--board'], params['--scenario']) (err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario']) if err_dic: common.print_red("Validate the scenario item failure", err=True) return err_dic # generate board defconfig with open(config_hv, 'w+') as config: err_dic = board_defconfig.generate_file(scenario_items['hv'], config) if err_dic: return err_dic # generate vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario_items, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario_items['vm'], config) if err_dic: return err_dic # generate pci_dev.c for vm_i, pci_dev_num in scenario_items['vm'].cfg_pci.pci_dev_num.items(): if pci_dev_num >= 2: with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(scenario_items['vm'], config) break if not err_dic: print( "Scenario configurations for {} is generated successfully.".format( scenario)) else: print("Scenario configurations for {} is generated failed.".format( scenario)) return err_dic
def main(args): """ This is main function to start generate source code related with board :param args: it is a command line args for the script """ err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = params['--board'] common.SCENARIO_INFO_FILE = params['--scenario'] common.get_vm_num(params['--scenario']) common.get_vm_types() if common.VM_COUNT > common.MAX_VM_NUM: err_dic[ 'vm count'] = "The vm count in config xml should be less or equal {}!".format( common.MAX_VM_NUM) return err_dic # check if this is the scenario config which matched board info # get board name (err_dic, board) = common.get_board_name() if err_dic: return err_dic (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic board_cfg_lib.BOARD_NAME = board # check if this is the scenario config which matched board info (err_dic, status) = common.is_config_file_match() if not status: err_dic[ 'board config'] = "The board xml file does not match scenario xml file!" return err_dic output = '' if params['--out']: if os.path.isabs(params['--out']): output = params['--out'] else: output = ACRN_PATH + params['--out'] else: output = ACRN_CONFIG_DEF board_fix_dir = os.path.join(output, "boards/") scen_board_dir = os.path.join(output, "scenarios/" + scenario + "/") common.mkdir(board_fix_dir) common.mkdir(scen_board_dir) config_pci = board_fix_dir + GEN_FILE[0] config_board = board_fix_dir + GEN_FILE[1] config_acpi = board_fix_dir + GEN_FILE[2] config_board_h = board_fix_dir + GEN_FILE[4] config_misc_cfg = scen_board_dir + GEN_FILE[3] config_vbar_base = scen_board_dir + GEN_FILE[5] # generate pci_devices.h with open(config_pci, 'w+') as config: pci_devices_h.generate_file(config) # generate board_info.h with open(config_board_h, 'w+') as config: err_dic = board_info_h.generate_file(config) if err_dic: return err_dic # generate board.c with open(config_board, 'w+') as config: err_dic = board_c.generate_file(config) if err_dic: return err_dic # generate vbar_base.h with open(config_vbar_base, 'w+') as config: vbar_base_h.generate_file(config) # generate platform_acpi_info.h with open(config_acpi, 'w+') as config: acpi_platform_h.generate_file(config, ACRN_DEFAULT_ACPI) # generate misc_cfg.h with open(config_misc_cfg, 'w+') as config: err_dic = misc_cfg_h.generate_file(config) if err_dic: return err_dic if not err_dic: print("Board configurations for {} is generated successfully.".format( board)) else: print("Board configurations for {} is generated failed.".format(board)) return err_dic
def is_matched_board(boardlist): (_, board) = common.get_board_name() return board in boardlist
def main(args): """ Generate board related source code :param args: command line args """ err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = params['--board'] common.SCENARIO_INFO_FILE = params['--scenario'] common.get_vm_num(params['--scenario']) common.get_vm_types() # get board name (err_dic, board_name) = common.get_board_name() # get scenario name (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic if common.VM_COUNT > common.MAX_VM_NUM: err_dic[ 'vm count'] = "Number of VMs in scenario xml file should be no greater than {}!".format( common.MAX_VM_NUM) return err_dic # check if this is the scenario config which matches board info (err_dic, status) = common.is_config_file_match() if not status: err_dic[ 'scenario config'] = "The board xml file does not match scenario xml file!" return err_dic if params['--out']: if os.path.isabs(params['--out']): scen_output = params['--out'] + "/scenarios/" + scenario + "/" else: scen_output = ACRN_PATH + params[ '--out'] + "/scenarios/" + scenario + "/" else: scen_output = ACRN_CONFIG_DEF + "/" + scenario + "/" scen_board = scen_output + board_name + "/" common.mkdir(scen_board) common.mkdir(scen_output) vm_config_h = scen_output + GEN_FILE[0] vm_config_c = scen_output + GEN_FILE[1] pci_config_c = scen_board + GEN_FILE[2] config_hv = scen_board + board_name + GEN_FILE[3] ivshmem_config_h = scen_board + GEN_FILE[4] pt_intx_config_c = scen_board + GEN_FILE[5] # parse the scenario.xml get_scenario_item_values(params['--board'], params['--scenario']) (err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario']) if err_dic: common.print_red("Scenario xml file validation failed:", err=True) return err_dic # generate board defconfig with open(config_hv, 'w+') as config: err_dic = board_defconfig.generate_file(scenario_items['hv'], config) if err_dic: return err_dic # generate vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario_items, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario_items, config) if err_dic: return err_dic # generate ivshmem_cfg.h with open(ivshmem_config_h, 'w') as config: ivshmem_cfg_h.generate_file(scenario_items, config) # generate pci_dev.c with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(scenario_items['vm'], config) # generate pt_intx.c with open(pt_intx_config_c, 'w') as config: pt_intx_c.generate_file(scenario_items['vm'], config) # generate ASL code of ACPI tables for Pre-launched VMs asl_gen.main(args) if not err_dic: print("Scenario configuration files were created successfully.") else: print("Failed to create scenario configuration files.") return err_dic
def main(args): """ Generate board related source code :param args: command line args """ err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = params['--board'] common.SCENARIO_INFO_FILE = params['--scenario'] common.get_vm_num(params['--scenario']) common.get_load_order() # get board name (err_dic, board_name) = common.get_board_name() # get scenario name (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic if common.VM_COUNT > common.MAX_VM_NUM: err_dic['vm count'] = "Number of VMs in scenario xml file should be no greater than hv/CAPACITIES/MAX_VM_NUM ! " \ "Now this value is {}.".format(common.MAX_VM_NUM) return err_dic if params['--out']: if os.path.isabs(params['--out']): scen_output = params['--out'] + "/scenarios/" + scenario + "/" else: scen_output = ACRN_PATH + params[ '--out'] + "/scenarios/" + scenario + "/" else: scen_output = ACRN_CONFIG_DEF + "/" + scenario + "/" scen_board = scen_output + "/" common.mkdir(scen_board) common.mkdir(scen_output) vm_config_h = scen_output + GEN_FILE[0] vm_config_c = scen_output + GEN_FILE[1] pci_config_c = scen_board + GEN_FILE[2] config_hv = scen_board + board_name + GEN_FILE[3] ivshmem_config_h = scen_board + GEN_FILE[4] pt_intx_config_c = scen_board + GEN_FILE[5] # parse the scenario.xml get_scenario_item_values(params['--board'], params['--scenario']) (err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario']) if err_dic: common.print_red("Scenario xml file validation failed:", err=True) return err_dic # generate board defconfig with open(config_hv, 'w+') as config: err_dic = board_defconfig.generate_file(scenario_items['hv'], config) if err_dic: return err_dic # generate ASL code of ACPI tables for Pre-launched VMs if not err_dic: err_dic = asl_gen.main(args) if not err_dic: print("Scenario configuration files were created successfully.") else: print("Failed to create scenario configuration files.") return err_dic
def main(args): """ This is main function to start generate source code related with board :param args: it is a command line args for the script """ err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = params['--board'] common.SCENARIO_INFO_FILE = params['--scenario'] common.get_vm_num(params['--scenario']) common.get_load_order() if common.VM_COUNT > common.MAX_VM_NUM: err_dic['vm count'] = "The number of VMs in the scenario XML file should be no greater than " \ "hv.CAPACITIES.MAX_VM_NUM. Its current value is {}.".format(common.MAX_VM_NUM) return err_dic # check if this is the scenario config which matched board info # get board name (err_dic, board) = common.get_board_name() if err_dic: return err_dic (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic board_cfg_lib.BOARD_NAME = board output = '' if params['--out']: if os.path.isabs(params['--out']): output = params['--out'] else: output = ACRN_PATH + params['--out'] else: output = ACRN_CONFIG_DEF board_fix_dir = os.path.join(output, "boards/") scen_board_dir = os.path.join(output, "scenarios/" + scenario + "/") common.mkdir(board_fix_dir) common.mkdir(scen_board_dir) config_pci = board_fix_dir + GEN_FILE[0] config_board = board_fix_dir + GEN_FILE[1] config_acpi = board_fix_dir + GEN_FILE[2] config_board_h = board_fix_dir + GEN_FILE[4] # generate pci_devices.h with open(config_pci, 'w+') as config: pci_devices_h.generate_file(config) # generate board_info.h with open(config_board_h, 'w+') as config: err_dic = board_info_h.generate_file(config) if err_dic: return err_dic # generate board.c with open(config_board, 'w+') as config: err_dic = board_c.generate_file(config) if err_dic: return err_dic # generate platform_acpi_info.h with open(config_acpi, 'w+') as config: acpi_platform_h.generate_file(config, ACRN_DEFAULT_ACPI) if not err_dic: print("Board configurations for {} is generated successfully.".format( board)) else: print("Board configurations for {} is generated failed.".format(board)) return err_dic
def main(args): """ This is main function to start generate source code related with board :param args: it is a command line args for the script """ err_dic = {} (err_dic, board_info_file, scenario_info_file, output_folder) = common.get_param(args) if err_dic: return err_dic if output_folder: common.ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/' # check env err_dic = common.prepare() if err_dic: return err_dic common.BOARD_INFO_FILE = board_info_file common.SCENARIO_INFO_FILE = scenario_info_file common.get_vm_num(scenario_info_file) # get board name (err_dic, board) = common.get_board_name() if err_dic: return err_dic board_cfg_lib.BOARD_NAME = board # check if this is the scenario config which matched board info (err_dic, status) = common.is_config_file_match() if not status: err_dic[ 'board config: Not match'] = "The board xml and scenario xml should be matched" return err_dic if common.ACRN_CONFIG_TARGET: board_dir = common.ACRN_CONFIG_TARGET + board + '/' else: board_dir = ACRN_CONFIG_DEF + board + '/' common.mkdir(board_dir) config_pci = board_dir + GEN_FILE[0] config_board = board_dir + GEN_FILE[1] config_acpi = board_dir + board + GEN_FILE[2] config_misc_cfg = board_dir + GEN_FILE[3] if common.ACRN_CONFIG_TARGET: config_board_kconfig = common.ACRN_CONFIG_TARGET + board + GEN_FILE[4] else: config_board_kconfig = ACRN_CONFIG_DEF + board + GEN_FILE[4] # generate board.c with open(config_board, 'w+') as config: err_dic = board_c.generate_file(config) if err_dic: return err_dic # generate pci_devices.h with open(config_pci, 'w+') as config: pci_devices_h.generate_file(config) # generate ($board)_acpi_info.h with open(config_acpi, 'w+') as config: acpi_platform_h.generate_file(config, ACRN_DEFAULT_ACPI) # generate misc_cfg.h with open(config_misc_cfg, 'w+') as config: err_dic = misc_cfg_h.generate_file(config) if err_dic: return err_dic # generate ($board).config with open(config_board_kconfig, 'w+') as config: err_dic = new_board_kconfig.generate_file(config) if err_dic: return err_dic if not err_dic: print("Board configurations for {} is generated successfully.".format( board)) else: print("Board configurations for {} is generated failed.".format(board)) return err_dic