From 4b3b41be114cac80198b27290cb9d5ae48ccd4d7 Mon Sep 17 00:00:00 2001 From: Yuanyuan Zhao Date: Fri, 12 Aug 2022 09:16:59 +0800 Subject: [PATCH] config_tool: add MAX_PCI_BUS_NUM in UI Add MAX_PCI_BUS_NUM in UI for user. If user defined MAX_PCI_BUS_NUM is greater than the value calculated by board.xml, use user defined MAX_PCI_BUS_NUM. Tracked-On: #8018 Signed-off-by: Yuanyuan Zhao Reviewed-by: Junjie Mao --- misc/config_tools/schema/config.xsd | 5 +++++ .../static_allocators/board_capability.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd index 0aa4f1ebb..a81d212a8 100644 --- a/misc/config_tools/schema/config.xsd +++ b/misc/config_tools/schema/config.xsd @@ -172,6 +172,11 @@ If your VM is not a security VM, leave this option unchecked. + + + Specify the maximum number of PCI buses. The default value is calculated from the board configuration file. Integer from 1 to 256. + + diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py index 141afca9c..e03528a5e 100644 --- a/misc/config_tools/static_allocators/board_capability.py +++ b/misc/config_tools/static_allocators/board_capability.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: BSD-3-Clause # - +import logging import common def powerof2_roundup(value): @@ -22,5 +22,14 @@ def create_max_ir_entries(scenario_etree, allocation_etree): def fn(board_etree, scenario_etree, allocation_etree): pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address") - common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree) + calc_pci_bus_nums = (max(map(lambda x: int(x, 16), pci_bus_nums)) + 1) + user_def_pci_bus_nums = common.get_node(f"//MAX_PCI_BUS_NUM/text()", scenario_etree) + if user_def_pci_bus_nums == '0': + common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(calc_pci_bus_nums), allocation_etree) + else: + if calc_pci_bus_nums > int(user_def_pci_bus_nums): + logging.error(f"MAX_PCI_BUS_NUM should be greater than {calc_pci_bus_nums}") + sys.exit(1) + else: + common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(int(user_def_pci_bus_nums)), allocation_etree) create_max_ir_entries(scenario_etree, allocation_etree)