RTEMS 6.1-rc7
Loading...
Searching...
No Matches
termiostypes.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
9/*
10 * COPYRIGHT (c) 1989-2011.
11 * On-Line Applications Research Corporation (OAR).
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __TERMIOSTYPES_H
36#define __TERMIOSTYPES_H
37
38#include <rtems.h>
39#include <rtems/libio.h>
40#include <rtems/assoc.h>
41#include <rtems/chain.h>
42#include <rtems/termiosdevice.h>
43#include <stdint.h>
44#include <termios.h>
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
56/*
57 * Wakeup callback data structure
58 */
59struct ttywakeup {
60 void (*sw_pfn)(struct termios *tty, void *arg);
61 void *sw_arg;
62};
63
64/*
65 * Variables associated with the character buffer
66 */
68 char *theBuf;
69 volatile unsigned int Head;
70 volatile unsigned int Tail;
71 volatile unsigned int Size;
72 rtems_binary_semaphore Semaphore;
73};
74
84 const rtems_termios_device_handler *handler;
85 const rtems_termios_device_flow *flow;
87 struct rtems_termios_tty *tty;
89
90/*
91 * Variables associated with each termios instance.
92 * One structure for each hardware I/O device.
93 */
94typedef struct rtems_termios_tty {
95 /*
96 * Linked-list of active TERMIOS devices
97 */
98 struct rtems_termios_tty *forw;
99 struct rtems_termios_tty *back;
100
101 /*
102 * How many times has this device been opened
103 */
104 int refcount;
105
106 /*
107 * This device
108 */
111
112 /*
113 * Mutual-exclusion semaphores
114 */
115 rtems_mutex isem;
116 rtems_mutex osem;
117
118 /*
119 * The canonical (cooked) character buffer
120 */
121 char *cbuf;
122 int ccount;
123 int cindex;
124
125 /*
126 * Keep track of cursor (printhead) position
127 */
128 int column;
129 int read_start_column;
130
131 /*
132 * The ioctl settings
133 */
134 struct termios termios;
135 rtems_interval vtimeTicks;
136
137 /*
138 * Raw input character buffer
139 */
140 struct rtems_termios_rawbuf rawInBuf;
141 bool rawInBufSemaphoreWait;
142 rtems_interval rawInBufSemaphoreTimeout;
143 rtems_interval rawInBufSemaphoreFirstTimeout;
144 unsigned int rawInBufDropped; /* Statistics */
145
146 /*
147 * Raw output character buffer
148 */
149 struct rtems_termios_rawbuf rawOutBuf;
150 int t_dqlen; /* count of characters dequeued from device */
151 enum {rob_idle, rob_busy, rob_wait } rawOutBufState;
152
153 /*
154 * Callbacks to device-specific routines
155 */
157
162
167
172
173 volatile unsigned int flow_ctrl;
174 unsigned int lowwater,highwater;
175
176 /*
177 * I/O task IDs (for task-driven drivers)
178 */
179 rtems_id rxTaskId;
180 rtems_id txTaskId;
181 /*
182 * Information for the tx task how many characters have been dequeued.
183 */
184 int txTaskCharsDequeued;
185
186 /*
187 * line discipline related stuff
188 */
189 int t_line; /* id of line discipline */
190 void *t_sc; /* hook for discipline-specific data structure */
191
192 /*
193 * Wakeup callback variables
194 */
195 struct ttywakeup tty_snd;
196 struct ttywakeup tty_rcv;
197 bool tty_rcvwakeup;
198
203
209
232 const char *device_file,
233 const rtems_termios_device_handler *handler,
234 const rtems_termios_device_flow *flow,
236);
237
243static inline void *rtems_termios_get_device_context(
244 const rtems_termios_tty *tty
245)
246{
247 return tty->device_context;
248}
249
260 struct termios *term,
261 uint32_t baud
262);
263
265 int (*l_open) (struct rtems_termios_tty *tp);
266 int (*l_close)(struct rtems_termios_tty *tp);
267 int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
268 int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
269 int (*l_rint )(int c,struct rtems_termios_tty *tp);
270 int (*l_start)(struct rtems_termios_tty *tp,int len);
271 int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args);
272 int (*l_modem)(struct rtems_termios_tty *tp,int flags);
273};
274
275/*
276 * FIXME: this should move to termios.h!
277 */
278void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty);
279
280/*
281 * FIXME: this should move to termios.h!
282 * put a string to output ring buffer
283 */
284void rtems_termios_puts (
285 const void *buf,
286 size_t len,
287 struct rtems_termios_tty *tty
288);
289
290/*
291 * global hooks for line disciplines
292 */
294extern int rtems_termios_nlinesw;
295
296#define TTYDISC 0 /* termios tty line discipline */
297#define TABLDISC 3 /* tablet discipline */
298#define SLIPDISC 4 /* serial IP discipline */
299#define PPPDISC 5 /* PPP discipline */
300#define MAXLDISC 8
301
302/* baudrate xxx integer type */
303typedef uint32_t rtems_termios_baud_t;
304
309
317speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
318
325rtems_termios_baud_t rtems_termios_baud_to_number(speed_t baud);
326
330int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud);
331
339 struct rtems_termios_tty *tty,
340 rtems_termios_baud_t baud
341);
342
349 rtems_libio_t *iop,
350 struct knote *kn
351);
352
359 rtems_libio_t *iop,
360 void **addr,
361 size_t len,
362 int prot,
363 off_t off
364);
365
372 rtems_libio_t *iop,
373 int events
374);
375
376#define RTEMS_IO_SNDWAKEUP _IOW('t', 11, struct ttywakeup ) /* send tty wakeup */
377#define RTEMS_IO_RCVWAKEUP _IOW('t', 12, struct ttywakeup ) /* recv tty wakeup */
378
379#define OLCUC 0x00000100 /* map lower case to upper case on output */
380#define IUCLC 0x00004000 /* map upper case to lower case on input */
381
382#define RTEMS_TERMIOS_NUMBER_BAUD_RATES 25
383
384#ifdef __cplusplus
385}
386#endif
387
388#endif /* TERMIOSTYPES_H */
RTEMS Associativity Routines.
This header file provides the Chains API.
uint32_t rtems_device_major_number
This integer type represents the major number of devices.
Definition: io.h:103
uint32_t rtems_device_minor_number
This integer type represents the minor number of devices.
Definition: io.h:115
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
Watchdog_Interval rtems_interval
This type represents clock tick intervals.
Definition: types.h:114
rtems_termios_device_handler handler
The device handler.
Definition: termiostypes.h:166
int rtems_termios_poll(rtems_libio_t *iop, int events)
Termios poll() filesystem node handler.
void rtems_termios_set_best_baud(struct termios *term, uint32_t baud)
Sets the best baud value in the Termios control.
Definition: termios_setbestbaud.c:34
const rtems_assoc_t rtems_termios_baud_table[]
RTEMS Termios Baud Table.
Definition: termios_baudtable.c:42
int rtems_termios_set_initial_baud(struct rtems_termios_tty *tty, rtems_termios_baud_t baud)
Sets the initial baud in the Termios context tty.
Definition: termios_setinitialbaud.c:42
int rtems_termios_mmap(rtems_libio_t *iop, void **addr, size_t len, int prot, off_t off)
Termios mmap() filter filesystem node handler.
int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud)
Convert Bxxx Constant to Index.
Definition: termios_baud2index.c:43
speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud)
Converts the Integral Baud value baud to the Termios Control Flag Representation.
Definition: termios_num2baud.c:42
rtems_termios_baud_t rtems_termios_baud_to_number(speed_t baud)
Converts the baud flags to an integral baud value.
Definition: termios_baud2num.c:42
int rtems_termios_kqfilter(rtems_libio_t *iop, struct knote *kn)
Termios kqueue() filter filesystem node handler.
rtems_termios_device_context legacy_device_context
Context for legacy devices using the callbacks.
Definition: termiostypes.h:161
rtems_termios_device_node * device_node
Corresponding device node.
Definition: termiostypes.h:202
rtems_status_code rtems_termios_device_install(const char *device_file, const rtems_termios_device_handler *handler, const rtems_termios_device_flow *flow, rtems_termios_device_context *context)
Installs a Termios device.
Definition: termios.c:126
rtems_termios_device_context * device_context
Context for device driver.
Definition: termiostypes.h:207
rtems_termios_device_flow flow
The device flow control handler.
Definition: termiostypes.h:171
Basic IO API.
rtems_termios_device_context * context
Definition: console-config.c:62
This header file defines the RTEMS Classic API.
This structure represents a chain node.
Definition: chain.h:78
Definition: assoc.h:57
Definition: thread.h:280
Parameter block for ioctl.
Definition: libio.h:1373
Paramameter block for read/write.
Definition: libio.h:1352
An open file data structure.
Definition: libio.h:1338
Definition: libio.h:1898
Termios device context.
Definition: termiosdevice.h:68
Termios device flow control handler.
Definition: termiosdevice.h:207
Termios device handler.
Definition: termiosdevice.h:100
Termios device node for installed devices.
Definition: termiostypes.h:80
Definition: termiostypes.h:264
Definition: termiostypes.h:67
Definition: termiostypes.h:94
Definition: termiostypes.h:59
This header file provides the interfaces of the RTEMS Termios Device Support.