@@ -20,6 +20,17 @@ pub(crate) mod gsp;
20
20
mod hal;
21
21
pub ( crate ) mod sec2;
22
22
23
+ // TODO[FPRI]: Replace with `ToPrimitive`.
24
+ macro_rules! impl_from_enum_to_u32 {
25
+ ( $enum_type: ty) => {
26
+ impl From <$enum_type> for u32 {
27
+ fn from( value: $enum_type) -> Self {
28
+ value as u32
29
+ }
30
+ }
31
+ } ;
32
+ }
33
+
23
34
/// Revision number of a falcon core, used in the [`crate::regs::NV_PFALCON_FALCON_HWCFG1`]
24
35
/// register.
25
36
#[ repr( u8 ) ]
@@ -34,6 +45,7 @@ pub(crate) enum FalconCoreRev {
34
45
Rev6 = 6 ,
35
46
Rev7 = 7 ,
36
47
}
48
+ impl_from_enum_to_u32 ! ( FalconCoreRev ) ;
37
49
38
50
// TODO[FPRI]: replace with `FromPrimitive`.
39
51
impl TryFrom < u8 > for FalconCoreRev {
@@ -68,6 +80,7 @@ pub(crate) enum FalconCoreRevSubversion {
68
80
Subversion2 = 2 ,
69
81
Subversion3 = 3 ,
70
82
}
83
+ impl_from_enum_to_u32 ! ( FalconCoreRevSubversion ) ;
71
84
72
85
// TODO[FPRI]: replace with `FromPrimitive`.
73
86
impl TryFrom < u8 > for FalconCoreRevSubversion {
@@ -102,6 +115,7 @@ pub(crate) enum FalconSecurityModel {
102
115
/// High-Secure: runs signed code with full privileges. Signature is validated by boot ROM.
103
116
Heavy = 3 ,
104
117
}
118
+ impl_from_enum_to_u32 ! ( FalconSecurityModel ) ;
105
119
106
120
// TODO[FPRI]: replace with `FromPrimitive`.
107
121
impl TryFrom < u8 > for FalconSecurityModel {
@@ -130,6 +144,7 @@ pub(crate) enum FalconModSelAlgo {
130
144
#[ default]
131
145
Rsa3k = 1 ,
132
146
}
147
+ impl_from_enum_to_u32 ! ( FalconModSelAlgo ) ;
133
148
134
149
// TODO[FPRI]: replace with `FromPrimitive`.
135
150
impl TryFrom < u8 > for FalconModSelAlgo {
@@ -151,6 +166,7 @@ pub(crate) enum DmaTrfCmdSize {
151
166
#[ default]
152
167
Size256B = 0x6 ,
153
168
}
169
+ impl_from_enum_to_u32 ! ( DmaTrfCmdSize ) ;
154
170
155
171
// TODO[FPRI]: replace with `FromPrimitive`.
156
172
impl TryFrom < u8 > for DmaTrfCmdSize {
@@ -173,6 +189,7 @@ pub(crate) enum PeregrineCoreSelect {
173
189
/// RISC-V core is active.
174
190
Riscv = 1 ,
175
191
}
192
+ impl_from_enum_to_u32 ! ( PeregrineCoreSelect ) ;
176
193
177
194
impl From < bool > for PeregrineCoreSelect {
178
195
fn from ( value : bool ) -> Self {
@@ -203,6 +220,7 @@ pub(crate) enum FalconFbifTarget {
203
220
/// Non-coherent system memory.
204
221
NoncoherentSysmem = 2 ,
205
222
}
223
+ impl_from_enum_to_u32 ! ( FalconFbifTarget ) ;
206
224
207
225
// TODO[FPRI]: replace with `FromPrimitive`.
208
226
impl TryFrom < u8 > for FalconFbifTarget {
@@ -229,6 +247,7 @@ pub(crate) enum FalconFbifMemType {
229
247
/// Physical memory addresses.
230
248
Physical = 1 ,
231
249
}
250
+ impl_from_enum_to_u32 ! ( FalconFbifMemType ) ;
232
251
233
252
/// Conversion from a single-bit register field.
234
253
impl From < bool > for FalconFbifMemType {
0 commit comments