1 | /** |
---|
2 | * @file rtems/termiostypes.h |
---|
3 | * |
---|
4 | * RTEMS termios device support internal data structures |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * COPYRIGHT (c) 1989-2011. |
---|
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 |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef __TERMIOSTYPES_H |
---|
19 | #define __TERMIOSTYPES_H |
---|
20 | |
---|
21 | #include <rtems.h> |
---|
22 | #include <rtems/libio.h> |
---|
23 | #include <stdint.h> |
---|
24 | |
---|
25 | #ifdef __cplusplus |
---|
26 | extern "C" { |
---|
27 | #endif |
---|
28 | |
---|
29 | /* |
---|
30 | * Wakeup callback data structure |
---|
31 | */ |
---|
32 | struct ttywakeup { |
---|
33 | void (*sw_pfn)(struct termios *tty, void *arg); |
---|
34 | void *sw_arg; |
---|
35 | }; |
---|
36 | |
---|
37 | /* |
---|
38 | * Variables associated with the character buffer |
---|
39 | */ |
---|
40 | struct rtems_termios_rawbuf { |
---|
41 | char *theBuf; |
---|
42 | volatile unsigned int Head; |
---|
43 | volatile unsigned int Tail; |
---|
44 | volatile unsigned int Size; |
---|
45 | rtems_id Semaphore; |
---|
46 | }; |
---|
47 | /* |
---|
48 | * Variables associated with each termios instance. |
---|
49 | * One structure for each hardware I/O device. |
---|
50 | */ |
---|
51 | struct rtems_termios_tty { |
---|
52 | /* |
---|
53 | * Linked-list of active TERMIOS devices |
---|
54 | */ |
---|
55 | struct rtems_termios_tty *forw; |
---|
56 | struct rtems_termios_tty *back; |
---|
57 | |
---|
58 | /* |
---|
59 | * How many times has this device been opened |
---|
60 | */ |
---|
61 | int refcount; |
---|
62 | |
---|
63 | /* |
---|
64 | * This device |
---|
65 | */ |
---|
66 | rtems_device_major_number major; |
---|
67 | rtems_device_minor_number minor; |
---|
68 | |
---|
69 | /* |
---|
70 | * Mutual-exclusion semaphores |
---|
71 | */ |
---|
72 | rtems_id isem; |
---|
73 | rtems_id osem; |
---|
74 | |
---|
75 | /* |
---|
76 | * The canonical (cooked) character buffer |
---|
77 | */ |
---|
78 | char *cbuf; |
---|
79 | int ccount; |
---|
80 | int cindex; |
---|
81 | |
---|
82 | /* |
---|
83 | * Keep track of cursor (printhead) position |
---|
84 | */ |
---|
85 | int column; |
---|
86 | int read_start_column; |
---|
87 | |
---|
88 | /* |
---|
89 | * The ioctl settings |
---|
90 | */ |
---|
91 | struct termios termios; |
---|
92 | rtems_interval vtimeTicks; |
---|
93 | |
---|
94 | /* |
---|
95 | * Raw input character buffer |
---|
96 | */ |
---|
97 | struct rtems_termios_rawbuf rawInBuf; |
---|
98 | uint32_t rawInBufSemaphoreOptions; |
---|
99 | rtems_interval rawInBufSemaphoreTimeout; |
---|
100 | rtems_interval rawInBufSemaphoreFirstTimeout; |
---|
101 | unsigned int rawInBufDropped; /* Statistics */ |
---|
102 | |
---|
103 | /* |
---|
104 | * Raw output character buffer |
---|
105 | */ |
---|
106 | struct rtems_termios_rawbuf rawOutBuf; |
---|
107 | int t_dqlen; /* count of characters dequeued from device */ |
---|
108 | enum {rob_idle, rob_busy, rob_wait } rawOutBufState; |
---|
109 | |
---|
110 | /* |
---|
111 | * Callbacks to device-specific routines |
---|
112 | */ |
---|
113 | rtems_termios_callbacks device; |
---|
114 | volatile unsigned int flow_ctrl; |
---|
115 | unsigned int lowwater,highwater; |
---|
116 | |
---|
117 | /* |
---|
118 | * I/O task IDs (for task-driven drivers) |
---|
119 | */ |
---|
120 | rtems_id rxTaskId; |
---|
121 | rtems_id txTaskId; |
---|
122 | |
---|
123 | /* |
---|
124 | * line discipline related stuff |
---|
125 | */ |
---|
126 | int t_line; /* id of line discipline */ |
---|
127 | void *t_sc; /* hook for discipline-specific data structure */ |
---|
128 | |
---|
129 | /* |
---|
130 | * Wakeup callback variables |
---|
131 | */ |
---|
132 | struct ttywakeup tty_snd; |
---|
133 | struct ttywakeup tty_rcv; |
---|
134 | int tty_rcvwakeup; |
---|
135 | }; |
---|
136 | |
---|
137 | struct rtems_termios_linesw { |
---|
138 | int (*l_open) (struct rtems_termios_tty *tp); |
---|
139 | int (*l_close)(struct rtems_termios_tty *tp); |
---|
140 | int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); |
---|
141 | int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); |
---|
142 | int (*l_rint )(int c,struct rtems_termios_tty *tp); |
---|
143 | int (*l_start)(struct rtems_termios_tty *tp); |
---|
144 | int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args); |
---|
145 | int (*l_modem)(struct rtems_termios_tty *tp,int flags); |
---|
146 | }; |
---|
147 | |
---|
148 | /* |
---|
149 | * FIXME: this should move to libio.h! |
---|
150 | * values for rtems_termios_callbacks.outputUsesInterrupts |
---|
151 | */ |
---|
152 | #define TERMIOS_POLLED 0 |
---|
153 | #define TERMIOS_IRQ_DRIVEN 1 |
---|
154 | #define TERMIOS_TASK_DRIVEN 2 |
---|
155 | |
---|
156 | /* |
---|
157 | * FIXME: this should move to termios.h! |
---|
158 | */ |
---|
159 | void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty); |
---|
160 | |
---|
161 | /* |
---|
162 | * FIXME: this should move to termios.h! |
---|
163 | * put a string to output ring buffer |
---|
164 | */ |
---|
165 | void rtems_termios_puts ( |
---|
166 | const void *buf, |
---|
167 | int len, |
---|
168 | struct rtems_termios_tty *tty |
---|
169 | ); |
---|
170 | |
---|
171 | /* |
---|
172 | * global hooks for line disciplines |
---|
173 | */ |
---|
174 | extern struct rtems_termios_linesw rtems_termios_linesw[]; |
---|
175 | extern int rtems_termios_nlinesw; |
---|
176 | |
---|
177 | #define TTYDISC 0 /* termios tty line discipline */ |
---|
178 | #define TABLDISC 3 /* tablet discipline */ |
---|
179 | #define SLIPDISC 4 /* serial IP discipline */ |
---|
180 | #define PPPDISC 5 /* PPP discipline */ |
---|
181 | #define MAXLDISC 8 |
---|
182 | |
---|
183 | /* baudrate xxx integer type */ |
---|
184 | typedef int32_t rtems_termios_baud_t; |
---|
185 | |
---|
186 | /* convert xxx integer to equivalent Bxxx constant */ |
---|
187 | int rtems_termios_number_to_baud(rtems_termios_baud_t baud); |
---|
188 | |
---|
189 | /* convert Bxxx constant to xxx integer */ |
---|
190 | rtems_termios_baud_t rtems_termios_baud_to_number(int termios_baud); |
---|
191 | |
---|
192 | /* convert Bxxx constant to index */ |
---|
193 | int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud); |
---|
194 | |
---|
195 | /* |
---|
196 | * This method is used by a driver to tell termios its |
---|
197 | * initial baud rate. This is especially important when |
---|
198 | * the device driver does not set the baud to the default |
---|
199 | * of B9600. |
---|
200 | */ |
---|
201 | int rtems_termios_set_initial_baud( |
---|
202 | struct rtems_termios_tty *ttyp, |
---|
203 | rtems_termios_baud_t baud |
---|
204 | ); |
---|
205 | |
---|
206 | #ifdef __cplusplus |
---|
207 | } |
---|
208 | #endif |
---|
209 | |
---|
210 | #endif /* TERMIOSTYPES_H */ |
---|