From e430600683edc118c7deb3345086b74405ec55d1 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 6 Jul 2020 21:02:46 +0800 Subject: [PATCH] fix exception vectors --- experiments/link.x | 12 +------- libsupport_zynq/src/abort.rs | 55 +++++++++++++++++++++++++++++++++--- libsupport_zynq/src/boot.rs | 2 +- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/experiments/link.x b/experiments/link.x index 3ca3abe..f6471cc 100644 --- a/experiments/link.x +++ b/experiments/link.x @@ -1,14 +1,4 @@ -ENTRY(_boot_cores); - -/* Provide some defaults */ -PROVIDE(Reset = _boot_cores); -PROVIDE(UndefinedInstruction = Reset); -PROVIDE(SoftwareInterrupt = Reset); -PROVIDE(PrefetchAbort = Reset); -PROVIDE(DataAbort = Reset); -PROVIDE(ReservedException = Reset); -PROVIDE(IRQ = Reset); -PROVIDE(FIQ = Reset); +ENTRY(Reset); MEMORY { diff --git a/libsupport_zynq/src/abort.rs b/libsupport_zynq/src/abort.rs index 4d7f7f2..247fbe1 100644 --- a/libsupport_zynq/src/abort.rs +++ b/libsupport_zynq/src/abort.rs @@ -2,16 +2,36 @@ use libregister::RegisterR; use libcortex_a9::regs::{DFSR, MPIDR}; use libboard_zynq::{println, slcr, stdio}; +#[link_section = ".text.boot"] #[no_mangle] -pub unsafe extern "C" fn PrefetchAbort() { +#[naked] +pub unsafe extern "C" fn UndefinedInstruction() { stdio::drop_uart(); - - println!("PrefetchAbort"); - + println!("UndefinedInstruction"); loop {} } +#[link_section = ".text.boot"] #[no_mangle] +#[naked] +pub unsafe extern "C" fn SoftwareInterrupt() { + stdio::drop_uart(); + println!("SoftwareInterrupt"); + loop {} +} + +#[link_section = ".text.boot"] +#[no_mangle] +#[naked] +pub unsafe extern "C" fn PrefetchAbort() { + stdio::drop_uart(); + println!("PrefetchAbort"); + loop {} +} + +#[link_section = ".text.boot"] +#[no_mangle] +#[naked] pub unsafe extern "C" fn DataAbort() { stdio::drop_uart(); @@ -21,3 +41,30 @@ pub unsafe extern "C" fn DataAbort() { loop {} } + +#[link_section = ".text.boot"] +#[no_mangle] +#[naked] +pub unsafe extern "C" fn ReservedException() { + stdio::drop_uart(); + println!("ReservedException"); + loop {} +} + +#[link_section = ".text.boot"] +#[no_mangle] +#[naked] +pub unsafe extern "C" fn IRQ() { + stdio::drop_uart(); + println!("IRQ"); + loop {} +} + +#[link_section = ".text.boot"] +#[no_mangle] +#[naked] +pub unsafe extern "C" fn FIQ() { + stdio::drop_uart(); + println!("FIQ"); + loop {} +} diff --git a/libsupport_zynq/src/boot.rs b/libsupport_zynq/src/boot.rs index 045ac49..70a47a5 100644 --- a/libsupport_zynq/src/boot.rs +++ b/libsupport_zynq/src/boot.rs @@ -21,7 +21,7 @@ static mut CORE1_ENABLED: VolatileCell = VolatileCell::new(false); #[link_section = ".text.boot"] #[no_mangle] #[naked] -pub unsafe extern "C" fn _boot_cores() -> ! { +pub unsafe extern "C" fn Reset() -> ! { const CORE_MASK: u32 = 0x3; match MPIDR.read() & CORE_MASK {