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 unsigned long localAddr; /*!< RPMsg local endpoint address */ 30 unsigned long peerAddr; /*!< RPMsg peer endpoint address */ 31 const char *epName; /*!< RPMsg endpoint name for name service announcement */ 32 } srtm_rpmsg_endpoint_config_t; 33 34 /** 35 * @brief SRTM RPMsg endpoint channel RX callback function type. 36 */ 37 typedef int (*srtm_rpmsg_endpoint_rx_cb_t)( 38 srtm_channel_t channel, void *payload, int payloadLen, unsigned long src, void *param); 39 40 /******************************************************************************* 41 * API 42 ******************************************************************************/ 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /*! 48 * @brief Create RPMsg endpoint channel. 49 * 50 * @param config SRTM RPMsg endpoint configuration. 51 * @return SRTM channel handle on success and NULL on failure. 52 */ 53 srtm_channel_t SRTM_RPMsgEndpoint_Create(srtm_rpmsg_endpoint_config_t *config); 54 55 /*! 56 * @brief Destroy RPMsg endpoint channel. 57 * 58 * @param channel SRTM channel to destroy. 59 */ 60 void SRTM_RPMsgEndpoint_Destroy(srtm_channel_t channel); 61 62 /*! 63 * @brief Override RPMsg endpoint channel RX handler. 64 * 65 * By default, the RX messages are posted to dispatcher for SRTM 66 * request/response/notification handling. This function is to change the default 67 * behavior for functionality extension. 68 * 69 * @param channel SRTM channel to override RX handler. 70 * @param callback User function to handle RX message. 71 * @param param User parameter to be used in callback. 72 * @return SRTM_Status_Success on success and others on failure. 73 */ 74 srtm_status_t SRTM_RPMsgEndpoint_OverrideRxHandler(srtm_channel_t channel, 75 srtm_rpmsg_endpoint_rx_cb_t callback, 76 void *param); 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 /*! @} */ 83 84 #endif /* __SRTM_RPMSG_ENDPOINT_H__ */ 85