Skip to content

Commit 77c17ab

Browse files
Wei Liuwenlingz
authored andcommitted
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>
1 parent a95a88c commit 77c17ab

File tree

13 files changed

+317
-102
lines changed

13 files changed

+317
-102
lines changed

misc/acrn-config/board_config/acpi_platform_h.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ def style_check_2(self):
3131

3232

3333
def multi_parser(line, s_line, pm_ac_sz, config):
34-
"""Multi parser the line"""
34+
"""Multi parser the line
35+
:param line: it is a line read from default_acpi_info.h
36+
:param s_line: it is a line read from board information file
37+
:param pm_ac_sz: it is a class for access size which would be override
38+
:param config: it is a file pointer to write acpi information
39+
"""
3540
addr = ['PM1A_EVT_ADDRESS', 'PM1B_EVT_ADDRESS', 'PM1A_CNT_ADDRESS', 'PM1B_CNT_ADDRESS']
3641
space_id = ['PM1A_EVT_SPACE_ID', 'PM1B_EVT_SPACE_ID', 'PM1A_CNT_SPACE_ID', 'PM1B_CNT_SPACE_ID']
3742

@@ -71,7 +76,12 @@ def multi_parser(line, s_line, pm_ac_sz, config):
7176

7277

7378
def multi_info_parser(config, default_platform, msg_s, msg_e):
74-
"""Parser multi information"""
79+
"""Parser multi information
80+
:param config: it is a file pointer to write acpi information
81+
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
82+
:param msg_s: it is a pattern of key stings what start to match from board information
83+
:param msg_e: it is a pattern of key stings what end to match from board information
84+
"""
7585
write_direct = ['PM1A_EVT_ACCESS_SIZE', 'PM1A_EVT_ADDRESS', 'PM1A_CNT_ADDRESS']
7686

7787
pm_ac_sz = OverridAccessSize()
@@ -99,7 +109,11 @@ def multi_info_parser(config, default_platform, msg_s, msg_e):
99109

100110

101111
def write_direct_info_parser(config, msg_s, msg_e):
102-
"""Direct to write"""
112+
"""Direct to write
113+
:param config: it is a file pointer to write acpi information
114+
:param msg_s: it is a pattern of key stings what start to match from board information
115+
:param msg_e: it is a pattern of key stings what end to match from board information
116+
"""
103117
vector_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, msg_s, msg_e)
104118

105119
for vector in vector_lines:
@@ -109,7 +123,9 @@ def write_direct_info_parser(config, msg_s, msg_e):
109123

110124

111125
def drhd_info_parser(config):
112-
"""Parser DRHD information"""
126+
"""Parser DRHD information
127+
:param config: it is a file pointer to write acpi information
128+
"""
113129
prev_num = 0
114130

115131
drhd_lines = board_cfg_lib.get_info(
@@ -133,7 +149,10 @@ def drhd_info_parser(config):
133149

134150

135151
def platform_info_parser(config, default_platform):
136-
"""Parser ACPI information"""
152+
"""Parser ACPI information
153+
:param config: it is a file pointer to write acpi information
154+
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
155+
"""
137156
print("\n/* pm sstate data */", file=config)
138157
multi_info_parser(config, default_platform, "<PM_INFO>", "</PM_INFO>")
139158
multi_info_parser(config, default_platform, "<S3_INFO>", "</S3_INFO>")
@@ -146,7 +165,10 @@ def platform_info_parser(config, default_platform):
146165

147166

148167
def generate_file(config, default_platform):
149-
"""write board_name_acpi_info.h"""
168+
"""write board_name_acpi_info.h
169+
:param config: it is a file pointer to write acpi information
170+
:param default_platform: it is the default_acpi_info.h in acrn-hypervisor
171+
"""
150172
print("{}".format(board_cfg_lib.HEADER_LICENSE), file=config)
151173

152174
print("{}".format(PLATFORM_HEADER), file=config)

misc/acrn-config/board_config/board_c.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def clos_info_parser():
2626

2727

2828
def gen_cat(config):
29-
"""Get CAT information"""
29+
"""Get CAT information
30+
:param config: it is a file pointer of board information for writing to
31+
"""
3032
(cache_support, clos_max) = clos_info_parser()
3133

3234
print("\n#include <board.h>", file=config)
@@ -48,7 +50,8 @@ def gen_cat(config):
4850
elif cache_support == "L3":
4951
print("\t\t.msr_index = {0}U,".format(hex(0x00000C90+i_cnt)), file=config)
5052
else:
51-
board_cfg_lib.print_red("The input of board_info.txt was corrupted!")
53+
board_cfg_lib.print_red("The input of {} was corrupted!".format(
54+
board_cfg_lib.BOARD_INFO_FILE))
5255
sys.exit(1)
5356
print("\t},", file=config)
5457

@@ -61,7 +64,9 @@ def gen_cat(config):
6164

6265

6366
def gen_px_cx(config):
64-
"""Get Px/Cx and store them to board.c"""
67+
"""Get Px/Cx and store them to board.c
68+
:param config: it is a file pointer of board information for writing to
69+
"""
6570
cpu_brand_lines = board_cfg_lib.get_info(
6671
board_cfg_lib.BOARD_INFO_FILE, "<CPU_BRAND>", "</CPU_BRAND>")
6772
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):
9297

9398

9499
def generate_file(config):
95-
"""Start to generate board.c"""
100+
"""Start to generate board.c
101+
:param config: it is a file pointer of board information for writing to
102+
"""
96103
print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config)
97104

98105
# insert bios info into board.c

misc/acrn-config/board_config/board_cfg_gen.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def prepare():
5454

5555

5656
def gen_patch(srcs_list, board_name):
57-
"""Generate patch and apply to local source code"""
57+
"""Generate patch and apply to local source code
58+
:param srcs_list: it is a list what contains source files
59+
:param board_name: board name
60+
"""
5861
changes = ' '.join(srcs_list)
5962
git_add = "git add {}".format(changes)
6063
subprocess.call(git_add, shell=True, stdout=subprocess.PIPE,
@@ -67,7 +70,9 @@ def gen_patch(srcs_list, board_name):
6770

6871

6972
def main(board_info_file):
70-
"""This is main function to start generate source code related with board"""
73+
"""This is main function to start generate source code related with board
74+
:param board_info_file: it is a file what contains board information for script to read from
75+
"""
7176
board = ''
7277
config_srcs = []
7378
config_dirs = []
@@ -101,7 +106,7 @@ def main(board_info_file):
101106
with open(config_platform, 'w+') as config:
102107
acpi_platform_h.generate_file(config, ACRN_DEFAULT_PLATFORM)
103108

104-
# move changes to patch, and applay to the source code
109+
# move changes to patch, and apply to the source code
105110
gen_patch(config_srcs, board)
106111

107112
if board not in BOARD_NAMES:
@@ -131,7 +136,6 @@ def usage():
131136
board_cfg_lib.print_red("{} is not exist!".format(BOARD_INFO_FILE))
132137
sys.exit(1)
133138

134-
# board_info.txt will be override
135139
board_cfg_lib.BOARD_INFO_FILE = BOARD_INFO_FILE
136140

137141
main(BOARD_INFO_FILE)

misc/acrn-config/board_config/board_cfg_lib.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,31 @@ def open_license():
2828

2929

3030
def print_yel(msg, warn=False):
31-
"""Print the message with color of yellow"""
31+
"""Print the message with color of yellow
32+
:param msg: the stings which will be output to STDOUT
33+
:param warn: the condition if needs to be output the color of yellow with 'Warning'
34+
"""
3235
if warn:
3336
print("\033[1;33mWarning\033[0m:"+msg)
3437
else:
3538
print("\033[1;33m{0}\033[0m".format(msg))
3639

3740

3841
def print_red(msg, err=False):
39-
"""Print the message with color of red"""
42+
"""Print the message with color of red
43+
:param msg: the stings which will be output to STDOUT
44+
:param err: the condition if needs to be output the color of red with 'Error'
45+
"""
4046
if err:
4147
print("\033[1;31mError\033[0m:"+msg)
4248
else:
4349
print("\033[1;31m{0}\033[0m".format(msg))
4450

4551

4652
def get_board_name(board_info):
47-
"""Get board name"""
53+
"""Get board name from board.xml at fist line
54+
:param board_info: it is a file what contains board information for script to read from
55+
"""
4856
with open(board_info, 'rt') as f_board:
4957
line = f_board.readline()
5058
if not "board=" in line:
@@ -56,7 +64,11 @@ def get_board_name(board_info):
5664

5765

5866
def get_info(board_info, msg_s, msg_e):
59-
"""Get information which specify by argument"""
67+
"""Get information which specify by argument
68+
:param board_info: it is a file what contains board information for script to read from
69+
:param msg_s: it is a pattern of key stings what start to match from board information
70+
:param msg_e: it is a pattern of key stings what end to match from board information
71+
"""
6072
info_start = False
6173
info_end = False
6274
info_lines = []
@@ -93,7 +105,9 @@ def get_info(board_info, msg_s, msg_e):
93105

94106

95107
def handle_bios_info(config):
96-
"""Handle bios information"""
108+
"""Handle bios information
109+
:param config: it is a file pointer of bios information for writing to
110+
"""
97111
bios_lines = get_info(BOARD_INFO_FILE, "<BIOS_INFO>", "</BIOS_INFO>")
98112
board_lines = get_info(BOARD_INFO_FILE, "<BASE_BOARD_INFO>", "</BASE_BOARD_INFO>")
99113
print("/*", file=config)
@@ -116,9 +130,9 @@ def handle_bios_info(config):
116130

117131
i_cnt += 1
118132

119-
for mics_info in bios_board_info:
120-
if mics_info == " ".join(line.split()[0:1]) or mics_info == \
121-
" ".join(line.split()[0:2]) or mics_info == " ".join(line.split()[0:3]):
133+
for misc_info in bios_board_info:
134+
if misc_info == " ".join(line.split()[0:1]) or misc_info == \
135+
" ".join(line.split()[0:2]) or misc_info == " ".join(line.split()[0:3]):
122136
print(" * {0}".format(line.strip()), file=config)
123137

124138
print(" */", file=config)

misc/acrn-config/board_config/pci_devices_h.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ def parser_pci():
6868

6969

7070
def write_pbdf(i_cnt, bdf, subname, config):
71-
"""Parser and generate pbdf"""
71+
"""Parser and generate pbdf
72+
:param i_cnt: the number of pci devices have the same PCI subname
73+
:param bdf: it is a string what contains BDF
74+
:param subname: it is a string belong to PIC subname
75+
:param config: it is a file pointer of pci information for writing to
76+
"""
7277
# if there is only one host bridge, then will discard the index of suffix
7378
if i_cnt == 0 and subname.upper() == "HOST BRIDGE":
7479
tmp_sub_name = "_".join(subname.split()).upper()
@@ -84,7 +89,11 @@ def write_pbdf(i_cnt, bdf, subname, config):
8489

8590

8691
def write_vbar(bdf, pci_bar_dic, config):
87-
"""Parser and generate vbar"""
92+
"""Parser and generate vbar
93+
:param bdf: it is a string what contains BDF
94+
:param pci_bar_dic: it is a dictionary of pci vbar for those BDF
95+
:param config: it is a file pointer of pci information for writing to
96+
"""
8897
tail = 0
8998
align = ' ' * 48
9099
if bdf in pci_bar_dic.keys():
@@ -110,7 +119,9 @@ def write_vbar(bdf, pci_bar_dic, config):
110119

111120

112121
def generate_file(config):
113-
"""Get PCI device and generate pci_devices.h"""
122+
"""Get PCI device and generate pci_devices.h
123+
:param config: it is a file pointer of pci information for writing to
124+
"""
114125

115126
# write the license into pci
116127
print("{0}".format(board_cfg_lib.HEADER_LICENSE), file=config)

0 commit comments

Comments
 (0)