From ed31f8283ca62f550da28456bc190250d6495815 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 18 May 2024 22:54:14 -0400 Subject: kernel: tty: Handle input processing better - Fix copying logic in tty_read() - Handle ICANON correctly - Add ECHO c_lflag bit - Add TTY_SOURCE_DEV and TTY_SOURCE_RAW defines Signed-off-by: Ian Moffett --- sys/include/sys/termios.h | 1 + sys/include/sys/tty.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/include') diff --git a/sys/include/sys/termios.h b/sys/include/sys/termios.h index 963c885..1fda67e 100644 --- a/sys/include/sys/termios.h +++ b/sys/include/sys/termios.h @@ -50,6 +50,7 @@ * Local flags */ #define ICANON 0x00000001U +#define ECHO 0x00000002U typedef uint32_t tcflag_t; typedef uint32_t speed_t; diff --git a/sys/include/sys/tty.h b/sys/include/sys/tty.h index c53ea73..342a1a7 100644 --- a/sys/include/sys/tty.h +++ b/sys/include/sys/tty.h @@ -38,6 +38,9 @@ #define TTY_RING_SIZE 32 +#define TTY_SOURCE_RAW 0x0001U /* Raw text */ +#define TTY_SOURCE_DEV 0x0002U /* Input from device (e.g keyboard) */ + struct tty_ring { char data[TTY_RING_SIZE]; /* Ring data */ off_t enq_index; /* Enqueue index */ @@ -48,6 +51,7 @@ struct tty { dev_t id; struct vcons_screen *scr; /* Console screen */ struct tty_ring ring; /* Input ring */ + struct tty_ring outring; /* Output ring */ struct spinlock rlock; /* Ring lock */ struct termios termios; /* Termios structure */ struct device *dev; /* Device pointer */ @@ -56,7 +60,7 @@ struct tty { extern struct tty g_root_tty; dev_t tty_attach(struct tty *tty); -int tty_putc(struct tty *tty, int c); +int tty_putc(struct tty *tty, int c, int flags); int tty_putstr(struct tty *tty, const char *s, size_t count); ssize_t tty_flush(struct tty *tty); -- cgit v1.2.3