/* tty_tb.c 4.4 82/08/22 */
* Line discipline for RS232 tablets.
* This supplies binary coordinate data to a user level program
* with a minimum of fuss.
* This discipline requires that tty device drivers call
* the line specific l_ioctl routine from their ioctl routines,
* assigning the result to cmd so that we can refuse most tty specific
* ioctls which are unsafe because we have ambushed the
* teletype input queues and other data, overlaying them with
* the following information: the tty queue header, t_un.T_CTLQ,
* is overlaid with a MTABCHAR character buffer -- the raw input
* chars. The local characters (t_rocount on) are overlaid with
* the current coordinate position.
* Open as tablet discipline. Called when discipline changed
* with ioctl, and changes the interpretation of the information
register struct tbposition
*tbp
;
if (tp
->t_line
== TABLDISC
|| tp
->t_line
== NTABLDISC
) {
tp
->t_cp
= (char *) &tp
->t_un
.T_CTLQ
; /* overlay control queue */
tbp
= (struct tbposition
*) &tp
->t_rocount
;
tbp
->xpos
= tbp
->ypos
= tbp
->status
= tbp
->scount
= 0;
* Break down... called when discipline changed or from device
tp
->t_rawq
.c_cc
= 0; /* clear queues -- paranoid */
tp
->t_un
.T_CTLQ
.c_cc
= 0; /* clear overlaid queue status */
tp
->t_un
.T_CTLQ
.c_cf
= tp
->t_un
.T_CTLQ
.c_cl
= NULL
;
tp
->t_line
= 0; /* paranoid: avoid races */
* Read from a tablet line.
* Characters have been buffered in a buffer and
* decoded. The coordinates are now sluffed back to the user.
struct tbposition tbposition
;
if ((tp
->t_state
&TS_CARR_ON
)==0)
u
.u_error
= iomove(&tp
->t_rocount
, sizeof tbposition
, UIO_READ
, uio
);
* Low level character input routine.
* Stuff the character in the buffer, and decode the it
* if all the chars are there.
* This routine could be expanded in-line in the receiver
* interrupt routine of the dh-11 to make it run as fast as possible.
if(tp
->t_line
== TABLDISC
) {
if((c
&0200) || (tp
->t_inbuf
== MTABCHAR
)) {
tp
->t_cp
= (char *) &tp
->t_un
.T_CTLQ
;
if(++tp
->t_inbuf
== MTABCHAR
)
tbdecode((char *) &tp
->t_un
.T_CTLQ
,
(struct tbposition
*) &tp
->t_rocount
);
} else if(tp
->t_line
== NTABLDISC
) {
if((c
&0200) || (tp
->t_inbuf
== MNTABCHAR
)) {
tp
->t_cp
= (char *) &tp
->t_un
.T_CTLQ
;
if(++tp
->t_inbuf
== MNTABCHAR
)
tbndecode((char *) &tp
->t_un
.T_CTLQ
,
(struct tbposition
*) &tp
->t_rocount
);
* Decode tablet coordinates from ascii to binary.
* (gtco 6 character format)
tbndecode(cp
, tbposition
)
register struct tbposition
*tbposition
;
tbposition
->status
= *cp
>>2; /* this needs to be decoded */
tbposition
->xpos
= ((*cp
++)&03)<<14;
tbposition
->xpos
|= (*cp
++)<<7;
tbposition
->xpos
|= (*cp
++);
tbposition
->ypos
= ((*cp
++)&03)<<14;
tbposition
->ypos
|= (*cp
++)<<7;
tbposition
->ypos
|= (*cp
++);
* Decode tablet coordinates from ascii to binary.
* (hitachi 5 character format)
register struct tbposition
*tbposition
;
status
= (byte
&0100) ? 0100000 : 0;
status
|= 1<<((byte
-040)/2);
tbposition
->xpos
= (*cp
++)<<7;
tbposition
->xpos
|= (*cp
++);
if(tbposition
->xpos
< 256) /* tablet wraps around at 256 */
status
&= 077777; /* make it out of proximity */
tbposition
->ypos
= (*cp
++)<<7;
tbposition
->ypos
|= (*cp
++);
tbposition
->status
= status
;
* This routine is called whenever a ioctl is about to be performed
* and gets a chance to reject the ioctl. We reject all teletype
* oriented ioctl's except those which set the discipline, and
* those which get parameters (gtty and get special characters).
tbioctl(tp
, cmd
, data
, flag
)