rpmsg_ns.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (c) 2014, Mentor Graphics Corporation
  3. * Copyright (c) 2015 Xilinx, Inc.
  4. * Copyright (c) 2016 Freescale Semiconductor, Inc.
  5. * Copyright 2016 NXP
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holder nor the names of its
  17. * contributors may be used to endorse or promote products derived from this
  18. * software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  24. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef RPMSG_NS_H_
  33. #define RPMSG_NS_H_
  34. #include "rpmsg_lite.h"
  35. //! @addtogroup rpmsg_ns
  36. //! @{
  37. #define RL_NS_EPT_ADDR (0x35u)
  38. /* Up to 32 flags available */
  39. enum rpmsg_ns_flags
  40. {
  41. RL_NS_CREATE = 0,
  42. RL_NS_DESTROY = 1,
  43. };
  44. /*! \typedef rpmsg_ns_new_ept_cb
  45. \brief New endpoint NS callback function type.
  46. */
  47. typedef void (*rpmsg_ns_new_ept_cb)(uint32_t new_ept, const char *new_ept_name, uint32_t flags, void *user_data);
  48. struct rpmsg_ns_callback_data
  49. {
  50. rpmsg_ns_new_ept_cb cb;
  51. void *user_data;
  52. };
  53. struct rpmsg_ns_context
  54. {
  55. struct rpmsg_lite_endpoint *ept;
  56. struct rpmsg_ns_callback_data *cb_ctxt;
  57. };
  58. typedef struct rpmsg_ns_context *rpmsg_ns_handle;
  59. struct rpmsg_ns_static_context_container
  60. {
  61. struct rpmsg_lite_ept_static_context ept_ctxt;
  62. struct rpmsg_ns_callback_data cb_ctxt;
  63. struct rpmsg_ns_context ns_ctxt;
  64. };
  65. typedef struct rpmsg_ns_static_context_container rpmsg_ns_static_context;
  66. #if defined(__cplusplus)
  67. extern "C" {
  68. #endif
  69. /*******************************************************************************
  70. * API
  71. ******************************************************************************/
  72. /* Exported API functions */
  73. /*!
  74. * @brief Registers application nameservice callback
  75. *
  76. * @param rpmsg_lite_dev RPMsg-Lite instance
  77. * @param app_cb Application nameservice callback
  78. * @param user_data Application nameservice callback data
  79. * @param ns_ept_ctxt Nameservice endpoint preallocated context pointer, used in case of static api
  80. * (RL_USE_STATIC_API)
  81. *
  82. * @return RL_NULL on error, NameService handle on success.
  83. *
  84. */
  85. #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
  86. rpmsg_ns_handle rpmsg_ns_bind(struct rpmsg_lite_instance *rpmsg_lite_dev,
  87. rpmsg_ns_new_ept_cb app_cb,
  88. void *user_data,
  89. rpmsg_ns_static_context *ns_ept_ctxt);
  90. #else
  91. rpmsg_ns_handle rpmsg_ns_bind(struct rpmsg_lite_instance *rpmsg_lite_dev, rpmsg_ns_new_ept_cb app_cb, void *user_data);
  92. #endif /* RL_USE_STATIC_API */
  93. /*!
  94. * @brief Unregisters application nameservice callback and cleans up
  95. *
  96. * @param rpmsg_lite_dev RPMsg-Lite instance
  97. * @param handle NameService handle
  98. *
  99. * @return Status of function execution, RL_SUCCESS on success.
  100. *
  101. */
  102. int32_t rpmsg_ns_unbind(struct rpmsg_lite_instance *rpmsg_lite_dev, rpmsg_ns_handle handle);
  103. /*!
  104. * @brief Sends name service announcement to remote device
  105. *
  106. * @param rpmsg_lite_dev RPMsg-Lite instance
  107. * @param new_ept New endpoint to announce
  108. * @param ept_name Name for the announced endpoint
  109. * @param flags Channel creation/deletion flags
  110. *
  111. * @return Status of function execution, RL_SUCCESS on success
  112. *
  113. */
  114. int32_t rpmsg_ns_announce(struct rpmsg_lite_instance *rpmsg_lite_dev,
  115. struct rpmsg_lite_endpoint *new_ept,
  116. const char *ept_name,
  117. uint32_t flags);
  118. //! @}
  119. #if defined(__cplusplus)
  120. }
  121. #endif
  122. #endif /* RPMSG_NS_H_ */