mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-29 16:58:10 +00:00
acrn-config: generate dmar info for board.c
1. Parse DRHD_INFO section from board config xml, and generate dmar structure information to board.c 2. Copy macro of DRHD_INFO from board config xml to $(board)_acpi_platform.h Tracked-On: #3854 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
ad9f424ce5
commit
7b0cafa84f
@ -12,7 +12,7 @@ PLATFORM_HEADER = r"""/* DO NOT MODIFY THIS FILE UNLESS YOU KNOW WHAT YOU ARE DO
|
||||
#define PLATFORM_ACPI_INFO_H
|
||||
"""
|
||||
|
||||
PLATFORM_END_HEADER = "\n#endif /* PLATFORM_ACPI_INFO_H */"
|
||||
PLATFORM_END_HEADER = "#endif /* PLATFORM_ACPI_INFO_H */"
|
||||
|
||||
|
||||
class OverridAccessSize():
|
||||
@ -144,18 +144,7 @@ def drhd_info_parser(config):
|
||||
# write DRHD
|
||||
print("/* DRHD of DMAR */", file=config)
|
||||
for drhd in drhd_lines:
|
||||
cur_num = drhd.strip().split()[1][4:5]
|
||||
|
||||
if drhd.strip().split()[1] == "DRHD_COUNT":
|
||||
print("", file=config)
|
||||
print("{}".format(drhd.strip()), file=config)
|
||||
continue
|
||||
|
||||
if cur_num != prev_num:
|
||||
print("", file=config)
|
||||
|
||||
print("{}".format(drhd.strip()), file=config)
|
||||
prev_num = cur_num
|
||||
print(drhd.strip(), file=config)
|
||||
|
||||
|
||||
def platform_info_parser(config, default_platform):
|
||||
|
@ -18,6 +18,62 @@ MSR_IA32_L3_MASK_BASE = 0x00000C90
|
||||
MSR_IA32_L3_MASK_END = 0x00000D0F
|
||||
|
||||
|
||||
def gen_dmar_structure(config):
|
||||
"""Generate dmar structure information"""
|
||||
|
||||
dmar_info_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>")
|
||||
drhd_cnt = 0
|
||||
drhd_dev_scope_cnt = []
|
||||
dev_scope_type = []
|
||||
|
||||
# parse to get DRHD count and dev scope count
|
||||
for dmar_line in dmar_info_lines:
|
||||
if "DRHD_COUNT" in dmar_line and not drhd_cnt:
|
||||
drhd_cnt = int(dmar_line.split()[2].strip('U'))
|
||||
|
||||
for i_cnt in range(drhd_cnt):
|
||||
for dmar_line in dmar_info_lines:
|
||||
dev_scope_cnt_str = "DRHD{}_DEV_CNT".format(i_cnt)
|
||||
|
||||
if dev_scope_cnt_str in dmar_line:
|
||||
tmp_dev_scope_cnt = int(dmar_line.split()[2].strip('U'), 16)
|
||||
drhd_dev_scope_cnt.append(tmp_dev_scope_cnt)
|
||||
|
||||
# gen dmar structure information
|
||||
for i_drhd_cnt in range(drhd_cnt):
|
||||
dev_cnt = drhd_dev_scope_cnt[i_drhd_cnt]
|
||||
print("static struct dmar_dev_scope drhd{}_dev_scope[DRHD{}_DEV_CNT] = {{".format(
|
||||
i_drhd_cnt, i_drhd_cnt), file=config)
|
||||
for i_dev_cnt in range(dev_cnt):
|
||||
print("\t{", file=config)
|
||||
print("\t\t.type = DRHD{}_DEVSCOPE{}_TYPE,".format(i_drhd_cnt, i_dev_cnt), file=config)
|
||||
print("\t\t.id = DRHD{}_DEVSCOPE{}_ID,".format(i_drhd_cnt, i_dev_cnt), file=config)
|
||||
print("\t\t.bus = DRHD{}_DEVSCOPE{}_BUS,".format(i_drhd_cnt, i_dev_cnt), file=config)
|
||||
print("\t\t.devfun = DRHD{}_DEVSCOPE{}_PATH,".format(i_drhd_cnt, i_dev_cnt), file=config)
|
||||
print("\t},", file=config)
|
||||
|
||||
print("};", file=config)
|
||||
print("", file=config)
|
||||
|
||||
print("static struct dmar_drhd drhd_info_array[DRHD_COUNT] = {", file=config)
|
||||
for i_drhd_cnt in range(drhd_cnt):
|
||||
print("\t{", file=config)
|
||||
print("\t\t.dev_cnt = DRHD{}_DEV_CNT,".format(i_drhd_cnt), file=config)
|
||||
print("\t\t.segment = DRHD{}_SEGMENT,".format(i_drhd_cnt), file=config)
|
||||
print("\t\t.flags = DRHD{}_FLAGS,".format(i_drhd_cnt), file=config)
|
||||
print("\t\t.reg_base_addr = DRHD{}_REG_BASE,".format(i_drhd_cnt), file=config)
|
||||
print("\t\t.ignore = DRHD{}_IGNORE,".format(i_drhd_cnt), file=config)
|
||||
print("\t\t.devices = drhd{}_dev_scope".format(i_drhd_cnt), file=config)
|
||||
print("\t},", file=config)
|
||||
|
||||
print("};", file=config)
|
||||
print("", file=config)
|
||||
print("struct dmar_info plat_dmar_info = {", file=config)
|
||||
print("\t.drhd_count = DRHD_COUNT,", file=config)
|
||||
print("\t.drhd_units = drhd_info_array,", file=config)
|
||||
print("};", file=config)
|
||||
|
||||
|
||||
def gen_cat(config):
|
||||
"""
|
||||
Get CAT information
|
||||
@ -101,12 +157,15 @@ def generate_file(config):
|
||||
board_cfg_lib.handle_bios_info(config)
|
||||
print(INCLUDE_HEADER, file=config)
|
||||
|
||||
# start to parser to get CAT info
|
||||
# start to parse DMAR info
|
||||
gen_dmar_structure(config)
|
||||
|
||||
# start to parse to get CAT info
|
||||
err_dic = gen_cat(config)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
# start to parser PX/CX info
|
||||
# start to parse PX/CX info
|
||||
gen_px_cx(config)
|
||||
|
||||
return err_dic
|
||||
|
Loading…
Reference in New Issue
Block a user