From 0f0d0c0d18ca4b196fd96a8acf28dc9f815ba387 Mon Sep 17 00:00:00 2001 From: dongshen Date: Wed, 9 Sep 2020 13:05:45 -0700 Subject: [PATCH] acrn-config: always generate P2SB_BAR_ADDR related boilerplate code in vm_configurations.c so that vm_configurations.h/vm_configurations.c are consistent for different boards The boilerplate code is protected by #ifdef P2SB_BAR_ADDR/#endif, so it will not hurt if we always produce related code. Define new macros P2SB_BAR_ADDR_GPA and P2SB_BAR_SIZE to make the code more flexible. Tracked-On: #5229 Signed-off-by: dongshen --- misc/acrn-config/board_config/board_info_h.py | 7 ++++++- misc/acrn-config/scenario_config/vm_configurations_c.py | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/misc/acrn-config/board_config/board_info_h.py b/misc/acrn-config/board_config/board_info_h.py index cd5a4ecd4..75edde94a 100644 --- a/misc/acrn-config/board_config/board_info_h.py +++ b/misc/acrn-config/board_config/board_info_h.py @@ -96,7 +96,12 @@ def generate_file(config): and board_cfg_lib.is_p2sb_passthru_possible()): print("", file=config) print("#define P2SB_VGPIO_DM_ENABLED", file=config) - print("#define P2SB_BAR_ADDR\t\t\t0x{:X}UL".format(board_cfg_lib.find_p2sb_bar_addr()), file=config) + + hpa = board_cfg_lib.find_p2sb_bar_addr() + print("#define P2SB_BAR_ADDR\t\t\t0x{:X}UL".format(hpa), file=config) + gpa = common.hpa2gpa(0, hpa, 0x1000000) + print("#define P2SB_BAR_ADDR_GPA\t\t0x{:X}UL".format(gpa), file=config) + print("#define P2SB_BAR_SIZE\t\t\t0x1000000UL", file=config) if board_cfg_lib.is_matched_board(("ehl-crb-b")): print("", file=config) diff --git a/misc/acrn-config/scenario_config/vm_configurations_c.py b/misc/acrn-config/scenario_config/vm_configurations_c.py index 57bd824d2..d433a3fb9 100644 --- a/misc/acrn-config/scenario_config/vm_configurations_c.py +++ b/misc/acrn-config/scenario_config/vm_configurations_c.py @@ -337,15 +337,13 @@ def gen_pre_launch_vm(vm_type, vm_i, scenario_items, config): print("\t\t},", file=config) print("#endif", file=config) - if (vm_i == 0 and vm_info.mmio_resource_info.p2sb.get(vm_i) is not None - and vm_info.mmio_resource_info.p2sb[vm_i]): + if vm_i == 0: print("#ifdef P2SB_BAR_ADDR", file=config) print("\t\t.pt_p2sb_bar = true,", file=config) print("\t\t.mmiodevs[0] = {", file=config) - gpa = common.hpa2gpa(0, board_cfg_lib.find_p2sb_bar_addr(), 0x1000000) - print("\t\t\t.base_gpa = 0x{:X}UL,".format(gpa), file=config) + print("\t\t\t.base_gpa = P2SB_BAR_ADDR_GPA,", file=config) print("\t\t\t.base_hpa = P2SB_BAR_ADDR,", file=config) - print("\t\t\t.size = 0x1000000UL,", file=config) + print("\t\t\t.size = P2SB_BAR_SIZE,", file=config) print("\t\t},", file=config) print("#endif", file=config)