summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-05-19 13:27:11 -0400
committerBenji Dial <benji@benjidial.net>2024-05-19 13:27:11 -0400
commit649ff9636fe7289749c91141bbf32b2dcbe6dde4 (patch)
tree5da6e8ddfd449b012d8936040e292fa4de534cc0 /kernel/include
parentf8ff95f19289a88706935abebd71e317355641d4 (diff)
downloadhilbert-os-649ff9636fe7289749c91141bbf32b2dcbe6dde4.tar.gz
add serial logging for exceptions, fix virtualbox issue
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/hilbert/kernel/serial.hpp27
1 files changed, 27 insertions, 0 deletions
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 <stdint.h>
+
+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 <int digits, int dot_every = 4>
+ 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('.');
+ }
+ }
+
+}