Skip to content

Commit ac3aa53

Browse files
Merge pull request #22 from us-irs/remove-multicore-handling
remove multi-core handling for cortex-a-rt
2 parents 6a4f2e3 + d5a8789 commit ac3aa53

14 files changed

+61
-68
lines changed

cortex-a-rt/src/lib.rs

+12-27
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
//! Usually, most Cortex-A based systems will require chip specific start-up code, so the
66
//! start-up method can over overriden.
77
//!
8+
//! The default startup routine provided by this crate does not include any special handling
9+
//! for multi-core support because this is oftentimes implementation defined and the exact
10+
//! handling depends on the specific chip in use. Many implementations only
11+
//! run the startup routine with one core and will keep other cores in reset until they are woken
12+
//! up by an implementation specific mechanism. For other implementations where multi-core
13+
//! specific startup adaptions are necessary, the startup routine can be overwritten by the user.
14+
//!
815
//! ## Features
916
//!
1017
//! - `vfp-dp`: Enables support for the double-precision VFP floating point support. If your target
@@ -44,14 +51,13 @@
4451
//!
4552
//! ### Functions
4653
//!
47-
//! * `boot_core` - the `extern "C"` entry point to your application. The CPU ID
48-
//! will be passed as the first argument to this function.
54+
//! * `kmain` - the `extern "C"` entry point to your application.
4955
//!
5056
//! Expected prototype:
5157
//!
5258
//! ```rust
5359
//! #[unsafe(no_mangle)]
54-
//! extern "C" fn boot_core(cpu_id: u32) -> !;
60+
//! extern "C" fn kmain() -> !;
5561
//! ```
5662
//!
5763
//! * `_svc_handler` - an `extern "C"` function to call when an SVC Exception
@@ -141,7 +147,7 @@
141147
//!
142148
//! * `_vector_table` - the start of the interrupt vector table
143149
//! * `_default_start` - the default Reset handler, that sets up some stacks and
144-
//! calls an `extern "C"` function called `boot_core`.
150+
//! calls an `extern "C"` function called `kmain`.
145151
//! * `_asm_default_fiq_handler` - an FIQ handler that just spins
146152
//! * `_asm_default_handler` - an exception handler that just spins
147153
//! * `_asm_svc_handler` - assembly language trampoline for SVC Exceptions that
@@ -543,7 +549,7 @@ macro_rules! fpu_enable {
543549

544550
// Default start-up code for Armv7-A
545551
//
546-
// We set up our stacks and `boot_core` in system mode.
552+
// We set up our stacks and `kmain` in system mode.
547553
core::arch::global_asm!(
548554
r#"
549555
.section .text.startup
@@ -552,25 +558,6 @@ core::arch::global_asm!(
552558
.global _default_start
553559
.type _default_start, %function
554560
_default_start:
555-
556-
// only allow cpu0 through for initialization
557-
// Read MPIDR
558-
mrc p15,0,r1,c0,c0,5
559-
// Extract CPU ID bits. For single-core systems, this should always be 0
560-
and r1, r1, #0x3
561-
cmp r1, #0
562-
beq initialize
563-
wait_loop:
564-
wfe
565-
// When Core 0 emits a SEV, the other cores will wake up.
566-
// Load CPU ID, we are CPU0
567-
mrc p15,0,r0,c0,c0,5
568-
// Extract CPU ID bits.
569-
and r0, r0, #0x3
570-
bl boot_core
571-
// Should never returns, loop permanently here.
572-
b .
573-
initialize:
574561
// Set up stacks.
575562
ldr r0, =_stack_top
576563
// Set stack pointer (right after) and mask interrupts for for UND mode (Mode 0x1B)
@@ -631,9 +618,7 @@ core::arch::global_asm!(
631618
b 0b
632619
1:
633620
// Jump to application
634-
// Load CPU ID, we are CPU0
635-
ldr r0, =0x0
636-
bl boot_core
621+
bl kmain
637622
// In case the application returns, loop forever
638623
b .
639624
.size _default_start, . - _default_start

examples/versatileab/reference/hello-armv7a-none-eabi.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PANIC: PanicInfo {
33
message: I am an example panic,
44
location: Location {
55
file: "src/bin/hello.rs",
6-
line: 19,
6+
line: 25,
77
col: 5,
88
},
99
can_unwind: true,

examples/versatileab/reference/hello-armv7r-none-eabi.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PANIC: PanicInfo {
33
message: I am an example panic,
44
location: Location {
55
file: "src/bin/hello.rs",
6-
line: 19,
6+
line: 25,
77
col: 5,
88
},
99
can_unwind: true,

examples/versatileab/reference/hello-armv7r-none-eabihf.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PANIC: PanicInfo {
33
message: I am an example panic,
44
location: Location {
55
file: "src/bin/hello.rs",
6-
line: 19,
6+
line: 25,
77
col: 5,
88
},
99
can_unwind: true,

examples/versatileab/reference/svc-armv7a-none-eabi.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PANIC: PanicInfo {
66
message: I am an example panic,
77
location: Location {
88
file: "src/bin/svc.rs",
9-
line: 22,
9+
line: 28,
1010
col: 5,
1111
},
1212
can_unwind: true,

examples/versatileab/reference/svc-armv7r-none-eabi.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PANIC: PanicInfo {
66
message: I am an example panic,
77
location: Location {
88
file: "src/bin/svc.rs",
9-
line: 22,
9+
line: 28,
1010
col: 5,
1111
},
1212
can_unwind: true,

examples/versatileab/reference/svc-armv7r-none-eabihf.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PANIC: PanicInfo {
66
message: I am an example panic,
77
location: Location {
88
file: "src/bin/svc.rs",
9-
line: 22,
9+
line: 28,
1010
col: 5,
1111
},
1212
can_unwind: true,

examples/versatileab/src/bin/abt-exception.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ use versatileab as _;
1111

1212
use semihosting::println;
1313

14-
versatileab::entry_point!();
15-
1614
static COUNTER: AtomicU32 = AtomicU32::new(0);
1715

16+
/// The entry-point to the Rust application.
17+
///
18+
/// It is called by the start-up.
19+
#[no_mangle]
20+
pub extern "C" fn kmain() -> ! {
21+
main();
22+
}
23+
1824
/// The main function of our Rust application.
1925
#[export_name = "main"]
2026
#[allow(unreachable_code)]

examples/versatileab/src/bin/hello.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ use versatileab as _;
88

99
use semihosting::println;
1010

11-
versatileab::entry_point!();
11+
/// The entry-point to the Rust application.
12+
///
13+
/// It is called by the start-up.
14+
#[no_mangle]
15+
pub extern "C" fn kmain() -> ! {
16+
main();
17+
}
1218

1319
/// The main function of our Rust application.
1420
#[export_name = "main"]

examples/versatileab/src/bin/prefetch-exception.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ use versatileab as _;
1111

1212
use semihosting::println;
1313

14-
versatileab::entry_point!();
14+
/// The entry-point to the Rust application.
15+
///
16+
/// It is called by the start-up.
17+
#[no_mangle]
18+
pub extern "C" fn kmain() -> ! {
19+
main();
20+
}
1521

1622
static COUNTER: AtomicU32 = AtomicU32::new(0);
1723

examples/versatileab/src/bin/registers.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ use versatileab as _;
88

99
use semihosting::println;
1010

11-
versatileab::entry_point!();
11+
/// The entry-point to the Rust application.
12+
///
13+
/// It is called by the start-up.
14+
#[no_mangle]
15+
pub extern "C" fn kmain() -> ! {
16+
main();
17+
}
1218

1319
/// The entry-point to the Rust application.
1420
///

examples/versatileab/src/bin/svc.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ use versatileab as _;
88

99
use semihosting::println;
1010

11-
versatileab::entry_point!();
11+
/// The entry-point to the Rust application.
12+
///
13+
/// It is called by the start-up.
14+
#[no_mangle]
15+
pub extern "C" fn kmain() -> ! {
16+
main();
17+
}
1218

1319
/// The main function of our Rust application.
1420
#[export_name = "main"]

examples/versatileab/src/bin/undef-exception.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ use versatileab as _;
1010

1111
use semihosting::println;
1212

13-
versatileab::entry_point!();
13+
/// The entry-point to the Rust application.
14+
///
15+
/// It is called by the start-up.
16+
#[no_mangle]
17+
pub extern "C" fn kmain() -> ! {
18+
main();
19+
}
1420

1521
static COUNTER: AtomicU32 = AtomicU32::new(0);
1622

examples/versatileab/src/lib.rs

-28
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,6 @@ use cortex_r_rt as _;
1111
#[cfg(arm_architecture = "v8-r")]
1212
compile_error!("This example/board is not compatible with the ARMv8-R architecture");
1313

14-
#[macro_export]
15-
macro_rules! entry_point {
16-
() => {
17-
/// The entry-point to the Rust application.
18-
///
19-
/// It is called by the start-up code in `cortex-m-rt`.
20-
#[no_mangle]
21-
#[cfg(arm_profile = "r")]
22-
pub extern "C" fn kmain() {
23-
main();
24-
}
25-
26-
/// The entry-point to the Rust application.
27-
///
28-
/// It is called by the start-up code in `cortex-a-rt`.
29-
#[no_mangle]
30-
#[cfg(arm_profile = "a")]
31-
pub extern "C" fn boot_core(cpu_id: u32) {
32-
match cpu_id {
33-
0 => {
34-
main();
35-
}
36-
_ => panic!("unexpected CPU ID {}", cpu_id),
37-
}
38-
}
39-
};
40-
}
41-
4214
/// Called when the application raises an unrecoverable `panic!`.
4315
///
4416
/// Prints the panic to the console and then exits QEMU using a semihosting

0 commit comments

Comments
 (0)