From 482a38725d4e1d9b5aee18e2b2d5af3d0b0e54e9 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 19 May 2024 19:10:35 -0400 Subject: kernel: tty: Implement tty_ioctl() Signed-off-by: Ian Moffett --- sys/kern/kern_tty.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_tty.c b/sys/kern/kern_tty.c index cb3e30a..5c060a4 100644 --- a/sys/kern/kern_tty.c +++ b/sys/kern/kern_tty.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -153,6 +154,26 @@ tty_dev_read(struct device *dev, struct sio_txn *sio) return len; } +static int +tty_ioctl(struct device *dev, uint32_t cmd, uintptr_t arg) +{ + /* TODO: Support multiple TTYs */ + struct termios *tp = &g_root_tty.termios; + + switch (cmd) { + case TCGETS: + copyout(tp, arg, sizeof(struct termios)); + break; + case TCSETS: + copyin(arg, tp, sizeof(struct termios)); + break; + default: + return -EINVAL; + } + + return 0; +} + /* * Serialized wrapper over __tty_flush() */ @@ -264,6 +285,7 @@ tty_attach(struct tty *tty) return tmp; dev->read = tty_dev_read; + dev->ioctl = tty_ioctl; dev->blocksize = 1; snprintf(devname, sizeof(devname), "tty%d", tty->id); -- cgit v1.2.3