DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

tty(D3oddi)


tty: ttclose, ttin, ttinit, ttopen, ttout, ttread, ttrdchk, ttselect, ttwrite, ttyflush, ttywait, ttioctl -- TTY driver routines

Syntax

   #include <sys/tty.h>

Routines referenced by line discipline zero members

   int ttclose(struct tty *tp);			                /* l_close */
   

int ttin(struct tty *tp, int code); /* l_input */

int ttioctl(strcut tty *tp, int cmd, int arg, int mode); /* l_ioctl */

int ttopen(struct tty *tp); /* l_open */

int ttout(struct tty *tp); /* l_output */

int ttread(struct tty *tp); /* l_read */

int ttwrite(struct tty *tp); /* l_write */

tty utility routines

   void ttinit(struct tty *tp);
   

int ttrdchk(struct tty *tp);

int ttselect(struct tty *tp, int rw);

int ttyflush(struct tty *tp, int rdwrt);

int ttywait(struct tty *tp);

Description

Functions referenced by line discipline zero members.

Arguments


tp
Pointer to the tty data structure associated with the device being accessed. This structure is defined in the <sys/tty.h> header file. xxproc is registered as the t_proc member, and the line discipline as the t_line member of the tty structure. The device driver declares an array of tty structures as large as the possible number of minor devices for the device.

code
Used by ttin. It is set to L_BREAK to handle a break interrupt on the line.

cmd, arg, and mode
Used by ttioctl to control I/O.

rw
Used with ttselect; it is set to SELREAD for non-blocking reads, or to SELWRITE for non-blocking writes.

rdwrt
Used by ttyflush to indicate which queues to release to the free list. Set to FREAD to release the input queues, t_canq and t_rawq; set FWRITE to release the output queue, t_outq.

Return values

ttout returns the number of characters present in the output queue, t_outq. It returns 0 (zero) if no characters are present.

ttrdchk returns 1 if there are characters present in the read queues, t_rawq or t_canq. It returns 0 (zero) if no characters are present.

Usage

The following TTY routines are referenced by line discipline zero members. Multithreaded drivers should call these routines through the run_ld(D3oddi) function.


ttclose
Referenced by line discipline zero member l_close. It is called by the driver's xxclose routine to remove access to a TTY device for a user process calling close(S) . The following actions occur:

ttin
Referenced by line discipline zero member l_input. It is called from a driver's xxintr routine to process and move characters placed in t_rbuf to the raw character queue, t_rawq. ttin handles signals issued from the keyboard such as SIGINT or SIGQUIT, echoing of input characters to the display, and mapping of input characters to character sequences including international character mapping.

If the value of code is passed as L_BREAK to indicate a break interrupt on the line, ttin takes the following actions:

The raw buffer is then tested to see if any characters require processing. ttin then does the following:


ttioctl
Referenced by line discipline zero member l_ioctl. The driver's xxioctl routine calls ttiocom(D3oddi) which in turn calls ttioctl to allocate, deallocate, or move the contents of terminal buffers. The cmd argument to ttioctl can take the following values:

ttopen
Referenced by line discipline zero member l_open. It is called from a driver's xxopen routine in response to a call to open(S) to open a serial line. The following actions are performed:

ttout
Referenced by line discipline zero member l_output. A driver's xxproc routine calls ttout to move data to the output buffer. ttout performs the following actions:

ttread
Referenced by line discipline zero member l_read. It is called from a driver's xxread routine in response to a call to read(S) to read data from a device. ttread performs the following actions:

ttwrite
is referenced by line discipline zero member l_write. It is called by a driver's xxwrite routine in response to a call to write(S) to write data to a device. ttwrite performs the following actions:

The following are tty utility routines which may be called from a driver:


ttinit
Initializes the tty structure for line discipline zero. The following members of the tty structure are initialized:

ttrdchk
Returns a non-zero value (1) if there are characters to be read from the input queue, t_rawq or t_canq (depending on whether ICANON is set in t_lflag) , and the device carrier is present (CARR_ON is set in t_state).

Otherwise, ttrdchk returns 0 (zero).


ttselect
Ensures that one-byte read or write can be performed without blocking. (Blocking puts the process to sleep until I/O can be satisfied.)

Set the argument rw to SELREAD to disable blocking for reading; to SELWRITE to disable blocking for writing.

Do not call sleep(D3oddi) before calling ttselect.

Do not call ttselect from an interrupt routine.


ttyflush
Releases character blocks to the free list from the write queue, t_outq, or from the two read queues, t_canq and t_rawq.

Set FREAD in the argument rdwrt to release the read queues; FWRITE to release the write queue. These two values may be ORed together to free all three queues.

Releasing the write queue causes the driver's xxproc routine to be called with the command argument T_WFLUSH set. If OASLP is set in t_state, any processes sleeping on the address of t_outq are woken and OASLP unset. If TTIOW is set in t_state, any processes sleeping on the address of t_oflag are woken and TTIOW unset.

Releasing the read buffers causes the driver's xxproc routine to be called with the command argument T_RFLUSH set. If IASLP is set in t_state, any processes sleeping on the address of t_rawq are woken and IASLP unset.


ttywait
waits for the UART to empty of all data. On entry, if characters are present in t_outq, or t_state is set to BUSY or TIMEOUT, then t_state is ORed with TTIOW and the process is put to sleep on the address of t_oflag at TTOPRI. On receiving a wakeup signal, control returns to the user process and EINTR is set in u.u_error and errno in the user program.
All routines on this manual page can only be used with character device drivers.

Usage

Context and synchronization


ttin and ttout
Non-blockable, interrupt, user, or blockable context.

ttclose, ttioctl (called via ttiocom), ttopen, ttread and ttwrite
User context.

ttinit, ttrdchk, ttselect, ttyflush and ttywait
User context.

ttioctl, ttwrite, ttselect and ttyflush all set priority level 5 internally using spltty.

Hardware applicability

All

Version applicability

oddi: 1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp

SVR5 DDI compatibility

SVR5 TTY drivers are implemented as STREAMS drivers so there is no direct parallel to these functions.

References

ldistributed(D3oddi), proc(D2oddi), run_ld(D3oddi), sleep(D3oddi), tc_tlock(D3oddi), termio(M) ttiocom(D3oddi)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005