1<?xml version="1.0"?>
2<!-- Copyright (C) 2022 Intel Corporation. -->
3<!-- SPDX-License-Identifier: BSD-3-Clause -->
4
5<xs:schema xml:id="root"
6           xmlns:xs="http://www.w3.org/2001/XMLSchema"
7           xmlns:acrn="https://projectacrn.org">
8
9  <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
10                   every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
11                   count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
12    <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/endpoint">
13      <xs:documentation>The vUART configuration of VM "{$vm_name}" may not connect to itself.</xs:documentation>
14    </xs:annotation>
15  </xs:assert>
16
17  <xs:assert test="every $io_port in /acrn-config//endpoint[vm_name != '']/io_port satisfies
18                   count(//endpoint[./vm_name=$io_port/ancestor::endpoint/vm_name and io_port=$io_port]) = 1">
19    <xs:annotation acrn:severity="error" acrn:report-on="$io_port">
20      <xs:documentation>VM "{$io_port/ancestor::endpoint/vm_name}" may not duplicate use of port "{$io_port}."</xs:documentation>
21    </xs:annotation>
22  </xs:assert>
23
24  <xs:assert test="every $console_port in /acrn-config//console_vuart satisfies
25                   if ($console_port = 'COM Port 1')
26                   then count(//endpoint[./vm_name=$console_port/ancestor::vm/name and io_port='0x3F8']) &lt; 1
27                   else if ($console_port = 'COM Port 2')
28                   then count(//endpoint[./vm_name=$console_port/ancestor::vm/name and io_port='0x2F8']) &lt; 1
29                   else if ($console_port = 'COM Port 3')
30                   then count(//endpoint[./vm_name=$console_port/ancestor::vm/name and io_port='0x3E8']) &lt; 1
31                   else if ($console_port = 'COM Port 4')
32                   then count(//endpoint[./vm_name=$console_port/ancestor::vm/name and io_port='0x2E8']) &lt; 1
33                   else true()">
34    <xs:annotation acrn:severity="error" acrn:report-on="$console_port">
35      <xs:documentation>VM "{$console_port/ancestor::vm/name}" may not duplicate use of console "{$console_port}."</xs:documentation>
36    </xs:annotation>
37  </xs:assert>
38
39  <xs:assert test="every $NAME in /acrn-config//vuart_connection//endpoint//vm_name satisfies
40                  not(/acrn-config//vuart_connection//endpoint//vm_name = '')">
41    <xs:annotation acrn:severity="error" acrn:report-on="$NAME">
42      <xs:documentation>VM name in "{$NAME/ancestor::vuart_connection/name}" must be set </xs:documentation>
43    </xs:annotation>
44  </xs:assert>
45
46  <xs:assert test="not (//BUILD_TYPE = 'debug' and //SERIAL_CONSOLE = 'None')">
47    <xs:annotation acrn:severity="error" acrn:report-on="//BUILD_TYPE">
48       <xs:documentation>Select a hypervisor serial console port when Build type is Debug, or use Build type Release if no serial console is available.</xs:documentation>
49    </xs:annotation>
50  </xs:assert>
51
52</xs:schema>
53