1
1
pub use super :: Interrupt ;
2
2
use super :: { BuildError , SvdError , ValidateLevel } ;
3
3
4
+ /// Description of the custom exceptions in the device.
5
+ pub mod exception;
6
+ pub use exception:: Exception ;
7
+
4
8
/// Description of HARTs in the device.
5
9
pub mod hart;
6
10
pub use hart:: Hart ;
@@ -25,6 +29,13 @@ pub struct Riscv {
25
29
) ]
26
30
pub core_interrupts : Vec < Interrupt > ,
27
31
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
+
28
39
/// Priority level enumeration values
29
40
#[ cfg_attr(
30
41
feature = "serde" ,
@@ -44,6 +55,7 @@ pub struct Riscv {
44
55
#[ derive( Clone , Debug , Default , PartialEq , Eq ) ]
45
56
pub struct RiscvBuilder {
46
57
core_interrupts : Option < Vec < Interrupt > > ,
58
+ exceptions : Option < Vec < Exception > > ,
47
59
priorities : Option < Vec < Priority > > ,
48
60
harts : Option < Vec < Hart > > ,
49
61
}
@@ -52,6 +64,7 @@ impl From<Riscv> for RiscvBuilder {
52
64
fn from ( riscv : Riscv ) -> Self {
53
65
Self {
54
66
core_interrupts : Some ( riscv. core_interrupts ) ,
67
+ exceptions : Some ( riscv. exceptions ) ,
55
68
priorities : Some ( riscv. priorities ) ,
56
69
harts : Some ( riscv. harts ) ,
57
70
}
@@ -65,6 +78,12 @@ impl RiscvBuilder {
65
78
self
66
79
}
67
80
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
+
68
87
/// Set the priority level enumeration values
69
88
pub fn priorities ( mut self , priorities : Vec < Priority > ) -> Self {
70
89
self . priorities = Some ( priorities) ;
@@ -83,6 +102,9 @@ impl RiscvBuilder {
83
102
core_interrupts : self
84
103
. core_interrupts
85
104
. ok_or_else ( || BuildError :: Uninitialized ( "core_interrupts" . to_string ( ) ) ) ?,
105
+ exceptions : self
106
+ . exceptions
107
+ . ok_or_else ( || BuildError :: Uninitialized ( "exceptions" . to_string ( ) ) ) ?,
86
108
priorities : self
87
109
. priorities
88
110
. ok_or_else ( || BuildError :: Uninitialized ( "priorities" . to_string ( ) ) ) ?,
@@ -110,6 +132,9 @@ impl Riscv {
110
132
if let Some ( core_interrupts) = builder. core_interrupts {
111
133
self . core_interrupts = core_interrupts;
112
134
}
135
+ if let Some ( exceptions) = builder. exceptions {
136
+ self . exceptions = exceptions;
137
+ }
113
138
if let Some ( priorities) = builder. priorities {
114
139
self . priorities = priorities;
115
140
}
@@ -124,12 +149,16 @@ impl Riscv {
124
149
/// # Errors
125
150
///
126
151
/// - If any of the core interrupt enumeration values are invalid
152
+ /// - If any of the exception enumeration values are invalid
127
153
/// - If any of the priority level enumeration values are invalid
128
154
/// - If any of the HART enumeration values are invalid
129
155
pub fn validate ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
130
156
for ci in & self . core_interrupts {
131
157
ci. validate ( lvl) ?;
132
158
}
159
+ for e in & self . exceptions {
160
+ e. validate ( lvl) ?;
161
+ }
133
162
for p in & self . priorities {
134
163
p. validate ( lvl) ?;
135
164
}
0 commit comments