Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
icmsg.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_IPC_ICMSG_H_
8#define ZEPHYR_INCLUDE_IPC_ICMSG_H_
9
10#include <stddef.h>
11#include <stdint.h>
12#include <zephyr/kernel.h>
13#include <zephyr/drivers/mbox.h>
15#include <zephyr/sys/atomic.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
33};
34
42};
43
45 /* Tx/Rx buffers. */
49#ifdef CONFIG_IPC_SERVICE_ICMSG_SHMEM_ACCESS_SYNC
50 struct k_mutex tx_lock;
51#endif
52
53 /* Callbacks for an endpoint. */
54 const struct ipc_service_cb *cb;
55 void *ctx;
56
57 /* General */
58 const struct icmsg_config_t *cfg;
62 /* No-copy */
63#ifdef CONFIG_IPC_SERVICE_ICMSG_NOCOPY_RX
64 atomic_t rx_buffer_state;
65 const void *rx_buffer;
66 uint16_t rx_len;
67#endif
68};
69
94int icmsg_open(const struct icmsg_config_t *conf,
95 struct icmsg_data_t *dev_data,
96 const struct ipc_service_cb *cb, void *ctx);
97
112int icmsg_close(const struct icmsg_config_t *conf,
113 struct icmsg_data_t *dev_data);
114
133int icmsg_send(const struct icmsg_config_t *conf,
134 struct icmsg_data_t *dev_data,
135 const void *msg, size_t len);
136
180int icmsg_get_tx_buffer(const struct icmsg_config_t *conf,
181 struct icmsg_data_t *dev_data,
182 void **data, size_t *size);
183
202 struct icmsg_data_t *dev_data,
203 const void *data);
204
238int icmsg_send_nocopy(const struct icmsg_config_t *conf,
239 struct icmsg_data_t *dev_data,
240 const void *msg, size_t len);
241
242#ifdef CONFIG_IPC_SERVICE_ICMSG_NOCOPY_RX
258int icmsg_hold_rx_buffer(const struct icmsg_config_t *conf,
259 struct icmsg_data_t *dev_data,
260 const void *data);
261
277int icmsg_release_rx_buffer(const struct icmsg_config_t *conf,
278 struct icmsg_data_t *dev_data,
279 const void *data);
280#endif
281
286#ifdef __cplusplus
287}
288#endif
289
290#endif /* ZEPHYR_INCLUDE_IPC_ICMSG_H_ */
long atomic_t
Definition: atomic.h:22
Generic low-level multi-channel inter-processor mailbox communication API.
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_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_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_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_state
Definition: icmsg.h:29
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.
@ ICMSG_STATE_BUSY
Definition: icmsg.h:31
@ ICMSG_STATE_READY
Definition: icmsg.h:32
@ ICMSG_STATE_OFF
Definition: icmsg.h:30
Public kernel APIs.
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: icmsg.h:35
size_t rx_shm_size
Definition: icmsg.h:39
size_t tx_shm_size
Definition: icmsg.h:38
uintptr_t rx_shm_addr
Definition: icmsg.h:37
struct mbox_channel mbox_rx
Definition: icmsg.h:41
uintptr_t tx_shm_addr
Definition: icmsg.h:36
struct mbox_channel mbox_tx
Definition: icmsg.h:40
Definition: icmsg.h:44
const struct ipc_service_cb * cb
Definition: icmsg.h:54
struct k_work_delayable notify_work
Definition: icmsg.h:59
const struct icmsg_config_t * cfg
Definition: icmsg.h:58
struct spsc_pbuf * tx_ib
Definition: icmsg.h:46
struct spsc_pbuf * rx_ib
Definition: icmsg.h:47
struct k_work mbox_work
Definition: icmsg.h:60
atomic_t tx_buffer_state
Definition: icmsg.h:48
void * ctx
Definition: icmsg.h:55
atomic_t state
Definition: icmsg.h:61
Event callback structure.
Definition: ipc_service.h:145
Mutex Structure.
Definition: kernel.h:2911
A structure used to submit work after a delay.
Definition: kernel.h:3893
A structure used to submit work.
Definition: kernel.h:3865
Provides a type to hold an MBOX channel.
Definition: mbox.h:93
Single producer, single consumer packet buffer.
Definition: spsc_pbuf.h:100