TTYDEV

Structure for a tty device

typedef struct ttydev_entry {
    iofunc_attr_t              attr;
    iofunc_mount_t             mount;
    TTYWAIT                  * waiting_read;
    TTYWAIT                  * waiting_write;
    TTYWAIT                  * waiting_drain;
    TTYWAIT                  * waiting_devctl;
    unsigned int               c_cflag;
    unsigned int               c_iflag;
    unsigned int               c_lflag;
    unsigned int               c_oflag;
    volatile unsigned          flags;
    volatile unsigned          xflags;
    volatile unsigned          eflags;
    volatile unsigned          lflags;
    unsigned int               verbose;
    unsigned int               bcnt;
    unsigned int               fwdcnt;
    struct ttydev_entry      * timer;
    int                        timeout;
    int                        timeout_reset;
    struct {
        struct {
            unsigned int       drn_tmr;
            unsigned int       tx_tmr;
            unsigned int       brk_tmr;
            unsigned int       dtr_tmr;
            unsigned int       spare_tmr;
            unsigned int       dsr_tmr;
            unsigned int       dcd_tmr;
        } s;
    } un;
    pid_t                      brkpgrp;
    pid_t                      huppid;
    cc_t                       c_cc[40];
    unsigned int               fifo;
    unsigned char              fwd;
    unsigned char              prefix_cnt;
    unsigned char              oband_data;
    unsigned int               highwater;
    unsigned int               baud;
    struct winsize             win_size;
    TTYBUF                     obuf;
    TTYBUF                     obuf_log;
    TTYBUF                     ibuf;
    TTYBUF                     ibuf_log;
    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);
    int                     (* custom_event_handler ) (struct ttydev_entry *tty);
    char                       name[TTY_NAME_MAX];
    char                     * logging_path;
    int                        tx_log_fd;
    int                        rx_log_fd;
    volatile unsigned          shush;
    struct {
        struct ttydev_entry  * tqe_next;
        struct ttydev_entry ** tqe_prev;
    }                          dlist_next;
} TTYDEV;

Description:

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.
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.
  • DEV_ACTIVE — used by PTYs to indicate device history.
  • 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_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
Extended flags. Currently, the following extended flags are defined:
  • 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.
  • MODEM_DISCONNECT — Prevent read/write while in a disconnected state.
  • IBUF_TRANSITION — Flag when the input buffer has changed from empty to non-empty.
  • SERCTL_INPROG — Hold off write requests until current SERCTL operation is complete.
  • DISCARD_OUTPUT — Discard all output written to the device.
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.
  • notify[2] — notify for data that out-of-band to the driver.

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.
custom_event_handler
A function pointer for handling custom events specific to the terminal device.
name
The device's name (e.g., /dev/ser1).
logging_path
A path where logging files are stored.
tx_log_fd
A file descriptor for the transmitted data logs.
rx_log_fd
A file descriptor for the received data logs.
shush
Suppress flooding slog with errors.
dlist_next
A structure representing main list of devices.
  • tqh_first — A pointer to the first element.
  • tqh_last — A pointer to the last element.
Page updated: