11pub use super :: Interrupt ;
22use super :: { BuildError , SvdError , ValidateLevel } ;
33
4+ /// Description of the custom exceptions in the device.
5+ pub mod exception;
6+ pub use exception:: Exception ;
7+
48/// Description of HARTs in the device.
59pub mod hart;
610pub use hart:: Hart ;
@@ -25,6 +29,13 @@ pub struct Riscv {
2529 ) ]
2630 pub core_interrupts : Vec < Interrupt > ,
2731
32+ /// Exception enumeration values
33+ #[ cfg_attr(
34+ feature = "serde" ,
35+ serde( default , skip_serializing_if = "Vec::is_empty" )
36+ ) ]
37+ pub exceptions : Vec < Exception > ,
38+
2839 /// Priority level enumeration values
2940 #[ cfg_attr(
3041 feature = "serde" ,
@@ -44,6 +55,7 @@ pub struct Riscv {
4455#[ derive( Clone , Debug , Default , PartialEq , Eq ) ]
4556pub struct RiscvBuilder {
4657 core_interrupts : Option < Vec < Interrupt > > ,
58+ exceptions : Option < Vec < Exception > > ,
4759 priorities : Option < Vec < Priority > > ,
4860 harts : Option < Vec < Hart > > ,
4961}
@@ -52,6 +64,7 @@ impl From<Riscv> for RiscvBuilder {
5264 fn from ( riscv : Riscv ) -> Self {
5365 Self {
5466 core_interrupts : Some ( riscv. core_interrupts ) ,
67+ exceptions : Some ( riscv. exceptions ) ,
5568 priorities : Some ( riscv. priorities ) ,
5669 harts : Some ( riscv. harts ) ,
5770 }
@@ -65,6 +78,12 @@ impl RiscvBuilder {
6578 self
6679 }
6780
81+ /// Set the exception enumeration values
82+ pub fn exceptions ( mut self , exceptions : Vec < Exception > ) -> Self {
83+ self . exceptions = Some ( exceptions) ;
84+ self
85+ }
86+
6887 /// Set the priority level enumeration values
6988 pub fn priorities ( mut self , priorities : Vec < Priority > ) -> Self {
7089 self . priorities = Some ( priorities) ;
@@ -83,6 +102,9 @@ impl RiscvBuilder {
83102 core_interrupts : self
84103 . core_interrupts
85104 . ok_or_else ( || BuildError :: Uninitialized ( "core_interrupts" . to_string ( ) ) ) ?,
105+ exceptions : self
106+ . exceptions
107+ . ok_or_else ( || BuildError :: Uninitialized ( "exceptions" . to_string ( ) ) ) ?,
86108 priorities : self
87109 . priorities
88110 . ok_or_else ( || BuildError :: Uninitialized ( "priorities" . to_string ( ) ) ) ?,
@@ -110,6 +132,9 @@ impl Riscv {
110132 if let Some ( core_interrupts) = builder. core_interrupts {
111133 self . core_interrupts = core_interrupts;
112134 }
135+ if let Some ( exceptions) = builder. exceptions {
136+ self . exceptions = exceptions;
137+ }
113138 if let Some ( priorities) = builder. priorities {
114139 self . priorities = priorities;
115140 }
@@ -124,12 +149,16 @@ impl Riscv {
124149 /// # Errors
125150 ///
126151 /// - If any of the core interrupt enumeration values are invalid
152+ /// - If any of the exception enumeration values are invalid
127153 /// - If any of the priority level enumeration values are invalid
128154 /// - If any of the HART enumeration values are invalid
129155 pub fn validate ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
130156 for ci in & self . core_interrupts {
131157 ci. validate ( lvl) ?;
132158 }
159+ for e in & self . exceptions {
160+ e. validate ( lvl) ?;
161+ }
133162 for p in & self . priorities {
134163 p. validate ( lvl) ?;
135164 }
0 commit comments