aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorGuido van Rooij <guido@FreeBSD.org>1994-03-02 20:28:38 +0000
committerGuido van Rooij <guido@FreeBSD.org>1994-03-02 20:28:38 +0000
commit79bdab6c8799f24747a9c9592077dd51162e88eb (patch)
treec1e42a5935b70cffef18b9284e8ad3347cefd405 /sys/dev
parent8a7af68d494904d398f518d498681ba00ba0ab9b (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sio/sio.c35
-rw-r--r--sys/dev/syscons/syscons.c25
2 files changed, 35 insertions, 25 deletions
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index f17f6ae131a9a..cebc9dce97330 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.29 1994/02/24 16:39:48 phk Exp $
+ * $Id: sio.c,v 1.30 1994/02/26 00:04:03 phk Exp $
*/
#include "sio.h"
@@ -270,7 +270,7 @@ static bool_t comconsinit;
static speed_t comdefaultrate = TTYDEF_SPEED;
static u_int com_events; /* input chars + weighted output completions */
static int commajor;
-struct tty sio_tty[NSIO];
+struct tty *sio_tty[NSIO];
extern struct tty *constty;
extern u_int ipending; /* XXX */
extern int tk_nin; /* XXX */
@@ -437,7 +437,7 @@ sioattach(isdp)
com->modem_ctl_port = iobase + com_mcr;
com->line_status_port = iobase + com_lsr;
com->modem_status_port = iobase + com_msr;
- com->tp = &sio_tty[unit];
+ com->tp = sio_tty[unit];
/* attempt to determine UART type */
printf("sio%d: type", unit);
@@ -568,7 +568,9 @@ sioopen(dev, flag, mode, p)
return (ENXIO);
#endif /* COM_BIDIR */
- tp = com->tp;
+
+ sio_tty[unit] = ttymalloc(sio_tty[unit]);
+ tp = com->tp = sio_tty[unit];
s = spltty();
#ifdef COM_BIDIR
@@ -722,7 +724,7 @@ bidir_open_top:
#endif /* COM_BIDIR */
&& !(tp->t_state & TS_CARR_ON)) {
tp->t_state |= TS_WOPEN;
- error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH,
+ error = ttysleep(tp, (caddr_t)tp->t_raw, TTIPRI | PCATCH,
ttopen, 0);
if (error != 0)
break;
@@ -768,6 +770,11 @@ sioclose(dev, flag, mode, p)
(*linesw[tp->t_line].l_close)(tp, flag);
comhardclose(com);
ttyclose(tp);
+ ttyfree(tp);
+#ifdef broken /* session holds a ref to the tty; can't deallocate */
+ sio_tty[UNIT(dev)] = (struct tty *)NULL;
+ com->tp = (struct tty *)NULL;
+#endif
return (0);
}
@@ -1184,7 +1191,7 @@ comflush(com)
com_events -= LOTS_OF_EVENTS;
com->state &= ~(CS_ODONE | CS_BUSY);
enable_intr();
- rbp = &com->tp->t_out;
+ rbp = com->tp->t_out;
rbp->rb_hd += com->ocount;
rbp->rb_hd = RB_ROLLOVER(rbp, rbp->rb_hd);
com->ocount = 0;
@@ -1305,7 +1312,7 @@ repeat:
if (incc <= 0 || !(tp->t_state & TS_ISOPEN))
continue;
if (com->state & CS_RTS_IFLOW
- && RB_LEN(&tp->t_raw) + incc >= RB_I_HIGH_WATER
+ && RB_LEN(tp->t_raw) + incc >= RB_I_HIGH_WATER
&& !(tp->t_state & TS_RTS_IFLOW)
/*
* XXX - need RTS flow control for all line disciplines.
@@ -1332,7 +1339,7 @@ repeat:
tk_rawcc += incc;
tp->t_rawcc += incc;
com->delta_error_counts[CE_TTY_BUF_OVERFLOW]
- += incc - rb_write(&tp->t_raw, (char *) buf,
+ += incc - rb_write(tp->t_raw, (char *) buf,
incc);
ttwakeup(tp);
if (tp->t_state & TS_TTSTOP
@@ -1439,7 +1446,7 @@ retry:
enable_intr();
while ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY))
!= (LSR_TSRE | LSR_TXRDY)) {
- error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH,
+ error = ttysleep(tp, (caddr_t)tp->t_raw, TTIPRI | PCATCH,
"sioparam", 1);
if (error != 0 && error != EAGAIN) {
if (!(tp->t_state & TS_TTSTOP)) {
@@ -1532,10 +1539,10 @@ comstart(tp)
enable_intr();
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP))
goto out;
- if (RB_LEN(&tp->t_out) <= tp->t_lowat) {
+ if (RB_LEN(tp->t_out) <= tp->t_lowat) {
if (tp->t_state & TS_ASLEEP) {
tp->t_state &= ~TS_ASLEEP;
- wakeup((caddr_t)&tp->t_out);
+ wakeup((caddr_t)tp->t_out);
}
if (tp->t_wsel) {
selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
@@ -1547,11 +1554,11 @@ comstart(tp)
disable_intr();
comintr1(com);
enable_intr();
- } else if (RB_LEN(&tp->t_out) != 0) {
+ } else if (RB_LEN(tp->t_out) != 0) {
tp->t_state |= TS_BUSY;
- com->ocount = RB_CONTIGGET(&tp->t_out);
+ com->ocount = RB_CONTIGGET(tp->t_out);
disable_intr();
- com->obufend = (com->optr = (u_char *) tp->t_out.rb_hd)
+ com->obufend = (com->optr = (u_char *) tp->t_out->rb_hd)
+ com->ocount;
com->state |= CS_BUSY;
comintr1(com); /* fake interrupt to start output */
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 5eb10afafc150..4932d59855355 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from:@(#)syscons.c 1.3 940129
- * $Id: syscons.c,v 1.34 1994/02/04 10:36:15 chmr Exp $
+ * $Id: syscons.c,v 1.35 1994/02/07 02:14:27 davidg Exp $
*
*/
@@ -273,26 +273,29 @@ int ttrstrt();
#endif
#if defined(__FreeBSD__)
+#define VIRTUAL_TTY(x) (pccons[x] = ttymalloc(pccons[x]))
+#define CONSOLE_TTY (pccons[NCONS] = ttymalloc(pccons[NCONS]))
#define frametype struct trapframe
#define eflags tf_eflags
#define timeout_t timeout_func_t
#define MONO_BUF (KERNBASE+0xB0000)
#define CGA_BUF (KERNBASE+0xB8000)
+struct tty *pccons[NCONS+1];
#endif
#if defined(__386BSD__) && !defined(__FreeBSD__)
+#define VIRTUAL_TTY(x) &pccons[x]
+#define CONSOLE_TTY &pccons[NCONS]
#define frametype struct syscframe
#define eflags sf_eflags
#define timeout_t caddr_t
#define MONO_BUF (0xFE0B0000)
#define CGA_BUF (0xFE0B8000)
+struct tty pccons[NCONS+1];
#endif
#if defined(__386BSD__) || defined(__FreeBSD__)
-#define VIRTUAL_TTY(x) &pccons[x]
-#define CONSOLE_TTY &pccons[NCONS]
u_short *Crtat = (u_short *)MONO_BUF;
-struct tty pccons[NCONS+1];
void consinit(void) {scinit();}
#include "ddb.h"
#if NDDB > 0
@@ -300,7 +303,6 @@ void consinit(void) {scinit();}
#endif
#endif
-
struct isa_driver scdriver = {
pcprobe, pcattach, "sc",
};
@@ -1060,10 +1062,10 @@ void pcstart(struct tty *tp)
s = spltty();
if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)))
for (;;) {
- if (RB_LEN(&tp->t_out) <= tp->t_lowat) {
+ if (RB_LEN(tp->t_out) <= tp->t_lowat) {
if (tp->t_state & TS_ASLEEP) {
tp->t_state &= ~TS_ASLEEP;
- wakeup((caddr_t)&tp->t_out);
+ wakeup((caddr_t)tp->t_out);
}
if (tp->t_wsel) {
selwakeup(tp->t_wsel,
@@ -1072,11 +1074,11 @@ void pcstart(struct tty *tp)
tp->t_state &= ~TS_WCOLL;
}
}
- if (RB_LEN(&tp->t_out) == 0)
+ if (RB_LEN(tp->t_out) == 0)
break;
if (scp->status & SLKED)
break;
- c = getc(&tp->t_out);
+ c = getc(tp->t_out);
tp->t_state |= TS_BUSY;
splx(s);
ansi_put(scp, c);
@@ -1100,9 +1102,10 @@ void pccnprobe(struct consdev *cp)
/* initialize required fields */
cp->cn_dev = makedev(maj, NCONS);
cp->cn_pri = CN_INTERNAL;
-#if defined(__FreeBSD__) || defined(__386BSD__)
+#warning Crude hack, do it better
+/*#if defined(__FreeBSD__) || defined(__386BSD__)
cp->cn_tp = CONSOLE_TTY;
-#endif
+#endif*/
}