From c88374eab18878019863cf0d560835fb28b4e018 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 20 May 2019 01:21:22 +0200 Subject: [PATCH] fix SP init --- src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5302a18..6cc161d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,15 +29,12 @@ pub unsafe extern "C" fn _boot_cores() -> ! { use cortex_a9::{asm, regs::*}; const CORE_MASK: u32 = 0x3; - // End of OCM RAM - const STACK_START: u32 = 256 << 10; + let stack_start = __end + 4096; match MPIDR.get() & CORE_MASK { 0 => { - SP.set(STACK_START); - zero_bss(&mut __bss_start, &mut __bss_end); - main(); - panic!("return from main"); + SP.set(stack_start); + boot_core0(); } _ => loop { // if not core0, infinitely wait for events @@ -46,6 +43,12 @@ pub unsafe extern "C" fn _boot_cores() -> ! { } } +unsafe fn boot_core0() -> ! { + zero_bss(&mut __bss_start, &mut __bss_end); + main(); + panic!("return from main"); +} + fn main() { let mut uart = Uart::uart0(); writeln!(uart, "Hello World\r").unwrap();