Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Functions
kfifo.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for kfifo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  kfifo
 

Functions

void kfifo_init (struct kfifo *fifo, void *data, size_t esize, size_t size)
 Initialize a FIFO using preallocated buffer. More...
 
struct kfifokfifo_alloc (size_t nmem, size_t size)
 Dynamically allocate a new fifo buffer. More...
 
void kfifo_free (struct kfifo *fifo)
 Deallocate the FIFO. More...
 
void kfifo_in (struct kfifo *fifo, const void *data, size_t n)
 Put data into the FIFO. More...
 
void kfifo_out (struct kfifo *fifo, void *data, size_t n)
 Get data from the FIFO. More...
 
void kfifo_out_peek (struct kfifo *fifo, void *data, size_t n)
 Get some data from the FIFO without removing it. More...
 
void kfifo_dma_in_prepare (struct kfifo *fifo, char **data_ptr)
 Read data pointer of the next element to write. More...
 
void kfifo_dma_in_finish (struct kfifo *fifo, size_t n)
 Complete data writing of FIFO with DMA. More...
 
void kfifo_dma_out_prepare (struct kfifo *fifo, char **data_ptr, size_t *n)
 Read data pointer of the next FIFO element to read. More...
 
void kfifo_dma_out_finish (struct kfifo *fifo)
 Complete data reading of the FIFO with DMA. More...
 
void kfifo_put (struct kfifo *fifo, void *data)
 Put data into the FIFO. More...
 
void kfifo_get (struct kfifo *fifo, void *data)
 Get data from the FIFO. More...
 
void kfifo_peek (struct kfifo *fifo, void *data)
 Get data from the FIFO without removing it. More...
 
size_t kfifo_peek_len (struct kfifo *fifo)
 Return the record length of the next FIFO element to read. More...
 
void kfifo_skip (struct kfifo *fifo)
 Skip next data to read from the FIFO. More...
 
size_t kfifo_avail (struct kfifo *fifo)
 Return the number of unused elements (free space) in the FIFO. More...
 
size_t kfifo_len (struct kfifo *fifo)
 Return the number of used elements in the FIFO. More...
 
size_t kfifo_esize (struct kfifo *fifo)
 Return the size of the element managed by the FIFO. More...
 
size_t kfifo_size (struct kfifo *fifo)
 Return the number of elements can be stored in the FIFO. More...
 
size_t kfifo_header_size (void)
 Return the size of the kfifo header. More...
 
bool kfifo_is_empty (struct kfifo *fifo)
 Return if the FIFO is empty or not. More...
 
bool kfifo_is_full (struct kfifo *fifo)
 Return if the FIFO is full or not. More...
 

Function Documentation

◆ kfifo_alloc()

struct kfifo* kfifo_alloc ( size_t  nmem,
size_t  size 
)

Dynamically allocate a new fifo buffer.

Parameters
esizeElement size of the FIFO.
sizeNumber of elements in the FIFO.
Return values
kfifoReturning object of the allocated FIFO.
None

◆ kfifo_avail()

size_t kfifo_avail ( struct kfifo fifo)

Return the number of unused elements (free space) in the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
size_tThe number of the avaliable slots.

◆ kfifo_dma_in_finish()

void kfifo_dma_in_finish ( struct kfifo fifo,
size_t  n 
)

Complete data writing of FIFO with DMA.

Parameters
fifoThe fifo object to provide.
nSize of the data written to the FIFO in bytes.
Return values
None

◆ kfifo_dma_in_prepare()

void kfifo_dma_in_prepare ( struct kfifo fifo,
char **  data_ptr 
)

Read data pointer of the next element to write.

Parameters
fifoPointer to the FIFO.
data_ptrFor saving the data pointer of the next FIFO element to write with DMA.
Return values
None

◆ kfifo_dma_out_finish()

void kfifo_dma_out_finish ( struct kfifo fifo)

Complete data reading of the FIFO with DMA.

Parameters
fifoPointer to the FIFO.
Return values
None

◆ kfifo_dma_out_prepare()

void kfifo_dma_out_prepare ( struct kfifo fifo,
char **  data_ptr,
size_t *  n 
)

Read data pointer of the next FIFO element to read.

Parameters
fifoPointer to the FIFO.
data_ptrFor saving the data pointer of the next FIFO element to read with DMA.
nSize of the data buffer to read from the fifo with DMA in bytes.
Return values
None

◆ kfifo_esize()

size_t kfifo_esize ( struct kfifo fifo)

Return the size of the element managed by the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
size_tThe size of the element managed by the FIFO.

◆ kfifo_free()

void kfifo_free ( struct kfifo fifo)

Deallocate the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
None

◆ kfifo_get()

void kfifo_get ( struct kfifo fifo,
void *  data 
)

Get data from the FIFO.

Parameters
fifoPointer to the FIFO.
dataPointer to the memory space for retrieving data.
Return values
None

◆ kfifo_header_size()

size_t kfifo_header_size ( void  )

Return the size of the kfifo header.

Parameters
None
Return values
size_tThe size of the kfifo header.

◆ kfifo_in()

void kfifo_in ( struct kfifo fifo,
const void *  data,
size_t  n 
)

Put data into the FIFO.

Parameters
fifoPointer to the FIFO.
dataPointer to the data.
nSize of the data in bytes.
Return values
None

◆ kfifo_init()

void kfifo_init ( struct kfifo fifo,
void *  data,
size_t  esize,
size_t  size 
)

Initialize a FIFO using preallocated buffer.

Parameters
fifoThe fifo object.
dataThe data space for the FIFO.
esizeElement size of the FIFO.
sizeNumber of elements in the FIFO.
Return values
None

◆ kfifo_is_empty()

bool kfifo_is_empty ( struct kfifo fifo)

Return if the FIFO is empty or not.

Parameters
fifoPointer to the FIFO.
Return values
booltrue or false.

◆ kfifo_is_full()

bool kfifo_is_full ( struct kfifo fifo)

Return if the FIFO is full or not.

Parameters
fifoPointer to the FIFO.
Return values
booltrue or false.

◆ kfifo_len()

size_t kfifo_len ( struct kfifo fifo)

Return the number of used elements in the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
size_tThe number of used elements can be read.

◆ kfifo_out()

void kfifo_out ( struct kfifo fifo,
void *  data,
size_t  n 
)

Get data from the FIFO.

Parameters
fifoPointer to the FIFO.
dataThe memory space for retrieving data.
nSize of the data buffer.
Return values
None

◆ kfifo_out_peek()

void kfifo_out_peek ( struct kfifo fifo,
void *  data,
size_t  n 
)

Get some data from the FIFO without removing it.

Parameters
fifoPointer to the FIFO.
dataThe memory space for retrieving data.
nSize of the data buffer.
Return values
None

◆ kfifo_peek()

void kfifo_peek ( struct kfifo fifo,
void *  data 
)

Get data from the FIFO without removing it.

Parameters
fifoPointer to the FIFO.
dataPointer to the memory space for retrieving data.
Return values
None

◆ kfifo_peek_len()

size_t kfifo_peek_len ( struct kfifo fifo)

Return the record length of the next FIFO element to read.

Parameters
fifoPointer to the memory space for retrieving data.
Return values
size_tSize of the next FIFO element in bytes.

◆ kfifo_put()

void kfifo_put ( struct kfifo fifo,
void *  data 
)

Put data into the FIFO.

Parameters
fifoPointer to the FIFO.
dataPointer to the data.
Return values
None

◆ kfifo_size()

size_t kfifo_size ( struct kfifo fifo)

Return the number of elements can be stored in the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
size_tThe number of elements can be stored in the FIFO.

◆ kfifo_skip()

void kfifo_skip ( struct kfifo fifo)

Skip next data to read from the FIFO.

Parameters
fifoPointer to the FIFO.
Return values
None