Skip to content

remove multi-core handling for cortex-a-rt #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions cortex-a-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/versatileab/reference/hello-armv7a-none-eabi.out
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/versatileab/reference/hello-armv7r-none-eabi.out
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/versatileab/reference/svc-armv7a-none-eabi.out
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/versatileab/reference/svc-armv7r-none-eabi.out
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/versatileab/reference/svc-armv7r-none-eabihf.out
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions examples/versatileab/src/bin/abt-exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 7 additions & 1 deletion examples/versatileab/src/bin/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 7 additions & 1 deletion examples/versatileab/src/bin/prefetch-exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion examples/versatileab/src/bin/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
8 changes: 7 additions & 1 deletion examples/versatileab/src/bin/svc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 7 additions & 1 deletion examples/versatileab/src/bin/undef-exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
28 changes: 0 additions & 28 deletions examples/versatileab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down