Skip to content

Commit 0c84cc5

Browse files
nashifkartben
authored andcommitted
kernel: drop deprecated pipe API
This API was deprecated in 4.1, so drop it for the 4.3 release. Use new PIPE API instead. Signed-off-by: Anas Nashif <[email protected]>
1 parent 4c306fd commit 0c84cc5

File tree

20 files changed

+2
-3332
lines changed

20 files changed

+2
-3332
lines changed

doc/releases/release-notes-4.3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Removed APIs and options
6060

6161
* The TinyCrypt library was removed as the upstream version is no longer maintained.
6262
PSA Crypto API is now the recommended cryptographic library for Zephyr.
63+
* The legacy pipe object API was removed. Use the new pipe API instead.
6364

6465
Deprecated APIs and options
6566
===========================

include/zephyr/kernel.h

Lines changed: 0 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -5211,206 +5211,6 @@ void k_mbox_data_get(struct k_mbox_msg *rx_msg, void *buffer);
52115211
*/
52125212
__syscall void k_pipe_init(struct k_pipe *pipe, uint8_t *buffer, size_t buffer_size);
52135213

5214-
#ifdef CONFIG_PIPES
5215-
/** Pipe Structure */
5216-
struct k_pipe {
5217-
unsigned char *buffer; /**< Pipe buffer: may be NULL */
5218-
size_t size; /**< Buffer size */
5219-
size_t bytes_used; /**< Number of bytes used in buffer */
5220-
size_t read_index; /**< Where in buffer to read from */
5221-
size_t write_index; /**< Where in buffer to write */
5222-
struct k_spinlock lock; /**< Synchronization lock */
5223-
5224-
struct {
5225-
_wait_q_t readers; /**< Reader wait queue */
5226-
_wait_q_t writers; /**< Writer wait queue */
5227-
} wait_q; /** Wait queue */
5228-
5229-
Z_DECL_POLL_EVENT
5230-
5231-
uint8_t flags; /**< Flags */
5232-
5233-
SYS_PORT_TRACING_TRACKING_FIELD(k_pipe)
5234-
5235-
#ifdef CONFIG_OBJ_CORE_PIPE
5236-
struct k_obj_core obj_core;
5237-
#endif
5238-
};
5239-
5240-
/**
5241-
* @cond INTERNAL_HIDDEN
5242-
*/
5243-
#define K_PIPE_FLAG_ALLOC BIT(0) /** Buffer was allocated */
5244-
5245-
#define Z_PIPE_INITIALIZER(obj, pipe_buffer, pipe_buffer_size) \
5246-
{ \
5247-
.buffer = pipe_buffer, \
5248-
.size = pipe_buffer_size, \
5249-
.bytes_used = 0, \
5250-
.read_index = 0, \
5251-
.write_index = 0, \
5252-
.lock = {}, \
5253-
.wait_q = { \
5254-
.readers = Z_WAIT_Q_INIT(&obj.wait_q.readers), \
5255-
.writers = Z_WAIT_Q_INIT(&obj.wait_q.writers) \
5256-
}, \
5257-
Z_POLL_EVENT_OBJ_INIT(obj) \
5258-
.flags = 0, \
5259-
}
5260-
5261-
/**
5262-
* INTERNAL_HIDDEN @endcond
5263-
*/
5264-
5265-
/**
5266-
* @brief Statically define and initialize a pipe.
5267-
*
5268-
* The pipe can be accessed outside the module where it is defined using:
5269-
*
5270-
* @code extern struct k_pipe <name>; @endcode
5271-
*
5272-
* @param name Name of the pipe.
5273-
* @param pipe_buffer_size Size of the pipe's ring buffer (in bytes),
5274-
* or zero if no ring buffer is used.
5275-
* @param pipe_align Alignment of the pipe's ring buffer (power of 2).
5276-
*
5277-
*/
5278-
#define K_PIPE_DEFINE(name, pipe_buffer_size, pipe_align) \
5279-
static unsigned char __noinit __aligned(pipe_align) \
5280-
_k_pipe_buf_##name[pipe_buffer_size]; \
5281-
STRUCT_SECTION_ITERABLE(k_pipe, name) = \
5282-
Z_PIPE_INITIALIZER(name, _k_pipe_buf_##name, pipe_buffer_size)
5283-
5284-
/**
5285-
* @deprecated Dynamic allocation of pipe buffers will be removed in the new k_pipe API.
5286-
* @brief Release a pipe's allocated buffer
5287-
*
5288-
* If a pipe object was given a dynamically allocated buffer via
5289-
* k_pipe_alloc_init(), this will free it. This function does nothing
5290-
* if the buffer wasn't dynamically allocated.
5291-
*
5292-
* @param pipe Address of the pipe.
5293-
* @retval 0 on success
5294-
* @retval -EAGAIN nothing to cleanup
5295-
*/
5296-
__deprecated int k_pipe_cleanup(struct k_pipe *pipe);
5297-
5298-
/**
5299-
* @deprecated Dynamic allocation of pipe buffers will be removed in the new k_pipe API.
5300-
* @brief Initialize a pipe and allocate a buffer for it
5301-
*
5302-
* Storage for the buffer region will be allocated from the calling thread's
5303-
* resource pool. This memory will be released if k_pipe_cleanup() is called,
5304-
* or userspace is enabled and the pipe object loses all references to it.
5305-
*
5306-
* This function should only be called on uninitialized pipe objects.
5307-
*
5308-
* @param pipe Address of the pipe.
5309-
* @param size Size of the pipe's ring buffer (in bytes), or zero if no ring
5310-
* buffer is used.
5311-
* @retval 0 on success
5312-
* @retval -ENOMEM if memory couldn't be allocated
5313-
*/
5314-
__deprecated __syscall int k_pipe_alloc_init(struct k_pipe *pipe, size_t size);
5315-
5316-
/**
5317-
* @deprecated k_pipe_put() is replaced by k_pipe_write(...) in the new k_pipe API.
5318-
* @brief Write data to a pipe.
5319-
*
5320-
* This routine writes up to @a bytes_to_write bytes of data to @a pipe.
5321-
*
5322-
* @param pipe Address of the pipe.
5323-
* @param data Address of data to write.
5324-
* @param bytes_to_write Size of data (in bytes).
5325-
* @param bytes_written Address of area to hold the number of bytes written.
5326-
* @param min_xfer Minimum number of bytes to write.
5327-
* @param timeout Waiting period to wait for the data to be written,
5328-
* or one of the special values K_NO_WAIT and K_FOREVER.
5329-
*
5330-
* @retval 0 At least @a min_xfer bytes of data were written.
5331-
* @retval -EIO Returned without waiting; zero data bytes were written.
5332-
* @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5333-
* minus one data bytes were written.
5334-
*/
5335-
__deprecated __syscall int k_pipe_put(struct k_pipe *pipe, const void *data,
5336-
size_t bytes_to_write, size_t *bytes_written,
5337-
size_t min_xfer, k_timeout_t timeout);
5338-
5339-
/**
5340-
* @deprecated k_pipe_get() is replaced by k_pipe_read(...) in the new k_pipe API.
5341-
* @brief Read data from a pipe.
5342-
*
5343-
* This routine reads up to @a bytes_to_read bytes of data from @a pipe.
5344-
*
5345-
* @param pipe Address of the pipe.
5346-
* @param data Address to place the data read from pipe.
5347-
* @param bytes_to_read Maximum number of data bytes to read.
5348-
* @param bytes_read Address of area to hold the number of bytes read.
5349-
* @param min_xfer Minimum number of data bytes to read.
5350-
* @param timeout Waiting period to wait for the data to be read,
5351-
* or one of the special values K_NO_WAIT and K_FOREVER.
5352-
*
5353-
* @retval 0 At least @a min_xfer bytes of data were read.
5354-
* @retval -EINVAL invalid parameters supplied
5355-
* @retval -EIO Returned without waiting; zero data bytes were read.
5356-
* @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5357-
* minus one data bytes were read.
5358-
*/
5359-
__deprecated __syscall int k_pipe_get(struct k_pipe *pipe, void *data,
5360-
size_t bytes_to_read, size_t *bytes_read,
5361-
size_t min_xfer, k_timeout_t timeout);
5362-
5363-
/**
5364-
* @deprecated k_pipe_read_avail() will be removed in the new k_pipe API.
5365-
* @brief Query the number of bytes that may be read from @a pipe.
5366-
*
5367-
* @param pipe Address of the pipe.
5368-
*
5369-
* @retval a number n such that 0 <= n <= @ref k_pipe.size; the
5370-
* result is zero for unbuffered pipes.
5371-
*/
5372-
__deprecated __syscall size_t k_pipe_read_avail(struct k_pipe *pipe);
5373-
5374-
/**
5375-
* @deprecated k_pipe_write_avail() will be removed in the new k_pipe API.
5376-
* @brief Query the number of bytes that may be written to @a pipe
5377-
*
5378-
* @param pipe Address of the pipe.
5379-
*
5380-
* @retval a number n such that 0 <= n <= @ref k_pipe.size; the
5381-
* result is zero for unbuffered pipes.
5382-
*/
5383-
__deprecated __syscall size_t k_pipe_write_avail(struct k_pipe *pipe);
5384-
5385-
/**
5386-
* @deprecated k_pipe_flush() will be removed in the new k_pipe API.
5387-
* @brief Flush the pipe of write data
5388-
*
5389-
* This routine flushes the pipe. Flushing the pipe is equivalent to reading
5390-
* both all the data in the pipe's buffer and all the data waiting to go into
5391-
* that pipe into a large temporary buffer and discarding the buffer. Any
5392-
* writers that were previously pended become unpended.
5393-
*
5394-
* @param pipe Address of the pipe.
5395-
*/
5396-
__deprecated __syscall void k_pipe_flush(struct k_pipe *pipe);
5397-
5398-
/**
5399-
* @deprecated k_pipe_buffer_flush will be removed in the new k_pipe API.
5400-
* @brief Flush the pipe's internal buffer
5401-
*
5402-
* This routine flushes the pipe's internal buffer. This is equivalent to
5403-
* reading up to N bytes from the pipe (where N is the size of the pipe's
5404-
* buffer) into a temporary buffer and then discarding that buffer. If there
5405-
* were writers previously pending, then some may unpend as they try to fill
5406-
* up the pipe's emptied buffer.
5407-
*
5408-
* @param pipe Address of the pipe.
5409-
*/
5410-
__deprecated __syscall void k_pipe_buffer_flush(struct k_pipe *pipe);
5411-
5412-
#else /* CONFIG_PIPES */
5413-
54145214
enum pipe_flags {
54155215
PIPE_FLAG_OPEN = BIT(0),
54165216
PIPE_FLAG_RESET = BIT(1),
@@ -5524,7 +5324,6 @@ __syscall void k_pipe_reset(struct k_pipe *pipe);
55245324
* @param pipe Address of the pipe.
55255325
*/
55265326
__syscall void k_pipe_close(struct k_pipe *pipe);
5527-
#endif /* CONFIG_PIPES */
55285327
/** @} */
55295328

55305329
/**

include/zephyr/kernel/thread.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ struct __thread_entry {
4242

4343
struct k_thread;
4444

45-
/*
46-
* This _pipe_desc structure is used by the pipes kernel module when
47-
* CONFIG_PIPES has been selected.
48-
*/
49-
50-
struct _pipe_desc {
51-
sys_dnode_t node;
52-
unsigned char *buffer; /* Position in src/dest buffer */
53-
size_t bytes_to_xfer; /* # bytes left to transfer */
54-
struct k_thread *thread; /* Back pointer to pended thread */
55-
};
56-
5745
/* can be used for creating 'dummy' threads, e.g. for pending on objects */
5846
struct _thread_base {
5947

@@ -361,11 +349,6 @@ struct k_thread {
361349
struct k_mem_paging_stats_t paging_stats;
362350
#endif /* CONFIG_DEMAND_PAGING_THREAD_STATS */
363351

364-
#ifdef CONFIG_PIPES
365-
/** Pipe descriptor used with blocking k_pipe operations */
366-
struct _pipe_desc pipe_desc;
367-
#endif /* CONFIG_PIPES */
368-
369352
#ifdef CONFIG_OBJ_CORE_THREAD
370353
struct k_obj_core obj_core;
371354
#endif /* CONFIG_OBJ_CORE_THREAD */

kernel/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,13 @@ list(APPEND kernel_files
8181
condvar.c
8282
thread.c
8383
sched.c
84+
pipe.c
8485
)
8586

8687
if (CONFIG_SCHED_SCALABLE OR CONFIG_WAITQ_SCALABLE)
8788
list(APPEND kernel_files priority_queues.c)
8889
endif()
8990

90-
# FIXME: Once the prior pipe implementation is removed, this should be included in the above list
91-
if(NOT CONFIG_PIPES)
92-
list(APPEND kernel_files pipe.c)
93-
endif() # NOT CONFIG_PIPES
9491
if(CONFIG_SMP)
9592
list(APPEND kernel_files
9693
smp.c
@@ -153,7 +150,6 @@ target_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_C kernel PRIVATE atomic_c.c)
153150
target_sources_ifdef(CONFIG_MMU kernel PRIVATE mmu.c)
154151
target_sources_ifdef(CONFIG_POLL kernel PRIVATE poll.c)
155152
target_sources_ifdef(CONFIG_EVENTS kernel PRIVATE events.c)
156-
target_sources_ifdef(CONFIG_PIPES kernel PRIVATE pipes.c)
157153
target_sources_ifdef(CONFIG_SCHED_THREAD_USAGE kernel PRIVATE usage.c)
158154
target_sources_ifdef(CONFIG_OBJ_CORE kernel PRIVATE obj_core.c)
159155

kernel/Kconfig

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -742,20 +742,6 @@ config EVENTS
742742
Note that setting this option slightly increases the size of the
743743
thread structure.
744744

745-
config PIPES
746-
bool "Pipe objects"
747-
select DEPRECATED
748-
help
749-
This option enables kernel pipes. A pipe is a kernel object that
750-
allows a thread to send a byte stream to another thread. Pipes can
751-
be used to synchronously transfer chunks of data in whole or in part.
752-
753-
Note that setting this option slightly increases the size of the
754-
thread structure.
755-
This Kconfig is deprecated and will be removed, by disabling this
756-
kconfig another implementation of k_pipe will be available when
757-
CONFIG_MULTITHREADING is enabled.
758-
759745
config KERNEL_MEM_POOL
760746
bool "Use Kernel Memory Pool"
761747
default y

0 commit comments

Comments
 (0)