Console
Description
The console driver is used to display text on the screen when operating in text mode. Using the VGA text framebuffer, you have to implement the write() syscall. It is as superset of the serial interface, the escapes codes must not be sent to the serial.
Syscall interface
NAME
write - writes to the console and the serial
SYNOPSIS
int write(const char *buf, size_t count);
DESCRIPTION
write() writes up to count bytes to the screen from the buffer starting at buf.
RETURN VALUE
write() returns the number of bytes written on the console (zero indicates nothing was written).
NOTES
write() is available in text mode only.
It is possible to affect the console in different ways by using particular character codes. To start
a special command sequence, send a character <CONS ESCAPE>, and then send:
<CONS CLEAR>
Clear the console.
<CONS COLOR><color>
Set the current color to color.
<CONS SETY><line number>
Set the current line to line number.
<CONS SETX><column number>
Set the current column to column number.
SEE ALSO
Useful constants are defined in k/kstd.h
Recommended methodology
- Write a function which clears the screen
- Write a function which initializes the console manager:
- set cursor position at (0,0)
- set current attributes to white text over a black background
- clear the screen
- Write a function which sets console attributes
- Write a function which displays a character:
- display the given character with current attributes at current cursor position
- update the cursor position
- Write a function which displays a string
- Implement write() as described in the console syscall interface
Notes
- ‘\r’ means CR
- ‘\n’ means CR+LF
- ‘\t’ is a 8-spaces tabulation