File indexing completed on 2025-05-11 08:24:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __TERMIOSTYPES_H
0036 #define __TERMIOSTYPES_H
0037
0038 #include <rtems.h>
0039 #include <rtems/libio.h>
0040 #include <rtems/assoc.h>
0041 #include <rtems/chain.h>
0042 #include <rtems/termiosdevice.h>
0043 #include <stdint.h>
0044 #include <termios.h>
0045
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct ttywakeup {
0060 void (*sw_pfn)(struct termios *tty, void *arg);
0061 void *sw_arg;
0062 };
0063
0064
0065
0066
0067 struct rtems_termios_rawbuf {
0068 char *theBuf;
0069 volatile unsigned int Head;
0070 volatile unsigned int Tail;
0071 volatile unsigned int Size;
0072 rtems_binary_semaphore Semaphore;
0073 };
0074
0075
0076
0077
0078
0079
0080 typedef struct rtems_termios_device_node {
0081 rtems_chain_node node;
0082 rtems_device_major_number major;
0083 rtems_device_minor_number minor;
0084 const rtems_termios_device_handler *handler;
0085 const rtems_termios_device_flow *flow;
0086 rtems_termios_device_context *context;
0087 struct rtems_termios_tty *tty;
0088 } rtems_termios_device_node;
0089
0090
0091
0092
0093
0094 typedef struct rtems_termios_tty {
0095
0096
0097
0098 struct rtems_termios_tty *forw;
0099 struct rtems_termios_tty *back;
0100
0101
0102
0103
0104 int refcount;
0105
0106
0107
0108
0109 rtems_device_major_number major;
0110 rtems_device_minor_number minor;
0111
0112
0113
0114
0115 rtems_mutex isem;
0116 rtems_mutex osem;
0117
0118
0119
0120
0121 char *cbuf;
0122 int ccount;
0123 int cindex;
0124
0125
0126
0127
0128 int column;
0129 int read_start_column;
0130
0131
0132
0133
0134 struct termios termios;
0135 rtems_interval vtimeTicks;
0136
0137
0138
0139
0140 struct rtems_termios_rawbuf rawInBuf;
0141 bool rawInBufSemaphoreWait;
0142 rtems_interval rawInBufSemaphoreTimeout;
0143 rtems_interval rawInBufSemaphoreFirstTimeout;
0144 unsigned int rawInBufDropped;
0145
0146
0147
0148
0149 struct rtems_termios_rawbuf rawOutBuf;
0150 int t_dqlen;
0151 enum {rob_idle, rob_busy, rob_wait } rawOutBufState;
0152
0153
0154
0155
0156 rtems_termios_callbacks device;
0157
0158
0159
0160
0161 rtems_termios_device_context legacy_device_context;
0162
0163
0164
0165
0166 rtems_termios_device_handler handler;
0167
0168
0169
0170
0171 rtems_termios_device_flow flow;
0172
0173 volatile unsigned int flow_ctrl;
0174 unsigned int lowwater,highwater;
0175
0176
0177
0178
0179 rtems_id rxTaskId;
0180 rtems_id txTaskId;
0181
0182
0183
0184 int txTaskCharsDequeued;
0185
0186
0187
0188
0189 int t_line;
0190 void *t_sc;
0191
0192
0193
0194
0195 struct ttywakeup tty_snd;
0196 struct ttywakeup tty_rcv;
0197 bool tty_rcvwakeup;
0198
0199
0200
0201
0202 rtems_termios_device_node *device_node;
0203
0204
0205
0206
0207 rtems_termios_device_context *device_context;
0208 } rtems_termios_tty;
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 rtems_status_code rtems_termios_device_install(
0232 const char *device_file,
0233 const rtems_termios_device_handler *handler,
0234 const rtems_termios_device_flow *flow,
0235 rtems_termios_device_context *context
0236 );
0237
0238
0239
0240
0241
0242
0243 static inline void *rtems_termios_get_device_context(
0244 const rtems_termios_tty *tty
0245 )
0246 {
0247 return tty->device_context;
0248 }
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259 void rtems_termios_set_best_baud(
0260 struct termios *term,
0261 uint32_t baud
0262 );
0263
0264 struct rtems_termios_linesw {
0265 int (*l_open) (struct rtems_termios_tty *tp);
0266 int (*l_close)(struct rtems_termios_tty *tp);
0267 int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
0268 int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
0269 int (*l_rint )(int c,struct rtems_termios_tty *tp);
0270 int (*l_start)(struct rtems_termios_tty *tp,int len);
0271 int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args);
0272 int (*l_modem)(struct rtems_termios_tty *tp,int flags);
0273 };
0274
0275
0276
0277
0278 void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty);
0279
0280
0281
0282
0283
0284 void rtems_termios_puts (
0285 const void *buf,
0286 size_t len,
0287 struct rtems_termios_tty *tty
0288 );
0289
0290
0291
0292
0293 extern struct rtems_termios_linesw rtems_termios_linesw[];
0294 extern int rtems_termios_nlinesw;
0295
0296 #define TTYDISC 0
0297 #define TABLDISC 3
0298 #define SLIPDISC 4
0299 #define PPPDISC 5
0300 #define MAXLDISC 8
0301
0302
0303 typedef uint32_t rtems_termios_baud_t;
0304
0305
0306
0307
0308 extern const rtems_assoc_t rtems_termios_baud_table [];
0309
0310
0311
0312
0313
0314
0315
0316
0317 speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
0318
0319
0320
0321
0322
0323
0324
0325 rtems_termios_baud_t rtems_termios_baud_to_number(speed_t baud);
0326
0327
0328
0329
0330 int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud);
0331
0332
0333
0334
0335
0336
0337
0338 int rtems_termios_set_initial_baud(
0339 struct rtems_termios_tty *tty,
0340 rtems_termios_baud_t baud
0341 );
0342
0343
0344
0345
0346
0347
0348 int rtems_termios_kqfilter(
0349 rtems_libio_t *iop,
0350 struct knote *kn
0351 );
0352
0353
0354
0355
0356
0357
0358 int rtems_termios_mmap(
0359 rtems_libio_t *iop,
0360 void **addr,
0361 size_t len,
0362 int prot,
0363 off_t off
0364 );
0365
0366
0367
0368
0369
0370
0371 int rtems_termios_poll(
0372 rtems_libio_t *iop,
0373 int events
0374 );
0375
0376 #define RTEMS_IO_SNDWAKEUP _IOW('t', 11, struct ttywakeup )
0377 #define RTEMS_IO_RCVWAKEUP _IOW('t', 12, struct ttywakeup )
0378
0379 #define OLCUC 0x00000100
0380 #define IUCLC 0x00004000
0381
0382 #define RTEMS_TERMIOS_NUMBER_BAUD_RATES 25
0383
0384 #ifdef __cplusplus
0385 }
0386 #endif
0387
0388 #endif