From a2ffb8358cf4f4fc7230b5307c651d5badab0860 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 17:42:21 +0200 Subject: vt: don't strand stale inverse cursor cells on scroll/clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cursor was blitted as an inverse-video cell directly onto the framebuffer, but that inversion was never recorded. RENDERED (the diff grid) only stored the logical cell, so when scrolling shifted the raw pixels up (gop::shift_up), the stale inverse block rode along while the grids said 'blank' — and blank-vs-blank never re-blits. Result: a cursor-shaped block at the end of every scrolled line, surviving even 'clear'. - flush() now mirrors the inverse colours into RENDERED when drawing the cursor (and restores RENDERED when erasing it), and the diff loop skips the visible cursor cell (owned by the cursor pass). Any scroll/clear then sees CELLS != RENDERED at a stale-inverse position and repaints it. - memory.rs heap self-test: snapshot heap state before its own allocations and assert the heap returns to that state, instead of asserting it coalesces to a single empty block. The vt cell grids (allocated earlier in boot) made the old 'free_blocks == 1' check fail; the new check is correct regardless of prior live allocations. Verified in QEMU: hexdump /dev/mem streams hundreds of lines, ^C, screendump shows exactly one inverse cell (the live cursor); 'clear' leaves exactly one (the fresh prompt cursor). heap self-test OK again. --- rsnix/src/memory.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'rsnix/src/memory.rs') diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs index d33c781..c80edab 100644 --- a/rsnix/src/memory.rs +++ b/rsnix/src/memory.rs @@ -436,6 +436,11 @@ pub fn heap_stats() -> HeapStats { /// the heap itself (fixed-size stack arrays only). Returns true on success. pub fn self_test() -> bool { unsafe { + // Snapshot the heap before we start: earlier boot code (e.g. the + // vt cell grids) may legitimately hold live allocations. The test + // must return the heap to exactly this state, not to "empty". + let before = heap_stats(); + const N: usize = 128; // (ptr, size, align) triplets — fixed array on the stack. let mut blocks: [(usize, usize, usize); N] = [(0, 0, 0); N]; @@ -504,7 +509,7 @@ pub fn self_test() -> bool { ALLOCATOR.dealloc(*ptr as *mut u8, layout); } let stats = heap_stats(); - stats.free_blocks == 1 && stats.free_bytes == stats.heap_size + stats.free_blocks == before.free_blocks && stats.free_bytes == before.free_bytes } } -- cgit v1.2.3