rpmsg_default_config.h 6.8 KB

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