rpmsg_default_config.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright (c) 2014, Mentor Graphics Corporation
  3. * Copyright (c) 2015 Xilinx, Inc.
  4. * Copyright (c) 2016 Freescale Semiconductor, Inc.
  5. * Copyright 2016-2022 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_DEFAULT_CONFIG_H_
  33. #define RPMSG_DEFAULT_CONFIG_H_
  34. #include <rtthread.h>
  35. #ifdef PKG_RPMSG_LITE_CUSTOM_CONFIG
  36. #define RL_USE_CUSTOM_CONFIG (1)
  37. #else
  38. #define RL_USE_CUSTOM_CONFIG (0)
  39. #endif
  40. #if RL_USE_CUSTOM_CONFIG
  41. #include "rpmsg_config.h"
  42. #endif
  43. /*!
  44. * @addtogroup config
  45. * @{
  46. * @file
  47. */
  48. //! @name Configuration options
  49. //@{
  50. //! @def RL_MS_PER_INTERVAL
  51. //!
  52. //! Delay in milliseconds used in non-blocking API functions for polling.
  53. //! The default value is 1.
  54. #ifndef RL_MS_PER_INTERVAL
  55. #define RL_MS_PER_INTERVAL (1)
  56. #endif
  57. //! @def RL_ALLOW_CUSTOM_SHMEM_CONFIG
  58. //!
  59. //! This option allows to define custom shared memory configuration and replacing
  60. //! the shared memory related global settings from rpmsg_config.h This is useful
  61. //! when multiple instances are running in parallel but different shared memory
  62. //! arrangement (vring size & alignment, buffers size & count) is required. Note,
  63. //! that once enabled the platform_get_custom_shmem_config() function needs
  64. //! to be implemented in platform layer. The default value is 0 (all RPMsg_Lite
  65. //! instances use the same shared memory arrangement as defined by common config macros).
  66. #ifndef RL_ALLOW_CUSTOM_SHMEM_CONFIG
  67. #define RL_ALLOW_CUSTOM_SHMEM_CONFIG (0)
  68. #endif
  69. #if !(defined(RL_ALLOW_CUSTOM_SHMEM_CONFIG) && (RL_ALLOW_CUSTOM_SHMEM_CONFIG == 1))
  70. //! @def RL_BUFFER_PAYLOAD_SIZE
  71. //!
  72. //! Size of the buffer payload, it must be equal to (240, 496, 1008, ...)
  73. //! [2^n - 16]. Ensure the same value is defined on both sides of rpmsg
  74. //! communication. The default value is 496U.
  75. #ifndef RL_BUFFER_PAYLOAD_SIZE
  76. #define RL_BUFFER_PAYLOAD_SIZE (496U)
  77. #endif
  78. //! @def RL_BUFFER_COUNT
  79. //!
  80. //! Number of the buffers, it must be power of two (2, 4, ...).
  81. //! The default value is 2U.
  82. //! Note this value defines the buffer count for one direction of the rpmsg
  83. //! communication only, i.e. if the default value of 2 is used
  84. //! in rpmsg_config.h files for the master and the remote side, 4 buffers
  85. //! in total are created in the shared memory.
  86. #ifndef RL_BUFFER_COUNT
  87. #define RL_BUFFER_COUNT (2U)
  88. #endif
  89. #else
  90. //! Define the buffer payload and count per different link IDs (rpmsg_lite instance) when RL_ALLOW_CUSTOM_SHMEM_CONFIG
  91. //! is set.
  92. //! Refer to the rpmsg_plaform.h for the used link IDs.
  93. #ifndef RL_BUFFER_PAYLOAD_SIZE
  94. #define RL_BUFFER_PAYLOAD_SIZE(link_id) (496U)
  95. #endif
  96. #ifndef RL_BUFFER_COUNT
  97. #define RL_BUFFER_COUNT(link_id) (((link_id) == 0U) ? 256U : 2U)
  98. #endif
  99. #endif /* !(defined(RL_ALLOW_CUSTOM_SHMEM_CONFIG) && (RL_ALLOW_CUSTOM_SHMEM_CONFIG == 1))*/
  100. //! @def RL_API_HAS_ZEROCOPY
  101. //!
  102. //! Zero-copy API functions enabled/disabled.
  103. //! The default value is 1 (enabled).
  104. #ifndef RL_API_HAS_ZEROCOPY
  105. #define RL_API_HAS_ZEROCOPY (1)
  106. #endif
  107. //! @def RL_USE_STATIC_API
  108. //!
  109. //! Static API functions (no dynamic allocation) enabled/disabled.
  110. //! The default value is 0 (static API disabled).
  111. #ifndef RL_USE_STATIC_API
  112. #define RL_USE_STATIC_API (0)
  113. #endif
  114. //! @def RL_CLEAR_USED_BUFFERS
  115. //!
  116. //! Clearing used buffers before returning back to the pool of free buffers
  117. //! enabled/disabled.
  118. //! The default value is 0 (disabled).
  119. #ifndef RL_CLEAR_USED_BUFFERS
  120. #define RL_CLEAR_USED_BUFFERS (0)
  121. #endif
  122. //! @def RL_USE_MCMGR_IPC_ISR_HANDLER
  123. //!
  124. //! When enabled IPC interrupts are managed by the Multicore Manager (IPC
  125. //! interrupts router), when disabled RPMsg-Lite manages IPC interrupts
  126. //! by itself.
  127. //! The default value is 0 (no MCMGR IPC ISR handler used).
  128. #ifndef RL_USE_MCMGR_IPC_ISR_HANDLER
  129. #define RL_USE_MCMGR_IPC_ISR_HANDLER (0)
  130. #endif
  131. //! @def RL_USE_ENVIRONMENT_CONTEXT
  132. //!
  133. //! When enabled the environment layer uses its own context.
  134. //! Added for QNX port mainly, but can be used if required.
  135. //! The default value is 0 (no context, saves some RAM).
  136. #ifndef RL_USE_ENVIRONMENT_CONTEXT
  137. #define RL_USE_ENVIRONMENT_CONTEXT (0)
  138. #endif
  139. //! @def RL_DEBUG_CHECK_BUFFERS
  140. //!
  141. //! When enabled buffer pointers passed to rpmsg_lite_send_nocopy() and
  142. //! rpmsg_lite_release_rx_buffer() functions (enabled by RL_API_HAS_ZEROCOPY config)
  143. //! are checked to avoid passing invalid buffer pointer.
  144. //! The default value is 0 (disabled). Do not use in RPMsg-Lite to Linux configuration.
  145. #ifndef RL_DEBUG_CHECK_BUFFERS
  146. #define RL_DEBUG_CHECK_BUFFERS (0)
  147. #endif
  148. //! @def RL_ALLOW_CONSUMED_BUFFERS_NOTIFICATION
  149. //!
  150. //! When enabled the opposite side is notified each time received buffers
  151. //! are consumed and put into the queue of available buffers.
  152. //! Enable this option in RPMsg-Lite to Linux configuration to allow unblocking
  153. //! of the Linux blocking send.
  154. //! The default value is 0 (RPMsg-Lite to RPMsg-Lite communication).
  155. #ifndef RL_ALLOW_CONSUMED_BUFFERS_NOTIFICATION
  156. #define RL_ALLOW_CONSUMED_BUFFERS_NOTIFICATION (0)
  157. #endif
  158. //! @def RL_HANG
  159. //!
  160. //! Default implementation of hang assert function
  161. static inline void RL_HANG(void)
  162. {
  163. /* coco begin validated: RL_HANG not reachable in unit tests when own RL_ASSERT implementation used */
  164. for (;;)
  165. {
  166. }
  167. }
  168. /* coco end */
  169. //! @def RL_ASSERT
  170. //!
  171. //! Assert implementation.
  172. #ifndef RL_ASSERT
  173. #define RL_ASSERT_BOOL(b) \
  174. do \
  175. { \
  176. if (!(b)) \
  177. { \
  178. RL_HANG(); \
  179. } \
  180. } while (0 == 1);
  181. #define RL_ASSERT(x) RL_ASSERT_BOOL((int32_t)(x) != 0)
  182. #endif
  183. //@}
  184. #endif /* RPMSG_DEFAULT_CONFIG_H_ */