Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
kfifo.h
Go to the documentation of this file.
1 
4 #ifndef __KFIFO_H__
5 #define __KFIFO_H__
6 
7 #include <stdbool.h>
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 struct kfifo {
12  int start;
13  int end;
14  int count;
15  void *data;
16  size_t size;
17  size_t esize;
18  size_t header_size;
19  size_t payload_size;
20 };
21 
30 void kfifo_init(struct kfifo *fifo, void *data, size_t esize, size_t size);
31 
39 struct kfifo *kfifo_alloc(size_t nmem, size_t size);
40 
46 void kfifo_free(struct kfifo *fifo);
47 
55 void kfifo_in(struct kfifo *fifo, const void *data, size_t n);
56 
64 void kfifo_out(struct kfifo *fifo, void *data, size_t n);
65 
73 void kfifo_out_peek(struct kfifo *fifo, void *data, size_t n);
74 
82 void kfifo_dma_in_prepare(struct kfifo *fifo, char **data_ptr);
83 
90 void kfifo_dma_in_finish(struct kfifo *fifo, size_t n);
91 
101 void kfifo_dma_out_prepare(struct kfifo *fifo, char **data_ptr, size_t *n);
102 
108 void kfifo_dma_out_finish(struct kfifo *fifo);
109 
116 void kfifo_put(struct kfifo *fifo, void *data);
117 
124 void kfifo_get(struct kfifo *fifo, void *data);
125 
132 void kfifo_peek(struct kfifo *fifo, void *data);
133 
139 size_t kfifo_peek_len(struct kfifo *fifo);
140 
146 void kfifo_skip(struct kfifo *fifo);
147 
153 size_t kfifo_avail(struct kfifo *fifo);
154 
160 size_t kfifo_len(struct kfifo *fifo);
161 
167 size_t kfifo_esize(struct kfifo *fifo);
168 
174 size_t kfifo_size(struct kfifo *fifo);
175 
181 size_t kfifo_header_size(void);
182 
188 bool kfifo_is_empty(struct kfifo *fifo);
189 
195 bool kfifo_is_full(struct kfifo *fifo);
196 
197 #endif
void kfifo_dma_in_prepare(struct kfifo *fifo, char **data_ptr)
Read data pointer of the next element to write.
Definition: kfifo.c:139
bool kfifo_is_empty(struct kfifo *fifo)
Return if the FIFO is empty or not.
Definition: kfifo.c:251
void kfifo_out_peek(struct kfifo *fifo, void *data, size_t n)
Get some data from the FIFO without removing it.
Definition: kfifo.c:117
size_t kfifo_len(struct kfifo *fifo)
Return the number of used elements in the FIFO.
Definition: kfifo.c:231
size_t kfifo_size(struct kfifo *fifo)
Return the number of elements can be stored in the FIFO.
Definition: kfifo.c:241
void kfifo_peek(struct kfifo *fifo, void *data)
Get data from the FIFO without removing it.
Definition: kfifo.c:212
size_t kfifo_esize(struct kfifo *fifo)
Return the size of the element managed by the FIFO.
Definition: kfifo.c:236
void kfifo_in(struct kfifo *fifo, const void *data, size_t n)
Put data into the FIFO.
Definition: kfifo.c:66
void kfifo_dma_out_finish(struct kfifo *fifo)
Complete data reading of the FIFO with DMA.
Definition: kfifo.c:182
void kfifo_skip(struct kfifo *fifo)
Skip next data to read from the FIFO.
Definition: kfifo.c:217
void kfifo_put(struct kfifo *fifo, void *data)
Put data into the FIFO.
Definition: kfifo.c:202
struct kfifo * kfifo_alloc(size_t nmem, size_t size)
Dynamically allocate a new fifo buffer.
Definition: kfifo.c:34
void kfifo_out(struct kfifo *fifo, void *data, size_t n)
Get data from the FIFO.
Definition: kfifo.c:101
size_t kfifo_peek_len(struct kfifo *fifo)
Return the record length of the next FIFO element to read.
Definition: kfifo.c:189
void kfifo_init(struct kfifo *fifo, void *data, size_t esize, size_t size)
Initialize a FIFO using preallocated buffer.
Definition: kfifo.c:13
size_t kfifo_avail(struct kfifo *fifo)
Return the number of unused elements (free space) in the FIFO.
Definition: kfifo.c:226
void kfifo_dma_out_prepare(struct kfifo *fifo, char **data_ptr, size_t *n)
Read data pointer of the next FIFO element to read.
Definition: kfifo.c:171
void kfifo_free(struct kfifo *fifo)
Deallocate the FIFO.
Definition: kfifo.c:52
bool kfifo_is_full(struct kfifo *fifo)
Return if the FIFO is full or not.
Definition: kfifo.c:256
void kfifo_dma_in_finish(struct kfifo *fifo, size_t n)
Complete data writing of FIFO with DMA.
Definition: kfifo.c:152
void kfifo_get(struct kfifo *fifo, void *data)
Get data from the FIFO.
Definition: kfifo.c:207
size_t kfifo_header_size(void)
Return the size of the kfifo header.
Definition: kfifo.c:246
Definition: kfifo.h:11