This repository was archived by the owner on Jan 24, 2022. It is now read-only.
File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -189,21 +189,34 @@ unsafe extern "C" fn reset_handler() -> ! {
189
189
r0:: init_data ( & mut _sdata, & mut _edata, & _sidata) ;
190
190
191
191
match ( ) {
192
+ #[ cfg( not( has_fpu) ) ]
193
+ ( ) => {
194
+ // Neither `argc` or `argv` make sense in bare metal context so we just
195
+ // stub them
196
+ main ( 0 , :: core:: ptr:: null ( ) ) ;
197
+ }
192
198
#[ cfg( has_fpu) ]
193
199
( ) => {
194
200
// NOTE(safe) no exception / interrupt that also accesses the FPU
195
201
// can occur here
196
202
let scb = & * cortex_m:: peripheral:: SCB . get ( ) ;
197
203
scb. enable_fpu ( ) ;
204
+
205
+ // Make sure the user main function never gets inlined into this
206
+ // function as that may cause FPU related instructions like vpush to
207
+ // be executed *before* enabling the FPU and that would generate an
208
+ // exception
209
+ #[ inline( never) ]
210
+ fn main ( ) {
211
+ unsafe {
212
+ :: main ( 0 , :: core:: ptr:: null ( ) ) ;
213
+ }
214
+ }
215
+
216
+ main ( )
198
217
}
199
- #[ cfg( not( has_fpu) ) ]
200
- ( ) => { }
201
218
}
202
219
203
- // Neither `argc` or `argv` make sense in bare metal context so we just
204
- // stub them
205
- main ( 0 , :: core:: ptr:: null ( ) ) ;
206
-
207
220
// If `main` returns, then we go into "reactive" mode and simply attend
208
221
// interrupts as they occur.
209
222
loop {
You can’t perform that action at this time.
0 commit comments