diff --git a/cortex-a-rt/src/lib.rs b/cortex-a-rt/src/lib.rs index 4a6cc09..a425435 100644 --- a/cortex-a-rt/src/lib.rs +++ b/cortex-a-rt/src/lib.rs @@ -5,6 +5,13 @@ //! Usually, most Cortex-A based systems will require chip specific start-up code, so the //! start-up method can over overriden. //! +//! The default startup routine provided by this crate does not include any special handling +//! for multi-core support because this is oftentimes implementation defined and the exact +//! handling depends on the specific chip in use. Many implementations only +//! run the startup routine with one core and will keep other cores in reset until they are woken +//! up by an implementation specific mechanism. For other implementations where multi-core +//! specific startup adaptions are necessary, the startup routine can be overwritten by the user. +//! //! ## Features //! //! - `vfp-dp`: Enables support for the double-precision VFP floating point support. If your target @@ -44,14 +51,13 @@ //! //! ### Functions //! -//! * `boot_core` - the `extern "C"` entry point to your application. The CPU ID -//! will be passed as the first argument to this function. +//! * `kmain` - the `extern "C"` entry point to your application. //! //! Expected prototype: //! //! ```rust //! #[unsafe(no_mangle)] -//! extern "C" fn boot_core(cpu_id: u32) -> !; +//! extern "C" fn kmain() -> !; //! ``` //! //! * `_svc_handler` - an `extern "C"` function to call when an SVC Exception @@ -141,7 +147,7 @@ //! //! * `_vector_table` - the start of the interrupt vector table //! * `_default_start` - the default Reset handler, that sets up some stacks and -//! calls an `extern "C"` function called `boot_core`. +//! calls an `extern "C"` function called `kmain`. //! * `_asm_default_fiq_handler` - an FIQ handler that just spins //! * `_asm_default_handler` - an exception handler that just spins //! * `_asm_svc_handler` - assembly language trampoline for SVC Exceptions that @@ -543,7 +549,7 @@ macro_rules! fpu_enable { // Default start-up code for Armv7-A // -// We set up our stacks and `boot_core` in system mode. +// We set up our stacks and `kmain` in system mode. core::arch::global_asm!( r#" .section .text.startup @@ -552,25 +558,6 @@ core::arch::global_asm!( .global _default_start .type _default_start, %function _default_start: - - // only allow cpu0 through for initialization - // Read MPIDR - mrc p15,0,r1,c0,c0,5 - // Extract CPU ID bits. For single-core systems, this should always be 0 - and r1, r1, #0x3 - cmp r1, #0 - beq initialize - wait_loop: - wfe - // When Core 0 emits a SEV, the other cores will wake up. - // Load CPU ID, we are CPU0 - mrc p15,0,r0,c0,c0,5 - // Extract CPU ID bits. - and r0, r0, #0x3 - bl boot_core - // Should never returns, loop permanently here. - b . - initialize: // Set up stacks. ldr r0, =_stack_top // Set stack pointer (right after) and mask interrupts for for UND mode (Mode 0x1B) @@ -631,9 +618,7 @@ core::arch::global_asm!( b 0b 1: // Jump to application - // Load CPU ID, we are CPU0 - ldr r0, =0x0 - bl boot_core + bl kmain // In case the application returns, loop forever b . .size _default_start, . - _default_start diff --git a/examples/versatileab/reference/hello-armv7a-none-eabi.out b/examples/versatileab/reference/hello-armv7a-none-eabi.out index 04a1a27..fdb05bb 100644 --- a/examples/versatileab/reference/hello-armv7a-none-eabi.out +++ b/examples/versatileab/reference/hello-armv7a-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 19, + line: 25, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7r-none-eabi.out b/examples/versatileab/reference/hello-armv7r-none-eabi.out index 04a1a27..fdb05bb 100644 --- a/examples/versatileab/reference/hello-armv7r-none-eabi.out +++ b/examples/versatileab/reference/hello-armv7r-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 19, + line: 25, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7r-none-eabihf.out b/examples/versatileab/reference/hello-armv7r-none-eabihf.out index 04a1a27..fdb05bb 100644 --- a/examples/versatileab/reference/hello-armv7r-none-eabihf.out +++ b/examples/versatileab/reference/hello-armv7r-none-eabihf.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 19, + line: 25, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/svc-armv7a-none-eabi.out b/examples/versatileab/reference/svc-armv7a-none-eabi.out index b6eabfe..79353f6 100644 --- a/examples/versatileab/reference/svc-armv7a-none-eabi.out +++ b/examples/versatileab/reference/svc-armv7a-none-eabi.out @@ -6,7 +6,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/svc.rs", - line: 22, + line: 28, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/svc-armv7r-none-eabi.out b/examples/versatileab/reference/svc-armv7r-none-eabi.out index b6eabfe..79353f6 100644 --- a/examples/versatileab/reference/svc-armv7r-none-eabi.out +++ b/examples/versatileab/reference/svc-armv7r-none-eabi.out @@ -6,7 +6,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/svc.rs", - line: 22, + line: 28, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/svc-armv7r-none-eabihf.out b/examples/versatileab/reference/svc-armv7r-none-eabihf.out index b6eabfe..79353f6 100644 --- a/examples/versatileab/reference/svc-armv7r-none-eabihf.out +++ b/examples/versatileab/reference/svc-armv7r-none-eabihf.out @@ -6,7 +6,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/svc.rs", - line: 22, + line: 28, col: 5, }, can_unwind: true, diff --git a/examples/versatileab/src/bin/abt-exception.rs b/examples/versatileab/src/bin/abt-exception.rs index 864bcd5..d8427bc 100644 --- a/examples/versatileab/src/bin/abt-exception.rs +++ b/examples/versatileab/src/bin/abt-exception.rs @@ -11,10 +11,16 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); - static COUNTER: AtomicU32 = AtomicU32::new(0); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} + /// The main function of our Rust application. #[export_name = "main"] #[allow(unreachable_code)] diff --git a/examples/versatileab/src/bin/hello.rs b/examples/versatileab/src/bin/hello.rs index aade0db..074cdc0 100644 --- a/examples/versatileab/src/bin/hello.rs +++ b/examples/versatileab/src/bin/hello.rs @@ -8,7 +8,13 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} /// The main function of our Rust application. #[export_name = "main"] diff --git a/examples/versatileab/src/bin/prefetch-exception.rs b/examples/versatileab/src/bin/prefetch-exception.rs index 9b1866f..091a75f 100644 --- a/examples/versatileab/src/bin/prefetch-exception.rs +++ b/examples/versatileab/src/bin/prefetch-exception.rs @@ -11,7 +11,13 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} static COUNTER: AtomicU32 = AtomicU32::new(0); diff --git a/examples/versatileab/src/bin/registers.rs b/examples/versatileab/src/bin/registers.rs index 0e0db57..f897bb4 100644 --- a/examples/versatileab/src/bin/registers.rs +++ b/examples/versatileab/src/bin/registers.rs @@ -8,7 +8,13 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} /// The entry-point to the Rust application. /// diff --git a/examples/versatileab/src/bin/svc.rs b/examples/versatileab/src/bin/svc.rs index 54c9dc1..83b33da 100644 --- a/examples/versatileab/src/bin/svc.rs +++ b/examples/versatileab/src/bin/svc.rs @@ -8,7 +8,13 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} /// The main function of our Rust application. #[export_name = "main"] diff --git a/examples/versatileab/src/bin/undef-exception.rs b/examples/versatileab/src/bin/undef-exception.rs index b98eca8..a87b73f 100644 --- a/examples/versatileab/src/bin/undef-exception.rs +++ b/examples/versatileab/src/bin/undef-exception.rs @@ -10,7 +10,13 @@ use versatileab as _; use semihosting::println; -versatileab::entry_point!(); +/// The entry-point to the Rust application. +/// +/// It is called by the start-up. +#[no_mangle] +pub extern "C" fn kmain() -> ! { + main(); +} static COUNTER: AtomicU32 = AtomicU32::new(0); diff --git a/examples/versatileab/src/lib.rs b/examples/versatileab/src/lib.rs index 0ecabf0..d931296 100644 --- a/examples/versatileab/src/lib.rs +++ b/examples/versatileab/src/lib.rs @@ -11,34 +11,6 @@ use cortex_r_rt as _; #[cfg(arm_architecture = "v8-r")] compile_error!("This example/board is not compatible with the ARMv8-R architecture"); -#[macro_export] -macro_rules! entry_point { - () => { - /// The entry-point to the Rust application. - /// - /// It is called by the start-up code in `cortex-m-rt`. - #[no_mangle] - #[cfg(arm_profile = "r")] - pub extern "C" fn kmain() { - main(); - } - - /// The entry-point to the Rust application. - /// - /// It is called by the start-up code in `cortex-a-rt`. - #[no_mangle] - #[cfg(arm_profile = "a")] - pub extern "C" fn boot_core(cpu_id: u32) { - match cpu_id { - 0 => { - main(); - } - _ => panic!("unexpected CPU ID {}", cpu_id), - } - } - }; -} - /// Called when the application raises an unrecoverable `panic!`. /// /// Prints the panic to the console and then exits QEMU using a semihosting