mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 20:53:46 +00:00
config-tools: add the ivshmem_cfg.h.xsl
Add a xslt file "ivshemem_cfg.h.xsl". This file is used to generate ivshemem_cfg.h which is used by hypervisor. Tracked-On: #5980 Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
ec11789894
commit
4111ebb46a
86
misc/config_tools/xforms/ivshmem_cfg.h.xsl
Normal file
86
misc/config_tools/xforms/ivshmem_cfg.h.xsl
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Copyright (C) 2021 Intel Corporation. All rights reserved. -->
|
||||
<!-- SPDX-License-Identifier: BSD-3-Clause -->
|
||||
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xi="http://www.w3.org/2003/XInclude"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:dyn="http://exslt.org/dynamic"
|
||||
xmlns:math="http://exslt.org/math"
|
||||
xmlns:acrn="http://projectacrn.org">
|
||||
<xsl:include href="lib.xsl" />
|
||||
<xsl:output method="text" />
|
||||
|
||||
<xsl:template match="/acrn-offline-data">
|
||||
<!-- Declaration of license -->
|
||||
<xsl:value-of select="$license" />
|
||||
|
||||
<!-- Header include guard -->
|
||||
<xsl:value-of select="acrn:include-guard('IVSHMEM_CFG_H')" />
|
||||
|
||||
<xsl:apply-templates select="config-data/acrn-config" />
|
||||
|
||||
<xsl:value-of select="acrn:include-guard-end('IVSHMEM_CFG_H')" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="config-data/acrn-config">
|
||||
<xsl:if test="./hv/FEATURES/IVSHMEM/IVSHMEM_ENABLED = 'y'">
|
||||
<!-- Included headers -->
|
||||
<xsl:value-of select="acrn:include('ivshmem.h')" />
|
||||
<xsl:value-of select="acrn:include('x86/pgtable.h')" />
|
||||
|
||||
<xsl:call-template name="ivshmem_shm_region_name" />
|
||||
<xsl:call-template name="ivshmem_shm_mem" />
|
||||
<xsl:apply-templates select="hv/FEATURES/IVSHMEM" />
|
||||
<xsl:call-template name="ivshmem_shm_region" />
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name ="ivshmem_shm_region_name">
|
||||
<xsl:for-each select="hv/FEATURES/IVSHMEM/IVSHMEM_REGION">
|
||||
<xsl:if test="text()">
|
||||
<xsl:value-of select="acrn:define(concat('IVSHMEM_SHM_REGION_', position() - 1), concat($quot, substring-before(text(), ','), $quot), '')" />
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:value-of select="$newline" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name ="ivshmem_shm_mem">
|
||||
<xsl:value-of select="acrn:comment('The IVSHMEM_SHM_SIZE is the sum of all memory regions. The size range of each memory region is [2MB, 512MB] and is a power of 2.')" />
|
||||
<xsl:value-of select="$newline" />
|
||||
<xsl:variable name="memsize" select="sum(dyn:map(//IVSHMEM_REGION, 'acrn:parse-shmem-size(.)'))" />
|
||||
<xsl:value-of select="acrn:define('IVSHMEM_SHM_SIZE', concat('0x', acrn:convert-num-base(string($memsize), 10, 16), '00000UL'))" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="IVSHMEM">
|
||||
<xsl:value-of select="acrn:define('IVSHMEM_DEV_NUM', sum(dyn:map(//IVSHMEM_REGION, 'acrn:count-shmem-dev-num(.)')), 'UL')" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name ="ivshmem_shm_region">
|
||||
<xsl:value-of select="acrn:comment('All user defined memory regions')" />
|
||||
<xsl:value-of select="$newline" />
|
||||
<xsl:value-of select="acrn:define('IVSHMEM_SHM_REGIONS', '', ' \')" />
|
||||
<xsl:for-each select="hv/FEATURES/IVSHMEM/IVSHMEM_REGION">
|
||||
<xsl:if test="text()">
|
||||
<xsl:variable name="memsize" select="acrn:parse-shmem-size(text())" />
|
||||
<xsl:text>{ \</xsl:text>
|
||||
<xsl:value-of select="$newline" />
|
||||
<xsl:value-of select="acrn:initializer('name', concat('IVSHMEM_SHM_REGION_', position() - 1, ', \'), true())" />
|
||||
<xsl:value-of select="acrn:initializer('size', concat('0x', acrn:convert-num-base(string($memsize), 10, 16), '00000UL', ', \'), true())" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="last() = position()">
|
||||
<xsl:text>},</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>}, \</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$newline" />
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:value-of select="$newline" />
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue
Block a user