Skip to content

Commit 7d892c7

Browse files
committed
code review updates
1 parent c595b5e commit 7d892c7

File tree

4 files changed

+30
-75
lines changed

4 files changed

+30
-75
lines changed

cortex-a-rt/src/lib.rs

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
//! `_asm_default_fiq_handler` but you can override it.
124124
//! * `_asm_undefined_handler` - a naked function to call when an Undefined
125125
//! Exception occurs. Our linker script PROVIDEs a default function at
126-
//! `_asm_defeault_undefined_handler` but you can override it.
126+
//! `_asm_default_undefined_handler` but you can override it.
127127
//! * `_asm_prefetch_handler` - a naked function to call when an Prefetch
128128
//! Exception occurs. Our linker script PROVIDEs a default function at
129129
//! `_asm_default_prefetch_handler` but you can override it. The provided default
@@ -224,12 +224,13 @@ core::arch::global_asm!(
224224
);
225225

226226
/// This macro expands to code for saving context on entry to an exception
227-
/// handler, ignoring FPU registers.
227+
/// handler.
228228
///
229229
/// It should match `restore_context!`.
230230
///
231231
/// On entry to this block, we assume that we are in exception context.
232-
macro_rules! save_context_ignore_fpu {
232+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
233+
macro_rules! save_context {
233234
() => {
234235
r#"
235236
// save preserved registers (and gives us some working area)
@@ -245,10 +246,11 @@ macro_rules! save_context_ignore_fpu {
245246
}
246247

247248
/// This macro expands to code for restoring context on exit from an exception
248-
/// handler, ignoring FPU registers.
249+
/// handler.
249250
///
250251
/// It should match `save_context!`.
251-
macro_rules! restore_context_ignore_fpu {
252+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
253+
macro_rules! restore_context {
252254
() => {
253255
r#"
254256
// restore alignment amount, and preserved register
@@ -261,30 +263,6 @@ macro_rules! restore_context_ignore_fpu {
261263
};
262264
}
263265

264-
/// This macro expands to code for saving context on entry to an exception
265-
/// handler.
266-
///
267-
/// It should match `restore_context!`.
268-
///
269-
/// On entry to this block, we assume that we are in exception context.
270-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
271-
macro_rules! save_context {
272-
() => {
273-
save_context_ignore_fpu!()
274-
};
275-
}
276-
277-
/// This macro expands to code for restoring context on exit from an exception
278-
/// handler.
279-
///
280-
/// It should match `save_context!`.
281-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
282-
macro_rules! restore_context {
283-
() => {
284-
restore_context_ignore_fpu!()
285-
};
286-
}
287-
288266
/// This macro expands to code for saving context on entry to an exception
289267
/// handler.
290268
///
@@ -463,14 +441,14 @@ done:
463441
// state save from compiled code
464442
srsfd sp!, {und_mode}
465443
"#,
466-
save_context_ignore_fpu!(),
444+
save_context!(),
467445
r#"
468446
// Pass the faulting instruction address to the handler.
469447
mov r0, lr
470448
// call C handler
471449
bl _undefined_handler
472450
"#,
473-
restore_context_ignore_fpu!(),
451+
restore_context!(),
474452
r#"
475453
// Return to the failing instruction which is the recommended approach by ARM.
476454
rfefd sp!
@@ -488,14 +466,14 @@ done:
488466
// state save from compiled code
489467
srsfd sp!, {abt_mode}
490468
"#,
491-
save_context_ignore_fpu!(),
469+
save_context!(),
492470
r#"
493471
// Pass the faulting instruction address to the handler.
494472
mov r0, lr
495473
// call C handler
496474
bl _prefetch_handler
497475
"#,
498-
restore_context_ignore_fpu!(),
476+
restore_context!(),
499477
r#"
500478
// Return to the failing instruction which is the recommended approach by ARM.
501479
rfefd sp!
@@ -513,14 +491,14 @@ done:
513491
// state save from compiled code
514492
srsfd sp!, {abt_mode}
515493
"#,
516-
save_context_ignore_fpu!(),
494+
save_context!(),
517495
r#"
518496
// Pass the faulting instruction address to the handler.
519497
mov r0, lr
520498
// call C handler
521499
bl _abort_handler
522500
"#,
523-
restore_context_ignore_fpu!(),
501+
restore_context!(),
524502
r#"
525503
// Return to the failing instruction which is the recommended approach by ARM.
526504
rfefd sp!

cortex-r-rt/src/lib.rs

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
//!
3535
//! ### Functions
3636
//!
37-
//! * `boot_core` - the `extern "C"` entry point to your application. The CPU ID
38-
//! will be passed as the first argument to this function.
37+
//! * `kmain` - the `extern "C"` entry point to your application.
3938
//!
4039
//! Expected prototype:
4140
//!
4241
//! ```rust
4342
//! #[unsafe(no_mangle)]
44-
//! extern "C" fn boot_core(cpu_id: u32) -> !;
43+
//! extern "C" fn kmain() -> !;
4544
//! ```
4645
//!
4746
//! * `_svc_handler` - an `extern "C"` function to call when an SVC Exception
@@ -113,7 +112,7 @@
113112
//! `_asm_default_fiq_handler` but you can override it.
114113
//! * `_asm_undefined_handler` - a naked function to call when an Undefined
115114
//! Exception occurs. Our linker script PROVIDEs a default function at
116-
//! `_asm_defeault_undefined_handler` but you can override it.
115+
//! `_asm_default_undefined_handler` but you can override it.
117116
//! * `_asm_prefetch_handler` - a naked function to call when an Prefetch
118117
//! Exception occurs. Our linker script PROVIDEs a default function at
119118
//! `_asm_default_prefetch_handler` but you can override it. The provided default
@@ -217,12 +216,13 @@ core::arch::global_asm!(
217216
);
218217

219218
/// This macro expands to code for saving context on entry to an exception
220-
/// handler, ignoring FPU registers.
219+
/// handler.
221220
///
222221
/// It should match `restore_context!`.
223222
///
224223
/// On entry to this block, we assume that we are in exception context.
225-
macro_rules! save_context_ignore_fpu {
224+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
225+
macro_rules! save_context {
226226
() => {
227227
r#"
228228
// save preserved registers (and gives us some working area)
@@ -238,10 +238,11 @@ macro_rules! save_context_ignore_fpu {
238238
}
239239

240240
/// This macro expands to code for restoring context on exit from an exception
241-
/// handler, ignoring FPU registers.
241+
/// handler.
242242
///
243243
/// It should match `save_context!`.
244-
macro_rules! restore_context_ignore_fpu {
244+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
245+
macro_rules! restore_context {
245246
() => {
246247
r#"
247248
// restore alignment amount, and preserved register
@@ -254,30 +255,6 @@ macro_rules! restore_context_ignore_fpu {
254255
};
255256
}
256257

257-
/// This macro expands to code for saving context on entry to an exception
258-
/// handler.
259-
///
260-
/// It should match `restore_context!`.
261-
///
262-
/// On entry to this block, we assume that we are in exception context.
263-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
264-
macro_rules! save_context {
265-
() => {
266-
save_context_ignore_fpu!()
267-
};
268-
}
269-
270-
/// This macro expands to code for restoring context on exit from an exception
271-
/// handler.
272-
///
273-
/// It should match `save_context!`.
274-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
275-
macro_rules! restore_context {
276-
() => {
277-
restore_context_ignore_fpu!()
278-
};
279-
}
280-
281258
/// This macro expands to code for saving context on entry to an exception
282259
/// handler.
283260
///
@@ -401,14 +378,14 @@ done:
401378
// state save from compiled code
402379
srsfd sp!, {und_mode}
403380
"#,
404-
save_context_ignore_fpu!(),
381+
save_context!(),
405382
r#"
406383
// Pass the faulting instruction address to the handler.
407384
mov r0, lr
408385
// call C handler
409386
bl _undefined_handler
410387
"#,
411-
restore_context_ignore_fpu!(),
388+
restore_context!(),
412389
r#"
413390
// Return to the failing instruction which is the recommended approach by ARM.
414391
rfefd sp!
@@ -426,14 +403,14 @@ done:
426403
// state save from compiled code
427404
srsfd sp!, {abt_mode}
428405
"#,
429-
save_context_ignore_fpu!(),
406+
save_context!(),
430407
r#"
431408
// Pass the faulting instruction address to the handler.
432409
mov r0, lr
433410
// call C handler
434411
bl _prefetch_handler
435412
"#,
436-
restore_context_ignore_fpu!(),
413+
restore_context!(),
437414
r#"
438415
// Return to the failing instruction which is the recommended approach by ARM.
439416
rfefd sp!
@@ -451,14 +428,14 @@ done:
451428
// state save from compiled code
452429
srsfd sp!, {abt_mode}
453430
"#,
454-
save_context_ignore_fpu!(),
431+
save_context!(),
455432
r#"
456433
// Pass the faulting instruction address to the handler.
457434
mov r0, lr
458435
// call C handler
459436
bl _abort_handler
460437
"#,
461-
restore_context_ignore_fpu!(),
438+
restore_context!(),
462439
r#"
463440
// Return to the failing instruction which is the recommended approach by ARM.
464441
rfefd sp!

examples/mps3-an536/src/bin/svc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn main() -> ! {
3030
}
3131

3232
/// This is our SVC exception handler
33-
#[unsafe(no_mangle)]
33+
#[no_mangle]
3434
unsafe extern "C" fn _svc_handler(arg: u32) {
3535
println!("In _svc_handler, with arg={:#06x}", arg);
3636
if arg == 0xABCDEF {

examples/versatileab/src/bin/svc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() -> ! {
2323
}
2424

2525
/// This is our SVC exception handler
26-
#[unsafe(no_mangle)]
26+
#[no_mangle]
2727
unsafe extern "C" fn _svc_handler(arg: u32) {
2828
println!("In _svc_handler, with arg={:#06x}", arg);
2929
if arg == 0xABCDEF {

0 commit comments

Comments
 (0)