full-screen vt100 terminal 4.4v -- keyboard-to-REPL bridge, real and tested: Refactored KEY-EVENT's per-arch translation logic (keyboard_words.c) into a shared C function, sk_key_event_poll(), so the REPL bridge reuses item 4.3.5f's already-converged Linux-keycode-namespace event stream instead of building separate amd64/aarch64/riscv64 tables. repl.c's sk_kbd_getc() decodes the standard US-QWERTY printable range plus Enter/Backspace/Shift against that stream; sk_readline() polls it as a second source alongside console_getc(). Verified via QEMU monitor sendkey injection, and by Captain Bob typing directly into the live QEMU window over real emulated PS/2 hardware mid-session (1 1 + . -> 2 ok, then a clean BYE shutdown). 4.4ab -- simplify to a full-screen terminal: Captain Bob's call, reverting the 640x480 CANVAS box + independent REPL strip (4.4o/4.4t/4.4x/4.4z) in favor of the simplest shape: the entire framebuffer is one vt100 terminal, g_vt.cols/rows = fb_width()/fb_height() divided by cell size, no origin offset, no box, no strip, no border drawing. The REPL prompt is just the terminal's last scrolling line. Scrollback, TTF rendering, and SGR color are all box-agnostic and keep working unmodified. 4.4r -- reframed as a text/graphics mode toggle: "Hide/show the scroll box" stopped meaning anything once the box was removed; the underlying need survives as a whole-screen mode switch. vt100_toggle_graphics() is a two-state machine (VISIBLE/HIDDEN) -- hidden mode stops the terminal from touching the framebuffer while its logical state keeps advancing, so direct framebuffer/TTF-TEXT drawing can use the whole screen; showing again wipes and reuses scrollback_redraw() to restore the terminal exactly. Reachable two ways, one transition function: physically via Alt+TAB (4.4y revised from Ctrl+TAB) and programmatically via the new ALT+TAB FORTH word. Verified: three-arch clean QEMU boot + logs; amd64 screendump confirms full-width text with no box/strip artifacts. Punch list §25 items 4.4v/4.4r/4.4ab complete; 4.4y revised. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
140 lines
4.4 KiB
C
140 lines
4.4 KiB
C
/*
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
*/
|
||
|
||
/**
|
||
* console.h - Serial console + framebuffer VT100 interface for StarKernel
|
||
*
|
||
* Output policy:
|
||
* - Serial UART is always active (initialized by console_init).
|
||
* - When console_fb_init() has been called and the framebuffer is ready,
|
||
* every character is also rendered through the VT100 terminal on screen.
|
||
* - Both outputs are always live simultaneously; serial cannot be disabled.
|
||
*/
|
||
|
||
#ifndef STARKERNEL_CONSOLE_H
|
||
#define STARKERNEL_CONSOLE_H
|
||
|
||
#include <stdint.h>
|
||
#include "uefi.h"
|
||
|
||
/**
|
||
* Initialize serial console (UART).
|
||
* Must be called once during early kernel boot.
|
||
*/
|
||
void console_init(void);
|
||
|
||
/**
|
||
* Initialize the framebuffer VT100 terminal.
|
||
* Call after UEFI boot services have been exited and the GOP framebuffer
|
||
* address is known (from BootInfo). Safe to call with info==NULL (no-op).
|
||
* fmt: FB_PIXEL_BGRX32 is correct for most QEMU / real hardware GOP.
|
||
*/
|
||
#include "framebuffer.h"
|
||
void console_fb_init(const FramebufferInfo *info, FbPixelFormat fmt);
|
||
|
||
/**
|
||
* FABRIC.md item 4.4j: switch the framebuffer console's glyph backend from
|
||
* font_8x16.c to TTF-TEXT's rasterizer. Thin wrapper over
|
||
* vt100_enable_ttf() -- see that function's doc comment for the full
|
||
* contract (lazy font load, cell-geometry/cols/rows recompute, screen
|
||
* clear, one-shot). No-op if the framebuffer console was never
|
||
* initialized (console_fb_init() not called, or it no-op'd on a NULL
|
||
* framebuffer).
|
||
*/
|
||
void console_fb_enable_ttf(void);
|
||
|
||
/**
|
||
* FABRIC.md item 4.4q: thin wrappers over vt100_scroll_back()/
|
||
* vt100_scroll_fwd() -- see those functions' doc comments for the full
|
||
* contract. No-op if the framebuffer console was never initialized.
|
||
*/
|
||
void console_fb_scroll_back(uint32_t n);
|
||
void console_fb_scroll_fwd(uint32_t n);
|
||
|
||
/**
|
||
* FABRIC.md item 4.4y-revised: thin wrapper over vt100_toggle_graphics()
|
||
* -- see that function's doc comment for the full contract (the
|
||
* Alt+TAB graphics/text state machine). No-op if the framebuffer console
|
||
* was never initialized.
|
||
*/
|
||
void console_fb_toggle_graphics(void);
|
||
|
||
/**
|
||
* Write a single character to serial console
|
||
*/
|
||
void console_putc(char c);
|
||
|
||
/**
|
||
* Write a null-terminated string to serial console
|
||
*/
|
||
void console_puts(const char *s);
|
||
|
||
/**
|
||
* Write a string with newline to serial console
|
||
*/
|
||
void console_println(const char *s);
|
||
|
||
/**
|
||
* Read a single character from serial console (non-blocking)
|
||
* Returns -1 if no character available
|
||
*/
|
||
int console_getc(void);
|
||
|
||
/**
|
||
* Check if character is available for reading
|
||
*/
|
||
int console_poll(void);
|
||
|
||
/**
|
||
* Set the active VM name shown as [Name] prefix on each output line.
|
||
* Pass NULL to suppress the prefix (kernel-only output before any VM).
|
||
* The pointer must remain valid for as long as it is active.
|
||
*/
|
||
void console_set_vm_name(const char *name);
|
||
const char *console_get_vm_name(void);
|
||
|
||
/* Last FORTH word name set by the dispatcher before entry->func(vm).
|
||
* Printed by the #GP fault handler to identify the faulting word. */
|
||
extern volatile const char *g_sk_fault_word;
|
||
|
||
#endif /* STARKERNEL_CONSOLE_H */
|