def parse_boot_info(): err_dic = {} vm_types = [] (err_dic, scenario_name) = board_cfg_lib.get_scenario_name() if err_dic: return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types) if scenario_name != "logical_partition": sos_cmdlines = board_cfg_lib.get_sub_leaf_tag( board_cfg_lib.SCENARIO_INFO_FILE, "board_private", "bootargs") sos_rootfs = board_cfg_lib.get_sub_leaf_tag( board_cfg_lib.SCENARIO_INFO_FILE, "board_private", "rootfs") (err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart( "board_private", "console") else: sos_cmdlines = board_cfg_lib.get_sub_leaf_tag( board_cfg_lib.SCENARIO_INFO_FILE, "os_config", "bootargs") sos_rootfs = board_cfg_lib.get_sub_leaf_tag( board_cfg_lib.SCENARIO_INFO_FILE, "os_config", "rootfs") (err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart( "os_config", "console") for i in range(board_cfg_lib.VM_COUNT): vm_type = board_cfg_lib.get_order_type_by_vmid(i) vm_types.append(vm_type) return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
def get_serial_type(): """ Get serial console type specified by user """ ttys_type = '' ttys_value = '' # Get ttySx information from board config file ttys_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>") scenario_name = board_cfg_lib.get_scenario_name() if scenario_name == "logical_partition": ttyn = 'ttyS0' else: # Get ttySx from scenario config file which selected by user (err_dic, ttyn) = board_cfg_lib.parser_vuart_console() if err_dic: board_cfg_lib.ERR_LIST.update(err_dic) # query the serial type from board config file for line in ttys_lines: if ttyn in line: # line format: # seri:/dev/ttyS0 type:portio base:0x3F8 irq:4 # seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 bdf:"0:x.y" ttys_type = line.split()[1].split(':')[1] if ttys_type == "portio": ttys_value = line.split()[2].split(':')[1] elif ttys_type == "mmio": ttys_value = line.split()[-1].split(':')[1] break return (ttys_type, ttys_value)
def generate_file(config): """Start to generate board.c :param config: it is a file pointer of board information for writing to """ err_dic = {} # this dictonary mapped with 'address start':'mem range' ram_range = {} if board_cfg_lib.VM_COUNT in list(VM_NUM_MAP_TOTAL_HV_RAM_SIZE.keys()): hv_ram_size = VM_NUM_MAP_TOTAL_HV_RAM_SIZE[board_cfg_lib.VM_COUNT] else: board_cfg_lib.print_red("VM num should not be greater than 8", err=True) err_dic["board config: total vm number error"] = "VM num should not be greater than 8" return err_dic ram_range = get_ram_range() # reseve 16M memory for hv sbuf, ramoops, etc. reserved_ram = 0x1000000 # We recommend to put hv ram start address high than 0x10000000 to # reduce memory conflict with GRUB/SOS Kernel. hv_start_offset = 0x10000000 total_size = reserved_ram + hv_ram_size avl_start_addr = find_avl_memory(ram_range, str(total_size), hv_start_offset) hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16) hv_start_addr = board_cfg_lib.round_up(hv_start_addr, MEM_ALIGN) # add config scenario name (err_dic, scenario_name) = board_cfg_lib.get_scenario_name() print("{}".format(DESC), file=config) print("CONFIG_{}=y".format(scenario_name.upper()), file=config) print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config) (serial_type, serial_value) = get_serial_type() if serial_type == "portio": print("CONFIG_SERIAL_LEGACY=y", file=config) print("CONFIG_SERIAL_PIO_BASE={}".format(serial_value), file=config) if serial_type == "mmio": print("CONFIG_SERIAL_PCI=y", file=config) print('CONFIG_SERIAL_PCI_BDF="{}"'.format(serial_value), file=config) print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config) print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config) cpu_core_num = len(board_cfg_lib.get_processor_info()) if scenario_name == "sdc" and cpu_core_num > 2: print("CONFIG_MAX_KATA_VM_NUM=1", file=config) else: if cpu_core_num == 2: print("# KATA VM is not supported on dual-core systems", file=config) print("CONFIG_MAX_KATA_VM_NUM=0", file=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