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 xml:id="config_common" 9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 10 11 <!-- XML tree visitors --> 12 13 <xsl:template match="//board-data/acrn-config"> 14 <xsl:call-template name="string-by-key-value"> 15 <xsl:with-param name="key" select="'BOARD'" /> 16 <xsl:with-param name="value" select="@board" /> 17 </xsl:call-template> 18 <xsl:call-template name="integer-by-key-value"> 19 <xsl:with-param name="key" select="'MAX_IOAPIC_NUM'" /> 20 <xsl:with-param name="value" select="//config-data//MAX_IOAPIC_NUM/text()" /> 21 <xsl:with-param name="default" select="acrn:max(1, count(.//ioapic))" /> 22 </xsl:call-template> 23 <xsl:call-template name="integer-by-key-value"> 24 <xsl:with-param name="key" select="'MAX_IOAPIC_LINES'" /> 25 <xsl:with-param name="value" select="//config-data//MAX_IOAPIC_LINES/text()" /> 26 <xsl:with-param name="default" select="math:max(.//ioapic/gsi_number/text() | exslt:node-set(48))" /> 27 </xsl:call-template> 28 <xsl:call-template name="msi-msix-max" /> 29 </xsl:template> 30 31 <xsl:template match="//config-data/acrn-config"> 32 <xsl:call-template name="string-by-key-value"> 33 <xsl:with-param name="key" select="'SCENARIO'" /> 34 <xsl:with-param name="value" select="@scenario" /> 35 </xsl:call-template> 36 37 <xsl:call-template name="boolean-by-key-value"> 38 <xsl:with-param name="key" select="'RELEASE'" /> 39 <xsl:with-param name="value" select="hv/BUILD_TYPE = 'release'" /> 40 </xsl:call-template> 41 42 <xsl:apply-templates select="hv/DEBUG_OPTIONS" /> 43 <xsl:apply-templates select="hv/FEATURES" /> 44 <xsl:apply-templates select="hv/MEMORY" /> 45 <xsl:apply-templates select="hv/CAPACITIES" /> 46 <xsl:apply-templates select="hv/MISC_CFG" /> 47 <xsl:apply-templates select="vm/os_config/kern_type" /> 48 </xsl:template> 49 50 <xsl:template match="DEBUG_OPTIONS"> 51 <xsl:call-template name="integer-by-key-value"> 52 <xsl:with-param name="key" select="'MEM_LOGLEVEL_DEFAULT'" /> 53 <xsl:with-param name="value" select="MEM_LOGLEVEL" /> 54 </xsl:call-template> 55 56 <xsl:call-template name="integer-by-key-value"> 57 <xsl:with-param name="key" select="'NPK_LOGLEVEL_DEFAULT'" /> 58 <xsl:with-param name="value" select="NPK_LOGLEVEL" /> 59 </xsl:call-template> 60 61 <xsl:call-template name="integer-by-key-value"> 62 <xsl:with-param name="key" select="'CONSOLE_LOGLEVEL_DEFAULT'" /> 63 <xsl:with-param name="value" select="CONSOLE_LOGLEVEL" /> 64 </xsl:call-template> 65 66 <xsl:call-template name="integer-by-key-value"> 67 <xsl:with-param name="key" select="'CONSOLE_DEFAULT_VM'" /> 68 <xsl:with-param name="value" select="CONSOLE_VM" /> 69 <!-- Default is HV console, ACRN_INVALID_VMID --> 70 <xsl:with-param name="default" select="'0xffff'" /> 71 </xsl:call-template> 72 73 <xsl:apply-templates select="SERIAL_CONSOLE" /> 74 </xsl:template> 75 76 <xsl:template match="FEATURES"> 77 <xsl:call-template name="boolean-by-key-value"> 78 <xsl:with-param name="key" select="SCHEDULER" /> 79 <xsl:with-param name="value" select="'y'" /> 80 </xsl:call-template> 81 82 <xsl:call-template name="boolean-by-key"> 83 <xsl:with-param name="key" select="'SERVICE_VM_SUPERVISOR_ENABLED'" /> 84 </xsl:call-template> 85 86 <xsl:call-template name="boolean-by-key"> 87 <xsl:with-param name="key" select="'SPLIT_LOCK_DETECTION_ENABLED'" /> 88 </xsl:call-template> 89 90 <xsl:call-template name="boolean-by-key"> 91 <xsl:with-param name="key" select="'UC_LOCK_DETECTION_ENABLED'" /> 92 </xsl:call-template> 93 94 <xsl:call-template name="boolean-by-key"> 95 <xsl:with-param name="key" select="'SECURITY_VM_FIXUP'" /> 96 </xsl:call-template> 97 98 <xsl:call-template name="boolean-by-key"> 99 <xsl:with-param name="key" select="'KEEP_IRQ_DISABLED'" /> 100 </xsl:call-template> 101 102 <xsl:call-template name="boolean-by-key-value"> 103 <xsl:with-param name="key" select="'RDT_ENABLED'" /> 104 <xsl:with-param name="value" select="RDT/RDT_ENABLED" /> 105 </xsl:call-template> 106 107 <xsl:if test="acrn:is-rdt-enabled()"> 108 <xsl:call-template name="boolean-by-key-value"> 109 <xsl:with-param name="key" select="'CDP_ENABLED'" /> 110 <xsl:with-param name="value" select="RDT/CDP_ENABLED" /> 111 </xsl:call-template> 112 113 <xsl:call-template name="boolean-by-key-value"> 114 <xsl:with-param name="key" select="'VCAT_ENABLED'" /> 115 <xsl:with-param name="value" select="RDT/VCAT_ENABLED" /> 116 </xsl:call-template> 117 </xsl:if> 118 119 <xsl:call-template name="boolean-by-key"> 120 <xsl:with-param name="key" select="'HYPERV_ENABLED'" /> 121 </xsl:call-template> 122 123 <xsl:call-template name="boolean-by-key-value"> 124 <xsl:with-param name="key" select="'NVMX_ENABLED'" /> 125 <xsl:with-param name="value" select="count(//vm[nested_virtualization_support = 'y']) > 0" /> 126 </xsl:call-template> 127 128 <xsl:call-template name="boolean-by-key"> 129 <xsl:with-param name="key" select="'ACPI_PARSE_ENABLED'" /> 130 </xsl:call-template> 131 132 <xsl:call-template name="boolean-by-key-value"> 133 <xsl:with-param name="key" select="'L1D_FLUSH_VMENTRY_ENABLED'" /> 134 <xsl:with-param name="value" select="L1D_VMENTRY_ENABLED" /> 135 </xsl:call-template> 136 137 <xsl:call-template name="boolean-by-key-value"> 138 <xsl:with-param name="key" select="'MCE_ON_PSC_WORKAROUND_ENABLED'" /> 139 <xsl:with-param name="value" select="MCE_ON_PSC_ENABLED" /> 140 </xsl:call-template> 141 142 <xsl:call-template name="boolean-by-key-value"> 143 <xsl:with-param name="key" select="'RELOC'" /> 144 <xsl:with-param name="value" select="RELOC_ENABLED" /> 145 </xsl:call-template> 146 147 <xsl:call-template name="boolean-by-key-value"> 148 <xsl:with-param name="key" select="'MULTIBOOT2'" /> 149 <xsl:with-param name="value" select="MULTIBOOT2_ENABLED" /> 150 </xsl:call-template> 151 152 <xsl:call-template name="boolean-by-key-value"> 153 <xsl:with-param name="key" select="'SSRAM_ENABLED'" /> 154 <xsl:with-param name="value" select="count(//cache/capability[@id='Software SRAM']) > 0" /> 155 </xsl:call-template> 156 157 <xsl:call-template name="boolean-by-key-value"> 158 <xsl:with-param name="key" select="'IVSHMEM_ENABLED'" /> 159 <xsl:with-param name="value" select="count(//hv//IVSHMEM/IVSHMEM_REGION[PROVIDED_BY = 'Hypervisor']) > 0" /> 160 </xsl:call-template> 161 162 <xsl:call-template name="integer-by-key"> 163 <xsl:with-param name="key" select="'VUART_RX_BUF_SIZE'" /> 164 </xsl:call-template> 165 166 <xsl:call-template name="integer-by-key"> 167 <xsl:with-param name="key" select="'VUART_TX_BUF_SIZE'" /> 168 </xsl:call-template> 169 170 <xsl:call-template name="integer-by-key"> 171 <xsl:with-param name="key" select="'VUART_TIMER_PCPU'" /> 172 </xsl:call-template> 173 </xsl:template> 174 175 <xsl:template match="MEMORY"> 176 <xsl:call-template name="integer-by-key"> 177 <xsl:with-param name="key" select="'HV_RAM_START'" /> 178 <xsl:with-param name="default" select="//allocation-data/acrn-config/hv/MEMORY/HV_RAM_START" /> 179 </xsl:call-template> 180 181 <xsl:call-template name="integer-by-key"> 182 <xsl:with-param name="key" select="'HV_RAM_SIZE'" /> 183 <xsl:with-param name="default" select="//allocation-data/acrn-config/hv/MEMORY/HV_RAM_SIZE" /> 184 </xsl:call-template> 185 186 <xsl:call-template name="integer-by-key"> 187 <xsl:with-param name="key" select="'STACK_SIZE'" /> 188 </xsl:call-template> 189 </xsl:template> 190 191 <xsl:template match="CAPACITIES"> 192 <xsl:call-template name="integer-by-key-value"> 193 <xsl:with-param name="prefix" select="'ACFG_'" /> 194 <xsl:with-param name="key" select="'MAX_PCI_BUS_NUM'" /> 195 <xsl:with-param name="value" select="//allocation-data/acrn-config/platform/MAX_PCI_BUS_NUM" /> 196 </xsl:call-template> 197 198 <xsl:call-template name="integer-by-key"> 199 <xsl:with-param name="key" select="'MAX_PCI_DEV_NUM'" /> 200 </xsl:call-template> 201 202 <xsl:call-template name="integer-by-key"> 203 <xsl:with-param name="key" select="'MAX_PT_IRQ_ENTRIES'" /> 204 </xsl:call-template> 205 206 <xsl:call-template name="integer-by-key-value"> 207 <xsl:with-param name="key" select="'MAX_EMULATED_MMIO_REGIONS'" /> 208 <xsl:with-param name="value" select="MAX_EMULATED_MMIO" /> 209 </xsl:call-template> 210 </xsl:template> 211 212 <xsl:template match="SERIAL_CONSOLE"> 213 <xsl:variable name="tokens" select="concat(substring-before(substring-after(/acrn-offline-data/board-data/acrn-config/TTYS_INFO, concat('seri:', current())), '
'), ' ')" /> 214 <xsl:variable name="type" select="substring-before(substring-after($tokens, 'type:'), ' ')" /> 215 <xsl:variable name="base" select="substring-before(substring-after($tokens, 'base:'), ' ')" /> 216 <xsl:variable name="irq" select="substring-before(substring-after($tokens, 'irq:'), ' ')" /> 217 <xsl:variable name="bdf_string" select="substring-before(substring-after($tokens, 'bdf:'), ' ')" /> 218 <xsl:variable name="bdf" select="substring($bdf_string, 2, string-length($bdf_string) - 2)" /> 219 220 <xsl:choose> 221 <!-- TODO: Raise an error upon incomplete serial port info --> 222 <xsl:when test="$type = 'portio'"> 223 <xsl:call-template name="boolean-by-key-value"> 224 <xsl:with-param name="key" select="'SERIAL_LEGACY'" /> 225 <xsl:with-param name="value" select="'y'" /> 226 </xsl:call-template> 227 <xsl:call-template name="integer-by-key-value"> 228 <xsl:with-param name="key" select="'SERIAL_PIO_BASE'" /> 229 <xsl:with-param name="value" select="$base" /> 230 </xsl:call-template> 231 <xsl:if test="$bdf != ''"> 232 <xsl:call-template name="boolean-by-key-value"> 233 <xsl:with-param name="key" select="'SERIAL_PCI'" /> 234 <xsl:with-param name="value" select="'y'" /> 235 </xsl:call-template> 236 <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" /> 237 <xsl:call-template name="integer-by-key-value"> 238 <xsl:with-param name="key" select="'SERIAL_PCI_BDF'" /> 239 <xsl:with-param name="value" select="$serial_bdf" /> 240 </xsl:call-template> 241 </xsl:if> 242 </xsl:when> 243 <xsl:when test="($type = 'mmio') and ($bdf != '')"> 244 <xsl:call-template name="boolean-by-key-value"> 245 <xsl:with-param name="key" select="'SERIAL_PCI'" /> 246 <xsl:with-param name="value" select="'y'" /> 247 </xsl:call-template> 248 <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" /> 249 <xsl:call-template name="integer-by-key-value"> 250 <xsl:with-param name="key" select="'SERIAL_PCI_BDF'" /> 251 <xsl:with-param name="value" select="$serial_bdf" /> 252 </xsl:call-template> 253 </xsl:when> 254 <xsl:otherwise> 255 <xsl:call-template name="boolean-by-key-value"> 256 <xsl:with-param name="key" select="'SERIAL_MMIO'" /> 257 <xsl:with-param name="value" select="'y'" /> 258 </xsl:call-template> 259 <xsl:if test="$base != ''"> 260 <xsl:call-template name="integer-by-key-value"> 261 <xsl:with-param name="key" select="'SERIAL_MMIO_BASE'" /> 262 <xsl:with-param name="value" select="$base" /> 263 </xsl:call-template> 264 </xsl:if> 265 </xsl:otherwise> 266 </xsl:choose> 267 </xsl:template> 268 269 <xsl:template match="MISC_CFG"> 270 <xsl:call-template name="integer-by-key-value"> 271 <xsl:with-param name="key" select="'IGD_SBDF'" /> 272 <xsl:with-param name="value" select="//allocation-data/acrn-config/hv/MISC_CFG/IGD_SBDF" /> 273 </xsl:call-template> 274 </xsl:template> 275 276 <xsl:template name="msi-msix-max"> 277 <xsl:variable name="max"> 278 <xsl:for-each select="//capability[@id='MSI' or @id='MSI-X']/*[starts-with(local-name(), 'count') or starts-with(local-name(), 'table_size')]"> 279 <xsl:sort select="." data-type="number" order="descending"/> 280 <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if> 281 </xsl:for-each> 282 </xsl:variable> 283 <xsl:choose> 284 <xsl:when test="//CAPACITIES/MAX_MSIX_TABLE_NUM/text()"> 285 <xsl:call-template name="integer-by-key-value"> 286 <xsl:with-param name="key" select="'MAX_MSIX_TABLE_NUM'" /> 287 <xsl:with-param name="value" select="acrn:max($max, //CAPACITIES/MAX_MSIX_TABLE_NUM)" /> 288 </xsl:call-template> 289 </xsl:when> 290 <xsl:otherwise> 291 <xsl:call-template name="integer-by-key-value"> 292 <xsl:with-param name="key" select="'MAX_MSIX_TABLE_NUM'" /> 293 <xsl:with-param name="value" select="$max" /> 294 </xsl:call-template> 295 </xsl:otherwise> 296 </xsl:choose> 297 </xsl:template> 298 299 <xsl:template match="kern_type"> 300 <xsl:call-template name="boolean-by-key-value"> 301 <xsl:with-param name="key" select="concat('GUEST_', current())" /> 302 <xsl:with-param name="value" select="'y'" /> 303 </xsl:call-template> 304 </xsl:template> 305 306 <xsl:template name="hex-to-bin"> 307 <xsl:param name="s" /> 308 <xsl:param name="width" /> 309 310 <xsl:if test="string-length($s) > 0"> 311 <xsl:variable name="digit" select="substring($s, 1, 1)" /> 312 <xsl:choose> 313 <xsl:when test="$digit='0'"><xsl:value-of select="substring('0000', 5 - $width)" /></xsl:when> 314 <xsl:when test="$digit='1'"><xsl:value-of select="substring('0001', 5 - $width)" /></xsl:when> 315 <xsl:when test="$digit='2'"><xsl:value-of select="substring('0010', 5 - $width)" /></xsl:when> 316 <xsl:when test="$digit='3'"><xsl:value-of select="substring('0011', 5 - $width)" /></xsl:when> 317 <xsl:when test="$digit='4'"><xsl:value-of select="substring('0100', 5 - $width)" /></xsl:when> 318 <xsl:when test="$digit='5'"><xsl:value-of select="substring('0101', 5 - $width)" /></xsl:when> 319 <xsl:when test="$digit='6'"><xsl:value-of select="substring('0110', 5 - $width)" /></xsl:when> 320 <xsl:when test="$digit='7'"><xsl:value-of select="substring('0111', 5 - $width)" /></xsl:when> 321 <xsl:when test="$digit='8'"><xsl:value-of select="substring('1000', 5 - $width)" /></xsl:when> 322 <xsl:when test="$digit='9'"><xsl:value-of select="substring('1001', 5 - $width)" /></xsl:when> 323 <xsl:when test="$digit='a'"><xsl:value-of select="substring('1010', 5 - $width)" /></xsl:when> 324 <xsl:when test="$digit='b'"><xsl:value-of select="substring('1011', 5 - $width)" /></xsl:when> 325 <xsl:when test="$digit='c'"><xsl:value-of select="substring('1100', 5 - $width)" /></xsl:when> 326 <xsl:when test="$digit='d'"><xsl:value-of select="substring('1101', 5 - $width)" /></xsl:when> 327 <xsl:when test="$digit='e'"><xsl:value-of select="substring('1110', 5 - $width)" /></xsl:when> 328 <xsl:when test="$digit='f'"><xsl:value-of select="substring('1111', 5 - $width)" /></xsl:when> 329 </xsl:choose> 330 331 <xsl:call-template name="hex-to-bin"> 332 <xsl:with-param name="s" select="substring($s, 2)" /> 333 <xsl:with-param name="width" select="4" /> 334 </xsl:call-template> 335 </xsl:if> 336 </xsl:template> 337 338 <!-- Common library routines --> 339 340 <xsl:template name="integer-by-key-value"> 341 <xsl:param name="prefix" /> 342 <xsl:param name="key" /> 343 <xsl:param name="value" /> 344 <xsl:param name="default" /> 345 346 <xsl:choose> 347 <xsl:when test="$value != ''"> 348 <xsl:call-template name="entry-by-key-value"> 349 <xsl:with-param name="prefix" select="$prefix" /> 350 <xsl:with-param name="key" select="$key" /> 351 <xsl:with-param name="value" select="concat($value, $integer-suffix)" /> 352 </xsl:call-template> 353 </xsl:when> 354 <xsl:when test="$default != ''"> 355 <xsl:call-template name="entry-by-key-value"> 356 <xsl:with-param name="prefix" select="$prefix" /> 357 <xsl:with-param name="key" select="$key" /> 358 <xsl:with-param name="value" select="concat($default, $integer-suffix)" /> 359 </xsl:call-template> 360 </xsl:when> 361 <xsl:otherwise> 362 <xsl:call-template name="entry-by-key-value"> 363 <xsl:with-param name="prefix" select="$prefix" /> 364 <xsl:with-param name="key" select="$key" /> 365 </xsl:call-template> 366 </xsl:otherwise> 367 </xsl:choose> 368 </xsl:template> 369 370 <xsl:template name="boolean-by-key"> 371 <xsl:param name="key" /> 372 373 <xsl:call-template name="boolean-by-key-value"> 374 <xsl:with-param name="key" select="$key" /> 375 <xsl:with-param name="value" select="./*[name() = $key]" /> 376 </xsl:call-template> 377 </xsl:template> 378 379 <xsl:template name="integer-by-key"> 380 <xsl:param name="key" /> 381 <xsl:param name="default" /> 382 383 <xsl:call-template name="integer-by-key-value"> 384 <xsl:with-param name="key" select="$key" /> 385 <xsl:with-param name="value" select="./*[name() = $key]" /> 386 <xsl:with-param name="default" select="$default" /> 387 </xsl:call-template> 388 </xsl:template> 389 390</xsl:stylesheet> 391