From b78a71c495a2429175a463babfa0789ee8b3a620 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 30 Aug 2020 00:34:10 +0800 Subject: [PATCH] kernel: print-panics: implement this feature in debug.rs With this feature enabled, claim the kernel UART for panic printing. Signed-off-by: Sean Cross --- kernel/src/debug.rs | 8 ++++---- kernel/src/main.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/src/debug.rs b/kernel/src/debug.rs index 6df5f977e..620737094 100644 --- a/kernel/src/debug.rs +++ b/kernel/src/debug.rs @@ -1,6 +1,6 @@ use core::fmt::{Error, Write}; #[macro_use] -#[cfg(all(not(test), feature = "debug-print"))] +#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))] pub mod debug_print_hardware { use crate::debug::*; pub const SUPERVISOR_UART: Uart = Uart { @@ -16,10 +16,10 @@ pub mod debug_print_hardware { }); } } -#[cfg(all(not(test), feature = "debug-print"))] +#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))] pub use crate::debug::debug_print_hardware::SUPERVISOR_UART; -#[cfg(all(not(test), not(feature = "debug-print")))] +#[cfg(all(not(test), not(any(feature = "debug-print", feature = "print-panics"))))] #[macro_export] macro_rules! print { ($($args:tt)+) => {{ @@ -82,7 +82,7 @@ impl Uart { } } -#[cfg(all(not(test), feature = "debug-print"))] +#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))] pub fn irq(_irq_number: usize, _arg: *mut usize) { println!( "Interrupt {}: Key pressed: {}", diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 17ff0257e..b3042e42e 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -58,7 +58,7 @@ pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offs // Either map memory using a syscall, or if we're debugging the syscall // handler then directly map it. - #[cfg(feature = "debug-print")] + #[cfg(any(feature = "debug-print", feature = "print-panics"))] { // Map the serial port so println!() works as expected. mem::MemoryManager::with_mut(|memory_manager| {