RTEMS 6.1-rc2
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Author: Wei Shen <cquark@gmail.com>
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_PIPE_H
38#define _RTEMS_PIPE_H
39
40#include <rtems/libio.h>
41#include <rtems/thread.h>
42
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/* Control block to manage each pipe */
57typedef struct pipe_control {
58 char *Buffer;
59 unsigned int Size;
60 unsigned int Start;
61 unsigned int Length;
62 unsigned int Readers;
63 unsigned int Writers;
64 unsigned int waitingReaders;
65 unsigned int waitingWriters;
66 unsigned int readerCounter; /* incremental counters */
67 unsigned int writerCounter; /* for differentiation of successive opens */
68 rtems_mutex Mutex;
69 rtems_condition_variable readBarrier; /* wait queues */
70 rtems_condition_variable writeBarrier;
71#if 0
72 boolean Anonymous; /* anonymous pipe or FIFO */
73#endif
75
84extern void pipe_release(
85 pipe_control_t **pipep,
86 rtems_libio_t *iop
87);
88
97extern int fifo_open(
98 pipe_control_t **pipep,
99 rtems_libio_t *iop
100);
101
107extern ssize_t pipe_read(
108 pipe_control_t *pipe,
109 void *buffer,
110 size_t count,
111 rtems_libio_t *iop
112);
113
119extern ssize_t pipe_write(
120 pipe_control_t *pipe,
121 const void *buffer,
122 size_t count,
123 rtems_libio_t *iop
124);
125
131extern int pipe_ioctl(
132 pipe_control_t *pipe,
133 ioctl_command_t cmd,
134 void *buffer,
135 rtems_libio_t *iop
136);
137
140#ifdef __cplusplus
141}
142#endif
143
144#endif
int fifo_open(pipe_control_t **pipep, rtems_libio_t *iop)
File system open. Interface to file system open.
Definition: fifo.c:196
int pipe_ioctl(pipe_control_t *pipe, ioctl_command_t cmd, void *buffer, rtems_libio_t *iop)
File system Input/Output control.
Definition: fifo.c:397
ssize_t pipe_write(pipe_control_t *pipe, const void *buffer, size_t count, rtems_libio_t *iop)
File system write.
Definition: fifo.c:325
void pipe_release(pipe_control_t **pipep, rtems_libio_t *iop)
Release a pipe.
Definition: fifo.c:146
ssize_t pipe_read(pipe_control_t *pipe, void *buffer, size_t count, rtems_libio_t *iop)
File system read.
Definition: fifo.c:269
Basic IO API.
Definition: pipe.h:57
An open file data structure.
Definition: libio.h:1338
This header file provides the API of Self-Contained Objects.