2021-03-09 04:00:05 +08:00
<?xml version="1.0" encoding="utf-8"?>
2022-04-05 18:59:24 +08:00
<!-- Copyright (C) 2021 Intel Corporation. -->
2021-03-09 04:00:05 +08:00
<!-- 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" >
2022-03-02 17:13:12 +08:00
<xsl:if test= "count(//hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']) > 0" >
2021-03-09 04:00:05 +08:00
<!-- Included headers -->
<xsl:value-of select= "acrn:include('ivshmem.h')" />
2021-04-23 15:50:57 +08:00
<xsl:value-of select= "acrn:include('asm/pgtable.h')" />
2021-03-09 04:00:05 +08:00
<xsl:call-template name= "ivshmem_shm_region_name" />
<xsl:call-template name= "ivshmem_shm_mem" />
2022-02-14 14:33:21 +08:00
<xsl:apply-templates select= "hv//IVSHMEM" />
2021-03-09 04:00:05 +08:00
<xsl:call-template name= "ivshmem_shm_region" />
</xsl:if>
</xsl:template>
<xsl:template name = "ivshmem_shm_region_name" >
2022-03-02 17:13:12 +08:00
<xsl:for-each select= "hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']" >
<xsl:value-of select= "acrn:define(concat('IVSHMEM_SHM_REGION_', position() - 1), concat($quot, 'hv:/', NAME, $quot), '')" />
2021-03-09 04:00:05 +08:00
</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" />
2022-03-02 17:13:12 +08:00
<xsl:variable name= "memsize" select= "sum(//IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']/IVSHMEM_SIZE)" />
2021-03-09 04:00:05 +08:00
<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" >
2022-03-02 17:13:12 +08:00
<xsl:variable name= "dev" select= "count(//hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']/IVSHMEM_VMS/IVSHMEM_VM)" />
2022-02-14 14:33:21 +08:00
<xsl:value-of select= "acrn:define('IVSHMEM_DEV_NUM', string($dev), 'UL')" />
2021-03-09 04:00:05 +08:00
</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', '', ' \')" />
2022-03-02 17:13:12 +08:00
<xsl:for-each select= "hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']" >
2021-03-09 04:00:05 +08:00
<xsl:if test= "text()" >
2022-02-14 14:33:21 +08:00
<xsl:variable name= "memsize" select= "IVSHMEM_SIZE" />
2021-03-09 04:00:05 +08:00
<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>