diff options
author | Marvin Borner | 2021-04-25 13:43:14 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-25 13:43:14 +0200 |
commit | f2b4acb2fe6a366288b19843e0d2678b8590bdf4 (patch) | |
tree | 1eb869f237908ec0b2516c00f940c6562c5cc5bd /kernel/features/logger.c | |
parent | cd46cefdd74b9ad0b225706f4d4b5864e87d97d6 (diff) |
Chu chuu, using the bus for everything now!
Well, I know: bus != train. But I like trains. So I don't care.
Go away!
Diffstat (limited to 'kernel/features/logger.c')
-rw-r--r-- | kernel/features/logger.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/features/logger.c b/kernel/features/logger.c new file mode 100644 index 0000000..7db9a82 --- /dev/null +++ b/kernel/features/logger.c @@ -0,0 +1,42 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#include <cpu.h> +#include <def.h> +#include <errno.h> +#include <io.h> +#include <logger.h> +#include <mem.h> +#include <print.h> +#include <serial.h> + +static res logger_write(const void *buf, u32 offset, u32 count) +{ + if (offset) + return -EINVAL; + + if (!count) + return EOK; + + print_prefix(); + + u32 i; + stac(); + for (i = 0; i < count; i++) { + if (!((const u8 *)buf)[i]) + break; + + serial_put(((const u8 *)buf)[i]); + } + clac(); + + serial_print("\x1B[0m"); + + return i; +} + +void logger_install(void) +{ + struct io_dev *dev = zalloc(sizeof(*dev)); + dev->write = logger_write; + io_add(IO_LOGGER, dev); +} |