diff options
Diffstat (limited to 'kernel/include')
-rw-r--r-- | kernel/include/hilbert/kernel/serial.hpp | 27 |
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('.'); + } + } + +} |