AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
earlycon.c
Go to the documentation of this file.
1
10
11#include <core/kargs.h>
12#include <core/string.h>
13#include <console/earlycon.h>
14
15static struct earlycon *earlycon;
16
17extern struct earlycon earlycon_uart;
18extern struct earlycon earlycon_vga;
19extern struct earlycon earlycon_fb;
20
21extern int earlycon_fb_available(void);
22
23/*
24 * Writes a string on the early console.
25 */
26int earlycon_puts(char *s)
27{
28 return earlycon->puts(s);
29}
30
31/*
32 * Writes a character on the early console.
33 */
34int earlycon_putc(char c)
35{
36 return earlycon->putc(c);
37}
38
39/*
40 * Says whether the early console writes on the screen rather than on the
41 * serial port.
42 */
44{
45 return earlycon != &earlycon_uart;
46}
47
48/* Starts the early console, on the first serial port, at boot. */
50{
52 earlycon->init();
53}
54
55/* Chooses the early console again once the kernel's command line is
56 * read: the framebuffer if there is one, unless `earlycon=` says
57 * otherwise. */
59{
60 const char *arg_earlycon = NULL;
61 /* the framebuffer if there is one, else the serial port */
63
64 if (!kargs_get("earlycon", &arg_earlycon) && arg_earlycon) {
65 if (!strcmp(arg_earlycon, "ttyS0"))
67 else if (!strcmp(arg_earlycon, "vga"))
69 else if (!strcmp(arg_earlycon, "fb") && earlycon_fb_available())
71 }
72
73 earlycon->init();
74}
int earlycon_putc(char c)
Writes a character on the early console.
Definition earlycon.c:23
void earlycon_reinit(void)
Sets up the early console again, once the kernel's command line has been read, since it may choose an...
Definition earlycon.c:65
int earlycon_puts(char *s)
Writes a string on the early console.
Definition earlycon.c:38
void earlycon_init(void)
Sets up the early console at boot, before anything else.
Definition earlycon.c:59
int earlycon_on_screen(void)
Says whether the early console writes on the screen, rather than on a serial port.
Definition earlycon.c:52
int earlycon_fb_available(void)
Says whether the boot loader's framebuffer can be the early console.
Definition fb.c:55
struct earlycon earlycon_vga
Definition vga.c:85
struct earlycon earlycon_fb
Definition fb.c:161
struct earlycon earlycon_uart
Definition uart.c:92
int kargs_get(const char *key, const char **value)
Looks up an argument of the kernel's command line.
Definition kargs.c:73
#define NULL
Definition stddef.h:27
An early console's operations.
Definition earlycon.h:11
void(*) init(void)
Definition earlycon.h:12
int(*) puts(char *)
Definition earlycon.h:13
int(*) putc(char)
Definition earlycon.h:14