2 * FreeRTOS SMP Kernel V202110.00
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * https://www.FreeRTOS.org
23 * https://github.com/FreeRTOS
35 /*-----------------------------------------------------------
36 * Port specific definitions.
38 * The settings in this file configure FreeRTOS correctly for the given hardware
41 * These settings should not be altered.
42 *-----------------------------------------------------------
45 /* Type definitions. */
47 #define portFLOAT float
48 #define portDOUBLE double
50 #define portSHORT short
51 #define portSTACK_TYPE size_t
52 #define portBASE_TYPE long
54 typedef portSTACK_TYPE StackType_t;
55 typedef portBASE_TYPE BaseType_t;
56 typedef uint64_t UBaseType_t;
58 typedef uint64_t TickType_t;
59 #define portMAX_DELAY ( ( TickType_t ) 0xffffffffffffffff )
61 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
62 not need to be guarded with a critical section. */
63 #define portTICK_TYPE_IS_ATOMIC 1
65 /*-----------------------------------------------------------*/
67 /* Hardware specifics. */
68 #define portSTACK_GROWTH ( -1 )
69 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
70 #define portBYTE_ALIGNMENT 16
71 #define portPOINTER_SIZE_TYPE uint64_t
73 /*-----------------------------------------------------------*/
77 /* Called at the end of an ISR that can cause a context switch. */
78 #define portEND_SWITCHING_ISR( xSwitchRequired )\
80 extern uint64_t ullPortYieldRequired; \
82 if( xSwitchRequired != pdFALSE ) \
84 ullPortYieldRequired = pdTRUE; \
88 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
90 #define portYIELD() __asm volatile ( "SVC 0" ::: "memory" )
92 #define portYIELD() __asm volatile ( "SMC 0" ::: "memory" )
94 /*-----------------------------------------------------------
95 * Critical section control
96 *----------------------------------------------------------*/
98 extern void vPortEnterCritical( void );
99 extern void vPortExitCritical( void );
100 extern UBaseType_t uxPortSetInterruptMask( void );
101 extern void vPortClearInterruptMask( UBaseType_t uxNewMaskValue );
102 extern void vPortInstallFreeRTOSVectorTable( void );
104 #define portDISABLE_INTERRUPTS() \
105 __asm volatile ( "MSR DAIFSET, #2" ::: "memory" ); \
106 __asm volatile ( "DSB SY" ); \
107 __asm volatile ( "ISB SY" );
109 #define portENABLE_INTERRUPTS() \
110 __asm volatile ( "MSR DAIFCLR, #2" ::: "memory" ); \
111 __asm volatile ( "DSB SY" ); \
112 __asm volatile ( "ISB SY" );
115 /* These macros do not globally disable/enable interrupts. They do mask off
116 interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */
117 #define portENTER_CRITICAL() vPortEnterCritical();
118 #define portEXIT_CRITICAL() vPortExitCritical();
119 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMask()
120 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
122 /*-----------------------------------------------------------*/
124 /* Task function macros as described on the FreeRTOS.org WEB site. These are
125 not required for this port but included in case common demo code that uses these
127 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
128 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
130 /* Prototype of the FreeRTOS tick handler. This must be installed as the
131 handler for whichever peripheral is used to generate the RTOS tick. */
132 void FreeRTOS_Tick_Handler( void );
134 /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()
135 before any floating point instructions are executed. */
136 void vPortTaskUsesFPU( void );
137 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
139 #define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )
140 #define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL )
142 /* Architecture specific optimisations. */
143 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
144 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
147 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
149 /* Store/clear the ready priorities in a bit map. */
150 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
151 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
153 /*-----------------------------------------------------------*/
155 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __builtin_clz( uxReadyPriorities ) )
157 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
160 void vPortValidateInterruptPriority( void );
161 #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
162 #endif /* configASSERT */
164 #define portNOP() __asm volatile( "NOP" )
165 #define portINLINE __inline
172 /* The number of bits to shift for an interrupt priority is dependent on the
173 number of bits implemented by the interrupt controller. */
174 #if configUNIQUE_INTERRUPT_PRIORITIES == 16
175 #define portPRIORITY_SHIFT 4
176 #define portMAX_BINARY_POINT_VALUE 3
177 #elif configUNIQUE_INTERRUPT_PRIORITIES == 32
178 #define portPRIORITY_SHIFT 3
179 #define portMAX_BINARY_POINT_VALUE 2
180 #elif configUNIQUE_INTERRUPT_PRIORITIES == 64
181 #define portPRIORITY_SHIFT 2
182 #define portMAX_BINARY_POINT_VALUE 1
183 #elif configUNIQUE_INTERRUPT_PRIORITIES == 128
184 #define portPRIORITY_SHIFT 1
185 #define portMAX_BINARY_POINT_VALUE 0
186 #elif configUNIQUE_INTERRUPT_PRIORITIES == 256
187 #define portPRIORITY_SHIFT 0
188 #define portMAX_BINARY_POINT_VALUE 0
190 #error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware
193 /* Interrupt controller access addresses. */
194 #define portICCPMR_PRIORITY_MASK_OFFSET ( 0x04 )
195 #define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET ( 0x0C )
196 #define portICCEOIR_END_OF_INTERRUPT_OFFSET ( 0x10 )
197 #define portICCBPR_BINARY_POINT_OFFSET ( 0x08 )
198 #define portICCRPR_RUNNING_PRIORITY_OFFSET ( 0x14 )
200 #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET )
201 #define portICCPMR_PRIORITY_MASK_REGISTER ( *( ( volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) ) )
202 #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET )
203 #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET )
204 #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET )
205 #define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) )
206 #define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) )
208 #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
210 #endif /* PORTMACRO_H */