AM64x MCU+ SDK  08.02.00
ipc_rpmsg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef IPC_RPMSG_H_
34 #define IPC_RPMSG_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <stdint.h>
41 #include <kernel/dpl/SystemP.h>
42 #include <drivers/hw_include/cslr_soc.h>
43 #include <drivers/ipc_rpmsg/include/ipc_rpmsg_linux_resource_table.h>
44 
60 #define RPMESSAGE_MAX_LOCAL_ENDPT (64U)
61 
68 #define RPMESSAGE_VRING_ADDR_INVALID (0xFFFFFFFFU)
69 
84 #define RPMESSAGE_VRING_SIZE(numBuf, bufSize) (((numBuf)*((bufSize)+32U))+32)
85 
89 #define RPMESSAGE_OBJECT_SIZE_MAX (192U)
90 
94 typedef struct RPMessage_Object_s {
95  uintptr_t rsv[RPMESSAGE_OBJECT_SIZE_MAX/sizeof(uint32_t)];
97 
114 typedef void (*RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg,
115  void *data, uint16_t dataLen,
116  uint16_t remoteCoreId, uint16_t remoteEndPt);
117 
131 typedef void (*RPMessage_RecvNotifyCallback)(RPMessage_Object *obj, void *arg);
132 
133 
148 typedef void (*RPMessage_ControlEndPtCallback)(void *arg,
149  uint16_t remoteCoreId, uint16_t remoteEndPt, const char *remoteServiceName);
150 
164 typedef struct
165 {
166  uint16_t localEndPt;
172 
183 typedef struct
184 {
185  uintptr_t vringTxBaseAddr[CSL_CORE_ID_MAX];
186  uintptr_t vringRxBaseAddr[CSL_CORE_ID_MAX];
187  uint32_t vringSize;
188  uint16_t vringNumBuf;
189  uint16_t vringMsgSize;
190  const RPMessage_ResourceTable *linuxResourceTable;
195  uint16_t linuxCoreId;
197 
204 
211 
217 int32_t RPMessage_init(const RPMessage_Params *params);
218 
223 
237 int32_t RPMessage_waitForLinuxReady(uint32_t timeout);
238 
246  void *controlEndPtCallbackArgs);
247 
262 
269 
277 
288 
307 int32_t RPMessage_announce(uint16_t remoteProcId, uint16_t localEndPt, const char* name);
308 
332 int32_t RPMessage_send( void *data,
333  uint16_t dataLen,
334  uint16_t remoteCoreId,
335  uint16_t remoteEndPt,
336  uint16_t localEndPt,
337  uint32_t timeout
338  );
339 
360 int32_t RPMessage_recv(RPMessage_Object *obj, void* data, uint16_t *dataLen,
361  uint16_t *remoteCoreId, uint16_t *remoteEndPt, uint32_t timeout);
362 
363 
366 #ifdef __cplusplus
367 }
368 #endif
369 
370 #endif /* IPC_RPMSG_H_ */
371 
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:75
RPMessage_recv
int32_t RPMessage_recv(RPMessage_Object *obj, void *data, uint16_t *dataLen, uint16_t *remoteCoreId, uint16_t *remoteEndPt, uint32_t timeout)
Blocking API to wait till a message is received from any CPU at the specified local end point.
RPMessage_ControlEndPtCallback
void(* RPMessage_ControlEndPtCallback)(void *arg, uint16_t remoteCoreId, uint16_t remoteEndPt, const char *remoteServiceName)
Callback that is invoked when a annoucement message is received on the control end point.
Definition: ipc_rpmsg.h:148
RPMessage_unblock
void RPMessage_unblock(RPMessage_Object *obj)
Unblocks RPMessage_recv, for the input object, if it is blocked waiting on messages and users want to...
RPMessage_Object
Opaque RPMessage object used with the RPMessage APIs.
Definition: ipc_rpmsg.h:94
RPMessage_Params::vringSize
uint32_t vringSize
Definition: ipc_rpmsg.h:187
SystemP.h
RPMessage_CreateParams::localEndPt
uint16_t localEndPt
Definition: ipc_rpmsg.h:166
RPMessage_construct
int32_t RPMessage_construct(RPMessage_Object *obj, const RPMessage_CreateParams *createParams)
Create a RPMessage object to receive messages at a specified end-point.
RPMessage_waitForLinuxReady
int32_t RPMessage_waitForLinuxReady(uint32_t timeout)
Wait for linux side RPMessage to be ready.
RPMessage_CreateParams::recvNotifyCallback
RPMessage_RecvNotifyCallback recvNotifyCallback
Definition: ipc_rpmsg.h:169
RPMessage_Params::vringMsgSize
uint16_t vringMsgSize
Definition: ipc_rpmsg.h:189
data
uint32_t data
Definition: tisci_rm_psil.h:1
RPMessage_init
int32_t RPMessage_init(const RPMessage_Params *params)
Initialize RPMessage module.
RPMessage_deInit
void RPMessage_deInit()
De-Initialize RPMessage module.
RPMessage_getLocalEndPt
uint16_t RPMessage_getLocalEndPt(const RPMessage_Object *obj)
Return local end point of a RPMessage_Object.
RPMessage_RecvNotifyCallback
void(* RPMessage_RecvNotifyCallback)(RPMessage_Object *obj, void *arg)
Callback that is invoked when a message is received from any CPU at the specified local end point.
Definition: ipc_rpmsg.h:131
RPMessage_Params::linuxResourceTable
const RPMessage_ResourceTable * linuxResourceTable
Definition: ipc_rpmsg.h:190
RPMessage_CreateParams::recvCallback
RPMessage_RecvCallback recvCallback
Definition: ipc_rpmsg.h:167
RPMessage_Params_init
void RPMessage_Params_init(RPMessage_Params *params)
Set default values to RPMessage_Params.
RPMessage_announce
int32_t RPMessage_announce(uint16_t remoteProcId, uint16_t localEndPt, const char *name)
Announce a local end point at which a service is created to a remote core.
RPMessage_CreateParams::recvCallbackArgs
void * recvCallbackArgs
Definition: ipc_rpmsg.h:168
RPMessage_Params::linuxCoreId
uint16_t linuxCoreId
Definition: ipc_rpmsg.h:195
RPMessage_CreateParams_init
void RPMessage_CreateParams_init(RPMessage_CreateParams *params)
Set default values to RPMessage_CreateParams.
RPMessage_RecvCallback
void(* RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg, void *data, uint16_t dataLen, uint16_t remoteCoreId, uint16_t remoteEndPt)
Callback that is invoked when a message is received from any CPU at the specified local end point.
Definition: ipc_rpmsg.h:114
RPMessage_Params::vringNumBuf
uint16_t vringNumBuf
Definition: ipc_rpmsg.h:188
RPMessage_Params
Parameters passed to RPMessage_init, these are generated via SysCfg.
Definition: ipc_rpmsg.h:184
RPMessage_CreateParams
Parameters passed to RPMessage_construct.
Definition: ipc_rpmsg.h:165
RPMessage_CreateParams::recvNotifyCallbackArgs
void * recvNotifyCallbackArgs
Definition: ipc_rpmsg.h:170
RPMessage_controlEndPtCallback
void RPMessage_controlEndPtCallback(RPMessage_ControlEndPtCallback controlEndPtCallback, void *controlEndPtCallbackArgs)
Callback to call when a control message is received on a control end point.
RPMessage_send
int32_t RPMessage_send(void *data, uint16_t dataLen, uint16_t remoteCoreId, uint16_t remoteEndPt, uint16_t localEndPt, uint32_t timeout)
Send a message to a remote core at a specified remote end point.
RPMESSAGE_OBJECT_SIZE_MAX
#define RPMESSAGE_OBJECT_SIZE_MAX
Size of RPMessage_Object.
Definition: ipc_rpmsg.h:89
RPMessage_destruct
void RPMessage_destruct(RPMessage_Object *obj)
Delete a previously created RPMessage object.