mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
config-tools: generate ACFG_MAX_PCI_BUS_NUM based on board.xml
Extract the max pci bus number from board information and generate the common configuration macro ACFG_MAX_PCI_BUS_NUM automatically. Tracked-On: #6942 Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
This commit is contained in:
parent
3555aae4ac
commit
ae998f157e
12
misc/config_tools/static_allocators/board_capability.py
Normal file
12
misc/config_tools/static_allocators/board_capability.py
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import common
|
||||
|
||||
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)
|
@ -26,11 +26,20 @@
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="entry-by-key-value">
|
||||
<xsl:param name="prefix" />
|
||||
<xsl:param name="key" />
|
||||
<xsl:param name="value" />
|
||||
<xsl:param name="default" />
|
||||
|
||||
<xsl:text>#define CONFIG_</xsl:text>
|
||||
<xsl:text>#define </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$prefix != ''">
|
||||
<xsl:value-of select="$prefix" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>CONFIG_</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$key" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
|
@ -21,11 +21,19 @@
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="entry-by-key-value">
|
||||
<xsl:param name="prefix" />
|
||||
<xsl:param name="key" />
|
||||
<xsl:param name="value" />
|
||||
<xsl:param name="default" />
|
||||
|
||||
<xsl:text>CONFIG_</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$prefix != ''">
|
||||
<xsl:value-of select="$prefix" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>CONFIG_</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$key" />
|
||||
<xsl:text>=</xsl:text>
|
||||
<xsl:choose>
|
||||
|
@ -151,8 +151,10 @@
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="CAPACITIES">
|
||||
<xsl:call-template name="integer-by-key">
|
||||
<xsl:with-param name="key" select="'IOMMU_BUS_NUM'" />
|
||||
<xsl:call-template name="integer-by-key-value">
|
||||
<xsl:with-param name="prefix" select="'ACFG_'" />
|
||||
<xsl:with-param name="key" select="'MAX_PCI_BUS_NUM'" />
|
||||
<xsl:with-param name="value" select="//allocation-data/acrn-config/platform/MAX_PCI_BUS_NUM" />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:call-template name="integer-by-key">
|
||||
@ -314,6 +316,7 @@
|
||||
<!-- Common library routines -->
|
||||
|
||||
<xsl:template name="integer-by-key-value">
|
||||
<xsl:param name="prefix" />
|
||||
<xsl:param name="key" />
|
||||
<xsl:param name="value" />
|
||||
<xsl:param name="default" />
|
||||
@ -321,18 +324,21 @@
|
||||
<xsl:choose>
|
||||
<xsl:when test="$value != ''">
|
||||
<xsl:call-template name="entry-by-key-value">
|
||||
<xsl:with-param name="prefix" select="$prefix" />
|
||||
<xsl:with-param name="key" select="$key" />
|
||||
<xsl:with-param name="value" select="concat($value, $integer-suffix)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="($value = '') and ($default != '')">
|
||||
<xsl:call-template name="entry-by-key-value">
|
||||
<xsl:with-param name="prefix" select="$prefix" />
|
||||
<xsl:with-param name="key" select="$key" />
|
||||
<xsl:with-param name="value" select="concat($default, $integer-suffix)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="entry-by-key-value">
|
||||
<xsl:with-param name="prefix" select="$prefix" />
|
||||
<xsl:with-param name="key" select="$key" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
|
Loading…
Reference in New Issue
Block a user