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.

^ 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. 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.

^ Back to top.

Console Operations

This console implements the console operations (console_operations_t)

Open

Implements the operation console_operations_t.open:

static int __basic_con_open(console_t *con)

Open the basic console con.

^ Back to top.

Write

Implements the operation console_operations_t.write:

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., newline, backspace, form feed. The respective output code is wrapped into separate functions. The cursor is moved accordingly.

^ Back to top.

Helper Functions

This console 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.