From 4455f740d2f8477ef94eff24cac2b68dd5fdfd57 Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 7 Mar 2024 12:47:16 +0800 Subject: [PATCH] main: set exception vector table addr linker: add exceptions start & end symbol --- src/libbuild_zynq/link.x | 2 ++ src/runtime/src/main.rs | 10 +++++++++- src/satman/src/main.rs | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/libbuild_zynq/link.x b/src/libbuild_zynq/link.x index 1f148a8..7687ea2 100644 --- a/src/libbuild_zynq/link.x +++ b/src/libbuild_zynq/link.x @@ -10,7 +10,9 @@ SECTIONS __text_start = .; .text : { + __exceptions_start = .; KEEP(*(.text.exceptions)); + __exceptions_end = .; *(.text.boot); *(.text .text.*); } > SDRAM diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index 50ffb03..e8b71a8 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -21,7 +21,7 @@ use libboard_artiq::{identifier_read, logger, pl}; use libboard_zynq::{gic, mpcore, timer::GlobalTimer}; use libconfig::Config; use libcortex_a9::l2c::enable_l2_cache; -use libsupport_zynq::ram; +use libsupport_zynq::{exception_vectors, ram}; use log::{info, warn}; mod analyzer; @@ -38,6 +38,11 @@ mod rtio_mgt; #[cfg(has_drtio)] mod subkernel; +// linker symbols +extern "C" { + static __exceptions_start: u32; +} + #[cfg(all(feature = "target_kasli_soc", has_drtio))] async fn io_expanders_service( i2c_bus: RefCell<&mut libboard_zynq::i2c::I2c>, @@ -77,6 +82,9 @@ static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17]; #[no_mangle] pub fn main_core0() { + unsafe { + exception_vectors::set_vector_table(&__exceptions_start as *const u32 as u32); + } enable_l2_cache(0x8); let mut timer = GlobalTimer::start(); diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index 5cded72..1ddea7b 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -38,7 +38,7 @@ use libboard_zynq::error_led::ErrorLED; use libboard_zynq::{i2c::I2c, print, println, time::Milliseconds, timer::GlobalTimer}; use libcortex_a9::{l2c::enable_l2_cache, regs::MPIDR}; use libregister::RegisterR; -use libsupport_zynq::ram; +use libsupport_zynq::{exception_vectors, ram}; use routing::Router; use subkernel::Manager as KernelManager; @@ -48,6 +48,11 @@ mod repeater; mod routing; mod subkernel; +// linker symbols +extern "C" { + static __exceptions_start: u32; +} + fn drtiosat_reset(reset: bool) { unsafe { csr::drtiosat::reset_write(if reset { 1 } else { 0 }); @@ -827,6 +832,9 @@ static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17]; #[no_mangle] pub extern "C" fn main_core0() -> i32 { + unsafe { + exception_vectors::set_vector_table(&__exceptions_start as *const u32 as u32); + } enable_l2_cache(0x8); let mut timer = GlobalTimer::start();