def divide_int(): '''Divides one integer by another and returns the address of a new integer equal to the result. 2 Params: 1. The address of an integer (left operand - dividend) 2. The address of another integer (right operand - divisor)''' N_PARAMS = 2 div_not_zero = CodeGenManager.get_label('div_not_zero') return [ '_divide_int:', common.function_prologue(), '; get the value for the left operand and put it in eax', common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('eax', 'eax'), '; get the value for the right operand and put in in ebx', common.get_param('ebx', 1, N_PARAMS), common.unwrap_primitive('ebx', 'ebx'), '; check for division by zero:', 'cmp ebx, 0', 'jne {0}'.format(div_not_zero), 'call __exception', '{0}:'.format(div_not_zero), common.fill_high_order_bit('eax', 'edx'), 'idiv ebx ; sets eax to edx:eax/ebx', '; create an int with the result', 'push eax ; the result of div has to be in eax', 'call _create_int', 'pop ebx ; pop param', '; eax is an integer object with the old value of eax', common.function_epilogue() ]
def add_int(): '''Adds two integers together and returns the address of a new integer with the result. 2 Params: 1. The address of an integer (left operand) 2. The address of another integer (right operand)''' N_PARAMS = 2 return [ '_add_int:', common.function_prologue(), '; get the value for the left operand and put it in ecx', common.get_param('ecx', 0, N_PARAMS), common.unwrap_primitive('ecx', 'ecx'), '; get the value for the right operand and put in in edx', common.get_param('edx', 1, N_PARAMS), common.unwrap_primitive('edx', 'edx'), 'add ecx, edx', '; create an int with the result', 'push ecx', 'call _create_int', 'pop ebx ; pop param', '; eax is an integer object with the value of ecx', common.function_epilogue() ]
def not_equals_ref(): '''Returns a boolean if both references are not equal. 2 Params: 1. Address of a reference (left operand) 2. Address of a reference (right operand) ''' N_PARAMS = 2 return [ '_not_equals_ref:', common.function_prologue(), common.get_param('eax', 0, N_PARAMS), common.get_param('ebx', 1, N_PARAMS), 'cmp eax, ebx', 'je _not_equals_ref_same', 'push 1 ; only run if not the same', 'jmp _not_equals_ref_done', '_not_equals_ref_same:', 'push 0 ; only run if the same', '_not_equals_ref_done:', 'call _create_boolean', 'pop ebx ; pop to garbage', common.function_epilogue(), ]
def multiply_int(): '''Multiplies two integers and returns the address of the result 2 Params: 1. The address of an integer (left operand) 2. The address of an integer (right operand) ''' N_PARAMS = 2 return [ '_mult_int:', common.function_prologue(), '; Get the left param and put it in eax', common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('eax', 'eax'), '; Get the right param and put it in ebx', common.get_param('ebx', 1, N_PARAMS), common.unwrap_primitive('ebx', 'ebx'), 'imul eax, ebx ; Multiply the two params', '; Create an int with the result.', 'push eax ; Push the int as a param', 'call _create_int', 'pop ebx ; Pop off param', common.function_epilogue() ]
def equals_prim(): '''Returns a boolean if both primitives are equal. 2 Params: 1. Address of a primitive (left operand) 2. Address of a primitive (right operand) ''' N_PARAMS = 2 return [ '_equals_prim:', common.function_prologue(), common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('ebx', 'eax'), common.get_param('eax', 1, N_PARAMS), common.unwrap_primitive('eax', 'eax'), 'cmp eax, ebx', 'je _equals_prim_same', 'push 0 ; only run if not the same', 'jmp _equals_prim_done', '_equals_prim_same:', 'push 1 ; only run if the same', '_equals_prim_done:', 'call _create_boolean', 'pop ebx ; pop to garbage', common.function_epilogue(), ]
def mod_int(): '''Computes the modulus of two integers and returns the address of the result 2 Params: 1. The address of an integer (dividend) 2. The address of an integer (dividend) ''' N_PARAMS = 2 return [ '_mod_int:', common.function_prologue(), '; get the value for the left operand and put it in eax', common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('eax', 'eax'), '; get the value for the right operand and put in in ebx', common.get_param('ebx', 1, N_PARAMS), common.unwrap_primitive('ebx', 'ebx'), common.fill_high_order_bit('eax', 'edx'), 'idiv ebx ; sets edx to edx:eax mod ebx', '; create an int with the result', 'push edx ; the result of mod is placed in ebx', 'call _create_int', 'pop ebx ; pop param', '; eax is an integer object with the old value of edx', common.function_epilogue() ]
def asm_op(): return [ '_{0}:'.format(name), common.function_prologue(), common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('eax', 'eax'), common.get_param('ebx', 1, N_PARAMS), common.unwrap_primitive('ebx', 'ebx'), 'cmp eax, ebx', '{0} _{1}_true'.format(x86_op, name), 'push 0 ; only run if fail comparison', 'jmp _{0}_done'.format(name), '_{0}_true:'.format(name), 'push 1 ; only run if pass comparison', '_{0}_done:'.format(name), 'call _create_boolean', 'pop ebx ; pop to garbage', common.function_epilogue(), ]
def sub_int(): '''Subtracts two integers (right from left) and returns the address of a new integer with the result. 2 Params: 1. The address of an integer (left operand) 2. The address of an integer (right operand)''' N_PARAMS = 2 return [ '_sub_int:', common.function_prologue(), common.get_param('ecx', 0, N_PARAMS), common.unwrap_primitive('ecx', 'ecx'), common.get_param('edx', 1, N_PARAMS), common.unwrap_primitive('edx', 'edx'), 'sub ecx, edx', '; create an int with the result', 'push ecx', 'call _create_int', 'pop ebx ; pop param', common.function_epilogue() ]
def eager_or(): '''Computes the OR of two booleans and returns the address of the result. 2 Params: 1. Address of a boolean (left operand) 2. Address of a boolean (right operand) ''' N_PARAMS = 2 return [ '_eager_or:', common.function_prologue(), common.get_param('eax', 0, N_PARAMS), common.unwrap_primitive('ebx', 'eax'), common.get_param('eax', 1, N_PARAMS), common.unwrap_primitive('eax', 'eax'), 'or eax, ebx', 'push eax', 'call _create_boolean', 'pop ebx ; pop param to garbage', '; result is stored in eax', common.function_epilogue() ]
def create_int(): '''Allocates space in memory for an integer (32-bits). The value at the memory address will be set to the parameter passed in. 1 Param: The value of the integer''' N_PARAMS = 1 return [ '_create_int:', common.function_prologue(), common.malloc(4), common.get_param('ebx', 0, N_PARAMS), 'mov dword [eax], ebx', common.function_epilogue() ]
def edit(request, group_id): param = {} if group_id: group = get_group(group_id) require = check_user(group) if require: return redirect("/redirect/?%s" % require) users = get_users(group) param.update({'group': group, 'users': users,}) errs = get_param(request, 'errs') if errs: errs = errs.split(',') for err in errs: param.update({"%s_error" % err: True,}) return respond('group_edit.html', param)
def negate_bool(): '''Negates a bool and returns the address of a new integer. 1 Param: 1. The address of the integer to negate.''' N_PARAMS = 1 return [ '_negate_bool:', common.function_prologue(), common.get_param('ebx', 0, N_PARAMS), common.unwrap_primitive('ebx', 'ebx'), 'mov eax, 1', 'xor eax, ebx', 'push eax', 'call _create_boolean', 'pop ebx ; pop param', common.function_epilogue(), ]
def create_boolean(): '''Allocates space in memory for a boolean (stores it in 32-bits). The value at the memory address will be set to 0 or 1 based on the parameter passed in: 0: if the parameter is 0 1: otherwise 1 Param: Integer value that will be converted to boolean based on above.''' N_PARAMS = 1 return [ '_create_boolean:', common.function_prologue(), common.malloc(4), common.get_param('ebx', 0, N_PARAMS), 'mov ecx, 0', 'cmp ebx, ecx', 'je _create_boolean_done_compare', 'mov ebx, 1', '_create_boolean_done_compare:', 'mov dword [eax], ebx', common.function_epilogue() ]
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 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 get_param(args): """ Get the script parameters from command line :param args: this the command line of string for the script without script name """ return common.get_param(args)
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 # get scenario name (err_dic, scenario) = common.get_scenario_name() if err_dic: 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: Not match'] = "The board xml and scenario xml should be matched!" return err_dic if common.ACRN_CONFIG_TARGET: scenario_dir = common.ACRN_CONFIG_TARGET + scenario + '/' else: scenario_dir = ACRN_CONFIG_DEF + scenario + '/' 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(board_info_file, scenario_info_file) (err_dic, vm_info) = validate_scenario_setting(board_info_file, scenario_info_file) if err_dic: common.print_red("Validate the scenario item failue", err=True) return err_dic # get kata vm count if scenario != "logical_partition": scenario_cfg_lib.KATA_VM_COUNT = common.VM_COUNT - scenario_cfg_lib.DEFAULT_VM_COUNT[ scenario] if scenario_cfg_lib.KATA_VM_COUNT > 1: err_dic[ 'scenario config: kata vm count err'] = "Only one kata vm is supported!" return err_dic # generate vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario, vm_info, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario, vm_info, config) if err_dic: return err_dic # generate pci_dev.c if scenario is logical_partition if scenario == 'logical_partition': with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(config) 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): err_dic = {} (err_dic, params) = common.get_param(args) if err_dic: return err_dic board = params['--board'] scenario = params['--scenario'] out = params['--out'] board_etree = lxml.etree.parse(board) board_root = board_etree.getroot() scenario_etree = lxml.etree.parse(scenario) scenario_root = scenario_etree.getroot() allocation_etree = lxml.etree.parse( os.path.join(os.path.dirname(board), "configs", "allocation.xml")) board_type = board_root.attrib['board'] scenario_name = scenario_root.attrib['scenario'] pcpu_list = board_root.find('CPU_PROCESSOR_INFO').text.strip().split(',') if isinstance(pcpu_list, list): pcpu_list = [x.strip() for x in pcpu_list] if out is None or out == '': DEST_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'scenarios', scenario_name) else: DEST_ACPI_PATH = os.path.join(common.SOURCE_ROOT_DIR, out, 'scenarios', scenario_name) if os.path.isdir(DEST_ACPI_PATH): for config in os.listdir(DEST_ACPI_PATH): if config.startswith('ACPI_VM') and os.path.isdir( os.path.join(DEST_ACPI_PATH, config)): shutil.rmtree(os.path.join(DEST_ACPI_PATH, config)) dict_passthru_devices = collections.OrderedDict() dict_pcpu_list = collections.OrderedDict() for vm in scenario_root.findall('vm'): vm_id = vm.attrib['id'] load_order_node = vm.find('load_order') if (load_order_node is not None) and (load_order_node.text == 'PRE_LAUNCHED_VM'): dict_passthru_devices[vm_id] = [] for pci_dev_node in vm.findall('pci_devs/pci_dev'): if pci_dev_node is not None and pci_dev_node.text is not None and pci_dev_node.text.strip( ): dict_passthru_devices[vm_id].append(pci_dev_node.text) mmio_dev_nodes = vm.find('mmio_resources') if mmio_dev_nodes is not None: for mmio_dev_node in list(mmio_dev_nodes): if mmio_dev_node is not None and mmio_dev_node.text.strip( ) == 'y': dict_passthru_devices[vm_id].append(mmio_dev_node.tag) dict_pcpu_list[vm_id] = [] for pcpu_id in vm.findall('cpu_affinity/pcpu_id'): if pcpu_id is not None and pcpu_id.text.strip() in pcpu_list: dict_pcpu_list[vm_id].append(int(pcpu_id.text)) PASSTHROUGH_RTCT = False PRELAUNCHED_RTVM_ID = None try: if scenario_root.find( 'hv/FEATURES/SSRAM/SSRAM_ENABLED').text.strip() == 'y': PASSTHROUGH_RTCT = True for vm in scenario_root.findall('vm'): vm_id = vm.attrib['id'] vm_type_node = vm.find('vm_type') load_order_node = vm.find('load_order') if (load_order_node is not None) and ( load_order_node.text == 'PRE_LAUNCHED_VM') and (vm_type_node.text == 'RTVM'): PRELAUNCHED_RTVM_ID = vm_id break except: PASSTHROUGH_RTCT = False kern_args = common.get_leaf_tag_map(scenario, "os_config", "bootargs") kern_type = common.get_leaf_tag_map(scenario, "os_config", "kern_type") for vm_id, passthru_devices in dict_passthru_devices.items(): if kern_args[int(vm_id)].find('reboot=acpi') == -1 and kern_type[int( vm_id)] in ['KERNEL_BZIMAGE']: emsg = "you need to specify 'reboot=acpi' in scenario file's bootargs for VM{}".format( vm_id) print(emsg) err_dic['vm,bootargs'] = emsg break print('start to generate ACPI ASL code for VM{}'.format(vm_id)) dest_vm_acpi_path = os.path.join(DEST_ACPI_PATH, 'ACPI_VM' + vm_id) if not os.path.isdir(dest_vm_acpi_path): os.makedirs(dest_vm_acpi_path) if PASSTHROUGH_RTCT is True and vm_id == PRELAUNCHED_RTVM_ID: for f in RTCT: if os.path.isfile( os.path.join(VM_CONFIGS_PATH, 'acpi_template', board_type, f)): passthru_devices.append(f) shutil.copy( os.path.join(VM_CONFIGS_PATH, 'acpi_template', board_type, f), dest_vm_acpi_path) break gen_rsdp(dest_vm_acpi_path) gen_xsdt(dest_vm_acpi_path, passthru_devices) gen_fadt(dest_vm_acpi_path, board_root) gen_mcfg(dest_vm_acpi_path) if vm_id in dict_pcpu_list: dict_pcpu_list[vm_id].sort() apic_ids = [] for id in dict_pcpu_list[vm_id]: apic_id = common.get_node( f"//processors/die/core/thread[cpu_id='{id}']/apic_id/text()", board_etree) if apic_id is None: emsg = 'some or all of the processors/die/core/thread/cpu_id tags are missing in board xml file for cpu {}, please run board_inspector.py to regenerate the board xml file!'.format( id) print(emsg) err_dic['board config: processors'] = emsg return err_dic else: apic_ids.append(int(apic_id, 16)) gen_madt(dest_vm_acpi_path, len(dict_pcpu_list[vm_id]), apic_ids) gen_tpm2(dest_vm_acpi_path, passthru_devices) gen_dsdt(board_etree, scenario_etree, allocation_etree, vm_id, os.path.join(dest_vm_acpi_path, "dsdt.aml")) print('generate ASL code of ACPI tables for VM {} into {}'.format( vm_id, dest_vm_acpi_path)) else: emsg = 'no cpu affinity config for VM {}'.format(vm_id) print(emsg) err_dic['vm,cpu_affinity,pcpu_id'] = emsg 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
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): """ 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