2 * FreeRTOS Kernel V10.3.1
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 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
31 /* System include files */
38 /*-----------------------------------------------------------
39 * Port specific definitions.
41 * The settings in this file configure FreeRTOS correctly for the
42 * given hardware and compiler.
44 * These settings should not be altered.
45 *-----------------------------------------------------------
48 /* Type definitions. */
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 #if( configUSE_16_BIT_TICKS == 1 )
62 typedef uint16_t TickType_t;
63 #define portMAX_DELAY ( TickType_t ) 0xffff
65 typedef uint32_t TickType_t;
66 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
68 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
69 not need to be guarded with a critical section. */
70 #define portTICK_TYPE_IS_ATOMIC 1
72 /*-----------------------------------------------------------*/
74 /* Hardware specifics. */
75 #define portBYTE_ALIGNMENT 8
76 #define portSTACK_GROWTH -1
77 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
78 /*-----------------------------------------------------------*/
80 /* Critical section management. */
81 #define portIPL_SHIFT ( 10UL )
82 /* Don't straddle the CEE bit. Interrupts calling FreeRTOS functions should
83 never have higher IPL bits set anyway. */
84 #define portALL_IPL_BITS ( 0x7FUL << portIPL_SHIFT )
85 #define portSW0_BIT ( 0x01 << 8 )
87 /* This clears the IPL bits, then sets them to
88 configMAX_SYSCALL_INTERRUPT_PRIORITY. An extra check is performed if
89 configASSERT() is defined to ensure an assertion handler does not inadvertently
90 attempt to lower the IPL when the call to assert was triggered because the IPL
91 value was found to be above configMAX_SYSCALL_INTERRUPT_PRIORITY when an ISR
92 safe FreeRTOS API function was executed. ISR safe FreeRTOS API functions are
93 those that end in FromISR. FreeRTOS maintains a separate interrupt API to
94 ensure API function and interrupt entry is as fast and as simple as possible. */
96 #define portDISABLE_INTERRUPTS() \
100 /* Mask interrupts at and below the kernel interrupt priority. */ \
101 ulStatus = _CP0_GET_STATUS(); \
103 /* Is the current IPL below configMAX_SYSCALL_INTERRUPT_PRIORITY? */ \
104 if( ( ( ulStatus & portALL_IPL_BITS ) >> portIPL_SHIFT ) < configMAX_SYSCALL_INTERRUPT_PRIORITY ) \
106 ulStatus &= ~portALL_IPL_BITS; \
107 _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \
110 #else /* configASSERT */
111 #define portDISABLE_INTERRUPTS() \
115 /* Mask interrupts at and below the kernel interrupt priority. */ \
116 ulStatus = _CP0_GET_STATUS(); \
117 ulStatus &= ~portALL_IPL_BITS; \
118 _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \
120 #endif /* configASSERT */
122 #define portENABLE_INTERRUPTS() \
126 /* Unmask all interrupts. */ \
127 ulStatus = _CP0_GET_STATUS(); \
128 ulStatus &= ~portALL_IPL_BITS; \
129 _CP0_SET_STATUS( ulStatus ); \
133 extern void vTaskEnterCritical( void );
134 extern void vTaskExitCritical( void );
135 #define portCRITICAL_NESTING_IN_TCB 1
136 #define portENTER_CRITICAL() vTaskEnterCritical()
137 #define portEXIT_CRITICAL() vTaskExitCritical()
139 extern UBaseType_t uxPortSetInterruptMaskFromISR();
140 extern void vPortClearInterruptMaskFromISR( UBaseType_t );
141 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
142 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) vPortClearInterruptMaskFromISR( uxSavedStatusRegister )
144 #if ( __mips_hard_float == 0 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
145 #error configUSE_TASK_FPU_SUPPORT can only be set to 1 when the part supports a hardware FPU module.
148 #if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
149 void vPortTaskUsesFPU( void );
150 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
153 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
154 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
157 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
159 /* Check the configuration. */
160 #if( configMAX_PRIORITIES > 32 )
161 #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.
164 /* Store/clear the ready priorities in a bit map. */
165 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
166 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
168 /*-----------------------------------------------------------*/
170 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - _clz( ( uxReadyPriorities ) ) )
172 #endif /* taskRECORD_READY_PRIORITY */
174 /*-----------------------------------------------------------*/
176 /* Task utilities. */
178 #define portYIELD() \
182 /* Trigger software interrupt. */ \
183 ulCause = _CP0_GET_CAUSE(); \
184 ulCause |= portSW0_BIT; \
185 _CP0_SET_CAUSE( ulCause ); \
188 extern volatile UBaseType_t uxInterruptNesting;
189 #define portASSERT_IF_IN_ISR() configASSERT( uxInterruptNesting == 0 )
191 #define portNOP() __asm volatile ( "nop" )
193 /*-----------------------------------------------------------*/
195 /* Task function macros as described on the FreeRTOS.org WEB site. */
196 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__((noreturn))
197 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
198 /*-----------------------------------------------------------*/
200 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) \
205 /* Required by the kernel aware debugger. */
207 #define portREMOVE_STATIC_QUALIFIER
214 #endif /* PORTMACRO_H */