2019-12-06 23:45:04 +01:00
|
|
|
#include <kernel/devices/tty.h>
|
2020-02-24 00:05:27 +01:00
|
|
|
#include <kernel/util/string.h>
|
2019-12-02 16:48:36 +01:00
|
|
|
|
|
|
|
// Internal TTY object.
|
|
|
|
struct tty_s tty;
|
|
|
|
|
2020-02-24 23:30:49 +01:00
|
|
|
//TODO: MULTIPLE OPEN !!!!
|
|
|
|
//TODO: SHARED TTY DEVICE !!!!
|
2020-01-06 20:25:06 +01:00
|
|
|
void *tty_open(dev_t major, dev_t minor)
|
2019-12-02 16:48:36 +01:00
|
|
|
{
|
2019-12-16 16:25:13 +01:00
|
|
|
int lines;
|
|
|
|
|
2020-02-24 23:30:49 +01:00
|
|
|
// TODO: handle major / minor ?
|
|
|
|
(void)major;
|
|
|
|
(void)minor;
|
|
|
|
|
2019-12-16 16:25:13 +01:00
|
|
|
// Initialize TTY cursor.
|
2019-12-02 16:48:36 +01:00
|
|
|
tty.cursor.x = 0;
|
|
|
|
tty.cursor.y = 0;
|
2019-12-16 16:25:13 +01:00
|
|
|
tty.cursor.max.x = TTY_BUFFER_COLUMNS;
|
|
|
|
tty.cursor.max.y = TTY_BUFFER_LINES;
|
|
|
|
|
|
|
|
// Initialize TTY buffer.
|
|
|
|
// TODO: user can set dynamicaly the TTY buffer size ?
|
|
|
|
lines = TTY_BUFFER_LINES;
|
|
|
|
while (--lines >= 0)
|
|
|
|
memset(tty.buffer[lines], '\0', TTY_BUFFER_COLUMNS);
|
2020-01-06 20:25:06 +01:00
|
|
|
return (&tty);
|
2019-12-02 16:48:36 +01:00
|
|
|
}
|