libboard_zynq::stdio: add drop_uart()

drops locks and causes reinitialization which is needed for exceptions
and clock canges.
This commit is contained in:
Astro 2020-01-23 22:34:37 +01:00
parent 99a2e5d621
commit 77f440db33
2 changed files with 9 additions and 1 deletions

View File

@ -1,13 +1,17 @@
use libboard_zynq::println; use libboard_zynq::{println, stdio};
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn PrefetchAbort() { pub unsafe extern "C" fn PrefetchAbort() {
stdio::drop_uart();
println!("PrefetchAbort"); println!("PrefetchAbort");
loop {} loop {}
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn DataAbort() { pub unsafe extern "C" fn DataAbort() {
stdio::drop_uart();
println!("DataAbort"); println!("DataAbort");
loop {} loop {}
} }

View File

@ -10,6 +10,10 @@ pub fn get_uart<'a>() -> MutexGuard<'a, LazyUart> {
unsafe { UART.lock() } unsafe { UART.lock() }
} }
pub fn drop_uart() {
unsafe { UART = Mutex::new(LazyUart::Uninitialized); }
}
/// Initializes the UART on first use through `.deref_mut()` for debug /// Initializes the UART on first use through `.deref_mut()` for debug
/// output through the `print!` and `println!` macros. /// output through the `print!` and `println!` macros.
pub enum LazyUart { pub enum LazyUart {