1 /*
2  * Copyright 2017, NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef __SRTM_RPMSG_ENDPOINT_H__
10 #define __SRTM_RPMSG_ENDPOINT_H__
11 
12 #include "srtm_channel.h"
13 #include "rpmsg_lite.h"
14 
15 /*!
16  * @addtogroup srtm_channel
17  * @{
18  */
19 
20 /*******************************************************************************
21  * Definitions
22  ******************************************************************************/
23 /**
24  * @brief SRTM RPMsg endpoint channel configuration fields
25  */
26 typedef struct _srtm_rpmsg_endpoint_config
27 {
28     struct rpmsg_lite_instance *rpmsgHandle; /*!< RPMsg handle initialized by app */
29 #if defined(SRTM_STATIC_API) && SRTM_STATIC_API
30     struct rpmsg_lite_ept_static_context *ept_context; /*!< RPMsg endpoint context */
31 #endif
32     unsigned long localAddr;                 /*!< RPMsg local endpoint address */
33     unsigned long peerAddr;                  /*!< RPMsg peer endpoint address */
34     const char *epName;                      /*!< RPMsg endpoint name for name service announcement */
35 } srtm_rpmsg_endpoint_config_t;
36 
37 /**
38  * @brief SRTM RPMsg endpoint channel RX callback function type.
39  */
40 typedef int (*srtm_rpmsg_endpoint_rx_cb_t)(
41     srtm_channel_t channel, void *payload, int payloadLen, unsigned long src, void *param);
42 
43 /*******************************************************************************
44  * API
45  ******************************************************************************/
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /*!
51  * @brief Create RPMsg endpoint channel.
52  *
53  * @param config SRTM RPMsg endpoint configuration.
54  * @return SRTM channel handle on success and NULL on failure.
55  */
56 srtm_channel_t SRTM_RPMsgEndpoint_Create(srtm_rpmsg_endpoint_config_t *config);
57 
58 /*!
59  * @brief Destroy RPMsg endpoint channel.
60  *
61  * @param channel SRTM channel to destroy.
62  */
63 void SRTM_RPMsgEndpoint_Destroy(srtm_channel_t channel);
64 
65 /*!
66  * @brief Override RPMsg endpoint channel RX handler.
67  *
68  * By default, the RX messages are posted to dispatcher for SRTM
69  * request/response/notification handling. This function is to change the default
70  * behavior for functionality extension.
71  *
72  * @param channel SRTM channel to override RX handler.
73  * @param callback User function to handle RX message.
74  * @param param User parameter to be used in callback.
75  * @return SRTM_Status_Success on success and others on failure.
76  */
77 srtm_status_t SRTM_RPMsgEndpoint_OverrideRxHandler(srtm_channel_t channel,
78                                                    srtm_rpmsg_endpoint_rx_cb_t callback,
79                                                    void *param);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 /*! @} */
86 
87 #endif /* __SRTM_RPMSG_ENDPOINT_H__ */
88