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 <yuanyuan.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Yuanyuan Zhao 2022-08-12 09:16:59 +08:00 committed by acrnsi-robot
parent ea596cd08c
commit 4b3b41be11
2 changed files with 16 additions and 2 deletions

View File

@ -172,6 +172,11 @@ If your VM is not a security VM, leave this option unchecked. </xs:documentation
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="MAX_PCI_BUS_NUM" type="xs:integer" default="0">
<xs:annotation acrn:views="">
<xs:documentation>Specify the maximum number of PCI buses. The default value is calculated from the board configuration file. Integer from 1 to 256.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MAX_PCI_DEV_NUM" default="96">
<xs:annotation acrn:title="Max PCI devices" acrn:views="advanced"
acrn:errormsg="'required': 'must config the max number of PCI devices'">

View File

@ -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)