From owner-svn-src-head@FreeBSD.ORG Sat Nov 3 22:21:38 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7C85199F; Sat, 3 Nov 2012 22:21:38 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 639418FC0C; Sat, 3 Nov 2012 22:21:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id qA3MLcRB056261; Sat, 3 Nov 2012 22:21:38 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id qA3MLcVX056256; Sat, 3 Nov 2012 22:21:38 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201211032221.qA3MLcVX056256@svn.freebsd.org> From: Ed Schouten Date: Sat, 3 Nov 2012 22:21:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242529 - in head/sys: dev/syscons kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2012 22:21:38 -0000 Author: ed Date: Sat Nov 3 22:21:37 2012 New Revision: 242529 URL: http://svn.freebsd.org/changeset/base/242529 Log: Add tty_set_winsize(). This removes some of the signalling magic from the Syscons driver and puts it in the TTY layer, where it belongs. Modified: head/sys/dev/syscons/scvidctl.c head/sys/kern/tty.c head/sys/sys/tty.h Modified: head/sys/dev/syscons/scvidctl.c ============================================================================== --- head/sys/dev/syscons/scvidctl.c Sat Nov 3 22:13:42 2012 (r242528) +++ head/sys/dev/syscons/scvidctl.c Sat Nov 3 22:21:37 2012 (r242529) @@ -137,6 +137,7 @@ sc_set_text_mode(scr_stat *scp, struct t int fontsize, int fontwidth) { video_info_t info; + struct winsize wsz; u_char *font; int prev_ysize; int error; @@ -234,16 +235,9 @@ sc_set_text_mode(scr_stat *scp, struct t if (tp == NULL) return 0; - DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n", - tp->t_winsize.ws_col, tp->t_winsize.ws_row, scp->xsize, scp->ysize)); - if (tp->t_winsize.ws_col != scp->xsize - || tp->t_winsize.ws_row != scp->ysize) { - tp->t_winsize.ws_col = scp->xsize; - tp->t_winsize.ws_row = scp->ysize; - - tty_signal_pgrp(tp, SIGWINCH); - } - + wsz.ws_col = scp->xsize; + wsz.ws_row = scp->ysize; + tty_set_winsize(tp, &wsz); return 0; } @@ -254,6 +248,7 @@ sc_set_graphics_mode(scr_stat *scp, stru return ENODEV; #else video_info_t info; + struct winsize wsz; int error; int s; @@ -300,14 +295,9 @@ sc_set_graphics_mode(scr_stat *scp, stru if (tp == NULL) return 0; - if (tp->t_winsize.ws_xpixel != scp->xpixel - || tp->t_winsize.ws_ypixel != scp->ypixel) { - tp->t_winsize.ws_xpixel = scp->xpixel; - tp->t_winsize.ws_ypixel = scp->ypixel; - - tty_signal_pgrp(tp, SIGWINCH); - } - + wsz.ws_col = scp->xsize; + wsz.ws_row = scp->ysize; + tty_set_winsize(tp, &wsz); return 0; #endif /* SC_NO_MODE_CHANGE */ } @@ -320,7 +310,7 @@ sc_set_pixel_mode(scr_stat *scp, struct return ENODEV; #else video_info_t info; - ksiginfo_t ksi; + struct winsize wsz; u_char *font; int prev_ysize; int error; @@ -425,20 +415,9 @@ sc_set_pixel_mode(scr_stat *scp, struct if (tp == NULL) return 0; - if (tp->t_winsize.ws_col != scp->xsize - || tp->t_winsize.ws_row != scp->ysize) { - tp->t_winsize.ws_col = scp->xsize; - tp->t_winsize.ws_row = scp->ysize; - if (tp->t_pgrp != NULL) { - ksiginfo_init(&ksi); - ksi.ksi_signo = SIGWINCH; - ksi.ksi_code = SI_KERNEL; - PGRP_LOCK(tp->t_pgrp); - pgsignal(tp->t_pgrp, SIGWINCH, 1, &ksi); - PGRP_UNLOCK(tp->t_pgrp); - } - } - + wsz.ws_col = scp->xsize; + wsz.ws_row = scp->ysize; + tty_set_winsize(tp, &wsz); return 0; #endif /* SC_PIXEL_MODE */ } Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Sat Nov 3 22:13:42 2012 (r242528) +++ head/sys/kern/tty.c Sat Nov 3 22:21:37 2012 (r242529) @@ -1381,6 +1381,16 @@ tty_flush(struct tty *tp, int flags) } } +void +tty_set_winsize(struct tty *tp, const struct winsize *wsz) +{ + + if (memcmp(&tp->t_winsize, wsz, sizeof(*wsz)) == 0) + return; + tp->t_winsize = *wsz; + tty_signal_pgrp(tp, SIGWINCH); +} + static int tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td) @@ -1689,10 +1699,7 @@ tty_generic_ioctl(struct tty *tp, u_long return (0); case TIOCSWINSZ: /* Set window size. */ - if (bcmp(&tp->t_winsize, data, sizeof(struct winsize)) == 0) - return (0); - tp->t_winsize = *(struct winsize*)data; - tty_signal_pgrp(tp, SIGWINCH); + tty_set_winsize(tp, data); return (0); case TIOCEXCL: tp->t_flags |= TF_EXCLUDE; Modified: head/sys/sys/tty.h ============================================================================== --- head/sys/sys/tty.h Sat Nov 3 22:13:42 2012 (r242528) +++ head/sys/sys/tty.h Sat Nov 3 22:21:37 2012 (r242529) @@ -192,6 +192,7 @@ int tty_ioctl(struct tty *tp, u_long cmd struct thread *td); int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data, int fflag, struct thread *td); +void tty_set_winsize(struct tty *tp, const struct winsize *wsz); void tty_init_console(struct tty *tp, speed_t speed); void tty_flush(struct tty *tp, int flags); void tty_hiwat_in_block(struct tty *tp);