From 5e8cf84fb8fb2821eb948ffd2fddafd18b18e8cc Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 15 Sep 2025 03:25:51 -0400 Subject: kern: cons: Finish string writing logic - Wrap on X overflow - Wrap on Y overflow - Keep track of max console width and height - Add console enable/disable control Signed-off-by: Ian Moffett --- src/sys/os/os_syslog.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/sys/os/os_syslog.c') diff --git a/src/sys/os/os_syslog.c b/src/sys/os/os_syslog.c index b0e07dc..b6d30b7 100644 --- a/src/sys/os/os_syslog.c +++ b/src/sys/os/os_syslog.c @@ -30,10 +30,18 @@ #include #include /* shared */ #include +#include #include #include #include +/* + * If this value is true, data will be written to + * the video console, otherwise only serial logging + * will be used. + */ +static bool cons_enabled = false; + static void syslog_write(const char *str, size_t len) { @@ -41,6 +49,8 @@ syslog_write(const char *str, size_t len) spinlock_acquire(&lock); for (int i = 0; i < len; ++i) { + if (cons_enabled) + cons_putstr(&g_root_scr, str, 1); uart_write(*str++); } spinlock_release(&lock); @@ -64,3 +74,9 @@ printf(const char *fmt, ...) vprintf(fmt, &ap); va_end(ap); } + +void +syslog_toggle(bool enable) +{ + cons_enabled = enable; +} -- cgit v1.2.3