]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
fix: kconsole overhaul — 8 bugs fixed (echo, VGA, serial, dmesg)
authorTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 06:51:01 +0000 (03:51 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 06:51:01 +0000 (03:51 -0300)
commiteb38508f3c07611bc65397fbeb2925a0ba46b093
treee54d995380f84e19e5420dd0bba595c1c68505ba
parente1ed128bca2d1021872934d4e6bc363ea27b3a7b
fix: kconsole overhaul — 8 bugs fixed (echo, VGA, serial, dmesg)

Issues reported and fixed:

1. Double echo: TTY keyboard callback was echoing characters via
   tty_output_char() AND kconsole was echoing via console_write().
   Fix: keyboard_set_callback(0) detaches TTY on kconsole entry.

2. Backspace printing garbage: VGA vga_put_char() only handled \n,
   treating \b as a visible glyph. Fix: full control char support
   in vga_put_char — \b moves cursor back, \r resets column, \t
   advances to next tab stop, non-printable chars filtered.

3. Enter printing garbage: same root cause as #2 — \r was not
   handled by VGA. Now handled properly.

4. Cursor not tracking: VGA had no hardware cursor update. Added
   hal_video_set_cursor() HAL function using CRTC registers
   0x3D4/0x3D5 on x86, called after every character output.

5. Clear screen broken: was using ANSI escape \033[2J which VGA
   can't parse. Added vga_clear() function, kconsole calls it
   directly.

6. dmesg contamination: kconsole prompts and help text used
   kprintf() which appends to klog ring buffer. Introduced
   kc_puts() wrapper over console_write() for interactive output
   that should NOT appear in dmesg.

7. Scroll (Shift+PageUp/Down): deferred — requires scrollback
   buffer (significant feature). Documented as known limitation.

8. Serial input not working (-serial stdio): kgetc() only read
   from PS/2 keyboard via keyboard_read_blocking(). Added
   hal_uart_try_getc() to HAL (poll UART LSR data-ready bit),
   rewrote kgetc() to poll both keyboard and UART in a loop.

9. ring3 command: removed from kconsole (useless without initrd
   in emergency mode). Replaced with proper ls command using
   readdir to list directory contents.

HAL changes (all 4 architectures):
- hal_video_set_cursor(row, col) — x86 uses VGA CRTC I/O ports
- hal_uart_try_getc() — non-blocking serial RX polling

Build: clean, cppcheck: clean, smoke: 19/19 pass
14 files changed:
include/hal/uart.h
include/hal/video.h
include/vga_console.h
src/drivers/vga_console.c
src/hal/arm/uart.c
src/hal/arm/video.c
src/hal/mips/uart.c
src/hal/mips/video.c
src/hal/riscv/uart.c
src/hal/riscv/video.c
src/hal/x86/uart.c
src/hal/x86/video.c
src/kernel/console.c
src/kernel/kconsole.c