]> git.sur5r.net Git - freertos/blob - Source/portable/GCC/MCF5235/portmacro.h
Update to V4.3.0 as described in http://www.FreeRTOS.org/History.txt
[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     See http://www.FreeRTOS.org for documentation, latest information, license\r
29     and contact details.  Please ensure to read the configuration and relevant\r
30     port sections of the online documentation.\r
31 \r
32         Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along\r
33         with commercial development and support options.\r
34     ***************************************************************************\r
35 */\r
36 \r
37 #ifndef PORTMACRO_H\r
38 #define PORTMACRO_H\r
39 \r
40 /* ------------------------ Data types for Coldfire ----------------------- */\r
41 #define portCHAR        char\r
42 #define portFLOAT       float\r
43 #define portDOUBLE      double\r
44 #define portLONG        long\r
45 #define portSHORT       short\r
46 #define portSTACK_TYPE  unsigned int\r
47 #define portBASE_TYPE   int\r
48 \r
49 #if( USE_16_BIT_TICKS == 1 )\r
50     typedef unsigned portSHORT portTickType;\r
51     #define portMAX_DELAY ( portTickType ) 0xffff\r
52 #else\r
53     typedef unsigned portLONG portTickType;\r
54     #define portMAX_DELAY ( portTickType ) 0xffffffff\r
55 #endif\r
56 \r
57 /* ------------------------ Architecture specifics ------------------------ */\r
58 #define portSTACK_GROWTH                ( -1 )\r
59 #define portTICK_RATE_MS                ( ( portTickType ) 1000 / configTICK_RATE_HZ )\r
60 #define portBYTE_ALIGNMENT              4\r
61 \r
62 #define portTRAP_YIELD                  0   /* Trap 0 */\r
63 #define portIPL_MAX                     7   /* Only NMI interrupt 7 allowed. */\r
64 \r
65 /* ------------------------ FreeRTOS macros for port ---------------------- */\r
66 \r
67 /*\r
68  * This function must be called when the current state of the active task\r
69  * should be stored. It must be called immediately after exception\r
70  * processing from the CPU, i.e. there exists a Coldfire exception frame at\r
71  * the current position in the stack. The function reserves space on\r
72  * the stack for the CPU registers and other task dependent values (e.g\r
73  * ulCriticalNesting) and updates the top of the stack in the TCB.\r
74  */\r
75 #define portSAVE_CONTEXT()                                                   \\r
76     asm volatile ( /* reserve space for task state. */                       \\r
77                    "lea.l   (-64, %sp), %sp\n\t"                             \\r
78                    /* push data register %d0-%d7/%a0-%a6 on stack. */        \\r
79                    "movem.l %d0-%d7/%a0-%a6, (%sp)\n\t"                      \\r
80                    /* push ulCriticalNesting counter on stack. */            \\r
81                    "lea.l  (60, %sp), %a0\n\t"                               \\r
82                    "move.l  ulCriticalNesting, (%a0)\n\t"                    \\r
83                    /* set the new top of the stack in the TCB. */            \\r
84                    "move.l  pxCurrentTCB, %a0\n\t"                           \\r
85                    "move.l  %sp, (%a0)");\r
86 \r
87 /*.\r
88  * This function restores the current active and continues its execution.\r
89  * It loads the current TCB and restores the processor registers, the\r
90  * task dependent values (e.g ulCriticalNesting). Finally execution\r
91  * is continued by executing an rte instruction.\r
92  */\r
93 #define portRESTORE_CONTEXT()                                                \\r
94     asm volatile ( "move.l  pxCurrentTCB, %sp\n\t"                           \\r
95                    "move.l  (%sp), %sp\n\t"                                  \\r
96                    /* stack pointer now points to the saved registers. */    \\r
97                    "movem.l (%sp), %d0-%d7/%a0-%a6\n\t"                      \\r
98                    /* restore ulCriticalNesting counter from stack. */       \\r
99                    "lea.l   (%sp, 60), %sp\n\t"                              \\r
100                    "move.l  (%sp)+, ulCriticalNesting\n\t"                   \\r
101                    /* stack pointer now points to exception frame. */        \\r
102                    "rte\n\t" );\r
103 \r
104 #define portENTER_CRITICAL()                                                 \\r
105     vPortEnterCritical();\r
106 \r
107 #define portEXIT_CRITICAL()                                                  \\r
108     vPortExitCritical();\r
109 \r
110 #define portSET_IPL( xIPL )                                                  \\r
111     asm_set_ipl( xIPL )\r
112 \r
113 #define portDISABLE_INTERRUPTS() \\r
114     do { ( void )portSET_IPL( portIPL_MAX ); } while( 0 )\r
115 #define portENABLE_INTERRUPTS() \\r
116     do { ( void )portSET_IPL( 0 ); } while( 0 )\r
117 \r
118 #define portYIELD()                                                          \\r
119     asm volatile ( " trap   %0\n\t" : : "i"(portTRAP_YIELD) )\r
120 \r
121 #define portNOP()                                                            \\r
122     asm volatile ( "nop\n\t" )\r
123 \r
124 #define portENTER_SWITCHING_ISR()                                            \\r
125     asm volatile ( "move.w  #0x2700, %sr" );                                 \\r
126     /* Save the context of the interrupted task. */                          \\r
127     portSAVE_CONTEXT(  );                                                    \\r
128     {\r
129 \r
130 #define portEXIT_SWITCHING_ISR( SwitchRequired )                             \\r
131         /* If a switch is required we call vTaskSwitchContext(). */          \\r
132         if( SwitchRequired )                                                 \\r
133         {                                                                    \\r
134             vTaskSwitchContext(  );                                          \\r
135         }                                                                    \\r
136     }                                                                        \\r
137     portRESTORE_CONTEXT(  );\r
138 \r
139 /* ------------------------ Function prototypes --------------------------- */\r
140 void vPortEnterCritical( void );\r
141 void vPortExitCritical( void );\r
142 int asm_set_ipl( unsigned long int uiNewIPL );\r
143 \r
144 /* ------------------------ Compiler specifics ---------------------------- */\r
145 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )                   \\r
146     void vFunction( void *pvParameters )\r
147 \r
148 #define portTASK_FUNCTION( vFunction, pvParameters )                         \\r
149     void vFunction( void *pvParameters )\r
150 #endif\r
151 \r