kernel: add kernel.early-console and kernel.console boot args

kernel.early-console is used to specify which output device the
kernel boot log should be written to. the first thing the kernel
does on boot after initialising the bootstrap processor is initialise
the early console, making it useful for debugging problems that
occur early in the boot process. this arg accepts a list of hard-coded
values for output devices, such as tty0 for the display or ttyS0
for the serial port. the exact values supported will depend on the
platform.

once all drivers are loaded, the kernel switches to the device specified
by kernel.console for output. unlike kernel.early-console, this arg
specifies the name of a tty device in /dev/tty. this means that, not
only are more devices supported (any device provided by a tty driver),
but the kernel can also get input from the user using this console too
(not used by the kernel itself, but will be used by the user to interact
with userspace programs, like the shell).
This commit is contained in:
2023-12-30 09:09:18 +00:00
parent fc56f906d3
commit b0c021d4e9
6 changed files with 91 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ extern char serial_recv_byte(int device);
extern int serial_rcvd(int device);
extern void serialcon_init(int baud);
extern void early_serialcon_init(int baud);
#ifdef __cplusplus
}

View File

@@ -5,7 +5,7 @@
#include <socks/libc/stdio.h>
#include <arch/ports.h>
#include <arch/irq.h>
#include "serial.h"
#include <socks/serialcon.h>
#define COM1 0x3F8
#define COM2 0x2F8
@@ -155,7 +155,7 @@ static struct irq_hook irq1_hook = {
.irq_callback = serial_irq1,
};
void serialcon_init(int baud)
void early_serialcon_init(int baud)
{
hook_irq(IRQ4, &irq1_hook);
init_serial_port(COM1, baud);