aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-19 23:08:13 -0400
committerIan Moffett <ian@osmora.org>2024-05-19 23:15:19 -0400
commit519eb6b79c76864508e2d51e0e3cb5be2d0f36e1 (patch)
treebfa47adb3c02e3f16107a5a5973f76e9e62f7794
parent2da0120af12cda00194522d04b50edf2f2166382 (diff)
kernel: tty: Define TTY open hook
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/kern/kern_tty.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/kern/kern_tty.c b/sys/kern/kern_tty.c
index 5c060a4..f8a4877 100644
--- a/sys/kern/kern_tty.c
+++ b/sys/kern/kern_tty.c
@@ -174,6 +174,20 @@ tty_ioctl(struct device *dev, uint32_t cmd, uintptr_t arg)
return 0;
}
+static int
+tty_open(struct device *dev)
+{
+ /* TODO: Support multiple TTYs */
+ struct tty *tty = &g_root_tty;
+ struct tty_ring *ring = &tty->outring;
+
+ /* Ensure the ring is clean */
+ spinlock_acquire(&tty->rlock);
+ tty_reset_ring(ring);
+ spinlock_release(&tty->rlock);
+ return 0;
+}
+
/*
* Serialized wrapper over __tty_flush()
*/
@@ -286,6 +300,7 @@ tty_attach(struct tty *tty)
dev->read = tty_dev_read;
dev->ioctl = tty_ioctl;
+ dev->open = tty_open;
dev->blocksize = 1;
snprintf(devname, sizeof(devname), "tty%d", tty->id);