I/O operations

To use the functions described in this page, the file <hal.h> should be included.

Output to the screen

JSLK currently only supports outputting to the screen in text mode, through a 24x80 map. A line is not considered because of the menu bar. The console is started by the kernel entrypoint, in x86 this is done through the startConsole() function defined in vga.c.

int kprintf(string c, ...)

Used to print a formatted string to the console.

Arguments

string c: The string to be printed. Use special characters in string to interpolate values.

Optional arguments: The values to be interpolated (in the order specified in the string).

Special characters

%i: Decimal number.

%s: String.

%h: Hexadecimal number.

Return value

Returns 0 if successful.

void setConsoleColor(uint8_t color)

Used to change the console color. clear_console() must be called to apply changes to the whole console.

Arguments

uint8_t color: The color of the text to be printed. A color value can be obtained through the getColor() function.

Return value

This function has no return value.

Input from the keyboard

Although there is a keyboard driver provided, there is currently no way of interfacing with it without the need to write auxiliary code. Currently, all input from the keyboard is printed to the screen, and there is one function that will indicate if the enter key was pressed (read_key()), although it was just written for testing purposes and will be removed in the future. If you are in need to use the keyboard, feel free to write your own interface until one is added in a future release.

File I/O

The VFS

I/O with other hardware

The following functions can be used to interface with ports.

void outb(uint16_t port, uint8_t value)

Used to send a byte to a specific port.

Arguments

uint16_t port: The port to send the byte to.

uint8_t value: The value to be sent.

Return value

This function has no return value.

Last updated