]> git.sur5r.net Git - freertos/blob - Source/portable/GCC/STR75x/portmacro.h
Tidy up, starting to get ready for next release.
[freertos] / Source / portable / GCC / STR75x / portmacro.h
1 /*\r
2         FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
3 \r
4         This file is part of the FreeRTOS distribution.\r
5 \r
6         FreeRTOS is free software; you can redistribute it and/or modify it     under \r
7         the terms of the GNU General Public License (version 2) as published by the \r
8         Free Software Foundation and modified by the FreeRTOS exception.\r
9         **NOTE** The exception to the GPL is included to allow you to distribute a\r
10         combined work that includes FreeRTOS without being obliged to provide the \r
11         source code for proprietary components outside of the FreeRTOS kernel.  \r
12         Alternative commercial license and support terms are also available upon \r
13         request.  See the licensing section of http://www.FreeRTOS.org for full \r
14         license details.\r
15 \r
16         FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
17         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
18         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
19         more details.\r
20 \r
21         You should have received a copy of the GNU General Public License along\r
22         with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
23         Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
24 \r
25 \r
26         ***************************************************************************\r
27         *                                                                         *\r
28         * Looking for a quick start?  Then check out the FreeRTOS eBook!          *\r
29         * See http://www.FreeRTOS.org/Documentation for details                   *\r
30         *                                                                         *\r
31         ***************************************************************************\r
32 \r
33         1 tab == 4 spaces!\r
34 \r
35         Please ensure to read the configuration and relevant port sections of the\r
36         online documentation.\r
37 \r
38         http://www.FreeRTOS.org - Documentation, latest information, license and\r
39         contact details.\r
40 \r
41         http://www.SafeRTOS.com - A version that is certified for use in safety\r
42         critical systems.\r
43 \r
44         http://www.OpenRTOS.com - Commercial support, development, porting,\r
45         licensing and training services.\r
46 */\r
47 \r
48 \r
49 #ifndef PORTMACRO_H\r
50 #define PORTMACRO_H\r
51 \r
52 #ifdef __cplusplus\r
53 extern "C" {\r
54 #endif\r
55 \r
56 /*-----------------------------------------------------------\r
57  * Port specific definitions.\r
58  *\r
59  * The settings in this file configure FreeRTOS correctly for the\r
60  * given hardware and compiler.\r
61  *\r
62  * These settings should not be altered.\r
63  *-----------------------------------------------------------\r
64  */\r
65 \r
66 /* Type definitions. */\r
67 #define portCHAR                char\r
68 #define portFLOAT               float\r
69 #define portDOUBLE              double\r
70 #define portLONG                long\r
71 #define portSHORT               short\r
72 #define portSTACK_TYPE  unsigned portLONG\r
73 #define portBASE_TYPE   portLONG\r
74 \r
75 #if( configUSE_16_BIT_TICKS == 1 )\r
76         typedef unsigned portSHORT portTickType;\r
77         #define portMAX_DELAY ( portTickType ) 0xffff\r
78 #else\r
79         typedef unsigned portLONG portTickType;\r
80         #define portMAX_DELAY ( portTickType ) 0xffffffff\r
81 #endif\r
82 /*-----------------------------------------------------------*/ \r
83 \r
84 /* Hardware specifics. */\r
85 #define portSTACK_GROWTH                        ( -1 )\r
86 #define portTICK_RATE_MS                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )          \r
87 #define portBYTE_ALIGNMENT                      8\r
88 #define portYIELD()                                     asm volatile ( "SWI 0" )\r
89 #define portNOP()                                       asm volatile ( "NOP" )\r
90 /*-----------------------------------------------------------*/ \r
91 \r
92 /* Critical section handling. */\r
93 /*\r
94  * The interrupt management utilities can only be called from ARM mode.  When\r
95  * THUMB_INTERWORK is defined the utilities are defined as functions in \r
96  * portISR.c to ensure a switch to ARM mode.  When THUMB_INTERWORK is not \r
97  * defined then the utilities are defined as macros here - as per other ports.\r
98  */\r
99 \r
100 #ifdef THUMB_INTERWORK\r
101 \r
102         extern void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked));\r
103         extern void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked));\r
104 \r
105         #define portDISABLE_INTERRUPTS()        vPortDisableInterruptsFromThumb()\r
106         #define portENABLE_INTERRUPTS()         vPortEnableInterruptsFromThumb()\r
107         \r
108 #else\r
109 \r
110         #define portDISABLE_INTERRUPTS()                                                                                        \\r
111                 asm volatile (                                                                                                                  \\r
112                         "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \\r
113                         "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \\r
114                         "ORR    R0, R0, #0xC0   \n\t"   /* Disable IRQ, FIQ.                    */      \\r
115                         "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \\r
116                         "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */\r
117                         \r
118         #define portENABLE_INTERRUPTS()                                                                                         \\r
119                 asm volatile (                                                                                                                  \\r
120                         "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \\r
121                         "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \\r
122                         "BIC    R0, R0, #0xC0   \n\t"   /* Enable IRQ, FIQ.                             */      \\r
123                         "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \\r
124                         "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */\r
125 \r
126 #endif /* THUMB_INTERWORK */\r
127 \r
128 extern void vPortEnterCritical( void );\r
129 extern void vPortExitCritical( void );\r
130 \r
131 #define portENTER_CRITICAL()            vPortEnterCritical();\r
132 #define portEXIT_CRITICAL()                     vPortExitCritical();\r
133 /*-----------------------------------------------------------*/ \r
134 \r
135 /* Task utilities. */\r
136 #define portEND_SWITCHING_ISR( xSwitchRequired )        \\r
137 {                                                                                                       \\r
138 extern void vTaskSwitchContext( void );                         \\r
139                                                                                                         \\r
140         if( xSwitchRequired )                                                   \\r
141         {                                                                                               \\r
142                 vTaskSwitchContext();                                           \\r
143         }                                                                                               \\r
144 }\r
145 /*-----------------------------------------------------------*/ \r
146 \r
147 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
148 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )\r
149 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )\r
150 \r
151 #ifdef __cplusplus\r
152 }\r
153 #endif\r
154 \r
155 #endif /* PORTMACRO_H */\r
156 \r
157 \r