-/* $OpenBSD: ace.c,v 1.4 1996/08/26 10:58:24 pefo Exp $ */
+/* $OpenBSD: ace.c,v 1.5 1996/09/02 09:01:49 deraadt Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*-
u_char sc_msr, sc_mcr, sc_lcr, sc_ier;
u_char sc_dtr;
+ u_char sc_cua;
+
u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend;
u_char sc_ibufs[2][COM_IBUFSIZE];
};
extern int kgdb_debug_init;
#endif
-#define COMUNIT(x) (minor(x))
+#define DEVUNIT(x) (minor(x) & 0x7f)
+#define DEVCUA(x) (minor(x) & 0x80)
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
int flag, mode;
struct proc *p;
{
- int unit = COMUNIT(dev);
+ int unit = DEVUNIT(dev);
struct com_softc *sc;
bus_chipset_tag_t bc;
bus_io_handle_t ioh;
if (!sc || ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING))
return ENXIO;
+ s = spltty();
if (!sc->sc_tty) {
tp = sc->sc_tty = ttymalloc();
tty_attach(tp);
} else
tp = sc->sc_tty;
+ splx(s);
tp->t_oproc = comstart;
tp->t_param = comparam;
bus_io_write_1(bc, ioh, com_ier, sc->sc_ier);
sc->sc_msr = bus_io_read_1(bc, ioh, com_msr);
- if (ISSET(sc->sc_swflags, COM_SW_SOFTCAR) ||
+ if (ISSET(sc->sc_swflags, COM_SW_SOFTCAR) || DEVCUA(dev) ||
ISSET(sc->sc_msr, MSR_DCD) || ISSET(tp->t_cflag, MDMBUF))
SET(tp->t_state, TS_CARR_ON);
else
else
s = spltty();
+ if (DEVCUA(dev)) {
+ if (ISSET(tp->t_state, TS_ISOPEN)) {
+ /* Ah, but someone already is dialed in... */
+ splx(s);
+ return EBUSY;
+ }
+ sc->sc_cua = 1; /* We go into CUA mode */
+ }
+
/* wait for carrier if necessary */
- if (!ISSET(flag, O_NONBLOCK))
- while (!ISSET(tp->t_cflag, CLOCAL) &&
+ if (ISSET(flag, O_NONBLOCK)) {
+ if (!DEVCUA(dev) && sc->sc_cua) {
+ /* Opening TTY non-blocking... but the CUA is busy */
+ splx(s);
+ return EBUSY;
+ }
+ } else {
+ while (!(DEVCUA(dev) && sc->sc_cua) &&
+ !ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON)) {
SET(tp->t_state, TS_WOPEN);
error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
if (error) {
/* XXX should turn off chip if we're the
only waiter */
+ if (DEVCUA(dev))
+ sc->sc_cua = 0;
splx(s);
return error;
}
}
+ }
splx(s);
return (*linesw[tp->t_line].l_open)(dev, tp);
int flag, mode;
struct proc *p;
{
- int unit = COMUNIT(dev);
+ int unit = DEVUNIT(dev);
struct com_softc *sc = ace_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
CLR(tp->t_state, TS_BUSY | TS_FLUSH);
if (--comsopen == 0)
untimeout(compoll, NULL);
+ sc->sc_cua = 0;
splx(s);
ttyclose(tp);
#ifdef COM_DEBUG
struct uio *uio;
int flag;
{
- struct com_softc *sc = ace_cd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = ace_cd.cd_devs[DEVUNIT(dev)];
struct tty *tp = sc->sc_tty;
if (ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) {
struct uio *uio;
int flag;
{
- struct com_softc *sc = ace_cd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = ace_cd.cd_devs[DEVUNIT(dev)];
struct tty *tp = sc->sc_tty;
if (ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) {
acetty(dev)
dev_t dev;
{
- struct com_softc *sc = ace_cd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = ace_cd.cd_devs[DEVUNIT(dev)];
struct tty *tp = sc->sc_tty;
return (tp);
int flag;
struct proc *p;
{
- int unit = COMUNIT(dev);
+ int unit = DEVUNIT(dev);
struct com_softc *sc = ace_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
struct tty *tp;
struct termios *t;
{
- struct com_softc *sc = ace_cd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = ace_cd.cd_devs[DEVUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int ospeed = comspeed(t->c_ospeed);
comstart(tp)
struct tty *tp;
{
- struct com_softc *sc = ace_cd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = ace_cd.cd_devs[DEVUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int s;