tty: implement read/write support

This commit is contained in:
2023-06-11 09:23:57 +01:00
parent 557e1dda30
commit abe4af093e
9 changed files with 124 additions and 14 deletions

View File

@@ -7,6 +7,9 @@
#include <socks/object.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)))
struct kext;
/* The TTY system.
@@ -82,9 +85,10 @@ struct tty_device {
unsigned int tty_xcells, tty_ycells;
unsigned int tty_xcur, tty_ycur;
unsigned int tty_iflag, tty_oflag, tty_lflag;
tty_attrib_t tty_curattrib;
};
extern kern_status_t tty_init(void);
extern kern_status_t tty_bootstrap(void);
extern struct device *tty_device_create(void);
extern kern_status_t tty_device_register(struct device *dev, struct tty_driver *owner, struct device *parent);
@@ -98,6 +102,9 @@ static inline struct driver *tty_driver_base(struct tty_driver *drv)
return &drv->tty_base;
}
extern kern_status_t tty_read(struct device *tty, void *buf, size_t max, size_t *nr_read, socks_flags_t flags);
extern kern_status_t tty_write(struct device *tty, const void *buf, size_t len, size_t *nr_written, socks_flags_t flags);
#ifdef __cplusplus
}
#endif