1 |
572 |
jeremybenn |
/*
|
2 |
|
|
FreeRTOS V4.1.1 - Copyright (C) 2003-2006 Richard Barry.
|
3 |
|
|
MCF5235 Port - Copyright (C) 2006 Christian Walter.
|
4 |
|
|
|
5 |
|
|
This file is part of the FreeRTOS distribution.
|
6 |
|
|
|
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.
|
11 |
|
|
|
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.
|
16 |
|
|
|
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
|
20 |
|
|
|
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
|
25 |
|
|
can be applied.
|
26 |
|
|
|
27 |
|
|
***************************************************************************
|
28 |
|
|
***************************************************************************
|
29 |
|
|
* *
|
30 |
|
|
* Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *
|
31 |
|
|
* *
|
32 |
|
|
* This is a concise, step by step, 'hands on' guide that describes both *
|
33 |
|
|
* general multitasking concepts and FreeRTOS specifics. It presents and *
|
34 |
|
|
* explains numerous examples that are written using the FreeRTOS API. *
|
35 |
|
|
* Full source code for all the examples is provided in an accompanying *
|
36 |
|
|
* .zip file. *
|
37 |
|
|
* *
|
38 |
|
|
***************************************************************************
|
39 |
|
|
***************************************************************************
|
40 |
|
|
|
41 |
|
|
Please ensure to read the configuration and relevant port sections of the
|
42 |
|
|
online documentation.
|
43 |
|
|
|
44 |
|
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
45 |
|
|
contact details.
|
46 |
|
|
|
47 |
|
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
48 |
|
|
critical systems.
|
49 |
|
|
|
50 |
|
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
51 |
|
|
licensing and training services.
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
#ifndef PORTMACRO_H
|
55 |
|
|
#define PORTMACRO_H
|
56 |
|
|
|
57 |
|
|
#ifdef __cplusplus
|
58 |
|
|
extern "C" {
|
59 |
|
|
#endif
|
60 |
|
|
|
61 |
|
|
/* ------------------------ Data types for Coldfire ----------------------- */
|
62 |
|
|
#define portCHAR char
|
63 |
|
|
#define portFLOAT float
|
64 |
|
|
#define portDOUBLE double
|
65 |
|
|
#define portLONG long
|
66 |
|
|
#define portSHORT short
|
67 |
|
|
#define portSTACK_TYPE unsigned int
|
68 |
|
|
#define portBASE_TYPE int
|
69 |
|
|
|
70 |
|
|
#if( USE_16_BIT_TICKS == 1 )
|
71 |
|
|
typedef unsigned portSHORT portTickType;
|
72 |
|
|
#define portMAX_DELAY ( portTickType ) 0xffff
|
73 |
|
|
#else
|
74 |
|
|
typedef unsigned portLONG portTickType;
|
75 |
|
|
#define portMAX_DELAY ( portTickType ) 0xffffffff
|
76 |
|
|
#endif
|
77 |
|
|
|
78 |
|
|
/* ------------------------ Architecture specifics ------------------------ */
|
79 |
|
|
#define portSTACK_GROWTH ( -1 )
|
80 |
|
|
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
81 |
|
|
#define portBYTE_ALIGNMENT 4
|
82 |
|
|
|
83 |
|
|
#define portTRAP_YIELD 0 /* Trap 0 */
|
84 |
|
|
#define portIPL_MAX 7 /* Only NMI interrupt 7 allowed. */
|
85 |
|
|
|
86 |
|
|
/* ------------------------ FreeRTOS macros for port ---------------------- */
|
87 |
|
|
|
88 |
|
|
/*
|
89 |
|
|
* This function must be called when the current state of the active task
|
90 |
|
|
* should be stored. It must be called immediately after exception
|
91 |
|
|
* processing from the CPU, i.e. there exists a Coldfire exception frame at
|
92 |
|
|
* the current position in the stack. The function reserves space on
|
93 |
|
|
* the stack for the CPU registers and other task dependent values (e.g
|
94 |
|
|
* ulCriticalNesting) and updates the top of the stack in the TCB.
|
95 |
|
|
*/
|
96 |
|
|
#define portSAVE_CONTEXT() \
|
97 |
|
|
asm volatile ( /* reserve space for task state. */ \
|
98 |
|
|
"lea.l (-64, %sp), %sp\n\t" \
|
99 |
|
|
/* push data register %d0-%d7/%a0-%a6 on stack. */ \
|
100 |
|
|
"movem.l %d0-%d7/%a0-%a6, (%sp)\n\t" \
|
101 |
|
|
/* push ulCriticalNesting counter on stack. */ \
|
102 |
|
|
"lea.l (60, %sp), %a0\n\t" \
|
103 |
|
|
"move.l ulCriticalNesting, (%a0)\n\t" \
|
104 |
|
|
/* set the new top of the stack in the TCB. */ \
|
105 |
|
|
"move.l pxCurrentTCB, %a0\n\t" \
|
106 |
|
|
"move.l %sp, (%a0)");
|
107 |
|
|
|
108 |
|
|
/*.
|
109 |
|
|
* This function restores the current active and continues its execution.
|
110 |
|
|
* It loads the current TCB and restores the processor registers, the
|
111 |
|
|
* task dependent values (e.g ulCriticalNesting). Finally execution
|
112 |
|
|
* is continued by executing an rte instruction.
|
113 |
|
|
*/
|
114 |
|
|
#define portRESTORE_CONTEXT() \
|
115 |
|
|
asm volatile ( "move.l pxCurrentTCB, %sp\n\t" \
|
116 |
|
|
"move.l (%sp), %sp\n\t" \
|
117 |
|
|
/* stack pointer now points to the saved registers. */ \
|
118 |
|
|
"movem.l (%sp), %d0-%d7/%a0-%a6\n\t" \
|
119 |
|
|
/* restore ulCriticalNesting counter from stack. */ \
|
120 |
|
|
"lea.l (%sp, 60), %sp\n\t" \
|
121 |
|
|
"move.l (%sp)+, ulCriticalNesting\n\t" \
|
122 |
|
|
/* stack pointer now points to exception frame. */ \
|
123 |
|
|
"rte\n\t" );
|
124 |
|
|
|
125 |
|
|
#define portENTER_CRITICAL() \
|
126 |
|
|
vPortEnterCritical();
|
127 |
|
|
|
128 |
|
|
#define portEXIT_CRITICAL() \
|
129 |
|
|
vPortExitCritical();
|
130 |
|
|
|
131 |
|
|
#define portSET_IPL( xIPL ) \
|
132 |
|
|
asm_set_ipl( xIPL )
|
133 |
|
|
|
134 |
|
|
#define portDISABLE_INTERRUPTS() \
|
135 |
|
|
do { ( void )portSET_IPL( portIPL_MAX ); } while( 0 )
|
136 |
|
|
#define portENABLE_INTERRUPTS() \
|
137 |
|
|
do { ( void )portSET_IPL( 0 ); } while( 0 )
|
138 |
|
|
|
139 |
|
|
#define portYIELD() \
|
140 |
|
|
asm volatile ( " trap %0\n\t" : : "i"(portTRAP_YIELD) )
|
141 |
|
|
|
142 |
|
|
#define portNOP() \
|
143 |
|
|
asm volatile ( "nop\n\t" )
|
144 |
|
|
|
145 |
|
|
#define portENTER_SWITCHING_ISR() \
|
146 |
|
|
asm volatile ( "move.w #0x2700, %sr" ); \
|
147 |
|
|
/* Save the context of the interrupted task. */ \
|
148 |
|
|
portSAVE_CONTEXT( ); \
|
149 |
|
|
{
|
150 |
|
|
|
151 |
|
|
#define portEXIT_SWITCHING_ISR( SwitchRequired ) \
|
152 |
|
|
/* If a switch is required we call vTaskSwitchContext(). */ \
|
153 |
|
|
if( SwitchRequired ) \
|
154 |
|
|
{ \
|
155 |
|
|
vTaskSwitchContext( ); \
|
156 |
|
|
} \
|
157 |
|
|
} \
|
158 |
|
|
portRESTORE_CONTEXT( );
|
159 |
|
|
|
160 |
|
|
/* ------------------------ Function prototypes --------------------------- */
|
161 |
|
|
void vPortEnterCritical( void );
|
162 |
|
|
void vPortExitCritical( void );
|
163 |
|
|
int asm_set_ipl( unsigned long int uiNewIPL );
|
164 |
|
|
|
165 |
|
|
/* ------------------------ Compiler specifics ---------------------------- */
|
166 |
|
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) \
|
167 |
|
|
void vFunction( void *pvParameters )
|
168 |
|
|
|
169 |
|
|
#define portTASK_FUNCTION( vFunction, pvParameters ) \
|
170 |
|
|
void vFunction( void *pvParameters )
|
171 |
|
|
|
172 |
|
|
#ifdef __cplusplus
|
173 |
|
|
}
|
174 |
|
|
#endif
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
#endif /* PORTMACRO_H */
|
178 |
|
|
|