-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathipc-shm.h
142 lines (129 loc) · 4.47 KB
/
ipc-shm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright 2018-2024 NXP
*/
#ifndef IPC_SHM_H
#define IPC_SHM_H
#include "ipc-types.h"
/**
* ipc_shm_init_instance() - Initialize the specified instance
* of the IPC-Shm driver
*
* @instance: instance id
* @cfg: ipc-shm instance configuration
*
* Return IPC_SHM_E_OK on success, error code otherwise
*/
int8_t ipc_shm_init_instance(uint8_t instance, const struct ipc_shm_cfg *cfg);
/**
* ipc_shm_init() - initialize shared memory device
* @cfg: configuration parameters
*
* Function is non-reentrant.
*
* Return: 0 on success, error code otherwise
*/
int8_t ipc_shm_init(const struct ipc_shm_instances_cfg *cfg);
/**
* ipc_shm_free_instance() - Deinitialize the specified instance
* of the IPC-Shm driver
*
* @instance: instance id
*
* Function is non-reentrant.
*/
void ipc_shm_free_instance(const uint8_t instance);
/**
* ipc_shm_free() - release all instances of shared memory device
*
* Function is non-reentrant.
*/
void ipc_shm_free(void);
/**
* ipc_shm_acquire_buf() - request a buffer for the given channel
* @instance: instance id
* @chan_id: channel index
* @mem_size: required size
*
* Function used only for managed channels where buffer management is enabled.
* Function is thread-safe for different channels but not for the same channel.
*
* Return: pointer to the buffer base address or NULL if buffer not found
*/
void *ipc_shm_acquire_buf(const uint8_t instance, uint8_t chan_id,
uint32_t mem_size);
/**
* ipc_shm_release_buf() - release a buffer for the given channel
* @instance: instance id
* @chan_id: channel index
* @buf: buffer pointer
*
* Function used only for managed channels where buffer management is enabled.
* Function is thread-safe for different channels but not for the same channel.
*
* Return: 0 on success, error code otherwise
*/
int8_t ipc_shm_release_buf(const uint8_t instance, uint8_t chan_id,
const void *buf);
/**
* ipc_shm_tx() - send data on given channel and notify remote
* @instance: instance id
* @chan_id: channel index
* @buf: buffer pointer
* @size: size of data written in buffer
*
* Function used only for managed channels where buffer management is enabled.
* Function is thread-safe for different channels but not for the same channel.
*
* Return: 0 on success, error code otherwise
*/
int8_t ipc_shm_tx(const uint8_t instance, int chan_id, void *buf,
uint32_t size);
/**
* ipc_shm_unmanaged_acquire() - acquire the unmanaged channel local memory
* @instance: instance id
* @chan_id: channel index
*
* Function used only for unmanaged channels. The memory must be acquired only
* once after the channel is initialized. There is no release function needed.
* Function is thread-safe for different channels but not for the same channel.
*
* Return: pointer to the channel memory or NULL if invalid channel
*/
void *ipc_shm_unmanaged_acquire(const uint8_t instance, uint8_t chan_id);
/**
* ipc_shm_unmanaged_tx() - notify remote that data has been written in channel
* @instance: instance id
* @chan_id: channel index
*
* Function used only for unmanaged channels. It can be used after the channel
* memory has been acquired whenever is needed to signal remote that new data
* is available in channel memory.
* Function is thread-safe for different channels but not for the same channel.
*
* Return: 0 on success, error code otherwise
*/
int8_t ipc_shm_unmanaged_tx(const uint8_t instance, uint8_t chan_id);
/**
* ipc_shm_is_remote_ready() - check whether remote is initialized
* @instance: instance id
*
* Function used to check if the remote is initialized and ready to receive
* messages. It should be invoked at least before the first transmit operation.
* Function is thread-safe.
*
* Return: 0 if remote is initialized, error code otherwise
*/
int8_t ipc_shm_is_remote_ready(const uint8_t instance);
/**
* ipc_shm_poll_channels() - poll the channels for available messages to process
* @instance: instance id
*
* This function handles all channels using a fair handling algorithm: all
* channels are treated equally and no channel is starving.
* Function is thread-safe for different instances but not for same instance.
*
* Return: number of messages processed, error code otherwise
*/
int8_t ipc_shm_poll_channels(const uint8_t instance);
#endif /* IPC_SHM_H */