From 649ff9636fe7289749c91141bbf32b2dcbe6dde4 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 13:27:11 -0400 Subject: add serial logging for exceptions, fix virtualbox issue --- kernel/include/hilbert/kernel/serial.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 kernel/include/hilbert/kernel/serial.hpp (limited to 'kernel/include/hilbert') diff --git a/kernel/include/hilbert/kernel/serial.hpp b/kernel/include/hilbert/kernel/serial.hpp new file mode 100644 index 0000000..e7a44f2 --- /dev/null +++ b/kernel/include/hilbert/kernel/serial.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace hilbert::kernel { + + extern "C" void serial_init(); + + extern "C" void serial_putchar(char ch); + + static inline void serial_putstr(const char *str) { + while (*str) { + serial_putchar(*str); + ++str; + } + } + + template + static inline void serial_puthex(uint64_t n) { + for (int d = digits - 1; d >= 0; --d) { + serial_putchar("0123456789abcdef"[(n >> (d * 4)) & 0xf]); + if (d % dot_every == 0 && d != 0) + serial_putchar('.'); + } + } + +} -- cgit v1.2.3