1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Generic console driver API. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Copyright (c) 2011 embedded brains GmbH. All rights reserved. |
---|
9 | * |
---|
10 | * embedded brains GmbH |
---|
11 | * Obere Lagerstr. 30 |
---|
12 | * 82178 Puchheim |
---|
13 | * Germany |
---|
14 | * <rtems@embedded-brains.de> |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef LIBBSP_SHARED_CONSOLE_GENERIC_H |
---|
22 | #define LIBBSP_SHARED_CONSOLE_GENERIC_H |
---|
23 | |
---|
24 | #include <rtems/libio.h> |
---|
25 | #include <rtems/termiostypes.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif /* __cplusplus */ |
---|
30 | |
---|
31 | typedef struct { |
---|
32 | rtems_termios_callbacks termios_callbacks; |
---|
33 | int (*poll_read)(int minor); |
---|
34 | void (*poll_write)(int minor, char c); |
---|
35 | } console_generic_callbacks; |
---|
36 | |
---|
37 | typedef struct { |
---|
38 | void *context; |
---|
39 | const console_generic_callbacks *callbacks; |
---|
40 | const char *device_path; |
---|
41 | } console_generic_info; |
---|
42 | |
---|
43 | extern const console_generic_info console_generic_info_table []; |
---|
44 | |
---|
45 | extern const size_t console_generic_info_count; |
---|
46 | |
---|
47 | extern const rtems_device_minor_number console_generic_minor; |
---|
48 | |
---|
49 | #define CONSOLE_GENERIC_INFO_TABLE \ |
---|
50 | const console_generic_info console_generic_info_table [] |
---|
51 | |
---|
52 | #define CONSOLE_GENERIC_INFO(context, callbacks, device_path) \ |
---|
53 | { context, callbacks, device_path } |
---|
54 | |
---|
55 | #define CONSOLE_GENERIC_INFO_COUNT \ |
---|
56 | const size_t console_generic_info_count = \ |
---|
57 | sizeof(console_generic_info_table) / sizeof(console_generic_info_table [0]) |
---|
58 | |
---|
59 | #define CONSOLE_GENERIC_MINOR(minor) \ |
---|
60 | const rtems_device_minor_number console_generic_minor = (minor) |
---|
61 | |
---|
62 | static inline void *console_generic_get_context(int minor) |
---|
63 | { |
---|
64 | return console_generic_info_table [minor].context; |
---|
65 | } |
---|
66 | |
---|
67 | static inline struct rtems_termios_tty *console_generic_get_tty_at_open( |
---|
68 | void *arg |
---|
69 | ) |
---|
70 | { |
---|
71 | const rtems_libio_open_close_args_t *oc = |
---|
72 | (const rtems_libio_open_close_args_t *) arg; |
---|
73 | |
---|
74 | return (struct rtems_termios_tty *) oc->iop->data1; |
---|
75 | } |
---|
76 | |
---|
77 | #ifdef __cplusplus |
---|
78 | } |
---|
79 | #endif /* __cplusplus */ |
---|
80 | |
---|
81 | #endif /* LIBBSP_SHARED_CONSOLE_GENERIC_H */ |
---|