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. --- rsnix/src/vt.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'rsnix/src/vt.rs') diff --git a/rsnix/src/vt.rs b/rsnix/src/vt.rs index 709ea71..53821b7 100644 --- a/rsnix/src/vt.rs +++ b/rsnix/src/vt.rs @@ -224,7 +224,13 @@ fn put_byte(b: u8) { } fn param(i: usize, default: usize) -> usize { - unsafe { if i < NPARAMS { PARAMS[i] } else { default } } + unsafe { + if i < NPARAMS { + PARAMS[i] + } else { + default + } + } } /// Place a printable glyph at the cursor and advance (wrapping/scrolling). @@ -409,7 +415,7 @@ fn newline() { /// only the newly-exposed rows. const SCROLL_BATCH: usize = 16; static mut PENDING_SCROLLS: usize = 0; -static mut LAST_SYNC_TICK: u16 = 0; +static mut LAST_SYNC_TICK: u64 = 0; /// Shift the logical grid up one row; defer the framebuffer shift. fn scroll_up() { @@ -424,7 +430,7 @@ fn scroll_up() { // Batch: sync when enough scrolls piled up, or when the stream // pauses (~40 ms at the 100 Hz timer) so interactive output still // appears promptly. - const TICK_LIMIT: u16 = 4; + const TICK_LIMIT: u64 = 4; let now = crate::interrupts::TICKS.load(core::sync::atomic::Ordering::Relaxed); if PENDING_SCROLLS >= SCROLL_BATCH || now.wrapping_sub(LAST_SYNC_TICK) > TICK_LIMIT { sync_scroll(); -- cgit v1.2.3