BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / commit / d41a53cbc7d055b1c00cf0a339dbed6925f4f02c / drivers / tty / tty_ioctl.c

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
new file mode 100644
index 0000000..5889c66
--- /dev/null
+++ b/drivers/tty/tty_ioctl.c
@@ -0,0 +1,39 @@
+/*
+ * This file implements the TTY ioctl() backend.  It stores many of the settings
+ * which are used throughout the rest of the TTY driver.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <string.h>
+#include <termios.h>
+#include "../../vfs/vfs.h"
+
+extern Termios tty;
+
+extern int ttyW, ttyH;
+extern int vgaWidth, vgaHeight;
+
+int
+tty_ioctl(File *file, unsigned long request, uintptr_t argp)
+{
+	Termios *ts;
+	Winsize *ws;
+	switch (request) {
+	case TCGETS:
+		ts = (void *) argp;
+		memcpy(ts, &tty, sizeof(Termios));
+		return 0;
+	case TCSETS:
+		ts = (void *) argp;
+		memcpy(&tty, ts, sizeof(Termios));
+		return 0;
+	case TCGWINSZ:
+		ws = (void *) argp;
+		ws->rows = ttyH;
+		ws->cols = ttyW;
+		ws->xres = vgaWidth;
+		ws->yres = vgaHeight;
+		return 0;
+	}
+}