tty: reading input from a tty is now handled by the line discipline

This commit is contained in:
2023-06-14 17:38:03 +01:00
parent 16d0a398b3
commit 2656696757
4 changed files with 206 additions and 10 deletions

View File

@@ -5,12 +5,14 @@
#include <socks/device.h>
#include <socks/queue.h>
#include <socks/object.h>
#include <socks/termios.h>
#include <stdint.h>
#define TTY_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_CHAR ? (dev)->chr.c_tty : NULL)
#define TTY_DRIVER(drv) ((struct tty_driver *)((char *)drv - offsetof(struct tty_driver, tty_base)))
#define TTY_INPUT_QUEUE_SIZE 256
#define TTY_LINE_MAX 4096
struct kext;
@@ -92,13 +94,14 @@ struct tty_driver {
struct tty_ldisc {
char name[OBJECT_NAME_MAX];
kern_status_t(*read)(struct device *, void *, size_t, size_t *, socks_flags_t);
void(*write)(struct device *, const struct input_event *);
};
struct tty_device {
unsigned int tty_xcells, tty_ycells;
unsigned int tty_xcur, tty_ycur;
unsigned int tty_iflag, tty_oflag, tty_lflag;
struct termios tty_config;
tty_attrib_t tty_curattrib;
enum tty_modifier_key tty_modstate;
@@ -107,6 +110,7 @@ struct tty_device {
/* input characters processed from tty_events, returned by tty_read() */
struct ringbuffer tty_input;
char *tty_linebuf;
};
extern kern_status_t tty_bootstrap(void);