mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
acrn-config: enhance the target config
1. add misc.py to get systemd ram and root device
2. add more specify comments for arguments of functions
v1-v2:
typo: Parser -> Parse
some grammar check
v2-v3:
add the message for Cx state
Tracked-On: #3602
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Terry Zou <terry.zou@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
@@ -31,7 +31,12 @@ class OverridAccessSize():
|
||||
|
||||
|
||||
def multi_parser(line, s_line, pm_ac_sz, config):
|
||||
"""Multi parser the line"""
|
||||
"""Multi parser the line
|
||||
:param line: it is a line read from default_acpi_info.h
|
||||
:param s_line: it is a line read from board information file
|
||||
:param pm_ac_sz: it is a class for access size which would be override
|
||||
:param config: it is a file pointer to write acpi information
|
||||
"""
|
||||
addr = ['PM1A_EVT_ADDRESS', 'PM1B_EVT_ADDRESS', 'PM1A_CNT_ADDRESS', 'PM1B_CNT_ADDRESS']
|
||||
space_id = ['PM1A_EVT_SPACE_ID', 'PM1B_EVT_SPACE_ID', 'PM1A_CNT_SPACE_ID', 'PM1B_CNT_SPACE_ID']
|
||||
|
||||
@@ -71,7 +76,12 @@ def multi_parser(line, s_line, pm_ac_sz, config):
|
||||
|
||||
|
||||
def multi_info_parser(config, default_platform, msg_s, msg_e):
|
||||
"""Parser multi information"""
|
||||
"""Parser multi information
|
||||
:param config: it is a file pointer to write acpi information
|
||||
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
write_direct = ['PM1A_EVT_ACCESS_SIZE', 'PM1A_EVT_ADDRESS', 'PM1A_CNT_ADDRESS']
|
||||
|
||||
pm_ac_sz = OverridAccessSize()
|
||||
@@ -99,7 +109,11 @@ def multi_info_parser(config, default_platform, msg_s, msg_e):
|
||||
|
||||
|
||||
def write_direct_info_parser(config, msg_s, msg_e):
|
||||
"""Direct to write"""
|
||||
"""Direct to write
|
||||
:param config: it is a file pointer to write acpi information
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
vector_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, msg_s, msg_e)
|
||||
|
||||
for vector in vector_lines:
|
||||
@@ -109,7 +123,9 @@ def write_direct_info_parser(config, msg_s, msg_e):
|
||||
|
||||
|
||||
def drhd_info_parser(config):
|
||||
"""Parser DRHD information"""
|
||||
"""Parser DRHD information
|
||||
:param config: it is a file pointer to write acpi information
|
||||
"""
|
||||
prev_num = 0
|
||||
|
||||
drhd_lines = board_cfg_lib.get_info(
|
||||
@@ -133,7 +149,10 @@ def drhd_info_parser(config):
|
||||
|
||||
|
||||
def platform_info_parser(config, default_platform):
|
||||
"""Parser ACPI information"""
|
||||
"""Parser ACPI information
|
||||
:param config: it is a file pointer to write acpi information
|
||||
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
|
||||
"""
|
||||
print("\n/* pm sstate data */", file=config)
|
||||
multi_info_parser(config, default_platform, "<PM_INFO>", "</PM_INFO>")
|
||||
multi_info_parser(config, default_platform, "<S3_INFO>", "</S3_INFO>")
|
||||
@@ -146,7 +165,10 @@ def platform_info_parser(config, default_platform):
|
||||
|
||||
|
||||
def generate_file(config, default_platform):
|
||||
"""write board_name_acpi_info.h"""
|
||||
"""write board_name_acpi_info.h
|
||||
:param config: it is a file pointer to write acpi information
|
||||
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
|
||||
"""
|
||||
print("{}".format(board_cfg_lib.HEADER_LICENSE), file=config)
|
||||
|
||||
print("{}".format(PLATFORM_HEADER), file=config)
|
||||
|
||||
@@ -26,7 +26,9 @@ def clos_info_parser():
|
||||
|
||||
|
||||
def gen_cat(config):
|
||||
"""Get CAT information"""
|
||||
"""Get CAT information
|
||||
:param config: it is a file pointer of board information for writing to
|
||||
"""
|
||||
(cache_support, clos_max) = clos_info_parser()
|
||||
|
||||
print("\n#include <board.h>", file=config)
|
||||
@@ -48,7 +50,8 @@ def gen_cat(config):
|
||||
elif cache_support == "L3":
|
||||
print("\t\t.msr_index = {0}U,".format(hex(0x00000C90+i_cnt)), file=config)
|
||||
else:
|
||||
board_cfg_lib.print_red("The input of board_info.txt was corrupted!")
|
||||
board_cfg_lib.print_red("The input of {} was corrupted!".format(
|
||||
board_cfg_lib.BOARD_INFO_FILE))
|
||||
sys.exit(1)
|
||||
print("\t},", file=config)
|
||||
|
||||
@@ -61,7 +64,9 @@ def gen_cat(config):
|
||||
|
||||
|
||||
def gen_px_cx(config):
|
||||
"""Get Px/Cx and store them to board.c"""
|
||||
"""Get Px/Cx and store them to board.c
|
||||
:param config: it is a file pointer of board information for writing to
|
||||
"""
|
||||
cpu_brand_lines = board_cfg_lib.get_info(
|
||||
board_cfg_lib.BOARD_INFO_FILE, "<CPU_BRAND>", "</CPU_BRAND>")
|
||||
cx_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "<CX_INFO>", "</CX_INFO>")
|
||||
@@ -92,7 +97,9 @@ def gen_px_cx(config):
|
||||
|
||||
|
||||
def generate_file(config):
|
||||
"""Start to generate board.c"""
|
||||
"""Start to generate board.c
|
||||
:param config: it is a file pointer of board information for writing to
|
||||
"""
|
||||
print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config)
|
||||
|
||||
# insert bios info into board.c
|
||||
|
||||
@@ -54,7 +54,10 @@ def prepare():
|
||||
|
||||
|
||||
def gen_patch(srcs_list, board_name):
|
||||
"""Generate patch and apply to local source code"""
|
||||
"""Generate patch and apply to local source code
|
||||
:param srcs_list: it is a list what contains source files
|
||||
:param board_name: board name
|
||||
"""
|
||||
changes = ' '.join(srcs_list)
|
||||
git_add = "git add {}".format(changes)
|
||||
subprocess.call(git_add, shell=True, stdout=subprocess.PIPE,
|
||||
@@ -67,7 +70,9 @@ def gen_patch(srcs_list, board_name):
|
||||
|
||||
|
||||
def main(board_info_file):
|
||||
"""This is main function to start generate source code related with board"""
|
||||
"""This is main function to start generate source code related with board
|
||||
:param board_info_file: it is a file what contains board information for script to read from
|
||||
"""
|
||||
board = ''
|
||||
config_srcs = []
|
||||
config_dirs = []
|
||||
@@ -101,7 +106,7 @@ def main(board_info_file):
|
||||
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
|
||||
# move changes to patch, and apply to the source code
|
||||
gen_patch(config_srcs, board)
|
||||
|
||||
if board not in BOARD_NAMES:
|
||||
@@ -131,7 +136,6 @@ if __name__ == '__main__':
|
||||
board_cfg_lib.print_red("{} is not exist!".format(BOARD_INFO_FILE))
|
||||
sys.exit(1)
|
||||
|
||||
# board_info.txt will be override
|
||||
board_cfg_lib.BOARD_INFO_FILE = BOARD_INFO_FILE
|
||||
|
||||
main(BOARD_INFO_FILE)
|
||||
|
||||
@@ -28,7 +28,10 @@ HEADER_LICENSE = open_license() + "\n"
|
||||
|
||||
|
||||
def print_yel(msg, warn=False):
|
||||
"""Print the message with color of yellow"""
|
||||
"""Print the message with 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'
|
||||
"""
|
||||
if warn:
|
||||
print("\033[1;33mWarning\033[0m:"+msg)
|
||||
else:
|
||||
@@ -36,7 +39,10 @@ def print_yel(msg, warn=False):
|
||||
|
||||
|
||||
def print_red(msg, err=False):
|
||||
"""Print the message with color of red"""
|
||||
"""Print the message with color of red
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param err: the condition if needs to be output the color of red with 'Error'
|
||||
"""
|
||||
if err:
|
||||
print("\033[1;31mError\033[0m:"+msg)
|
||||
else:
|
||||
@@ -44,7 +50,9 @@ def print_red(msg, err=False):
|
||||
|
||||
|
||||
def get_board_name(board_info):
|
||||
"""Get board name"""
|
||||
"""Get board name from board.xml at fist line
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
"""
|
||||
with open(board_info, 'rt') as f_board:
|
||||
line = f_board.readline()
|
||||
if not "board=" in line:
|
||||
@@ -56,7 +64,11 @@ def get_board_name(board_info):
|
||||
|
||||
|
||||
def get_info(board_info, msg_s, msg_e):
|
||||
"""Get information which specify by argument"""
|
||||
"""Get information which specify by argument
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
info_start = False
|
||||
info_end = False
|
||||
info_lines = []
|
||||
@@ -93,7 +105,9 @@ def get_info(board_info, msg_s, msg_e):
|
||||
|
||||
|
||||
def handle_bios_info(config):
|
||||
"""Handle bios information"""
|
||||
"""Handle bios information
|
||||
:param config: it is a file pointer of bios information for writing to
|
||||
"""
|
||||
bios_lines = get_info(BOARD_INFO_FILE, "<BIOS_INFO>", "</BIOS_INFO>")
|
||||
board_lines = get_info(BOARD_INFO_FILE, "<BASE_BOARD_INFO>", "</BASE_BOARD_INFO>")
|
||||
print("/*", file=config)
|
||||
@@ -116,9 +130,9 @@ def handle_bios_info(config):
|
||||
|
||||
i_cnt += 1
|
||||
|
||||
for mics_info in bios_board_info:
|
||||
if mics_info == " ".join(line.split()[0:1]) or mics_info == \
|
||||
" ".join(line.split()[0:2]) or mics_info == " ".join(line.split()[0:3]):
|
||||
for misc_info in bios_board_info:
|
||||
if misc_info == " ".join(line.split()[0:1]) or misc_info == \
|
||||
" ".join(line.split()[0:2]) or misc_info == " ".join(line.split()[0:3]):
|
||||
print(" * {0}".format(line.strip()), file=config)
|
||||
|
||||
print(" */", file=config)
|
||||
|
||||
@@ -68,7 +68,12 @@ def parser_pci():
|
||||
|
||||
|
||||
def write_pbdf(i_cnt, bdf, subname, config):
|
||||
"""Parser and generate pbdf"""
|
||||
"""Parser and generate pbdf
|
||||
:param i_cnt: the number of pci devices have the same PCI subname
|
||||
:param bdf: it is a string what contains BDF
|
||||
:param subname: it is a string belong to PIC subname
|
||||
:param config: it is a file pointer of pci information for writing to
|
||||
"""
|
||||
# if there is only one host bridge, then will discard the index of suffix
|
||||
if i_cnt == 0 and subname.upper() == "HOST BRIDGE":
|
||||
tmp_sub_name = "_".join(subname.split()).upper()
|
||||
@@ -84,7 +89,11 @@ def write_pbdf(i_cnt, bdf, subname, config):
|
||||
|
||||
|
||||
def write_vbar(bdf, pci_bar_dic, config):
|
||||
"""Parser and generate vbar"""
|
||||
"""Parser and generate vbar
|
||||
:param bdf: it is a string what contains BDF
|
||||
:param pci_bar_dic: it is a dictionary of pci vbar for those BDF
|
||||
:param config: it is a file pointer of pci information for writing to
|
||||
"""
|
||||
tail = 0
|
||||
align = ' ' * 48
|
||||
if bdf in pci_bar_dic.keys():
|
||||
@@ -110,7 +119,9 @@ def write_vbar(bdf, pci_bar_dic, config):
|
||||
|
||||
|
||||
def generate_file(config):
|
||||
"""Get PCI device and generate pci_devices.h"""
|
||||
"""Get PCI device and generate pci_devices.h
|
||||
:param config: it is a file pointer of pci information for writing to
|
||||
"""
|
||||
|
||||
# write the license into pci
|
||||
print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config)
|
||||
|
||||
Reference in New Issue
Block a user