diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-07-14 04:25:14 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-07-14 04:25:14 +0000 |
commit | 666402903fb3eace8a58bf283cf542cfa1a8fc31 (patch) | |
tree | 4378cfda9f51c9422a7b10d2cc48721fe4dd8b1f | |
parent | 3868888fb751ca7165ef64fbe1c916aed642e470 (diff) |
cua devices for all!
-rw-r--r-- | sys/arch/hp300/dev/apci.c | 36 | ||||
-rw-r--r-- | sys/arch/hp300/dev/dca.c | 36 | ||||
-rw-r--r-- | sys/arch/hp300/dev/dcm.c | 35 |
3 files changed, 90 insertions, 17 deletions
diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c index d1c7da73a20..abc5e0b778d 100644 --- a/sys/arch/hp300/dev/apci.c +++ b/sys/arch/hp300/dev/apci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apci.c,v 1.1 1997/07/06 08:01:44 downsj Exp $ */ +/* $OpenBSD: apci.c,v 1.2 1997/07/14 04:25:12 downsj Exp $ */ /* $NetBSD: apci.c,v 1.1 1997/05/12 08:12:36 thorpej Exp $ */ /* @@ -94,6 +94,7 @@ struct apci_softc { sc_oflow, sc_toterr; /* stats */ int sc_flags; + u_char sc_cua; /* callout mode */ }; /* sc_flags */ @@ -125,7 +126,8 @@ int apcicheckdca __P((void)); cdev_decl(apci); -#define APCIUNIT(x) minor(x) +#define APCIUNIT(x) (minor(x) & 0x7f) +#define APCICUA(x) (minor(x) & 0x80) int apcidefaultrate = TTYDEF_SPEED; @@ -266,11 +268,14 @@ apciopen(dev, flag, mode, p) apci = sc->sc_apci; + s = spltty(); if (sc->sc_tty == NULL) { tp = sc->sc_tty = ttymalloc(); tty_attach(tp); } else tp = sc->sc_tty; + splx(s); + tp->t_oproc = apcistart; tp->t_param = apciparam; tp->t_dev = dev; @@ -315,18 +320,36 @@ apciopen(dev, flag, mode, p) (void) apcimctl(sc, MCR_DTR | MCR_RTS, DMSET); /* Set soft-carrier if so configured. */ - if ((sc->sc_flags & APCI_SOFTCAR) || + if ((sc->sc_flags & APCI_SOFTCAR) || APCICUA(dev) || (apcimctl(sc, 0, DMGET) & MSR_DCD)) tp->t_state |= TS_CARR_ON; - + + if (APCICUA(dev)) { + if (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 ((flag & O_NONBLOCK) == 0) { - while ((tp->t_cflag & CLOCAL) == 0 && + if (flag & O_NONBLOCK) { + if (!APCICUA(dev) && sc->sc_cua) { + /* Opening TTY non-blocking... but the CUA is busy */ + splx(s); + return (EBUSY); + } + } else { + while (!(APCICUA(dev) && sc->sc_cua) && + (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) { + if (APCICUA(dev)) + sc->sc_cua = 0; splx(s); return (error); } @@ -375,6 +398,7 @@ apciclose(dev, flag, mode, p) (void) apcimctl(sc, 0, DMSET); } tp->t_state &= ~(TS_BUSY | TS_FLUSH); + sc->sc_cua = 0; splx(s); ttyclose(tp); #if 0 diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index 675d1c23206..93b58f17aeb 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dca.c,v 1.9 1997/07/06 08:01:46 downsj Exp $ */ +/* $OpenBSD: dca.c,v 1.10 1997/07/14 04:25:13 downsj Exp $ */ /* $NetBSD: dca.c,v 1.35 1997/05/05 20:58:18 thorpej Exp $ */ /* @@ -78,6 +78,7 @@ struct dca_softc { struct tty *sc_tty; /* our tty instance */ int sc_oflows; /* overflow counter */ short sc_flags; /* state flags */ + u_char sc_cua; /* callout mode */ /* * Bits for sc_flags. @@ -155,7 +156,8 @@ extern int kgdb_rate; extern int kgdb_debug_init; #endif -#define DCAUNIT(x) minor(x) +#define DCAUNIT(x) (minor(x) & 0x7f) +#define DCACUA(x) (minor(x) & 0x80) #ifdef DEBUG long fifoin[17]; @@ -302,11 +304,14 @@ dcaopen(dev, flag, mode, p) dca = sc->sc_dca; + s = spltty(); if (sc->sc_tty == NULL) { tp = sc->sc_tty = ttymalloc(); tty_attach(tp); } else tp = sc->sc_tty; + splx(s); + tp->t_oproc = dcastart; tp->t_param = dcaparam; tp->t_dev = dev; @@ -352,21 +357,41 @@ dcaopen(dev, flag, mode, p) (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMSET); /* Set soft-carrier if so configured. */ - if ((sc->sc_flags & DCA_SOFTCAR) || (dcamctl(sc, 0, DMGET) & MSR_DCD)) + if ((sc->sc_flags & DCA_SOFTCAR) || DCACUA(dev) || + (dcamctl(sc, 0, DMGET) & MSR_DCD)) tp->t_state |= TS_CARR_ON; + if (DCACUA(dev)) { + if (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 ((flag & O_NONBLOCK) == 0) - while ((tp->t_cflag & CLOCAL) == 0 && + if (flag & O_NONBLOCK) { + if (!DCACUA(dev) && sc->sc_cua) { + /* Opening TTY non-blocking... but the CUA is busy */ + splx(s); + return (EBUSY); + } + } else { + while (!(DCACUA(dev) && sc->sc_cua) && + (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) { + if (DCACUA(dev)) + sc->sc_cua = 0; splx(s); return (error); } } + } splx(s); if (error == 0) @@ -409,6 +434,7 @@ dcaclose(dev, flag, mode, p) (void) dcamctl(sc, 0, DMSET); } tp->t_state &= ~(TS_BUSY | TS_FLUSH); + sc->sc_cua = 0; splx(s); ttyclose(tp); #if 0 diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 2fbb9f50691..b851d36d67a 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dcm.c,v 1.9 1997/07/06 08:01:47 downsj Exp $ */ +/* $OpenBSD: dcm.c,v 1.10 1997/07/14 04:25:13 downsj Exp $ */ /* $NetBSD: dcm.c,v 1.41 1997/05/05 20:59:16 thorpej Exp $ */ /* @@ -174,7 +174,8 @@ struct dcmstats { }; #endif -#define DCMUNIT(x) minor(x) +#define DCMUNIT(x) (minor(x) & 0x7f) +#define DCMCUA(x) (minor(x) & 0x80) #define DCMBOARD(x) (((x) >> 2) & 0x3f) #define DCMPORT(x) ((x) & 3) @@ -226,6 +227,7 @@ struct dcm_softc { char sc_mcndlast[NDCMPORT]; /* XXX last modem status for port */ short sc_softCAR; /* mask of ports with soft-carrier */ struct dcmischeme sc_scheme; /* interrupt scheme for board */ + u_char sc_cua; /* callout mode */ /* * Mask of soft-carrier bits in config flags. @@ -451,11 +453,13 @@ dcmopen(dev, flag, mode, p) if ((sc->sc_flags & DCM_ACTIVE) == 0) return (ENXIO); + s = spltty(); if (sc->sc_tty[port] == NULL) { tp = sc->sc_tty[port] = ttymalloc(); tty_attach(tp); } else tp = sc->sc_tty[port]; + splx(s); tp->t_oproc = dcmstart; tp->t_param = dcmparam; @@ -494,10 +498,19 @@ dcmopen(dev, flag, mode, p) (void) dcmmctl(dev, mbits, DMSET); /* enable port */ /* Set soft-carrier if so configured. */ - if ((sc->sc_softCAR & (1 << port)) || + if ((sc->sc_softCAR & (1 << port)) || DCMCUA(dev) || (dcmmctl(dev, MO_OFF, DMGET) & MI_CD)) tp->t_state |= TS_CARR_ON; + if (DCMCUA(dev)) { + if (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 */ + } + #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s: dcmopen port %d softcarr %c\n", @@ -506,18 +519,27 @@ dcmopen(dev, flag, mode, p) #endif /* Wait for carrier if necessary. */ - if ((flag & O_NONBLOCK) == 0) - while ((tp->t_cflag & CLOCAL) == 0 && + if (flag & O_NONBLOCK) { + if (!DCMCUA(dev) && sc->sc_cua) { + /* Opening TTY non-blocking... but the CUA is busy */ + splx(s); + return (EBUSY); + } + } else { + while (!(DCMCUA(dev) && sc->sc_cua) && + (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) { + if (DCMCUA(dev)) + sc->sc_cua = 0; splx(s); return (error); } } - + } splx(s); #ifdef DEBUG @@ -561,6 +583,7 @@ dcmclose(dev, flag, mode, p) printf("%s port %d: dcmclose: st %x fl %x\n", sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags); #endif + sc->sc_cua = 0; splx(s); ttyclose(tp); #if 0 |