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