Skip to content

Commit d18fd5f

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: find 64-bit mmio for HI_MMIO_START/HI_MMIO_END
Find the 64-bit mmio window from /proc/iomem to generate HI_MMIO_START/HI_MMIO_END. Tracked-On: #4569 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
1 parent d9d5046 commit d18fd5f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

misc/acrn-config/board_config/misc_cfg_h.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,47 @@ def parse_boot_info():
7070
return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
7171

7272

73+
def find_hi_mmio_window(config):
74+
75+
i_cnt = 0
76+
mmio_min = 0
77+
mmio_max = 0
78+
is_hi_mmio = False
79+
80+
iomem_lines = board_cfg_lib.get_info(board_cfg_lib.BOARD_INFO_FILE, "<IOMEM_INFO>", "</IOMEM_INFO>")
81+
82+
for line in iomem_lines:
83+
if "PCI Bus" not in line:
84+
continue
85+
86+
line_start_addr = int(line.split('-')[0], 16)
87+
line_end_addr = int(line.split('-')[1].split()[0], 16)
88+
if line_start_addr < board_cfg_lib.SIZE_4G and line_end_addr < board_cfg_lib.SIZE_4G:
89+
continue
90+
elif line_start_addr < board_cfg_lib.SIZE_4G and line_end_addr >= board_cfg_lib.SIZE_4G:
91+
i_cnt += 1
92+
is_hi_mmio = True
93+
mmio_min = board_cfg_lib.SIZE_4G
94+
mmio_max = line_end_addr
95+
continue
96+
97+
is_hi_mmio = True
98+
if i_cnt == 0:
99+
mmio_min = line_start_addr
100+
mmio_max = line_end_addr
101+
102+
if mmio_max < line_end_addr:
103+
mmio_max = line_end_addr
104+
i_cnt += 1
105+
106+
print("", file=config)
107+
if is_hi_mmio:
108+
print("#define HI_MMIO_START\t\t0x%xUL" % mmio_min, file=config)
109+
print("#define HI_MMIO_END\t\t0x%xUL" % mmio_max, file=config)
110+
else:
111+
print("#define HI_MMIO_START\t\t~0UL", file=config)
112+
print("#define HI_MMIO_END\t\t0UL", file=config)
113+
73114
def generate_file(config):
74115
"""
75116
Start to generate board.c
@@ -171,6 +212,10 @@ def generate_file(config):
171212
print("#define MAX_HIDDEN_PDEVS_NUM {}U".format(len(board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME])), file=config)
172213
else:
173214
print("#define MAX_HIDDEN_PDEVS_NUM 0U", file=config)
215+
216+
# generate HI_MMIO_START/HI_MMIO_END
217+
find_hi_mmio_window(config)
218+
174219
print("", file=config)
175220

176221
print("{}".format(MISC_CFG_END), file=config)

0 commit comments

Comments
 (0)