1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
1994-03-08 11:12:56 +03:00
|
|
|
* Copyright (c) 1993, 1994 Charles Hannum.
|
1993-03-21 12:45:37 +03:00
|
|
|
* Copyright (c) 1991 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1993-05-18 22:18:40 +04:00
|
|
|
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
|
1994-03-08 11:12:56 +03:00
|
|
|
* $Id: com.c,v 1.21 1994/03/08 08:12:56 mycroft Exp $
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* COM driver, based on HP dca driver
|
|
|
|
* uses National Semiconductor NS16450/NS16550AF UART
|
|
|
|
*/
|
1994-03-08 11:12:56 +03:00
|
|
|
#include "com.h"
|
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/types.h>
|
1994-03-08 11:12:56 +03:00
|
|
|
#include <sys/device.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
#include <machine/cpu.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <machine/pio.h>
|
|
|
|
|
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
#include <i386/isa/comreg.h>
|
|
|
|
#include <i386/isa/ic/ns16550.h>
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
struct com_softc {
|
|
|
|
struct device sc_dev;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
u_short sc_iobase;
|
|
|
|
u_char sc_flags;
|
|
|
|
#define COM_SOFTCAR 0x01
|
|
|
|
#define COM_FIFO 0x02
|
|
|
|
u_char sc_msr, sc_mcr;
|
|
|
|
} com_softc[NCOM];
|
|
|
|
/* XXXX should be in com_softc, but not ready for that yet */
|
|
|
|
struct tty *com_tty[NCOM];
|
|
|
|
|
|
|
|
int comprobe __P((struct isa_device *));
|
|
|
|
int comattach __P((struct isa_device *));
|
|
|
|
int comopen __P((dev_t, int, int, struct proc *));
|
|
|
|
int comclose __P((dev_t, int, int, struct proc *));
|
|
|
|
int comintr __P((int));
|
|
|
|
int comparam __P((struct tty *, struct termios *));
|
|
|
|
void comstart __P((struct tty *));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
struct isa_driver comdriver = {
|
|
|
|
comprobe, comattach, "com"
|
|
|
|
};
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int comdefaultrate = TTYDEF_SPEED;
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifdef COMCONSOLE
|
|
|
|
int comconsole = COMCONSOLE;
|
|
|
|
#else
|
|
|
|
int comconsole = -1;
|
|
|
|
#endif
|
|
|
|
int comconsinit;
|
|
|
|
int commajor;
|
|
|
|
|
|
|
|
#ifdef KGDB
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <machine/remote-sl.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
extern int kgdb_dev;
|
|
|
|
extern int kgdb_rate;
|
|
|
|
extern int kgdb_debug_init;
|
|
|
|
#endif
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
#define COMUNIT(x) (minor(x))
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
#define bis(c, b) do { const register u_short com_ad = (c); \
|
|
|
|
outb(com_ad, inb(com_ad) | (b)); } while(0)
|
|
|
|
#define bic(c, b) do { const register u_short com_ad = (c); \
|
|
|
|
outb(com_ad, inb(com_ad) & ~(b)); } while(0)
|
|
|
|
|
|
|
|
int
|
|
|
|
comspeed(speed)
|
|
|
|
long speed;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
#define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */
|
|
|
|
|
|
|
|
int x, err;
|
|
|
|
|
|
|
|
if (speed == 0)
|
|
|
|
return 0;
|
|
|
|
if (speed < 0)
|
|
|
|
return -1;
|
|
|
|
x = divrnd((COM_FREQ / 16), speed);
|
|
|
|
if (x <= 0)
|
|
|
|
return -1;
|
|
|
|
err = divrnd((COM_FREQ / 16) * 1000, speed * x) - 1000;
|
|
|
|
if (err < 0)
|
|
|
|
err = -err;
|
|
|
|
if (err > COM_TOLERANCE)
|
|
|
|
return -1;
|
|
|
|
return x;
|
|
|
|
|
|
|
|
#undef divrnd(n, q)
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
comprobe1(iobase)
|
|
|
|
u_short iobase;
|
|
|
|
{
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/* force access to id reg */
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_cfcr, 0);
|
|
|
|
outb(iobase + com_iir, 0);
|
|
|
|
if (inb(iobase + com_iir) & 0x38)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
|
|
|
comprobe(isa_dev)
|
|
|
|
struct isa_device *isa_dev;
|
|
|
|
{
|
|
|
|
struct com_softc *sc = &com_softc[isa_dev->id_unit];
|
|
|
|
u_short iobase = isa_dev->id_iobase;
|
|
|
|
|
|
|
|
/* XXX HACK */
|
|
|
|
sprintf(sc->sc_dev.dv_xname, "%s%d", comdriver.name, isa_dev->id_unit);
|
|
|
|
sc->sc_dev.dv_unit = isa_dev->id_unit;
|
|
|
|
|
|
|
|
if (!comprobe1(iobase))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return COM_NPORTS;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
int
|
1994-03-08 11:12:56 +03:00
|
|
|
comattach(isa_dev)
|
|
|
|
struct isa_device *isa_dev;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = isa_dev->id_unit;
|
|
|
|
struct com_softc *sc = &com_softc[unit];
|
|
|
|
u_short iobase = isa_dev->id_iobase;
|
|
|
|
struct tty *tp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (unit == comconsole)
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(1000);
|
1994-03-08 11:12:56 +03:00
|
|
|
|
|
|
|
sc->sc_iobase = iobase;
|
|
|
|
sc->sc_flags = 0;
|
|
|
|
|
|
|
|
printf("%s: ", sc->sc_dev.dv_xname);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* look for a NS 16550AF UART with FIFOs */
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_fifo,
|
|
|
|
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(100);
|
1994-03-08 11:12:56 +03:00
|
|
|
if ((inb(iobase + com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK)
|
|
|
|
if ((inb(iobase + com_fifo) & FIFO_TRIGGER_14) == FIFO_TRIGGER_14) {
|
|
|
|
sc->sc_flags |= COM_FIFO;
|
|
|
|
printf("ns16550a, working fifo\n");
|
|
|
|
} else
|
|
|
|
printf("ns82550 or ns16550, broken fifo\n");
|
|
|
|
else
|
|
|
|
printf("ns82450 or ns16450, no fifo\n");
|
|
|
|
outb(iobase + com_fifo, 0);
|
|
|
|
|
|
|
|
/* disable interrupts */
|
|
|
|
outb(iobase + com_ier, 0);
|
|
|
|
outb(iobase + com_mcr, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifdef KGDB
|
1993-03-21 21:04:42 +03:00
|
|
|
if (kgdb_dev == makedev(commajor, unit)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (comconsole == unit)
|
|
|
|
kgdb_dev = -1; /* can't debug over console port */
|
|
|
|
else {
|
|
|
|
(void) cominit(unit, kgdb_rate);
|
|
|
|
if (kgdb_debug_init) {
|
|
|
|
/*
|
|
|
|
* Print prefix of device name,
|
|
|
|
* let kgdb_connect print the rest.
|
|
|
|
*/
|
1994-03-08 11:12:56 +03:00
|
|
|
printf("%s: ", sc->sc_dev.dv_xname);
|
1993-03-21 12:45:37 +03:00
|
|
|
kgdb_connect(1);
|
|
|
|
} else
|
1994-03-08 11:12:56 +03:00
|
|
|
printf("%s: kgdb enabled\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1994-03-08 11:12:56 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Need to reset baud rate, etc. of next print so reset comconsinit.
|
1994-03-08 11:12:56 +03:00
|
|
|
* Also make sure console is always "hardwired".
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
if (unit == comconsole) {
|
|
|
|
comconsinit = 0;
|
1994-03-08 11:12:56 +03:00
|
|
|
sc->sc_flags |= COM_SOFTCAR;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
|
|
|
comopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = COMUNIT(dev);
|
|
|
|
struct com_softc *sc;
|
|
|
|
u_short iobase;
|
|
|
|
struct tty *tp;
|
|
|
|
int s;
|
1993-03-21 12:45:37 +03:00
|
|
|
int error = 0;
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
if (unit > NCOM)
|
|
|
|
return ENXIO;
|
|
|
|
sc = &com_softc[unit];
|
|
|
|
if (!sc->sc_iobase)
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
if (!com_tty[unit])
|
1993-07-12 15:36:53 +04:00
|
|
|
tp = com_tty[unit] = ttymalloc();
|
1994-03-08 11:12:56 +03:00
|
|
|
else
|
1993-05-26 14:06:41 +04:00
|
|
|
tp = com_tty[unit];
|
1994-03-08 11:12:56 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_oproc = comstart;
|
|
|
|
tp->t_param = comparam;
|
|
|
|
tp->t_dev = dev;
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
ttychars(tp);
|
1994-01-30 19:41:27 +03:00
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG;
|
|
|
|
tp->t_lflag = TTYDEF_LFLAG;
|
|
|
|
tp->t_ispeed = tp->t_ospeed = comdefaultrate;
|
1993-03-21 12:45:37 +03:00
|
|
|
comparam(tp, &tp->t_termios);
|
|
|
|
ttsetwater(tp);
|
1994-03-08 11:12:56 +03:00
|
|
|
|
|
|
|
iobase = sc->sc_iobase;
|
|
|
|
/* flush any pending I/O */
|
|
|
|
if (sc->sc_flags & COM_FIFO)
|
|
|
|
outb(iobase + com_fifo,
|
|
|
|
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST |
|
|
|
|
FIFO_TRIGGER_8);
|
|
|
|
(void) inb(iobase + com_lsr);
|
|
|
|
(void) inb(iobase + com_data);
|
|
|
|
/* you turn me on, baby */
|
|
|
|
outb(iobase + com_mcr,
|
|
|
|
sc->sc_mcr = MCR_DTR | MCR_RTS | MCR_IENABLE);
|
|
|
|
outb(iobase + com_ier,
|
|
|
|
IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC);
|
|
|
|
|
|
|
|
sc->sc_msr = inb(iobase + com_msr);
|
|
|
|
if (sc->sc_flags & COM_SOFTCAR || sc->sc_msr & MSR_DCD)
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
|
|
|
else
|
|
|
|
tp->t_state &= ~TS_CARR_ON;
|
|
|
|
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) {
|
|
|
|
splx(s);
|
|
|
|
return EBUSY;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
|
|
|
|
/* wait for carrier if necessary */
|
|
|
|
if ((flag & O_NONBLOCK) == 0)
|
|
|
|
while ((tp->t_cflag & CLOCAL) == 0 &&
|
|
|
|
(tp->t_state & TS_CARR_ON) == 0) {
|
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
error = ttysleep(tp, (caddr_t)&tp->t_rawq,
|
|
|
|
TTIPRI | PCATCH, ttopen, 0);
|
|
|
|
if (error) {
|
|
|
|
/* XXX should turn off chip if we're the
|
|
|
|
only waiter */
|
|
|
|
splx(s);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return (*linesw[tp->t_line].l_open)(dev, tp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
comclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = COMUNIT(dev);
|
|
|
|
struct com_softc *sc = &com_softc[unit];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
struct tty *tp = com_tty[unit];
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
|
|
|
#ifdef KGDB
|
|
|
|
/* do not disable interrupts if debugging */
|
1993-03-21 21:04:42 +03:00
|
|
|
if (kgdb_dev != makedev(commajor, unit))
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
1994-03-08 11:12:56 +03:00
|
|
|
{
|
|
|
|
bic(iobase + com_cfcr, CFCR_SBREAK);
|
|
|
|
outb(iobase + com_ier, 0);
|
|
|
|
if (tp->t_cflag & HUPCL && (sc->sc_flags & COM_SOFTCAR) == 0)
|
|
|
|
/* XXX perhaps only clear DTR */
|
|
|
|
outb(iobase + com_mcr, 0);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
ttyclose(tp);
|
1994-03-08 11:12:56 +03:00
|
|
|
#ifdef notyet /* XXXX */
|
|
|
|
if (unit != comconsole) {
|
|
|
|
ttyfree(tp);
|
|
|
|
com_tty[unit] = (struct tty *)NULL;
|
|
|
|
}
|
1993-09-29 05:36:21 +03:00
|
|
|
#endif
|
1994-03-08 11:12:56 +03:00
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
comread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-03-08 11:12:56 +03:00
|
|
|
int flag;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
struct tty *tp = com_tty[COMUNIT(dev)];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
comwrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-03-08 11:12:56 +03:00
|
|
|
int flag;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
struct tty *tp = com_tty[COMUNIT(dev)];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
static u_char
|
|
|
|
tiocm_xxx2mcr(data)
|
|
|
|
int data;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
u_char m = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
if (data & TIOCM_DTR)
|
|
|
|
m |= MCR_DTR;
|
|
|
|
if (data & TIOCM_RTS)
|
|
|
|
m |= MCR_RTS;
|
|
|
|
return m;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
1994-02-10 00:06:46 +03:00
|
|
|
comioctl(dev, cmd, data, flag, p)
|
1993-03-21 12:45:37 +03:00
|
|
|
dev_t dev;
|
1994-02-10 00:06:46 +03:00
|
|
|
int cmd;
|
1993-03-21 12:45:37 +03:00
|
|
|
caddr_t data;
|
1994-02-10 00:06:46 +03:00
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = COMUNIT(dev);
|
|
|
|
struct com_softc *sc = &com_softc[unit];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
struct tty *tp = com_tty[unit];
|
|
|
|
int error;
|
|
|
|
|
1994-02-10 00:06:46 +03:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (error >= 0)
|
1994-03-08 11:12:56 +03:00
|
|
|
return error;
|
1994-02-10 00:06:46 +03:00
|
|
|
error = ttioctl(tp, cmd, data, flag, p);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (error >= 0)
|
1994-03-08 11:12:56 +03:00
|
|
|
return error;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TIOCSBRK:
|
1994-03-08 11:12:56 +03:00
|
|
|
bis(iobase + com_cfcr, CFCR_SBREAK);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case TIOCCBRK:
|
1994-03-08 11:12:56 +03:00
|
|
|
bic(iobase + com_cfcr, CFCR_SBREAK);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case TIOCSDTR:
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_mcr, sc->sc_mcr |= (MCR_DTR | MCR_RTS));
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case TIOCCDTR:
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_mcr, sc->sc_mcr &= ~(MCR_DTR | MCR_RTS));
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case TIOCMSET:
|
1994-03-08 11:12:56 +03:00
|
|
|
sc->sc_mcr &= ~(MCR_DTR | MCR_RTS);
|
1993-03-21 12:45:37 +03:00
|
|
|
case TIOCMBIS:
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_mcr,
|
|
|
|
sc->sc_mcr |= tiocm_xxx2mcr(*(int *)data));
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case TIOCMBIC:
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_mcr,
|
|
|
|
sc->sc_mcr &= ~tiocm_xxx2mcr(*(int *)data));
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-03-08 11:12:56 +03:00
|
|
|
case TIOCMGET: {
|
|
|
|
u_char m;
|
|
|
|
int bits = 0;
|
|
|
|
|
|
|
|
m = sc->sc_mcr;
|
|
|
|
if (m & MCR_DTR)
|
|
|
|
bits |= TIOCM_DTR;
|
|
|
|
if (m & MCR_RTS)
|
|
|
|
bits |= TIOCM_RTS;
|
|
|
|
m = sc->sc_msr;
|
|
|
|
if (m & MSR_DCD)
|
|
|
|
bits |= TIOCM_CD;
|
|
|
|
if (m & MSR_CTS)
|
|
|
|
bits |= TIOCM_CTS;
|
|
|
|
if (m & MSR_DSR)
|
|
|
|
bits |= TIOCM_DSR;
|
|
|
|
if (m & (MSR_RI | MSR_TERI))
|
|
|
|
bits |= TIOCM_RI;
|
|
|
|
if (inb(iobase + com_ier))
|
|
|
|
bits |= TIOCM_LE;
|
|
|
|
*(int *)data = bits;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-03-08 11:12:56 +03:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
default:
|
1994-03-08 11:12:56 +03:00
|
|
|
return ENOTTY;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
|
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
comparam(tp, t)
|
1994-03-08 11:12:56 +03:00
|
|
|
struct tty *tp;
|
|
|
|
struct termios *t;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
struct com_softc *sc = &com_softc[COMUNIT(tp->t_dev)];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
int ospeed = comspeed(t->c_ospeed);
|
|
|
|
u_char cfcr;
|
|
|
|
int s;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/* check requested parameters */
|
1994-03-08 11:12:56 +03:00
|
|
|
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
switch (t->c_cflag & CSIZE) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case CS5:
|
1994-03-08 11:12:56 +03:00
|
|
|
cfcr = CFCR_5BITS;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
case CS6:
|
1994-03-08 11:12:56 +03:00
|
|
|
cfcr = CFCR_6BITS;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
case CS7:
|
1994-03-08 11:12:56 +03:00
|
|
|
cfcr = CFCR_7BITS;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
case CS8:
|
1994-03-08 11:12:56 +03:00
|
|
|
cfcr = CFCR_8BITS;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
if (t->c_cflag & PARENB) {
|
1993-03-21 12:45:37 +03:00
|
|
|
cfcr |= CFCR_PENAB;
|
1994-03-08 11:12:56 +03:00
|
|
|
if ((t->c_cflag & PARODD) == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
cfcr |= CFCR_PEVEN;
|
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
if (t->c_cflag & CSTOPB)
|
1993-03-21 12:45:37 +03:00
|
|
|
cfcr |= CFCR_STOPB;
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
s = spltty();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
/* and copy to tty */
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = t->c_cflag;
|
|
|
|
|
|
|
|
if (ospeed == 0)
|
|
|
|
outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR);
|
|
|
|
else
|
|
|
|
outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR);
|
|
|
|
|
|
|
|
outb(iobase + com_cfcr, cfcr | CFCR_DLAB);
|
|
|
|
outb(iobase + com_dlbl, ospeed);
|
|
|
|
outb(iobase + com_dlbh, ospeed>>8);
|
|
|
|
outb(iobase + com_cfcr, cfcr);
|
|
|
|
|
|
|
|
/* When not using CRTS_IFLOW, RTS follows DTR. */
|
|
|
|
if ((t->c_cflag & CRTS_IFLOW) == 0) {
|
|
|
|
if (sc->sc_mcr & MCR_DTR) {
|
|
|
|
if ((sc->sc_mcr & MCR_RTS) == 0)
|
|
|
|
outb(iobase + com_mcr, sc->sc_mcr |= MCR_RTS);
|
|
|
|
} else {
|
|
|
|
if (sc->sc_mcr & MCR_RTS)
|
|
|
|
outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_RTS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If CTS is off and CCTS_OFLOW is changed, we must toggle TS_TTSTOP. */
|
|
|
|
if ((sc->sc_msr & MSR_CTS) == 0 &&
|
|
|
|
(tp->t_cflag & CCTS_OFLOW) != (t->c_cflag & CCTS_OFLOW)) {
|
|
|
|
if ((t->c_cflag & CCTS_OFLOW) == 0) {
|
|
|
|
tp->t_state &= ~TS_TTSTOP;
|
|
|
|
ttstart(tp);
|
|
|
|
} else
|
|
|
|
tp->t_state |= TS_TTSTOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
|
1993-08-29 17:46:31 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
comstart(tp)
|
1994-03-08 11:12:56 +03:00
|
|
|
struct tty *tp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
struct com_softc *sc = &com_softc[COMUNIT(tp->t_dev)];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
int s;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
s = spltty();
|
1994-03-08 11:12:56 +03:00
|
|
|
if (tp->t_state & (TS_TTSTOP | TS_BUSY))
|
|
|
|
goto out;
|
|
|
|
#if 0 /* XXXX I think this is handled adequately by commint() and comparam(). */
|
|
|
|
if (tp->t_cflag & CCTS_OFLOW && (sc->sc_mcr & MSR_CTS) == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
goto out;
|
1994-03-08 11:12:56 +03:00
|
|
|
#endif
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat) {
|
1994-03-08 11:12:56 +03:00
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
1993-07-12 15:36:53 +04:00
|
|
|
wakeup((caddr_t)&tp->t_outq);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-05-18 22:18:40 +04:00
|
|
|
selwakeup(&tp->t_wsel);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
goto out;
|
1994-03-08 11:12:56 +03:00
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
if ((inb(iobase + com_lsr) & LSR_TXRDY) == 0)
|
|
|
|
goto out;
|
|
|
|
if (sc->sc_flags & COM_FIFO) {
|
|
|
|
u_char buffer[16], *cp = buffer;
|
|
|
|
int n = q_to_b(&tp->t_outq, cp, sizeof buffer);
|
|
|
|
do {
|
|
|
|
outb(iobase + com_data, *cp++);
|
|
|
|
} while (--n);
|
|
|
|
} else
|
|
|
|
outb(iobase + com_data, getc(&tp->t_outq));
|
1993-03-21 12:45:37 +03:00
|
|
|
out:
|
|
|
|
splx(s);
|
|
|
|
}
|
1994-03-08 11:12:56 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Stop output on a line.
|
|
|
|
*/
|
1994-03-08 11:12:56 +03:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
comstop(tp, flag)
|
1994-03-08 11:12:56 +03:00
|
|
|
struct tty *tp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int s;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
s = spltty();
|
1994-03-08 11:12:56 +03:00
|
|
|
if (tp->t_state & TS_BUSY)
|
|
|
|
if ((tp->t_state & TS_TTSTOP) == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
static inline void
|
|
|
|
comeint(sc, stat)
|
|
|
|
struct com_softc *sc;
|
|
|
|
int stat;
|
|
|
|
{
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
int unit = sc->sc_dev.dv_unit;
|
|
|
|
struct tty *tp = com_tty[unit];
|
|
|
|
int c;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
c = inb(iobase + com_data);
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
#ifdef KGDB
|
|
|
|
/* we don't care about parity errors */
|
|
|
|
if (((stat & (LSR_BI | LSR_FE | LSR_PE)) == LSR_PE) &&
|
|
|
|
kgdb_dev == makedev(commajor, unit) && c == FRAME_END)
|
|
|
|
kgdb_connect(0); /* trap into kgdb */
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stat & (LSR_BI | LSR_FE))
|
|
|
|
c |= TTY_FE;
|
|
|
|
else if (stat & LSR_PE)
|
|
|
|
c |= TTY_PE;
|
|
|
|
if (stat & LSR_OE)
|
|
|
|
log(LOG_WARNING, "%s: silo overflow\n", sc->sc_dev.dv_xname);
|
|
|
|
/* XXXX put in FIFO and process later */
|
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
commint(sc)
|
|
|
|
struct com_softc *sc;
|
|
|
|
{
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
struct tty *tp = com_tty[sc->sc_dev.dv_unit];
|
|
|
|
u_char msr, delta;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
msr = inb(iobase + com_msr);
|
|
|
|
delta = msr ^ sc->sc_msr;
|
|
|
|
sc->sc_msr = msr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
if (delta & MSR_DCD && (sc->sc_flags & COM_SOFTCAR) == 0) {
|
|
|
|
if (msr & MSR_DCD)
|
|
|
|
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
|
|
|
|
else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
|
|
|
|
outb(iobase + com_mcr,
|
|
|
|
sc->sc_mcr &= ~(MCR_DTR | MCR_RTS));
|
|
|
|
}
|
|
|
|
if (delta & MSR_CTS && tp->t_cflag & CCTS_OFLOW) {
|
|
|
|
/* the line is up and we want to do rts/cts flow control */
|
|
|
|
if (msr & MSR_CTS) {
|
|
|
|
tp->t_state &= ~TS_TTSTOP;
|
|
|
|
ttstart(tp);
|
|
|
|
} else
|
|
|
|
tp->t_state |= TS_TTSTOP;
|
|
|
|
}
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
int
|
|
|
|
comintr(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
|
|
|
struct com_softc *sc = &com_softc[unit];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
struct tty *tp;
|
|
|
|
u_char code;
|
|
|
|
|
|
|
|
code = inb(iobase + com_iir) & IIR_IMASK;
|
|
|
|
if (code & IIR_NOPEND)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (code & IIR_RXRDY) {
|
|
|
|
tp = com_tty[sc->sc_dev.dv_unit];
|
|
|
|
/* XXXX put in FIFO and process later */
|
|
|
|
while (code = (inb(iobase + com_lsr) & LSR_RCV_MASK)) {
|
|
|
|
if (code == LSR_RXRDY) {
|
|
|
|
code = inb(iobase + com_data);
|
|
|
|
if (tp->t_state & TS_ISOPEN)
|
|
|
|
(*linesw[tp->t_line].l_rint)(code, tp);
|
|
|
|
#ifdef KGDB
|
|
|
|
else {
|
|
|
|
if (kgdb_dev == makedev(commajor, unit) &&
|
|
|
|
code == FRAME_END)
|
|
|
|
kgdb_connect(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else
|
|
|
|
comeint(sc, code);
|
|
|
|
}
|
|
|
|
} else if (code == IIR_TXRDY) {
|
|
|
|
tp = com_tty[sc->sc_dev.dv_unit];
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
if (tp->t_state & TS_FLUSH)
|
|
|
|
tp->t_state &= ~TS_FLUSH;
|
|
|
|
else
|
|
|
|
if (tp->t_line)
|
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
|
|
|
else
|
|
|
|
comstart(tp);
|
|
|
|
} else if (code == IIR_MLSC) {
|
|
|
|
commint(sc);
|
|
|
|
} else {
|
|
|
|
log(LOG_WARNING, "%s: weird interrupt: iir=0x%02x\n",
|
|
|
|
sc->sc_dev.dv_xname, code);
|
|
|
|
}
|
|
|
|
code = inb(iobase + com_iir) & IIR_IMASK;
|
|
|
|
if (code & IIR_NOPEND)
|
|
|
|
return 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Following are all routines needed for COM to act as console
|
|
|
|
*/
|
1994-02-01 06:42:08 +03:00
|
|
|
#include <dev/cons.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
comcnprobe(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = CONUNIT;
|
|
|
|
|
|
|
|
if (!comprobe1(CONADDR)) {
|
|
|
|
cp->cn_pri = CN_DEAD;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* locate the major number */
|
|
|
|
for (commajor = 0; commajor < nchrdev; commajor++)
|
|
|
|
if (cdevsw[commajor].d_open == comopen)
|
|
|
|
break;
|
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
com_softc[unit].sc_iobase = CONADDR;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* initialize required fields */
|
1993-03-21 21:04:42 +03:00
|
|
|
cp->cn_dev = makedev(commajor, unit);
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifdef COMCONSOLE
|
|
|
|
cp->cn_pri = CN_REMOTE; /* Force a serial port console */
|
|
|
|
#else
|
|
|
|
cp->cn_pri = CN_NORMAL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
comcninit(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int unit = CONUNIT;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
cominit(unit, comdefaultrate);
|
|
|
|
comconsole = unit;
|
1994-03-08 11:12:56 +03:00
|
|
|
comconsinit = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cominit(unit, rate)
|
|
|
|
int unit, rate;
|
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int s = splhigh();
|
|
|
|
u_short iobase = com_softc[unit].sc_iobase;
|
|
|
|
u_char stat;
|
|
|
|
|
|
|
|
outb(iobase + com_cfcr, CFCR_DLAB);
|
|
|
|
rate = comspeed(comdefaultrate);
|
|
|
|
outb(iobase + com_dlbl, rate);
|
|
|
|
outb(iobase + com_dlbh, rate >> 8);
|
|
|
|
outb(iobase + com_cfcr, CFCR_8BITS);
|
|
|
|
outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY);
|
|
|
|
outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_4);
|
|
|
|
stat = inb(iobase + com_iir);
|
1993-03-21 12:45:37 +03:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
comcngetc(dev)
|
1994-03-08 11:12:56 +03:00
|
|
|
dev_t dev;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-08 11:12:56 +03:00
|
|
|
int s = splhigh();
|
|
|
|
u_short iobase = com_softc[COMUNIT(dev)].sc_iobase;
|
|
|
|
u_char stat, c;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-08 11:12:56 +03:00
|
|
|
while (((stat = inb(iobase + com_lsr)) & LSR_RXRDY) == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
;
|
1994-03-08 11:12:56 +03:00
|
|
|
c = inb(iobase + com_data);
|
|
|
|
stat = inb(iobase + com_iir);
|
1993-03-21 12:45:37 +03:00
|
|
|
splx(s);
|
1994-03-08 11:12:56 +03:00
|
|
|
return c;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Console kernel output character routine.
|
|
|
|
*/
|
|
|
|
comcnputc(dev, c)
|
|
|
|
dev_t dev;
|
1994-03-08 11:12:56 +03:00
|
|
|
int c;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int s = splhigh();
|
1994-03-08 11:12:56 +03:00
|
|
|
u_short iobase = com_softc[COMUNIT(dev)].sc_iobase;
|
|
|
|
u_char stat;
|
|
|
|
register int timo;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifdef KGDB
|
|
|
|
if (dev != kgdb_dev)
|
|
|
|
#endif
|
|
|
|
if (comconsinit == 0) {
|
1994-03-08 11:12:56 +03:00
|
|
|
(void) cominit(COMUNIT(dev), comdefaultrate);
|
1993-03-21 12:45:37 +03:00
|
|
|
comconsinit = 1;
|
|
|
|
}
|
|
|
|
/* wait for any pending transmission to finish */
|
|
|
|
timo = 50000;
|
1994-03-08 11:12:56 +03:00
|
|
|
while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
|
1993-03-21 12:45:37 +03:00
|
|
|
;
|
1994-03-08 11:12:56 +03:00
|
|
|
outb(iobase + com_data, c);
|
1993-03-21 12:45:37 +03:00
|
|
|
/* wait for this transmission to complete */
|
|
|
|
timo = 1500000;
|
1994-03-08 11:12:56 +03:00
|
|
|
while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
|
1993-03-21 12:45:37 +03:00
|
|
|
;
|
|
|
|
/* clear any interrupts generated by this transmission */
|
1994-03-08 11:12:56 +03:00
|
|
|
stat = inb(iobase + com_iir);
|
1993-03-21 12:45:37 +03:00
|
|
|
splx(s);
|
|
|
|
}
|