1 /*
2  * Copyright (c) 2013-2021 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * -----------------------------------------------------------------------------
19  *
20  * $Revision:   V5.5.2
21  *
22  * Project:     CMSIS-RTOS RTX
23  * Title:       RTX Configuration definitions
24  *
25  * -----------------------------------------------------------------------------
26  */
27 
28 #ifndef RTX_CONFIG_H_
29 #define RTX_CONFIG_H_
30 
31 #ifdef   _RTE_
32 #include "RTE_Components.h"
33 #ifdef    RTE_RTX_CONFIG_H
34 #include  RTE_RTX_CONFIG_H
35 #endif
36 #endif
37 
38 //-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
39 
40 // <h>System Configuration
41 // =======================
42 
43 //   <o>Global Dynamic Memory size [bytes] <0-1073741824:8>
44 //   <i> Defines the combined global dynamic memory size.
45 //   <i> Default: 32768
46 #ifndef OS_DYNAMIC_MEM_SIZE
47 #define OS_DYNAMIC_MEM_SIZE         32768
48 #endif
49 
50 //   <o>Kernel Tick Frequency [Hz] <1-1000000>
51 //   <i> Defines base time unit for delays and timeouts.
52 //   <i> Default: 1000 (1ms tick)
53 #ifndef OS_TICK_FREQ
54 #define OS_TICK_FREQ                1000
55 #endif
56 
57 //   <e>Round-Robin Thread switching
58 //   <i> Enables Round-Robin Thread switching.
59 #ifndef OS_ROBIN_ENABLE
60 #define OS_ROBIN_ENABLE             1
61 #endif
62 
63 //     <o>Round-Robin Timeout <1-1000>
64 //     <i> Defines how many ticks a thread will execute before a thread switch.
65 //     <i> Default: 5
66 #ifndef OS_ROBIN_TIMEOUT
67 #define OS_ROBIN_TIMEOUT            5
68 #endif
69 
70 //   </e>
71 
72 //   <o>ISR FIFO Queue
73 //      <4=>  4 entries    <8=>   8 entries   <12=>  12 entries   <16=>  16 entries
74 //     <24=> 24 entries   <32=>  32 entries   <48=>  48 entries   <64=>  64 entries
75 //     <96=> 96 entries  <128=> 128 entries  <196=> 196 entries  <256=> 256 entries
76 //   <i> RTOS Functions called from ISR store requests to this buffer.
77 //   <i> Default: 16 entries
78 #ifndef OS_ISR_FIFO_QUEUE
79 #define OS_ISR_FIFO_QUEUE           16
80 #endif
81 
82 //   <q>Object Memory usage counters
83 //   <i> Enables object memory usage counters (requires RTX source variant).
84 #ifndef OS_OBJ_MEM_USAGE
85 #define OS_OBJ_MEM_USAGE            0
86 #endif
87 
88 // </h>
89 
90 // <h>Thread Configuration
91 // =======================
92 
93 //   <e>Object specific Memory allocation
94 //   <i> Enables object specific memory allocation.
95 #ifndef OS_THREAD_OBJ_MEM
96 #define OS_THREAD_OBJ_MEM           0
97 #endif
98 
99 //     <o>Number of user Threads <1-1000>
100 //     <i> Defines maximum number of user threads that can be active at the same time.
101 //     <i> Applies to user threads with system provided memory for control blocks.
102 #ifndef OS_THREAD_NUM
103 #define OS_THREAD_NUM               1
104 #endif
105 
106 //     <o>Number of user Threads with default Stack size <0-1000>
107 //     <i> Defines maximum number of user threads with default stack size.
108 //     <i> Applies to user threads with zero stack size specified.
109 #ifndef OS_THREAD_DEF_STACK_NUM
110 #define OS_THREAD_DEF_STACK_NUM     0
111 #endif
112 
113 //     <o>Total Stack size [bytes] for user Threads with user-provided Stack size <0-1073741824:8>
114 //     <i> Defines the combined stack size for user threads with user-provided stack size.
115 //     <i> Applies to user threads with user-provided stack size and system provided memory for stack.
116 //     <i> Default: 0
117 #ifndef OS_THREAD_USER_STACK_SIZE
118 #define OS_THREAD_USER_STACK_SIZE   0
119 #endif
120 
121 //   </e>
122 
123 //   <o>Default Thread Stack size [bytes] <96-1073741824:8>
124 //   <i> Defines stack size for threads with zero stack size specified.
125 //   <i> Default: 3072
126 #ifndef OS_STACK_SIZE
127 #define OS_STACK_SIZE               3072
128 #endif
129 
130 //   <o>Idle Thread Stack size [bytes] <72-1073741824:8>
131 //   <i> Defines stack size for Idle thread.
132 //   <i> Default: 512
133 #ifndef OS_IDLE_THREAD_STACK_SIZE
134 #define OS_IDLE_THREAD_STACK_SIZE   512
135 #endif
136 
137 //   <o>Idle Thread TrustZone Module Identifier
138 //   <i> Defines TrustZone Thread Context Management Identifier.
139 //   <i> Applies only to cores with TrustZone technology.
140 //   <i> Default: 0 (not used)
141 #ifndef OS_IDLE_THREAD_TZ_MOD_ID
142 #define OS_IDLE_THREAD_TZ_MOD_ID    0
143 #endif
144 
145 //   <q>Stack overrun checking
146 //   <i> Enables stack overrun check at thread switch (requires RTX source variant).
147 //   <i> Enabling this option increases slightly the execution time of a thread switch.
148 #ifndef OS_STACK_CHECK
149 #define OS_STACK_CHECK              0
150 #endif
151 
152 //   <q>Stack usage watermark
153 //   <i> Initializes thread stack with watermark pattern for analyzing stack usage.
154 //   <i> Enabling this option increases significantly the execution time of thread creation.
155 #ifndef OS_STACK_WATERMARK
156 #define OS_STACK_WATERMARK          0
157 #endif
158 
159 //   <o>Processor mode for Thread execution
160 //     <0=> Unprivileged mode
161 //     <1=> Privileged mode
162 //   <i> Default: Privileged mode
163 #ifndef OS_PRIVILEGE_MODE
164 #define OS_PRIVILEGE_MODE           1
165 #endif
166 
167 // </h>
168 
169 // <h>Timer Configuration
170 // ======================
171 
172 //   <e>Object specific Memory allocation
173 //   <i> Enables object specific memory allocation.
174 #ifndef OS_TIMER_OBJ_MEM
175 #define OS_TIMER_OBJ_MEM            0
176 #endif
177 
178 //     <o>Number of Timer objects <1-1000>
179 //     <i> Defines maximum number of objects that can be active at the same time.
180 //     <i> Applies to objects with system provided memory for control blocks.
181 #ifndef OS_TIMER_NUM
182 #define OS_TIMER_NUM                1
183 #endif
184 
185 //   </e>
186 
187 //   <o>Timer Thread Priority
188 //      <8=> Low
189 //     <16=> Below Normal  <24=> Normal  <32=> Above Normal
190 //     <40=> High
191 //     <48=> Realtime
192 //   <i> Defines priority for timer thread
193 //   <i> Default: High
194 #ifndef OS_TIMER_THREAD_PRIO
195 #define OS_TIMER_THREAD_PRIO        40
196 #endif
197 
198 //   <o>Timer Thread Stack size [bytes] <0-1073741824:8>
199 //   <i> Defines stack size for Timer thread.
200 //   <i> May be set to 0 when timers are not used.
201 //   <i> Default: 512
202 #ifndef OS_TIMER_THREAD_STACK_SIZE
203 #define OS_TIMER_THREAD_STACK_SIZE  512
204 #endif
205 
206 //   <o>Timer Thread TrustZone Module Identifier
207 //   <i> Defines TrustZone Thread Context Management Identifier.
208 //   <i> Applies only to cores with TrustZone technology.
209 //   <i> Default: 0 (not used)
210 #ifndef OS_TIMER_THREAD_TZ_MOD_ID
211 #define OS_TIMER_THREAD_TZ_MOD_ID   0
212 #endif
213 
214 //   <o>Timer Callback Queue entries <0-256>
215 //   <i> Number of concurrent active timer callback functions.
216 //   <i> May be set to 0 when timers are not used.
217 //   <i> Default: 4
218 #ifndef OS_TIMER_CB_QUEUE
219 #define OS_TIMER_CB_QUEUE           4
220 #endif
221 
222 // </h>
223 
224 // <h>Event Flags Configuration
225 // ============================
226 
227 //   <e>Object specific Memory allocation
228 //   <i> Enables object specific memory allocation.
229 #ifndef OS_EVFLAGS_OBJ_MEM
230 #define OS_EVFLAGS_OBJ_MEM          0
231 #endif
232 
233 //     <o>Number of Event Flags objects <1-1000>
234 //     <i> Defines maximum number of objects that can be active at the same time.
235 //     <i> Applies to objects with system provided memory for control blocks.
236 #ifndef OS_EVFLAGS_NUM
237 #define OS_EVFLAGS_NUM              1
238 #endif
239 
240 //   </e>
241 
242 // </h>
243 
244 // <h>Mutex Configuration
245 // ======================
246 
247 //   <e>Object specific Memory allocation
248 //   <i> Enables object specific memory allocation.
249 #ifndef OS_MUTEX_OBJ_MEM
250 #define OS_MUTEX_OBJ_MEM            0
251 #endif
252 
253 //     <o>Number of Mutex objects <1-1000>
254 //     <i> Defines maximum number of objects that can be active at the same time.
255 //     <i> Applies to objects with system provided memory for control blocks.
256 #ifndef OS_MUTEX_NUM
257 #define OS_MUTEX_NUM                1
258 #endif
259 
260 //   </e>
261 
262 // </h>
263 
264 // <h>Semaphore Configuration
265 // ==========================
266 
267 //   <e>Object specific Memory allocation
268 //   <i> Enables object specific memory allocation.
269 #ifndef OS_SEMAPHORE_OBJ_MEM
270 #define OS_SEMAPHORE_OBJ_MEM        0
271 #endif
272 
273 //     <o>Number of Semaphore objects <1-1000>
274 //     <i> Defines maximum number of objects that can be active at the same time.
275 //     <i> Applies to objects with system provided memory for control blocks.
276 #ifndef OS_SEMAPHORE_NUM
277 #define OS_SEMAPHORE_NUM            1
278 #endif
279 
280 //   </e>
281 
282 // </h>
283 
284 // <h>Memory Pool Configuration
285 // ============================
286 
287 //   <e>Object specific Memory allocation
288 //   <i> Enables object specific memory allocation.
289 #ifndef OS_MEMPOOL_OBJ_MEM
290 #define OS_MEMPOOL_OBJ_MEM          0
291 #endif
292 
293 //     <o>Number of Memory Pool objects <1-1000>
294 //     <i> Defines maximum number of objects that can be active at the same time.
295 //     <i> Applies to objects with system provided memory for control blocks.
296 #ifndef OS_MEMPOOL_NUM
297 #define OS_MEMPOOL_NUM              1
298 #endif
299 
300 //     <o>Data Storage Memory size [bytes] <0-1073741824:8>
301 //     <i> Defines the combined data storage memory size.
302 //     <i> Applies to objects with system provided memory for data storage.
303 //     <i> Default: 0
304 #ifndef OS_MEMPOOL_DATA_SIZE
305 #define OS_MEMPOOL_DATA_SIZE        0
306 #endif
307 
308 //   </e>
309 
310 // </h>
311 
312 // <h>Message Queue Configuration
313 // ==============================
314 
315 //   <e>Object specific Memory allocation
316 //   <i> Enables object specific memory allocation.
317 #ifndef OS_MSGQUEUE_OBJ_MEM
318 #define OS_MSGQUEUE_OBJ_MEM         0
319 #endif
320 
321 //     <o>Number of Message Queue objects <1-1000>
322 //     <i> Defines maximum number of objects that can be active at the same time.
323 //     <i> Applies to objects with system provided memory for control blocks.
324 #ifndef OS_MSGQUEUE_NUM
325 #define OS_MSGQUEUE_NUM             1
326 #endif
327 
328 //     <o>Data Storage Memory size [bytes] <0-1073741824:8>
329 //     <i> Defines the combined data storage memory size.
330 //     <i> Applies to objects with system provided memory for data storage.
331 //     <i> Default: 0
332 #ifndef OS_MSGQUEUE_DATA_SIZE
333 #define OS_MSGQUEUE_DATA_SIZE       0
334 #endif
335 
336 //   </e>
337 
338 // </h>
339 
340 // <h>Event Recorder Configuration
341 // ===============================
342 
343 //   <e>Global Initialization
344 //   <i> Initialize Event Recorder during 'osKernelInitialize'.
345 #ifndef OS_EVR_INIT
346 #define OS_EVR_INIT                 0
347 #endif
348 
349 //     <q>Start recording
350 //     <i> Start event recording after initialization.
351 #ifndef OS_EVR_START
352 #define OS_EVR_START                1
353 #endif
354 
355 //     <h>Global Event Filter Setup
356 //     <i> Initial recording level applied to all components.
357 //       <o.0>Error events
358 //       <o.1>API function call events
359 //       <o.2>Operation events
360 //       <o.3>Detailed operation events
361 //     </h>
362 #ifndef OS_EVR_LEVEL
363 #define OS_EVR_LEVEL                0x00U
364 #endif
365 
366 //     <h>RTOS Event Filter Setup
367 //     <i> Recording levels for RTX components.
368 //     <i> Only applicable if events for the respective component are generated.
369 
370 //       <e.7>Memory Management
371 //       <i> Recording level for Memory Management events.
372 //         <o.0>Error events
373 //         <o.1>API function call events
374 //         <o.2>Operation events
375 //         <o.3>Detailed operation events
376 //       </e>
377 #ifndef OS_EVR_MEMORY_LEVEL
378 #define OS_EVR_MEMORY_LEVEL         0x81U
379 #endif
380 
381 //       <e.7>Kernel
382 //       <i> Recording level for Kernel events.
383 //         <o.0>Error events
384 //         <o.1>API function call events
385 //         <o.2>Operation events
386 //         <o.3>Detailed operation events
387 //       </e>
388 #ifndef OS_EVR_KERNEL_LEVEL
389 #define OS_EVR_KERNEL_LEVEL         0x81U
390 #endif
391 
392 //       <e.7>Thread
393 //       <i> Recording level for Thread events.
394 //         <o.0>Error events
395 //         <o.1>API function call events
396 //         <o.2>Operation events
397 //         <o.3>Detailed operation events
398 //       </e>
399 #ifndef OS_EVR_THREAD_LEVEL
400 #define OS_EVR_THREAD_LEVEL         0x85U
401 #endif
402 
403 //       <e.7>Generic Wait
404 //       <i> Recording level for Generic Wait events.
405 //         <o.0>Error events
406 //         <o.1>API function call events
407 //         <o.2>Operation events
408 //         <o.3>Detailed operation events
409 //       </e>
410 #ifndef OS_EVR_WAIT_LEVEL
411 #define OS_EVR_WAIT_LEVEL           0x81U
412 #endif
413 
414 //       <e.7>Thread Flags
415 //       <i> Recording level for Thread Flags events.
416 //         <o.0>Error events
417 //         <o.1>API function call events
418 //         <o.2>Operation events
419 //         <o.3>Detailed operation events
420 //       </e>
421 #ifndef OS_EVR_THFLAGS_LEVEL
422 #define OS_EVR_THFLAGS_LEVEL        0x81U
423 #endif
424 
425 //       <e.7>Event Flags
426 //       <i> Recording level for Event Flags events.
427 //         <o.0>Error events
428 //         <o.1>API function call events
429 //         <o.2>Operation events
430 //         <o.3>Detailed operation events
431 //       </e>
432 #ifndef OS_EVR_EVFLAGS_LEVEL
433 #define OS_EVR_EVFLAGS_LEVEL        0x81U
434 #endif
435 
436 //       <e.7>Timer
437 //       <i> Recording level for Timer events.
438 //         <o.0>Error events
439 //         <o.1>API function call events
440 //         <o.2>Operation events
441 //         <o.3>Detailed operation events
442 //       </e>
443 #ifndef OS_EVR_TIMER_LEVEL
444 #define OS_EVR_TIMER_LEVEL          0x81U
445 #endif
446 
447 //       <e.7>Mutex
448 //       <i> Recording level for Mutex events.
449 //         <o.0>Error events
450 //         <o.1>API function call events
451 //         <o.2>Operation events
452 //         <o.3>Detailed operation events
453 //       </e>
454 #ifndef OS_EVR_MUTEX_LEVEL
455 #define OS_EVR_MUTEX_LEVEL          0x81U
456 #endif
457 
458 //       <e.7>Semaphore
459 //       <i> Recording level for Semaphore events.
460 //         <o.0>Error events
461 //         <o.1>API function call events
462 //         <o.2>Operation events
463 //         <o.3>Detailed operation events
464 //       </e>
465 #ifndef OS_EVR_SEMAPHORE_LEVEL
466 #define OS_EVR_SEMAPHORE_LEVEL      0x81U
467 #endif
468 
469 //       <e.7>Memory Pool
470 //       <i> Recording level for Memory Pool events.
471 //         <o.0>Error events
472 //         <o.1>API function call events
473 //         <o.2>Operation events
474 //         <o.3>Detailed operation events
475 //       </e>
476 #ifndef OS_EVR_MEMPOOL_LEVEL
477 #define OS_EVR_MEMPOOL_LEVEL        0x81U
478 #endif
479 
480 //       <e.7>Message Queue
481 //       <i> Recording level for Message Queue events.
482 //         <o.0>Error events
483 //         <o.1>API function call events
484 //         <o.2>Operation events
485 //         <o.3>Detailed operation events
486 //       </e>
487 #ifndef OS_EVR_MSGQUEUE_LEVEL
488 #define OS_EVR_MSGQUEUE_LEVEL       0x81U
489 #endif
490 
491 //     </h>
492 
493 //   </e>
494 
495 //   <h>RTOS Event Generation
496 //   <i> Enables event generation for RTX components (requires RTX source variant).
497 
498 //     <q>Memory Management
499 //     <i> Enables Memory Management event generation.
500 #ifndef OS_EVR_MEMORY
501 #define OS_EVR_MEMORY               1
502 #endif
503 
504 //     <q>Kernel
505 //     <i> Enables Kernel event generation.
506 #ifndef OS_EVR_KERNEL
507 #define OS_EVR_KERNEL               1
508 #endif
509 
510 //     <q>Thread
511 //     <i> Enables Thread event generation.
512 #ifndef OS_EVR_THREAD
513 #define OS_EVR_THREAD               1
514 #endif
515 
516 //     <q>Generic Wait
517 //     <i> Enables Generic Wait event generation.
518 #ifndef OS_EVR_WAIT
519 #define OS_EVR_WAIT                 1
520 #endif
521 
522 //     <q>Thread Flags
523 //     <i> Enables Thread Flags event generation.
524 #ifndef OS_EVR_THFLAGS
525 #define OS_EVR_THFLAGS              1
526 #endif
527 
528 //     <q>Event Flags
529 //     <i> Enables Event Flags event generation.
530 #ifndef OS_EVR_EVFLAGS
531 #define OS_EVR_EVFLAGS              1
532 #endif
533 
534 //     <q>Timer
535 //     <i> Enables Timer event generation.
536 #ifndef OS_EVR_TIMER
537 #define OS_EVR_TIMER                1
538 #endif
539 
540 //     <q>Mutex
541 //     <i> Enables Mutex event generation.
542 #ifndef OS_EVR_MUTEX
543 #define OS_EVR_MUTEX                1
544 #endif
545 
546 //     <q>Semaphore
547 //     <i> Enables Semaphore event generation.
548 #ifndef OS_EVR_SEMAPHORE
549 #define OS_EVR_SEMAPHORE            1
550 #endif
551 
552 //     <q>Memory Pool
553 //     <i> Enables Memory Pool event generation.
554 #ifndef OS_EVR_MEMPOOL
555 #define OS_EVR_MEMPOOL              1
556 #endif
557 
558 //     <q>Message Queue
559 //     <i> Enables Message Queue event generation.
560 #ifndef OS_EVR_MSGQUEUE
561 #define OS_EVR_MSGQUEUE             1
562 #endif
563 
564 //   </h>
565 
566 // </h>
567 
568 // Number of Threads which use standard C/C++ library libspace
569 // (when thread specific memory allocation is not used).
570 #if (OS_THREAD_OBJ_MEM == 0)
571 #ifndef OS_THREAD_LIBSPACE_NUM
572 #define OS_THREAD_LIBSPACE_NUM      4
573 #endif
574 #else
575 #define OS_THREAD_LIBSPACE_NUM      OS_THREAD_NUM
576 #endif
577 
578 //------------- <<< end of configuration section >>> ---------------------------
579 
580 #endif  // RTX_CONFIG_H_
581