2 * FreeRTOS Kernel V10.1.0
\r
3 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
35 /* System Includes. */
\r
37 #include <machine/intrinsics.h>
\r
39 /*-----------------------------------------------------------
\r
40 * Port specific definitions.
\r
42 * The settings in this file configure FreeRTOS correctly for the
\r
43 * given hardware and compiler.
\r
45 * These settings should not be altered.
\r
46 *-----------------------------------------------------------
\r
49 /* Type definitions. */
\r
50 #define portCHAR char
\r
51 #define portFLOAT float
\r
52 #define portDOUBLE double
\r
53 #define portLONG long
\r
54 #define portSHORT short
\r
55 #define portSTACK_TYPE uint32_t
\r
56 #define portBASE_TYPE long
\r
58 typedef portSTACK_TYPE StackType_t;
\r
59 typedef long BaseType_t;
\r
60 typedef unsigned long UBaseType_t;
\r
62 #if( configUSE_16_BIT_TICKS == 1 )
\r
63 typedef uint16_t TickType_t;
\r
64 #define portMAX_DELAY ( TickType_t ) 0xffff
\r
66 typedef uint32_t TickType_t;
\r
67 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
69 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
\r
70 not need to be guarded with a critical section. */
\r
71 #define portTICK_TYPE_IS_ATOMIC 1
\r
73 /*---------------------------------------------------------------------------*/
\r
75 /* Architecture specifics. */
\r
76 #define portSTACK_GROWTH ( -1 )
\r
77 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
78 #define portBYTE_ALIGNMENT 4
\r
79 #define portNOP() __asm volatile( " nop " )
\r
80 #define portCRITICAL_NESTING_IN_TCB 1
\r
81 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL 1
\r
84 /*---------------------------------------------------------------------------*/
\r
86 typedef struct MPU_SETTINGS { uint32_t ulNotUsed; } xMPU_SETTINGS;
\r
88 /* Define away the instruction from the Restore Context Macro. */
\r
89 #define portPRIVILEGE_BIT 0x0UL
\r
91 #define portCCPN_MASK ( 0x000000FFUL )
\r
93 extern void vTaskEnterCritical( void );
\r
94 extern void vTaskExitCritical( void );
\r
95 #define portENTER_CRITICAL() vTaskEnterCritical()
\r
96 #define portEXIT_CRITICAL() vTaskExitCritical()
\r
97 /*---------------------------------------------------------------------------*/
\r
99 /* CSA Manipulation. */
\r
100 #define portCSA_TO_ADDRESS( pCSA ) ( ( uint32_t * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )
\r
101 #define portADDRESS_TO_CSA( pAddress ) ( ( uint32_t )( ( ( ( (uint32_t)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( ( uint32_t )( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )
\r
102 /*---------------------------------------------------------------------------*/
\r
104 #define portYIELD() _syscall( 0 )
\r
105 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */
\r
106 #define portSYSCALL_TASK_YIELD 0
\r
107 #define portSYSCALL_RAISE_PRIORITY 1
\r
108 /*---------------------------------------------------------------------------*/
\r
110 /* Critical section management. */
\r
112 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
\r
113 #define portDISABLE_INTERRUPTS() { \
\r
116 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
117 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
118 ulICR |= configMAX_SYSCALL_INTERRUPT_PRIORITY; /* Set mask bits to required priority mask. */ \
\r
119 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
124 /* Clear ICR.CCPN to allow all interrupt priorities. */
\r
125 #define portENABLE_INTERRUPTS() { \
\r
128 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
129 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
130 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
135 /* Set ICR.CCPN to uxSavedMaskValue. */
\r
136 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedMaskValue ) { \
\r
139 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
140 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
141 ulICR |= uxSavedMaskValue; /* Set mask bits to previously saved mask value. */ \
\r
142 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
148 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */
\r
149 extern uint32_t uxPortSetInterruptMaskFromISR( void );
\r
150 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
\r
152 /* Pend a priority 1 interrupt, which will take care of the context switch. */
\r
153 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken != pdFALSE ) { CPU_SRC0.bits.SETR = 1; _isync(); }
\r
155 /*---------------------------------------------------------------------------*/
\r
157 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
158 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
159 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
160 /*---------------------------------------------------------------------------*/
\r
163 * Port specific clean up macro required to free the CSAs that were consumed by
\r
164 * a task that has since been deleted.
\r
166 void vPortReclaimCSA( uint32_t *pxTCB );
\r
167 #define portCLEAN_UP_TCB( pxTCB ) vPortReclaimCSA( ( uint32_t * ) ( pxTCB ) )
\r
173 #endif /* PORTMACRO_H */
\r