1<?xml version='1.0' encoding='utf-8'?> 2<xsl:stylesheet 3 version="1.0" 4 xmlns:xi="http://www.w3.org/2003/XInclude" 5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 6 xmlns:dyn="http://exslt.org/dynamic" 7 xmlns:math="http://exslt.org/math" 8 xmlns:acrn="http://projectacrn.org"> 9 <xsl:include href="lib.xsl" /> 10 <xsl:output method="text" /> 11 12 <xsl:template match="/acrn-offline-data"> 13 <!-- Declaration of license --> 14 <xsl:value-of select="$license" /> 15 16 <!-- Included headers --> 17 <xsl:value-of select="acrn:include('asm/vm_config.h')" /> 18 <xsl:value-of select="acrn:include('vuart.h')" /> 19 <xsl:value-of select="acrn:include('asm/pci_dev.h')" /> 20 <xsl:value-of select="acrn:include('asm/pgtable.h')" /> 21 <xsl:value-of select="acrn:include('schedule.h')" /> 22 <xsl:value-of select="$newline" /> 23 <xsl:value-of select="$newline" /> 24 25 <xsl:apply-templates select="config-data/acrn-config" /> 26 </xsl:template> 27 28 <xsl:template match="config-data/acrn-config"> 29 <!-- Declaration of pci_devs --> 30 <xsl:for-each select="vm"> 31 <xsl:variable name="vm_id" select="@id" /> 32 <xsl:choose> 33 <xsl:when test="acrn:is-service-vm(load_order)"> 34 <xsl:value-of select="acrn:extern('struct acrn_vm_pci_dev_config', 'sos_pci_devs', 'CONFIG_MAX_PCI_DEV_NUM')" /> 35 </xsl:when> 36 <xsl:when test="acrn:pci-dev-num(@id)"> 37 <xsl:value-of select="acrn:extern('struct acrn_vm_pci_dev_config', concat('vm', @id, '_pci_devs'), concat('VM', @id, '_CONFIG_PCI_DEV_NUM'))" /> 38 </xsl:when> 39 </xsl:choose> 40 41 <!-- Declaration of pt_intx --> 42 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 43 <xsl:variable name="length" select="count(acrn:get-intx-mapping(//vm[@id=$vm_id]//pt_intx))" /> 44 <xsl:choose> 45 <xsl:when test="$length"> 46 <xsl:value-of select="acrn:extern('struct pt_intx_config', concat('vm', @id, '_pt_intx'), concat($length, 'U'))" /> 47 </xsl:when> 48 <xsl:otherwise> 49 <xsl:value-of select="acrn:extern('struct pt_intx_config', concat('vm', @id, '_pt_intx'), '1U')" /> 50 </xsl:otherwise> 51 </xsl:choose> 52 53 <!-- Initializer of memory --> 54 <xsl:value-of select="concat('static struct vm_hpa_regions ', concat('vm', @id, '_hpa'), '[] = {')" /> 55 <xsl:for-each select="//allocation-data/acrn-config/vm[@id=$vm_id]/memory/hpa_region" > 56 <xsl:variable name="pos" select="position()" /> 57 <xsl:variable name="start_hpa" select="acrn:initializer('start_hpa', ./start_hpa, 'UL')" /> 58 <xsl:variable name="size_hpa" select="acrn:initializer('size_hpa', ./size_hpa, 'UL')" /> 59 <xsl:value-of select="concat('{', $start_hpa, ', ', $size_hpa, '}', ',')" /> 60 </xsl:for-each> 61 <xsl:text>};</xsl:text> 62 <xsl:value-of select="$newline" /> 63 </xsl:if> 64 </xsl:for-each> 65 66 <xsl:if test="acrn:is-rdt-enabled()"> 67 <xsl:value-of select="$newline" /> 68 <xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" /> 69 70 <xsl:for-each select="vm"> 71 <xsl:variable name="vm_id" select="@id" /> 72 <xsl:value-of select="concat('static uint16_t ', concat('vm', @id, '_vcpu_clos'), '[', count(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U] = {')" /> 73 <xsl:value-of select="acrn:string-join(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos, ', ', '', 'U')" /> 74 <xsl:text>};</xsl:text> 75 <xsl:value-of select="$newline" /> 76 </xsl:for-each> 77 78 <xsl:value-of select="$endif" /> 79 <xsl:value-of select="$newline" /> 80 </xsl:if> 81 82 <!-- Definition of vm_configs --> 83 <xsl:value-of select="acrn:array-initializer('struct acrn_vm_config', 'vm_configs', 'CONFIG_MAX_VM_NUM')" /> 84 <xsl:apply-templates select="vm"/> 85 <xsl:if test="count(vm) < hv/CAPACITIES/MAX_VM_NUM"> 86 <xsl:value-of select="acrn:vm_fill(count(vm), hv/CAPACITIES/MAX_VM_NUM)"/> 87 </xsl:if> 88 <xsl:value-of select="$newline"/> 89 <xsl:value-of select="$end_of_array_initializer" /> 90 <xsl:value-of select="$newline"/> 91 <xsl:choose> 92 <xsl:when test="count(vm[load_order='SERVICE_VM'])"> 93 <xsl:value-of select="concat('struct acrn_vm_config *const service_vm_config = &vm_configs[', vm[load_order='SERVICE_VM']/@id, '];')" /> 94 </xsl:when> 95 <xsl:otherwise> 96 <xsl:value-of select="concat('struct acrn_vm_config *const service_vm_config =', ' NULL;')" /> 97 </xsl:otherwise> 98 </xsl:choose> 99 </xsl:template> 100 101 <xsl:template match="vm"> 102 <!-- Initializer of a acrn_vm_configs instance --> 103 <xsl:text>{</xsl:text> 104 <xsl:value-of select="acrn:comment(concat('Static configured VM', @id))" /> 105 <xsl:value-of select="$newline" /> 106 107 <xsl:call-template name="load_order" /> 108 <xsl:apply-templates select="name" /> 109 <xsl:if test="acrn:is-service-vm(load_order)"> 110 <xsl:value-of select="acrn:comment('Allow Service VM to reboot the system since it is the highest priority VM.')" /> 111 <xsl:value-of select="$newline" /> 112 </xsl:if> 113 <xsl:value-of select="acrn:initializer('sched_params', '{', true())" /> 114 <xsl:value-of select="acrn:initializer('prio', priority)" /> 115 <xsl:value-of select="acrn:initializer('bvt_weight', bvt_weight)" /> 116 <xsl:value-of select="acrn:initializer('bvt_warp_value', bvt_warp_value)" /> 117 <xsl:value-of select="acrn:initializer('bvt_warp_limit', bvt_warp_limit)" /> 118 <xsl:value-of select="acrn:initializer('bvt_unwarp_period', bvt_unwarp_period)" /> 119 <xsl:text>},</xsl:text> 120 <xsl:value-of select="$newline" /> 121 <xsl:value-of select="acrn:initializer('companion_vm_id', concat(companion_vmid, 'U'))" /> 122 <xsl:call-template name="guest_flags" /> 123 124 <xsl:if test="acrn:is-rdt-enabled()"> 125 <xsl:call-template name="clos" /> 126 </xsl:if> 127 128 <xsl:call-template name="cpu_affinity" /> 129 <xsl:apply-templates select="epc_section" /> 130 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 131 <xsl:apply-templates select="memory" /> 132 </xsl:if> 133 <xsl:apply-templates select="os_config" /> 134 <xsl:call-template name="acpi_config" /> 135 <xsl:apply-templates select="console_vuart" /> 136 <xsl:call-template name="vuart_connection" /> 137 <xsl:call-template name="pci_dev_num" /> 138 <xsl:call-template name="pci_devs" /> 139 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 140 <xsl:call-template name="pre_launched" /> 141 </xsl:if> 142 143 <!-- End of the initializer --> 144 <xsl:text>}</xsl:text> 145 <xsl:if test="not(position() = last())"> 146 <xsl:text>,</xsl:text> 147 <xsl:value-of select="$newline" /> 148 </xsl:if> 149 </xsl:template> 150 151 <xsl:template name="load_order"> 152 <xsl:variable name="vm_type" select="vm_type" /> 153 <xsl:choose> 154 <xsl:when test="load_order = 'SERVICE_VM'"> 155 <xsl:value-of select="'CONFIG_SERVICE_VM,'" /> 156 </xsl:when> 157 <xsl:when test="load_order = 'PRE_LAUNCHED_VM' and $vm_type = 'RTVM'"> 158 <xsl:value-of select="'CONFIG_PRE_RT_VM,'" /> 159 </xsl:when> 160 <xsl:when test="load_order = 'PRE_LAUNCHED_VM' and $vm_type != 'RTVM'"> 161 <xsl:value-of select="'CONFIG_PRE_STD_VM,'" /> 162 </xsl:when> 163 <xsl:when test="load_order = 'POST_LAUNCHED_VM' and $vm_type = 'RTVM'"> 164 <xsl:value-of select="'CONFIG_POST_RT_VM,'" /> 165 </xsl:when> 166 <xsl:when test="load_order = 'POST_LAUNCHED_VM' and $vm_type != 'RTVM'"> 167 <xsl:value-of select="'CONFIG_POST_STD_VM,'" /> 168 </xsl:when> 169 </xsl:choose> 170 <xsl:value-of select="$newline" /> 171 </xsl:template> 172 173 <xsl:template match="name"> 174 <xsl:value-of select="acrn:initializer('name', concat($quot, current(), $quot))" /> 175 </xsl:template> 176 177 <xsl:template name="cpu_affinity"> 178 <xsl:choose> 179 <xsl:when test="acrn:is-service-vm(load_order)"> 180 <xsl:value-of select="acrn:initializer('cpu_affinity', 'SERVICE_VM_CONFIG_CPU_AFFINITY')" /> 181 </xsl:when> 182 <xsl:otherwise> 183 <xsl:if test="cpu_affinity"> 184 <xsl:value-of select="acrn:initializer('cpu_affinity', concat('VM', @id, '_CONFIG_CPU_AFFINITY'))" /> 185 </xsl:if> 186 </xsl:otherwise> 187 </xsl:choose> 188 </xsl:template> 189 190 <xsl:template name="guest_flags"> 191 <xsl:variable name="vm_id" select="@id" /> 192 <xsl:value-of select="acrn:initializer('guest_flags', concat('(', acrn:string-join(//allocation-data/acrn-config/vm[@id=$vm_id]/guest_flags/guest_flag, '|', '', ''),')'))" /> 193 </xsl:template> 194 195 <xsl:template name="clos"> 196 <xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" /> 197 <xsl:value-of select="acrn:initializer('pclosids', concat('vm', @id, '_vcpu_clos'))" /> 198 199 <xsl:variable name="vm_id" select="@id" /> 200 <xsl:variable name="vm_name" select="name/text()" /> 201 <xsl:choose> 202 <xsl:when test="acrn:is-vcat-enabled() and virtual_cat_support[text() = 'y']"> 203 <xsl:value-of select="acrn:initializer('num_pclosids', concat(count(//vm[@id=$vm_id]/virtual_cat_number), 'U'))" /> 204 <xsl:variable name="rdt_res_str" select="acrn:get-normalized-closinfo-rdt-res-str()" /> 205 206 <xsl:if test="contains($rdt_res_str, 'L2')"> 207 <xsl:value-of select="acrn:initializer('max_l2_pcbm', //CACHE_ALLOCATION[CACHE_LEVEL='2']/POLICY[VM=$vm_name]/CLOS_MASK)" /> 208 </xsl:if> 209 210 <xsl:if test="contains($rdt_res_str, 'L3')"> 211 <xsl:value-of select="acrn:initializer('max_l3_pcbm', //CACHE_ALLOCATION[CACHE_LEVEL='3']/POLICY[VM=$vm_name]/CLOS_MASK)" /> 212 </xsl:if> 213 </xsl:when> 214 <xsl:otherwise> 215 <xsl:value-of select="acrn:initializer('num_pclosids', concat(count(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U'))" /> 216 </xsl:otherwise> 217 </xsl:choose> 218 219 <xsl:value-of select="$endif" /> 220 </xsl:template> 221 222 <xsl:template match="memory"> 223 <xsl:variable name="vm_id" select="../@id" /> 224 <xsl:value-of select="acrn:initializer('memory', '{', true())" /> 225 <xsl:value-of select="acrn:initializer('region_num', count(//allocation-data/acrn-config/vm[@id=$vm_id]/memory/hpa_region))" /> 226 <xsl:value-of select="acrn:initializer('host_regions', concat('vm', ../@id, '_hpa'))" /> 227 <xsl:text>},</xsl:text> 228 <xsl:value-of select="$newline" /> 229 </xsl:template> 230 231 <xsl:template match="epc_section"> 232 <xsl:if test="base != '0' and size != '0'"> 233 <xsl:value-of select="acrn:initializer('epc', '{', true())" /> 234 <xsl:value-of select="acrn:initializer('base', base)" /> 235 <xsl:value-of select="acrn:initializer('size', size)" /> 236 <xsl:text>},</xsl:text> 237 <xsl:value-of select="$newline" /> 238 </xsl:if> 239 </xsl:template> 240 241 <xsl:template match="os_config"> 242 <xsl:value-of select="acrn:initializer('os_config', '{', true())" /> 243 <xsl:value-of select="acrn:initializer('name', concat($quot, name, $quot))" /> 244 <xsl:value-of select="acrn:initializer('kernel_type', kern_type)" /> 245 <xsl:value-of select="acrn:initializer('kernel_mod_tag', concat($quot, kern_mod, $quot))" /> 246 <xsl:value-of select="acrn:initializer('ramdisk_mod_tag', concat($quot, ramdisk_mod, $quot))" /> 247 <xsl:if test="kern_load_addr/text()"> 248 <xsl:value-of select="acrn:initializer('kernel_load_addr', kern_load_addr)" /> 249 </xsl:if> 250 <xsl:if test="kern_entry_addr/text()"> 251 <xsl:value-of select="acrn:initializer('kernel_entry_addr', kern_entry_addr)" /> 252 </xsl:if> 253 <xsl:if test="normalize-space(bootargs)"> 254 <xsl:choose> 255 <xsl:when test="acrn:is-service-vm(../load_order)"> 256 <xsl:value-of select="acrn:initializer('bootargs', 'SERVICE_VM_OS_BOOTARGS')" /> 257 </xsl:when> 258 <xsl:when test="acrn:is-pre-launched-vm(../load_order)"> 259 <xsl:value-of select="acrn:initializer('bootargs', concat('VM', ../@id, '_BOOT_ARGS'))" /> 260 </xsl:when> 261 </xsl:choose> 262 </xsl:if> 263 <xsl:text>},</xsl:text> 264 <xsl:value-of select="$newline" /> 265 </xsl:template> 266 267 <xsl:template name="acpi_config"> 268 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 269 <xsl:value-of select="acrn:initializer('acpi_config', '{', true())" /> 270 <xsl:value-of select="acrn:initializer('acpi_mod_tag', concat($quot,'ACPI_VM', @id, $quot))" /> 271 <xsl:text>},</xsl:text> 272 <xsl:value-of select="$newline" /> 273 </xsl:if> 274 </xsl:template> 275 276 <xsl:template match="console_vuart"> 277 <xsl:value-of select="acrn:initializer('vuart[0]', '{', true())" /> 278 <xsl:choose> 279 <xsl:when test="./text() = 'COM Port 1'"> 280 <xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" /> 281 <xsl:value-of select="acrn:initializer('addr.port_base', '0x3F8U')" /> 282 <xsl:value-of select="acrn:initializer('irq', '4U')" /> 283 </xsl:when> 284 <xsl:when test="./text() = 'COM Port 2'"> 285 <xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" /> 286 <xsl:value-of select="acrn:initializer('addr.port_base', '0x2F8U')" /> 287 <xsl:value-of select="acrn:initializer('irq', '3U')" /> 288 </xsl:when> 289 <xsl:when test="./text() = 'COM Port 3'"> 290 <xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" /> 291 <xsl:value-of select="acrn:initializer('addr.port_base', '0x3E8U')" /> 292 <xsl:value-of select="acrn:initializer('irq', '4U')" /> 293 </xsl:when> 294 <xsl:when test="./text() = 'COM Port 4'"> 295 <xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" /> 296 <xsl:value-of select="acrn:initializer('addr.port_base', '0x2E8U')" /> 297 <xsl:value-of select="acrn:initializer('irq', '3U')" /> 298 </xsl:when> 299 <xsl:when test="./text() = 'PCI'"> 300 <xsl:value-of select="acrn:initializer('type', 'VUART_PCI')" /> 301 </xsl:when> 302 </xsl:choose> 303 <xsl:text>},</xsl:text> 304 <xsl:value-of select="$newline" /> 305 </xsl:template> 306 307 <xsl:template name="vuart_connection"> 308 <xsl:variable name="vm_id" select="@id" /> 309 <xsl:variable name="vmname" select="name/text()" /> 310 <xsl:for-each select="//vuart_connection[endpoint/vm_name = $vmname]"> 311 <xsl:variable name="connection_name" select="name/text()" /> 312 <xsl:variable name="type" select="type/text()" /> 313 <xsl:variable name="vuart_id" select="position()"/> 314 <xsl:value-of select="acrn:initializer(concat('vuart[', $vuart_id, ']'), '{', true())" /> 315 <xsl:if test="$type = 'legacy'"> 316 <xsl:value-of select="acrn:initializer('irq', concat(//allocation-data/acrn-config/vm[@id=$vm_id]/legacy_vuart[@id=$vuart_id]/irq, 'U'))" /> 317 <xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" /> 318 <xsl:for-each select="endpoint"> 319 <xsl:choose> 320 <xsl:when test="vm_name = $vmname"> 321 <xsl:value-of select="acrn:initializer('addr.port_base', concat(io_port, 'U'))" /> 322 </xsl:when> 323 <xsl:otherwise> 324 <xsl:variable name="target_name" select="vm_name" /> 325 <xsl:value-of select="acrn:initializer('t_vuart.vm_id', concat(//vm[name = $target_name]/@id, 'U'))" /> 326 <xsl:for-each select="//vuart_connection[endpoint/vm_name = $target_name]"> 327 <xsl:variable name="uart_num" select="position()"/> 328 <xsl:if test="name = $connection_name"> 329 <xsl:value-of select="acrn:initializer('t_vuart.vuart_id', concat($uart_num, 'U'))" /> 330 </xsl:if> 331 </xsl:for-each> 332 </xsl:otherwise> 333 </xsl:choose> 334 </xsl:for-each> 335 </xsl:if> 336 <xsl:text>},</xsl:text> 337 <xsl:value-of select="$newline" /> 338 </xsl:for-each> 339 </xsl:template> 340 341 <xsl:template name="pci_dev_num"> 342 <xsl:choose> 343 <xsl:when test="acrn:is-service-vm(load_order)"> 344 <xsl:value-of select="acrn:initializer('pci_dev_num', concat(acrn:pci-dev-num(@id), 'U'))" /> 345 </xsl:when> 346 <xsl:otherwise> 347 <xsl:if test="acrn:pci-dev-num(@id)"> 348 <xsl:value-of select="acrn:initializer('pci_dev_num', concat('VM', @id, '_CONFIG_PCI_DEV_NUM'))" /> 349 </xsl:if> 350 </xsl:otherwise> 351 </xsl:choose> 352 </xsl:template> 353 354 <xsl:template name="pci_devs"> 355 <xsl:choose> 356 <xsl:when test="acrn:is-service-vm(load_order)"> 357 <xsl:value-of select="acrn:initializer('pci_devs', 'sos_pci_devs')" /> 358 </xsl:when> 359 <xsl:when test="acrn:pci-dev-num(@id)"> 360 <xsl:value-of select="acrn:initializer('pci_devs', concat('vm', @id, '_pci_devs'))" /> 361 </xsl:when> 362 </xsl:choose> 363 </xsl:template> 364 365 <xsl:template name="pre_launched"> 366 <xsl:if test="@id = '0'"> 367 <xsl:value-of select="acrn:ifdef('VM0_PASSTHROUGH_TPM')" /> 368 <xsl:value-of select="acrn:initializer('pt_tpm2', 'true')" /> 369 <xsl:value-of select="acrn:initializer('mmiodevs[0]', '{', true())" /> 370 <xsl:value-of select="acrn:initializer('name', concat($quot, 'tpm2', $quot))" /> 371 <xsl:value-of select="acrn:initializer('res[0]', '{', true())" /> 372 <xsl:value-of select="acrn:initializer('user_vm_pa', 'VM0_TPM_BUFFER_BASE_ADDR_GPA')" /> 373 <xsl:value-of select="acrn:initializer('host_pa', 'VM0_TPM_BUFFER_BASE_ADDR')" /> 374 <xsl:value-of select="acrn:initializer('size', 'VM0_TPM_BUFFER_SIZE')" /> 375 <xsl:value-of select="acrn:initializer('mem_type', 'EPT_UNCACHED')" /> 376 <xsl:text>},</xsl:text> 377 <xsl:value-of select="$newline" /> 378 <xsl:if test="//capability[@id='log_area'] and //capability[@id='log_area']/log_area_minimum_length != '0x0' and //capability[@id='log_area']/log_area_start_address != '0x0'"> 379 <xsl:value-of select="acrn:initializer('res[1]', '{', true())" /> 380 <xsl:value-of select="acrn:initializer('user_vm_pa', 'VM0_TPM_EVENTLOG_BASE_ADDR')" /> 381 <xsl:value-of select="acrn:initializer('host_pa', 'VM0_TPM_EVENTLOG_BASE_ADDR_HPA')" /> 382 <xsl:value-of select="acrn:initializer('size', 'VM0_TPM_EVENTLOG_SIZE')" /> 383 <xsl:value-of select="acrn:initializer('mem_type', 'EPT_WB')" /> 384 <xsl:text>},</xsl:text> 385 <xsl:value-of select="$newline" /> 386 </xsl:if> 387 <xsl:text>},</xsl:text> 388 <xsl:value-of select="$newline" /> 389 <xsl:value-of select="$endif" /> 390 <xsl:value-of select="acrn:ifdef('P2SB_BAR_ADDR')" /> 391 <xsl:value-of select="acrn:initializer('pt_p2sb_bar', 'true')" /> 392 <xsl:value-of select="acrn:initializer('mmiodevs[0]', '{', true())" /> 393 <xsl:value-of select="acrn:initializer('res[0]', '{', true())" /> 394 <xsl:value-of select="acrn:initializer('user_vm_pa', 'P2SB_BAR_ADDR_GPA')" /> 395 <xsl:value-of select="acrn:initializer('host_pa', 'P2SB_BAR_ADDR')" /> 396 <xsl:value-of select="acrn:initializer('size', 'P2SB_BAR_SIZE')" /> 397 <xsl:text>},</xsl:text> 398 <xsl:value-of select="$newline" /> 399 <xsl:text>},</xsl:text> 400 <xsl:value-of select="$newline" /> 401 <xsl:value-of select="$endif" /> 402 </xsl:if> 403 404 <xsl:variable name="vm_id" select="@id" /> 405 <xsl:variable name="length" select="count(acrn:get-intx-mapping(//vm[@id=$vm_id]//pt_intx))" /> 406 <xsl:value-of select="acrn:initializer('pt_intx_num', $length)" /> 407 <xsl:value-of select="acrn:initializer('pt_intx', concat('vm', @id, '_pt_intx'))" /> 408 </xsl:template> 409 410</xsl:stylesheet> 411