Basic Console Frontend

The basic console frontend is implemented in os/drivers/console/basic_console.c.

This console frontend 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 sreen, like, e.g., printk. For output to the screen it uses the console backend that has been registered to the console subsystem, beforehand.

Initialization

This driver is initialized by calling

void basic_console_init(void)

Initialize the console frontend.

^ Back to top.

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.

Returns:

A pointer to the newly allocated console.

^ Back to top.

Console Operations

This frontend implements the console operation:

Write

Implements

void (*write)(console_t *console, const char *string, unsigned int count)

Write count characters from string to console.

of struct console_operations_t (documentation):

static void __basic_con_write(console_t *con, const char *string, unsigned int count)

Write count characters of a string to the console con.

Output printable characters but also handle (some) control characters, e.g., neline, backspace, form feed. The cursor is moved accordingly.

^ Back to top.

Helper Functions

This frontend uses helper functions to wrap some of the tasks handled by the write operation:

static void __basic_con_backspace(console_t *con)

Handle a backspace on the console con.

static void __basic_con_check_scroll(console_t *con)

Check if console con needs to be scrolled.

static void __basic_con_form_feed(console_t *con)

Perform a form feed on the console con.

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 c to the console con.