diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cy/cy.c | 19 | ||||
-rw-r--r-- | sys/dev/cy/cy_isa.c | 19 | ||||
-rw-r--r-- | sys/dev/sio/sio.c | 41 | ||||
-rw-r--r-- | sys/dev/snp/snp.c | 168 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 63 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.h | 11 |
6 files changed, 164 insertions, 157 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 3bd203b..ff67eb4 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 3bd203b..ff67eb4 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 c284150..39bec6d 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 eaee544..553b5c2 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 1671125..379776b 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 546b2de..60cf84e 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 { |