1<?xml version="1.0" encoding="utf-8"?>
2
3<!-- Copyright (C) 2021-2022 Intel Corporation. -->
4<!-- SPDX-License-Identifier: BSD-3-Clause -->
5
6<xsl:stylesheet
7    version="1.0"
8    xmlns:xi="http://www.w3.org/2003/XInclude"
9    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10    xmlns:dyn="http://exslt.org/dynamic"
11    xmlns:math="http://exslt.org/math"
12    xmlns:acrn="http://projectacrn.org">
13  <xsl:include href="lib.xsl" />
14  <xsl:output method="text" indent="yes" />
15
16  <xsl:template match="/acrn-offline-data">
17     <!-- Declaration of license -->
18    <xsl:value-of select="$license" />
19
20    <!-- Included headers -->
21    <xsl:value-of select="acrn:include('asm/vm_config.h')" />
22
23    <xsl:apply-templates select="config-data/acrn-config/vm" />
24  </xsl:template>
25
26  <xsl:template name="format_remappings">
27    <xsl:param name="pText" />
28    <xsl:param name="index" />
29    <xsl:if test="string-length($pText)">
30      <xsl:variable name="tokens" select="substring-before(concat($pText,')'),')')" />
31      <xsl:variable name="phys_gsi" select="substring-after(substring-before($tokens, ','), '(')" />
32      <xsl:variable name="virt_gsi" select="substring-after($tokens, ',')" />
33      <xsl:text>[</xsl:text>
34      <xsl:value-of select="concat($index, 'U')" />
35      <xsl:text>] = {</xsl:text>
36      <xsl:value-of select="$newline" />
37      <xsl:value-of select="acrn:initializer('phys_gsi', concat($phys_gsi, 'U'))" />
38      <xsl:value-of select="acrn:initializer('virt_gsi', concat($virt_gsi, 'U'))" />
39      <xsl:text>},</xsl:text>
40      <xsl:value-of select="$newline" />
41    </xsl:if>
42  </xsl:template>
43
44  <xsl:template match="config-data/acrn-config/vm">
45    <xsl:if test="acrn:is-pre-launched-vm(load_order)">
46      <xsl:variable name="vm_id" select="@id" />
47      <xsl:variable name="pt_intx" select="acrn:get-intx-mapping(//vm[@id=$vm_id]//pt_intx)" />
48      <xsl:variable name="length" select="count($pt_intx)" />
49
50      <xsl:choose>
51	<xsl:when test="$length">
52	  <xsl:value-of select="acrn:array-initializer('struct pt_intx_config', concat('vm', @id, '_pt_intx'), concat($length, 'U'))" />
53	  <xsl:for-each select="$pt_intx">
54	    <xsl:call-template name="format_remappings">
55              <xsl:with-param name="pText" select="." />
56              <xsl:with-param name="index" select="position() - 1" />
57	    </xsl:call-template>
58	  </xsl:for-each>
59	  <xsl:value-of select="$end_of_array_initializer" />
60	</xsl:when>
61	<xsl:otherwise>
62	  <xsl:value-of select="acrn:array-initializer('struct pt_intx_config', concat('vm', @id, '_pt_intx'), '1U')" />
63	  <xsl:value-of select="$end_of_array_initializer" />
64	</xsl:otherwise>
65      </xsl:choose>
66      <xsl:value-of select="$newline" />
67    </xsl:if>
68  </xsl:template>
69
70</xsl:stylesheet>
71