1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX FIFO/pipe File System Support |
---|
5 | * |
---|
6 | * This include file defines the interface to the POSIX FIFO/pipe file system |
---|
7 | * support. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * Author: Wei Shen <cquark@gmail.com> |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_PIPE_H |
---|
19 | #define _RTEMS_PIPE_H |
---|
20 | |
---|
21 | #include <rtems/libio.h> |
---|
22 | #include <rtems/thread.h> |
---|
23 | |
---|
24 | /** |
---|
25 | * @defgroup FIFO_PIPE FIFO/Pipe File System Support |
---|
26 | * |
---|
27 | * @ingroup FileSystemTypesAndMount |
---|
28 | * |
---|
29 | * @brief Interface to the POSIX FIFO/Pipe File System |
---|
30 | */ |
---|
31 | /**@{*/ |
---|
32 | |
---|
33 | #ifdef __cplusplus |
---|
34 | extern "C" { |
---|
35 | #endif |
---|
36 | |
---|
37 | /* Control block to manage each pipe */ |
---|
38 | typedef struct pipe_control { |
---|
39 | char *Buffer; |
---|
40 | unsigned int Size; |
---|
41 | unsigned int Start; |
---|
42 | unsigned int Length; |
---|
43 | unsigned int Readers; |
---|
44 | unsigned int Writers; |
---|
45 | unsigned int waitingReaders; |
---|
46 | unsigned int waitingWriters; |
---|
47 | unsigned int readerCounter; /* incremental counters */ |
---|
48 | unsigned int writerCounter; /* for differentiation of successive opens */ |
---|
49 | rtems_mutex Mutex; |
---|
50 | rtems_id readBarrier; /* wait queues */ |
---|
51 | rtems_id writeBarrier; |
---|
52 | #if 0 |
---|
53 | boolean Anonymous; /* anonymous pipe or FIFO */ |
---|
54 | #endif |
---|
55 | } pipe_control_t; |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Release a pipe. |
---|
59 | * |
---|
60 | * Interface to file system close. |
---|
61 | * |
---|
62 | * *pipep points to pipe control structure. When the last user releases pipe, |
---|
63 | * it will be set to NULL. |
---|
64 | */ |
---|
65 | extern void pipe_release( |
---|
66 | pipe_control_t **pipep, |
---|
67 | rtems_libio_t *iop |
---|
68 | ); |
---|
69 | |
---|
70 | /** |
---|
71 | * @brief File system open. |
---|
72 | * Interface to file system open. |
---|
73 | * |
---|
74 | * *pipep points to pipe control structure. If called with *pipep = NULL, |
---|
75 | * fifo_open will try allocating and initializing a control structure. If the |
---|
76 | * call succeeds, *pipep will be set to address of new control structure. |
---|
77 | */ |
---|
78 | extern int fifo_open( |
---|
79 | pipe_control_t **pipep, |
---|
80 | rtems_libio_t *iop |
---|
81 | ); |
---|
82 | |
---|
83 | /** |
---|
84 | * @brief File system read. |
---|
85 | * |
---|
86 | * Interface to file system read. |
---|
87 | */ |
---|
88 | extern ssize_t pipe_read( |
---|
89 | pipe_control_t *pipe, |
---|
90 | void *buffer, |
---|
91 | size_t count, |
---|
92 | rtems_libio_t *iop |
---|
93 | ); |
---|
94 | |
---|
95 | /** |
---|
96 | * @brief File system write. |
---|
97 | * |
---|
98 | * Interface to file system write. |
---|
99 | */ |
---|
100 | extern ssize_t pipe_write( |
---|
101 | pipe_control_t *pipe, |
---|
102 | const void *buffer, |
---|
103 | size_t count, |
---|
104 | rtems_libio_t *iop |
---|
105 | ); |
---|
106 | |
---|
107 | /** |
---|
108 | * @brief File system Input/Output control. |
---|
109 | * |
---|
110 | * Interface to file system ioctl. |
---|
111 | */ |
---|
112 | extern int pipe_ioctl( |
---|
113 | pipe_control_t *pipe, |
---|
114 | ioctl_command_t cmd, |
---|
115 | void *buffer, |
---|
116 | rtems_libio_t *iop |
---|
117 | ); |
---|
118 | |
---|
119 | /** @} */ |
---|
120 | |
---|
121 | #ifdef __cplusplus |
---|
122 | } |
---|
123 | #endif |
---|
124 | |
---|
125 | #endif |
---|