AM64x MCU+ SDK  10.01.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 
122 typedef void (*RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg,
123  void *data, uint16_t dataLen, int32_t crcStatus,
124  uint16_t remoteCoreId, uint16_t remoteEndPt);
125 
139 typedef void (*RPMessage_RecvNotifyCallback)(RPMessage_Object *obj, void *arg);
140 
141 
156 typedef void (*RPMessage_ControlEndPtCallback)(void *arg,
157  uint16_t remoteCoreId, uint16_t remoteEndPt, const char *remoteServiceName);
158 
168 typedef int32_t (*RPMessage_CrcHookFxn)(uint8_t *data, uint16_t dataLen, uint8_t crcSize, void *crc);
169 
183 typedef struct
184 {
185  uint16_t localEndPt;
191 
202 typedef struct
203 {
204  uintptr_t vringTxBaseAddr[CSL_CORE_ID_MAX];
205  uintptr_t vringRxBaseAddr[CSL_CORE_ID_MAX];
206  uint32_t vringSize;
207  uint16_t vringNumBuf;
208  uint16_t vringMsgSize;
209  const RPMessage_ResourceTable *linuxResourceTable;
214  uint16_t linuxCoreId;
215  uint8_t isCrcEnabled; /* CRC Enable/Disable flag */
216  RPMessage_CrcHookFxn crcHookFxn; /* Hook Function to be provided by application for CRC calculation */
218 
225 
232 
238 int32_t RPMessage_init(const RPMessage_Params *params);
239 
243 void RPMessage_deInit(void);
244 
258 int32_t RPMessage_waitForLinuxReady(uint32_t timeout);
259 
267  void *controlEndPtCallbackArgs);
268 
283 
290 
298 
309 
328 int32_t RPMessage_announce(uint16_t remoteProcId, uint16_t localEndPt, const char* name);
329 
353 int32_t RPMessage_send( void *data,
354  uint16_t dataLen,
355  uint16_t remoteCoreId,
356  uint16_t remoteEndPt,
357  uint16_t localEndPt,
358  uint32_t timeout
359  );
360 
381 int32_t RPMessage_recv(RPMessage_Object *obj, void* data, uint16_t *dataLen,
382  uint16_t *remoteCoreId, uint16_t *remoteEndPt, uint32_t timeout);
383 
384 
387 #ifdef __cplusplus
388 }
389 #endif
390 
391 #endif /* IPC_RPMSG_H_ */
392 
CSL_CORE_ID_MAX
#define CSL_CORE_ID_MAX
Definition: cslr_soc_defines.h:77
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:168
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:156
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:206
SystemP.h
RPMessage_CreateParams::localEndPt
uint16_t localEndPt
Definition: ipc_rpmsg.h:185
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:188
RPMessage_Params::vringMsgSize
uint16_t vringMsgSize
Definition: ipc_rpmsg.h:208
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:139
RPMessage_Params::linuxResourceTable
const RPMessage_ResourceTable * linuxResourceTable
Definition: ipc_rpmsg.h:209
RPMessage_CreateParams::recvCallback
RPMessage_RecvCallback recvCallback
Definition: ipc_rpmsg.h:186
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:187
RPMessage_Params::linuxCoreId
uint16_t linuxCoreId
Definition: ipc_rpmsg.h:214
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:122
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:215
RPMessage_Params::vringNumBuf
uint16_t vringNumBuf
Definition: ipc_rpmsg.h:207
RPMessage_Params
Parameters passed to RPMessage_init, these are generated via SysCfg.
Definition: ipc_rpmsg.h:203
RPMessage_Params::crcHookFxn
RPMessage_CrcHookFxn crcHookFxn
Definition: ipc_rpmsg.h:216
RPMessage_CreateParams
Parameters passed to RPMessage_construct.
Definition: ipc_rpmsg.h:184
RPMessage_CreateParams::recvNotifyCallbackArgs
void * recvNotifyCallbackArgs
Definition: ipc_rpmsg.h:189
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.