mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Ttys structures are now allocated dynamically via ttymalloc/ttyfree.
This inetrface should be used from now on. pseudo device pty xx still keeps its meaning: a maximum of xx ptys is allowed. A ringbuffer is now 2040 bytes long, per Garrett Wollman's request. The changes are inspired by the way NetBSD did it (thanks for that!), though I made it slihghtly different, including the interface so at least 75% of the allocated space is deallocated when the tty is closed. Note further that it is easy to modify the ringbuffer length runtime. This will have to wait untill some later date... -Guido
This commit is contained in:
parent
8a7af68d49
commit
79bdab6c87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=1235
@ -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 @@ sioopen(dev, flag, mode, p)
|
||||
#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 @@ siopoll()
|
||||
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 @@ siopoll()
|
||||
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 @@ comparam(tp, t)
|
||||
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 */
|
||||
|
@ -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*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
|
||||
* $Id: conf.c,v 1.20 1994/01/04 20:08:56 nate Exp $
|
||||
* $Id: conf.c,v 1.21 1994/02/27 21:51:05 phk Exp $
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
@ -229,7 +229,7 @@ d_close_t pcclose;
|
||||
d_rdwr_t pcread, pcwrite;
|
||||
d_ioctl_t pcioctl;
|
||||
d_mmap_t pcmmap;
|
||||
extern struct tty pccons;
|
||||
extern struct tty *pccons;
|
||||
|
||||
/* controlling TTY */
|
||||
d_open_t cttyopen;
|
||||
@ -255,7 +255,7 @@ d_close_t ptcclose;
|
||||
d_rdwr_t ptcread, ptcwrite;
|
||||
d_select_t ptcselect;
|
||||
d_ioctl_t ptyioctl;
|
||||
extern struct tty pt_tty[];
|
||||
extern struct tty *pt_tty[];
|
||||
#else
|
||||
#define ptsopen (d_open_t *)enxio
|
||||
#define ptsclose (d_close_t *)enxio
|
||||
@ -280,7 +280,7 @@ d_rdwr_t comwrite;
|
||||
d_ioctl_t comioctl;
|
||||
d_select_t comselect;
|
||||
#define comreset (d_reset_t *)enxio
|
||||
extern struct tty com_tty[];
|
||||
extern struct tty *com_tty[];
|
||||
#else
|
||||
#define comopen (d_open_t *)enxio
|
||||
#define comclose (d_close_t *)enxio
|
||||
@ -442,7 +442,7 @@ d_ioctl_t sioioctl;
|
||||
d_select_t sioselect;
|
||||
d_stop_t siostop;
|
||||
#define sioreset (d_reset_t *)enxio
|
||||
extern struct tty sio_tty[];
|
||||
extern struct tty *sio_tty[];
|
||||
#else
|
||||
#define sioopen (d_open_t *)enxio
|
||||
#define sioclose (d_close_t *)enxio
|
||||
|
@ -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 @@ sioopen(dev, flag, mode, p)
|
||||
#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 @@ siopoll()
|
||||
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 @@ siopoll()
|
||||
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 @@ comparam(tp, t)
|
||||
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 */
|
||||
|
@ -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*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ sioopen(dev, flag, mode, p)
|
||||
#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 @@ siopoll()
|
||||
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 @@ siopoll()
|
||||
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 @@ comparam(tp, t)
|
||||
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 */
|
||||
|
@ -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*/
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user