]> begriffs open source - freertos/blob - portable/GCC/ARM_CR5/portmacro.h
Update version number to 10.4.0 (#153)
[freertos] / portable / GCC / ARM_CR5 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.4.0\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * https://www.FreeRTOS.org\r
23  * https://github.com/FreeRTOS\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 #ifndef PORTMACRO_H\r
29     #define PORTMACRO_H\r
30 \r
31     #ifdef __cplusplus\r
32         extern "C" {\r
33     #endif\r
34 \r
35 /*-----------------------------------------------------------\r
36  * Port specific definitions.\r
37  *\r
38  * The settings in this file configure FreeRTOS correctly for the given hardware\r
39  * and compiler.\r
40  *\r
41  * These settings should not be altered.\r
42  *-----------------------------------------------------------\r
43  */\r
44 \r
45 /* Type definitions. */\r
46     #define portCHAR          char\r
47     #define portFLOAT         float\r
48     #define portDOUBLE        double\r
49     #define portLONG          long\r
50     #define portSHORT         short\r
51     #define portSTACK_TYPE    uint32_t\r
52     #define portBASE_TYPE     long\r
53 \r
54     typedef portSTACK_TYPE   StackType_t;\r
55     typedef long             BaseType_t;\r
56     typedef unsigned long    UBaseType_t;\r
57 \r
58     typedef uint32_t         TickType_t;\r
59     #define portMAX_DELAY    ( TickType_t ) 0xffffffffUL\r
60 \r
61 /*-----------------------------------------------------------*/\r
62 \r
63 /* Hardware specifics. */\r
64     #define portSTACK_GROWTH      ( -1 )\r
65     #define portTICK_PERIOD_MS    ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
66     #define portBYTE_ALIGNMENT    8\r
67 \r
68 /*-----------------------------------------------------------*/\r
69 \r
70 /* Task utilities. */\r
71 \r
72 /* Called at the end of an ISR that can cause a context switch. */\r
73     #define portEND_SWITCHING_ISR( xSwitchRequired ) \\r
74     {                                                \\r
75         extern uint32_t ulPortYieldRequired;         \\r
76                                                      \\r
77         if( xSwitchRequired != pdFALSE )             \\r
78         {                                            \\r
79             ulPortYieldRequired = pdTRUE;            \\r
80         }                                            \\r
81     }\r
82 \r
83     #define portYIELD_FROM_ISR( x )    portEND_SWITCHING_ISR( x )\r
84     #define portYIELD()                __asm volatile ( "SWI 0" ::: "memory" );\r
85 \r
86 \r
87 /*-----------------------------------------------------------\r
88 * Critical section control\r
89 *----------------------------------------------------------*/\r
90 \r
91     extern void vPortEnterCritical( void );\r
92     extern void vPortExitCritical( void );\r
93     extern uint32_t ulPortSetInterruptMask( void );\r
94     extern void vPortClearInterruptMask( uint32_t ulNewMaskValue );\r
95     extern void vPortInstallFreeRTOSVectorTable( void );\r
96 \r
97 /* These macros do not globally disable/enable interrupts.  They do mask off\r
98  * interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */\r
99     #define portENTER_CRITICAL()                      vPortEnterCritical();\r
100     #define portEXIT_CRITICAL()                       vPortExitCritical();\r
101     #define portDISABLE_INTERRUPTS()                  ulPortSetInterruptMask()\r
102     #define portENABLE_INTERRUPTS()                   vPortClearInterruptMask( 0 )\r
103     #define portSET_INTERRUPT_MASK_FROM_ISR()         ulPortSetInterruptMask()\r
104     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x )    vPortClearInterruptMask( x )\r
105 \r
106 /*-----------------------------------------------------------*/\r
107 \r
108 /* Task function macros as described on the FreeRTOS.org WEB site.  These are\r
109  * not required for this port but included in case common demo code that uses these\r
110  * macros is used. */\r
111     #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )\r
112     #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )\r
113 \r
114 /* Prototype of the FreeRTOS tick handler.  This must be installed as the\r
115  * handler for whichever peripheral is used to generate the RTOS tick. */\r
116     void FreeRTOS_Tick_Handler( void );\r
117 \r
118 /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()\r
119  * before any floating point instructions are executed. */\r
120     void vPortTaskUsesFPU( void );\r
121     #define portTASK_USES_FLOATING_POINT()    vPortTaskUsesFPU()\r
122 \r
123     #define portLOWEST_INTERRUPT_PRIORITY           ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )\r
124     #define portLOWEST_USABLE_INTERRUPT_PRIORITY    ( portLOWEST_INTERRUPT_PRIORITY - 1UL )\r
125 \r
126 /* Architecture specific optimisations. */\r
127     #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
128         #define configUSE_PORT_OPTIMISED_TASK_SELECTION    1\r
129     #endif\r
130 \r
131     #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
132 \r
133 /* Store/clear the ready priorities in a bit map. */\r
134         #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities )    ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )\r
135         #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities )     ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )\r
136 \r
137 /*-----------------------------------------------------------*/\r
138 \r
139         #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    uxTopPriority = ( 31 - __builtin_clz( uxReadyPriorities ) )\r
140 \r
141     #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
142 \r
143     #ifdef configASSERT\r
144         void vPortValidateInterruptPriority( void );\r
145         #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()    vPortValidateInterruptPriority()\r
146     #endif /* configASSERT */\r
147 \r
148     #define portNOP()                                         __asm volatile ( "NOP" )\r
149 \r
150 \r
151     #ifdef __cplusplus\r
152         } /* extern C */\r
153     #endif\r
154 \r
155 \r
156 /* The number of bits to shift for an interrupt priority is dependent on the\r
157  * number of bits implemented by the interrupt controller. */\r
158     #if configUNIQUE_INTERRUPT_PRIORITIES == 16\r
159         #define portPRIORITY_SHIFT            4\r
160         #define portMAX_BINARY_POINT_VALUE    3\r
161     #elif configUNIQUE_INTERRUPT_PRIORITIES == 32\r
162         #define portPRIORITY_SHIFT            3\r
163         #define portMAX_BINARY_POINT_VALUE    2\r
164     #elif configUNIQUE_INTERRUPT_PRIORITIES == 64\r
165         #define portPRIORITY_SHIFT            2\r
166         #define portMAX_BINARY_POINT_VALUE    1\r
167     #elif configUNIQUE_INTERRUPT_PRIORITIES == 128\r
168         #define portPRIORITY_SHIFT            1\r
169         #define portMAX_BINARY_POINT_VALUE    0\r
170     #elif configUNIQUE_INTERRUPT_PRIORITIES == 256\r
171         #define portPRIORITY_SHIFT            0\r
172         #define portMAX_BINARY_POINT_VALUE    0\r
173     #else /* if configUNIQUE_INTERRUPT_PRIORITIES == 16 */\r
174         #error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting.  configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware\r
175     #endif /* if configUNIQUE_INTERRUPT_PRIORITIES == 16 */\r
176 \r
177 /* Interrupt controller access addresses. */\r
178     #define portICCPMR_PRIORITY_MASK_OFFSET                      ( 0x04 )\r
179     #define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET              ( 0x0C )\r
180     #define portICCEOIR_END_OF_INTERRUPT_OFFSET                  ( 0x10 )\r
181     #define portICCBPR_BINARY_POINT_OFFSET                       ( 0x08 )\r
182     #define portICCRPR_RUNNING_PRIORITY_OFFSET                   ( 0x14 )\r
183 \r
184     #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS       ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET )\r
185     #define portICCPMR_PRIORITY_MASK_REGISTER                    ( *( ( volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) ) )\r
186     #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS    ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET )\r
187     #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS        ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET )\r
188     #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS            ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET )\r
189     #define portICCBPR_BINARY_POINT_REGISTER                     ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) )\r
190     #define portICCRPR_RUNNING_PRIORITY_REGISTER                 ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) )\r
191 \r
192     #define portMEMORY_BARRIER()    __asm volatile ( "" ::: "memory" )\r
193 \r
194 #endif /* PORTMACRO_H */\r