From 6447eb12948d37b74adae2fdbf1db5a9d7b363d5 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 14:21:11 +0200 Subject: klog: [ssss.mmm] millisecond timestamps from the PIT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - interrupts::uptime_ms(): monotonic ms since boot — the 100 Hz PIT tick (10 ms) plus interpolation from the PIT's live 1.19 MHz down-counter (read twice around the tick load; a count jump means a tick fired between reads) for true sub-ms resolution. TICKS widened AtomicU16 -> AtomicU64 (u16 wrapped after ~11 min). - PIT_READY gates interpolation until interrupts::init configures the timer, so early-boot lines are deterministically [0000.000] instead of uninitialised-PIT noise; klog clamps timestamps monotonic. - The CMOS RTC cannot provide milliseconds (1 Hz BCD device, seconds only) — millis come from the PIT. - klog stores ms per line at append time; dump format is now '[0000.123] 000000 === rsnix boot ===' (user-specified format). Verified in QEMU: first line [0000.000], Phase-2 lines show real monotonic ms (fs: vfs ready at [0000.519], self-test [0000.524]), per-dump monotonicity, boot.log persists timestamps, test-disk round trip fsck-clean. --- CONTEXT.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index 86822d1..fd83245 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -259,7 +259,18 @@ Workspace of four crates, all built for the `x86_64-unknown-uefi` target: lines (128 chars each, ~16 KB), fed by `serial_println!` (one choke point — every boot/low-level message captured for free). Sequence numbers per line + wrap/drop accounting; a dump header reports how - many lines were lost to wrap. Exposed as the `/dev/klog` char + many lines were lost to wrap. Each line carries a `[ssss.mmm]` + timestamp — monotonic ms since boot from `interrupts::uptime_ms()`: + the 100 Hz PIT tick (10 ms) plus interpolation from the PIT's live + 1.19 MHz down-counter read twice around the tick load (a jump = a + tick fired between reads) for true sub-ms resolution; `TICKS` widened + to u64 so uptime never wraps. **The CMOS RTC cannot provide + milliseconds** — it is a 1 Hz BCD device (seconds only) — so the + millis come from the PIT. Early-boot lines are `[0000.000]` + (PIT not yet configured; `PIT_READY` gates interpolation), and + timestamps are clamped monotonic in the ring. + + Exposed as the `/dev/klog` char device; the shell `klog` command is a thin alias for `cat /dev/klog` (same filters/redirection), so `klog -t 5`, `klog -g fat`, and `klog WRITING /disk/…/boot.log` (persists the boot log) -- cgit v1.2.3