aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPaul Traina <pst@FreeBSD.org>1995-02-25 20:09:44 +0000
committerPaul Traina <pst@FreeBSD.org>1995-02-25 20:09:44 +0000
commit77f77631e75f6858d00b61473e49b7c8906c5aa8 (patch)
tree1f0482b969de4dd457ac5b450c026dcaab6317e2 /sys
parent686c46d225921363fb8749fd74457ecbf8a9e987 (diff)
downloadsrc-77f77631e75f6858d00b61473e49b7c8906c5aa8.tar.gz
src-77f77631e75f6858d00b61473e49b7c8906c5aa8.zip
(a) remove the pointer to each driver's tty structure array from cdevsw
(b) add a function callback vector to tty drivers that will return a pointer to a valid tty structure based upon a dev_t (c) make syscons structures the same size whether or not APM is enabled so utilities don't crash if NAPM changes (and make the damn kernel compile!) (d) rewrite /dev/snp ioctl interface so that it is device driver and i386 independant
Notes
Notes: svn path=/head/; revision=6712
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cy/cy.c19
-rw-r--r--sys/dev/cy/cy_isa.c19
-rw-r--r--sys/dev/sio/sio.c41
-rw-r--r--sys/dev/snp/snp.c168
-rw-r--r--sys/dev/syscons/syscons.c63
-rw-r--r--sys/dev/syscons/syscons.h11
-rw-r--r--sys/gnu/isdn/iitty.c23
-rw-r--r--sys/i386/i386/conf.c168
-rw-r--r--sys/i386/i386/cons.c7
-rw-r--r--sys/i386/isa/cx.c5
-rw-r--r--sys/i386/isa/cy.c19
-rw-r--r--sys/i386/isa/sio.c41
-rw-r--r--sys/i386/isa/syscons.c63
-rw-r--r--sys/i386/isa/syscons.h11
-rw-r--r--sys/isa/sio.c41
-rw-r--r--sys/isa/syscons.c63
-rw-r--r--sys/isa/syscons.h11
-rw-r--r--sys/kern/tty.c17
-rw-r--r--sys/kern/tty_cons.c7
-rw-r--r--sys/kern/tty_pty.c22
-rw-r--r--sys/kern/tty_snoop.c168
-rw-r--r--sys/sys/conf.h5
-rw-r--r--sys/sys/linedisc.h5
-rw-r--r--sys/sys/snoop.h29
-rw-r--r--sys/sys/tty.h4
25 files changed, 555 insertions, 475 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 3bd203bcb2aa..ff67eb436198 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.1 1995/02/09 09:47:27 jkh Exp $
+ * $Id: cy.c,v 1.2 1995/02/15 18:41:41 bde Exp $
*/
/*
@@ -1500,13 +1500,26 @@ cystop(struct tty *tp, int flag)
return 0;
}
+struct tty *
+cydevtotty(dev_t dev)
+{
+ u_char unit = UNIT(dev);
+
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return NULL;
+
+ return info[unit]->tty;
+}
int
cyselect(dev_t dev, int rw, struct proc *p)
{
- return (ttselect(UNIT(dev), rw, p));
-} /* end of cyselect() */
+ u_char unit = UNIT(dev);
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return (ENXIO);
+ return (ttyselect(info[unit]->tty, rw, p));
+}
int
cyspeed(int speed, int *prescaler_io)
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 3bd203bcb2aa..ff67eb436198 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.1 1995/02/09 09:47:27 jkh Exp $
+ * $Id: cy.c,v 1.2 1995/02/15 18:41:41 bde Exp $
*/
/*
@@ -1500,13 +1500,26 @@ cystop(struct tty *tp, int flag)
return 0;
}
+struct tty *
+cydevtotty(dev_t dev)
+{
+ u_char unit = UNIT(dev);
+
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return NULL;
+
+ return info[unit]->tty;
+}
int
cyselect(dev_t dev, int rw, struct proc *p)
{
- return (ttselect(UNIT(dev), rw, p));
-} /* end of cyselect() */
+ u_char unit = UNIT(dev);
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return (ENXIO);
+ return (ttyselect(info[unit]->tty, rw, p));
+}
int
cyspeed(int speed, int *prescaler_io)
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index c2841501ba9a..39bec6dd050e 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.65 1995/01/20 07:34:15 wpaul Exp $
+ * $Id: sio.c,v 1.66 1995/02/24 00:11:01 ache Exp $
*/
#include "sio.h"
@@ -1819,15 +1819,50 @@ siostop(tp, rw)
enable_intr();
}
+struct tty *
+siodevtotty(dev)
+ dev_t dev;
+{
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
+ return NULL;
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return NULL;
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return NULL;
+
+ return com->tp;
+}
+
int
sioselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
- if (minor(dev) & CONTROL_MASK)
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
return (ENODEV);
- return (ttselect(dev & ~MINOR_MAGIC_MASK, rw, p));
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return (ENXIO);
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return (ENXIO);
+
+ return (ttyselect(com->tp, rw, p));
}
static void
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index eaee5442b885..553b5c252ed6 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -33,81 +33,22 @@
#include <sys/snoop.h>
-
-
-#ifdef ST_PTY
-/*
- * This should be same as in "kern/tty_pty.c"
- */
-#include "pty.h"
-
-#if NPTY == 1
-#undef NPTY
-#define NPTY 32
-#endif
-
-extern struct tty pt_tty[];
-#endif /* ST_PTY */
-
-
-#ifdef ST_SIO
-/*
- * This should be same as "i386/isa/sio.c"
- */
-#include "sio.h"
-
-extern struct tty sio_tty[];
-#endif /* ST_SIO */
-
-
-#ifdef ST_VTY
-/*
- * This should match "i386/isa/sc.c"
- */
-
-#if !defined(MAXCONS)
-#define MAXCONS 16
-#endif
-
-extern struct tty sccons[];
-#endif /* ST_VTY */
-
-
-/*
- * This is local structure to hold data for all tty arrays we serve.
- */
-typedef struct tty tty_arr[];
-struct tty_tab {
- int lt_max;
- tty_arr *lt_tab;
-};
-
-static struct tty_tab tty_tabs[] = {
-#ifdef ST_PTY
- {NPTY, &pt_tty},
-#else
- {-1, NULL},
-#endif
-#ifdef ST_VTY
- {MAXCONS, &sccons},
-#else
- {-1, NULL},
-#endif
-#ifdef ST_SIO
- {NSIO, &sio_tty}
-#else
- {-1, NULL}
-#endif
-};
-
-
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
-
static struct snoop snoopsw[NSNP];
+static struct tty *
+devtotty (dev)
+ dev_t dev;
+{
+ if (major(dev) > nchrdev)
+ return (NULL); /* no such device available */
+
+ return (*cdevsw[major(dev)].d_devtotty)(dev);
+}
+
int
snpread(dev, uio, flag)
dev_t dev;
@@ -124,7 +65,8 @@ snpread(dev, uio, flag)
if ((snp->snp_len + snp->snp_base) > snp->snp_blen)
panic("snoop buffer error");
#endif
- if (snp->snp_unit == -1)
+
+ if (snp->snp_target == -1)
return (EIO);
snp->snp_flags &= ~SNOOP_RWAIT;
@@ -183,7 +125,6 @@ snpin(snp, buf, n)
int s, len, nblen;
caddr_t from, to;
char *nbuf;
- struct tty_tab *l_tty;
struct tty *tp;
@@ -278,9 +219,12 @@ snpopen(dev, flag, mode, p)
if ((unit = minor(dev)) >= NSNP)
return (ENXIO);
+
snp = &snoopsw[unit];
+
if (snp->snp_flags & SNOOP_OPEN)
return (ENXIO);
+
/*
* We intentionally do not OR flags with SNOOP_OPEN,but set them so
* all previous settings (especially SNOOP_OFLOW) will be cleared.
@@ -295,8 +239,7 @@ snpopen(dev, flag, mode, p)
/*
* unit == -1 is for inactive snoop devices.
*/
- snp->snp_unit = -1;
-
+ snp->snp_target = -1;
return (0);
}
@@ -306,8 +249,6 @@ snp_detach(snp)
struct snoop *snp;
{
struct tty *tp;
- struct tty_tab *l_tty;
-
snp->snp_base = 0;
snp->snp_len = 0;
@@ -317,21 +258,19 @@ snp_detach(snp)
* change it anyway.
*/
- if (snp->snp_unit == -1)
+ if (snp->snp_target == -1)
goto detach_notty;
-
- l_tty = &tty_tabs[snp->snp_type];
- tp = &((*l_tty->lt_tab)[snp->snp_unit]);
-
- if ((tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
+ tp = devtotty(snp->snp_target);
+
+ if (tp && (tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
(tp->t_line == OTTYDISC || tp->t_line == NTTYDISC)) {
tp->t_sc = NULL;
tp->t_state &= ~TS_SNOOP;
} else
printf("Snoop: bad attached tty data.\n");
- snp->snp_unit = -1;
+ snp->snp_target = -1;
detach_notty:
selwakeup(&snp->snp_sel);
@@ -376,47 +315,38 @@ snpioctl(dev, cmd, data, flag)
int flag;
{
int unit = minor(dev), s;
- int tunit, ttype;
+ dev_t tdev;
struct snoop *snp = &snoopsw[unit];
struct tty *tp, *tpo;
- struct tty_tab *l_tty, *l_otty;
switch (cmd) {
case SNPSTTY:
- tunit = ((struct snptty *) data)->st_unit;
- ttype = ((struct snptty *) data)->st_type;
-
- if (ttype == -1 || tunit == -1)
+ tdev = *((dev_t *) data);
+ if (tdev == -1)
return (snpdown(snp));
- if (ttype < 0 || ttype > ST_MAXTYPE)
- return (EINVAL);
-
- l_tty = &tty_tabs[ttype];
- if (l_tty->lt_tab == NULL)
- return (EINVAL);
-
- if (tunit < 0 || tunit >= l_tty->lt_max)
+ tp = devtotty(tdev);
+ if (!tp)
return (EINVAL);
- tp = &((*l_tty->lt_tab)[tunit]);
-
- if (tp->t_sc != (caddr_t) snp && (tp->t_state & TS_SNOOP))
+ if ((tp->t_sc != (caddr_t) snp) && (tp->t_state & TS_SNOOP))
return (EBUSY);
- if (tp->t_line != OTTYDISC && tp->t_line != NTTYDISC)
+ if ((tp->t_line != OTTYDISC) && (tp->t_line != NTTYDISC))
return (EBUSY);
s = spltty();
- if (snp->snp_unit != -1) {
- l_otty = &tty_tabs[snp->snp_type];
- tpo = &((*l_otty->lt_tab)[snp->snp_unit]);
- tpo->t_state &= ~TS_SNOOP;
+
+ if (snp->snp_target == -1) {
+ tpo = devtotty(snp->snp_target);
+ if (tpo)
+ tpo->t_state &= ~TS_SNOOP;
}
+
tp->t_sc = (caddr_t) snp;
tp->t_state |= TS_SNOOP;
- snp->snp_unit = tunit;
- snp->snp_type = ttype;
+ snp->snp_target = tdev;
+
/*
* Clean overflow and down flags -
* we'll have a chance to get them in the future :)))
@@ -424,11 +354,10 @@ snpioctl(dev, cmd, data, flag)
snp->snp_flags &= ~SNOOP_OFLOW;
snp->snp_flags &= ~SNOOP_DOWN;
splx(s);
-
break;
+
case SNPGTTY:
- ((struct snptty *) data)->st_unit = snp->snp_unit;
- ((struct snptty *) data)->st_type = snp->snp_type;
+ *((dev_t *) data) = snp->snp_target;
break;
case FIONBIO:
@@ -437,19 +366,21 @@ snpioctl(dev, cmd, data, flag)
else
snp->snp_flags &= ~SNOOP_NBIO;
break;
+
case FIOASYNC:
if (*(int *) data)
snp->snp_flags |= SNOOP_ASYNC;
else
snp->snp_flags &= ~SNOOP_ASYNC;
break;
+
case FIONREAD:
s = spltty();
- if (snp->snp_unit != -1)
+ if (snp->snp_target != -1)
*(int *) data = snp->snp_len;
else
- if (snp->snp_flags&SNOOP_DOWN) {
- if (snp->snp_flags&SNOOP_OFLOW)
+ if (snp->snp_flags & SNOOP_DOWN) {
+ if (snp->snp_flags & SNOOP_OFLOW)
*(int *) data = SNP_OFLOW;
else
*(int *) data = SNP_TTYCLOSE;
@@ -458,6 +389,7 @@ snpioctl(dev, cmd, data, flag)
}
splx(s);
break;
+
default:
return (ENOTTY);
}
@@ -474,20 +406,20 @@ snpselect(dev, rw, p)
int unit = minor(dev), s;
struct snoop *snp = &snoopsw[unit];
- if (rw != FREAD) {
+ if (rw != FREAD)
return 0;
- }
- if (snp->snp_len > 0) {
+
+ if (snp->snp_len > 0)
return 1;
- }
+
/*
* If snoop is down,we don't want to select() forever so we return 1.
* Caller should see if we down via FIONREAD ioctl().The last should
* return -1 to indicate down state.
*/
- if (snp->snp_flags & SNOOP_DOWN) {
+ if (snp->snp_flags & SNOOP_DOWN)
return 1;
- }
+
selrecord(p, &snp->snp_sel);
return 0;
}
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 1671125b731f..379776bab639 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -25,10 +25,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.c,v 1.104 1995/02/22 13:40:19 sos Exp $
*/
#include "sc.h"
+#include "apm.h"
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,6 +51,7 @@
#include <machine/psl.h>
#include <machine/frame.h>
#include <machine/pc/display.h>
+#include <machine/apm_bios.h>
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
@@ -61,10 +63,6 @@
#if !defined(MAXCONS)
#define MAXCONS 16
#endif
-#include "apm.h"
-#if NAPM > 0
-#include "machine/apm_bios.h"
-#endif
/* this may break on older VGA's but is usefull on real 32 bit systems */
#define bcopyw bcopy
@@ -218,6 +216,19 @@ sc_registerdev(struct isa_device *id)
dev_attach(&kdc_sc[id->id_unit]);
}
+#if NAPM > 0
+static int
+scresume(void *dummy)
+{
+ shfts = 0;
+ ctls = 0;
+ alts = 0;
+ agrs = 0;
+ metas = 0;
+ return 0;
+}
+#endif
+
int
scattach(struct isa_device *dev)
{
@@ -267,7 +278,7 @@ scattach(struct isa_device *dev)
update_leds(scp->status);
sc_registerdev(dev);
#if NAPM > 0
- scp->r_hook.ah_fun = pcresume;
+ scp->r_hook.ah_fun = scresume;
scp->r_hook.ah_arg = NULL;
scp->r_hook.ah_name = "system keyboard";
scp->r_hook.ah_order = APM_MID_ORDER;
@@ -276,8 +287,8 @@ scattach(struct isa_device *dev)
return 0;
}
-static struct tty
-*get_tty_ptr(dev_t dev)
+struct tty
+*scdevtotty(dev_t dev)
{
int unit = minor(dev);
@@ -288,6 +299,17 @@ static struct tty
return VIRTUAL_TTY(unit);
}
+int
+scselect(dev_t dev, int rw, struct proc *p)
+{
+ struct tty *tp = scdevtotty(dev);
+
+ if (tp == NULL)
+ return(ENXIO);
+
+ return (ttyselect(tp, rw, p));
+}
+
static scr_stat
*get_scr_stat(dev_t dev)
{
@@ -313,7 +335,7 @@ get_scr_num()
int
scopen(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -344,7 +366,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
int
scclose(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
struct scr_stat *scp;
if (!tp)
@@ -379,7 +401,7 @@ scclose(dev_t dev, int flag, int mode, struct proc *p)
int
scread(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -389,7 +411,7 @@ scread(dev_t dev, struct uio *uio, int flag)
int
scwrite(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -458,7 +480,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
struct trapframe *fp;
scr_stat *scp;
- tp = get_tty_ptr(dev);
+ tp = scdevtotty(dev);
if (!tp)
return ENXIO;
scp = get_scr_stat(tp->t_dev);
@@ -1050,7 +1072,7 @@ set_mouse_pos:
void
scxint(dev_t dev)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return;
@@ -1094,19 +1116,6 @@ scstart(struct tty *tp)
splx(s);
}
-#if NAPM > 0
-static int
-scresume(void *dummy)
-{
- shfts = 0;
- ctls = 0;
- alts = 0;
- agrs = 0;
- metas = 0;
- return 0;
-}
-#endif
-
void
pccnprobe(struct consdev *cp)
{
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 546b2de63316..60cf84eb94db 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -25,9 +25,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.h,v 1.1 1995/02/22 13:40:21 sos Exp $
*/
+/*
+ * The APM stuff is -not- under conditional compilation because we don't want
+ * the size of the scr_stat structure to vary depending upon if APM has been
+ * compiled in or not, that can cause utilities and lkms to crash!
+ */
+#include <machine/apm_bios.h>
+
/* vm things */
#define ISMAPPED(pa, width) \
(((pa) <= (u_long)0x1000 - (width)) \
@@ -140,9 +147,7 @@ typedef struct scr_stat {
u_short *history_pos; /* position shown on screen */
u_short *history_save; /* save area index */
int history_size; /* size of history buffer */
-#if NAPM > 0
struct apmhook r_hook; /* reconfiguration support */
-#endif
} scr_stat;
typedef struct default_attr {
diff --git a/sys/gnu/isdn/iitty.c b/sys/gnu/isdn/iitty.c
index bb3ac0646f05..0ca62f5ff6c6 100644
--- a/sys/gnu/isdn/iitty.c
+++ b/sys/gnu/isdn/iitty.c
@@ -1,6 +1,6 @@
-static char _ittyid[] = "@(#)$Id: iitty.c,v 1.1 1995/02/14 15:00:32 jkh Exp $";
+static char _ittyid[] = "@(#)$Id: iitty.c,v 1.2 1995/02/15 06:28:28 jkh Exp $";
/*******************************************************************************
- * II - Version 0.1 $Revision: 1.1 $ $State: Exp $
+ * II - Version 0.1 $Revision: 1.2 $ $State: Exp $
*
* Copyright 1994 Dietmar Friede
*******************************************************************************
@@ -10,6 +10,9 @@ static char _ittyid[] = "@(#)$Id: iitty.c,v 1.1 1995/02/14 15:00:32 jkh Exp
*
*******************************************************************************
* $Log: iitty.c,v $
+ * Revision 1.2 1995/02/15 06:28:28 jkh
+ * Fix up include paths, nuke some warnings.
+ *
* Revision 1.1 1995/02/14 15:00:32 jkh
* An ISDN driver that supports the EDSS1 and the 1TR6 ISDN interfaces.
* EDSS1 is the "Euro-ISDN", 1TR6 is the soon obsolete german ISDN Interface.
@@ -321,10 +324,24 @@ itystop(struct tty *tp, int flag)
splx(s);
}
+struct tty *
+itydevtotty(dev_t dev)
+{
+ register int unit = UNIT(dev);
+ if (unit >= next_if)
+ return (NULL);
+
+ return (&ity_tty[unit]);
+}
+
int
ityselect(dev_t dev, int rw, struct proc *p)
{
- return (ttselect(dev, rw, p));
+ register int unit = UNIT(dev);
+ if (unit >= next_if)
+ return (ENXIO);
+
+ return (ttyselect(&ity_tty[unit], rw, p));
}
#endif
diff --git a/sys/i386/i386/conf.c b/sys/i386/i386/conf.c
index 6372438be610..e15e85aef4c2 100644
--- a/sys/i386/i386/conf.c
+++ b/sys/i386/i386/conf.c
@@ -42,7 +42,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
- * $Id: conf.c,v 1.66 1995/02/15 12:01:24 jkh Exp $
+ * $Id: conf.c,v 1.67 1995/02/21 04:26:35 jkh Exp $
*/
#include <sys/param.h>
@@ -69,6 +69,7 @@ d_strategy_t swstrategy;
#define nommap (d_mmap_t *)enodev
#define nostrat (d_strategy_t *)enodev
#define nodump (d_dump_t *)enodev
+#define nodevtotty (d_ttycv_t *)nullop
#define nxopen (d_open_t *)enxio
#define nxclose (d_close_t *)enxio
@@ -81,6 +82,7 @@ d_strategy_t swstrategy;
#define nxreset (d_reset_t *)enxio
#define nxselect (d_select_t *)enxio
#define nxmmap (d_mmap_t *)enxio
+#define nxdevtotty (d_ttycv_t *)nullop
#define nullopen (d_open_t *)nullop
#define nullclose (d_close_t *)nullop
@@ -352,17 +354,19 @@ int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
d_open_t scopen;
d_close_t scclose;
d_rdwr_t scread, scwrite;
+d_select_t scselect;
d_ioctl_t scioctl;
d_mmap_t scmmap;
-extern struct tty sccons[];
+d_ttycv_t scdevtotty;
#else
#define scopen nxopen
#define scclose nxclose
#define scread nxread
#define scwrite nxwrite
+#define scselect nxselect
#define scioctl nxioctl
#define scmmap nxmmap
-#define sccons NULL
+#define scdevtotty nxdevtotty
#endif
/* controlling TTY */
@@ -371,6 +375,7 @@ d_rdwr_t cttyread;
d_rdwr_t cttywrite;
d_ioctl_t cttyioctl;
d_select_t cttyselect;
+d_ttycv_t cttydevtotty;
/* /dev/mem */
d_open_t mmopen;
@@ -383,28 +388,31 @@ d_mmap_t memmmap;
#if NPTY > 0
d_open_t ptsopen;
d_close_t ptsclose;
-d_rdwr_t ptsread, ptswrite;
+d_rdwr_t ptsread;
+d_rdwr_t ptswrite;
d_stop_t ptsstop;
+d_select_t ptsselect;
d_open_t ptcopen;
d_close_t ptcclose;
d_rdwr_t ptcread;
d_rdwr_t ptcwrite;
d_select_t ptcselect;
+d_ttycv_t ptydevtotty;
d_ioctl_t ptyioctl;
-extern struct tty pt_tty[];
#else
#define ptsopen nxopen
#define ptsclose nxclose
#define ptsread nxread
#define ptswrite nxwrite
+#define ptsselect nxselect
#define ptcopen nxopen
#define ptcclose nxclose
#define ptcread nxread
#define ptcwrite nxwrite
#define ptyioctl nxioctl
-#define pt_tty NULL
#define ptcselect nxselect
#define ptsstop nullstop
+#define ptydevtotty nxdevtotty
#endif
@@ -466,12 +474,14 @@ d_open_t twopen;
d_close_t twclose;
d_rdwr_t twread, twwrite;
d_select_t twselect;
+d_ttycv_t twdevtotty;
#else
#define twopen nxopen
#define twclose nxclose
#define twread nxread
#define twwrite nxwrite
#define twselect nxselect
+#define twdevtotty nxdevtotty
#endif
#include "psm.h"
@@ -589,8 +599,8 @@ d_rdwr_t sioread, siowrite;
d_ioctl_t sioioctl;
d_select_t sioselect;
d_stop_t siostop;
+d_ttycv_t siodevtotty;
#define sioreset nxreset
-extern struct tty sio_tty[];
#else
#define sioopen nxopen
#define sioclose nxclose
@@ -600,7 +610,7 @@ extern struct tty sio_tty[];
#define siostop nxstop
#define sioreset nxreset
#define sioselect nxselect
-#define sio_tty (struct tty *)NULL
+#define siodevtotty nxdevtotty
#endif
#include "su.h"
@@ -702,7 +712,6 @@ d_rdwr_t cxread, cxwrite;
d_ioctl_t cxioctl;
d_select_t cxselect;
d_stop_t cxstop;
-extern struct tty cx_tty[];
#else
#define cxopen nxopen
#define cxclose nxclose
@@ -711,7 +720,6 @@ extern struct tty cx_tty[];
#define cxioctl nxioctl
#define cxstop nxstop
#define cxselect nxselect
-#define cx_tty (struct tty *)NULL
#endif
#include "gp.h"
@@ -797,10 +805,10 @@ d_write_t cywrite;
d_ioctl_t cyioctl;
d_stop_t cystop;
d_select_t cyselect;
+d_ttycv_t cydevtotty;
#define cyreset nxreset
#define cymmap nxmmap
#define cystrategy nxstrategy
-extern struct tty cy_tty[];
#else
#define cyopen nxopen
#define cyclose nxclose
@@ -812,7 +820,7 @@ extern struct tty cy_tty[];
#define cyselect nxselect
#define cymmap nxmmap
#define cystrategy nxstrategy
-#define cy_tty (struct tty *)NULL
+#define cydevtotty nxdevtotty
#endif
#include "ity.h"
@@ -823,8 +831,8 @@ d_read_t ityread;
d_write_t itywrite;
d_ioctl_t ityioctl;
d_select_t ityselect;
+d_ttycv_t itydevtotty;
#define ityreset nxreset
-extern struct tty ity_tty[];
#else
#define ityopen nxopen
#define ityclose nxclose
@@ -833,7 +841,7 @@ extern struct tty ity_tty[];
#define ityioctl nxioctl
#define ityreset nxreset
#define ityselect nxselect
-#define ity_tty (struct tty *)NULL
+#define itydevtotty nxdevtotty
#endif
#include "nic.h"
@@ -906,196 +914,196 @@ d_ioctl_t ispyioctl;
struct cdevsw cdevsw[] =
{
{ cnopen, cnclose, cnread, cnwrite, /*0*/
- cnioctl, nullstop, nullreset, NULL, /* console */
+ cnioctl, nullstop, nullreset, nodevtotty,/* console */
cnselect, nommap, NULL },
{ cttyopen, nullclose, cttyread, cttywrite, /*1*/
- cttyioctl, nullstop, nullreset, NULL, /* tty */
+ cttyioctl, nullstop, nullreset, nodevtotty,/* tty */
cttyselect, nommap, NULL },
{ mmopen, mmclose, mmrw, mmrw, /*2*/
- noioc, nullstop, nullreset, NULL, /* memory */
+ noioc, nullstop, nullreset, nodevtotty,/* memory */
mmselect, memmmap, NULL },
{ wdopen, wdclose, rawread, rawwrite, /*3*/
- wdioctl, nostop, nullreset, NULL, /* wd */
+ wdioctl, nostop, nullreset, nodevtotty,/* wd */
seltrue, nommap, wdstrategy },
{ nullopen, nullclose, rawread, rawwrite, /*4*/
- noioc, nostop, noreset, NULL, /* swap */
+ noioc, nostop, noreset, nodevtotty,/* swap */
noselect, nommap, swstrategy },
{ ptsopen, ptsclose, ptsread, ptswrite, /*5*/
- ptyioctl, ptsstop, nullreset, pt_tty, /* ttyp */
- ttselect, nommap, NULL },
+ ptyioctl, ptsstop, nullreset, ptydevtotty,/* ttyp */
+ ptsselect, nommap, NULL },
{ ptcopen, ptcclose, ptcread, ptcwrite, /*6*/
- ptyioctl, nullstop, nullreset, pt_tty, /* ptyp */
+ ptyioctl, nullstop, nullreset, ptydevtotty,/* ptyp */
ptcselect, nommap, NULL },
{ logopen, logclose, logread, nowrite, /*7*/
- logioctl, nostop, nullreset, NULL, /* klog */
+ logioctl, nostop, nullreset, nodevtotty,/* klog */
logselect, nommap, NULL },
{ bquopen, bquclose, bquread, bquwrite, /*8*/
- bquioctl, nostop, nullreset, NULL, /* tputer */
+ bquioctl, nostop, nullreset, nodevtotty,/* tputer */
bquselect, nommap, NULL },
{ Fdopen, fdclose, rawread, rawwrite, /*9*/
- fdioctl, nostop, nullreset, NULL, /* Fd (!=fd) */
+ fdioctl, nostop, nullreset, nodevtotty,/* Fd (!=fd) */
seltrue, nommap, fdstrategy },
{ wtopen, wtclose, rawread, rawwrite, /*10*/
- wtioctl, nostop, nullreset, NULL, /* wt */
+ wtioctl, nostop, nullreset, nodevtotty,/* wt */
seltrue, nommap, wtstrategy },
{ spigot_open, spigot_close, spigot_read, spigot_write, /*11*/
- spigot_ioctl, nostop, nullreset, NULL, /* Spigot */
+ spigot_ioctl, nostop, nullreset, nodevtotty,/* Spigot */
spigot_select, spigot_mmap, NULL },
{ scopen, scclose, scread, scwrite, /*12*/
- scioctl, nullstop, nullreset, sccons, /* sc */
- ttselect, scmmap, NULL },
+ scioctl, nullstop, nullreset, scdevtotty,/* sc */
+ scselect, scmmap, NULL },
{ sdopen, sdclose, rawread, rawwrite, /*13*/
- sdioctl, nostop, nullreset, NULL, /* sd */
+ sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy },
{ stopen, stclose, rawread, rawwrite, /*14*/
- stioctl, nostop, nullreset, NULL, /* st */
+ stioctl, nostop, nullreset, nodevtotty,/* st */
seltrue, nommap, ststrategy },
{ cdopen, cdclose, rawread, nowrite, /*15*/
- cdioctl, nostop, nullreset, NULL, /* cd */
+ cdioctl, nostop, nullreset, nodevtotty,/* cd */
seltrue, nommap, cdstrategy },
{ lptopen, lptclose, noread, lptwrite, /*16*/
- lptioctl, nullstop, nullreset, NULL, /* lpt */
+ lptioctl, nullstop, nullreset, nodevtotty,/* lpt */
seltrue, nommap, nostrat},
{ chopen, chclose, noread, nowrite, /*17*/
- chioctl, nostop, nullreset, NULL, /* ch */
+ chioctl, nostop, nullreset, nodevtotty,/* ch */
noselect, nommap, nostrat },
{ suopen, suclose, suread, suwrite, /*18*/
- suioctl, nostop, nullreset, NULL, /* scsi */
+ suioctl, nostop, nullreset, nodevtotty,/* scsi */
suselect, summap, sustrategy }, /* 'generic' */
{ twopen, twclose, twread, twwrite, /*19*/
- noioc, nullstop, nullreset, NULL, /* tw */
+ noioc, nullstop, nullreset, nodevtotty,/* tw */
twselect, nommap, nostrat },
/*
* If you need a cdev major number for a driver that you intend to donate
* back to the group or release publically, please contact the FreeBSD team
- * by sending mail to "FreeBSD-hackers@freefall.cdrom.com".
+ * by sending mail to "hackers@freebsd.org".
* If you assign one yourself it may conflict with someone else.
* Otherwise, simply use the one reserved for local use.
*/
/* character device 20 is reserved for local use */
{ nxopen, nxclose, nxread, /*20*/
nxwrite, nxioctl, nxstop,
- nxreset, NULL, nxselect,
+ nxreset, nxdevtotty, nxselect,
nxmmap, NULL },
{ psmopen, psmclose, psmread, nowrite, /*21*/
- psmioctl, nostop, nullreset, NULL, /* psm mice */
+ psmioctl, nostop, nullreset, nodevtotty,/* psm mice */
psmselect, nommap, NULL },
{ fdopen, noclose, noread, nowrite, /*22*/
- noioc, nostop, nullreset, NULL, /* fd (!=Fd) */
+ noioc, nostop, nullreset, nodevtotty,/* fd (!=Fd) */
noselect, nommap, nostrat },
{ bpfopen, bpfclose, bpfread, bpfwrite, /*23*/
- bpfioctl, nostop, nullreset, NULL, /* bpf */
+ bpfioctl, nostop, nullreset, nodevtotty,/* bpf */
bpfselect, nommap, NULL },
{ pcaopen, pcaclose, noread, pcawrite, /*24*/
- pcaioctl, nostop, nullreset, NULL, /* pcaudio */
+ pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */
pcaselect, nommap, NULL },
{ vaopen, vaclose, varead, vawrite, /*25*/
- vaioctl, nostop, nullreset, NULL, /* vat */
+ vaioctl, nostop, nullreset, nodevtotty,/* vat */
vaselect, nommap, NULL },
{ spkropen, spkrclose, noread, spkrwrite, /*26*/
- spkrioctl, nostop, nullreset, NULL, /* spkr */
+ spkrioctl, nostop, nullreset, nodevtotty,/* spkr */
seltrue, nommap, NULL },
{ mseopen, mseclose, mseread, nowrite, /*27*/
- noioc, nostop, nullreset, NULL, /* mse */
+ noioc, nostop, nullreset, nodevtotty,/* mse */
mseselect, nommap, NULL },
{ sioopen, sioclose, sioread, siowrite, /*28*/
- sioioctl, siostop, sioreset, sio_tty, /* sio */
+ sioioctl, siostop, sioreset, siodevtotty,/* sio */
sioselect, nommap, NULL },
{ mcdopen, mcdclose, rawread, nowrite, /*29*/
- mcdioctl, nostop, nullreset, NULL, /* mitsumi cd */
+ mcdioctl, nostop, nullreset, nodevtotty,/* mitsumi cd */
seltrue, nommap, mcdstrategy },
{ sndopen, sndclose, sndread, sndwrite, /*30*/
- sndioctl, nostop, nullreset, NULL, /* sound */
+ sndioctl, nostop, nullreset, nodevtotty,/* sound */
sndselect, nommap, NULL },
{ ukopen, ukclose, noread, nowrite, /*31*/
- ukioctl, nostop, nullreset, NULL, /* unknown */
- seltrue, nommap, NULL }, /* scsi */
+ ukioctl, nostop, nullreset, nodevtotty,/* unknown */
+ seltrue, nommap, NULL }, /* scsi */
{ lkmcopen, lkmcclose, noread, nowrite, /*32*/
- lkmcioctl, nostop, nullreset, NULL,
+ lkmcioctl, nostop, nullreset, nodevtotty,
noselect, nommap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*33*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*34*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*35*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*36*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*37*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ lkmopen, lkmclose, lkmread, lkmwrite, /*38*/
- lkmioctl, lkmstop, lkmreset, NULL,
+ lkmioctl, lkmstop, lkmreset, nodevtotty,
lkmselect, lkmmmap, NULL },
{ apmopen, apmclose, noread, nowrite, /*39*/
- apmioctl, nostop, nullreset, NULL, /* laptop APM */
+ apmioctl, nostop, nullreset, nodevtotty,/* APM */
seltrue, nommap, NULL },
{ ctxopen, ctxclose, ctxread, ctxwrite, /*40*/
- ctxioctl, nostop, nullreset, NULL, /* cortex */
+ ctxioctl, nostop, nullreset, nodevtotty,/* cortex */
seltrue, nommap, NULL },
{ sockopen, sockclose, noread, nowrite, /*41*/
- sockioctl, nostop, nullreset, NULL, /* socksys */
+ sockioctl, nostop, nullreset, nodevtotty,/* socksys */
seltrue, nommap, NULL },
{ cxopen, cxclose, cxread, cxwrite, /*42*/
- cxioctl, cxstop, nullreset, cx_tty, /* cronyx */
+ cxioctl, cxstop, nullreset, nodevtotty,/* cronyx */
cxselect, nommap, NULL },
{ vnopen, vnclose, rawread, rawwrite, /*43*/
- vnioctl, nostop, nullreset, NULL, /* vn */
+ vnioctl, nostop, nullreset, nodevtotty,/* vn */
seltrue, nommap, vnstrategy },
{ gpopen, gpclose, noread, gpwrite, /*44*/
- gpioctl, nostop, nullreset, NULL, /* GPIB */
+ gpioctl, nostop, nullreset, nodevtotty,/* GPIB */
seltrue, nommap, NULL },
{ scdopen, scdclose, rawread, nowrite, /*45*/
- scdioctl, nostop, nullreset, NULL, /* sony cd */
+ scdioctl, nostop, nullreset, nodevtotty,/* sony cd */
seltrue, nommap, scdstrategy },
{ pcdopen, pcdclose, rawread, nowrite, /*46*/
- pcdioctl, nostop, nullreset, NULL, /* pana cd */
+ pcdioctl, nostop, nullreset, nodevtotty,/* pana cd */
seltrue, nommap, pcdstrategy },
{ gscopen, gscclose, gscread, nowrite, /*47*/
- gscioctl, nostop, nullreset, NULL, /* gsc */
+ gscioctl, nostop, nullreset, nodevtotty,/* gsc */
seltrue, nommap, NULL },
{ cyopen, cyclose, cyread, cywrite, /*48*/
- cyioctl, cystop, cyreset, cy_tty,
- cyselect, cymmap, cystrategy }, /* cyclades */
+ cyioctl, cystop, cyreset, cydevtotty,/*cyclades*/
+ cyselect, cymmap, cystrategy },
{ sscopen, sscclose, sscread, sscwrite, /*49*/
- sscioctl, nostop, nullreset, NULL, /* scsi super */
+ sscioctl, nostop, nullreset, nodevtotty,/* scsi super */
sscselect, sscmmap, sscstrategy },
{ nxopen, nxclose, nxread, nxwrite, /*50*/
- nxioctl, nxstop, nxreset, NULL, /* pcmcia */
+ nxioctl, nxstop, nxreset, nodevtotty,/* pcmcia */
nxselect, nxmmap, NULL },
{ joyopen, joyclose, joyread, nowrite, /*51*/
- joyioctl, nostop, nullreset, NULL, /*joystick */
+ joyioctl, nostop, nullreset, nodevtotty,/*joystick */
seltrue, nommap, NULL},
{ tunopen, tunclose, tunread, tunwrite, /*52*/
- tunioctl, nostop, nullreset, NULL, /* tunnel */
+ tunioctl, nostop, nullreset, nodevtotty,/* tunnel */
tunselect, nommap, NULL },
{ snpopen, snpclose, snpread, nowrite, /*53*/
- snpioctl, nostop, nullreset, NULL, /* snoop */
+ snpioctl, nostop, nullreset, nodevtotty,/* snoop */
snpselect, nommap, NULL },
{ nicopen, nicclose, noread, nowrite, /*54*/
- nicioctl, nostop, nullreset, NULL, /* nic */
+ nicioctl, nostop, nullreset, nodevtotty,/* nic */
seltrue, nommap, NULL },
{ isdnopen, isdnclose, isdnread, nowrite, /*55*/
- isdnioctl, nostop, nullreset, NULL, /* isdn */
+ isdnioctl, nostop, nullreset, nodevtotty,/* isdn */
seltrue, nommap, NULL },
{ ityopen, ityclose, ityread, itywrite, /*56*/
- ityioctl, nostop, ityreset, ity_tty,/* ity */
+ ityioctl, nostop, ityreset, itydevtotty,/* ity */
ityselect, nommap, NULL },
{ itelopen, itelclose, itelread, itelwrite, /*57*/
- itelioctl, nostop, nullreset, NULL, /* itel */
+ itelioctl, nostop, nullreset, nodevtotty,/* itel */
seltrue, nommap, NULL },
{ nxopen, nxclose, nxread, nxwrite, /*58*/
- nxioctl, nxstop, nxreset, NULL, /* unused */
+ nxioctl, nxstop, nxreset, nxdevtotty,/* unused */
seltrue, nxmmap, NULL },
{ ispyopen, ispyclose, ispyread, nowrite, /*59*/
- ispyioctl, nostop, nullreset, NULL, /* ispy */
+ ispyioctl, nostop, nullreset, nodevtotty,/* ispy */
seltrue, nommap, NULL },
{ nnicopen, nnicclose, noread, nowrite, /*60*/
- nnicioctl, nostop, nullreset, NULL, /* nnic */
+ nnicioctl, nostop, nullreset, nodevtotty,/* nnic */
seltrue, nommap, NULL },
};
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
diff --git a/sys/i386/i386/cons.c b/sys/i386/i386/cons.c
index 611cfdbdaaa1..9e0f47f14285 100644
--- a/sys/i386/i386/cons.c
+++ b/sys/i386/i386/cons.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
- * $Id: cons.c,v 1.20 1995/01/21 14:12:15 bde Exp $
+ * $Id: cons.c,v 1.21 1995/01/23 18:46:13 davidg Exp $
*/
#include <sys/param.h>
@@ -229,7 +229,10 @@ cnselect(dev, rw, p)
{
if (cn_tab == NULL)
return (1);
- return (ttselect(cn_tab->cn_dev, rw, p));
+
+ dev = cn_tab->cn_dev;
+
+ return ((*cdevsw[major(dev)].d_select)(dev, rw, p));
}
int
diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c
index f1729b6f7e4c..f7a53fed428d 100644
--- a/sys/i386/isa/cx.c
+++ b/sys/i386/isa/cx.c
@@ -678,12 +678,7 @@ int cxselect (dev_t dev, int flag, struct proc *p)
if (unit == UNIT_CTL)
return (0);
-#ifdef __FreeBSD__
- return (ttselect (dev, flag, p));
-#endif
-#ifdef __bsdi__
return (ttyselect (cxchan[unit]->ttyp, flag, p));
-#endif
}
/*
diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c
index 3bd203bcb2aa..ff67eb436198 100644
--- a/sys/i386/isa/cy.c
+++ b/sys/i386/isa/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.1 1995/02/09 09:47:27 jkh Exp $
+ * $Id: cy.c,v 1.2 1995/02/15 18:41:41 bde Exp $
*/
/*
@@ -1500,13 +1500,26 @@ cystop(struct tty *tp, int flag)
return 0;
}
+struct tty *
+cydevtotty(dev_t dev)
+{
+ u_char unit = UNIT(dev);
+
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return NULL;
+
+ return info[unit]->tty;
+}
int
cyselect(dev_t dev, int rw, struct proc *p)
{
- return (ttselect(UNIT(dev), rw, p));
-} /* end of cyselect() */
+ u_char unit = UNIT(dev);
+ if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM)
+ return (ENXIO);
+ return (ttyselect(info[unit]->tty, rw, p));
+}
int
cyspeed(int speed, int *prescaler_io)
diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c
index c2841501ba9a..39bec6dd050e 100644
--- a/sys/i386/isa/sio.c
+++ b/sys/i386/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.65 1995/01/20 07:34:15 wpaul Exp $
+ * $Id: sio.c,v 1.66 1995/02/24 00:11:01 ache Exp $
*/
#include "sio.h"
@@ -1819,15 +1819,50 @@ siostop(tp, rw)
enable_intr();
}
+struct tty *
+siodevtotty(dev)
+ dev_t dev;
+{
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
+ return NULL;
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return NULL;
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return NULL;
+
+ return com->tp;
+}
+
int
sioselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
- if (minor(dev) & CONTROL_MASK)
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
return (ENODEV);
- return (ttselect(dev & ~MINOR_MAGIC_MASK, rw, p));
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return (ENXIO);
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return (ENXIO);
+
+ return (ttyselect(com->tp, rw, p));
}
static void
diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c
index 1671125b731f..379776bab639 100644
--- a/sys/i386/isa/syscons.c
+++ b/sys/i386/isa/syscons.c
@@ -25,10 +25,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.c,v 1.104 1995/02/22 13:40:19 sos Exp $
*/
#include "sc.h"
+#include "apm.h"
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,6 +51,7 @@
#include <machine/psl.h>
#include <machine/frame.h>
#include <machine/pc/display.h>
+#include <machine/apm_bios.h>
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
@@ -61,10 +63,6 @@
#if !defined(MAXCONS)
#define MAXCONS 16
#endif
-#include "apm.h"
-#if NAPM > 0
-#include "machine/apm_bios.h"
-#endif
/* this may break on older VGA's but is usefull on real 32 bit systems */
#define bcopyw bcopy
@@ -218,6 +216,19 @@ sc_registerdev(struct isa_device *id)
dev_attach(&kdc_sc[id->id_unit]);
}
+#if NAPM > 0
+static int
+scresume(void *dummy)
+{
+ shfts = 0;
+ ctls = 0;
+ alts = 0;
+ agrs = 0;
+ metas = 0;
+ return 0;
+}
+#endif
+
int
scattach(struct isa_device *dev)
{
@@ -267,7 +278,7 @@ scattach(struct isa_device *dev)
update_leds(scp->status);
sc_registerdev(dev);
#if NAPM > 0
- scp->r_hook.ah_fun = pcresume;
+ scp->r_hook.ah_fun = scresume;
scp->r_hook.ah_arg = NULL;
scp->r_hook.ah_name = "system keyboard";
scp->r_hook.ah_order = APM_MID_ORDER;
@@ -276,8 +287,8 @@ scattach(struct isa_device *dev)
return 0;
}
-static struct tty
-*get_tty_ptr(dev_t dev)
+struct tty
+*scdevtotty(dev_t dev)
{
int unit = minor(dev);
@@ -288,6 +299,17 @@ static struct tty
return VIRTUAL_TTY(unit);
}
+int
+scselect(dev_t dev, int rw, struct proc *p)
+{
+ struct tty *tp = scdevtotty(dev);
+
+ if (tp == NULL)
+ return(ENXIO);
+
+ return (ttyselect(tp, rw, p));
+}
+
static scr_stat
*get_scr_stat(dev_t dev)
{
@@ -313,7 +335,7 @@ get_scr_num()
int
scopen(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -344,7 +366,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
int
scclose(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
struct scr_stat *scp;
if (!tp)
@@ -379,7 +401,7 @@ scclose(dev_t dev, int flag, int mode, struct proc *p)
int
scread(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -389,7 +411,7 @@ scread(dev_t dev, struct uio *uio, int flag)
int
scwrite(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -458,7 +480,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
struct trapframe *fp;
scr_stat *scp;
- tp = get_tty_ptr(dev);
+ tp = scdevtotty(dev);
if (!tp)
return ENXIO;
scp = get_scr_stat(tp->t_dev);
@@ -1050,7 +1072,7 @@ set_mouse_pos:
void
scxint(dev_t dev)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return;
@@ -1094,19 +1116,6 @@ scstart(struct tty *tp)
splx(s);
}
-#if NAPM > 0
-static int
-scresume(void *dummy)
-{
- shfts = 0;
- ctls = 0;
- alts = 0;
- agrs = 0;
- metas = 0;
- return 0;
-}
-#endif
-
void
pccnprobe(struct consdev *cp)
{
diff --git a/sys/i386/isa/syscons.h b/sys/i386/isa/syscons.h
index 546b2de63316..60cf84eb94db 100644
--- a/sys/i386/isa/syscons.h
+++ b/sys/i386/isa/syscons.h
@@ -25,9 +25,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.h,v 1.1 1995/02/22 13:40:21 sos Exp $
*/
+/*
+ * The APM stuff is -not- under conditional compilation because we don't want
+ * the size of the scr_stat structure to vary depending upon if APM has been
+ * compiled in or not, that can cause utilities and lkms to crash!
+ */
+#include <machine/apm_bios.h>
+
/* vm things */
#define ISMAPPED(pa, width) \
(((pa) <= (u_long)0x1000 - (width)) \
@@ -140,9 +147,7 @@ typedef struct scr_stat {
u_short *history_pos; /* position shown on screen */
u_short *history_save; /* save area index */
int history_size; /* size of history buffer */
-#if NAPM > 0
struct apmhook r_hook; /* reconfiguration support */
-#endif
} scr_stat;
typedef struct default_attr {
diff --git a/sys/isa/sio.c b/sys/isa/sio.c
index c2841501ba9a..39bec6dd050e 100644
--- a/sys/isa/sio.c
+++ b/sys/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.65 1995/01/20 07:34:15 wpaul Exp $
+ * $Id: sio.c,v 1.66 1995/02/24 00:11:01 ache Exp $
*/
#include "sio.h"
@@ -1819,15 +1819,50 @@ siostop(tp, rw)
enable_intr();
}
+struct tty *
+siodevtotty(dev)
+ dev_t dev;
+{
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
+ return NULL;
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return NULL;
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return NULL;
+
+ return com->tp;
+}
+
int
sioselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
- if (minor(dev) & CONTROL_MASK)
+ register int mynor, unit;
+ struct com_s *com;
+
+ mynor = minor(dev);
+ if (mynor & CONTROL_MASK)
return (ENODEV);
- return (ttselect(dev & ~MINOR_MAGIC_MASK, rw, p));
+
+ unit = MINOR_TO_UNIT(mynor);
+ if (unit >= NSIO)
+ return (ENXIO);
+
+ com = com_addr(unit);
+ if (com == NULL)
+ return (ENXIO);
+
+ return (ttyselect(com->tp, rw, p));
}
static void
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c
index 1671125b731f..379776bab639 100644
--- a/sys/isa/syscons.c
+++ b/sys/isa/syscons.c
@@ -25,10 +25,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.c,v 1.104 1995/02/22 13:40:19 sos Exp $
*/
#include "sc.h"
+#include "apm.h"
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,6 +51,7 @@
#include <machine/psl.h>
#include <machine/frame.h>
#include <machine/pc/display.h>
+#include <machine/apm_bios.h>
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
@@ -61,10 +63,6 @@
#if !defined(MAXCONS)
#define MAXCONS 16
#endif
-#include "apm.h"
-#if NAPM > 0
-#include "machine/apm_bios.h"
-#endif
/* this may break on older VGA's but is usefull on real 32 bit systems */
#define bcopyw bcopy
@@ -218,6 +216,19 @@ sc_registerdev(struct isa_device *id)
dev_attach(&kdc_sc[id->id_unit]);
}
+#if NAPM > 0
+static int
+scresume(void *dummy)
+{
+ shfts = 0;
+ ctls = 0;
+ alts = 0;
+ agrs = 0;
+ metas = 0;
+ return 0;
+}
+#endif
+
int
scattach(struct isa_device *dev)
{
@@ -267,7 +278,7 @@ scattach(struct isa_device *dev)
update_leds(scp->status);
sc_registerdev(dev);
#if NAPM > 0
- scp->r_hook.ah_fun = pcresume;
+ scp->r_hook.ah_fun = scresume;
scp->r_hook.ah_arg = NULL;
scp->r_hook.ah_name = "system keyboard";
scp->r_hook.ah_order = APM_MID_ORDER;
@@ -276,8 +287,8 @@ scattach(struct isa_device *dev)
return 0;
}
-static struct tty
-*get_tty_ptr(dev_t dev)
+struct tty
+*scdevtotty(dev_t dev)
{
int unit = minor(dev);
@@ -288,6 +299,17 @@ static struct tty
return VIRTUAL_TTY(unit);
}
+int
+scselect(dev_t dev, int rw, struct proc *p)
+{
+ struct tty *tp = scdevtotty(dev);
+
+ if (tp == NULL)
+ return(ENXIO);
+
+ return (ttyselect(tp, rw, p));
+}
+
static scr_stat
*get_scr_stat(dev_t dev)
{
@@ -313,7 +335,7 @@ get_scr_num()
int
scopen(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -344,7 +366,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
int
scclose(dev_t dev, int flag, int mode, struct proc *p)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
struct scr_stat *scp;
if (!tp)
@@ -379,7 +401,7 @@ scclose(dev_t dev, int flag, int mode, struct proc *p)
int
scread(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -389,7 +411,7 @@ scread(dev_t dev, struct uio *uio, int flag)
int
scwrite(dev_t dev, struct uio *uio, int flag)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return(ENXIO);
@@ -458,7 +480,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
struct trapframe *fp;
scr_stat *scp;
- tp = get_tty_ptr(dev);
+ tp = scdevtotty(dev);
if (!tp)
return ENXIO;
scp = get_scr_stat(tp->t_dev);
@@ -1050,7 +1072,7 @@ set_mouse_pos:
void
scxint(dev_t dev)
{
- struct tty *tp = get_tty_ptr(dev);
+ struct tty *tp = scdevtotty(dev);
if (!tp)
return;
@@ -1094,19 +1116,6 @@ scstart(struct tty *tp)
splx(s);
}
-#if NAPM > 0
-static int
-scresume(void *dummy)
-{
- shfts = 0;
- ctls = 0;
- alts = 0;
- agrs = 0;
- metas = 0;
- return 0;
-}
-#endif
-
void
pccnprobe(struct consdev *cp)
{
diff --git a/sys/isa/syscons.h b/sys/isa/syscons.h
index 546b2de63316..60cf84eb94db 100644
--- a/sys/isa/syscons.h
+++ b/sys/isa/syscons.h
@@ -25,9 +25,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: syscons.h,v 1.1 1995/02/22 13:40:21 sos Exp $
*/
+/*
+ * The APM stuff is -not- under conditional compilation because we don't want
+ * the size of the scr_stat structure to vary depending upon if APM has been
+ * compiled in or not, that can cause utilities and lkms to crash!
+ */
+#include <machine/apm_bios.h>
+
/* vm things */
#define ISMAPPED(pa, width) \
(((pa) <= (u_long)0x1000 - (width)) \
@@ -140,9 +147,7 @@ typedef struct scr_stat {
u_short *history_pos; /* position shown on screen */
u_short *history_save; /* save area index */
int history_size; /* size of history buffer */
-#if NAPM > 0
struct apmhook r_hook; /* reconfiguration support */
-#endif
} scr_stat;
typedef struct default_attr {
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 33c75a06822b..03a055159b53 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
- * $Id: tty.c,v 1.28 1995/02/15 22:25:51 ache Exp $
+ * $Id: tty.c,v 1.31 1995/02/24 02:36:01 ache Exp $
*/
#include "snp.h"
@@ -233,7 +233,7 @@ ttyclose(tp)
/*-
* TODO:
* o Fix races for sending the start char in ttyflush().
- * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttselect().
+ * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttyselect().
* With luck, there will be MIN chars before select() returns().
* o Handle CLOCAL consistently for ptys. Perhaps disallow setting it.
* o Don't allow input in TS_ZOMBIE case. It would be visible through
@@ -956,15 +956,15 @@ ttioctl(tp, cmd, data, flag)
}
int
-ttselect(device, rw, p)
- dev_t device;
+ttyselect(tp, rw, p)
+ struct tty *tp;
int rw;
struct proc *p;
{
- register struct tty *tp;
int nread, s;
- tp = &cdevsw[major(device)].d_ttys[minor(device)];
+ if (tp == NULL)
+ return (ENXIO);
s = spltty();
switch (rw) {
@@ -2144,9 +2144,8 @@ ttysleep(tp, chan, pri, wmesg, timo)
}
/*
- * XXX this is usable but not useful or used. ttselect() requires an array
- * of tty structs. Most tty drivers have ifdefs for using ttymalloc() but
- * assume a different interface.
+ * XXX this is usable not useful or used. Most tty drivers have
+ * ifdefs for using ttymalloc() but assume a different interface.
*/
/*
* Allocate a tty struct. Clists in the struct will be allocated by
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c
index 611cfdbdaaa1..9e0f47f14285 100644
--- a/sys/kern/tty_cons.c
+++ b/sys/kern/tty_cons.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
- * $Id: cons.c,v 1.20 1995/01/21 14:12:15 bde Exp $
+ * $Id: cons.c,v 1.21 1995/01/23 18:46:13 davidg Exp $
*/
#include <sys/param.h>
@@ -229,7 +229,10 @@ cnselect(dev, rw, p)
{
if (cn_tab == NULL)
return (1);
- return (ttselect(cn_tab->cn_dev, rw, p));
+
+ dev = cn_tab->cn_dev;
+
+ return ((*cdevsw[major(dev)].d_select)(dev, rw, p));
}
int
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 31a06733b0fa..14ef309576b5 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
- * $Id: tty_pty.c,v 1.5 1994/10/02 17:35:30 phk Exp $
+ * $Id: tty_pty.c,v 1.6 1994/10/29 23:59:48 ache Exp $
*/
/*
@@ -552,6 +552,26 @@ block:
goto again;
}
+struct tty *
+ptydevtotty(dev)
+ dev_t dev;
+{
+ if (minor(dev) >= npty)
+ return (NULL);
+
+ return &pt_tty[minor(dev)];
+}
+
+int
+ptsselect(dev, rw, p)
+ dev_t dev;
+ int rw;
+ struct proc * p;
+{
+ return ttyselect(ptydevtotty(dev), rw, p);
+}
+
+
/*ARGSUSED*/
int
ptyioctl(dev, cmd, data, flag, p)
diff --git a/sys/kern/tty_snoop.c b/sys/kern/tty_snoop.c
index eaee5442b885..553b5c252ed6 100644
--- a/sys/kern/tty_snoop.c
+++ b/sys/kern/tty_snoop.c
@@ -33,81 +33,22 @@
#include <sys/snoop.h>
-
-
-#ifdef ST_PTY
-/*
- * This should be same as in "kern/tty_pty.c"
- */
-#include "pty.h"
-
-#if NPTY == 1
-#undef NPTY
-#define NPTY 32
-#endif
-
-extern struct tty pt_tty[];
-#endif /* ST_PTY */
-
-
-#ifdef ST_SIO
-/*
- * This should be same as "i386/isa/sio.c"
- */
-#include "sio.h"
-
-extern struct tty sio_tty[];
-#endif /* ST_SIO */
-
-
-#ifdef ST_VTY
-/*
- * This should match "i386/isa/sc.c"
- */
-
-#if !defined(MAXCONS)
-#define MAXCONS 16
-#endif
-
-extern struct tty sccons[];
-#endif /* ST_VTY */
-
-
-/*
- * This is local structure to hold data for all tty arrays we serve.
- */
-typedef struct tty tty_arr[];
-struct tty_tab {
- int lt_max;
- tty_arr *lt_tab;
-};
-
-static struct tty_tab tty_tabs[] = {
-#ifdef ST_PTY
- {NPTY, &pt_tty},
-#else
- {-1, NULL},
-#endif
-#ifdef ST_VTY
- {MAXCONS, &sccons},
-#else
- {-1, NULL},
-#endif
-#ifdef ST_SIO
- {NSIO, &sio_tty}
-#else
- {-1, NULL}
-#endif
-};
-
-
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
-
static struct snoop snoopsw[NSNP];
+static struct tty *
+devtotty (dev)
+ dev_t dev;
+{
+ if (major(dev) > nchrdev)
+ return (NULL); /* no such device available */
+
+ return (*cdevsw[major(dev)].d_devtotty)(dev);
+}
+
int
snpread(dev, uio, flag)
dev_t dev;
@@ -124,7 +65,8 @@ snpread(dev, uio, flag)
if ((snp->snp_len + snp->snp_base) > snp->snp_blen)
panic("snoop buffer error");
#endif
- if (snp->snp_unit == -1)
+
+ if (snp->snp_target == -1)
return (EIO);
snp->snp_flags &= ~SNOOP_RWAIT;
@@ -183,7 +125,6 @@ snpin(snp, buf, n)
int s, len, nblen;
caddr_t from, to;
char *nbuf;
- struct tty_tab *l_tty;
struct tty *tp;
@@ -278,9 +219,12 @@ snpopen(dev, flag, mode, p)
if ((unit = minor(dev)) >= NSNP)
return (ENXIO);
+
snp = &snoopsw[unit];
+
if (snp->snp_flags & SNOOP_OPEN)
return (ENXIO);
+
/*
* We intentionally do not OR flags with SNOOP_OPEN,but set them so
* all previous settings (especially SNOOP_OFLOW) will be cleared.
@@ -295,8 +239,7 @@ snpopen(dev, flag, mode, p)
/*
* unit == -1 is for inactive snoop devices.
*/
- snp->snp_unit = -1;
-
+ snp->snp_target = -1;
return (0);
}
@@ -306,8 +249,6 @@ snp_detach(snp)
struct snoop *snp;
{
struct tty *tp;
- struct tty_tab *l_tty;
-
snp->snp_base = 0;
snp->snp_len = 0;
@@ -317,21 +258,19 @@ snp_detach(snp)
* change it anyway.
*/
- if (snp->snp_unit == -1)
+ if (snp->snp_target == -1)
goto detach_notty;
-
- l_tty = &tty_tabs[snp->snp_type];
- tp = &((*l_tty->lt_tab)[snp->snp_unit]);
-
- if ((tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
+ tp = devtotty(snp->snp_target);
+
+ if (tp && (tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
(tp->t_line == OTTYDISC || tp->t_line == NTTYDISC)) {
tp->t_sc = NULL;
tp->t_state &= ~TS_SNOOP;
} else
printf("Snoop: bad attached tty data.\n");
- snp->snp_unit = -1;
+ snp->snp_target = -1;
detach_notty:
selwakeup(&snp->snp_sel);
@@ -376,47 +315,38 @@ snpioctl(dev, cmd, data, flag)
int flag;
{
int unit = minor(dev), s;
- int tunit, ttype;
+ dev_t tdev;
struct snoop *snp = &snoopsw[unit];
struct tty *tp, *tpo;
- struct tty_tab *l_tty, *l_otty;
switch (cmd) {
case SNPSTTY:
- tunit = ((struct snptty *) data)->st_unit;
- ttype = ((struct snptty *) data)->st_type;
-
- if (ttype == -1 || tunit == -1)
+ tdev = *((dev_t *) data);
+ if (tdev == -1)
return (snpdown(snp));
- if (ttype < 0 || ttype > ST_MAXTYPE)
- return (EINVAL);
-
- l_tty = &tty_tabs[ttype];
- if (l_tty->lt_tab == NULL)
- return (EINVAL);
-
- if (tunit < 0 || tunit >= l_tty->lt_max)
+ tp = devtotty(tdev);
+ if (!tp)
return (EINVAL);
- tp = &((*l_tty->lt_tab)[tunit]);
-
- if (tp->t_sc != (caddr_t) snp && (tp->t_state & TS_SNOOP))
+ if ((tp->t_sc != (caddr_t) snp) && (tp->t_state & TS_SNOOP))
return (EBUSY);
- if (tp->t_line != OTTYDISC && tp->t_line != NTTYDISC)
+ if ((tp->t_line != OTTYDISC) && (tp->t_line != NTTYDISC))
return (EBUSY);
s = spltty();
- if (snp->snp_unit != -1) {
- l_otty = &tty_tabs[snp->snp_type];
- tpo = &((*l_otty->lt_tab)[snp->snp_unit]);
- tpo->t_state &= ~TS_SNOOP;
+
+ if (snp->snp_target == -1) {
+ tpo = devtotty(snp->snp_target);
+ if (tpo)
+ tpo->t_state &= ~TS_SNOOP;
}
+
tp->t_sc = (caddr_t) snp;
tp->t_state |= TS_SNOOP;
- snp->snp_unit = tunit;
- snp->snp_type = ttype;
+ snp->snp_target = tdev;
+
/*
* Clean overflow and down flags -
* we'll have a chance to get them in the future :)))
@@ -424,11 +354,10 @@ snpioctl(dev, cmd, data, flag)
snp->snp_flags &= ~SNOOP_OFLOW;
snp->snp_flags &= ~SNOOP_DOWN;
splx(s);
-
break;
+
case SNPGTTY:
- ((struct snptty *) data)->st_unit = snp->snp_unit;
- ((struct snptty *) data)->st_type = snp->snp_type;
+ *((dev_t *) data) = snp->snp_target;
break;
case FIONBIO:
@@ -437,19 +366,21 @@ snpioctl(dev, cmd, data, flag)
else
snp->snp_flags &= ~SNOOP_NBIO;
break;
+
case FIOASYNC:
if (*(int *) data)
snp->snp_flags |= SNOOP_ASYNC;
else
snp->snp_flags &= ~SNOOP_ASYNC;
break;
+
case FIONREAD:
s = spltty();
- if (snp->snp_unit != -1)
+ if (snp->snp_target != -1)
*(int *) data = snp->snp_len;
else
- if (snp->snp_flags&SNOOP_DOWN) {
- if (snp->snp_flags&SNOOP_OFLOW)
+ if (snp->snp_flags & SNOOP_DOWN) {
+ if (snp->snp_flags & SNOOP_OFLOW)
*(int *) data = SNP_OFLOW;
else
*(int *) data = SNP_TTYCLOSE;
@@ -458,6 +389,7 @@ snpioctl(dev, cmd, data, flag)
}
splx(s);
break;
+
default:
return (ENOTTY);
}
@@ -474,20 +406,20 @@ snpselect(dev, rw, p)
int unit = minor(dev), s;
struct snoop *snp = &snoopsw[unit];
- if (rw != FREAD) {
+ if (rw != FREAD)
return 0;
- }
- if (snp->snp_len > 0) {
+
+ if (snp->snp_len > 0)
return 1;
- }
+
/*
* If snoop is down,we don't want to select() forever so we return 1.
* Caller should see if we down via FIONREAD ioctl().The last should
* return -1 to indicate down state.
*/
- if (snp->snp_flags & SNOOP_DOWN) {
+ if (snp->snp_flags & SNOOP_DOWN)
return 1;
- }
+
selrecord(p, &snp->snp_sel);
return 0;
}
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 63455a5095a5..17844b165a4c 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
- * $Id: conf.h,v 1.7 1995/01/23 02:52:28 phk Exp $
+ * $Id: conf.h,v 1.8 1995/02/09 13:51:25 davidg Exp $
*/
#ifndef _SYS_CONF_H_
@@ -66,6 +66,7 @@ typedef int d_stop_t __P((struct tty *, int));
typedef int d_reset_t __P((int));
typedef int d_select_t __P((dev_t, int, struct proc *));
typedef int d_mmap_t __P((/* XXX */));
+typedef struct tty * d_ttycv_t __P((dev_t));
struct bdevsw {
d_open_t *d_open;
@@ -89,7 +90,7 @@ struct cdevsw {
d_ioctl_t *d_ioctl;
d_stop_t *d_stop;
d_reset_t *d_reset;
- struct tty *d_ttys;
+ d_ttycv_t *d_devtotty;
d_select_t *d_select;
d_mmap_t *d_mmap;
d_strategy_t *d_strategy;
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
index 63455a5095a5..17844b165a4c 100644
--- a/sys/sys/linedisc.h
+++ b/sys/sys/linedisc.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
- * $Id: conf.h,v 1.7 1995/01/23 02:52:28 phk Exp $
+ * $Id: conf.h,v 1.8 1995/02/09 13:51:25 davidg Exp $
*/
#ifndef _SYS_CONF_H_
@@ -66,6 +66,7 @@ typedef int d_stop_t __P((struct tty *, int));
typedef int d_reset_t __P((int));
typedef int d_select_t __P((dev_t, int, struct proc *));
typedef int d_mmap_t __P((/* XXX */));
+typedef struct tty * d_ttycv_t __P((dev_t));
struct bdevsw {
d_open_t *d_open;
@@ -89,7 +90,7 @@ struct cdevsw {
d_ioctl_t *d_ioctl;
d_stop_t *d_stop;
d_reset_t *d_reset;
- struct tty *d_ttys;
+ d_ttycv_t *d_devtotty;
d_select_t *d_select;
d_mmap_t *d_mmap;
d_strategy_t *d_strategy;
diff --git a/sys/sys/snoop.h b/sys/sys/snoop.h
index 3790b0006a67..6da28a84b319 100644
--- a/sys/sys/snoop.h
+++ b/sys/sys/snoop.h
@@ -33,11 +33,11 @@
*/
struct snoop {
- int snp_unit; /* Pty unit number to snoop on */
- int snp_type; /* Type same as st_type later */
- u_long snp_len,snp_base; /* Buffer data len and base */
+ dev_t snp_target; /* major/minor number of device*/
+ u_long snp_len; /* buffer data length */
+ u_long snp_base; /* buffer data base */
u_long snp_blen; /* Overall buffer len */
- char *snp_buf; /* Data buffer */
+ caddr_t snp_buf; /* Data buffer */
int snp_flags; /* Flags place */
#define SNOOP_NBIO 0x0001
#define SNOOP_ASYNC 0x0002
@@ -48,22 +48,6 @@ struct snoop {
struct selinfo snp_sel; /* Selection info */
};
-
-
-/*
- * This is structure to be passed
- * to ioctl() so we can define different
- * types of tty's..
- */
-struct snptty {
- int st_unit;
- int st_type;
-#define ST_PTY 0 /* Regular Pty */
-#define ST_VTY 1 /* Vty for SysCons.. */
-#define ST_SIO 2 /* Serial lines */
-#define ST_MAXTYPE 2
-};
-
/*
* Theese are snoop io controls
* SNPSTTY accepts 'struct snptty' as input.
@@ -71,8 +55,8 @@ struct snptty {
* detached from it's current tty.
*/
-#define SNPSTTY _IOW('T', 90, struct snptty)
-#define SNPGTTY _IOR('T', 89, struct snptty)
+#define SNPSTTY _IOW('T', 90, dev_t)
+#define SNPGTTY _IOR('T', 89, dev_t)
/*
* Theese values would be returned by FIONREAD ioctl
@@ -84,4 +68,3 @@ struct snptty {
#define SNP_DETACH -3
#endif
-
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 277c074662a6..cb7a667fe1c3 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.h 8.6 (Berkeley) 1/21/94
- * $Id: tty.h,v 1.9 1995/02/09 11:14:19 jkh Exp $
+ * $Id: tty.h,v 1.10 1995/02/14 21:23:48 ugen Exp $
*/
#ifndef _SYS_TTY_H_
@@ -208,7 +208,7 @@ int ttioctl __P((struct tty *tp, int com, void *data, int flag));
int ttread __P((struct tty *tp, struct uio *uio, int flag));
int ttnread __P((struct tty *));
void ttrstrt __P((void *tp));
-int ttselect __P((dev_t device, int rw, struct proc *p));
+int ttyselect __P((struct tty *tp, int rw, struct proc *p));
void ttsetwater __P((struct tty *tp));
int ttspeedtab __P((int speed, struct speedtab *table));
int ttstart __P((struct tty *tp));