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