AquilaOS documentation
How it works, and its code
Toggle main menu visibility
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
15
static
struct
earlycon
*
earlycon
;
16
17
extern
struct
earlycon
earlycon_uart
;
18
extern
struct
earlycon
earlycon_vga
;
19
extern
struct
earlycon
earlycon_fb
;
20
21
extern
int
earlycon_fb_available
(
void
);
22
23
/*
24
* Writes a string on the early console.
25
*/
26
int
earlycon_puts
(
char
*s)
27
{
28
return
earlycon
->
puts
(s);
29
}
30
31
/*
32
* Writes a character on the early console.
33
*/
34
int
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
*/
43
int
earlycon_on_screen
(
void
)
44
{
45
return
earlycon
!= &
earlycon_uart
;
46
}
47
48
/* Starts the early console, on the first serial port, at boot. */
49
void
earlycon_init
()
50
{
51
earlycon
= &
earlycon_uart
;
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. */
58
void
earlycon_reinit
()
59
{
60
const
char
*arg_earlycon =
NULL
;
61
/* the framebuffer if there is one, else the serial port */
62
earlycon
=
earlycon_fb_available
() ? &
earlycon_fb
: &
earlycon_uart
;
63
64
if
(!
kargs_get
(
"earlycon"
, &arg_earlycon) && arg_earlycon) {
65
if
(!strcmp(arg_earlycon,
"ttyS0"
))
66
earlycon
= &
earlycon_uart
;
67
else
if
(!strcmp(arg_earlycon,
"vga"
))
68
earlycon
= &
earlycon_vga
;
69
else
if
(!strcmp(arg_earlycon,
"fb"
) &&
earlycon_fb_available
())
70
earlycon
= &
earlycon_fb
;
71
}
72
73
earlycon
->
init
();
74
}
earlycon_putc
int earlycon_putc(char c)
Writes a character on the early console.
Definition
earlycon.c:23
earlycon_reinit
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
earlycon_puts
int earlycon_puts(char *s)
Writes a string on the early console.
Definition
earlycon.c:38
earlycon_init
void earlycon_init(void)
Sets up the early console at boot, before anything else.
Definition
earlycon.c:59
earlycon_on_screen
int earlycon_on_screen(void)
Says whether the early console writes on the screen, rather than on a serial port.
Definition
earlycon.c:52
earlycon.h
earlycon_fb_available
int earlycon_fb_available(void)
Says whether the boot loader's framebuffer can be the early console.
Definition
fb.c:55
earlycon_vga
struct earlycon earlycon_vga
Definition
vga.c:85
earlycon_fb
struct earlycon earlycon_fb
Definition
fb.c:161
earlycon_uart
struct earlycon earlycon_uart
Definition
uart.c:92
kargs_get
int kargs_get(const char *key, const char **value)
Looks up an argument of the kernel's command line.
Definition
kargs.c:73
kargs.h
NULL
#define NULL
Definition
stddef.h:27
string.h
earlycon
An early console's operations.
Definition
earlycon.h:11
earlycon::init
void(*) init(void)
Definition
earlycon.h:12
earlycon::puts
int(*) puts(char *)
Definition
earlycon.h:13
earlycon::putc
int(*) putc(char)
Definition
earlycon.h:14
kernel
arch
i386
earlycon
earlycon.c
Generated by
1.18.0