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

Subversion Repositories openrisc

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

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
#ifndef PORTMACRO_H
55
#define PORTMACRO_H
56
 
57
#ifdef __cplusplus
58
extern "C" {
59
#endif
60
 
61
/*-----------------------------------------------------------
62
 * Port specific definitions.
63
 *
64
 * The settings in this file configure FreeRTOS correctly for the
65
 * given hardware and compiler.
66
 *
67
 * These settings should not be altered.
68
 *-----------------------------------------------------------
69
 */
70
 
71
/* Type definitions. */
72
#define portCHAR                char
73
#define portFLOAT               float
74
#define portDOUBLE              double
75
#define portLONG                long
76
#define portSHORT               short
77
#define portSTACK_TYPE  unsigned portLONG
78
#define portBASE_TYPE   portLONG
79
 
80
#if( configUSE_16_BIT_TICKS == 1 )
81
        typedef unsigned portSHORT portTickType;
82
        #define portMAX_DELAY ( portTickType ) 0xffff
83
#else
84
        typedef unsigned portLONG portTickType;
85
        #define portMAX_DELAY ( portTickType ) 0xffffffff
86
#endif
87
/*-----------------------------------------------------------*/
88
 
89
/* Architecture specifics. */
90
#define portSTACK_GROWTH                        ( -1 )
91
#define portTICK_RATE_MS                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )          
92
#define portBYTE_ALIGNMENT                      8
93
#define portNOP()                                       __asm volatile ( "NOP" );
94
/*-----------------------------------------------------------*/
95
 
96
 
97
/* Scheduler utilities. */
98
 
99
/*
100
 * portRESTORE_CONTEXT, portRESTORE_CONTEXT, portENTER_SWITCHING_ISR
101
 * and portEXIT_SWITCHING_ISR can only be called from ARM mode, but
102
 * are included here for efficiency.  An attempt to call one from
103
 * THUMB mode code will result in a compile time error.
104
 */
105
 
106
#define portRESTORE_CONTEXT()                                                                                   \
107
{                                                                                                                                               \
108
extern volatile void * volatile pxCurrentTCB;                                                   \
109
extern volatile unsigned portLONG ulCriticalNesting;                                    \
110
                                                                                                                                                \
111
        /* Set the LR to the task stack. */                                                                     \
112
        __asm volatile (                                                                                                        \
113
        "LDR            R0, =pxCurrentTCB                                                               \n\t"   \
114
        "LDR            R0, [R0]                                                                                \n\t"   \
115
        "LDR            LR, [R0]                                                                                \n\t"   \
116
                                                                                                                                                \
117
        /* The critical nesting depth is the first item on the stack. */        \
118
        /* Load it into the ulCriticalNesting variable. */                                      \
119
        "LDR            R0, =ulCriticalNesting                                                  \n\t"   \
120
        "LDMFD  LR!, {R1}                                                                                       \n\t"   \
121
        "STR            R1, [R0]                                                                                \n\t"   \
122
                                                                                                                                                \
123
        /* Get the SPSR from the stack. */                                                                      \
124
        "LDMFD  LR!, {R0}                                                                                       \n\t"   \
125
        "MSR            SPSR, R0                                                                                \n\t"   \
126
                                                                                                                                                \
127
        /* Restore all system mode registers for the task. */                           \
128
        "LDMFD  LR, {R0-R14}^                                                                           \n\t"   \
129
        "NOP                                                                                                            \n\t"   \
130
                                                                                                                                                \
131
        /* Restore the return address. */                                                                       \
132
        "LDR            LR, [LR, #+60]                                                                  \n\t"   \
133
                                                                                                                                                \
134
        /* And return - correcting the offset in the LR to obtain the */        \
135
        /* correct address. */                                                                                          \
136
        "SUBS   PC, LR, #4                                                                                      \n\t"   \
137
        );                                                                                                                                      \
138
        ( void ) ulCriticalNesting;                                                                                     \
139
        ( void ) pxCurrentTCB;                                                                                          \
140
}
141
/*-----------------------------------------------------------*/
142
 
143
#define portSAVE_CONTEXT()                                                                                              \
144
{                                                                                                                                               \
145
extern volatile void * volatile pxCurrentTCB;                                                   \
146
extern volatile unsigned portLONG ulCriticalNesting;                                    \
147
                                                                                                                                                \
148
        /* Push R0 as we are going to use the register. */                                      \
149
        __asm volatile (                                                                                                        \
150
        "STMDB  SP!, {R0}                                                                                       \n\t"   \
151
                                                                                                                                                \
152
        /* Set R0 to point to the task stack pointer. */                                        \
153
        "STMDB  SP,{SP}^                                                                                        \n\t"   \
154
        "NOP                                                                                                            \n\t"   \
155
        "SUB    SP, SP, #4                                                                                      \n\t"   \
156
        "LDMIA  SP!,{R0}                                                                                        \n\t"   \
157
                                                                                                                                                \
158
        /* Push the return address onto the stack. */                                           \
159
        "STMDB  R0!, {LR}                                                                                       \n\t"   \
160
                                                                                                                                                \
161
        /* Now we have saved LR we can use it instead of R0. */                         \
162
        "MOV    LR, R0                                                                                          \n\t"   \
163
                                                                                                                                                \
164
        /* Pop R0 so we can save it onto the system mode stack. */                      \
165
        "LDMIA  SP!, {R0}                                                                                       \n\t"   \
166
                                                                                                                                                \
167
        /* Push all the system mode registers onto the task stack. */           \
168
        "STMDB  LR,{R0-LR}^                                                                                     \n\t"   \
169
        "NOP                                                                                                            \n\t"   \
170
        "SUB    LR, LR, #60                                                                                     \n\t"   \
171
                                                                                                                                                \
172
        /* Push the SPSR onto the task stack. */                                                        \
173
        "MRS    R0, SPSR                                                                                        \n\t"   \
174
        "STMDB  LR!, {R0}                                                                                       \n\t"   \
175
                                                                                                                                                \
176
        "LDR    R0, =ulCriticalNesting                                                          \n\t"   \
177
        "LDR    R0, [R0]                                                                                        \n\t"   \
178
        "STMDB  LR!, {R0}                                                                                       \n\t"   \
179
                                                                                                                                                \
180
        /* Store the new top of stack for the task. */                                          \
181
        "LDR    R0, =pxCurrentTCB                                                                       \n\t"   \
182
        "LDR    R0, [R0]                                                                                        \n\t"   \
183
        "STR    LR, [R0]                                                                                        \n\t"   \
184
        );                                                                                                                                      \
185
        ( void ) ulCriticalNesting;                                                                                     \
186
        ( void ) pxCurrentTCB;                                                                                          \
187
}
188
 
189
extern void vTaskSwitchContext( void );
190
#define portYIELD_FROM_ISR()            vTaskSwitchContext()
191
#define portYIELD()                                     __asm volatile ( "SWI 0" )
192
/*-----------------------------------------------------------*/
193
 
194
 
195
/* Critical section management. */
196
 
197
/*
198
 * The interrupt management utilities can only be called from ARM mode.  When
199
 * THUMB_INTERWORK is defined the utilities are defined as functions in
200
 * portISR.c to ensure a switch to ARM mode.  When THUMB_INTERWORK is not
201
 * defined then the utilities are defined as macros here - as per other ports.
202
 */
203
 
204
#ifdef THUMB_INTERWORK
205
 
206
        extern void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked));
207
        extern void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked));
208
 
209
        #define portDISABLE_INTERRUPTS()        vPortDisableInterruptsFromThumb()
210
        #define portENABLE_INTERRUPTS()         vPortEnableInterruptsFromThumb()
211
 
212
#else
213
 
214
        #define portDISABLE_INTERRUPTS()                                                                                        \
215
                __asm volatile (                                                                                                                \
216
                        "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \
217
                        "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \
218
                        "ORR    R0, R0, #0xC0   \n\t"   /* Disable IRQ, FIQ.                    */      \
219
                        "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \
220
                        "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */
221
 
222
        #define portENABLE_INTERRUPTS()                                                                                         \
223
                __asm volatile (                                                                                                                \
224
                        "STMDB  SP!, {R0}               \n\t"   /* Push R0.                                             */      \
225
                        "MRS    R0, CPSR                \n\t"   /* Get CPSR.                                    */      \
226
                        "BIC    R0, R0, #0xC0   \n\t"   /* Enable IRQ, FIQ.                             */      \
227
                        "MSR    CPSR, R0                \n\t"   /* Write back modified value.   */      \
228
                        "LDMIA  SP!, {R0}                       " )     /* Pop R0.                                              */
229
 
230
#endif /* THUMB_INTERWORK */
231
 
232
extern void vPortEnterCritical( void );
233
extern void vPortExitCritical( void );
234
 
235
#define portENTER_CRITICAL()            vPortEnterCritical();
236
#define portEXIT_CRITICAL()                     vPortExitCritical();
237
/*-----------------------------------------------------------*/
238
 
239
/* Task function macros as described on the FreeRTOS.org WEB site. */
240
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
241
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
242
 
243
#ifdef __cplusplus
244
}
245
#endif
246
 
247
#endif /* PORTMACRO_H */
248
 

powered by: WebSVN 2.1.0

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