Basic Console¶
The basic console is implemented in
os/drivers/console/basic_console.c.
This console provides an interface for higher-level abstractions, like, hopefully, the virtual terminal layer, and other things in the kernel that need to print text to the screen, like, e.g., printk. For output to the screen, it uses the vga text display.
Initialization¶
This driver is initialized by calling
-
void basic_console_init(void)¶
Initialize the console frontend.
Allocating a Basic Console¶
A new instance of the basic console is allocated by calling
-
console_t *basic_console_alloc(void)¶
Allocate and return a new instance of a basic console.
Allocating a basic console in turn allocates a new console datastructure (console_t). The provided console operations are stored in the console data structure. The operations of the desired video driver – currently the vga text display – are stored as the console’s private driver data.
- Returns:
A pointer to the newly allocated console.
Console Operations¶
This console implements the console operations (console_operations_t)
Open¶
Implements the operation console_operations_t.open:
Write¶
Implements the operation console_operations_t.write:
-
static void __basic_con_write(console_t *con, const char *string, unsigned int count)¶
Write
countcharacters of astringto the consolecon.Output printable characters but also handle (some) control characters, e.g., newline, backspace, form feed. The respective output code is wrapped into separate functions. The cursor is moved accordingly.
Helper Functions¶
This console uses helper functions to wrap some of the tasks handled by the write operation:
-
static void __basic_con_newline(console_t *con)¶
Perform a carriage return, newline on the console
con.
-
static void __basic_con_putc(console_t *con, const char *c)¶
Write a character
cto the consolecon.