From bf8704b63d6df9ddfd5b0aa468dfa5404ea40f6f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 26 Dec 2015 23:34:35 +0000 Subject: [PATCH] tty: first cut at SIGWINCH and friends Actually looks small enough that this would make sense for level 1. --- Kernel/include/tty.h | 17 +++++++++++++++++ Kernel/tty.c | 13 +++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Kernel/include/tty.h b/Kernel/include/tty.h index 7233fadf..8e506d9b 100644 --- a/Kernel/include/tty.h +++ b/Kernel/include/tty.h @@ -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) diff --git a/Kernel/tty.c b/Kernel/tty.c index 258dc437..f0ce55dc 100644 --- a/Kernel/tty.c +++ b/Kernel/tty.c @@ -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); -- 2.34.1