def main(board_info_file): """This is main function to start generate source code related with board""" board = '' config_srcs = [] config_dirs = [] # get board name board = board_cfg_lib.get_board_name(board_info_file) config_dirs.append(ACRN_CONFIG + board) if board not in BOARD_NAMES: for config_dir in config_dirs: if not os.path.exists(config_dir): os.makedirs(config_dir) config_pci = config_dirs[0] + '/' + GEN_FILE[3] config_board = config_dirs[0] + '/' + GEN_FILE[4] config_platform = config_dirs[0] + '/' + board + GEN_FILE[5] config_srcs.append(config_pci) config_srcs.append(config_board) config_srcs.append(config_platform) # generate board.c with open(config_board, 'w+') as config: board_c.generate_file(config) # generate pci_devices.h with open(config_pci, 'w+') as config: pci_devices_h.generate_file(config) # generate acpi_platform.h with open(config_platform, 'w+') as config: acpi_platform_h.generate_file(config, ACRN_DEFAULT_PLATFORM) # move changes to patch, and applay to the source code gen_patch(config_srcs, board) if board not in BOARD_NAMES: print("Config patch for NEW board {} is committed successfully!".format(board)) else: print("Config patch for {} is committed successfully!".format(board))
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 = {} config_srcs = [] config_dirs = [] (err_dic, board_info_file, scenario_info_file, enable_commit) = board_cfg_lib.get_param(args) if err_dic: return err_dic board_cfg_lib.BOARD_INFO_FILE = board_info_file board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file board_cfg_lib.get_vm_count(scenario_info_file) # get board name (err_dic, board) = board_cfg_lib.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) = board_cfg_lib.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 config_dirs.append(ACRN_CONFIG + board) if board not in board_cfg_lib.BOARD_NAMES: for config_dir in config_dirs: if not os.path.exists(config_dir): os.makedirs(config_dir) config_pci = config_dirs[0] + '/' + GEN_FILE[0] config_board = config_dirs[0] + '/' + GEN_FILE[1] config_platform = config_dirs[0] + '/' + board + GEN_FILE[2] config_misc_cfg = config_dirs[0] + '/' + GEN_FILE[3] config_ve820 = config_dirs[0] + '/' + GEN_FILE[4] config_board_kconfig = ACRN_CONFIG + board + GEN_FILE[5] config_srcs.append(config_pci) config_srcs.append(config_board) config_srcs.append(config_platform) config_srcs.append(config_misc_cfg) config_srcs.append(config_ve820) config_srcs.append(config_board_kconfig) # 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 acpi_platform.h with open(config_platform, 'w+') as config: acpi_platform_h.generate_file(config, ACRN_DEFAULT_PLATFORM) # generate acpi_platform.h with open(config_ve820, 'w+') as config: err_dic = ve820_c.generate_file(config) if err_dic: return err_dic # generate acpi_platform.h with open(config_misc_cfg, 'w+') as config: err_dic = misc_cfg_h.generate_file(config) if err_dic: return err_dic # generate new board_name.config if board not in board_cfg_lib.BOARD_NAMES: with open(config_board_kconfig, 'w+') as config: err_dic = new_board_kconfig.generate_file(config) if err_dic: return err_dic config_str = 'Config files' gen_str = 'generated' # move changes to patch, and apply to the source code if enable_commit: err_dic = board_cfg_lib.gen_patch(config_srcs, board) config_str = 'Config patch' gen_str = 'committed' if board not in board_cfg_lib.BOARD_NAMES and not err_dic: print("{} for NEW board {} is {} successfully!".format( config_str, board, gen_str)) elif not err_dic: print("{} for {} is {} successfully!".format(config_str, board, gen_str)) else: print("{} for {} is failed".format(config_str, board)) return err_dic
def ve820_per_launch(config, hpa_size): """ Start to generate board.c :param config: it is a file pointer of board information for writing to """ (err_dic, board_name) = board_cfg_lib.get_board_name() if err_dic: return err_dic board_name = board_cfg_lib.undline_name(board_name) low_mem_to_pci_hole_len = '0xA0000000' low_mem_to_pci_hole = '0x20000000' pci_hole_addr = '0xe0000000' pci_hole_len = '0x20000000' start_low_hpa = 0x100000 hpa_len = int(hpa_size, 16) - 1 * 1024 * 1024 # pre_launch memroy: mem_size is the ve820 length print("#include <e820.h>", file=config) print("#include <vm.h>", file=config) print("", file=config) print("#define VE820_ENTRIES_{}\t{}U".format(board_name, 5), file=config) print("static const struct e820_entry ve820_entry[{}] = {{".format( "VE820_ENTRIES_{}".format(board_name)), file=config) print("\t{\t/* usable RAM under 1MB */", file=config) print("\t\t.baseaddr = 0x0UL,", file=config) print("\t\t.length = 0xF0000UL,\t\t/* 960KB */", file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* mptable */", file=config) print("\t\t.baseaddr = 0xF0000UL,\t\t/* 960KB */", file=config) print("\t\t.length = 0x10000UL,\t\t/* 16KB */", file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* lowmem */", file=config) print("\t\t.baseaddr = {}UL,\t\t/* 1MB */".format(hex(start_low_hpa)), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format(hex(hpa_len), hpa_len / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* between lowmem and PCI hole */", file=config) print("\t\t.baseaddr = {}UL,\t/* {}MB */".format( low_mem_to_pci_hole, int(low_mem_to_pci_hole, 16) / 1024 / 1024), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( low_mem_to_pci_hole_len, int(low_mem_to_pci_hole_len, 16) / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("", file=config) print("\t{{\t/* between PCI hole and {}GB */".format(TOTAL_MEM_SIZE / 1024 / 1024 / 1024), file=config) print("\t\t.baseaddr = {}UL,\t/* {}GB */".format( hex(int(pci_hole_addr, 16)), int(pci_hole_addr, 16) / 1024 / 1024 / 1024), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(int(pci_hole_len, 16)), int(pci_hole_len, 16) / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("};", file=config) print("", file=config) print("/**", file=config) print(" * @pre vm != NULL", file=config) print("*/", file=config) print("void create_prelaunched_vm_e820(struct acrn_vm *vm)", file=config) print("{", file=config) print("\tvm->e820_entry_num = VE820_ENTRIES_{};".format(board_name), file=config) print("\tvm->e820_entries = ve820_entry;", file=config) print("}", file=config) return err_dic
def ve820_per_launch(config, hpa_size, hpa2_size): """ Start to generate board.c :param config: it is a file pointer of board information for writing to """ (err_dic, board_name) = board_cfg_lib.get_board_name() if err_dic: return err_dic board_name = board_cfg_lib.undline_name(board_name) pre_vm_cnt = board_cfg_lib.get_pre_launch_cnt( board_cfg_lib.SCENARIO_INFO_FILE) low_mem_to_pci_hole_len = '0xA0000000' low_mem_to_pci_hole = '0x20000000' pci_hole_addr = '0xe0000000' pci_hole_len = '0x20000000' start_low_hpa = 0x100000 low_mem_hpa_len = [] high_mem_hpa_len = [] high_mem_hpa2_len = [] high_mem_hpa2_addr = [] # pre_launch memroy: mem_size is the ve820 length print("#include <e820.h>", file=config) print("#include <vm.h>", file=config) print("", file=config) for i in range(pre_vm_cnt): if (int(hpa_size[i], 16) <= 512 * 1024 * 1024): low_mem_hpa_len.append(int(hpa_size[i], 16) - 1 * 1024 * 1024) high_mem_hpa_len.append(0) else: low_mem_hpa_len.append(511 * 1024 * 1024) high_mem_hpa_len.append(int(hpa_size[i], 16) - 512 * 1024 * 1024) if len(hpa2_size) == 0: high_mem_hpa2_len.append(0) else: high_mem_hpa2_len.append(int(hpa2_size[i], 16)) #HPA2 is always allocated in >4G space. if (high_mem_hpa_len[i] != 0) and (high_mem_hpa2_len[i] != 0): high_mem_hpa2_addr.append(FOUR_GBYTE + high_mem_hpa_len[i]) else: high_mem_hpa2_addr.append(FOUR_GBYTE) if (high_mem_hpa_len[i] != 0) and (high_mem_hpa2_len[i] != 0): print("#define VM{}_VE820_ENTRIES_{}\t{}U".format( i, board_name, 7), file=config) elif (high_mem_hpa_len[i] != 0) or (high_mem_hpa2_len[i] != 0): print("#define VM{}_VE820_ENTRIES_{}\t{}U".format( i, board_name, 6), file=config) else: print("#define VM{}_VE820_ENTRIES_{}\t{}U".format( i, board_name, 5), file=config) for i in range(pre_vm_cnt): print( "static const struct e820_entry vm{}_ve820_entry[{}] = {{".format( i, "VM{}_VE820_ENTRIES_{}".format(i, board_name)), file=config) print("\t{\t/* usable RAM under 1MB */", file=config) print("\t\t.baseaddr = 0x0UL,", file=config) print("\t\t.length = 0xF0000UL,\t\t/* 960KB */", file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* mptable */", file=config) print("\t\t.baseaddr = 0xF0000UL,\t\t/* 960KB */", file=config) print("\t\t.length = 0x10000UL,\t\t/* 64KB */", file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* lowmem */", file=config) print("\t\t.baseaddr = {}UL,\t\t/* 1MB */".format(hex(start_low_hpa)), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(low_mem_hpa_len[i]), low_mem_hpa_len[i] / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* between lowmem and PCI hole */", file=config) print("\t\t.baseaddr = {}UL,\t/* {}MB */".format( low_mem_to_pci_hole, int(low_mem_to_pci_hole, 16) / 1024 / 1024), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( low_mem_to_pci_hole_len, int(low_mem_to_pci_hole_len, 16) / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* between PCI hole and 4 GB */", file=config) print("\t\t.baseaddr = {}UL,\t/* {}GB */".format( hex(int(pci_hole_addr, 16)), int(pci_hole_addr, 16) / 1024 / 1024 / 1024), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(int(pci_hole_len, 16)), int(pci_hole_len, 16) / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RESERVED", file=config) print("\t},", file=config) print("", file=config) if (high_mem_hpa_len[i] != 0) and (high_mem_hpa2_len[i] != 0): print("\t{\t/* high mem after 4GB*/", file=config) print("\t\t.baseaddr = {}UL,\t/* 4 GB */".format(hex(FOUR_GBYTE)), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(high_mem_hpa_len[i]), high_mem_hpa_len[i] / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("\t{\t/* HPA2 after high mem*/", file=config) print("\t\t.baseaddr = {}UL,\t/* {}GB */".format( hex(high_mem_hpa2_addr[i]), high_mem_hpa2_addr[i] / 1024 / 1024 / 1024), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(high_mem_hpa2_len[i]), high_mem_hpa2_len[i] / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) elif (high_mem_hpa_len[i] != 0): print("\t{\t/* high mem after 4GB*/", file=config) print("\t\t.baseaddr = {}UL,\t/* 4 GB */".format(hex(FOUR_GBYTE)), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(high_mem_hpa_len[i]), high_mem_hpa_len[i] / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) elif (high_mem_hpa2_len[i] != 0): print("\t{\t/* HPA2 after 4GB*/", file=config) print("\t\t.baseaddr = {}UL,\t/* 4 GB */".format(hex(FOUR_GBYTE)), file=config) print("\t\t.length = {}UL,\t/* {}MB */".format( hex(high_mem_hpa2_len[i]), high_mem_hpa2_len[i] / 1024 / 1024), file=config) print("\t\t.type = E820_TYPE_RAM", file=config) print("\t},", file=config) print("", file=config) print("};", file=config) print("", file=config) print("/**", file=config) print(" * @pre vm != NULL", file=config) print("*/", file=config) print("void create_prelaunched_vm_e820(struct acrn_vm *vm)", file=config) print("{", file=config) for i in range(pre_vm_cnt): print("\tif (vm->vm_id == {}U)".format(hex(i)), file=config) print("\t{", file=config) print("\t\tvm->e820_entry_num = VM{}_VE820_ENTRIES_{};".format( i, board_name), file=config) print("\t\tvm->e820_entries = vm{}_ve820_entry;".format(i), file=config) print("\t}", file=config) print("", file=config) print("}", file=config) 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 """ global ACRN_CONFIG_TARGET err_dic = {} (err_dic, board_info_file, scenario_info_file, output_folder) = board_cfg_lib.get_param(args) if err_dic: return err_dic if output_folder: ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/' # check env err_dic = board_cfg_lib.prepare() if err_dic: return err_dic board_cfg_lib.BOARD_INFO_FILE = board_info_file board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file board_cfg_lib.get_vm_count(scenario_info_file) # get board name (err_dic, board) = board_cfg_lib.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) = board_cfg_lib.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 board_dir = ACRN_CONFIG_TARGET + board + '/' board_cfg_lib.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] config_board_kconfig = ACRN_CONFIG_TARGET + 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