AM62x MCU+ SDK  09.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)*(uint16_t)((bufSize) + 32U)) + 32U)
85 
100 #define RPMESSAGE_VRING_SIZE_PDK(numBuf, bufSize) (2 * ((numBuf)*((bufSize))))
101 
105 #define RPMESSAGE_OBJECT_SIZE_MAX (192U)
106 
110 typedef struct RPMessage_Object_s {
111  uintptr_t rsv[RPMESSAGE_OBJECT_SIZE_MAX/sizeof(uint32_t)];
113 
130 typedef void (*RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg,
131  void *data, uint16_t dataLen,
132  uint16_t remoteCoreId, uint16_t remoteEndPt);
133 
147 typedef void (*RPMessage_RecvNotifyCallback)(RPMessage_Object *obj, void *arg);
148 
149 
164 typedef void (*RPMessage_ControlEndPtCallback)(void *arg,
165  uint16_t remoteCoreId, uint16_t remoteEndPt, const char *remoteServiceName);
166 
180 typedef struct
181 {
182  uint16_t localEndPt;
188 
199 typedef struct
200 {
201  uintptr_t vringTxBaseAddr[CSL_CORE_ID_MAX];
202  uintptr_t vringRxBaseAddr[CSL_CORE_ID_MAX];
203  uint32_t vringSize;
204  uint32_t vringNumBuf;
205  uint32_t vringMsgSize;
206  const RPMessage_ResourceTable *linuxResourceTable;
211  uint16_t linuxCoreId;
214 
221 
228 
234 int32_t RPMessage_init(const RPMessage_Params *params);
235 
239 void RPMessage_deInit(void);
240 
254 int32_t RPMessage_waitForLinuxReady(uint32_t timeout);
255 
263  void *controlEndPtCallbackArgs);
264 
279 
286 
294 
305 
324 int32_t RPMessage_announce(uint16_t remoteProcId, uint16_t localEndPt, const char* name);
325 
349 int32_t RPMessage_send( void *data,
350  uint16_t dataLen,
351  uint16_t remoteCoreId,
352  uint16_t remoteEndPt,
353  uint16_t localEndPt,
354  uint32_t timeout
355  );
356 
377 int32_t RPMessage_recv(RPMessage_Object *obj, void* data, uint16_t *dataLen,
378  uint16_t *remoteCoreId, uint32_t *remoteEndPt, uint32_t timeout);
379 
380 
383 #ifdef __cplusplus
384 }
385 #endif
386 
387 #endif /* IPC_RPMSG_H_ */
388 
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:78
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:164
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:110
RPMessage_Params::vringSize
uint32_t vringSize
Definition: ipc_rpmsg.h:203
SystemP.h
RPMessage_CreateParams::localEndPt
uint16_t localEndPt
Definition: ipc_rpmsg.h:182
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:185
RPMessage_deInit
void RPMessage_deInit(void)
De-Initialize RPMessage module.
data
uint32_t data
Definition: tisci_rm_psil.h:1
RPMessage_init
int32_t RPMessage_init(const RPMessage_Params *params)
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:147
RPMessage_Params::linuxResourceTable
const RPMessage_ResourceTable * linuxResourceTable
Definition: ipc_rpmsg.h:206
RPMessage_CreateParams::recvCallback
RPMessage_RecvCallback recvCallback
Definition: ipc_rpmsg.h:183
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_Params::vringMsgSize
uint32_t vringMsgSize
Definition: ipc_rpmsg.h:205
RPMessage_CreateParams::recvCallbackArgs
void * recvCallbackArgs
Definition: ipc_rpmsg.h:184
RPMessage_Params::linuxCoreId
uint16_t linuxCoreId
Definition: ipc_rpmsg.h:211
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:130
RPMessage_Params::vringNumBuf
uint32_t vringNumBuf
Definition: ipc_rpmsg.h:204
RPMessage_Params::vringAllocationPDK
uint8_t vringAllocationPDK
Definition: ipc_rpmsg.h:212
RPMessage_Params
Parameters passed to RPMessage_init, these are generated via SysCfg.
Definition: ipc_rpmsg.h:200
RPMessage_CreateParams
Parameters passed to RPMessage_construct.
Definition: ipc_rpmsg.h:181
RPMessage_CreateParams::recvNotifyCallbackArgs
void * recvNotifyCallbackArgs
Definition: ipc_rpmsg.h:186
RPMessage_recv
int32_t RPMessage_recv(RPMessage_Object *obj, void *data, uint16_t *dataLen, uint16_t *remoteCoreId, uint32_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(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:105
RPMessage_destruct
void RPMessage_destruct(RPMessage_Object *obj)
Delete a previously created RPMessage object.