2018-10-14 19:37:18 +08:00
|
|
|
/*
|
2023-04-18 10:26:23 +08:00
|
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
2018-10-14 19:37:18 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
*/
|
2022-03-02 18:45:19 +08:00
|
|
|
|
2017-10-15 22:56:46 +08:00
|
|
|
#ifndef PIPE_H__
|
|
|
|
#define PIPE_H__
|
|
|
|
|
2022-03-02 18:45:19 +08:00
|
|
|
#include <rtthread.h>
|
|
|
|
|
2017-10-15 22:56:46 +08:00
|
|
|
/**
|
|
|
|
* Pipe Device
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rt_pipe_device
|
|
|
|
{
|
2017-11-03 21:09:04 +08:00
|
|
|
struct rt_device parent;
|
2019-03-31 15:21:49 +08:00
|
|
|
rt_bool_t is_named;
|
2022-12-03 12:07:44 +08:00
|
|
|
#ifdef RT_USING_POSIX_DEVIO
|
|
|
|
int pipeno; /* for unamed pipe */
|
|
|
|
#endif
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
/* ring buffer in pipe device */
|
|
|
|
struct rt_ringbuffer *fifo;
|
2017-12-29 22:33:39 +08:00
|
|
|
rt_uint16_t bufsz;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
rt_wqueue_t reader_queue;
|
|
|
|
rt_wqueue_t writer_queue;
|
2022-12-03 12:07:44 +08:00
|
|
|
int writer;
|
|
|
|
int reader;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
struct rt_mutex lock;
|
2017-10-15 22:56:46 +08:00
|
|
|
};
|
|
|
|
typedef struct rt_pipe_device rt_pipe_t;
|
|
|
|
|
2017-12-29 22:33:39 +08:00
|
|
|
rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
|
2018-07-10 14:54:39 +08:00
|
|
|
int rt_pipe_delete(const char *name);
|
2022-03-02 18:45:19 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
#endif /* PIPE_H__ */
|