1 /* Copyright (c) 2020, XMOS Ltd, All rights reserved */
2 
3 #ifndef RTOS_SUPPORT_RTOS_CONFIG_H_
4 #define RTOS_SUPPORT_RTOS_CONFIG_H_
5 
6 /**
7  * Lets the application know that the RTOS in use is FreeRTOS.
8  */
9 #define RTOS_FREERTOS                              1
10 
11 /**
12  * The number of words to extend the stack by when entering an ISR.
13  *
14  * When entering an ISR we need to grow the stack by one more word than
15  * we actually need to save the thread context. This is because there are
16  * some functions, written in assembly *cough* memcpy() *cough*, that think
17  * it is OK to store words at SP[0]. Therefore the ISR must leave SP[0] alone
18  * even though it is normally not necessary to do so.
19  */
20 #define RTOS_SUPPORT_INTERRUPT_STACK_GROWTH        ( 44 + 1 )
21 
22 /**
23  * The word offset into the stack where R1 is to be stored after it
24  * is extended when saving a thread's context.
25  */
26 #define RTOS_SUPPORT_INTERRUPT_R1_STACK_OFFSET     9
27 
28 /**
29  * The word offset into the stack where R11 is to be stored after it
30  * is extended when saving a thread's context.
31  */
32 #define RTOS_SUPPORT_INTERRUPT_R11_STACK_OFFSET    19
33 
34 /**
35  * The RTOS provided handler that should run when a
36  * core receives an intercore interrupt request.
37  */
38 #define RTOS_INTERCORE_INTERRUPT_ISR()       \
39     do {                                     \
40         void vIntercoreInterruptISR( void ); \
41         vIntercoreInterruptISR();            \
42     } while( 0 )
43 
44 /**
45  * The number of hardware locks that the RTOS
46  * requires. For a single core RTOS this could be
47  * zero. Locks are recursive.
48  *
49  * Note that the IRQ routines require a lock and
50  * will share the first one with the RTOS.
51  */
52 #define RTOS_LOCK_COUNT            2
53 
54 /**
55  * Remaps all calls to debug_printf() to rtos_printf().
56  * When this is on, files should not include both rtos_support.h
57  * and debug_print.h.
58  */
59 #define RTOS_DEBUG_PRINTF_REMAP    1
60 
61 
62 #ifdef configENABLE_DEBUG_PRINTF
63     #if configENABLE_DEBUG_PRINTF
64 
65 /* ensure that debug_printf is enabled */
66         #ifdef DEBUG_PRINT_ENABLE
67             #undef DEBUG_PRINT_ENABLE
68         #endif
69         #define DEBUG_PRINT_ENABLE                        1
70 
71         #ifndef configTASKS_DEBUG
72             #define configTASKS_DEBUG                     0
73         #endif
74         #if configTASKS_DEBUG == 1
75             #define DEBUG_PRINT_ENABLE_FREERTOS_TASKS     1
76         #else
77             #define DEBUG_PRINT_DISABLE_FREERTOS_TASKS    1
78         #endif
79 
80     #else /* configENABLE_DEBUG_PRINTF */
81 
82 /* ensure that debug_printf is disabled */
83         #ifdef DEBUG_UNIT
84             #undef DEBUG_UNIT
85         #endif
86         #ifdef DEBUG_PRINT_ENABLE
87             #undef DEBUG_PRINT_ENABLE
88         #endif
89 
90         #define DEBUG_PRINT_ENABLE    0
91 
92     #endif /* configENABLE_DEBUG_PRINTF */
93 #endif /* ifdef configENABLE_DEBUG_PRINTF */
94 
95 #endif /* RTOS_SUPPORT_RTOS_CONFIG_H_ */
96