Next Generation WASM Microkernel Operating System
at trap_handler 31 lines 985 B view raw
1// Copyright 2025 Jonas Kruckenberg 2// 3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or 4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or 5// http://opensource.org/licenses/MIT>, at your option. This file may not be 6// copied, modified, or distributed except according to those terms. 7 8use crate::arch; 9use abort::abort; 10 11#[panic_handler] 12fn panic(info: &core::panic::PanicInfo) -> ! { 13 // disable interrupts as soon as we enter the panic subsystem 14 // no need to bother with those now as we're about to shut down anyway 15 arch::interrupt::disable(); 16 17 let loc = info.location().unwrap(); // The current implementation always returns Some 18 let msg = info.message(); 19 20 log::error!("cpu panicked at {loc}:\n{msg}"); 21 22 rust_panic() 23} 24 25/// Mirroring std, this is an unmangled function on which to slap 26/// yer breakpoints for backtracing panics. 27#[inline(never)] 28#[unsafe(no_mangle)] 29fn rust_panic() -> ! { 30 abort() 31}