I had the problem with select() not working on com ports. I got no
response from a post regarding this one, so I started to look into it
myself. I found out that the com driver calculates unit = minor(dev) -1;
This has the following implications:
/dev/com1 corresponds to COM0, /dev/com2 to COM1 (very confusing
in kernel messages)
It is incompatible with the config file entries com1 at..., com2 at...
Unpredictible results will occur if someone puts a com0 at.. in
his config file.
It is incompatible with the DOS usage of COM1, COM2 (But who cares 8-)
ttselect() calculates unit = minor(dev), and uses this as an index in
com_tty. Because this index is different from that used
in the com driver, select() on /dev/com1 looks at
/dev/com2 and select() on /dev/com2 looks at an undefined
entry in com_tty and returns always true.
WARNING: RE-mknod /dev/com1, /dev/com2, and modify your kernel config!
AUTHOR: Christoph Robitschko (chmr@fstgds01.tu-graz.ac.at)
386BSD-Patchkit: patch00018
* SUCH DAMAGE.
*
* @(#)com.c 7.5 (Berkeley) 5/16/91
* SUCH DAMAGE.
*
* @(#)com.c 7.5 (Berkeley) 5/16/91
+ *
+ * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
+ * -------------------- ----- ----------------------
+ * CURRENT PATCH LEVEL: 1 00018
+ * -------------------- ----- ----------------------
+ *
+ * 09 Aug 92 Christoph Robitschko Correct minor number on com ports
*/
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 $";
extern int kgdb_debug_init;
#endif
extern int kgdb_debug_init;
#endif
-#define UNIT(x) (minor(x)-1)
+#define UNIT(x) (minor(x))
comprobe(dev)
struct isa_device *dev;
comprobe(dev)
struct isa_device *dev;
u_char unit;
int port = isdp->id_iobase;
u_char unit;
int port = isdp->id_iobase;
- unit = isdp->id_unit - 1;
if (unit == comconsole)
DELAY(1000);
com_addr[unit] = port;
if (unit == comconsole)
DELAY(1000);
com_addr[unit] = port;
outb(port+com_ier, 0);
outb(port+com_mcr, 0 | MCR_IENABLE);
#ifdef KGDB
outb(port+com_ier, 0);
outb(port+com_mcr, 0 | MCR_IENABLE);
#ifdef KGDB
- if (kgdb_dev == makedev(commajor, unit+1)) {
+ if (kgdb_dev == makedev(commajor, unit)) {
if (comconsole == unit)
kgdb_dev = -1; /* can't debug over console port */
else {
if (comconsole == unit)
kgdb_dev = -1; /* can't debug over console port */
else {
outb(com+com_cfcr, inb(com+com_cfcr) & ~CFCR_SBREAK);
#ifdef KGDB
/* do not disable interrupts if debugging */
outb(com+com_cfcr, inb(com+com_cfcr) & ~CFCR_SBREAK);
#ifdef KGDB
/* do not disable interrupts if debugging */
- if (kgdb_dev != makedev(commajor, unit+1))
+ if (kgdb_dev != makedev(commajor, unit))
#endif
outb(com+com_ier, 0);
if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
#endif
outb(com+com_ier, 0);
if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
register u_char code;
register struct tty *tp;
register u_char code;
register struct tty *tp;
com = com_addr[unit];
while (1) {
code = inb(com+com_iir);
com = com_addr[unit];
while (1) {
code = inb(com+com_iir);
#define RCVBYTE() \
code = inb(com+com_data); \
if ((tp->t_state & TS_ISOPEN) == 0) { \
#define RCVBYTE() \
code = inb(com+com_data); \
if ((tp->t_state & TS_ISOPEN) == 0) { \
- if (kgdb_dev == makedev(commajor, unit+1) && \
+ if (kgdb_dev == makedev(commajor, unit) && \
code == FRAME_END) \
kgdb_connect(0); /* trap into kgdb */ \
} else \
code == FRAME_END) \
kgdb_connect(0); /* trap into kgdb */ \
} else \
#ifdef KGDB
/* we don't care about parity errors */
if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) &&
#ifdef KGDB
/* we don't care about parity errors */
if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) &&
- kgdb_dev == makedev(commajor, unit+1) && c == FRAME_END)
+ kgdb_dev == makedev(commajor, unit) && c == FRAME_END)
kgdb_connect(0); /* trap into kgdb */
#endif
return;
kgdb_connect(0); /* trap into kgdb */
#endif
return;
/* make sure hardware exists? XXX */
/* initialize required fields */
/* make sure hardware exists? XXX */
/* initialize required fields */
- cp->cn_dev = makedev(commajor, unit+1);
+ cp->cn_dev = makedev(commajor, unit);
cp->cn_tp = &com_tty[unit];
#ifdef COMCONSOLE
cp->cn_pri = CN_REMOTE; /* Force a serial port console */
cp->cn_tp = &com_tty[unit];
#ifdef COMCONSOLE
cp->cn_pri = CN_REMOTE; /* Force a serial port console */