Skip to main content

proka_kernel/
panic.rs

1//! # Proka Kernel - A kernel for ProkaOS
2//! Copyright (C) RainSTR Studio 2025, All rights reserved.
3//!
4//! This provides the panic handler with tests and normal.
5
6use crate::serial_println;
7use core::panic::PanicInfo;
8
9// This is the default panic handler
10#[cfg(not(test))]
11#[panic_handler]
12pub fn panic(info: &PanicInfo) -> ! {
13    serial_println!("{}", info);
14    loop {}
15}
16
17// And this is for test
18#[cfg(test)]
19#[panic_handler]
20pub fn panic(info: &PanicInfo) -> ! {
21    // Call the default test panic handler
22    panic_for_test(info)
23}
24
25// This is the panic handler for all testing function
26#[cfg(test)]
27pub fn panic_for_test(info: &PanicInfo) -> ! {
28    serial_println!("[FAILED]");
29    serial_println!("Caused by:\n\t{}", info);
30    crate::test::long_jmp();
31}