AM263x MCU+ SDK  10.00.00
ipc_rpmsg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2023 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 
89 #define RPMESSAGE_OBJECT_SIZE_MAX (192U)
90 
94 #define RPMESSAGE_CRC_SIZE (2U)
95 
99 typedef struct RPMessage_Object_s {
100  uintptr_t rsv[RPMESSAGE_OBJECT_SIZE_MAX/sizeof(uint32_t)];
102 
120 typedef void (*RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg,
121  void *data, uint16_t dataLen, int32_t crcStatus,
122  uint16_t remoteCoreId, uint16_t remoteEndPt);
123 
137 typedef void (*RPMessage_RecvNotifyCallback)(RPMessage_Object *obj, void *arg);
138 
139 
154 typedef void (*RPMessage_ControlEndPtCallback)(void *arg,
155  uint16_t remoteCoreId, uint16_t remoteEndPt, const char *remoteServiceName);
156 
166 typedef int32_t (*RPMessage_CrcHookFxn)(uint8_t *data, uint16_t dataLen, uint8_t crcSize, void *crc);
167 
181 typedef struct
182 {
183  uint16_t localEndPt;
189 
200 typedef struct
201 {
202  uintptr_t vringTxBaseAddr[CSL_CORE_ID_MAX];
203  uintptr_t vringRxBaseAddr[CSL_CORE_ID_MAX];
204  uint32_t vringSize;
205  uint16_t vringNumBuf;
206  uint16_t vringMsgSize;
207  const RPMessage_ResourceTable *linuxResourceTable;
212  uint16_t linuxCoreId;
213  uint8_t isCrcEnabled; /* CRC Enable/Disable flag */
214  RPMessage_CrcHookFxn crcHookFxn; /* Hook Function to be provided by application for CRC calculation */
216 
223 
230 
236 int32_t RPMessage_init(const RPMessage_Params *params);
237 
241 void RPMessage_deInit(void);
242 
256 int32_t RPMessage_waitForLinuxReady(uint32_t timeout);
257 
265  void *controlEndPtCallbackArgs);
266 
281 
288 
296 
307 
326 int32_t RPMessage_announce(uint16_t remoteProcId, uint16_t localEndPt, const char* name);
327 
351 int32_t RPMessage_send( void *data,
352  uint16_t dataLen,
353  uint16_t remoteCoreId,
354  uint16_t remoteEndPt,
355  uint16_t localEndPt,
356  uint32_t timeout
357  );
358 
379 int32_t RPMessage_recv(RPMessage_Object *obj, void* data, uint16_t *dataLen,
380  uint16_t *remoteCoreId, uint16_t *remoteEndPt, uint32_t timeout);
381 
382 
385 #ifdef __cplusplus
386 }
387 #endif
388 
389 #endif /* IPC_RPMSG_H_ */
390 
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:120
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_CrcHookFxn
int32_t(* RPMessage_CrcHookFxn)(uint8_t *data, uint16_t dataLen, uint8_t crcSize, void *crc)
This is the CRC Hook function to be defined in application for CRC Calculation.
Definition: ipc_rpmsg.h:166
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:154
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:99
RPMessage_Params::vringSize
uint32_t vringSize
Definition: ipc_rpmsg.h:204
SystemP.h
RPMessage_CreateParams::localEndPt
uint16_t localEndPt
Definition: ipc_rpmsg.h:183
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:186
RPMessage_Params::vringMsgSize
uint16_t vringMsgSize
Definition: ipc_rpmsg.h:206
RPMessage_deInit
void RPMessage_deInit(void)
De-Initialize RPMessage module.
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:137
RPMessage_Params::linuxResourceTable
const RPMessage_ResourceTable * linuxResourceTable
Definition: ipc_rpmsg.h:207
RPMessage_CreateParams::recvCallback
RPMessage_RecvCallback recvCallback
Definition: ipc_rpmsg.h:184
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.
dataLen
uint32_t dataLen
Definition: hsmclient.h:1
RPMessage_CreateParams::recvCallbackArgs
void * recvCallbackArgs
Definition: ipc_rpmsg.h:185
RPMessage_Params::linuxCoreId
uint16_t linuxCoreId
Definition: ipc_rpmsg.h:212
RPMessage_RecvCallback
void(* RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg, void *data, uint16_t dataLen, int32_t crcStatus, 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:120
RPMessage_CreateParams_init
void RPMessage_CreateParams_init(RPMessage_CreateParams *params)
Set default values to RPMessage_CreateParams.
RPMessage_Params::isCrcEnabled
uint8_t isCrcEnabled
Definition: ipc_rpmsg.h:213
RPMessage_Params::vringNumBuf
uint16_t vringNumBuf
Definition: ipc_rpmsg.h:205
RPMessage_Params
Parameters passed to RPMessage_init, these are generated via SysCfg.
Definition: ipc_rpmsg.h:201
RPMessage_Params::crcHookFxn
RPMessage_CrcHookFxn crcHookFxn
Definition: ipc_rpmsg.h:214
RPMessage_CreateParams
Parameters passed to RPMessage_construct.
Definition: ipc_rpmsg.h:182
RPMessage_CreateParams::recvNotifyCallbackArgs
void * recvNotifyCallbackArgs
Definition: ipc_rpmsg.h:187
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.