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 #include <machine/cpu.h>
\r
38 /*-----------------------------------------------------------
\r
39 * Port specific definitions.
\r
41 * The settings in this file configure FreeRTOS correctly for the
\r
42 * given hardware and compiler.
\r
44 * These settings should not be altered.
\r
45 *-----------------------------------------------------------
\r
48 /* Type definitions. */
\r
49 #define portCHAR char
\r
50 #define portFLOAT float
\r
51 #define portDOUBLE double
\r
52 #define portLONG long
\r
53 #define portSHORT short
\r
54 #define portSTACK_TYPE uint32_t
\r
55 #define portBASE_TYPE long
\r
57 typedef portSTACK_TYPE StackType_t;
\r
58 typedef long BaseType_t;
\r
59 typedef unsigned long UBaseType_t;
\r
61 #if( configUSE_16_BIT_TICKS == 1 )
\r
62 typedef uint16_t TickType_t;
\r
63 #define portMAX_DELAY ( TickType_t ) 0xffff
\r
65 typedef uint32_t TickType_t;
\r
66 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
68 /*-----------------------------------------------------------*/
\r
70 /* Architecture specifics. */
\r
71 #define portSTACK_GROWTH ( -1 )
\r
72 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
73 #define portBYTE_ALIGNMENT 4
\r
74 #define portNOP() __asm__ volatile ( "mov r0, r0" )
\r
75 #define portCRITICAL_NESTING_IN_TCB 1
\r
76 #define portIRQ_TRAP_YIELD 31
\r
77 /*-----------------------------------------------------------*/
\r
79 /* Task utilities. */
\r
81 extern void vPortYield( void );
\r
83 /*---------------------------------------------------------------------------*/
\r
85 #define portYIELD() asm __volatile__( " trap #%0 "::"i"(portIRQ_TRAP_YIELD):"memory")
\r
86 /*---------------------------------------------------------------------------*/
\r
88 extern void vTaskEnterCritical( void );
\r
89 extern void vTaskExitCritical( void );
\r
90 #define portENTER_CRITICAL() vTaskEnterCritical()
\r
91 #define portEXIT_CRITICAL() vTaskExitCritical()
\r
92 /*---------------------------------------------------------------------------*/
\r
94 /* Critical section management. */
\r
95 #define portDISABLE_INTERRUPTS() cpu_int_disable()
\r
96 #define portENABLE_INTERRUPTS() cpu_int_enable()
\r
98 /*---------------------------------------------------------------------------*/
\r
100 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken != pdFALSE ) vTaskSwitchContext()
\r
102 /*---------------------------------------------------------------------------*/
\r
104 #define portSAVE_CONTEXT() \
\r
107 "sub r1, #68 \n" /* Make space on the stack for the context. */ \
\r
108 "std r2, [r1] + 0 \n" \
\r
109 "stq r4, [r1] + 8 \n" \
\r
110 "stq r8, [r1] + 24 \n" \
\r
111 "stq r12, [r1] + 40 \n" \
\r
114 "std r6, [r1] + 56 \n" \
\r
115 "movhi r2, #16384 \n" /* Set the pointer to the IC. */ \
\r
116 "ldub r3, [r2] + 2 \n" /* Load the current interrupt mask. */ \
\r
117 "st r3, [r1]+ 64 \n" /* Store the interrupt mask on the stack. */ \
\r
118 "ld r2, [r0]+short(pxCurrentTCB) \n" /* Load the pointer to the TCB. */ \
\r
119 "st r1, [r2] \n" /* Save the stack pointer into the TCB. */ \
\r
120 "mov r14, r1 \n" /* Compiler expects r14 to be set to the function stack. */ \
\r
122 /*---------------------------------------------------------------------------*/
\r
124 #define portRESTORE_CONTEXT() \
\r
125 asm __volatile__( \
\r
126 "ld r2, [r0]+short(pxCurrentTCB) \n" /* Load the TCB to find the stack pointer and context. */ \
\r
128 "movhi r2, #16384 \n" /* Set the pointer to the IC. */ \
\r
129 "ld r3, [r1] + 64 \n" /* Load the previous interrupt mask. */ \
\r
130 "stb r3, [r2] + 2 \n" /* Set the current interrupt mask to be the previous. */ \
\r
131 "ldd r6, [r1] + 56 \n" /* Restore context. */ \
\r
134 "ldd r2, [r1] + 0 \n" \
\r
135 "ldq r4, [r1] + 8 \n" \
\r
136 "ldq r8, [r1] + 24 \n" \
\r
137 "ldq r12, [r1] + 40 \n" \
\r
142 /*---------------------------------------------------------------------------*/
\r
144 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
145 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
146 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
147 /*---------------------------------------------------------------------------*/
\r
153 #endif /* PORTMACRO_H */
\r