2019-12-02 16:48:36 +01:00
|
|
|
#ifndef __KERNEL_TTY_H__
|
|
|
|
# define __KERNEL_TTY_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2020-02-25 23:28:14 +01:00
|
|
|
#include <kernel/drivers/screen.h>
|
2020-02-24 00:05:27 +01:00
|
|
|
#include <kernel/util/types.h>
|
2020-02-25 23:28:14 +01:00
|
|
|
#include <kernel/util/draw.h>
|
2019-12-16 16:25:13 +01:00
|
|
|
|
|
|
|
// Define default buffer size.
|
|
|
|
// TODO: remove me ?
|
2019-12-20 11:31:34 +01:00
|
|
|
#define TTY_BUFFER_LINES (DISPLAY_VCHAR_MAX * 3)
|
|
|
|
#define TTY_BUFFER_COLUMNS (DISPLAY_HCHAR_MAX)
|
2019-12-02 16:48:36 +01:00
|
|
|
|
2020-01-06 20:25:06 +01:00
|
|
|
// Define TTY major
|
|
|
|
#define TTY_DEV_MAJOR (4)
|
|
|
|
|
2019-12-02 16:48:36 +01:00
|
|
|
struct tty_s
|
|
|
|
{
|
2019-12-20 11:31:34 +01:00
|
|
|
char buffer[TTY_BUFFER_LINES + 1][TTY_BUFFER_COLUMNS + 1];
|
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;
|
2020-02-24 23:30:49 +01:00
|
|
|
|
|
|
|
/*struct {
|
2019-12-16 16:25:13 +01:00
|
|
|
ssize_t (*write)(const void *buffer, size_t count);
|
|
|
|
ssize_t (*read)(void *buffer, size_t count);
|
2020-02-24 23:30:49 +01:00
|
|
|
} primitives;*/
|
2019-12-16 16:25:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// internal strct used by the TTY read primitives
|
|
|
|
// TODO: Move me ?
|
2020-02-24 23:30:49 +01:00
|
|
|
// TODO: Add internal keyboard buffer !!!
|
2019-12-16 16:25:13 +01:00
|
|
|
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;
|
2020-02-25 23:28:14 +01:00
|
|
|
|
|
|
|
// FIXME Dirty place, remove / move me !
|
|
|
|
struct tty_s *tty;
|
2019-12-02 16:48:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// primitives.
|
2020-01-06 20:25:06 +01:00
|
|
|
extern void *tty_open(dev_t major, dev_t minor);
|
|
|
|
extern ssize_t tty_write(void *inode, const void *buffer, size_t count);
|
|
|
|
extern ssize_t tty_read(void *inode, void *buffer, size_t count);
|
|
|
|
extern int tty_close(void *inode);
|
2019-12-02 16:48:36 +01:00
|
|
|
|
2019-12-20 11:31:34 +01:00
|
|
|
// IOCTL.
|
|
|
|
#define TTY_IOCTL_GETDX (0x00)
|
|
|
|
#define TTY_IOCTL_GETDY (0x01)
|
2020-01-06 20:25:06 +01:00
|
|
|
extern void tty_ioctl(void *inode, uint32_t cmd, ...);
|
2019-12-20 11:31:34 +01:00
|
|
|
|
2019-12-02 16:48:36 +01:00
|
|
|
#endif /*__KERNEL_TTY_H__*/
|