[kernel] Move the logger from kutil into kernel

Part one of a series of code moves. The kutil library is not very
useful, as most of its code is kernel-specific. This was originally for
testing purposes, but that can be achieved in other ways with the
current build system. I find this mostly creates a strange division in
the kernel code.

Instead, I'm going to move everything kernel-specific to actually be in
the kernel, and replace kutil with just 'util' for generic utility code
I want to share.

This commit:

- Moves the logger into the kernel.
- Updates the 'printf' library used from mpaland/printf to
  eyalroz/printf and moved it into the kernel, as it's only used by the
  logger in kutil.
- Removes some other unused kutil headers from some files, to help
  future code rearrangement.

Note that the (now redundant-seeming) log.cpp/h in kernel is currently
still there - these files are more about log output than the logging
system, and will get replaced once I add user-space log output.
This commit is contained in:
Justin C. Miller
2022-01-01 18:02:11 -08:00
parent 99de8454cd
commit 042f061d86
19 changed files with 1379 additions and 892 deletions

View File

@@ -1,6 +1,7 @@
#include "printf/printf.h"
#include "cpu.h"
#include "display.h"
#include "kutil/printf.h"
#include "serial.h"
#include "symbol_table.h"
@@ -25,7 +26,7 @@ print_header(
out.write(":");
char linestr[6];
snprintf(linestr, sizeof(linestr), "%d", line);
snprintf(linestr, sizeof(linestr), "%ld", line);
out.write(linestr);
out.write("\n \e[0;31m===================================================================================\n");
@@ -56,7 +57,7 @@ print_reg(serial_port &out, const char *name, uint64_t val, const char *color)
{
char message[512];
snprintf(message, sizeof(message), " \e[0;%sm%-3s %016llx\e[0m", color, name, val);
snprintf(message, sizeof(message), " \e[0;%sm%-3s %016lx\e[0m", color, name, val);
out.write(message);
}
@@ -102,3 +103,6 @@ print_cpu_state(serial_port &out, const cpu_state &regs)
}
} // namespace panic
// For printf.c
extern "C" void putchar_(char c) {}