2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
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:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
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.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
37 /*-----------------------------------------------------------
38 * Port specific definitions.
40 * The settings in this file configure FreeRTOS correctly for the
41 * given hardware and compiler.
43 * These settings should not be altered.
44 *-----------------------------------------------------------
47 /* Type definitions - These are a bit legacy and not really used now, other
48 * than portSTACK_TYPE and portBASE_TYPE. */
50 #define portFLOAT float
51 #define portDOUBLE double
53 #define portSHORT short
54 #define portSTACK_TYPE uint32_t
55 #define portBASE_TYPE long
57 typedef portSTACK_TYPE StackType_t;
58 typedef long BaseType_t;
59 typedef unsigned long UBaseType_t;
61 /* Defines the maximum time when using a wait command in a task */
62 #if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
63 typedef uint16_t TickType_t;
64 #define portMAX_DELAY ( TickType_t ) 0xffff
65 #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
66 typedef uint32_t TickType_t;
67 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
69 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
70 * not need to be guarded with a critical section. */
71 #define portTICK_TYPE_IS_ATOMIC 1
73 #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
76 /*-----------------------------------------------------------*/
78 /* Architecture specifics */
80 #define portSTSR( reg ) __stsr( ( reg ) )
81 #define portLDSR( reg, val ) __ldsr( ( reg ), ( val ) )
82 #define portSTSR_CCRH( reg, sel ) __stsr_rh( ( reg ), ( sel ) )
83 #define portSYNCM() __syncm()
85 /* Determine the descending of the stack from high address to address */
86 #define portSTACK_GROWTH ( -1 )
88 /* Determine the time (in milliseconds) corresponding to each tick */
89 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
91 /* It is a multiple of 4 (the two lower-order bits of the address = 0),
92 * otherwise it will cause MAE (Misaligned Exception) according to the manual */
93 #define portBYTE_ALIGNMENT ( 4 )
95 /* Interrupt control macros. */
97 #define portENABLE_INTERRUPTS() __EI() /* Macro to enable all maskable interrupts. */
98 #define portDISABLE_INTERRUPTS() __DI() /* Macro to disable all maskable interrupts. */
99 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
100 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
102 /* SMP build which means configNUM_CORES is relevant */
103 #define portSUPPORT_SMP 1
105 #define portMAX_CORE_COUNT 2
106 #ifndef configNUMBER_OF_CORES
107 #define configNUMBER_OF_CORES 1
110 /*-----------------------------------------------------------*/
111 /* Scheduler utilities */
113 /* Called at the end of an ISR that can cause a context switch */
114 extern void vPortSetSwitch( BaseType_t vPortSetSwitch );
116 #define portEND_SWITCHING_ISR( xSwitchRequired ) vPortSetSwitch( vPortSetSwitch )
118 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
120 /* Use to transfer control from one task to perform other tasks of
122 extern void vPortYield( void );
124 #define portYIELD() vPortYield()
125 #if ( configNUMBER_OF_CORES > 1 )
127 /* Return the core ID on which the code is running. */
128 extern BaseType_t xPortGET_CORE_ID();
130 #define portGET_CORE_ID() xPortGET_CORE_ID()
131 #define coreid xPortGET_CORE_ID()
133 /* Request the core ID x to yield. */
134 extern void vPortYieldCore( unsigned int coreID );
136 #define portYIELD_CORE( x ) vPortYieldCore( x )
138 #define portENTER_CRITICAL_FROM_ISR() vTaskEnterCriticalFromISR()
139 #define portEXIT_CRITICAL_FROM_ISR( x ) vTaskExitCriticalFromISR( x )
141 #endif /* if ( configNUMBER_OF_CORES > 1 ) */
143 #if ( configNUMBER_OF_CORES == 1 )
144 #define portGET_ISR_LOCK()
145 #define portRELEASE_ISR_LOCK()
146 #define portGET_TASK_LOCK()
147 #define portRELEASE_TASK_LOCK()
149 extern void vPortRecursiveLockAcquire( BaseType_t xFromIsr );
150 extern void vPortRecursiveLockRelease( BaseType_t xFromIsr );
152 #define portGET_ISR_LOCK() vPortRecursiveLockAcquire( pdTRUE )
153 #define portRELEASE_ISR_LOCK() vPortRecursiveLockRelease( pdTRUE )
154 #define portGET_TASK_LOCK() vPortRecursiveLockAcquire( pdFALSE )
155 #define portRELEASE_TASK_LOCK() vPortRecursiveLockRelease( pdFALSE )
156 #endif /* if ( configNUMBER_OF_CORES == 1 ) */
158 /*-----------------------------------------------------------*/
159 /* Critical section management. */
161 /* The critical nesting functions defined within tasks.c */
163 extern void vTaskEnterCritical( void );
164 extern void vTaskExitCritical( void );
166 /* Macro to mark the start of a critical code region */
167 #define portENTER_CRITICAL() vTaskEnterCritical()
169 /* Macro to mark the end of a critical code region */
170 #define portEXIT_CRITICAL() vTaskExitCritical()
172 /*-----------------------------------------------------------*/
173 /* Macros to set and clear the interrupt mask. */
174 portLONG xPortSetInterruptMask();
175 void vPortClearInterruptMask( portLONG );
177 #define portSET_INTERRUPT_MASK() xPortSetInterruptMask()
178 #define portCLEAR_INTERRUPT_MASK( x ) vPortClearInterruptMask( ( x ) )
179 #define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
180 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( ( x ) )
182 /*-----------------------------------------------------------*/
183 /* Task function macros as described on the FreeRTOS.org WEB site. */
185 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
186 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
188 /*-----------------------------------------------------------*/
193 #endif /* PORTMACRO_H */