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" /> 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 <xsl:value-of select="acrn:include('vpci.h')" /> 23 <xsl:value-of select="acrn:include('asm/mmu.h')" /> 24 <xsl:value-of select="acrn:include('asm/page.h')" /> 25 <xsl:value-of select="acrn:include('vmcs9900.h')" /> 26 <xsl:value-of select="acrn:include('ivshmem_cfg.h')" /> 27 28 <xsl:value-of select="acrn:define('INVALID_PCI_BASE', '0', 'U')" /> 29 30 <xsl:apply-templates select="config-data/acrn-config/vm" /> 31 </xsl:template> 32 33 <xsl:template match="config-data/acrn-config/vm"> 34 <!-- Initializer of a acrn_vm_pci_dev_config instance --> 35 <xsl:choose> 36 <xsl:when test="acrn:is-service-vm(load_order)"> 37 <xsl:value-of select="acrn:array-initializer('struct acrn_vm_pci_dev_config', 'sos_pci_devs', 'CONFIG_MAX_PCI_DEV_NUM')" /> 38 </xsl:when> 39 <xsl:when test="acrn:pci-dev-num(@id)"> 40 <xsl:value-of select="acrn:array-initializer('struct acrn_vm_pci_dev_config', concat('vm', @id, '_pci_devs'), concat('VM', @id, '_CONFIG_PCI_DEV_NUM'))" /> 41 </xsl:when> 42 </xsl:choose> 43 44 <xsl:if test="acrn:is-pre-launched-vm(load_order) and acrn:pci-dev-num(@id)"> 45 <xsl:call-template name="virtual_pci_hostbridge" /> 46 </xsl:if> 47 <xsl:call-template name="ivshmem_shm_mem" /> 48 <xsl:apply-templates select="console_vuart" /> 49 <xsl:call-template name="communication_vuart" /> 50 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 51 <xsl:apply-templates select="pci_devs" /> 52 </xsl:if> 53 <xsl:if test="acrn:is-post-launched-vm(load_order)"> 54 <xsl:apply-templates select="PTM" /> 55 </xsl:if> 56 57 <xsl:if test="acrn:is-service-vm(load_order) or acrn:pci-dev-num(@id)"> 58 <xsl:value-of select="$end_of_array_initializer" /> 59 </xsl:if> 60 </xsl:template> 61 62 <xsl:template name="virtual_pci_hostbridge"> 63 <xsl:text>{</xsl:text> 64 <xsl:value-of select="$newline" /> 65 <xsl:value-of select="acrn:initializer('emu_type', 'PCI_DEV_TYPE_HVEMUL', '')" /> 66 <xsl:value-of select="acrn:initializer('vdev_ops', '&vhostbridge_ops', '')" /> 67 <xsl:value-of select="acrn:initializer('vbdf.bits', '{.b = 0x00U, .d = 0x00U, .f = 0x00U}', '')" /> 68 <xsl:text>},</xsl:text> 69 <xsl:value-of select="$newline" /> 70 </xsl:template> 71 72 <xsl:template match="console_vuart"> 73 <xsl:if test="base != 'INVALID_PCI_BASE'"> 74 <xsl:variable name="vm_id" select="../@id" /> 75 <xsl:variable name="dev_name" select="concat('VUART_', @id)" /> 76 <xsl:text>{</xsl:text> 77 <xsl:value-of select="$newline" /> 78 <xsl:value-of select="acrn:initializer('vuart_idx', @id, '')" /> 79 <xsl:value-of select="acrn:initializer('emu_type', 'PCI_DEV_TYPE_HVEMUL', '')" /> 80 <xsl:value-of select="acrn:initializer('vdev_ops', '&vmcs9900_ops', '')" /> 81 <xsl:choose> 82 <xsl:when test="acrn:is-post-launched-vm(../load_order)"> 83 <xsl:value-of select="acrn:initializer('vbar_base[0]', 'INVALID_PCI_BASE', '')" /> 84 <xsl:value-of select="acrn:initializer('vbdf.value', 'UNASSIGNED_VBDF', '')" /> 85 </xsl:when> 86 <xsl:otherwise> 87 <xsl:for-each select="//vm[@id = $vm_id]/device[@name = $dev_name]/bar"> 88 <xsl:value-of select="acrn:initializer(concat('vbar_base[', @id,']'), concat(text(), 'UL'), '')" /> 89 </xsl:for-each> 90 <xsl:value-of select="acrn:initializer('vbdf.bits', acrn:get-vbdf(../@id, $dev_name), '')" /> 91 </xsl:otherwise> 92 </xsl:choose> 93 <xsl:text>},</xsl:text> 94 <xsl:value-of select="$newline" /> 95 </xsl:if> 96 </xsl:template> 97 98 <xsl:template name="communication_vuart"> 99 <xsl:variable name="vm_id" select="@id" /> 100 <xsl:variable name="vm_name" select="name/text()" /> 101 <xsl:variable name="load_order" select="load_order/text()" /> 102 <xsl:for-each select="//vuart_connection[endpoint/vm_name/text() = $vm_name]"> 103 <xsl:variable name="connection_name" select="name/text()" /> 104 <xsl:if test="./type/text() = 'pci'"> 105 <xsl:variable name="vuart_id" select="position()"/> 106 <xsl:variable name="dev_name" select="concat('VUART_', $vuart_id)" /> 107 <xsl:text>{</xsl:text> 108 <xsl:value-of select="$newline" /> 109 <xsl:value-of select="acrn:initializer('vuart_idx', $vuart_id, '')" /> 110 <xsl:value-of select="acrn:initializer('emu_type', 'PCI_DEV_TYPE_HVEMUL', '')" /> 111 <xsl:value-of select="acrn:initializer('vdev_ops', '&vmcs9900_ops', '')" /> 112 <xsl:for-each select="endpoint"> 113 <xsl:choose> 114 <xsl:when test="vm_name = $vm_name"> 115 <xsl:choose> 116 <xsl:when test="acrn:is-post-launched-vm($load_order)"> 117 <xsl:value-of select="acrn:initializer('vbar_base[0]', 'INVALID_PCI_BASE', '')" /> 118 <xsl:value-of select="acrn:initializer('vbdf.value', 'UNASSIGNED_VBDF')" /> 119 </xsl:when> 120 <xsl:otherwise> 121 <xsl:for-each select="//vm[@id = $vm_id]/device[@name = $dev_name]/bar"> 122 <xsl:value-of select="acrn:initializer(concat('vbar_base[', @id,']'), concat(text(), 'UL'), '')" /> 123 </xsl:for-each> 124 <xsl:variable name="b" select="substring-before(vbdf/text(), ':')" /> 125 <xsl:variable name="d" select="substring-before(substring-after(vbdf/text(), ':'), '.')" /> 126 <xsl:variable name="f" select="substring-after(vbdf/text(), '.')" /> 127 <xsl:value-of select="acrn:initializer('vbdf.bits', concat('{', '0x', $b, ', ', '0x', $d, ', ', '0x', $f, '}'))" /> 128 </xsl:otherwise> 129 </xsl:choose> 130 </xsl:when> 131 <xsl:otherwise> 132 <xsl:variable name="target_name" select="vm_name" /> 133 <xsl:value-of select="acrn:initializer('t_vuart.vm_id', concat(//vm[name = $target_name]/@id, 'U'))" /> 134 <xsl:for-each select="//vuart_connection[endpoint/vm_name = $target_name]"> 135 <xsl:variable name="uart_num" select="position()"/> 136 <xsl:if test="name = $connection_name"> 137 <xsl:value-of select="acrn:initializer('t_vuart.vuart_id', concat($uart_num, 'U'))" /> 138 </xsl:if> 139 </xsl:for-each> 140 </xsl:otherwise> 141 </xsl:choose> 142 </xsl:for-each> 143 <xsl:text>},</xsl:text> 144 <xsl:value-of select="$newline" /> 145 </xsl:if> 146 </xsl:for-each> 147 </xsl:template> 148 149 <xsl:template match="pci_devs"> 150 <xsl:variable name="vm_id" select="../@id" /> 151 <xsl:for-each select="pci_dev/text()"> 152 <xsl:text>{</xsl:text> 153 <xsl:value-of select="$newline" /> 154 <xsl:variable name="devname_suffix" select="acrn:ptdev-name-suffix(.)" /> 155 <xsl:variable name="dev_name" select="concat('PTDEV_', $devname_suffix)" /> 156 <xsl:value-of select="acrn:initializer('emu_type', 'PCI_DEV_TYPE_PTDEV', '')" /> 157 <xsl:value-of select="acrn:initializer('vbdf.bits', acrn:get-vbdf($vm_id, $dev_name), '')" /> 158 <xsl:value-of select="acrn:initializer('pbdf.bits', acrn:get-pbdf(.), '')" /> 159 <xsl:for-each select="//device[@name = $dev_name]/bar"> 160 <xsl:value-of select="acrn:initializer(concat('vbar_base[', @id,']'), concat(text(), 'UL'), '')" /> 161 </xsl:for-each> 162 <xsl:text>},</xsl:text> 163 <xsl:value-of select="$newline" /> 164 </xsl:for-each> 165 </xsl:template> 166 167 <xsl:template name="ivshmem_shm_mem"> 168 <xsl:variable name="vm_id" select="@id" /> 169 <xsl:variable name="vm_name" select="name" /> 170 <xsl:variable name="load_order" select="load_order" /> 171 <xsl:for-each select="//hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']/IVSHMEM_VMS/IVSHMEM_VM[VM_NAME = $vm_name]"> 172 <xsl:text>{</xsl:text> 173 <xsl:value-of select="$newline" /> 174 <xsl:value-of select="acrn:initializer('emu_type', 'PCI_DEV_TYPE_HVEMUL', '')" /> 175 <xsl:value-of select="acrn:initializer('vdev_ops', '&vpci_ivshmem_ops', '')" /> 176 <xsl:choose> 177 <xsl:when test="acrn:is-post-launched-vm($load_order)"> 178 <xsl:value-of select="acrn:initializer('vbdf.value', 'UNASSIGNED_VBDF', '')" /> 179 </xsl:when> 180 <xsl:otherwise> 181 <xsl:variable name="dev_name" select="concat('IVSHMEM_', acrn:shmem-index(ancestor::IVSHMEM_REGION/NAME))" /> 182 <xsl:value-of select="acrn:initializer('vbdf.bits', acrn:get-vbdf($vm_id, $dev_name), '')" /> 183 <xsl:for-each select="//vm[@id = $vm_id]/device[@name = $dev_name]/bar"> 184 <xsl:value-of select="acrn:initializer(concat('vbar_base[', @id,']'), concat(text(), 'UL'), '')" /> 185 </xsl:for-each> 186 </xsl:otherwise> 187 </xsl:choose> 188 <xsl:value-of select="acrn:initializer('shm_region_name', concat('IVSHMEM_SHM_REGION_', acrn:shmem-index(ancestor::IVSHMEM_REGION/NAME)), '')" /> 189 <xsl:text>},</xsl:text> 190 <xsl:value-of select="$newline" /> 191 </xsl:for-each> 192 </xsl:template> 193 194 <xsl:template match="PTM"> 195 <xsl:if test="text() = 'y'"> 196 <xsl:text>{</xsl:text> 197 <xsl:value-of select="$newline" /> 198 <xsl:value-of select="acrn:initializer('vbdf.value', 'UNASSIGNED_VBDF', '')" /> 199 <xsl:value-of select="acrn:initializer('vrp_sec_bus', '1', '')" /> 200 <xsl:text>},</xsl:text> 201 <xsl:value-of select="$newline" /> 202 </xsl:if> 203 </xsl:template> 204 205</xsl:stylesheet> 206