diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 17:42:21 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 17:42:21 +0200 |
| commit | a2ffb8358cf4f4fc7230b5307c651d5badab0860 (patch) | |
| tree | 5412fa837a6832ca078443e7668a776ee760f75c /rsnix/src/memory.rs | |
| parent | vt: decode UTF-8, render box-drawing/arrow glyphs procedurally (diff) | |
| download | rs-dos-a2ffb8358cf4f4fc7230b5307c651d5badab0860.tar.gz rs-dos-a2ffb8358cf4f4fc7230b5307c651d5badab0860.zip | |
vt: don't strand stale inverse cursor cells on scroll/clear
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.
Diffstat (limited to '')
| -rw-r--r-- | rsnix/src/memory.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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 { | |||
| 436 | /// the heap itself (fixed-size stack arrays only). Returns true on success. | 436 | /// the heap itself (fixed-size stack arrays only). Returns true on success. |
| 437 | pub fn self_test() -> bool { | 437 | pub fn self_test() -> bool { |
| 438 | unsafe { | 438 | unsafe { |
| 439 | // Snapshot the heap before we start: earlier boot code (e.g. the | ||
| 440 | // vt cell grids) may legitimately hold live allocations. The test | ||
| 441 | // must return the heap to exactly this state, not to "empty". | ||
| 442 | let before = heap_stats(); | ||
| 443 | |||
| 439 | const N: usize = 128; | 444 | const N: usize = 128; |
| 440 | // (ptr, size, align) triplets — fixed array on the stack. | 445 | // (ptr, size, align) triplets — fixed array on the stack. |
| 441 | let mut blocks: [(usize, usize, usize); N] = [(0, 0, 0); N]; | 446 | let mut blocks: [(usize, usize, usize); N] = [(0, 0, 0); N]; |
| @@ -504,7 +509,7 @@ pub fn self_test() -> bool { | |||
| 504 | ALLOCATOR.dealloc(*ptr as *mut u8, layout); | 509 | ALLOCATOR.dealloc(*ptr as *mut u8, layout); |
| 505 | } | 510 | } |
| 506 | let stats = heap_stats(); | 511 | let stats = heap_stats(); |
| 507 | stats.free_blocks == 1 && stats.free_bytes == stats.heap_size | 512 | stats.free_blocks == before.free_blocks && stats.free_bytes == before.free_bytes |
| 508 | } | 513 | } |
| 509 | } | 514 | } |
| 510 | 515 | ||
