summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-02 09:01:50 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-02 09:01:50 +0000
commit76960e5e0df3a13e75b17366a05d532770218364 (patch)
treea14074c3e9a4b1924f4773781c60f2540bf97d1e /sys
parentc5560040f94bcd87bc7ee55e55ff653491a034f9 (diff)
cua support
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arc/dev/ace.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/sys/arch/arc/dev/ace.c b/sys/arch/arc/dev/ace.c
index a916d639098..b9d91d0f5be 100644
--- a/sys/arch/arc/dev/ace.c
+++ b/sys/arch/arc/dev/ace.c
@@ -1,4 +1,4 @@
-/* $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 $ */
/*-
@@ -111,6 +111,8 @@ struct com_softc {
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];
};
@@ -201,7 +203,8 @@ extern int kgdb_rate;
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)
@@ -782,7 +785,7 @@ aceopen(dev, flag, mode, p)
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;
@@ -796,11 +799,13 @@ aceopen(dev, flag, mode, p)
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;
@@ -886,7 +891,7 @@ aceopen(dev, flag, mode, p)
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
@@ -896,9 +901,25 @@ aceopen(dev, flag, mode, p)
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,
@@ -906,10 +927,13 @@ aceopen(dev, flag, mode, p)
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);
@@ -921,7 +945,7 @@ aceclose(dev, flag, mode, p)
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;
@@ -948,6 +972,7 @@ aceclose(dev, flag, mode, p)
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
@@ -973,7 +998,7 @@ aceread(dev, uio, flag)
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)) {
@@ -992,7 +1017,7 @@ acewrite(dev, uio, flag)
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)) {
@@ -1009,7 +1034,7 @@ struct tty *
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);
@@ -1036,7 +1061,7 @@ aceioctl(dev, cmd, data, flag, p)
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;
@@ -1156,7 +1181,7 @@ comparam(tp, t)
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);
@@ -1314,7 +1339,7 @@ void
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;