1<?xml version="1.0" encoding="utf-8"?>
2<!--
3Copyright (C) 2004 Josh Triplett.  All Rights Reserved.
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all
13copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the names of the authors or their
23institutions shall not be used in advertising or otherwise to promote the
24sale, use or other dealings in this Software without prior written
25authorization from the authors.
26-->
27<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
28
29  <!-- The root element -->
30  <xsd:element name="xcb">
31    <xsd:complexType>
32      <xsd:group ref="macro" minOccurs="0" maxOccurs="unbounded" />
33      <xsd:attribute name="header" type="xsd:string" use="required" />
34      <xsd:attribute name="extension-xname" type="xsd:string" use="optional" />
35      <xsd:attribute name="extension-name"  type="xsd:string" use="optional" />
36      <xsd:attribute name="extension-multiword" type="xsd:boolean" use="optional" default="false" />
37      <xsd:attribute name="major-version"   type="xsd:integer" use="optional" />
38      <xsd:attribute name="minor-version"   type="xsd:integer" use="optional" />
39    </xsd:complexType>
40  </xsd:element>
41
42  <!-- Padding -->
43  <xsd:element name="pad">
44    <xsd:complexType>
45      <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
46      <xsd:attribute name="align" type="xsd:integer" use="optional" />
47      <xsd:attribute name="serialize" type="xsd:boolean" use="optional" />
48    </xsd:complexType>
49  </xsd:element>
50
51  <!-- Alignment -->
52  <xsd:element name="required_start_align" >
53    <xsd:complexType>
54      <xsd:attribute name="align" type="xsd:integer" use="required" />
55      <xsd:attribute name="offset" type="xsd:integer" use="optional" />
56    </xsd:complexType>
57  </xsd:element>
58
59  <!-- Type for fields or parameters with attributes "name" and "type" -->
60  <xsd:complexType name="var">
61    <xsd:attribute name="name" type="xsd:string" use="required" />
62    <xsd:attribute name="type" type="xsd:string" use="required" />
63    <xsd:attribute name="enum" type="xsd:string" use="optional" />
64    <xsd:attribute name="altenum" type="xsd:string" use="optional" />
65    <xsd:attribute name="mask" type="xsd:string" use="optional" />
66    <xsd:attribute name="altmask" type="xsd:string" use="optional" />
67  </xsd:complexType>
68
69  <!-- case expression -->
70  <xsd:complexType name="caseexpr">
71    <xsd:sequence>
72      <!-- case expression: -->
73      <xsd:group ref="expression" minOccurs="1" maxOccurs="unbounded" />
74      <!-- match -->
75      <xsd:group ref="fields" minOccurs="1" maxOccurs="unbounded" />
76      <xsd:choice>
77        <xsd:element ref="switch" minOccurs="0" maxOccurs="unbounded" />
78      </xsd:choice>
79    </xsd:sequence>
80    <xsd:attribute name="name" type="xsd:string" use="optional" />
81  </xsd:complexType>
82
83  <!-- switch expression -->
84  <xsd:complexType name="switchexpr">
85    <xsd:sequence>
86      <!-- switch(expression) -->
87      <xsd:group ref="expression" minOccurs="1" maxOccurs="1" />
88      <xsd:element ref="required_start_align" minOccurs="0" maxOccurs="1" />
89      <xsd:choice>
90        <!-- bitcase expression - bit test -->
91        <xsd:element name="bitcase" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
92        <!-- case expression - value test -->
93        <xsd:element name="case" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
94      </xsd:choice>
95    </xsd:sequence>
96    <xsd:attribute name="name" type="xsd:string" use="required" />
97  </xsd:complexType>
98
99  <xsd:element name="switch" type="switchexpr" />
100
101  <!-- field replaces FIELD, PARAM, and REPLY. -->
102  <xsd:element name="field" type="var" />
103
104  <!-- Length of data structures -->
105  <xsd:element name="length">
106    <xsd:complexType>
107      <xsd:group ref="expression" />
108    </xsd:complexType>
109  </xsd:element>
110
111  <!-- fd passing parameter -->
112  <xsd:element name="fd">
113    <xsd:complexType>
114      <xsd:attribute name="name" type="xsd:string" use="required" />
115    </xsd:complexType>
116  </xsd:element>
117
118  <!-- list replaces ARRAYFIELD, LISTPARAM, and ARRAYREPLY.  The name and type
119       are specified as attributes.  The content is an expression giving the
120       length. -->
121  <xsd:element name="list">
122    <xsd:complexType>
123      <xsd:complexContent>
124        <xsd:extension base="var">
125          <xsd:group ref="expression" minOccurs="0" maxOccurs="1" />
126        </xsd:extension>
127      </xsd:complexContent>
128    </xsd:complexType>
129  </xsd:element>
130
131  <!-- Expressions -->
132  <xsd:group name="expression">
133    <xsd:choice>
134      <xsd:element name="op">
135        <xsd:complexType>
136          <xsd:sequence>
137            <xsd:group ref="expression" />
138            <xsd:group ref="expression" />
139          </xsd:sequence>
140          <xsd:attribute name="op" use="required">
141            <xsd:simpleType>
142              <xsd:restriction base="xsd:string">
143                <xsd:pattern value="\+|-|\*|/|&amp;|&lt;&lt;" />
144              </xsd:restriction>
145            </xsd:simpleType>
146          </xsd:attribute>
147        </xsd:complexType>
148      </xsd:element>
149      <xsd:element name="unop">
150         <xsd:complexType>
151            <xsd:sequence>
152              <xsd:group ref="expression" />
153            </xsd:sequence>
154            <xsd:attribute name="op" use="required">
155              <xsd:simpleType>
156                <xsd:restriction base="xsd:string">
157                  <xsd:pattern value="~" />
158                </xsd:restriction>
159              </xsd:simpleType>
160            </xsd:attribute>
161         </xsd:complexType>
162      </xsd:element>
163      <xsd:element name="fieldref" type="xsd:string" />
164      <xsd:element name="paramref">
165        <xsd:complexType>
166          <xsd:simpleContent>
167            <xsd:extension base="xsd:string">
168              <xsd:attribute name="type" use="required" type="xsd:string" />
169            </xsd:extension>
170          </xsd:simpleContent>
171        </xsd:complexType>
172      </xsd:element>
173      <xsd:element name="enumref">
174        <xsd:complexType>
175          <xsd:simpleContent>
176            <xsd:extension base="xsd:string">
177              <xsd:attribute name="ref" use="required" type="xsd:string" />
178            </xsd:extension>
179          </xsd:simpleContent>
180        </xsd:complexType>
181      </xsd:element>
182      <xsd:element name="popcount">
183        <xsd:complexType>
184          <xsd:group ref="expression" />
185        </xsd:complexType>
186      </xsd:element>
187      <xsd:element name="sumof">
188        <xsd:complexType>
189          <xsd:sequence>
190            <xsd:group ref="expression" minOccurs="0" maxOccurs="1"/>
191          </xsd:sequence>
192          <xsd:attribute name="ref" use="required" type="xsd:string" />
193        </xsd:complexType>
194      </xsd:element>
195      <xsd:element name="listelement-ref" />
196      <xsd:element name="value" type="xsd:integer" />
197      <xsd:element name="bit" type="bitType" />
198    </xsd:choice>
199  </xsd:group>
200  
201  <!-- Fields in requests that are calculated from other information, not
202       supplied by the caller. -->
203  <xsd:element name="exprfield" >
204    <xsd:complexType>
205      <xsd:complexContent>
206        <xsd:extension base="var">
207          <xsd:group ref="expression" />
208        </xsd:extension>
209      </xsd:complexContent>
210    </xsd:complexType>
211  </xsd:element>
212
213  <xsd:group name="fields">
214    <xsd:choice>
215      <xsd:element ref="pad" />
216      <xsd:element ref="field" />
217      <xsd:element ref="list" />
218      <xsd:element ref="fd" />
219      <xsd:element ref="required_start_align" />
220      <xsd:element ref="length" />
221    </xsd:choice>
222  </xsd:group>
223
224  <!-- Type for a structure -->
225  <xsd:complexType name="struct">
226    <xsd:sequence>
227      <xsd:group ref="fields" minOccurs="1" maxOccurs="unbounded" />
228      <xsd:choice minOccurs="0" maxOccurs="1">
229        <xsd:element ref="switch" />
230      </xsd:choice>
231    </xsd:sequence>
232    <xsd:attribute name="name" type="xsd:string" use="required" />
233  </xsd:complexType>
234
235  <!-- Type for a packet structure -->
236  <xsd:complexType name="packet-struct">
237    <xsd:sequence>
238      <xsd:group ref="fields" minOccurs="0" maxOccurs="unbounded" />
239    </xsd:sequence>
240    <xsd:attribute name="name" type="xsd:string" use="required" />
241    <xsd:attribute name="number" type="xsd:integer" use="required" />
242  </xsd:complexType>
243
244  <!-- Type for a packet structure copy -->
245  <xsd:complexType name="packet-struct-copy">
246    <xsd:attribute name="name" type="xsd:string" use="required" />
247    <xsd:attribute name="number" type="xsd:integer" use="required" />
248    <xsd:attribute name="ref" type="xsd:string" use="required" />
249  </xsd:complexType>
250
251  <!-- Type for a structure that is an event
252       which can be of an event type from a set of event types -->
253  <xsd:complexType name="eventstruct">
254    <xsd:sequence>
255      <xsd:element name="allowed">
256        <xsd:complexType>
257          <xsd:attribute name="extension" type="xsd:string" use="required" />
258          <xsd:attribute name="xge" type="xsd:boolean" use="required" />
259          <xsd:attribute name="opcode-min" type="xsd:integer" use="required" />
260          <xsd:attribute name="opcode-max" type="xsd:integer" use="required" />
261        </xsd:complexType>
262      </xsd:element>
263    </xsd:sequence>
264    <xsd:attribute name="name" type="xsd:string" use="required" />
265  </xsd:complexType>
266
267  <!-- Type for bit values -->
268  <xsd:simpleType name="bitType">
269    <xsd:restriction base="xsd:integer">
270      <xsd:minInclusive value="0" />
271      <xsd:maxExclusive value="32" />
272    </xsd:restriction>
273  </xsd:simpleType>
274
275  <!-- Type for documentation -->
276  <xsd:group name="doc-fields">
277    <xsd:sequence>
278      <xsd:element name="field">
279        <xsd:complexType>
280          <xsd:simpleContent>
281            <xsd:extension base="xsd:string">
282              <xsd:attribute name="name" type="xsd:string" />
283            </xsd:extension>
284          </xsd:simpleContent>
285        </xsd:complexType>
286      </xsd:element>
287    </xsd:sequence>
288  </xsd:group>
289
290  <xsd:group name="error-fields">
291    <xsd:sequence>
292      <xsd:element name="error">
293        <xsd:complexType>
294          <xsd:simpleContent>
295            <xsd:extension base="xsd:string">
296              <xsd:attribute name="type" type="xsd:string" />
297            </xsd:extension>
298          </xsd:simpleContent>
299        </xsd:complexType>
300      </xsd:element>
301    </xsd:sequence>
302  </xsd:group>
303
304  <xsd:group name="see-fields">
305    <xsd:sequence>
306      <xsd:element name="see">
307        <xsd:complexType>
308          <xsd:attribute name="name" type="xsd:string" />
309          <xsd:attribute name="type" type="xsd:string" />
310        </xsd:complexType>
311      </xsd:element>
312    </xsd:sequence>
313  </xsd:group>
314
315  <xsd:element name="doc">
316    <xsd:complexType mixed="true">
317      <xsd:sequence>
318        <xsd:element name="brief" type="xsd:string" minOccurs="0" maxOccurs="1" />
319        <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1" />
320        <xsd:element name="example" type="xsd:string" minOccurs="0" maxOccurs="1" />
321        <xsd:group ref="doc-fields" minOccurs="0" maxOccurs="unbounded" />
322        <xsd:group ref="error-fields" minOccurs="0" maxOccurs="unbounded" />
323        <xsd:group ref="see-fields" minOccurs="0" maxOccurs="unbounded" />
324      </xsd:sequence>
325    </xsd:complexType>
326  </xsd:element>
327
328  <xsd:group name="macro">
329    <xsd:choice>
330      <xsd:element name="request">
331        <xsd:complexType>
332          <xsd:sequence>
333            <xsd:choice minOccurs="0" maxOccurs="unbounded">
334              <xsd:group ref="fields" />
335              <xsd:element ref="exprfield" />
336            </xsd:choice>
337            <xsd:choice minOccurs="0" maxOccurs="1">
338              <xsd:element ref="switch" />
339            </xsd:choice>
340            <xsd:element name="reply" minOccurs="0" maxOccurs="1">
341              <xsd:complexType>
342                <xsd:sequence>
343                  <xsd:choice minOccurs="1" maxOccurs="unbounded">
344                    <xsd:group ref="fields" />
345                  </xsd:choice>
346                  <xsd:choice minOccurs="0" maxOccurs="1">
347                    <xsd:element ref="switch" />
348                  </xsd:choice>
349                  <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
350                </xsd:sequence>
351              </xsd:complexType>
352            </xsd:element>
353            <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
354          </xsd:sequence>
355          <xsd:attribute name="name" type="xsd:string" use="required" />
356          <xsd:attribute name="opcode" type="xsd:integer" use="required" />
357          <xsd:attribute name="combine-adjacent" type="xsd:boolean"
358                         use="optional" default="false" />
359        </xsd:complexType>
360      </xsd:element>
361      <xsd:element name="event">
362        <xsd:complexType>
363          <xsd:complexContent>
364            <xsd:extension base="packet-struct">
365              <xsd:sequence>
366                <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
367              </xsd:sequence>
368              <xsd:attribute name="no-sequence-number" type="xsd:boolean"
369                             use="optional" default="false" />
370              <xsd:attribute name="xge" type="xsd:boolean"
371                             use="optional" default="false" />
372            </xsd:extension>
373          </xsd:complexContent>
374        </xsd:complexType>
375      </xsd:element>
376      <xsd:element name="eventcopy" type="packet-struct-copy" />
377      <xsd:element name="error" type="packet-struct" />
378      <xsd:element name="errorcopy" type="packet-struct-copy" />
379      <xsd:element name="struct" type="struct" />
380      <xsd:element name="union" type="struct" />
381      <xsd:element name="eventstruct" type="eventstruct" />
382      <xsd:element name="xidtype">
383        <xsd:complexType>
384          <xsd:attribute name="name" type="xsd:string" use="required" />
385        </xsd:complexType>
386      </xsd:element>
387      <xsd:element name="xidunion">
388        <xsd:complexType>
389          <xsd:sequence>
390            <xsd:element name="type" type="xsd:string"
391                         minOccurs="1" maxOccurs="unbounded" />
392          </xsd:sequence>
393          <xsd:attribute name="name" type="xsd:string" use="required" />
394        </xsd:complexType>
395      </xsd:element>
396      <xsd:element name="enum">
397        <xsd:complexType>
398          <xsd:sequence minOccurs="1" maxOccurs="unbounded">
399            <xsd:element name="item">
400              <xsd:complexType>
401                <xsd:choice minOccurs="1" maxOccurs="1">
402                  <xsd:element name="value" type="xsd:unsignedInt" />
403                  <xsd:element name="bit" type="bitType" />
404                </xsd:choice>
405                <xsd:attribute name="name" type="xsd:string" use="required" />
406              </xsd:complexType>
407            </xsd:element>
408            <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
409          </xsd:sequence>
410          <xsd:attribute name="name" type="xsd:string" use="required" />
411        </xsd:complexType>
412      </xsd:element>
413      <xsd:element name="typedef">
414        <xsd:complexType>
415          <xsd:attribute name="oldname" type="xsd:string" use="required" />
416          <xsd:attribute name="newname" type="xsd:string" use="required" />
417        </xsd:complexType>
418      </xsd:element>
419      <!-- The import element allows a protocol description to reference the
420           declarations of another protocol description. -->
421      <xsd:element name="import" type="xsd:string" />
422    </xsd:choice>
423  </xsd:group>
424</xsd:schema>
425