OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [GCC/] [ARM7_AT91FR40008/] [portmacro.h] - Blame information for rev 612

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 572 jeremybenn
/*
2
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
 
4
    ***************************************************************************
5
    *                                                                         *
6
    * If you are:                                                             *
7
    *                                                                         *
8
    *    + New to FreeRTOS,                                                   *
9
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
    *    + Looking for basic training,                                        *
11
    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
    *                                                                         *
13
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
    *                                                                         *
15
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
    *                  http://www.FreeRTOS.org/Documentation                  *
17
    *                                                                         *
18
    * A pdf reference manual is also available.  Both are usually delivered   *
19
    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
    * exceptional circumstances).  Thank you for your support!                *
22
    *                                                                         *
23
    ***************************************************************************
24
 
25
    This file is part of the FreeRTOS distribution.
26
 
27
    FreeRTOS is free software; you can redistribute it and/or modify it under
28
    the terms of the GNU General Public License (version 2) as published by the
29
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30
    ***NOTE*** The exception to the GPL is included to allow you to distribute
31
    a combined work that includes FreeRTOS without being obliged to provide the
32
    source code for proprietary components outside of the FreeRTOS kernel.
33
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36
    more details. You should have received a copy of the GNU General Public
37
    License and the FreeRTOS license exception along with FreeRTOS; if not it
38
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39
    by writing to Richard Barry, contact details for whom are available on the
40
    FreeRTOS WEB site.
41
 
42
    1 tab == 4 spaces!
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
/*
55
        Changes from V3.2.3
56
 
57
        + Modified portENTER_SWITCHING_ISR() to allow use with GCC V4.0.1.
58
 
59
        Changes from V3.2.4
60
 
61
        + Removed the use of the %0 parameter within the assembler macros and
62
          replaced them with hard coded registers.  This will ensure the
63
          assembler does not select the link register as the temp register as
64
          was occasionally happening previously.
65
 
66
        + The assembler statements are now included in a single asm block rather
67
          than each line having its own asm block.
68
 
69
        Changes from V4.5.0
70
 
71
        + Removed the portENTER_SWITCHING_ISR() and portEXIT_SWITCHING_ISR() macros
72
          and replaced them with portYIELD_FROM_ISR() macro.  Application code
73
          should now make use of the portSAVE_CONTEXT() and portRESTORE_CONTEXT()
74
          macros as per the V4.5.1 demo code.
75
*/
76
 
77
#ifndef PORTMACRO_H
78
#define PORTMACRO_H
79
 
80
#ifdef __cplusplus
81
extern "C" {
82
#endif
83
 
84
/*-----------------------------------------------------------
85
 * Port specific definitions.
86
 *
87
 * The settings in this file configure FreeRTOS correctly for the
88
 * given hardware and compiler.
89
 *
90
 * These settings should not be altered.
91
 *-----------------------------------------------------------
92
 */
93
 
94
/* Type definitions. */
95
#define portCHAR                char
96
#define portFLOAT               float
97
#define portDOUBLE              double
98
#define portLONG                long
99
#define portSHORT               short
100
#define portSTACK_TYPE  unsigned portLONG
101
#define portBASE_TYPE   long
102
 
103
#if( configUSE_16_BIT_TICKS == 1 )
104
        typedef unsigned portSHORT portTickType;
105
        #define portMAX_DELAY ( portTickType ) 0xffff
106
#else
107
        typedef unsigned portLONG portTickType;
108
        #define portMAX_DELAY ( portTickType ) 0xffffffff
109
#endif
110
/*-----------------------------------------------------------*/
111
 
112
/* Hardware specifics. */
113
#define portSTACK_GROWTH                        ( -1 )
114
#define portTICK_RATE_MS                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )          
115
#define portBYTE_ALIGNMENT                      8
116
#define portYIELD()                                     asm volatile ( "SWI 0" )
117
#define portNOP()                                       asm volatile ( "NOP" )
118
 
119
/*
120
 * These define the timer to use for generating the tick interrupt.
121
 * They are put in this file so they can be shared between "port.c"
122
 * and "portisr.c".
123
 */
124
#define portTIMER_REG_BASE_PTR          AT91C_BASE_TC0
125
#define portTIMER_CLK_ENABLE_BIT        AT91C_PS_TC0
126
#define portTIMER_AIC_CHANNEL           ( ( unsigned portLONG ) 4 )
127
/*-----------------------------------------------------------*/
128
 
129
/* Task utilities. */
130
 
131
/*
132
 * portRESTORE_CONTEXT, portRESTORE_CONTEXT, portENTER_SWITCHING_ISR
133
 * and portEXIT_SWITCHING_ISR can only be called from ARM mode, but
134
 * are included here for efficiency.  An attempt to call one from
135
 * THUMB mode code will result in a compile time error.
136
 */
137
 
138
#define portRESTORE_CONTEXT()                                                                                   \
139
{                                                                                                                                               \
140
extern volatile void * volatile pxCurrentTCB;                                                   \
141
extern volatile unsigned portLONG ulCriticalNesting;                                    \
142
                                                                                                                                                \
143
        /* Set the LR to the task stack. */                                                                     \
144
        asm volatile (                                                                                                          \
145
        "LDR            R0, =pxCurrentTCB                                                               \n\t"   \
146
        "LDR            R0, [R0]                                                                                \n\t"   \
147
        "LDR            LR, [R0]                                                                                \n\t"   \
148
                                                                                                                                                \
149
        /* The critical nesting depth is the first item on the stack. */        \
150
        /* Load it into the ulCriticalNesting variable. */                                      \
151
        "LDR            R0, =ulCriticalNesting                                                  \n\t"   \
152
        "LDMFD  LR!, {R1}                                                                                       \n\t"   \
153
        "STR            R1, [R0]                                                                                \n\t"   \
154
                                                                                                                                                \
155
        /* Get the SPSR from the stack. */                                                                      \
156
        "LDMFD  LR!, {R0}                                                                                       \n\t"   \
157
        "MSR            SPSR, R0                                                                                \n\t"   \
158
                                                                                                                                                \
159
        /* Restore all system mode registers for the task. */                           \
160
        "LDMFD  LR, {R0-R14}^                                                                           \n\t"   \
161
        "NOP                                                                                                            \n\t"   \
162
                                                                                                                                                \
163
        /* Restore the return address. */                                                                       \
164
        "LDR            LR, [LR, #+60]                                                                  \n\t"   \
165
                                                                                                                                                \
166
        /* And return - correcting the offset in the LR to obtain the */        \
167
        /* correct address. */                                                                                          \
168
        "SUBS   PC, LR, #4                                                                                      \n\t"   \
169
        );                                                                                                                                      \
170
        ( void ) ulCriticalNesting;                                                                                     \
171
        ( void ) pxCurrentTCB;                                                                                          \
172
}
173
/*-----------------------------------------------------------*/
174
 
175
#define portSAVE_CONTEXT()                                                                                              \
176
{                                                                                                                                               \
177
extern volatile void * volatile pxCurrentTCB;                                                   \
178
extern volatile unsigned portLONG ulCriticalNesting;                                    \
179
                                                                                                                                                \
180
        /* Push R0 as we are going to use the register. */                                      \
181
        asm volatile (                                                                                                          \
182
        "STMDB  SP!, {R0}                                                                                       \n\t"   \
183
                                                                                                                                                \
184
        /* Set R0 to point to the task stack pointer. */                                        \
185
        "STMDB  SP,{SP}^                                                                                        \n\t"   \
186
        "NOP                                                                                                            \n\t"   \
187
        "SUB    SP, SP, #4                                                                                      \n\t"   \
188
        "LDMIA  SP!,{R0}                                                                                        \n\t"   \
189
                                                                                                                                                \
190
        /* Push the return address onto the stack. */                                           \
191
        "STMDB  R0!, {LR}                                                                                       \n\t"   \
192
                                                                                                                                                \
193
        /* Now we have saved LR we can use it instead of R0. */                         \
194
        "MOV    LR, R0                                                                                          \n\t"   \
195
                                                                                                                                                \
196
        /* Pop R0 so we can save it onto the system mode stack. */                      \
197
        "LDMIA  SP!, {R0}                                                                                       \n\t"   \
198
                                                                                                                                                \
199
        /* Push all the system mode registers onto the task stack. */           \
200
        "STMDB  LR,{R0-LR}^                                                                                     \n\t"   \
201
        "NOP                                                                                                            \n\t"   \
202
        "SUB    LR, LR, #60                                                                                     \n\t"   \
203
                                                                                                                                                \
204
        /* Push the SPSR onto the task stack. */                                                        \
205
        "MRS    R0, SPSR                                                                                        \n\t"   \
206
        "STMDB  LR!, {R0}                                                                                       \n\t"   \
207
                                                                                                                                                \
208
        "LDR    R0, =ulCriticalNesting                                                          \n\t"   \
209
        "LDR    R0, [R0]                                                                                        \n\t"   \
210
        "STMDB  LR!, {R0}                                                                                       \n\t"   \
211
                                                                                                                                                \
212
        /* Store the new top of stack for the task. */                                          \
213
        "LDR    R0, =pxCurrentTCB                                                                       \n\t"   \
214
        "LDR    R0, [R0]                                                                                        \n\t"   \
215
        "STR    LR, [R0]                                                                                        \n\t"   \
216
        );                                                                                                                                      \
217
        ( void ) ulCriticalNesting;                                                                                     \
218
        ( void ) pxCurrentTCB;                                                                                          \
219
}
220
 
221
#define portYIELD_FROM_ISR() vTaskSwitchContext()
222
 
223
/* Critical section handling. */
224
 
225
/*
226
 * The interrupt management utilities can only be called from ARM mode.  When
227
 * THUMB_INTERWORK is defined the utilities are defined as functions in
228
 * portISR.c to ensure a switch to ARM mode.  When THUMB_INTERWORK is not
229
 * defined then the utilities are defined as macros here - as per other ports.
230
 */
231
 
232
#ifdef THUMB_INTERWORK
233
 
234
        extern void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked));
235
        extern void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked));
236
 
237
        #define portDISABLE_INTERRUPTS()        vPortDisableInterruptsFromThumb()
238
        #define portENABLE_INTERRUPTS()         vPortEnableInterruptsFromThumb()
239
 
240
#else
241
 
242
        #define portDISABLE_INTERRUPTS()                                                                                        \
243
                asm volatile (                                                                                                                  \
244
                        "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \
245
                        "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \
246
                        "ORR    R0, R0, #0xC0   \n\t"   /* Disable IRQ, FIQ.                    */      \
247
                        "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \
248
                        "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */
249
 
250
        #define portENABLE_INTERRUPTS()                                                                                         \
251
                asm volatile (                                                                                                                  \
252
                        "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \
253
                        "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \
254
                        "BIC    R0, R0, #0xC0   \n\t"   /* Enable IRQ, FIQ.                             */      \
255
                        "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \
256
                        "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */
257
 
258
#endif /* THUMB_INTERWORK */
259
 
260
extern void vPortEnterCritical( void );
261
extern void vPortExitCritical( void );
262
 
263
#define portENTER_CRITICAL()            vPortEnterCritical();
264
#define portEXIT_CRITICAL()                     vPortExitCritical();
265
 
266
/*-----------------------------------------------------------*/
267
 
268
/* Task function macros as described on the FreeRTOS.org WEB site. */
269
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
270
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
271
 
272
#ifdef __cplusplus
273
}
274
#endif
275
 
276
#endif /* PORTMACRO_H */
277
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.