@@ -23,11 +23,44 @@ pub struct Cpu {
23
23
/// Indicate whether the processor is equipped with a hardware floating point unit (FPU)
24
24
pub fpu_present : bool ,
25
25
26
+ /// Indicate whether the processor is equipped with a double precision floating point unit.
27
+ /// This element is valid only when `fpu_present` is set to `true`
28
+ #[ cfg_attr( feature = "serde" , serde( rename = "fpuDP" ) ) ]
29
+ pub fpu_double_precision : Option < bool > ,
30
+
31
+ /// Indicates whether the processor implements the optional SIMD DSP extensions (DSP)
32
+ pub dsp_present : Option < bool > ,
33
+
34
+ /// Indicate whether the processor has an instruction cache
35
+ pub icache_present : Option < bool > ,
36
+
37
+ /// Indicate whether the processor has a data cache
38
+ pub dcache_present : Option < bool > ,
39
+
40
+ /// Indicate whether the processor has an instruction tightly coupled memory
41
+ pub itcm_present : Option < bool > ,
42
+
43
+ /// Indicate whether the processor has a data tightly coupled memory
44
+ pub dtcm_present : Option < bool > ,
45
+
46
+ /// Indicate whether the Vector Table Offset Register (VTOR) is implemented.
47
+ /// If not specified, then VTOR is assumed to be present
48
+ pub vtor_present : Option < bool > ,
49
+
26
50
/// Define the number of bits available in the Nested Vectored Interrupt Controller (NVIC) for configuring priority
51
+ #[ cfg_attr( feature = "serde" , serde( rename = "nvicPrioBits" ) ) ]
27
52
pub nvic_priority_bits : u32 ,
28
53
29
54
/// Indicate whether the processor implements a vendor-specific System Tick Timer
55
+ #[ cfg_attr( feature = "serde" , serde( rename = "vendorSystickConfig" ) ) ]
30
56
pub has_vendor_systick : bool ,
57
+
58
+ /// Add 1 to the highest interrupt number and specify this number in here
59
+ pub device_num_interrupts : Option < u32 > ,
60
+
61
+ /// Indicate the amount of regions in the Security Attribution Unit (SAU)
62
+ pub sau_num_regions : Option < u32 > ,
63
+ // sauRegionsConfig
31
64
}
32
65
33
66
/// Builder for [`Cpu`]
@@ -38,8 +71,17 @@ pub struct CpuBuilder {
38
71
endian : Option < Endian > ,
39
72
mpu_present : Option < bool > ,
40
73
fpu_present : Option < bool > ,
74
+ fpu_double_precision : Option < bool > ,
75
+ dsp_present : Option < bool > ,
76
+ icache_present : Option < bool > ,
77
+ dcache_present : Option < bool > ,
78
+ itcm_present : Option < bool > ,
79
+ dtcm_present : Option < bool > ,
80
+ vtor_present : Option < bool > ,
41
81
nvic_priority_bits : Option < u32 > ,
42
82
has_vendor_systick : Option < bool > ,
83
+ device_num_interrupts : Option < u32 > ,
84
+ sau_num_regions : Option < u32 > ,
43
85
}
44
86
45
87
impl From < Cpu > for CpuBuilder {
@@ -50,8 +92,17 @@ impl From<Cpu> for CpuBuilder {
50
92
endian : Some ( c. endian ) ,
51
93
mpu_present : Some ( c. mpu_present ) ,
52
94
fpu_present : Some ( c. fpu_present ) ,
95
+ fpu_double_precision : c. fpu_double_precision ,
96
+ dsp_present : c. dsp_present ,
97
+ icache_present : c. icache_present ,
98
+ dcache_present : c. dcache_present ,
99
+ itcm_present : c. itcm_present ,
100
+ dtcm_present : c. dtcm_present ,
101
+ vtor_present : c. vtor_present ,
53
102
nvic_priority_bits : Some ( c. nvic_priority_bits ) ,
54
103
has_vendor_systick : Some ( c. has_vendor_systick ) ,
104
+ device_num_interrupts : c. device_num_interrupts ,
105
+ sau_num_regions : c. sau_num_regions ,
55
106
}
56
107
}
57
108
}
@@ -82,6 +133,41 @@ impl CpuBuilder {
82
133
self . fpu_present = Some ( value) ;
83
134
self
84
135
}
136
+ /// Set the fpu_double_precision of the cpu.
137
+ pub fn fpu_double_precision ( mut self , value : Option < bool > ) -> Self {
138
+ self . fpu_double_precision = value;
139
+ self
140
+ }
141
+ /// Set the dsp_present of the cpu.
142
+ pub fn dsp_present ( mut self , value : Option < bool > ) -> Self {
143
+ self . dsp_present = value;
144
+ self
145
+ }
146
+ /// Set the icache_present of the cpu.
147
+ pub fn icache_present ( mut self , value : Option < bool > ) -> Self {
148
+ self . icache_present = value;
149
+ self
150
+ }
151
+ /// Set the dcache_present of the cpu.
152
+ pub fn dcache_present ( mut self , value : Option < bool > ) -> Self {
153
+ self . dcache_present = value;
154
+ self
155
+ }
156
+ /// Set the itcm_present of the cpu.
157
+ pub fn itcm_present ( mut self , value : Option < bool > ) -> Self {
158
+ self . itcm_present = value;
159
+ self
160
+ }
161
+ /// Set the dtcm_present of the cpu.
162
+ pub fn dtcm_present ( mut self , value : Option < bool > ) -> Self {
163
+ self . dtcm_present = value;
164
+ self
165
+ }
166
+ /// Set the vtor_present of the cpu.
167
+ pub fn vtor_present ( mut self , value : Option < bool > ) -> Self {
168
+ self . vtor_present = value;
169
+ self
170
+ }
85
171
/// Set the nvic_priority_bits of the cpu.
86
172
pub fn nvic_priority_bits ( mut self , value : u32 ) -> Self {
87
173
self . nvic_priority_bits = Some ( value) ;
@@ -92,6 +178,16 @@ impl CpuBuilder {
92
178
self . has_vendor_systick = Some ( value) ;
93
179
self
94
180
}
181
+ /// Set the device_num_interrupts of the cpu.
182
+ pub fn device_num_interrupts ( mut self , value : Option < u32 > ) -> Self {
183
+ self . device_num_interrupts = value;
184
+ self
185
+ }
186
+ /// Set the sau_num_regions of the cpu.
187
+ pub fn sau_num_regions ( mut self , value : Option < u32 > ) -> Self {
188
+ self . sau_num_regions = value;
189
+ self
190
+ }
95
191
/// Validate and build a [`Cpu`].
96
192
pub fn build ( self , lvl : ValidateLevel ) -> Result < Cpu , SvdError > {
97
193
let mut cpu = Cpu {
@@ -110,12 +206,21 @@ impl CpuBuilder {
110
206
fpu_present : self
111
207
. fpu_present
112
208
. ok_or_else ( || BuildError :: Uninitialized ( "fpu_present" . to_string ( ) ) ) ?,
209
+ fpu_double_precision : self . fpu_double_precision ,
210
+ dsp_present : self . dsp_present ,
211
+ icache_present : self . icache_present ,
212
+ dcache_present : self . dcache_present ,
213
+ itcm_present : self . itcm_present ,
214
+ dtcm_present : self . dtcm_present ,
215
+ vtor_present : self . vtor_present ,
113
216
nvic_priority_bits : self
114
217
. nvic_priority_bits
115
218
. ok_or_else ( || BuildError :: Uninitialized ( "nvic_priority_bits" . to_string ( ) ) ) ?,
116
219
has_vendor_systick : self
117
220
. has_vendor_systick
118
221
. ok_or_else ( || BuildError :: Uninitialized ( "has_vendor_systick" . to_string ( ) ) ) ?,
222
+ device_num_interrupts : self . device_num_interrupts ,
223
+ sau_num_regions : self . sau_num_regions ,
119
224
} ;
120
225
if !lvl. is_disabled ( ) {
121
226
cpu. validate ( lvl) ?;
@@ -146,12 +251,39 @@ impl Cpu {
146
251
if let Some ( fpu_present) = builder. fpu_present {
147
252
self . fpu_present = fpu_present;
148
253
}
254
+ if builder. fpu_double_precision . is_some ( ) {
255
+ self . fpu_double_precision = builder. fpu_double_precision ;
256
+ }
257
+ if builder. dsp_present . is_some ( ) {
258
+ self . dsp_present = builder. dsp_present ;
259
+ }
260
+ if builder. icache_present . is_some ( ) {
261
+ self . icache_present = builder. icache_present ;
262
+ }
263
+ if builder. dcache_present . is_some ( ) {
264
+ self . dcache_present = builder. dcache_present ;
265
+ }
266
+ if builder. itcm_present . is_some ( ) {
267
+ self . itcm_present = builder. itcm_present ;
268
+ }
269
+ if builder. dtcm_present . is_some ( ) {
270
+ self . dtcm_present = builder. dtcm_present ;
271
+ }
272
+ if builder. vtor_present . is_some ( ) {
273
+ self . vtor_present = builder. vtor_present ;
274
+ }
149
275
if let Some ( nvic_priority_bits) = builder. nvic_priority_bits {
150
276
self . nvic_priority_bits = nvic_priority_bits;
151
277
}
152
278
if let Some ( has_vendor_systick) = builder. has_vendor_systick {
153
279
self . has_vendor_systick = has_vendor_systick;
154
280
}
281
+ if builder. device_num_interrupts . is_some ( ) {
282
+ self . device_num_interrupts = builder. device_num_interrupts ;
283
+ }
284
+ if builder. sau_num_regions . is_some ( ) {
285
+ self . sau_num_regions = builder. sau_num_regions ;
286
+ }
155
287
if !lvl. is_disabled ( ) {
156
288
self . validate ( lvl)
157
289
} else {
0 commit comments