Zephyr Project API  3.1.0
A Scalable Open Source RTOS
ipc_icmsg_buf.h File Reference

Go to the source code of this file.

Data Structures

struct  icmsg_buf
 IPC Service ICMsg buffer API. More...
 

Functions

struct icmsg_buficmsg_buf_init (void *buf, size_t blen)
 Initialize inter core messaging buffer. More...
 
int icmsg_buf_write (struct icmsg_buf *ib, const char *buf, uint16_t len)
 Write specified amount of data to the inter core messaging buffer. More...
 
int icmsg_buf_read (struct icmsg_buf *ib, char *buf, uint16_t len)
 Read specified amount of data from the inter core messaging buffer. More...
 

Function Documentation

◆ icmsg_buf_init()

struct icmsg_buf * icmsg_buf_init ( void *  buf,
size_t  blen 
)

Initialize inter core messaging buffer.

This function initializes inter core messaging buffer on top of dedicated memory region.

Parameters
bufPointer to a memory region on which buffer is created.
blenLength of the buffer. Must be large enough to contain the internal structure and at least two bytes of data (one is reserved for written messages length).
Return values
structicmsg_buf* Pointer to the created buffer. The pointer points to the same address as buf.

◆ icmsg_buf_read()

int icmsg_buf_read ( struct icmsg_buf ib,
char *  buf,
uint16_t  len 
)

Read specified amount of data from the inter core messaging buffer.

Single read allows to read the message send by the single write. The provided buf must be big enough to store the whole message.

Parameters
ibA icmsg buffer to which data are to be written
bufData pointer to which read data will be written. If NULL, len of stored message is returned.
lenNumber of bytes to be read from the icmsg buffer.
Return values
intBytes read, negative error code on fail. Bytes to be read, if buf == NULL. -ENOMEM, if message can not fit in provided buf. -EAGAIN, if not whole message is ready yet.

◆ icmsg_buf_write()

int icmsg_buf_write ( struct icmsg_buf ib,
const char *  buf,
uint16_t  len 
)

Write specified amount of data to the inter core messaging buffer.

Parameters
ibA icmsg buffer to which to write.
bufPointer to the data to be written to icmsg buffer.
lenNumber of bytes to be written to the icmsg buffer.
Return values
intNumber of bytes written, negative error code on fail. -EINVAL, if len == 0. -ENOMEM, if len is bigger than the icmsg buffer can fit.