Serial Console¶
The serial console is implemented in
os/drivers/console/serial_console.c.
Implements a serial console that takes output from a higher-level component, like, printk or a tty and passes it to a serial line. It also takes input from the serial line and passes it to the virtual terminal subsystem. The latter will change in the future.
Initialization¶
This driver is initialized by calling
-
void serial_console_init(void)¶
Initialize the console frontend.
Allocating a Serial Console¶
A new instance of the serial console is allocated by calling
-
console_t *serial_console_alloc(void)¶
Allocate and return a new instance of a serial console.
Allocating a serial console in turn allocates a new console datastructure (console_t) and a new serial line data structure (serial_line_t). The provided console operations are stored in the console data structure. The serial line is stored as the private driver data of the console.
- 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:
Helper Functions¶
This console uses helper functions to wrap some of the tasks handled by the write operation:
Serial Input¶
For serial input an input handler is registered to the input subsystem that
processes EV_SERIAL events, re-maps some characters and passes them to the
VT subsystem:
-
static void __serial_input_handler(input_event_type_t type, uint16_t code, uint32_t value)¶
Handle input via the serial port.
Receive serial input via the input subsystem. Re-map some of the input characters to match the expectations of tomOSii.
Pass the mapped input to the vt subsystem – similar to the keyboard input, though this gets remapped in the vt subsystem.
Note
This way, the active VT receives serial input, whenever a serial console is available. This has to be separated, once true serial TTYs are implemented.
Note
This will change in the future. For now, this is a sensible place to handle/forward the serial input.