From 9545a0eaa495284d00e773c17bb9981265e162dc Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Tue, 10 Sep 1996 19:14:49 +0000 Subject: [PATCH] Hack workaround XFree86 switching failure when used with /dev/sysmouse and xdm, possibly in general. What was happening was that the server was doing a tcsetattr(.. TCSADRAIN) on the mouse fd after a write. Since /dev/sysmouse had a null t_oproc, the drain failed with EIO. Somehow this spammed XFree86 (!@&^#%*& binary release!!), and the driver was left in a bogus state (ie: switch_in_progress permanently TRUE). The simplest way out was to implement a dummy scmousestart() routine to accept any characters from the tty system and toss them into the void. It would probably be more correct to intercept scwrite()'s to the mouse device, but that's executed for every single write to the screen. Supplying a start routine to eat the characters is only executed for the mouse port during startup/shutdown, so it should be faster. --- sys/dev/syscons/syscons.c | 25 +++++++++++++++++++++++-- sys/i386/isa/syscons.c | 25 +++++++++++++++++++++++-- sys/isa/syscons.c | 25 +++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index e2651b6b764..533596d045b 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.168 1996/09/08 21:31:56 sos Exp $ + * $Id: syscons.c,v 1.169 1996/09/09 19:02:26 sos Exp $ */ #include "sc.h" @@ -164,6 +164,7 @@ static int scattach(struct isa_device *dev); static int scparam(struct tty *tp, struct termios *t); static int scprobe(struct isa_device *dev); static void scstart(struct tty *tp); +static void scmousestart(struct tty *tp); static void scinit(void); static u_int scgetc(int noblock); static scr_stat *get_scr_stat(dev_t dev); @@ -519,7 +520,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -1338,6 +1339,26 @@ scstart(struct tty *tp) splx(s); } +static void +scmousestart(struct tty *tp) +{ + struct clist *rbp; + int s; + u_char buf[PCBURST]; + + s = spltty(); + if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { + tp->t_state |= TS_BUSY; + rbp = &tp->t_outq; + while (rbp->c_cc) { + q_to_b(rbp, buf, PCBURST); + } + tp->t_state &= ~TS_BUSY; + ttwwakeup(tp); + } + splx(s); +} + void sccnprobe(struct consdev *cp) { diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index e2651b6b764..533596d045b 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.168 1996/09/08 21:31:56 sos Exp $ + * $Id: syscons.c,v 1.169 1996/09/09 19:02:26 sos Exp $ */ #include "sc.h" @@ -164,6 +164,7 @@ static int scattach(struct isa_device *dev); static int scparam(struct tty *tp, struct termios *t); static int scprobe(struct isa_device *dev); static void scstart(struct tty *tp); +static void scmousestart(struct tty *tp); static void scinit(void); static u_int scgetc(int noblock); static scr_stat *get_scr_stat(dev_t dev); @@ -519,7 +520,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -1338,6 +1339,26 @@ scstart(struct tty *tp) splx(s); } +static void +scmousestart(struct tty *tp) +{ + struct clist *rbp; + int s; + u_char buf[PCBURST]; + + s = spltty(); + if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { + tp->t_state |= TS_BUSY; + rbp = &tp->t_outq; + while (rbp->c_cc) { + q_to_b(rbp, buf, PCBURST); + } + tp->t_state &= ~TS_BUSY; + ttwwakeup(tp); + } + splx(s); +} + void sccnprobe(struct consdev *cp) { diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index e2651b6b764..533596d045b 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.168 1996/09/08 21:31:56 sos Exp $ + * $Id: syscons.c,v 1.169 1996/09/09 19:02:26 sos Exp $ */ #include "sc.h" @@ -164,6 +164,7 @@ static int scattach(struct isa_device *dev); static int scparam(struct tty *tp, struct termios *t); static int scprobe(struct isa_device *dev); static void scstart(struct tty *tp); +static void scmousestart(struct tty *tp); static void scinit(void); static u_int scgetc(int noblock); static scr_stat *get_scr_stat(dev_t dev); @@ -519,7 +520,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -1338,6 +1339,26 @@ scstart(struct tty *tp) splx(s); } +static void +scmousestart(struct tty *tp) +{ + struct clist *rbp; + int s; + u_char buf[PCBURST]; + + s = spltty(); + if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { + tp->t_state |= TS_BUSY; + rbp = &tp->t_outq; + while (rbp->c_cc) { + q_to_b(rbp, buf, PCBURST); + } + tp->t_state &= ~TS_BUSY; + ttwwakeup(tp); + } + splx(s); +} + void sccnprobe(struct consdev *cp) {