2 * FreeRTOS Kernel V10.6.2
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
32 /* System include files */
41 /*-----------------------------------------------------------
42 * Port specific definitions.
44 * The settings in this file configure FreeRTOS correctly for the
45 * given hardware and compiler.
47 * These settings should not be altered.
48 *-----------------------------------------------------------
51 /* Type definitions. */
53 #define portFLOAT float
54 #define portDOUBLE double
56 #define portSHORT short
57 #define portSTACK_TYPE uint32_t
58 #define portBASE_TYPE long
60 typedef portSTACK_TYPE StackType_t;
61 typedef long BaseType_t;
62 typedef unsigned long UBaseType_t;
64 #if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
65 typedef uint16_t TickType_t;
66 #define portMAX_DELAY ( TickType_t ) 0xffff
67 #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
68 typedef uint32_t TickType_t;
69 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
71 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
72 not need to be guarded with a critical section. */
73 #define portTICK_TYPE_IS_ATOMIC 1
75 #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
77 /*-----------------------------------------------------------*/
79 /* Hardware specifics. */
80 #define portBYTE_ALIGNMENT 8
81 #define portSTACK_GROWTH -1
82 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
83 /*-----------------------------------------------------------*/
85 /* Critical section management. */
86 #define portIPL_SHIFT ( 10UL )
87 /* Don't straddle the CEE bit. Interrupts calling FreeRTOS functions should
88 never have higher IPL bits set anyway. */
89 #define portALL_IPL_BITS ( 0x7FUL << portIPL_SHIFT )
90 #define portSW0_BIT ( 0x01 << 8 )
92 /* This clears the IPL bits, then sets them to
93 configMAX_SYSCALL_INTERRUPT_PRIORITY. An extra check is performed if
94 configASSERT() is defined to ensure an assertion handler does not inadvertently
95 attempt to lower the IPL when the call to assert was triggered because the IPL
96 value was found to be above configMAX_SYSCALL_INTERRUPT_PRIORITY when an ISR
97 safe FreeRTOS API function was executed. ISR safe FreeRTOS API functions are
98 those that end in FromISR. FreeRTOS maintains a separate interrupt API to
99 ensure API function and interrupt entry is as fast and as simple as possible. */
101 #define portDISABLE_INTERRUPTS() \
105 /* Mask interrupts at and below the kernel interrupt priority. */ \
106 ulStatus = _CP0_GET_STATUS(); \
108 /* Is the current IPL below configMAX_SYSCALL_INTERRUPT_PRIORITY? */ \
109 if( ( ( ulStatus & portALL_IPL_BITS ) >> portIPL_SHIFT ) < configMAX_SYSCALL_INTERRUPT_PRIORITY ) \
111 ulStatus &= ~portALL_IPL_BITS; \
112 _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \
115 #else /* configASSERT */
116 #define portDISABLE_INTERRUPTS() \
120 /* Mask interrupts at and below the kernel interrupt priority. */ \
121 ulStatus = _CP0_GET_STATUS(); \
122 ulStatus &= ~portALL_IPL_BITS; \
123 _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \
125 #endif /* configASSERT */
127 #define portENABLE_INTERRUPTS() \
131 /* Unmask all interrupts. */ \
132 ulStatus = _CP0_GET_STATUS(); \
133 ulStatus &= ~portALL_IPL_BITS; \
134 _CP0_SET_STATUS( ulStatus ); \
138 extern void vTaskEnterCritical( void );
139 extern void vTaskExitCritical( void );
140 #define portCRITICAL_NESTING_IN_TCB 1
141 #define portENTER_CRITICAL() vTaskEnterCritical()
142 #define portEXIT_CRITICAL() vTaskExitCritical()
144 extern UBaseType_t uxPortSetInterruptMaskFromISR();
145 extern void vPortClearInterruptMaskFromISR( UBaseType_t );
146 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
147 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) vPortClearInterruptMaskFromISR( uxSavedStatusRegister )
149 #if ( __mips_hard_float == 0 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
150 #error configUSE_TASK_FPU_SUPPORT can only be set to 1 when the part supports a hardware FPU module.
153 #if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
154 void vPortTaskUsesFPU( void );
155 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
158 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
159 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
162 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
164 /* Check the configuration. */
165 #if( configMAX_PRIORITIES > 32 )
166 #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
169 /* Store/clear the ready priorities in a bit map. */
170 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
171 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
173 /*-----------------------------------------------------------*/
175 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - _clz( ( uxReadyPriorities ) ) )
177 #endif /* taskRECORD_READY_PRIORITY */
179 /*-----------------------------------------------------------*/
181 /* Task utilities. */
183 #define portYIELD() \
187 /* Trigger software interrupt. */ \
188 ulCause = _CP0_GET_CAUSE(); \
189 ulCause |= portSW0_BIT; \
190 _CP0_SET_CAUSE( ulCause ); \
193 extern volatile UBaseType_t uxInterruptNesting;
194 #define portASSERT_IF_IN_ISR() configASSERT( uxInterruptNesting == 0 )
196 #define portNOP() __asm volatile ( "nop" )
198 /*-----------------------------------------------------------*/
200 /* Task function macros as described on the FreeRTOS.org WEB site. */
201 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__((noreturn))
202 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
203 /*-----------------------------------------------------------*/
205 #define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) { portYIELD(); } } while( 0 )
207 /* Required by the kernel aware debugger. */
209 #define portREMOVE_STATIC_QUALIFIER
218 #endif /* PORTMACRO_H */