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