diff --git a/misc/acrn-config/board_config/board_c.py b/misc/acrn-config/board_config/board_c.py index 8346b0814..80a6f9124 100644 --- a/misc/acrn-config/board_config/board_c.py +++ b/misc/acrn-config/board_config/board_c.py @@ -48,6 +48,26 @@ def gen_cat(config): return err_dic +def gen_single_data(data_lines, domain_str, config): + line_i = 0 + data_statues = True + data_len = len(data_lines) + for data_l in data_lines: + if line_i == 0: + if "not available" in data_l: + print(data_l.strip(), file=config) + print("static const struct cpu_{}x_data board_cpu_{}x[0];".format(domain_str, domain_str), file=config) + print("", file=config) + data_statues = False + break + else: + print("static const struct cpu_{}x_data board_cpu_{}x[{}] = {{".format(domain_str, domain_str, data_len), file=config) + print("\t{0}".format(data_l.strip()), file=config) + line_i += 1 + if data_statues: + print("};\n", file=config) + + def gen_px_cx(config): """ Get Px/Cx and store them to board.c @@ -58,18 +78,8 @@ def gen_px_cx(config): cx_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "", "") px_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "", "") - cx_len = len(cx_lines) - px_len = len(px_lines) - #print("#ifdef CONFIG_CPU_POWER_STATES_SUPPORT", file=config) - print("static const struct cpu_cx_data board_cpu_cx[%s] = {"%str(cx_len), file=config) - for cx_l in cx_lines: - print("\t{0}".format(cx_l.strip()), file=config) - print("};\n", file=config) - - print("static const struct cpu_px_data board_cpu_px[%s] = {"%str(px_len), file=config) - for px_l in px_lines: - print("\t{0}".format(px_l.strip()), file=config) - print("};\n", file=config) + gen_single_data(cx_lines, 'c', config) + gen_single_data(px_lines, 'p', config) for brand_line in cpu_brand_lines: cpu_brand = brand_line @@ -79,7 +89,6 @@ def gen_px_cx(config): print("\t{(uint8_t)ARRAY_SIZE(board_cpu_px), board_cpu_px,", file=config) print("\t(uint8_t)ARRAY_SIZE(board_cpu_cx), board_cpu_cx}", file=config) print("};", file=config) - #print("#endif", file=config) def generate_file(config): diff --git a/misc/acrn-config/target/acpi.py b/misc/acrn-config/target/acpi.py index 60be0ba30..53e3e9e0c 100644 --- a/misc/acrn-config/target/acpi.py +++ b/misc/acrn-config/target/acpi.py @@ -421,13 +421,15 @@ def store_cx_data(sysnode1, sysnode2, config): idle_driver = acpi_idle.read(32) if idle_driver.find("acpi_idle") == -1: + parser_lib.print_yel("The Cx data for ACRN relies on " +\ + "acpi_idle driver but it is not found, ", warn=True, end=False) if idle_driver.find("intel_idle") == 0: - parser_lib.print_red("The tool need to run with acpi_idle driver, " + - "please add intel_idle.max_cstate=0 in kernel " + - "cmdline to fall back to acpi_idle driver", err=True) + print("please add idle=nomwait in kernel " +\ + "cmdline to fall back to acpi_idle driver") else: - parser_lib.print_red("acpi_idle driver is not found.", err=True) - sys.exit(1) + parser_lib.print_yel("please make sure ACPI Cstate is enabled in BIOS.", warn=True) + print("\t/* Cx data is not available */", file=config) + return files = os.listdir(sysnode2) for d_path in files: @@ -487,13 +489,15 @@ def store_px_data(sysnode, config): with open(sysnode+'cpu0/cpufreq/scaling_driver', 'r') as f_node: freq_driver = f_node.read() if freq_driver.find("acpi-cpufreq") == -1: + parser_lib.print_yel("The Px data for ACRN relies on " +\ + "acpi-cpufreq driver but it is not found, ", warn=True, end=False) if freq_driver.find("intel_pstate") == 0: - parser_lib.print_red("The tool need to run with acpi_cpufreq driver, " + - "please add intel_pstate=disable in kernel cmdline " + - "to fall back to acpi-cpufreq driver.", err=True) + print("please add intel_pstate=disable in kernel " +\ + "cmdline to fall back to acpi-cpufreq driver") else: - parser_lib.print_red("acpi-cpufreq driver is not found.", err=True) - sys.exit(1) + parser_lib.print_yel("please make sure ACPI Pstate is enabled in BIOS.", warn=True) + print("\t/* Px data is not available */", file=config) + return try: with open(sysnode+'cpufreq/boost', 'r') as f_node: diff --git a/misc/acrn-config/target/parser_lib.py b/misc/acrn-config/target/parser_lib.py index adc41f554..aa43bb980 100644 --- a/misc/acrn-config/target/parser_lib.py +++ b/misc/acrn-config/target/parser_lib.py @@ -16,15 +16,22 @@ def check_dmi(): return os.path.exists("/sys/firmware/dmi") -def print_yel(msg, warn=False): +def print_yel(msg, warn=False, end=True): """Output the message with the color of yellow :param msg: the stings which will be output to STDOUT :param warn: the condition if needs to be output the color of yellow with 'Warning' + :param end: The flag of it needs to combine with the next line for stdout """ if warn: - print("\033[1;33mWarning\033[0m:"+msg) + if end: + print("\033[1;33mWarning\033[0m:"+msg) + else: + print("\033[1;33mWarning\033[0m:"+msg, end="") else: - print("\033[1;33m{0}\033[0m".format(msg)) + if end: + print("\033[1;33m{}\033[0m".format(msg)) + else: + print("\033[1;33m{}\033[0m".format(msg), end="") def print_red(msg, err=False):