2019-12-02 16:48:36 +01:00
|
|
|
#ifndef __KERNEL_TTY_H__
|
|
|
|
# define __KERNEL_TTY_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2019-12-16 16:25:13 +01:00
|
|
|
#include <kernel/devices/display.h>
|
|
|
|
#include <kernel/types.h>
|
|
|
|
|
|
|
|
// Define default buffer size.
|
|
|
|
// TODO: remove me ?
|
|
|
|
#define TTY_BUFFER_LINES (DISPLAY_SCREEN_WIDTH * 3)
|
|
|
|
#define TTY_BUFFER_COLUMNS (DISPLAY_SCREEN_HEIGHT)
|
2019-12-02 16:48:36 +01:00
|
|
|
|
|
|
|
struct tty_s
|
|
|
|
{
|
2019-12-16 16:25:13 +01:00
|
|
|
char buffer[TTY_BUFFER_LINES][TTY_BUFFER_COLUMNS];
|
2019-12-02 16:48:36 +01:00
|
|
|
struct {
|
2019-12-16 16:25:13 +01:00
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
2019-12-02 16:48:36 +01:00
|
|
|
struct {
|
2019-12-16 16:25:13 +01:00
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
2019-12-02 16:48:36 +01:00
|
|
|
} max;
|
|
|
|
} cursor;
|
2019-12-16 16:25:13 +01:00
|
|
|
struct {
|
|
|
|
ssize_t (*write)(const void *buffer, size_t count);
|
|
|
|
ssize_t (*read)(void *buffer, size_t count);
|
|
|
|
} primitives;
|
|
|
|
};
|
|
|
|
|
|
|
|
// internal strct used by the TTY read primitives
|
|
|
|
// TODO: Move me ?
|
|
|
|
struct keyboard_obj_s
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
uint8_t *addr;
|
|
|
|
size_t size;
|
|
|
|
size_t clen;
|
|
|
|
off_t cursor;
|
|
|
|
} buffer;
|
|
|
|
uint8_t mode;
|
|
|
|
uint8_t cvisible;
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
|
|
|
} cursor;
|
|
|
|
} tty;
|
|
|
|
} saved;
|
2019-12-02 16:48:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// primitives.
|
|
|
|
extern int tty_open(void);
|
2019-12-16 16:25:13 +01:00
|
|
|
extern ssize_t tty_write(const void *buffer, size_t count);
|
|
|
|
extern ssize_t tty_read(void *buffer, size_t count);
|
2019-12-02 16:48:36 +01:00
|
|
|
extern int tty_close(void);
|
|
|
|
|
|
|
|
#endif /*__KERNEL_TTY_H__*/
|