add static exception handling

This commit is contained in:
Astro 2019-05-30 20:30:19 +02:00
parent b13bf72c17
commit 2df74cc055
4 changed files with 38 additions and 1 deletions

14
link.x
View File

@ -1,6 +1,14 @@
ENTRY(_boot_cores);
STACK_SIZE = 0x2000 - 0x10;
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);
MEMORY
{
@ -10,9 +18,13 @@ MEMORY
SECTIONS
{
.exceptions :
{
. = 0x0;
KEEP(*(.text.exceptions));
} > OCM
.text :
{
/* Starts at LOADER_ADDR. */
. = 0x8000;
KEEP(*(.text.boot))
*(.text .text.*)

View File

@ -0,0 +1,12 @@
.section ".text.exceptions"
.global exception_vector
exception_vector:
b Reset
b UndefinedInstruction
b SoftwareInterrupt
b PrefetchAbort
b DataAbort
b ReservedException
b IRQ
b FIQ

View File

@ -1,2 +1,4 @@
pub mod asm;
pub mod regs;
global_asm!(include_str!("exceptions.s"));

View File

@ -1,6 +1,7 @@
#![no_std]
#![no_main]
#![feature(asm)]
#![feature(global_asm)]
#![feature(naked_functions)]
use core::fmt::Write;
@ -94,3 +95,13 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
slcr::RegisterBlock::unlocked(|slcr| slcr.soft_reset());
unreachable!()
}
#[no_mangle]
pub unsafe extern "C" fn PrefetchAbort() {
panic!("PrefetchAbort");
}
#[no_mangle]
pub unsafe extern "C" fn DataAbort() {
panic!("DataAbort");
}