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