tty: first cut at SIGWINCH and friends
authorAlan Cox <alan@linux.intel.com>
Sat, 26 Dec 2015 23:34:35 +0000 (23:34 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 26 Dec 2015 23:34:35 +0000 (23:34 +0000)
Actually looks small enough that this would make sense for level 1.

Kernel/include/tty.h
Kernel/tty.c

index 7233fad..8e506d9 100644 (file)
@@ -145,11 +145,24 @@ struct termios {
 #define KBSETTRANS     0x23
 #define VTATTRS                0x24
 
+/* Fuzix systems to level 2 have 256 byte tty buffers as per standards, level 1
+   boxes may not */
+#if defined(CONFIG_LEVEL_2)
+#define TTYSIZ 256
+#endif
+
 /* Character Input Queue size */
 #if !defined TTYSIZ
 #define TTYSIZ 132
 #endif
 
+struct winsize {
+    unsigned short ws_row;
+    unsigned short ws_col;
+    unsigned short ws_xpixel;
+    unsigned short ws_ypixel;
+};
+
 /* Group the tty into a single object. That lets 8bit processors keep all
    the data indexed off a single register */
 struct tty {
@@ -163,6 +176,10 @@ struct tty {
 #define TTYF_DEAD      4
     uint16_t pgrp;
     struct termios termios;
+    /* TODO: For now lets work on the basis winsz is level 2 */
+#ifdef CONFIG_LEVEL_2
+    struct winsize winsize;
+#endif
 };
 
 #define CTRL(x)                ((x)&0x1F)
index 258dc43..f0ce55d 100644 (file)
@@ -231,7 +231,7 @@ int tty_ioctl(uint8_t minor, uarg_t request, char *data)
         }
        switch (request) {
        case TCGETS:
-               return uput(&ttydata[minor].termios, data, sizeof(struct termios));
+               return uput(&t->termios, data, sizeof(struct termios));
                break;
        case TCSETSF:
                clrq(&ttyinq[minor]);
@@ -240,7 +240,7 @@ int tty_ioctl(uint8_t minor, uarg_t request, char *data)
                /* We don't have an output queue really so for now drop
                   through */
        case TCSETS:
-               if (uget(data, &ttydata[minor].termios, sizeof(struct termios)) == -1)
+               if (uget(data, &t->termios, sizeof(struct termios)) == -1)
                        return -1;
                 tty_setup(minor);
                break;
@@ -258,6 +258,15 @@ int tty_ioctl(uint8_t minor, uarg_t request, char *data)
        case TIOCOSTART:
                t->flag &= ~TTYF_STOP;
                break;
+#ifdef CONFIG_LEVEL_2
+        case TIOCGWINSZ:
+                return uput(&t->winsize, data, sizeof(struct winsize));
+        case TIOCSWINSZ:
+                if (uget(&t->winsize, data, sizeof(struct winsize)))
+                        return -1;
+                sgrpsig(t->pgrp, SIGWINCH);
+                return 0;
+#endif
        default:
                udata.u_error = ENOTTY;
                return (-1);