2 FreeRTOS V4.1.1 - Copyright (C) 2003-2006 Richard Barry.
\r
3 MCF5235 Port - Copyright (C) 2006 Christian Walter.
\r
5 This file is part of the FreeRTOS distribution.
\r
7 FreeRTOS is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 FreeRTOS is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with FreeRTOS; if not, write to the Free Software
\r
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
21 A special exception to the GPL can be applied should you wish to distribute
\r
22 a combined work that includes FreeRTOS, without being obliged to provide
\r
23 the source code for any proprietary components. See the licensing section
\r
24 of http://www.FreeRTOS.org for full details of how and when the exception
\r
27 ***************************************************************************
\r
29 Please ensure to read the configuration and relevant port sections of the
\r
30 online documentation.
\r
32 +++ http://www.FreeRTOS.org +++
\r
33 Documentation, latest information, license and contact details.
\r
35 +++ http://www.SafeRTOS.com +++
\r
36 A version that is certified for use in safety critical systems.
\r
38 +++ http://www.OpenRTOS.com +++
\r
39 Commercial support, development, porting, licensing and training services.
\r
41 ***************************************************************************
\r
51 /* ------------------------ Data types for Coldfire ----------------------- */
\r
52 #define portCHAR char
\r
53 #define portFLOAT float
\r
54 #define portDOUBLE double
\r
55 #define portLONG long
\r
56 #define portSHORT short
\r
57 #define portSTACK_TYPE unsigned int
\r
58 #define portBASE_TYPE int
\r
60 #if( USE_16_BIT_TICKS == 1 )
\r
61 typedef unsigned portSHORT portTickType;
\r
62 #define portMAX_DELAY ( portTickType ) 0xffff
\r
64 typedef unsigned portLONG portTickType;
\r
65 #define portMAX_DELAY ( portTickType ) 0xffffffff
\r
68 /* ------------------------ Architecture specifics ------------------------ */
\r
69 #define portSTACK_GROWTH ( -1 )
\r
70 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
\r
71 #define portBYTE_ALIGNMENT 4
\r
73 #define portTRAP_YIELD 0 /* Trap 0 */
\r
74 #define portIPL_MAX 7 /* Only NMI interrupt 7 allowed. */
\r
76 /* ------------------------ FreeRTOS macros for port ---------------------- */
\r
79 * This function must be called when the current state of the active task
\r
80 * should be stored. It must be called immediately after exception
\r
81 * processing from the CPU, i.e. there exists a Coldfire exception frame at
\r
82 * the current position in the stack. The function reserves space on
\r
83 * the stack for the CPU registers and other task dependent values (e.g
\r
84 * ulCriticalNesting) and updates the top of the stack in the TCB.
\r
86 #define portSAVE_CONTEXT() \
\r
87 asm volatile ( /* reserve space for task state. */ \
\r
88 "lea.l (-64, %sp), %sp\n\t" \
\r
89 /* push data register %d0-%d7/%a0-%a6 on stack. */ \
\r
90 "movem.l %d0-%d7/%a0-%a6, (%sp)\n\t" \
\r
91 /* push ulCriticalNesting counter on stack. */ \
\r
92 "lea.l (60, %sp), %a0\n\t" \
\r
93 "move.l ulCriticalNesting, (%a0)\n\t" \
\r
94 /* set the new top of the stack in the TCB. */ \
\r
95 "move.l pxCurrentTCB, %a0\n\t" \
\r
96 "move.l %sp, (%a0)");
\r
99 * This function restores the current active and continues its execution.
\r
100 * It loads the current TCB and restores the processor registers, the
\r
101 * task dependent values (e.g ulCriticalNesting). Finally execution
\r
102 * is continued by executing an rte instruction.
\r
104 #define portRESTORE_CONTEXT() \
\r
105 asm volatile ( "move.l pxCurrentTCB, %sp\n\t" \
\r
106 "move.l (%sp), %sp\n\t" \
\r
107 /* stack pointer now points to the saved registers. */ \
\r
108 "movem.l (%sp), %d0-%d7/%a0-%a6\n\t" \
\r
109 /* restore ulCriticalNesting counter from stack. */ \
\r
110 "lea.l (%sp, 60), %sp\n\t" \
\r
111 "move.l (%sp)+, ulCriticalNesting\n\t" \
\r
112 /* stack pointer now points to exception frame. */ \
\r
115 #define portENTER_CRITICAL() \
\r
116 vPortEnterCritical();
\r
118 #define portEXIT_CRITICAL() \
\r
119 vPortExitCritical();
\r
121 #define portSET_IPL( xIPL ) \
\r
122 asm_set_ipl( xIPL )
\r
124 #define portDISABLE_INTERRUPTS() \
\r
125 do { ( void )portSET_IPL( portIPL_MAX ); } while( 0 )
\r
126 #define portENABLE_INTERRUPTS() \
\r
127 do { ( void )portSET_IPL( 0 ); } while( 0 )
\r
129 #define portYIELD() \
\r
130 asm volatile ( " trap %0\n\t" : : "i"(portTRAP_YIELD) )
\r
132 #define portNOP() \
\r
133 asm volatile ( "nop\n\t" )
\r
135 #define portENTER_SWITCHING_ISR() \
\r
136 asm volatile ( "move.w #0x2700, %sr" ); \
\r
137 /* Save the context of the interrupted task. */ \
\r
138 portSAVE_CONTEXT( ); \
\r
141 #define portEXIT_SWITCHING_ISR( SwitchRequired ) \
\r
142 /* If a switch is required we call vTaskSwitchContext(). */ \
\r
143 if( SwitchRequired ) \
\r
145 vTaskSwitchContext( ); \
\r
148 portRESTORE_CONTEXT( );
\r
150 /* ------------------------ Function prototypes --------------------------- */
\r
151 void vPortEnterCritical( void );
\r
152 void vPortExitCritical( void );
\r
153 int asm_set_ipl( unsigned long int uiNewIPL );
\r
155 /* ------------------------ Compiler specifics ---------------------------- */
\r
156 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) \
\r
157 void vFunction( void *pvParameters )
\r
159 #define portTASK_FUNCTION( vFunction, pvParameters ) \
\r
160 void vFunction( void *pvParameters )
\r
167 #endif /* PORTMACRO_H */
\r