summaryrefslogtreecommitdiffstats
path: root/CONTEXT.md
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-01 14:09:14 +0200
committersalmonik <salmonik@tuta.io>2026-08-01 14:09:14 +0200
commitc7540c31d45dac68fa1852f5d25645d569b2da9d (patch)
treec102aacb40f99d4f9bb87ab2a996cb08df0dfae0 /CONTEXT.md
parentshell: cat <path> TIL <marker> sugar + precise ordering errors (diff)
downloadrs-dos-c7540c31d45dac68fa1852f5d25645d569b2da9d.tar.gz
rs-dos-c7540c31d45dac68fa1852f5d25645d569b2da9d.zip
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.
Diffstat (limited to 'CONTEXT.md')
-rw-r--r--CONTEXT.md36
1 files changed, 28 insertions, 8 deletions
diff --git a/CONTEXT.md b/CONTEXT.md
index c6bd5f9..86822d1 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -255,6 +255,34 @@ Workspace of four crates, all built for the `x86_64-unknown-uefi` target:
255 monitor (`--sock`, US layout, named keys for punctuation; bare 255 monitor (`--sock`, US layout, named keys for punctuation; bare
256 `-`/`.`/`/` are not valid sendkey names) 256 `-`/`.`/`/` are not valid sendkey names)
257 257
258✅ **`klog` kernel log ring** — a RAM ring of the last 128 serial log
259 lines (128 chars each, ~16 KB), fed by `serial_println!` (one choke
260 point — every boot/low-level message captured for free). Sequence
261 numbers per line + wrap/drop accounting; a dump header reports how
262 many lines were lost to wrap. Exposed as the `/dev/klog` char
263 device; the shell `klog` command is a thin alias for `cat
264 /dev/klog` (same filters/redirection), so `klog -t 5`, `klog -g
265 fat`, and `klog WRITING /disk/…/boot.log` (persists the boot log)
266 all work. The ring never allocates (const-constructible static);
267 only the dump allocates, at shell time. `klog` rejects positional
268 args (usage) and input keywords ("does not accept input").
269
270 **Design consequence: shell output must not feed the ring.** The
271 plan's "hook `serial_println!`" only works if that macro is
272 kernel-logging-only — but the shell printed prompts/errors/results
273 through it, which would have flooded the boot log with echo/cat
274 output (a `cat /dev/mem` would wrap the ring). The shell now
275 writes user-facing output (banner, prompt, `term_print`/
276 `term_println`, pipeline sink, halt/poweroff) directly to the
277 serial port via `serial::write_str`; tty echo already did. Only
278 kernel messages (rsnix modules + `rsdos/main.rs`) go through
279 `serial_println!` now. Verified in QEMU: 28 boot lines captured
280 (seq 0..27, first `=== rsnix boot ===`, last `boot: entering
281 shell`), `echo hello` output absent from the ring, `klog WRITING`
282 persists a boot log (mtype-verified), wrap behavior verified with a
283 temporary 140-line boot loop (128 kept / 40 dropped, seq 40..167,
284 oldest live line correct — loop reverted after the test).
285
258## Known issues / perf notes 286## Known issues / perf notes
259 287
260- **Scroll cost** — scrolling still shifts the whole framebuffer (a 288- **Scroll cost** — scrolling still shifts the whole framebuffer (a
@@ -289,14 +317,6 @@ Workspace of four crates, all built for the `x86_64-unknown-uefi` target:
289 317
290## Pending decisions (agreed, not yet implemented) 318## Pending decisions (agreed, not yet implemented)
291 319
292- **`klog` kernel log ring**: capture all boot/low-level messages by
293 appending to a RAM ring buffer inside `serial_println!` (one choke
294 point, every existing message captured for free). Ring: 128 lines ×
295 128 chars ≈ 16 KB, sequence numbers, wrap/drop accounting.
296- **`klog` command** = thin alias for `cat /dev/klog` plus filters
297 `-h` (head) and `-t` (tail); no log levels, no timestamps, nothing
298 fancier. `/dev/klog` is a char device so `klog WRITING /disk/…/boot.log`
299 persists a boot log via the existing redirection.
300- **Disk recognition scope — keep simple for now**: no pre-EBS UEFI 320- **Disk recognition scope — keep simple for now**: no pre-EBS UEFI
301 block-device census, no GPT/MBR partition parsing, no NVMe driver. 321 block-device census, no GPT/MBR partition parsing, no NVMe driver.
302 (Revisit later: Linux-style recognition = PCI scan → ahci/nvme → 322 (Revisit later: Linux-style recognition = PCI scan → ahci/nvme →