summaryrefslogtreecommitdiff
path: root/sys/arch/mvme68k/dev/cl.c
diff options
context:
space:
mode:
authorDale S. Rahn <rahnds@cvs.openbsd.org>1996-05-10 16:54:55 +0000
committerDale S. Rahn <rahnds@cvs.openbsd.org>1996-05-10 16:54:55 +0000
commit340a25673b09f54f1e33303aec3944a7b1ca2d6d (patch)
treed351e8ee343d0f9a137cd22b4ace986cd3e0a747 /sys/arch/mvme68k/dev/cl.c
parentae41959e705fc3ebb57a1ac4df087ac772f51971 (diff)
Add some code bulletproofing, I have had this around for some time
I actually thought it was checked in. This should stop any extra transmit interupts occuring and a possible crash if another system talks to the tty port before it is completely configured. Also allows debugging when no processes have the port open for writing. If abort is pressed before getty starts.
Diffstat (limited to 'sys/arch/mvme68k/dev/cl.c')
-rw-r--r--sys/arch/mvme68k/dev/cl.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/arch/mvme68k/dev/cl.c b/sys/arch/mvme68k/dev/cl.c
index c74e7ddb477..6a1fdafbc3c 100644
--- a/sys/arch/mvme68k/dev/cl.c
+++ b/sys/arch/mvme68k/dev/cl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl.c,v 1.11 1996/05/07 07:47:34 deraadt Exp $ */
+/* $OpenBSD: cl.c,v 1.12 1996/05/10 16:54:54 rahnds Exp $ */
/*
* Copyright (c) 1995 Dale Rahn. All rights reserved.
@@ -977,8 +977,14 @@ clcngetc(dev)
{
u_char val, reoir, licr, isrl, data, status, fifo_cnt;
int got_char = 0;
+ u_char ier_old = 0xff;
struct clreg *cl_reg = cl_cons.cl_vaddr;
volatile struct pcctworeg *pcc2_base = cl_cons.pcctwoaddr;
+ cl_reg->cl_car = 0;
+ if (!(cl_reg->cl_ier & 0x08)) {
+ ier_old = cl_reg->cl_ier;
+ cl_reg->cl_ier = 0x08;
+ }
while (got_char == 0) {
val = cl_reg->cl_rir;
/* if no receive interrupt pending wait */
@@ -1009,6 +1015,9 @@ clcngetc(dev)
#endif
fifo_cnt = cl_reg->cl_rfoc;
data = cl_reg->cl_rdr;
+ if (ier_old != 0xff) {
+ cl_reg->cl_ier = ier_old;
+ }
got_char = 1;
cl_reg->cl_teoir = 0x00;
} else {
@@ -1491,6 +1500,7 @@ cl_txintr(sc)
tp = sc->sc_cl[channel].tty;
if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) {
+ sc->cl_reg->cl_ier = sc->cl_reg->cl_ier & ~0x3;
sc->cl_reg->cl_teoir = 0x08;
return 1;
}
@@ -1729,6 +1739,14 @@ channel, nbuf, cnt, status);
for (i = 0; i < fifocnt; i++) {
buffer[i] = sc->cl_reg->cl_rdr;
}
+ if (NULL == tp) {
+ /* if the channel is not configured,
+ * dont send characters upstream.
+ * also fix problem with NULL dereference
+ */
+ reoir = 0x00;
+ break;
+ }
sc->cl_reg->cl_reoir = reoir;
for (i = 0; i < fifocnt; i++) {