PSDK QNX API Guide
ipc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2018
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the
15  * distribution.
16  *
17  * Neither the name of Texas Instruments Incorporated nor the names of
18  * its contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
43 /* @} */
44 
59 #ifndef IPC_H_
60 #define IPC_H_
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /* ========================================================================== */
67 /* Include Files */
68 /* ========================================================================== */
69 #include <ti/csl/soc.h>
70 #include <ti/csl/csl_types.h>
71 
77 #include <ti/drv/ipc/soc/ipc_soc.h>
78 #include <string.h>
79 
80 /* ========================================================================== */
81 /* Macros & Typedefs */
82 /* ========================================================================== */
86 typedef struct RPMessage_Object_s* RPMessage_Handle;
87 
98 typedef void (*RPMessage_Callback)(RPMessage_Handle handle, void* arg, void* data,
99  uint16_t len, uint32_t src);
100 
101 typedef void (*RPMessage_ProcCallback)(uint32_t srcEndPt, uint32_t srcProcId,
102  uint32_t destEndPt, void* arg);
103 
104 
105 /* ========================================================================== */
106 /* Structure Declarations */
107 /* ========================================================================== */
108 
113 typedef struct Ipc_InitPrms_s
114 {
115  uint32_t instId;
118  uint32_t padding;
150 } Ipc_InitPrms;
151 
155 typedef struct RPMessage_Params_s
156 {
157  uint32_t requestedEndpt;
160  uint32_t numBufs;
163  void* buf;
166  void* stackBuffer;
169  uint32_t bufSize;
174  uint32_t stackSize;
177 
181 typedef struct RPMessage_Stats_s
182 {
189 
190 /* ========================================================================== */
191 /* Function Declarations */
192 /* ========================================================================== */
210 void IpcInitPrms_init(uint32_t instId, Ipc_InitPrms *initPrms);
211 
224 int32_t Ipc_init(const Ipc_InitPrms *cfg);
225 
233 int32_t Ipc_deinit(void);
234 
239 
240 
245 
258 
270 /* Rename proc to procId in function prototype to fix MISRA.CT.UNIQUE.ID and MISRA.VAR.HIDDEN KW issues */
271 int32_t RPMessage_lateInit(uint32_t procId);
272 
273 
278 void RPMessage_deInit(void);
279 
280 
293 
314 
333 
354 int32_t RPMessage_setCallbackForProc(RPMessage_ProcCallback cb, void* arg, int32_t priority);
355 
369 
401 int32_t RPMessage_recv(RPMessage_Handle handle, void* data, uint16_t *len,
402  uint32_t *rplyEndPt, uint32_t *fromProcId, uint32_t timeout);
403 
425 int32_t RPMessage_recvNb(RPMessage_Handle handle, void* data, uint16_t *len,
426  uint32_t *rplyEndPt, uint32_t *fromProcId);
427 
442  uint32_t dstProc,
443  uint32_t dstEndPt,
444  uint32_t srcEndPt,
445  void* data,
446  uint16_t len);
447 
461 int32_t RPMessage_delete(RPMessage_Handle *handlePtr);
462 
480 
481 
506 int32_t RPMessage_getRemoteEndPt(uint32_t currProcId, const char* name, uint32_t *remoteProcId,
507  uint32_t *remoteEndPt, uint32_t timeout);
508 
509 /*
510  * \brief Wait for an endpoint to become available on another
511  * processor with token.
512  *
513  * Block the current task until the specified processor announces the
514  * named endpoint. The name is a string that identifies the service
515  * that is offered on the endpoint. This allows an application to both
516  * wait for the remote processor to signal that it is ready to
517  * communicate and to lookup services by name. The procId can be that
518  * of a specific processor or PRMessage_ANY to wait for any processor
519  * to announce the named endpoint. Suitable values for timeout are the
520  * same as for the ti.sysbios.knl.Semaphore module.
521  * This is the same as RPMessage_getRemoteEndPt, except that a token
522  * can be taken with the request, which can be used by the application
523  * to unblock the request in order to unblock it's waiting task.
524  *
525  * \param currProcId [IN] Remote processor ID
526  * \param name [IN] Name of the endpoint
527  * \param remoteProcId [OUT] Remote processor ID
528  * \param remoteEndPt [OUT] Remote endpoint ID
529  * \param timeout [IN] Timeout value (in system ticks)
530  * \param token [IN] User-provided token that can be used to unblock the function
531  *
532  * Restrictions:
533  * - The token passed must be unique for each call.
534  *
535  * \return - #IPC_SOK: Endpoint successfully returned
536  * - #IPC_ETIMEOUT: Time out occured
537  * - #IPC_EFAIL: Invalid input
538  * - #IPC_E_NO_ENDPOINT: End point not found
539  */
540 int32_t RPMessage_getRemoteEndPtToken(uint32_t currProcId, const char* name, uint32_t *remoteProcId,
541  uint32_t *remoteEndPt, uint32_t timeout, uint32_t token);
542 
556 void RPMessage_unblockGetRemoteEndPt(uint32_t token);
557 
582 int32_t RPMessage_announce(uint32_t remoteProcId, uint32_t endPt,
583  const char* name);
584 
604 
614 void Ipc_mailboxEnableNewMsgInt(uint16_t selfId, uint16_t remoteProcId);
615 
625 void Ipc_mailboxDisableNewMsgInt(uint16_t selfId, uint16_t remoteProcId);
626 
627 /* ========================================================================== */
628 /* Static Function Definitions */
629 /* ========================================================================== */
630 
631 /* None */
632 
633 #ifdef __cplusplus
634 }
635 #endif
636 
637 #endif /* #ifndef IPC_H_ */
638 
639 /* @} */
void RPMessage_deInit(void)
Tear down the RPMessage Module. The module API should not be used after this is called.
void RPMessage_unblockGetRemoteEndPt(uint32_t token)
Unblocks an RPMessage_getRemoteEndPtToken() call.
void * buf
Definition: ipc.h:163
int32_t RPMessage_setCallback(RPMessage_Handle handle, RPMessage_Callback cb, void *arg)
Sets callback.
int32_t RPMessage_send(RPMessage_Handle handle, uint32_t dstProc, uint32_t dstEndPt, uint32_t srcEndPt, void *data, uint16_t len)
Sends data to a remote processor.
void(* RPMessage_ProcCallback)(uint32_t srcEndPt, uint32_t srcProcId, uint32_t destEndPt, void *arg)
Definition: ipc.h:101
uint32_t bufSize
Definition: ipc.h:169
int32_t RPMessage_recvNb(RPMessage_Handle handle, void *data, uint16_t *len, uint32_t *rplyEndPt, uint32_t *fromProcId)
A non blocking API to receive message.
Ipc_PhyToVirtFxn phyToVirtFxn
Definition: ipc.h:120
RPMessage_Handle RPMessage_create(RPMessage_Params *params, uint32_t *endPt)
Create a endpoint instance for receiving.
uint32_t recvBufferAllocFailures
Definition: ipc.h:186
int32_t Ipc_deinit(void)
De Initialize IPC module.
uint32_t recvTotalMessages
Definition: ipc.h:183
Ipc_PrintFxn printFxn
Definition: ipc.h:147
uint32_t requestedEndpt
Definition: ipc.h:157
int32_t RPMessage_deleteCallbackForProc(void)
Deletes callback.
int32_t RPMessage_recv(RPMessage_Handle handle, void *data, uint16_t *len, uint32_t *rplyEndPt, uint32_t *fromProcId, uint32_t timeout)
Receives a message from an endpoint instance.
int32_t RPMessage_getRemoteEndPt(uint32_t currProcId, const char *name, uint32_t *remoteProcId, uint32_t *remoteEndPt, uint32_t timeout)
Wait for an endpoint to become available on another processor.
int32_t RPMessage_init(RPMessage_Params *params)
Initialize RPMessage Module.
uint32_t recvMessagesLiveTransferred
Definition: ipc.h:184
Ipc_NewMsgReceivedFxn newMsgFxn
Definition: ipc.h:139
int32_t RPMessage_lateInit(uint32_t procId)
Add a proc to RPMessage Module.
void * stackBuffer
Definition: ipc.h:166
void(* RPMessage_Callback)(RPMessage_Handle handle, void *arg, void *data, uint16_t len, uint32_t src)
RPMessage_Callback.
Definition: ipc.h:98
struct RPMessage_Object_s * RPMessage_Handle
RPMessage_Handle type.
Definition: ipc.h:86
int32_t RPMessage_getRemoteEndPtToken(uint32_t currProcId, const char *name, uint32_t *remoteProcId, uint32_t *remoteEndPt, uint32_t timeout, uint32_t token)
uint32_t numBufs
Definition: ipc.h:160
uint32_t recvEndpointFindFails
Definition: ipc.h:187
void Ipc_mailboxEnableNewMsgInt(uint16_t selfId, uint16_t remoteProcId)
API Mailbox Enable new MSG interrupt for a given remote processor.
int32_t RPMessage_delete(RPMessage_Handle *handlePtr)
Delete an endpoint instance.
int32_t RPMessage_setCallbackForProc(RPMessage_ProcCallback cb, void *arg, int32_t priority)
Sets callback.
int32_t RPMessageParams_init(RPMessage_Params *params)
Initialize an RPMessage_Params structure to default values.
void Ipc_mailboxDisableNewMsgInt(uint16_t selfId, uint16_t remoteProcId)
API Mailbox Disable new MSG interrupt for a given remote processor.
Ipc_RpMboxMsgFxn rpMboxMsgFxn
Definition: ipc.h:143
int32_t Ipc_init(const Ipc_InitPrms *cfg)
Initialize IPC module.
Ipc_OsalPrms osalPrms
Definition: ipc.h:136
int32_t RPMessage_announce(uint32_t remoteProcId, uint32_t endPt, const char *name)
Annouce the name of an endpoint and that it is ready to to receive messages.
uint32_t RPMessage_getObjMemRequired(void)
Returns local memory for RPMessage Object.
uint32_t instId
Definition: ipc.h:115
uint32_t recvMessagesQueued
Definition: ipc.h:185
void RPMessage_unblock(RPMessage_Handle handle)
Unblocks an RPMessage_recv()
Ipc_VirtToPhyFxn virtToPhyFxn
Definition: ipc.h:128
uint32_t stackSize
Definition: ipc.h:174
uint32_t RPMessage_getMessageBufferSize(void)
Returns Message Buffer Size.
void IpcInitPrms_init(uint32_t instId, Ipc_InitPrms *initPrms)
Initialize IPC init params.
uint32_t padding
Definition: ipc.h:118
void RPMessage_getStats(RPMessage_Stats *stats)
Copies the current statistics of the IPC driver into the structure provided.
configurations for ipc module.
IPC - Multiproc interface.
data types definitions for ipc module.
uint32_t(* Ipc_VirtToPhyFxn)(const void *virtAddr)
IPC Virtual to Physical address translation callback function.
Definition: ipc_types.h:165
void(* Ipc_NewMsgReceivedFxn)(uint32_t srcEndPt, uint32_t srcProcId, uint32_t destEndPt)
IPC New message notification.
Definition: ipc_types.h:329
void *(* Ipc_PhyToVirtFxn)(uint32_t phyAddr)
IPC Physical to Virtual address translation callback function.
Definition: ipc_types.h:177
void(* Ipc_PrintFxn)(const char *str)
IPC info/debug print function prototype.
Definition: ipc_types.h:186
void(* Ipc_RpMboxMsgFxn)(uint32_t remoteCoreId, uint32_t msgVal)
IPC message for RP Mbox notification.
Definition: ipc_types.h:337
VirtIO Interface for application.
IPC initialization parameters.
Definition: ipc.h:114
IPC driver OSAL function pointers.
Definition: ipc_types.h:343
Parameter structure for creating RPMessage endpoints.
Definition: ipc.h:156
Storage structure for profiling the behavior of IPC.
Definition: ipc.h:182