Structure for a tty device
typedef struct ttydev_entry {
    iofunc_attr_t		attr;
    iofunc_mount_t		mount;
    TTYPOWER 			power;
    TTYWAIT                 	*waiting_read;
    TTYWAIT                 	*waiting_write;
    TTYWAIT                 	*waiting_drain;
    TTYWAIT                 	*waiting_devctl;
    int                     	c_cflag;
    int                     	c_iflag;
    int                     	c_lflag;
    int                     	c_oflag;
    volatile unsigned       	flags;
    volatile unsigned       	xflags;
    volatile unsigned       	eflags;
    volatile unsigned       	lflags;
    unsigned int		bcnt;
    unsigned int		fwdcnt;
    struct ttydev_entry     	*timer;
    int                     	timeout;
    int                     	timeout_reset;
    union {
        uint64_t		tmrs;
        struct {
            char        	drn_tmr;
            char         	tx_tmr;
            char         	brk_tmr;
            char         	dtr_tmr;
            char         	spare_tmr;
            char         	rsvd1;
            char         	rsvd2;
            char         	rsvd3;
        }   s;
    }       un;
    pid_t                   	brkpgrp;
    pid_t                   	huppid;
    cc_t                    	c_cc[NCCS];
    unsigned char           	fifo;
    unsigned char           	fwd;
    unsigned char           	prefix_cnt;
    unsigned char           	oband_data;
    int                     	highwater;
    int                     	baud;
    struct winsize          	winsize;
    TTYBUF                  	obuf;
    TTYBUF                  	ibuf;
    TTYBUF                  	cbuf;
    iofunc_notify_t         	notify[3];
    struct ttydev_entry     	*extra;
    TTYWAIT                 	*waiting_open;  
    int 			linkid;
    void                    	*reserved2;    
    int                     	(*io_devctlext)(resmgr_context_t *ctp, io_devctl_t *msg, iofunc_ocb_t *ocb);
    char                    	name[TTY_NAME_MAX];
    } TTYDEV;
A character driver shares the TTYDEV structure with the
io-char library.
This structure is used to handle devices shared between the driver and io-char. 
The members include:
- attr
- A resource manager attribute.
- mount
- Related to resource manager information.
- power
- A power-management attribute.
- waiting_read
- The queue to store blocking clients waiting to read.
- waiting_write
- The queue to store blocking clients waiting to write.
- waiting_drain
- The queue to store blocking clients waiting to drain.
- c_cflag
- POSIX termios flag describing the hardware control of the terminal.
- c_iflag
- POSIX termios flag describing the basic terminal input control.
- c_lflag
- POSIX termios flag used to control various terminal functions.
- c_oflag
- POSIX termios flag describing the basic terminal output control.
- flags
- The following flags are currently defined:
- OHW_PAGED — the output hardware flow control (set by io-char and 
used by the driver).
  
- IHW_PAGED — input hardware flow control is asserted; the device's highwater mark has been reached, 
and the device doesn't want to receive any more data. This flag also asserts the RTS line.
  
- OSW_PAGED — output software flow control is asserted; the device should not transmit any data (set by io-char 
and used by the driver).
  
- ISW_PAGED — input software flow control is asserted; the device's highwater mark has been reached, 
and the device doesn't want to receive any more data. This flag also transmits VSTOP. 
  
- EDIT_INSERT — for edit mode. Insert or overstrike typing mode.
  
- EDIT_PREFIX — for edit mode. Look for edit keys which begin with
a fixed prefix, e.g. ESC [ ansi" used with POSIX c_cc[VPREFIX].
  
- OBAND_DATA — indicates that out-of-band data is available.
  
- LOSES_TX_INTR —
  tells the character device library (io-char) that the
  device sometimes fails to generate TX interrupts.
  With this knowledge of the hardware's shortcomings, the io-char
  library will take extra precautions when transmitting data, by using an
  internal countdown timer to keep track of the time between TX interrupts.
  If the timer expires before the next TX interrupt comes in, the
  io-char library assumes the hardware failed to generate the
  interrupt and attempts to transmit more data by calling tto().
  If there's no more data to be transmitted, the countdown timer isn't
  reloaded.
  
- TIMER_ACTIVE — used by io-char.
  
- TIMER_KEEP — used by io-char.
  
- NOTTY — used by PTYs.
  
- NL_INSERT — used to notify application if a \n
was changed to a \r.
  
- ISAPTY — used by PTYs.
  
- PTY_MASTER_ONLY — used by PTYs.
  
- LITERAL — used by io-char.
  
- FIRST_TIME_ALONE — used by io-char.
  
 
- Flags indicate which event occurred. Then the driver sends the event to io-char. 
- The following events are currently defined:
- EVENT_QUEUED — there is an event queued. 
  
- EVENT_SIGINT — an interrupt character event was received, or a break event was received.
  
- EVENT_SIGHUP — POSIX job control, TTI_HANGUP.
  
- EVENT_SIGBRK — POSIX job control for
  SIGBRK sends SIGINT. This event is called by TTI_BREAK, 
  so the driver probably doesn't need to do this.
  
  
- EVENT_TTO — used to call into the tto() at thread time to transmit data. 
Interrupt handler can return this event rather than calling tto() directly.
  
- EVENT_READ — used by io-char.
  
- EVENT_WRITE — called by the driver. Unblock an application waiting to 
write when the output buffer has room to take characters.
  
- EVENT_DRAIN — called by the driver. The output buffer has drained 
(unblock someone waiting on the device to drain).
  
- EVENT_TIMEOUT — used by io-char.
  
- EVENT_NOTIFY_INPUT — input notification (used by io-char). See the 
notify entry in TTYDEV.
  
- EVENT_NOTIFY_OUTPUT — output notification (used by io-char. See 
the notify entry in TTYDEV.
  
- EVENT_NOTIFY_OBAND — driver notifies io-char if out-of-band data is available.
  
- EVENT_CARRIER — generated by TTI_CARRIER. 
  
- EVENT_SIGQUIT — job control, generated by TTI_QUIT
to notify that a QUIT character has been received.
  
- EVENT_SIGSUP — job control, generated by TTI_SUSP to 
notify that a SUSP character has been received.
  
 
- xflags
- OSW_PAGED_OVERRIDE — override
  OSW_PAGED to allow transmission of
controlled characters when in a software flow-control suspend state. This flag is set by
io-char, and is used and cleared by the driver.
  
- eflags
- Event flag, extension to the event in the flags variable.
- lflags
- Logging flag.
- bcnt
- Internal to io-char and used to determine the number of bytes needed to notify a read client.
- fwdcnt
- Internal to io-char and used to determine the number of fwd counts.
- timer
- Used by io-char.
- timeout
- Used by io-char.
- timeout_reset
- Used by io-char.
- tmrs
- One of the below available timers for io-char to use.
- drn_tmr
-  Drain timer.
- tx_tmr
- Loses tx interrupt timer. Enabled by LOSES_TX_INTR. The timer causes tto() to be called to
work around some parts that lose transmit interrupts.
- brk_tmr
- Break timer. Used only by io-char sending break; calls tto(TTO_CTRL, dtrchg).  
- dtr_tmr
- dtr line timer. Used by io-char to set dtr line i.e. generate
  SIGHUP calls tto(TTO_CTRL, dtrchg).
- spare_tmr
- Spare timer for driver use ONLY .
- dsr_tmr
- For device-side driver where DSR is an output.
- dcd_tmr
- For device-side driver where DCD is an output.
- rsvd3
- Reserved for more timers to be added.
- brkpgrp
- Used by io-char.
- huppid
- Used by io-char.
- c_cc
- POSIX special control-characters.
- fifo
- Used only by the driver.
- fwd
- Forward character used by io-char. It's used with fwdcnt to 
implement forward, described in readcond().
For more information, see the QNX Neutrino Library Reference . 
- prefix_cnt
- For io-char only.
- oband_data
- Out-of-band data set by the driver in <intr.c>. The application gets it
from io-char via a devctl().
- highwater
- Set by the driver and used by io-char to determine when to invoke flow control. 
(Make sure this value is LESS than the input buffer size).
- baud
- The device's baud rate.
- winsize
- Used only by io-char.
- obuf
- The output buffer.
- ibuf
- The input buffer. 
- cbuf
- The canonical buffer.
- notify
-  An array of three iofunc_notify_t structures that represent (in order), the input, output, 
and out-of-band notification list: 
  
- notify[0] — notify for input used by io-char.
  
- notify[1] — notify for output to the driver, tto.c.
  
- notify[2] — notify for data that out-of-band to the driver, intr.c
  
   For information about this structure, see the entry for
  iofunc_notify()
  in the QNX Neutrino Library Reference.
  
- extra
- Used for PTYs.
- waiting_open
- The queue to store blocking clients waiting to open.
- linkid
- The ID returned from resmgr_attach().
- reserved2
- Reserved for use by io-char.
- io_devctlext
- Custom devctl command.
- name
- The device's name e.g. /dev/ser1.
QNX Neutrino
TTYCTRL