From c7540c31d45dac68fa1852f5d25645d569b2da9d Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 14:09:14 +0200 Subject: klog: kernel log ring + /dev/klog + klog shell command - rsnix/src/klog.rs: RAM ring of the last 128 serial log lines (128 chars each), fed by serial_println! so every boot/low-level message is captured for free. Sequence numbers per line, wrap/drop accounting; the ring never allocates (const-constructible static). - /dev/klog char device; shell 'klog' is a thin alias for cat /dev/klog with the same filters/redirection, so 'klog -t 5', 'klog -g fat' and 'klog WRITING /disk/.../boot.log' all work. klog rejects positional args (usage) and input keywords. - Shell user-facing output (banner, prompt, term_print/term_println, pipeline sink, halt/poweroff) now writes to serial directly instead of through serial_println!, keeping echo/cat output out of the boot log (a streaming cat /dev/mem would otherwise wrap the ring). - serial_println! macro hooks klog::append_fmt via format_args! (no alloc at call sites); klog::dump formats the log for the device. Verified in QEMU: 28 boot lines captured (seq 0..27), shell output absent from the ring, klog WRITING persists a boot log (mtype-checked), wrap verified with a temporary 140-line boot loop (128 kept / 40 dropped, seq 40..167, oldest-live correct; loop reverted); full test-disk round trip still fsck-clean. --- rsnix/src/lib.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'rsnix/src/lib.rs') diff --git a/rsnix/src/lib.rs b/rsnix/src/lib.rs index fc823ea..a2d41da 100644 --- a/rsnix/src/lib.rs +++ b/rsnix/src/lib.rs @@ -8,6 +8,7 @@ pub mod font; pub mod fs; pub mod gop; pub mod interrupts; +pub mod klog; pub mod memory; pub mod paging; pub mod pci; -- cgit v1.2.3