summaryrefslogtreecommitdiff
path: root/kernel/src/panic.rs
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-02-25 01:18:10 -0600
committerNathan Ringo <nathan@remexre.com>2024-02-25 10:59:35 -0600
commit178cb5bb0755064a0824b1b3d564260db412ea92 (patch)
treec9917506abe9d2b9910f01a383b9320513a69c53 /kernel/src/panic.rs
parentc8de43bf43242c4ebac3d0ecb8e7951fe2371506 (diff)
[console] Adds the start of a console subsystem to handle kernel logs.
The idea is that this is an output-only facility that log messages from the log crate are written to. It has a small buffer, and relies on a log destination regularly reading from the buffer. In the next commit, platform-specific code will be able to provide a "strict flush" routine, which runs after every write to the buffer and drains the buffer. This is mainly to help kernel development, where it's not assured that the kernel will even get as far in boot as initializing its allocator. Eventually, there will be a console fd that userspace can request, wait on, and read from.
Diffstat (limited to 'kernel/src/panic.rs')
-rw-r--r--kernel/src/panic.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/kernel/src/panic.rs b/kernel/src/panic.rs
index ed6e5d4..9aabb01 100644
--- a/kernel/src/panic.rs
+++ b/kernel/src/panic.rs
@@ -1,12 +1,12 @@
-use core::panic::PanicInfo;
+//! The kernel panic handler.
+
+use core::{arch::asm, panic::PanicInfo};
#[panic_handler]
-fn panic(_info: &PanicInfo) -> ! {
+fn panic(info: &PanicInfo) -> ! {
+ log::error!("{info:?}");
+
loop {
- for byte in "panic\n".bytes() {
- unsafe {
- core::ptr::write_volatile(0x10000000 as *mut u8, byte);
- }
- }
+ unsafe { asm!("wfi") }
}
}