RTEMS 6.1-rc4
Loading...
Searching...
No Matches
termiosdevice.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_TERMIOSDEVICE_H
38#define _RTEMS_TERMIOSDEVICE_H
39
40#include <rtems/thread.h>
41#include <rtems/rtems/intr.h>
42
43#include <sys/ioccom.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48
51struct termios;
52
69 union {
70 /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */
71 rtems_interrupt_lock interrupt;
72
73 /* Used for TERMIOS_IRQ_SERVER_DRIVEN and TERMIOS_TASK_DRIVEN */
74 rtems_mutex mutex;
75 } lock;
76
77 void ( *lock_acquire )(
80 );
81
82 void ( *lock_release )(
85 );
87
88typedef enum {
89 TERMIOS_POLLED,
90 TERMIOS_IRQ_DRIVEN,
91 TERMIOS_TASK_DRIVEN,
92 TERMIOS_IRQ_SERVER_DRIVEN
93} rtems_termios_device_mode;
94
100typedef struct {
118 bool (*first_open)(
119 struct rtems_termios_tty *tty,
121 struct termios *term,
122 struct rtems_libio_open_close_args *args
123 );
124
133 void (*last_close)(
134 struct rtems_termios_tty *tty,
136 struct rtems_libio_open_close_args *args
137 );
138
152
161 void (*write)(
163 const char *buf,
164 size_t len
165 );
166
176 bool (*set_attributes)(
178 const struct termios *term
179 );
180
190 int (*ioctl)(
192 ioctl_command_t request,
193 void *buffer
194 );
195
199 rtems_termios_device_mode mode;
201
207typedef struct {
213 void (*stop_remote_tx)(rtems_termios_device_context *context);
214
220 void (*start_remote_tx)(rtems_termios_device_context *context);
222
223void rtems_termios_device_lock_acquire_default(
225 rtems_interrupt_lock_context *lock_context
226);
227
228void rtems_termios_device_lock_release_default(
230 rtems_interrupt_lock_context *lock_context
231);
232
241static inline void rtems_termios_device_context_initialize(
243 const char *name
244)
245{
246 rtems_interrupt_lock_initialize( &context->lock.interrupt, name );
247 context->lock_acquire = rtems_termios_device_lock_acquire_default;
248 context->lock_release = rtems_termios_device_lock_release_default;
249}
250
257#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \
258 { \
259 { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \
260 rtems_termios_device_lock_acquire_default, \
261 rtems_termios_device_lock_release_default \
262 }
263
271static inline void rtems_termios_device_lock_acquire(
273 rtems_interrupt_lock_context *lock_context
274)
275{
276 ( *context->lock_acquire )( context, lock_context );
277}
278
286static inline void rtems_termios_device_lock_release(
288 rtems_interrupt_lock_context *lock_context
289)
290{
291 ( *context->lock_release )( context, lock_context );
292}
293
296#ifdef __cplusplus
297}
298#endif /* __cplusplus */
299
300#endif /* _RTEMS_TERMIOSDEVICE_H */
char rtems_interrupt_lock
This structure represents an ISR lock.
Definition: intr.h:532
#define rtems_interrupt_lock_initialize(_lock, _name)
Initializes the ISR lock.
Definition: intr.h:577
This header file defines the Interrupt Manager API.
ssize_t write(int fd, const void *buffer, size_t count)
Definition: write.c:49
rtems_termios_device_context * context
Definition: console-config.c:62
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:94
Definition: mutex.h:4
Parameter block for open/close.
Definition: libio.h:1364
Termios device context.
Definition: termiosdevice.h:68
Termios device flow control handler.
Definition: termiosdevice.h:207
Termios device handler.
Definition: termiosdevice.h:100
rtems_termios_device_mode mode
Termios device mode.
Definition: termiosdevice.h:199
Definition: termiostypes.h:94
This header file provides the API of Self-Contained Objects.