diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-15 03:25:51 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-15 03:26:17 -0400 |
commit | 5e8cf84fb8fb2821eb948ffd2fddafd18b18e8cc (patch) | |
tree | e816489c6b23afa83360faf27c0c493a1e81f0db /src/sys/os | |
parent | 40bca9deb5f81e57907e5614846678a46bcc1a49 (diff) |
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 <ian@osmora.org>
Diffstat (limited to 'src/sys/os')
-rw-r--r-- | src/sys/os/os_init.c | 1 | ||||
-rw-r--r-- | src/sys/os/os_syslog.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/sys/os/os_init.c b/src/sys/os/os_init.c index 66e8aca..b56ab94 100644 --- a/src/sys/os/os_init.c +++ b/src/sys/os/os_init.c @@ -18,6 +18,7 @@ main(void) vm_init(); cons_init(); + syslog_toggle(true); panic("end of kernel reached\n"); for (;;); 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 <sys/types.h> #include <machine/uart.h> /* shared */ #include <sys/syslog.h> +#include <io/cons/cons.h> #include <os/spinlock.h> #include <string.h> #include <stdarg.h> +/* + * 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; +} |