xos_params.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /** @file */
  2. // xos_params.h - user-settable compile time parameters for XOS.
  3. // Copyright (c) 2003-2015 Cadence Design Systems, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining
  6. // a copy of this software and associated documentation files (the
  7. // "Software"), to deal in the Software without restriction, including
  8. // without limitation the rights to use, copy, modify, merge, publish,
  9. // distribute, sublicense, and/or sell copies of the Software, and to
  10. // permit persons to whom the Software is furnished to do so, subject to
  11. // the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included
  14. // in all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  19. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  20. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. #ifndef __XOS_PARAMS_H__
  24. #define __XOS_PARAMS_H__
  25. #include <xtensa/config/core.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. //-----------------------------------------------------------------------------
  30. ///
  31. /// Number of thread priority levels. At this time XOS supports a maximum of
  32. /// 32 priority levels (0 - 31).
  33. ///
  34. //-----------------------------------------------------------------------------
  35. #ifndef XOS_NUM_PRIORITY
  36. #define XOS_NUM_PRIORITY 16 // Default is 16
  37. #endif
  38. //-----------------------------------------------------------------------------
  39. ///
  40. /// Debug flags - Set to 1 to enable debug mode (and more verbose operation).
  41. /// Can be set individually, or define XOS_DEBUG_ALL to enable all of them.
  42. ///
  43. /// - XOS_DEBUG -- Generic OS debug
  44. /// - XOS_COND_DEBUG -- Condition objects debug
  45. /// - XOS_EVENT_DEBUG -- Event objects debug
  46. /// - XOS_MSGQ_DEBUG -- Message queue debug
  47. /// - XOS_MUTEX_DEBUG -- Mutex objects debug
  48. /// - XOS_SEM_DEBUG -- Semaphore objects debug
  49. /// - XOS_THREAD_DEBUG -- Thread module debug
  50. /// - XOS_TIMER_DEBUG -- Timer module debug
  51. ///
  52. /// WARNING: Enabling one or more of these flags will affect system performance
  53. /// and timing.
  54. ///
  55. /// NOTE: Not all of these have been fully implemented.
  56. ///
  57. //-----------------------------------------------------------------------------
  58. #if defined XOS_DEBUG_ALL
  59. #define XOS_DEBUG 1
  60. #define XOS_THREAD_DEBUG 1
  61. #define XOS_TIMER_DEBUG 1
  62. #define XOS_COND_DEBUG 1
  63. #define XOS_MUTEX_DEBUG 1
  64. #define XOS_SEM_DEBUG 1
  65. #define XOS_EVENT_DEBUG 1
  66. #define XOS_MSGQ_DEBUG 1
  67. #else
  68. #ifndef XOS_DEBUG
  69. #define XOS_DEBUG 0
  70. #endif
  71. #ifndef XOS_THREAD_DEBUG
  72. #define XOS_THREAD_DEBUG 0
  73. #endif
  74. #ifndef XOS_TIMER_DEBUG
  75. #define XOS_TIMER_DEBUG 0
  76. #endif
  77. #ifndef XOS_COND_DEBUG
  78. #define XOS_COND_DEBUG 0
  79. #endif
  80. #ifndef XOS_MUTEX_DEBUG
  81. #define XOS_MUTEX_DEBUG 0
  82. #endif
  83. #ifndef XOS_SEM_DEBUG
  84. #define XOS_SEM_DEBUG 0
  85. #endif
  86. #ifndef XOS_EVENT_DEBUG
  87. #define XOS_EVENT_DEBUG 0
  88. #endif
  89. #ifndef XOS_MSGQ_DEBUG
  90. #define XOS_MSGQ_DEBUG 0
  91. #endif
  92. #endif
  93. //-----------------------------------------------------------------------------
  94. ///
  95. /// Set this option to 1 to enable runtime statistics collection for XOS.
  96. /// NOTE: Enabling this option does have some impact on runtime performance
  97. /// and OS footprint.
  98. ///
  99. //-----------------------------------------------------------------------------
  100. #ifndef XOS_OPT_STATS
  101. #define XOS_OPT_STATS 1
  102. #endif
  103. //-----------------------------------------------------------------------------
  104. ///
  105. /// Set this option to 1 to enable statistics tracking for message queues.
  106. /// enabling this will cause message queue objects to increase in size, and add
  107. /// some overhead to message queue processing.
  108. ///
  109. //-----------------------------------------------------------------------------
  110. #ifndef XOS_OPT_MSGQ_STATS
  111. #define XOS_OPT_MSGQ_STATS 0
  112. #endif
  113. //-----------------------------------------------------------------------------
  114. ///
  115. /// Size of interrupt stack in bytes. Shared by all interrupt handlers. Must be
  116. /// sized to handle worst case nested interrupts. This is also used by the idle
  117. /// thread so must exist even if interrupts are not configured.
  118. ///
  119. //-----------------------------------------------------------------------------
  120. #ifndef XOS_INT_STACK_SIZE
  121. #if XCHAL_HAVE_INTERRUPTS
  122. #define XOS_INT_STACK_SIZE 8192
  123. #else
  124. #define XOS_INT_STACK_SIZE 32
  125. #endif
  126. #endif
  127. //-----------------------------------------------------------------------------
  128. ///
  129. /// Default maximum interrupt level at which XOS primitives may be called.
  130. /// It is the level at which interrupts are disabled by default.
  131. /// See also description of xos_set_int_pri_level().
  132. ///
  133. //-----------------------------------------------------------------------------
  134. #ifndef XOS_MAX_OS_INTLEVEL
  135. #define XOS_MAX_OS_INTLEVEL XCHAL_EXCM_LEVEL
  136. #endif
  137. //-----------------------------------------------------------------------------
  138. ///
  139. /// Set this to 1 to enable stack checking. The stack is filled with a pattern
  140. /// on thread creation, and the stack is checked at certain times during system
  141. /// operation.
  142. /// WARNING: Enabling this option can have some impact on runtime performance.
  143. ///
  144. //-----------------------------------------------------------------------------
  145. #ifndef XOS_OPT_STACK_CHECK
  146. #if XOS_DEBUG
  147. #define XOS_OPT_STACK_CHECK 1
  148. #else
  149. #define XOS_OPT_STACK_CHECK 0
  150. #endif
  151. #endif
  152. //-----------------------------------------------------------------------------
  153. ///
  154. /// Set XOS_CLOCK_FREQ to the system clock frequency if this is known ahead of
  155. /// time. Otherwise, call xos_set_clock_freq() to set it at run time.
  156. ///
  157. //-----------------------------------------------------------------------------
  158. #ifndef XOS_CLOCK_FREQ
  159. #define XOS_CLOCK_FREQ 1000000
  160. #endif
  161. #define XOS_DEFAULT_CLOCK_FREQ XOS_CLOCK_FREQ
  162. //-----------------------------------------------------------------------------
  163. ///
  164. /// Set this option to 1 to enable software prioritization of interrupts. The
  165. /// priority scheme applied is that a higher interrupt number at the same level
  166. /// will have higher priority.
  167. ///
  168. //-----------------------------------------------------------------------------
  169. #ifndef XOS_OPT_INTERRUPT_SWPRI
  170. #define XOS_OPT_INTERRUPT_SWPRI 1
  171. #endif
  172. //-----------------------------------------------------------------------------
  173. ///
  174. /// Set this option to 1 to use the thread-safe version of the C runtime library.
  175. /// You may need to enable this if you call C library functions from multiple
  176. /// threads -- see the documentation for the relevant C library to determine if
  177. /// this is necessary. This option increases the size of the TCB.
  178. /// NOTE: At this time only the newlib and xclib libraries are supported for
  179. /// thread safety.
  180. ///
  181. //-----------------------------------------------------------------------------
  182. #include <xtensa/config/system.h>
  183. #ifndef XOS_OPT_THREAD_SAFE_CLIB
  184. #if XSHAL_CLIB == XTHAL_CLIB_XCLIB
  185. #define XOS_OPT_THREAD_SAFE_CLIB 1
  186. #elif XSHAL_CLIB == XTHAL_CLIB_NEWLIB
  187. #define XOS_OPT_THREAD_SAFE_CLIB 1
  188. #else
  189. #define XOS_OPT_THREAD_SAFE_CLIB 0
  190. #endif
  191. #endif
  192. //-----------------------------------------------------------------------------
  193. ///
  194. /// Set this option to 1 to enable the wait timeout feature. This allows waits
  195. /// on waitable objects to expire after a specified timeout.
  196. ///
  197. //-----------------------------------------------------------------------------
  198. #ifndef XOS_OPT_WAIT_TIMEOUT
  199. #define XOS_OPT_WAIT_TIMEOUT 1
  200. #endif
  201. //-----------------------------------------------------------------------------
  202. ///
  203. /// Set this option to 1 to enable threads waiting on timer objects. If this
  204. /// feature is not used, turning it off will make timer objects smaller, and
  205. /// reduce the time taken by timer expiry processing (by a small amount).
  206. ///
  207. //-----------------------------------------------------------------------------
  208. #ifndef XOS_OPT_TIMER_WAIT
  209. #define XOS_OPT_TIMER_WAIT 1
  210. #endif
  211. //-----------------------------------------------------------------------------
  212. ///
  213. /// Set this option to 1 to enable time-slicing between multiple threads at the
  214. /// same priority. If this option is enabled then on every timer tick the timer
  215. /// handler will switch out the current thread if there is another ready thread
  216. /// at the same priority, and allow the latter thread to run. Execution will be
  217. /// round robin switched among all the threads at the same priority.
  218. ///
  219. /// Currently the time slice interval is fixed to be one timer tick.
  220. ///
  221. /// This feature is most useful if fixed duration timer ticks are used.
  222. /// If dynamic ticking is enabled, then time slicing will work unpredictably
  223. /// because the interval between ticks will vary. In some cases it may be
  224. /// better to turn time slicing off.
  225. ///
  226. //-----------------------------------------------------------------------------
  227. #ifndef XOS_OPT_TIME_SLICE
  228. #define XOS_OPT_TIME_SLICE 1
  229. #endif
  230. #ifdef __cplusplus
  231. }
  232. #endif
  233. #endif // __XOS_PARAMS_H__