Zephyr API Documentation
3.5.0
A Scalable Open Source RTOS
|
|
3.5.0 |
Icmsg IPC library API. More...
Data Structures | |
struct | icmsg_config_t |
struct | icmsg_data_t |
Enumerations | |
enum | icmsg_state { ICMSG_STATE_OFF , ICMSG_STATE_BUSY , ICMSG_STATE_READY } |
Functions | |
int | icmsg_open (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data, const struct ipc_service_cb *cb, void *ctx) |
Open an icmsg instance. | |
int | icmsg_close (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data) |
Close an icmsg instance. | |
int | icmsg_send (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data, const void *msg, size_t len) |
Send a message to the remote icmsg instance. | |
int | icmsg_get_tx_buffer (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data, void **data, size_t *size) |
Get an empty TX buffer to be sent using icmsg_send_nocopy. | |
int | icmsg_drop_tx_buffer (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data, const void *data) |
Drop and release a TX buffer. | |
int | icmsg_send_nocopy (const struct icmsg_config_t *conf, struct icmsg_data_t *dev_data, const void *msg, size_t len) |
Send a message from a buffer obtained by icmsg_get_tx_buffer to the remote icmsg instance. | |
Icmsg IPC library API.
enum icmsg_state |
#include <zephyr/ipc/icmsg.h>
Enumerator | |
---|---|
ICMSG_STATE_OFF | |
ICMSG_STATE_BUSY | |
ICMSG_STATE_READY |
int icmsg_close | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data | ||
) |
#include <zephyr/ipc/icmsg.h>
Close an icmsg instance.
Closing an icmsg instance results in releasing all resources used by given instance including the shared memory regions and mbox devices.
[in] | conf | Structure containing configuration parameters for the icmsg instance being closed. Its content must be the same as used for creating this instance with icmsg_open. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
0 | on success. |
other | errno codes from dependent modules. |
int icmsg_drop_tx_buffer | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data, | ||
const void * | data | ||
) |
#include <zephyr/ipc/icmsg.h>
Drop and release a TX buffer.
Drop and release a TX buffer. It is possible to drop only TX buffers obtained by using icmsg_get_tx_buffer.
[in] | conf | Structure containing configuration parameters for the icmsg instance. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
[in] | data | Pointer to the TX buffer. |
-EALREADY | when the buffer was already dropped. |
-ENXIO | when the buffer was not obtained using ipc_service_get_tx_buffer |
0 | on success. |
int icmsg_get_tx_buffer | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data, | ||
void ** | data, | ||
size_t * | size | ||
) |
#include <zephyr/ipc/icmsg.h>
Get an empty TX buffer to be sent using icmsg_send_nocopy.
This function can be called to get an empty TX buffer so that the application can directly put its data into the sending buffer avoiding copy performed by the icmsg library.
It is the application responsibility to correctly fill the allocated TX buffer with data and passing correct parameters to icmsg_send_nocopy function to perform data no-copy-send mechanism.
The size parameter can be used to request a buffer with a certain size:
In all the cases on return the size parameter contains the maximum size for the returned buffer.
When the function returns no errors, the buffer is intended as allocated and it is released under one of two conditions: (1) when sending the buffer using icmsg_send_nocopy (and in this case the buffer is automatically released by the backend), (2) when using icmsg_drop_tx_buffer on a buffer not sent.
[in] | conf | Structure containing configuration parameters for the icmsg instance. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
[out] | data | Pointer to the empty TX buffer. |
[in,out] | size | Pointer to store the requested TX buffer size. If the function returns -ENOMEM, this parameter returns the maximum allowed size. |
-ENOBUFS | when there are no TX buffers available. |
-EALREADY | when a buffer was already claimed and not yet released. |
-ENOMEM | when the requested size is too big (and the size parameter contains the maximum allowed size). |
0 | on success. |
int icmsg_open | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data, | ||
const struct ipc_service_cb * | cb, | ||
void * | ctx | ||
) |
#include <zephyr/ipc/icmsg.h>
Open an icmsg instance.
Open an icmsg instance to be able to send and receive messages to a remote instance. This function is blocking until the handshake with the remote instance is completed. This function is intended to be called late in the initialization process, possibly from a thread which can be safely blocked while handshake with the remote instance is being pefromed.
[in] | conf | Structure containing configuration parameters for the icmsg instance. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
[in] | cb | Structure containing callback functions to be called on events generated by this icmsg instance. The pointed memory must be preserved while the icmsg instance is active. |
[in] | ctx | Pointer to context passed as an argument to callbacks. |
0 | on success. |
-EALREADY | when the instance is already opened. |
other | errno codes from dependent modules. |
int icmsg_send | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data, | ||
const void * | msg, | ||
size_t | len | ||
) |
#include <zephyr/ipc/icmsg.h>
Send a message to the remote icmsg instance.
[in] | conf | Structure containing configuration parameters for the icmsg instance. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
[in] | msg | Pointer to a buffer containing data to send. |
[in] | len | Size of data in the msg buffer. |
0 | on success. |
-EBUSY | when the instance has not finished handshake with the remote instance. |
-ENODATA | when the requested data to send is empty. |
-EBADMSG | when the requested data to send is too big. |
-ENOBUFS | when there are no TX buffers available. |
other | errno codes from dependent modules. |
int icmsg_send_nocopy | ( | const struct icmsg_config_t * | conf, |
struct icmsg_data_t * | dev_data, | ||
const void * | msg, | ||
size_t | len | ||
) |
#include <zephyr/ipc/icmsg.h>
Send a message from a buffer obtained by icmsg_get_tx_buffer to the remote icmsg instance.
This is equivalent to icmsg_send but in this case the TX buffer must have been obtained by using icmsg_get_tx_buffer.
The API user has to take the responsibility for getting the TX buffer using icmsg_get_tx_buffer and filling the TX buffer with the data.
After the icmsg_send_nocopy function is issued the TX buffer is no more owned by the sending task and must not be touched anymore unless the function fails and returns an error.
If this function returns an error, icmsg_drop_tx_buffer can be used to drop the TX buffer.
[in] | conf | Structure containing configuration parameters for the icmsg instance. |
[in,out] | dev_data | Structure containing run-time data used by the icmsg instance. |
[in] | msg | Pointer to a buffer containing data to send. |
[in] | len | Size of data in the msg buffer. |
-EBUSY | when the instance has not finished handshake with the remote instance. |
-ENODATA | when the requested data to send is empty. |
-EBADMSG | when the requested data to send is too big. |
-ENXIO | when the buffer was not obtained using ipc_service_get_tx_buffer |
other | errno codes from dependent modules. |