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