2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 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. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
36 /* System Includes. */
\r
38 #include <machine/intrinsics.h>
\r
40 /*-----------------------------------------------------------
\r
41 * Port specific definitions.
\r
43 * The settings in this file configure FreeRTOS correctly for the
\r
44 * given hardware and compiler.
\r
46 * These settings should not be altered.
\r
47 *-----------------------------------------------------------
\r
50 /* Type definitions. */
\r
51 #define portCHAR char
\r
52 #define portFLOAT float
\r
53 #define portDOUBLE double
\r
54 #define portLONG long
\r
55 #define portSHORT short
\r
56 #define portSTACK_TYPE uint32_t
\r
57 #define portBASE_TYPE long
\r
59 typedef portSTACK_TYPE StackType_t;
\r
60 typedef long BaseType_t;
\r
61 typedef unsigned long UBaseType_t;
\r
63 #if( configUSE_16_BIT_TICKS == 1 )
\r
64 typedef uint16_t TickType_t;
\r
65 #define portMAX_DELAY ( TickType_t ) 0xffff
\r
67 typedef uint32_t TickType_t;
\r
68 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
70 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
\r
71 not need to be guarded with a critical section. */
\r
72 #define portTICK_TYPE_IS_ATOMIC 1
\r
74 /*---------------------------------------------------------------------------*/
\r
76 /* Architecture specifics. */
\r
77 #define portSTACK_GROWTH ( -1 )
\r
78 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
79 #define portBYTE_ALIGNMENT 4
\r
80 #define portNOP() __asm volatile( " nop " )
\r
81 #define portCRITICAL_NESTING_IN_TCB 1
\r
82 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL 1
\r
85 /*---------------------------------------------------------------------------*/
\r
87 typedef struct MPU_SETTINGS { uint32_t ulNotUsed; } xMPU_SETTINGS;
\r
89 /* Define away the instruction from the Restore Context Macro. */
\r
90 #define portPRIVILEGE_BIT 0x0UL
\r
92 #define portCCPN_MASK ( 0x000000FFUL )
\r
94 extern void vTaskEnterCritical( void );
\r
95 extern void vTaskExitCritical( void );
\r
96 #define portENTER_CRITICAL() vTaskEnterCritical()
\r
97 #define portEXIT_CRITICAL() vTaskExitCritical()
\r
98 /*---------------------------------------------------------------------------*/
\r
100 /* CSA Manipulation. */
\r
101 #define portCSA_TO_ADDRESS( pCSA ) ( ( uint32_t * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )
\r
102 #define portADDRESS_TO_CSA( pAddress ) ( ( uint32_t )( ( ( ( (uint32_t)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( ( uint32_t )( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )
\r
103 /*---------------------------------------------------------------------------*/
\r
105 #define portYIELD() _syscall( 0 )
\r
106 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */
\r
107 #define portSYSCALL_TASK_YIELD 0
\r
108 #define portSYSCALL_RAISE_PRIORITY 1
\r
109 /*---------------------------------------------------------------------------*/
\r
111 /* Critical section management. */
\r
113 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
\r
114 #define portDISABLE_INTERRUPTS() { \
\r
117 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
118 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
119 ulICR |= configMAX_SYSCALL_INTERRUPT_PRIORITY; /* Set mask bits to required priority mask. */ \
\r
120 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
125 /* Clear ICR.CCPN to allow all interrupt priorities. */
\r
126 #define portENABLE_INTERRUPTS() { \
\r
129 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
130 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
131 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
136 /* Set ICR.CCPN to uxSavedMaskValue. */
\r
137 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedMaskValue ) { \
\r
140 ulICR = __MFCR( $ICR ); /* Get current ICR value. */ \
\r
141 ulICR &= ~portCCPN_MASK; /* Clear down mask bits. */ \
\r
142 ulICR |= uxSavedMaskValue; /* Set mask bits to previously saved mask value. */ \
\r
143 _mtcr( $ICR, ulICR ); /* Write back updated ICR. */ \
\r
149 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */
\r
150 extern uint32_t uxPortSetInterruptMaskFromISR( void );
\r
151 #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
\r
153 /* Pend a priority 1 interrupt, which will take care of the context switch. */
\r
154 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken != pdFALSE ) { CPU_SRC0.bits.SETR = 1; _isync(); }
\r
156 /*---------------------------------------------------------------------------*/
\r
158 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
159 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
160 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
161 /*---------------------------------------------------------------------------*/
\r
164 * Port specific clean up macro required to free the CSAs that were consumed by
\r
165 * a task that has since been deleted.
\r
167 void vPortReclaimCSA( uint32_t *pxTCB );
\r
168 #define portCLEAN_UP_TCB( pxTCB ) vPortReclaimCSA( ( uint32_t * ) ( pxTCB ) )
\r
174 #endif /* PORTMACRO_H */
\r