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, ...)
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.
int cprintf(string c, uint8_t color, ...)
int cprintf(string c, uint8_t color, ...)Used to print a formatted rich-text string to the console.
Arguments
string c: The string to be printed. Use special characters in string to interpolate values.
uint8_t color: The color of the text to be printed. A color value can be obtained through the getColor() function.
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 consolePutChar(char c, uint8_t color, size_t x, size_t y);
void consolePutChar(char c, uint8_t color, size_t x, size_t y);Used to print a character to the console on the specified position.
Arguments
char c: The character to be printed.
uint8_t color: The color of the text to be printed. A color value can be obtained through the getColor() function.
size_t x: The x position of the character coordinate.
size_t y: The y position of the character coordinate.
Return value
This function has no return value.
void setConsoleColor(uint8_t color)
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.
uint8_t getColor(vga_color text, vga_color background)
uint8_t getColor(vga_color text, vga_color background)Used to get a console compatible color.
Special Types
vga_color: One of the sixteen possible VGA colors.
// ...
enum vga_color_t
{
vga_black = 0,
vga_blue = 1,
vga_green = 2,
vga_cyan = 3,
vga_red = 4,
vga_magenta = 5,
vga_brown = 6,
vga_light_grey = 7,
vga_grey = 8,
vga_light_blue = 9,
vga_light_green = 10,
vga_light_cyan = 11,
vga_light_red = 12,
vga_light_magenta = 13,
vga_light_brown = 14,
vga_white = 15,
};
// ...
Arguments
vga_color text: Text color in the console (foreground).
vga_color background: Console's background color.
Optional arguments: The values to be interpolated (in the order specified in the string).
Return value
Returns a console compatible color value in a uint8_t.
Sample usage
uint8_t color = getColor(vga_grey, vga_black); // Get a color value to use later
setConsoleColor(color); // Example of how you could use the obtained valueInput 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
I/O with other hardware
The following functions can be used to interface with ports.
Last updated
Was this helpful?