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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-08-30 00:34:10 +08:00
parent 750f05c322
commit b78a71c495
2 changed files with 5 additions and 5 deletions

View file

@ -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: {}",

View file

@ -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| {