You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//
|
|
|
|
// Copyright (c) 2018-2019 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
|
|
|
|
//! A panic handler that infinitely waits.
|
|
|
|
|
|
|
|
use crate::{arch, bsp};
|
|
|
|
use core::{fmt, panic::PanicInfo};
|
|
|
|
|
|
|
|
fn _panic_print(args: fmt::Arguments) {
|
|
|
|
use fmt::Write;
|
|
|
|
|
|
|
|
unsafe { bsp::panic_console_out().write_fmt(args).unwrap() };
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Prints with a newline - only use from the panic handler.
|
|
|
|
///
|
|
|
|
/// Carbon copy from https://doc.rust-lang.org/src/std/macros.rs.html
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! panic_println {
|
|
|
|
($($arg:tt)*) => ({
|
|
|
|
_panic_print(format_args_nl!($($arg)*));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[panic_handler]
|
|
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
|
|
if let Some(args) = info.message() {
|
|
|
|
panic_println!("Kernel panic: {}", args);
|
|
|
|
} else {
|
|
|
|
panic_println!("Kernel panic!");
|
|
|
|
}
|
|
|
|
|
|
|
|
arch::wait_forever()
|
|
|
|
}
|