blob: fd5d73091fe33bd68ef007f1a883ccf11c8fa481 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// MIT License, Copyright (c) 2021 Marvin Borner
#include <def.h>
#include <drivers/cpu.h>
#include <drivers/serial.h>
#include <errno.h>
#include <io.h>
#include <logger.h>
#include <mem.h>
#include <print.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);
}
|