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
35 /* System Includes. */
37 #include <machine/intrinsics.h>
39 /*-----------------------------------------------------------
40 * Port specific definitions.
42 * The settings in this file configure FreeRTOS correctly for the
43 * given hardware and compiler.
45 * These settings should not be altered.
46 *-----------------------------------------------------------
49 /* Type definitions. */
51 #define portFLOAT float
52 #define portDOUBLE double
54 #define portSHORT short
55 #define portSTACK_TYPE uint32_t
56 #define portBASE_TYPE long
58 typedef portSTACK_TYPE StackType_t;
59 typedef long BaseType_t;
60 typedef unsigned long UBaseType_t;
62 #if( configUSE_16_BIT_TICKS == 1 )
63 typedef uint16_t TickType_t;
64 #define portMAX_DELAY ( TickType_t ) 0xffff
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 /*---------------------------------------------------------------------------*/
75 /* Architecture specifics. */
76 #define portSTACK_GROWTH ( -1 )
77 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
78 #define portBYTE_ALIGNMENT 4
79 #define portNOP() __asm volatile( " nop " )
80 #define portCRITICAL_NESTING_IN_TCB 1
81 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL 1
84 /*---------------------------------------------------------------------------*/
86 typedef struct MPU_SETTINGS { uint32_t ulNotUsed; } xMPU_SETTINGS;
88 /* Define away the instruction from the Restore Context Macro. */
89 #define portPRIVILEGE_BIT 0x0UL
91 #define portCCPN_MASK ( 0x000000FFUL )
93 extern void vTaskEnterCritical( void );
94 extern void vTaskExitCritical( void );
95 #define portENTER_CRITICAL() vTaskEnterCritical()
96 #define portEXIT_CRITICAL() vTaskExitCritical()
97 /*---------------------------------------------------------------------------*/
99 /* CSA Manipulation. */
100 #define portCSA_TO_ADDRESS( pCSA ) ( ( uint32_t * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )
101 #define portADDRESS_TO_CSA( pAddress ) ( ( uint32_t )( ( ( ( (uint32_t)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( ( uint32_t )( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )
102 /*---------------------------------------------------------------------------*/
104 #define portYIELD() _syscall( 0 )
105 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */
106 #define portSYSCALL_TASK_YIELD 0
107 #define portSYSCALL_RAISE_PRIORITY 1
108 /*---------------------------------------------------------------------------*/
110 /* Critical section management. */
112 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
113 #define portDISABLE_INTERRUPTS() { \
116 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
117 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
118 ulICR |= configMAX_SYSCALL_INTERRUPT_PRIORITY; /* Set mask bits to required priority mask. */ \
119 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
124 /* Clear ICR.CCPN to allow all interrupt priorities. */
125 #define portENABLE_INTERRUPTS() { \
128 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
129 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
130 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
135 /* Set ICR.CCPN to uxSavedMaskValue. */
136 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedMaskValue ) { \
139 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
140 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
141 ulICR |= uxSavedMaskValue; /* Set mask bits to previously saved mask value. */ \
142 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
148 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */
149 extern uint32_t uxPortSetInterruptMaskFromISR( void );
150 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
152 /* Pend a priority 1 interrupt, which will take care of the context switch. */
153 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken != pdFALSE ) { CPU_SRC0.bits.SETR = 1; _isync(); }
155 /*---------------------------------------------------------------------------*/
157 /* Task function macros as described on the FreeRTOS.org WEB site. */
158 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
159 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
160 /*---------------------------------------------------------------------------*/
163 * Port specific clean up macro required to free the CSAs that were consumed by
164 * a task that has since been deleted.
166 void vPortReclaimCSA( uint32_t *pxTCB );
167 #define portCLEAN_UP_TCB( pxTCB ) vPortReclaimCSA( ( uint32_t * ) ( pxTCB ) )
173 #endif /* PORTMACRO_H */