Skip to content

Commit

Permalink
Added XSD and a validation script
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Podhradsky <[email protected]>
  • Loading branch information
podhrmic committed Oct 24, 2023
1 parent 95a4ab3 commit 1a0dc1b
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
93 changes: 93 additions & 0 deletions system.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="system">
<xs:complexType>
<xs:sequence>
<xs:element name="memory_region" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="size" type="xs:string" use="required" />
<xs:attribute name="page_size" type="xs:string" use="optional" />
<xs:attribute name="phys_addr" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>

<xs:element name="protection_domain" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="program_image" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="path" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="map">
<xs:complexType>
<xs:attribute name="mr" type="xs:string" use="required" />
<xs:attribute name="vaddr" type="xs:string" use="required" />
<xs:attribute name="perms" type="xs:string" use="required" />
<xs:attribute name="cached" type="xs:boolean" use="optional" default="false" />
<xs:attribute name="setvar_vaddr" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="setvar">
<xs:complexType>
<xs:attribute name="symbol" type="xs:string" use="required" />
<xs:attribute name="region_paddr" type="xs:string" use="optional" />
<xs:attribute name="vaddr" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="irq" minOccurs="0" maxOccurs="63">
<xs:complexType>
<xs:attribute name="irq" type="xs:integer" use="required" />
<xs:attribute name="id" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="priority" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0" />
<xs:maxInclusive value="254" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="pp" type="xs:boolean" use="optional" default="false" />
<xs:attribute name="budget" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(\d_?)+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="period" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(\d_?)+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="passive" type="xs:boolean" use="optional" default="false" />
</xs:complexType>
</xs:element>

<xs:element name="channel" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="end" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:attribute name="pd" type="xs:string" use="required" />
<xs:attribute name="id" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>
15 changes: 15 additions & 0 deletions validate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env bash
err=0

for f in `find . -wholename "./example/*.system"`
do
xmllint --noout --schema system.xsd $f
if (($? != 0)); then
err=$((err + 1))
fi
done

if ((${err} > 0)); then
echo "There were errors while parsing"
exit 1
fi

0 comments on commit 1a0dc1b

Please sign in to comment.