[21242c2] | 1 | /** |
---|
[e354eb4f] | 2 | * @file |
---|
[e2324c0] | 3 | * |
---|
[e354eb4f] | 4 | * @brief POSIX FIFO/pipe File System Support |
---|
[9ab091e] | 5 | * |
---|
[21242c2] | 6 | * This include file defines the interface to the POSIX FIFO/pipe file system |
---|
| 7 | * support. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /* |
---|
[e2324c0] | 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 |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[e2324c0] | 16 | */ |
---|
| 17 | |
---|
| 18 | #ifndef _RTEMS_PIPE_H |
---|
| 19 | #define _RTEMS_PIPE_H |
---|
| 20 | |
---|
| 21 | #include <rtems/libio.h> |
---|
[8ddd92d] | 22 | #include <rtems/thread.h> |
---|
[e2324c0] | 23 | |
---|
[11109ea] | 24 | /** |
---|
[a15eaaf] | 25 | * @defgroup FIFO_PIPE FIFO/Pipe File System Support |
---|
[9ab091e] | 26 | * |
---|
[a15eaaf] | 27 | * @ingroup FileSystemTypesAndMount |
---|
[e354eb4f] | 28 | * |
---|
[a15eaaf] | 29 | * @brief Interface to the POSIX FIFO/Pipe File System |
---|
[11109ea] | 30 | */ |
---|
[a15eaaf] | 31 | /**@{*/ |
---|
| 32 | |
---|
| 33 | #ifdef __cplusplus |
---|
| 34 | extern "C" { |
---|
| 35 | #endif |
---|
[11109ea] | 36 | |
---|
[e2324c0] | 37 | /* Control block to manage each pipe */ |
---|
| 38 | typedef struct pipe_control { |
---|
| 39 | char *Buffer; |
---|
[4da0caef] | 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 */ |
---|
[8ddd92d] | 49 | rtems_mutex Mutex; |
---|
[b1b6dd71] | 50 | rtems_condition_variable readBarrier; /* wait queues */ |
---|
| 51 | rtems_condition_variable writeBarrier; |
---|
[e2324c0] | 52 | #if 0 |
---|
| 53 | boolean Anonymous; /* anonymous pipe or FIFO */ |
---|
| 54 | #endif |
---|
| 55 | } pipe_control_t; |
---|
| 56 | |
---|
[11109ea] | 57 | /** |
---|
[e354eb4f] | 58 | * @brief Release a pipe. |
---|
[9ab091e] | 59 | * |
---|
[e2324c0] | 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 | */ |
---|
[8f0b334] | 65 | extern void pipe_release( |
---|
[e2324c0] | 66 | pipe_control_t **pipep, |
---|
| 67 | rtems_libio_t *iop |
---|
| 68 | ); |
---|
| 69 | |
---|
[11109ea] | 70 | /** |
---|
[e354eb4f] | 71 | * @brief File system open. |
---|
[e2324c0] | 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 | */ |
---|
[3fa979c] | 78 | extern int fifo_open( |
---|
[e2324c0] | 79 | pipe_control_t **pipep, |
---|
| 80 | rtems_libio_t *iop |
---|
| 81 | ); |
---|
| 82 | |
---|
[11109ea] | 83 | /** |
---|
[e354eb4f] | 84 | * @brief File system read. |
---|
[9ab091e] | 85 | * |
---|
[e2324c0] | 86 | * Interface to file system read. |
---|
| 87 | */ |
---|
[3fa979c] | 88 | extern ssize_t pipe_read( |
---|
[e2324c0] | 89 | pipe_control_t *pipe, |
---|
| 90 | void *buffer, |
---|
| 91 | size_t count, |
---|
| 92 | rtems_libio_t *iop |
---|
| 93 | ); |
---|
| 94 | |
---|
[11109ea] | 95 | /** |
---|
[e354eb4f] | 96 | * @brief File system write. |
---|
[9ab091e] | 97 | * |
---|
[e2324c0] | 98 | * Interface to file system write. |
---|
| 99 | */ |
---|
[3fa979c] | 100 | extern ssize_t pipe_write( |
---|
[e2324c0] | 101 | pipe_control_t *pipe, |
---|
| 102 | const void *buffer, |
---|
| 103 | size_t count, |
---|
| 104 | rtems_libio_t *iop |
---|
| 105 | ); |
---|
| 106 | |
---|
[11109ea] | 107 | /** |
---|
[e354eb4f] | 108 | * @brief File system Input/Output control. |
---|
[9ab091e] | 109 | * |
---|
[e2324c0] | 110 | * Interface to file system ioctl. |
---|
| 111 | */ |
---|
[3fa979c] | 112 | extern int pipe_ioctl( |
---|
[df01da67] | 113 | pipe_control_t *pipe, |
---|
| 114 | ioctl_command_t cmd, |
---|
| 115 | void *buffer, |
---|
| 116 | rtems_libio_t *iop |
---|
[e2324c0] | 117 | ); |
---|
| 118 | |
---|
[e354eb4f] | 119 | /** @} */ |
---|
| 120 | |
---|
[3fa979c] | 121 | #ifdef __cplusplus |
---|
[0a7278e] | 122 | } |
---|
[3fa979c] | 123 | #endif |
---|
| 124 | |
---|
| 125 | #endif |
---|