Patchkit 0.2 changed the way the device select interface worked,
which broke, among other things, the standard com driver. This patch
will fix this and cure the symptom where the XFree86 server loops
continuously, eating CPU time. The code for comselect was lifted
straight from Chris Demetriou's (cgd@agate.berkeley.edu) multiport
serial driver.
AUTHOR: Jordan K. Hubbard (jkh@whisker.lotus.ie) & Chris Demetriou
386BSD-Patchkit: patch00079
* SUCH DAMAGE.
*
* @(#)conf.c 5.8 (Berkeley) 5/12/91
* SUCH DAMAGE.
*
* @(#)conf.c 5.8 (Berkeley) 5/12/91
+ *
+ * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
+ * -------------------- ----- ----------------------
+ * CURRENT PATCH LEVEL: 1 00079
+ * -------------------- ----- ----------------------
+ *
+ * 10 Feb 93 Jordan K. Hubbard Added select entry for com driver
*/
static char rcsid[] = "$Header: /usr/src/sys.386bsd/i386/i386/RCS/conf.c,v 1.2 92/01/21 14:21:57 william Exp Locker: toor $";
*/
static char rcsid[] = "$Header: /usr/src/sys.386bsd/i386/i386/RCS/conf.c,v 1.2 92/01/21 14:21:57 william Exp Locker: toor $";
#include "com.h"
#if NCOM > 0
#include "com.h"
#if NCOM > 0
-int comopen(),comclose(),comread(),comwrite(),comioctl();
+int comopen(),comclose(),comread(),comwrite(),comioctl(),comselect();
#define comreset enxio
extern struct tty com_tty[];
#else
#define comreset enxio
extern struct tty com_tty[];
#else
#define comwrite enxio
#define comioctl enxio
#define comreset enxio
#define comwrite enxio
#define comioctl enxio
#define comreset enxio
#define com_tty NULL
#endif
#define com_tty NULL
#endif
logselect, enodev, NULL },
{ comopen, comclose, comread, comwrite, /*8*/
comioctl, enodev, comreset, com_tty,
logselect, enodev, NULL },
{ comopen, comclose, comread, comwrite, /*8*/
comioctl, enodev, comreset, com_tty,
- ttselect, enodev, NULL },
+ comselect, enodev, NULL },
{ Fdopen, fdclose, rawread, rawwrite, /*9*/
fdioctl, enodev, nullop, NULL,
seltrue, enodev, fdstrategy },
{ Fdopen, fdclose, rawread, rawwrite, /*9*/
fdioctl, enodev, nullop, NULL,
seltrue, enodev, fdstrategy },
*
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
*
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
- * CURRENT PATCH LEVEL: 3 00045
+ * CURRENT PATCH LEVEL: 4 00079
* -------------------- ----- ----------------------
*
* 23 Sep 92 Rodney W. Grimes Fix SILO overflow on 16550 UARTS
* 30 Aug 92 Poul-Henning Kamp Stabilize SLIP on lossy lines/UARTS
* 09 Aug 92 Christoph Robitschko Correct minor number on com ports
* -------------------- ----- ----------------------
*
* 23 Sep 92 Rodney W. Grimes Fix SILO overflow on 16550 UARTS
* 30 Aug 92 Poul-Henning Kamp Stabilize SLIP on lossy lines/UARTS
* 09 Aug 92 Christoph Robitschko Correct minor number on com ports
+ * 10 Feb 93 Jordan K. Hubbard Added select code
*/
static char rcsid[] = "$Header: /usr/bill/working/sys/i386/isa/RCS/com.c,v 1.2 92/01/21 14:34:11 william Exp $";
*/
static char rcsid[] = "$Header: /usr/bill/working/sys/i386/isa/RCS/com.c,v 1.2 92/01/21 14:34:11 william Exp $";
+
+int
+comselect(dev, rw, p)
+ dev_t dev;
+ int rw;
+ struct proc *p;
+{
+ register struct tty *tp = &com_tty[UNIT(dev)];
+ int nread;
+ int s = spltty();
+ struct proc *selp;
+
+ switch (rw) {
+
+ case FREAD:
+ nread = ttnread(tp);
+ if (nread > 0 ||
+ ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0))
+ goto win;
+ if (tp->t_rsel && (selp = pfind(tp->t_rsel)) && selp->p_wchan == (caddr_t)&selwait)
+ tp->t_state |= TS_RCOLL;
+ else
+ tp->t_rsel = p->p_pid;
+ break;
+
+ case FWRITE:
+ if (RB_LEN(&tp->t_out) <= tp->t_lowat)
+ goto win;
+ if (tp->t_wsel && (selp = pfind(tp->t_wsel)) && selp->p_wchan == (caddr_t)&selwait)
+ tp->t_state |= TS_WCOLL;
+ else
+ tp->t_wsel = p->p_pid;
+ break;
+ }
+ splx(s);
+ return (0);
+ win:
+ splx(s);
+ return (1);
+}