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