diff options
-rw-r--r-- | share/man/man4/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/tb.4 | 117 | ||||
-rw-r--r-- | sys/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/conf/files | 4 | ||||
-rw-r--r-- | sys/kern/tty_conf.c | 18 | ||||
-rw-r--r-- | sys/kern/tty_tb.c | 370 |
6 files changed, 6 insertions, 510 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index f0d52d2dfe3..8b4ff3952fe 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.373 2006/08/03 08:45:06 deraadt Exp $ +# $OpenBSD: Makefile,v 1.374 2006/08/03 16:13:24 mbalmer Exp $ MAN= aac.4 ac97.4 acx.4 acphy.4 acpi.4 acpihpet.4 acpitimer.4 \ adc.4 addcom.4 admcts.4 admlc.4 admtemp.4 \ @@ -39,7 +39,7 @@ MAN= aac.4 ac97.4 acx.4 acphy.4 acpi.4 acpihpet.4 acpitimer.4 \ sdmmc.4 sdhc.4 ses.4 \ sequencer.4 sf.4 sf2r.4 sfr.4 siop.4 sis.4 sk.4 sl.4 sm.4 \ speaker.4 sppp.4 sqphy.4 ss.4 st.4 ste.4 stge.4 sti.4 stp.4 sv.4 \ - systrace.4 tb.4 tcic.4 tcp.4 termios.4 ti.4 tl.4 \ + systrace.4 tcic.4 tcp.4 termios.4 ti.4 tl.4 \ tlphy.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 tun.4 twe.4 txp.4 \ txphy.4 uaudio.4 ubsa.4 ubsec.4 ubt.4 ucom.4 udav.4 \ udcf.4 udp.4 udsbr.4 \ diff --git a/share/man/man4/tb.4 b/share/man/man4/tb.4 deleted file mode 100644 index e3e9afc03ce..00000000000 --- a/share/man/man4/tb.4 +++ /dev/null @@ -1,117 +0,0 @@ -.\" $OpenBSD: tb.4,v 1.9 2004/03/21 19:47:59 miod Exp $ -.\" $NetBSD: tb.4,v 1.3.6.1 1996/05/31 00:37:45 cgd Exp $ -.\" -.\" Copyright (c) 1986, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tb.4 6.4 (Berkeley) 3/27/91 -.\" -.Dd March 27, 1991 -.Dt TB 4 -.Os -.Sh NAME -.Nm tb -.Nd line discipline for digitizing devices -.Sh SYNOPSIS -.Cd "pseudo-device tb" Op Ar count -.Sh DESCRIPTION -This line discipline provides a polled interface to many common -digitizing devices which are connected to a host through a serial line. -When these devices stream data at high speed, the use of the -line discipline is critical in minimizing the number of samples -that would otherwise be lost due to buffer exhaustion in the -.Xr tty 4 -handler. -.Pp -The line discipline is enabled by a sequence: -.Bd -literal -offset indent -#include <sys/tablet.h> -int ldisc = TABLDISC, fildes; ... -ioctl(fildes, TIOCSETD, &ldisc); -.Ed -.Pp -A typical application program then polls the digitizing device by -reading a binary data structure which contains: the current X and -Y positions (in the device coordinate space), -up-down status of the buttons or pen stylus, -proximity information (when available), and a count -of the number of samples received from the input device -since it was opened. -In addition, devices such as the -.Tn GTCO -append tilt and pressure information to the end of -the aforementioned structure. -For the Polhemus 3-D digitizer the structure read is completely different. -Refer to the include file for a complete description. -.Pp -While in tablet mode, normal teletype input and output functions take place. -Thus, if an 8 bit output data path is desired, it is necessary -to prepare the output line by putting it into -.Tn RAW -mode using -.Xr ioctl 2 . -This must be done -.Em before -changing the discipline with -.Dv TIOCSETD , -as most -.Xr ioctl 2 -calls are disabled while in tablet line-discipline mode. -.Pp -The line discipline supports -.Xr ioctl 2 -requests to get/set the operating mode, and to get/set the tablet type -and operating mode by -.Em or Ns -ing -the two values together. -.Pp -Calling -.Xr read 2 -on the device always succeeds, returning the last sample, -although the -.Xr select 2 -and -.Xr poll 2 -system calls will correctly report the read state for new samples. -.Pp -The line discipline supports digitizing devices which are -compatible with Hitachi, -.Tn GTCO , -or Polhemus protocol formats. -For Hitachi there are several formats with that used in the -newer model -.Tn HDG-1111B -the most common. -.Sh DIAGNOSTICS -None. -.Sh SEE ALSO -.Xr tty 4 -.Sh HISTORY -The -.Nm -interface appeared in -.Bx 4.3 . diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC index 107cde1cdf4..3b7860fd72c 100644 --- a/sys/conf/GENERIC +++ b/sys/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.124 2006/06/14 06:18:55 mbalmer Exp $ +# $OpenBSD: GENERIC,v 1.125 2006/08/03 16:13:24 mbalmer Exp $ # # Machine-independent option; used by all architectures for their # GENERIC kernel @@ -76,7 +76,6 @@ pseudo-device enc 1 # option IPSEC needs the encapsulation interface #pseudo-device strip 1 # Starmode Radio IP interface pseudo-device pty 16 # initial number of pseudo-terminals -pseudo-device tb 1 # tablet line discipline pseudo-device nmea 1 # NMEA 0183 line discipline pseudo-device vnd 4 # paging to files pseudo-device ccd 4 # concatenated disk devices diff --git a/sys/conf/files b/sys/conf/files index f047ee9a7d5..8cc0e1268f4 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.382 2006/08/03 08:45:01 mglocker Exp $ +# $OpenBSD: files,v 1.383 2006/08/03 16:13:24 mbalmer Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -421,7 +421,6 @@ pseudo-device rd: disk file dev/ramdisk.c rd needs-flag pseudo-device pty: tty -pseudo-device tb: tty pseudo-device loop: ifnet pseudo-device sl: ifnet @@ -658,7 +657,6 @@ file kern/tty.c file kern/tty_conf.c file kern/tty_pty.c pty needs-count file kern/tty_subr.c -file kern/tty_tb.c tb needs-count file kern/tty_tty.c file kern/uipc_domain.c file kern/uipc_mbuf.c diff --git a/sys/kern/tty_conf.c b/sys/kern/tty_conf.c index 5ddcc090f39..a47b52239c5 100644 --- a/sys/kern/tty_conf.c +++ b/sys/kern/tty_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_conf.c,v 1.10 2006/06/01 20:10:28 mbalmer Exp $ */ +/* $OpenBSD: tty_conf.c,v 1.11 2006/08/03 16:13:24 mbalmer Exp $ */ /* $NetBSD: tty_conf.c,v 1.18 1996/05/19 17:17:55 jonathan Exp $ */ /*- @@ -52,16 +52,6 @@ int nullioctl(struct tty *, u_long, caddr_t, int, struct proc *); -#include "tb.h" -#if NTB > 0 -int tbopen(dev_t dev, struct tty *tp); -int tbclose(struct tty *tp, int flags); -int tbread(struct tty *tp, struct uio *uio, int flags); -int tbtioctl(struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p); -int tbinput(int c, struct tty *tp); -#endif - #include "sl.h" #if NSL > 0 int slopen(dev_t dev, struct tty *tp); @@ -117,13 +107,9 @@ struct linesw linesw[] = ttyerrinput, ttyerrstart, nullmodem }, /* 2- defunct */ #endif -#if NTB > 0 - { tbopen, tbclose, tbread, ttyerrio, tbtioctl, - tbinput, ttstart, nullmodem }, /* 3- TABLDISC */ -#else + /* 3- TABLDISC (defunct) */ { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl, ttyerrinput, ttyerrstart, nullmodem }, -#endif #if NSL > 0 { slopen, slclose, ttyerrio, ttyerrio, sltioctl, diff --git a/sys/kern/tty_tb.c b/sys/kern/tty_tb.c deleted file mode 100644 index 8f66fab24c5..00000000000 --- a/sys/kern/tty_tb.c +++ /dev/null @@ -1,370 +0,0 @@ -/* $OpenBSD: tty_tb.c,v 1.6 2005/12/21 12:43:49 jsg Exp $ */ -/* $NetBSD: tty_tb.c,v 1.18 1996/02/04 02:17:36 christos Exp $ */ - -/*- - * Copyright (c) 1982, 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)tty_tb.c 8.1 (Berkeley) 6/10/93 - */ - -#include "tb.h" - -/* - * Line discipline for RS232 tablets; - * supplies binary coordinate data. - */ -#include <sys/param.h> -#include <sys/tablet.h> -#include <sys/systm.h> -#include <sys/ioctl.h> -#include <sys/ioctl_compat.h> -#include <sys/tty.h> -#include <sys/proc.h> - -union tbpos { - struct hitpos hitpos; - struct gtcopos gtcopos; - struct polpos polpos; -}; - -/* - * Tablet configuration table. - */ -struct tbconf { - short tbc_recsize; /* input record size in bytes */ - short tbc_uiosize; /* size of data record returned user */ - int tbc_sync; /* mask for finding sync byte/bit */ - /* decoding routine */ - void (*tbc_decode)(const struct tbconf *, char *, union tbpos *); - u_char *tbc_run; /* enter run mode sequence */ - u_char *tbc_point; /* enter point mode sequence */ - u_char *tbc_stop; /* stop sequence */ - u_char *tbc_start; /* start/restart sequence */ - int tbc_flags; -#define TBF_POL 0x1 /* polhemus hack */ -#define TBF_INPROX 0x2 /* tablet has proximity info */ -}; - -static void gtcodecode(const struct tbconf *, char *, union tbpos *); -static void tbolddecode(const struct tbconf *, char *, union tbpos *); -static void tblresdecode(const struct tbconf *, char *, union tbpos *); -static void tbhresdecode(const struct tbconf *, char *, union tbpos *); -static void poldecode(const struct tbconf *, char *, union tbpos *); - - -const struct tbconf tbconf[TBTYPE] = { -{ 0 }, -{ 5, sizeof (struct hitpos), 0200, tbolddecode, "6", "4" }, -{ 5, sizeof (struct hitpos), 0200, tbolddecode, "\1CN", "\1RT", "\2", "\4" }, -{ 8, sizeof (struct gtcopos), 0200, gtcodecode }, -{17, sizeof (struct polpos), 0200, poldecode, 0, 0, "\21", "\5\22\2\23", - TBF_POL }, -{ 5, sizeof (struct hitpos), 0100, tblresdecode, "\1CN", "\1PT", "\2", "\4", - TBF_INPROX }, -{ 6, sizeof (struct hitpos), 0200, tbhresdecode, "\1CN", "\1PT", "\2", "\4", - TBF_INPROX }, -{ 5, sizeof (struct hitpos), 0100, tblresdecode, "\1CL\33", "\1PT\33", 0, 0}, -{ 6, sizeof (struct hitpos), 0200, tbhresdecode, "\1CL\33", "\1PT\33", 0, 0}, -}; - -/* - * Tablet state - */ -struct tb { - int tbflags; /* mode & type bits */ -#define TBMAXREC 17 /* max input record size */ - char cbuf[TBMAXREC]; /* input buffer */ - int tbinbuf; - char *tbcp; - union tbpos tbpos; -} tb[NTB]; - - -int tbopen(dev_t, struct tty *); -void tbclose(struct tty *); -int tbread(struct tty *, struct uio *); -void tbinput(int, struct tty *); -int tbtioctl(struct tty *, u_long, caddr_t, int, struct proc *); -void tbattach(int); - -/* - * Open as tablet discipline; called on discipline change. - */ -/*ARGSUSED*/ -int -tbopen(dev_t dev, struct tty *tp) -{ - struct tb *tbp; - - if (tp->t_line == TABLDISC) - return (ENODEV); - ttywflush(tp); - for (tbp = tb; tbp < &tb[NTB]; tbp++) - if (tbp->tbflags == 0) - break; - if (tbp >= &tb[NTB]) - return (EBUSY); - tbp->tbflags = TBTIGER|TBPOINT; /* default */ - tbp->tbcp = tbp->cbuf; - tbp->tbinbuf = 0; - bzero((caddr_t)&tbp->tbpos, sizeof (tbp->tbpos)); - tp->t_sc = (caddr_t)tbp; - tp->t_flags |= LITOUT; - return (0); -} - -/* - * Line discipline change or last device close. - */ -void -tbclose(struct tty *tp) -{ - int modebits = TBPOINT|TBSTOP; - - tbtioctl(tp, BIOSMODE, (caddr_t) &modebits, 0, curproc); -} - -/* - * Read from a tablet line. - * Characters have been buffered in a buffer and decoded. - */ -int -tbread(struct tty *tp, struct uio *uio) -{ - struct tb *tbp = (struct tb *)tp->t_sc; - const struct tbconf *tc = &tbconf[tbp->tbflags & TBTYPE]; - int ret; - - if ((tp->t_state&TS_CARR_ON) == 0) - return (EIO); - ret = uiomove((caddr_t) &tbp->tbpos, tc->tbc_uiosize, uio); - if (tc->tbc_flags&TBF_POL) - tbp->tbpos.polpos.p_key = ' '; - return (ret); -} - -/* - * Low level character input routine. - * Stuff the character in the buffer, and decode - * if all the chars are there. - * - * This routine could be expanded in-line in the receiver - * interrupt routine to make it run as fast as possible. - */ -void -tbinput(int c, struct tty *tp) -{ - struct tb *tbp = (struct tb *)tp->t_sc; - const struct tbconf *tc = &tbconf[tbp->tbflags & TBTYPE]; - - if (tc->tbc_recsize == 0 || tc->tbc_decode == 0) /* paranoid? */ - return; - /* - * Locate sync bit/byte or reset input buffer. - */ - if (c&tc->tbc_sync || tbp->tbinbuf == tc->tbc_recsize) { - tbp->tbcp = tbp->cbuf; - tbp->tbinbuf = 0; - } - *tbp->tbcp++ = c&0177; - /* - * Call decode routine only if a full record has been collected. - */ - if (++tbp->tbinbuf == tc->tbc_recsize) - (*tc->tbc_decode)(tc, tbp->cbuf, &tbp->tbpos); -} - -/* - * Decode GTCO 8 byte format (high res, tilt, and pressure). - */ -static void -gtcodecode(const struct tbconf *tc, char *cp, union tbpos *u) -{ - struct gtcopos *pos = &u->gtcopos; - pos->pressure = *cp >> 2; - pos->status = (pos->pressure > 16) | TBINPROX; /* half way down */ - pos->xpos = (*cp++ & 03) << 14; - pos->xpos |= *cp++ << 7; - pos->xpos |= *cp++; - pos->ypos = (*cp++ & 03) << 14; - pos->ypos |= *cp++ << 7; - pos->ypos |= *cp++; - pos->xtilt = *cp++; - pos->ytilt = *cp++; - pos->scount++; -} - -/* - * Decode old Hitachi 5 byte format (low res). - */ -static void -tbolddecode(const struct tbconf *tc, char *cp, union tbpos *u) -{ - struct hitpos *pos = &u->hitpos; - char byte; - - byte = *cp++; - pos->status = (byte&0100) ? TBINPROX : 0; - byte &= ~0100; - if (byte > 036) - pos->status |= 1 << ((byte-040)/2); - pos->xpos = *cp++ << 7; - pos->xpos |= *cp++; - if (pos->xpos < 256) /* tablet wraps around at 256 */ - pos->status &= ~TBINPROX; /* make it out of proximity */ - pos->ypos = *cp++ << 7; - pos->ypos |= *cp++; - pos->scount++; -} - -/* - * Decode new Hitach 5-byte format (low res). - */ -static void -tblresdecode(const struct tbconf *tc, char *cp, union tbpos *u) -{ - struct hitpos *pos = &u->hitpos; - - *cp &= ~0100; /* mask sync bit */ - pos->status = (*cp++ >> 2) | TBINPROX; - if (tc->tbc_flags&TBF_INPROX && pos->status&020) - pos->status &= ~(020|TBINPROX); - pos->xpos = *cp++; - pos->xpos |= *cp++ << 6; - pos->ypos = *cp++; - pos->ypos |= *cp++ << 6; - pos->scount++; -} - -/* - * Decode new Hitach 6-byte format (high res). - */ -static void -tbhresdecode(const struct tbconf *tc, char *cp, union tbpos *u) -{ - struct hitpos *pos = &u->hitpos; - char byte; - - byte = *cp++; - pos->xpos = (byte & 03) << 14; - pos->xpos |= *cp++ << 7; - pos->xpos |= *cp++; - pos->ypos = *cp++ << 14; - pos->ypos |= *cp++ << 7; - pos->ypos |= *cp++; - pos->status = (byte >> 2) | TBINPROX; - if (tc->tbc_flags&TBF_INPROX && pos->status&020) - pos->status &= ~(020|TBINPROX); - pos->scount++; -} - -/* - * Polhemus decode. - */ -static void -poldecode(const struct tbconf *tc, char *cp, union tbpos *u) -{ - struct polpos *pos = &u->polpos; - - pos->p_x = cp[4] | cp[3]<<7 | (cp[9] & 0x03) << 14; - pos->p_y = cp[6] | cp[5]<<7 | (cp[9] & 0x0c) << 12; - pos->p_z = cp[8] | cp[7]<<7 | (cp[9] & 0x30) << 10; - pos->p_azi = cp[11] | cp[10]<<7 | (cp[16] & 0x03) << 14; - pos->p_pit = cp[13] | cp[12]<<7 | (cp[16] & 0x0c) << 12; - pos->p_rol = cp[15] | cp[14]<<7 | (cp[16] & 0x30) << 10; - pos->p_stat = cp[1] | cp[0]<<7; - if (cp[2] != ' ') - pos->p_key = cp[2]; -} - -/*ARGSUSED*/ -int -tbtioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) -{ - struct tb *tbp = (struct tb *)tp->t_sc; - - switch (cmd) { - - case BIOGMODE: - *(int *)data = tbp->tbflags & TBMODE; - break; - - case BIOSTYPE: - if (tbconf[*(int *)data & TBTYPE].tbc_recsize == 0 || - tbconf[*(int *)data & TBTYPE].tbc_decode == 0) - return (EINVAL); - tbp->tbflags &= ~TBTYPE; - tbp->tbflags |= *(int *)data & TBTYPE; - /* fall thru... to set mode bits */ - - case BIOSMODE: { - const struct tbconf *tc; - u_char *c; - - tbp->tbflags &= ~TBMODE; - tbp->tbflags |= *(int *)data & TBMODE; - tc = &tbconf[tbp->tbflags & TBTYPE]; - if (tbp->tbflags & TBSTOP) { - if (tc->tbc_stop) - for (c = tc->tbc_stop; *c != '\0'; c++) - ttyoutput(*c, tp); - } else if (tc->tbc_start) - for (c = tc->tbc_start; *c != '\0'; c++) - ttyoutput(*c, tp); - if (tbp->tbflags & TBPOINT) { - if (tc->tbc_point) - for (c = tc->tbc_point; *c != '\0'; c++) - ttyoutput(*c, tp); - } else if (tc->tbc_run) - for (c = tc->tbc_run; *c != '\0'; c++) - ttyoutput(*c, tp); - ttstart(tp); - break; - } - - case BIOGTYPE: - *(int *)data = tbp->tbflags & TBTYPE; - break; - - case TIOCSETD: - case TIOCGETD: - case TIOCGETP: - case TIOCGETC: - return (-1); /* pass thru... */ - - default: - return (ENOTTY); - } - return (0); -} - -void -tbattach(int dummy) -{ - /* stub to handle side effect of new config */ -} |