[a080705] | 1 | /* |
---|
| 2 | * RTEMS termios device support internal data structures |
---|
| 3 | * |
---|
| 4 | * COPYRIGHT (c) 1989-2000. |
---|
| 5 | * On-Line Applications Research Corporation (OAR). |
---|
| 6 | * |
---|
| 7 | * The license and distribution terms for this file may be |
---|
| 8 | * found in the file LICENSE in this distribution or at |
---|
| 9 | * http://www.OARcorp.com/rtems/license.html. |
---|
| 10 | * |
---|
| 11 | * $Id$ |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | #ifndef TERMIOSTYPES_H |
---|
| 15 | #define TERMIOSTYPES_H |
---|
| 16 | |
---|
| 17 | #include <rtems.h> |
---|
| 18 | #include <rtems/libio.h> |
---|
| 19 | |
---|
| 20 | #ifdef __cplusplus |
---|
| 21 | extern "C" { |
---|
| 22 | #endif |
---|
| 23 | |
---|
[f7691e3] | 24 | /* |
---|
| 25 | * Wakeup callback data structure |
---|
| 26 | */ |
---|
| 27 | struct ttywakeup { |
---|
| 28 | void (*sw_pfn)__P((struct termios *tty, void *arg)); |
---|
| 29 | void *sw_arg; |
---|
| 30 | }; |
---|
| 31 | |
---|
[a080705] | 32 | /* |
---|
| 33 | * Variables associated with the character buffer |
---|
| 34 | */ |
---|
| 35 | struct rtems_termios_rawbuf { |
---|
| 36 | volatile char *theBuf; |
---|
| 37 | volatile unsigned int Head; |
---|
| 38 | volatile unsigned int Tail; |
---|
| 39 | volatile unsigned int Size; |
---|
| 40 | rtems_id Semaphore; |
---|
| 41 | }; |
---|
| 42 | /* |
---|
| 43 | * Variables associated with each termios instance. |
---|
| 44 | * One structure for each hardware I/O device. |
---|
| 45 | */ |
---|
| 46 | struct rtems_termios_tty { |
---|
| 47 | /* |
---|
| 48 | * Linked-list of active TERMIOS devices |
---|
| 49 | */ |
---|
| 50 | struct rtems_termios_tty *forw; |
---|
| 51 | struct rtems_termios_tty *back; |
---|
| 52 | |
---|
| 53 | /* |
---|
| 54 | * How many times has this device been opened |
---|
| 55 | */ |
---|
| 56 | int refcount; |
---|
| 57 | |
---|
| 58 | /* |
---|
| 59 | * This device |
---|
| 60 | */ |
---|
| 61 | rtems_device_major_number major; |
---|
| 62 | rtems_device_major_number minor; |
---|
| 63 | |
---|
| 64 | /* |
---|
| 65 | * Mutual-exclusion semaphores |
---|
| 66 | */ |
---|
| 67 | rtems_id isem; |
---|
| 68 | rtems_id osem; |
---|
| 69 | |
---|
| 70 | /* |
---|
| 71 | * The canonical (cooked) character buffer |
---|
| 72 | */ |
---|
| 73 | char *cbuf; |
---|
| 74 | int ccount; |
---|
| 75 | int cindex; |
---|
| 76 | |
---|
| 77 | /* |
---|
| 78 | * Keep track of cursor (printhead) position |
---|
| 79 | */ |
---|
| 80 | int column; |
---|
| 81 | int read_start_column; |
---|
| 82 | |
---|
| 83 | /* |
---|
| 84 | * The ioctl settings |
---|
| 85 | */ |
---|
| 86 | struct termios termios; |
---|
| 87 | rtems_interval vtimeTicks; |
---|
| 88 | |
---|
| 89 | /* |
---|
| 90 | * Raw input character buffer |
---|
| 91 | */ |
---|
| 92 | struct rtems_termios_rawbuf rawInBuf; |
---|
| 93 | rtems_unsigned32 rawInBufSemaphoreOptions; |
---|
| 94 | rtems_interval rawInBufSemaphoreTimeout; |
---|
| 95 | rtems_interval rawInBufSemaphoreFirstTimeout; |
---|
| 96 | unsigned int rawInBufDropped; /* Statistics */ |
---|
| 97 | |
---|
| 98 | /* |
---|
| 99 | * Raw output character buffer |
---|
| 100 | */ |
---|
| 101 | struct rtems_termios_rawbuf rawOutBuf; |
---|
| 102 | int t_dqlen; /* count of characters dequeued from device */ |
---|
| 103 | enum {rob_idle, rob_busy, rob_wait } rawOutBufState; |
---|
| 104 | |
---|
| 105 | /* |
---|
| 106 | * Callbacks to device-specific routines |
---|
| 107 | */ |
---|
| 108 | rtems_termios_callbacks device; |
---|
| 109 | volatile unsigned int flow_ctrl; |
---|
| 110 | unsigned int lowwater,highwater; |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | * I/O task IDs (for task-driven drivers) |
---|
| 114 | */ |
---|
| 115 | rtems_id rxTaskId; |
---|
| 116 | rtems_id txTaskId; |
---|
| 117 | /* |
---|
| 118 | * line discipline related stuff |
---|
| 119 | */ |
---|
| 120 | int t_line; /* id of line discipline */ |
---|
| 121 | void *t_sc; /* hook for discipline-specific data structure */ |
---|
[f7691e3] | 122 | /* |
---|
| 123 | * Wakeup callback variables |
---|
| 124 | */ |
---|
| 125 | struct ttywakeup tty_snd; |
---|
| 126 | struct ttywakeup tty_rcv; |
---|
| 127 | int tty_rcvwakeup; |
---|
[a080705] | 128 | }; |
---|
| 129 | |
---|
| 130 | struct linesw { |
---|
| 131 | int (*l_open) (struct rtems_termios_tty *tp); |
---|
| 132 | int (*l_close)(struct rtems_termios_tty *tp); |
---|
| 133 | int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); |
---|
| 134 | int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); |
---|
| 135 | int (*l_rint )(int c,struct rtems_termios_tty *tp); |
---|
| 136 | int (*l_start)(struct rtems_termios_tty *tp); |
---|
| 137 | int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args); |
---|
| 138 | int (*l_modem)(struct rtems_termios_tty *tp,int flags); |
---|
| 139 | }; |
---|
| 140 | |
---|
| 141 | /* |
---|
| 142 | * FIXME: this should move to libio.h! |
---|
| 143 | * values for rtems_termios_callbacks.outputUsesInterrupts |
---|
| 144 | */ |
---|
| 145 | #define TERMIOS_POLLED 0 |
---|
| 146 | #define TERMIOS_IRQ_DRIVEN 1 |
---|
| 147 | #define TERMIOS_TASK_DRIVEN 2 |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | /* |
---|
| 151 | * FIXME: this should move to termios.h! |
---|
| 152 | */ |
---|
| 153 | void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty); |
---|
| 154 | /* |
---|
| 155 | * FIXME: this should move to termios.h! |
---|
| 156 | * put a string to output ring buffer |
---|
| 157 | */ |
---|
| 158 | void rtems_termios_puts (const char *buf, |
---|
| 159 | int len, |
---|
| 160 | struct rtems_termios_tty *tty); |
---|
| 161 | /* |
---|
| 162 | * global hooks for line disciplines |
---|
| 163 | */ |
---|
| 164 | extern struct linesw linesw[]; |
---|
| 165 | extern int nlinesw; |
---|
| 166 | |
---|
| 167 | #define TTYDISC 0 /* termios tty line discipline */ |
---|
| 168 | #define TABLDISC 3 /* tablet discipline */ |
---|
| 169 | #define SLIPDISC 4 /* serial IP discipline */ |
---|
| 170 | #define PPPDISC 5 /* PPP discipline */ |
---|
| 171 | #define MAXLDISC 8 |
---|
| 172 | |
---|
| 173 | #ifdef __cplusplus |
---|
| 174 | } |
---|
| 175 | #endif |
---|
| 176 | |
---|
| 177 | #endif /* TERMIOSTYPES_H */ |
---|