Initial commit
Signed-off-by: Robert Allan James <robert.allan.james@gmail.com>
This commit is contained in:
@@ -176,6 +176,7 @@ static int serial_transmit_empty(void) {
|
||||
static char g_active_vm_name_buf[CONSOLE_VM_NAME_BUF];
|
||||
static const char *g_active_vm_name = (void *)0;
|
||||
static int g_line_start = 1;
|
||||
static uint64_t g_console_tx_count; /* monotonic console_putc() counter (BSS) */
|
||||
|
||||
void console_set_vm_name(const char *name) {
|
||||
/* Empty string treated the same as NULL: console_save_vm_name()
|
||||
@@ -258,8 +259,23 @@ static void emit_prefix(void) {
|
||||
* Emits "[VMName] " at the start of each new line when a VM name is set.
|
||||
* Also mirrors output to the framebuffer VT100 terminal when available.
|
||||
* Serial output is ALWAYS active regardless of framebuffer state.
|
||||
*
|
||||
* console_putc_inner(): the same body minus the tx-counter increment.
|
||||
* console_ensure_line_start() uses the inner form so its format-only
|
||||
* newline does not read as "real output" to the REPL's prompt re-anchor
|
||||
* (repl.c) -- a silent idle beat that merely closes a dangling prompt line
|
||||
* must not be mistaken for chatter and trigger a prompt repaint. The
|
||||
* counter counts characters the caller actually intended to emit.
|
||||
*/
|
||||
static void console_putc_inner(char c);
|
||||
|
||||
void console_putc(char c) {
|
||||
g_console_tx_count++;
|
||||
console_putc_inner(c);
|
||||
}
|
||||
|
||||
static void console_putc_inner(char c)
|
||||
{
|
||||
/* --- serial UART path (always on) --- */
|
||||
if (g_active_vm_name && g_line_start && c != '\n') {
|
||||
emit_prefix();
|
||||
@@ -288,6 +304,19 @@ void console_puts(const char *s) {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t console_tx_count(void)
|
||||
{
|
||||
return g_console_tx_count;
|
||||
}
|
||||
|
||||
void console_ensure_line_start(void)
|
||||
{
|
||||
if (!g_line_start)
|
||||
{
|
||||
console_putc_inner('\n');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string with newline to serial console
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user