Console Subsystem¶
The Console Subsystem is made up of
the console drivers, providing console devices
the implementation of the subsystem itself, providing means for managing consoles
The Console Subsystem is implemented in
os/drivers/console/console.c.
This simple subsystem allocates new consoles and provides a generic open function that dispatches to the respective console. It furthermore provides a means to set and get the initial (boot) console.
Initialization¶
This subsystem is initialized by calling
-
void console_init(void)¶
Initialize the console subsystem.
Allocating a Console¶
A new console is allocated by calling
-
console_t *console_alloc(void)¶
Allocate, initialize and return a new console.
Console operations (console_t::con_ops) need to be provided by the actual console implementation.
Note
This function is intended to be called from the respective console driver.
Datatypes Provided by the Subsystem¶
Console Data Structure¶
The data structure keeping track of console-related data
-
struct console_t¶
Console state and operations (backend and frontend).
Tracks the state, e.g., cursor x and y position, and stores the operations provided of and required for a (virtual) console. These operations (con_ops) will be implemented by a console driver and provided to higher-level system components.
Public Members
-
const console_operations_tconsole_operations_t *con_ops¶
The operations provided by a console frontend.
-
unsigned int pos_x¶
The column for new strings to be printed.
-
unsigned int pos_y¶
The row for new strings to be printed.
-
unsigned int width¶
The number of columns the backend provides.
-
unsigned int height¶
The number of rows the backend provides.
-
uint8_t default_attribute¶
The default attribute to use for characters.
-
void *driver_data¶
Driver-specific private data.
-
const console_operations_tconsole_operations_t *con_ops¶
Console Operations¶
The interface between higher-level system components and the console frontend.
-
struct console_operations_t¶
Callbacks provided by console drivers to higher-level components.
These callbacks provide other parts of the system with means of, e.g., writing text to a console. The callbacks have to be implemented by the respective console frontend. They can be used, for instance, in
printkto output text to the screen.This data structure and the callbacks defined in it are based on
struct consolefrom the Linux kernel (as of 6.17.5). They are adapted and simplified and may long have diverged in order to make tomOSii a prototypical teaching operating system.