From 77f440db335ec19d948e1dfbe3c4b1b40d761df0 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 23 Jan 2020 22:34:37 +0100 Subject: [PATCH] libboard_zynq::stdio: add drop_uart() drops locks and causes reinitialization which is needed for exceptions and clock canges. --- libboard_zc706/src/abort.rs | 6 +++++- libboard_zynq/src/stdio.rs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libboard_zc706/src/abort.rs b/libboard_zc706/src/abort.rs index dd0250c..f3c16d0 100644 --- a/libboard_zc706/src/abort.rs +++ b/libboard_zc706/src/abort.rs @@ -1,13 +1,17 @@ -use libboard_zynq::println; +use libboard_zynq::{println, stdio}; #[no_mangle] pub unsafe extern "C" fn PrefetchAbort() { + stdio::drop_uart(); + println!("PrefetchAbort"); loop {} } #[no_mangle] pub unsafe extern "C" fn DataAbort() { + stdio::drop_uart(); + println!("DataAbort"); loop {} } diff --git a/libboard_zynq/src/stdio.rs b/libboard_zynq/src/stdio.rs index d4db7db..4fb9d6a 100644 --- a/libboard_zynq/src/stdio.rs +++ b/libboard_zynq/src/stdio.rs @@ -10,6 +10,10 @@ pub fn get_uart<'a>() -> MutexGuard<'a, LazyUart> { unsafe { UART.lock() } } +pub fn drop_uart() { + unsafe { UART = Mutex::new(LazyUart::Uninitialized); } +} + /// Initializes the UART on first use through `.deref_mut()` for debug /// output through the `print!` and `println!` macros. pub enum LazyUart {