diff options
author | bde <bde@FreeBSD.org> | 1995-02-15 18:41:41 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-02-15 18:41:41 +0000 |
commit | 868b16fdda6736719292daa6beab7e1199f6f11e (patch) | |
tree | 7eb627521a366e42985b49553e408fd5ea8a552c /sys/dev/cy | |
parent | 84d9700dbc89fd8d74ea84c38ac81bdb51828174 (diff) | |
download | FreeBSD-src-868b16fdda6736719292daa6beab7e1199f6f11e.zip FreeBSD-src-868b16fdda6736719292daa6beab7e1199f6f11e.tar.gz |
Avoid duplicating ttselect() so that we don't have to change cyselect()
when ttselect() is improved. This requires using an array of tty structs
and not using ttymalloc().
Fix an off by 1 error. Some caclulations seem to be off by a factor
of NCY. NCY defaults to 16, which gives 256 tty structs occupying
0xd000 bytes. The minor number encoding only allows 16 ttys.
Update the types of timeout functions to 2.0.
Diffstat (limited to 'sys/dev/cy')
-rw-r--r-- | sys/dev/cy/cy.c | 48 | ||||
-rw-r--r-- | sys/dev/cy/cy_isa.c | 48 |
2 files changed, 36 insertions, 60 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 86a9604..3bd203b 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.7 1994/05/24 07:31:12 mycroft Exp $ + * $Id: cy.c,v 1.1 1995/02/09 09:47:27 jkh Exp $ */ /* @@ -244,7 +244,11 @@ struct cy { int cydefaultrate = TTYDEF_SPEED; cy_addr cyclom_base; /* base address of the card */ static struct cy *info[NCY*PORTS_PER_CYCLOM]; +#ifdef __FreeBSD__ /* XXX actually only temporarily for 2.1-Development */ +struct tty cy_tty[NCY*PORTS_PER_CYCLOM]; +#else struct tty *cy_tty[NCY*PORTS_PER_CYCLOM]; +#endif static volatile u_char timeout_scheduled = 0; /* true if a timeout has been scheduled */ #ifdef CyDebug @@ -354,13 +358,17 @@ cyopen(dev_t dev, int flag, int mode, struct proc *p) int error = 0; u_char carrier; - if (unit >= PORTS_PER_CYCLOM) + if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM) return (ENXIO); infop = info[unit]; base = infop->base_addr; +#ifdef __FreeBSD__ + infop->tty = &cy_tty[unit]; +#else if (!cy_tty[unit]) infop->tty = cy_tty[unit] = ttymalloc(); +#endif tp = infop->tty; tp->t_oproc = cystart; @@ -421,7 +429,7 @@ cyopen(dev_t dev, int flag, int mode, struct proc *p) void -cyclose_wakeup(caddr_t arg) +cyclose_wakeup(void *arg) { wakeup(arg); } /* end of cyclose_wakeup() */ @@ -664,7 +672,7 @@ service_upper_mdm(int unit) /* upper level character processing routine */ void -cytimeout(caddr_t ptr) +cytimeout(void *ptr) { int unit; @@ -1496,31 +1504,7 @@ cystop(struct tty *tp, int flag) int cyselect(dev_t dev, int rw, struct proc *p) { - struct tty *tp = info[UNIT(dev)]->tty; - int s = spltty(); - int nread; - - switch (rw) { - - case FREAD: - nread = ttnread(tp); - if (nread > 0 || - ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0)) - goto win; - selrecord(p, &tp->t_rsel); - break; - - case FWRITE: - if (tp->t_outq.c_cc <= tp->t_lowat) - goto win; - selrecord(p, &tp->t_wsel); - break; - } - splx(s); - return (0); - win: - splx(s); - return (1); + return (ttselect(UNIT(dev), rw, p)); } /* end of cyselect() */ @@ -1617,11 +1601,15 @@ cyparam_dummy(struct tty *tp, struct termios *t) void cyset(int unit, int active) { - if (unit < 0 || unit > PORTS_PER_CYCLOM) { + if (unit < 0 || unit >= /* NCY *? */ PORTS_PER_CYCLOM) { printf("bad unit number %d\n", unit); return; } +#ifdef __FreeBSD__ + cy_tty[unit].t_param = active ? cyparam : cyparam_dummy; +#else cy_tty[unit]->t_param = active ? cyparam : cyparam_dummy; +#endif } diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 86a9604..3bd203b 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.7 1994/05/24 07:31:12 mycroft Exp $ + * $Id: cy.c,v 1.1 1995/02/09 09:47:27 jkh Exp $ */ /* @@ -244,7 +244,11 @@ struct cy { int cydefaultrate = TTYDEF_SPEED; cy_addr cyclom_base; /* base address of the card */ static struct cy *info[NCY*PORTS_PER_CYCLOM]; +#ifdef __FreeBSD__ /* XXX actually only temporarily for 2.1-Development */ +struct tty cy_tty[NCY*PORTS_PER_CYCLOM]; +#else struct tty *cy_tty[NCY*PORTS_PER_CYCLOM]; +#endif static volatile u_char timeout_scheduled = 0; /* true if a timeout has been scheduled */ #ifdef CyDebug @@ -354,13 +358,17 @@ cyopen(dev_t dev, int flag, int mode, struct proc *p) int error = 0; u_char carrier; - if (unit >= PORTS_PER_CYCLOM) + if (unit >= /* NCY * ? */ PORTS_PER_CYCLOM) return (ENXIO); infop = info[unit]; base = infop->base_addr; +#ifdef __FreeBSD__ + infop->tty = &cy_tty[unit]; +#else if (!cy_tty[unit]) infop->tty = cy_tty[unit] = ttymalloc(); +#endif tp = infop->tty; tp->t_oproc = cystart; @@ -421,7 +429,7 @@ cyopen(dev_t dev, int flag, int mode, struct proc *p) void -cyclose_wakeup(caddr_t arg) +cyclose_wakeup(void *arg) { wakeup(arg); } /* end of cyclose_wakeup() */ @@ -664,7 +672,7 @@ service_upper_mdm(int unit) /* upper level character processing routine */ void -cytimeout(caddr_t ptr) +cytimeout(void *ptr) { int unit; @@ -1496,31 +1504,7 @@ cystop(struct tty *tp, int flag) int cyselect(dev_t dev, int rw, struct proc *p) { - struct tty *tp = info[UNIT(dev)]->tty; - int s = spltty(); - int nread; - - switch (rw) { - - case FREAD: - nread = ttnread(tp); - if (nread > 0 || - ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0)) - goto win; - selrecord(p, &tp->t_rsel); - break; - - case FWRITE: - if (tp->t_outq.c_cc <= tp->t_lowat) - goto win; - selrecord(p, &tp->t_wsel); - break; - } - splx(s); - return (0); - win: - splx(s); - return (1); + return (ttselect(UNIT(dev), rw, p)); } /* end of cyselect() */ @@ -1617,11 +1601,15 @@ cyparam_dummy(struct tty *tp, struct termios *t) void cyset(int unit, int active) { - if (unit < 0 || unit > PORTS_PER_CYCLOM) { + if (unit < 0 || unit >= /* NCY *? */ PORTS_PER_CYCLOM) { printf("bad unit number %d\n", unit); return; } +#ifdef __FreeBSD__ + cy_tty[unit].t_param = active ? cyparam : cyparam_dummy; +#else cy_tty[unit]->t_param = active ? cyparam : cyparam_dummy; +#endif } |