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

Subversion Repositories openrisc

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

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
#ifndef PORTMACRO_H
54
#define PORTMACRO_H
55
 
56
#ifdef __cplusplus
57
extern "C" {
58
#endif
59
 
60
//-----------------------------------------------------------
61
// Port specific definitions
62
//-----------------------------------------------------------
63
// Type definitions.
64
#define portCHAR        char
65
#define portFLOAT       float
66
#define portDOUBLE      double
67
#define portLONG        long
68
#define portSHORT       short
69
#define portSTACK_TYPE  unsigned portLONG
70
#define portBASE_TYPE   long
71
#define portTickType    unsigned portLONG
72
#define portMAX_DELAY   (portTickType)0xffffffff
73
 
74
#if( configUSE_16_BIT_TICKS == 1 )
75
        #effor "configUSE_16_BIT_TICKS must be 0"
76
#endif
77
 
78
/*-----------------------------------------------------------*/
79
#define portSTACK_GROWTH                        -1
80
#define portTICK_RATE_MS                        ( (portTickType) 1000 / configTICK_RATE_HZ )
81
#define portBYTE_ALIGNMENT                      4
82
#define portCRITICAL_NESTING_IN_TCB             1
83
#define portINSTRUCTION_SIZE                    ( ( portSTACK_TYPE ) 4 )
84
#define portNO_CRITICAL_SECTION_NESTING ( ( portSTACK_TYPE ) 0 )
85
 
86
#define portYIELD_FROM_ISR()                    vTaskSwitchContext()
87
#define portYIELD()             {       \
88
        __asm__ __volatile__ ( "l.addi r1, r1, -4" ); \
89
        __asm__ __volatile__ ( "l.sw 0x0(r1), r11" ); \
90
        __asm__ __volatile__ ( "l.addi r11, r0, 0x0FCC" ); \
91
        __asm__ __volatile__ ( "l.sys 0x0FCC" ); \
92
        __asm__ __volatile__ ( "l.nop       " ); \
93
}
94
#define portNOP()               __asm__ __volatile__ ( "l.nop" )
95
 
96
 
97
/*
98
 * naked attribute is ignored or32-elf-gcc 4.5.1-or32-1.0rc1
99
 * use assemble routines in portasm.S
100
 */
101
#if 0
102
extern void vPortDisableInterrupts( void ) __attribute__ ((__naked__));
103
extern void vPortEnableInterrupts( void ) __attribute__ ((__naked__));
104
#else
105
void vPortDisableInterrupts( void );
106
void vPortEnableInterrupts( void );
107
#endif
108
 
109
#define portDISABLE_INTERRUPTS()        vPortDisableInterrupts()
110
#define portENABLE_INTERRUPTS()         vPortEnableInterrupts()
111
 
112
/*-----------------------------------------------------------*/
113
 
114
 
115
// Critical section handling.
116
// switch supervisormode, disable tick interrupt and all external interrupt, switch back usermode
117
#define portENTER_CRITICAL()    {       \
118
        __asm__ __volatile__ ( "l.addi r1, r1, -4" ); \
119
        __asm__ __volatile__ ( "l.sw 0x0(r1), r11" ); \
120
        __asm__ __volatile__ ( "l.addi r11, r0, 0x0FCE" ); \
121
        __asm__ __volatile__ ( "l.sys 0x0FCE" ); \
122
        __asm__ __volatile__ ( "l.nop       " ); \
123
}
124
 
125
// switch supervisormode, enable tick interrupt and all external interrupt, switch back usermode
126
#define portEXIT_CRITICAL()             {       \
127
        __asm__ __volatile__ ( "l.addi r1, r1, -4" ); \
128
        __asm__ __volatile__ ( "l.sw 0x0(r1), r11" ); \
129
        __asm__ __volatile__ ( "l.addi r11, r0, 0x0FCF" ); \
130
        __asm__ __volatile__ ( "l.sys 0x0FCF" ); \
131
        __asm__ __volatile__ ( "l.nop       " ); \
132
}
133
 
134
/* Task function macros as described on the FreeRTOS.org WEB site. */
135
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
136
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
137
 
138
#ifdef __cplusplus
139
}
140
#endif
141
 
142
// Macro to save all registers, stack pointer into the TCB.
143
#define portSAVE_CONTEXT()                                              \
144
        asm volatile (                                                          \
145
        "       .global pxCurrentTCB                    \n\t"   \
146
        "       # make rooms in stack                   \n\t"   \
147
        "       l.addi  r1, r1, -132                    \n\t"   \
148
        "       # early save r3-r5, these are clobber register\n\t" \
149
        "       l.sw    0x08(r1), r3                    \n\t"   \
150
        "       l.sw    0x0C(r1), r4                    \n\t"   \
151
        "       l.sw    0x10(r1), r5                    \n\t"   \
152
        "       # save SPR_ESR_BASE(0), SPR_EPCR_BASE(0)\n\t"   \
153
        "       l.mfspr r3, r0, (0<<11) + 64    \n\t"   \
154
        "       l.mfspr r4, r0, (0<<11) + 32    \n\t"   \
155
        "       l.sw    0x78(r1), r3                    \n\t"   \
156
        "       l.sw    0x7C(r1), r4                    \n\t"   \
157
        "       l.sw    0x00(r1), r9                    \n\t"   \
158
        "       # disable interrupts                    \n\t"   \
159
        "       l.jal vPortDisableInterrupts    \n\t"   \
160
        "       # Save Context                                  \n\t"   \
161
        "       l.sw    0x04(r1), r2                    \n\t"   \
162
        "       l.sw    0x14(r1), r6                    \n\t"   \
163
        "       l.sw    0x18(r1), r7                    \n\t"   \
164
        "       l.sw    0x1C(r1), r8                    \n\t"   \
165
        "       l.sw    0x20(r1), r10                   \n\t"   \
166
        "       l.sw    0x24(r1), r11                   \n\t"   \
167
        "       l.sw    0x28(r1), r12                   \n\t"   \
168
        "       l.sw    0x2C(r1), r13                   \n\t"   \
169
        "       l.sw    0x30(r1), r14                   \n\t"   \
170
        "       l.sw    0x34(r1), r15                   \n\t"   \
171
        "       l.sw    0x38(r1), r16                   \n\t"   \
172
        "       l.sw    0x3C(r1), r17                   \n\t"   \
173
        "       l.sw    0x40(r1), r18                   \n\t"   \
174
        "       l.sw    0x44(r1), r19                   \n\t"   \
175
        "       l.sw    0x48(r1), r20                   \n\t"   \
176
        "       l.sw    0x4C(r1), r21                   \n\t"   \
177
        "       l.sw    0x50(r1), r22                   \n\t"   \
178
        "       l.sw    0x54(r1), r23                   \n\t"   \
179
        "       l.sw    0x58(r1), r24                   \n\t"   \
180
        "       l.sw    0x5C(r1), r25                   \n\t"   \
181
        "       l.sw    0x60(r1), r26                   \n\t"   \
182
        "       l.sw    0x64(r1), r27                   \n\t"   \
183
        "       l.sw    0x68(r1), r28                   \n\t"   \
184
        "       l.sw    0x6C(r1), r29                   \n\t"   \
185
        "       l.sw    0x70(r1), r30                   \n\t"   \
186
        "       l.sw    0x74(r1), r31                   \n\t"   \
187
        "       # Save the top of stack in TCB  \n\t"   \
188
        "       l.movhi r3, hi(pxCurrentTCB)    \n\t"   \
189
        "       l.ori   r3, r3, lo(pxCurrentTCB)\n\t"   \
190
        "       l.lwz   r3, 0x0(r3)                             \n\t"   \
191
        "       l.sw    0x0(r3), r1                             \n\t"   \
192
        "       # restore clobber register              \n\t"   \
193
        "       l.lwz   r3, 0x08(r1)                    \n\t"   \
194
        "       l.lwz   r4, 0x0C(r1)                    \n\t"   \
195
        "       l.lwz   r5, 0x10(r1)                    \n\t"   \
196
        );
197
 
198
#define portRESTORE_CONTEXT()                                   \
199
        asm volatile (                                                          \
200
        "       .global pxCurrentTCB                    \n\t"   \
201
        "       # restore stack pointer                 \n\t"   \
202
        "       l.movhi r3, hi(pxCurrentTCB)    \n\t"   \
203
        "       l.ori   r3, r3, lo(pxCurrentTCB)\n\t"   \
204
        "       l.lwz   r3, 0x0(r3)                             \n\t"   \
205
        "       l.lwz   r1, 0x0(r3)                             \n\t"   \
206
        "       # restore context                               \n\t"   \
207
        "       l.lwz   r9, 0x00(r1)                    \n\t"   \
208
        "       l.lwz   r2, 0x04(r1)                    \n\t"   \
209
        "       l.lwz   r6, 0x14(r1)                    \n\t"   \
210
        "       l.lwz   r7, 0x18(r1)                    \n\t"   \
211
        "       l.lwz   r8, 0x1C(r1)                    \n\t"   \
212
        "       l.lwz   r10, 0x20(r1)                   \n\t"   \
213
        "       l.lwz   r11, 0x24(r1)                   \n\t"   \
214
        "       l.lwz   r12, 0x28(r1)                   \n\t"   \
215
        "       l.lwz   r13, 0x2C(r1)                   \n\t"   \
216
        "       l.lwz   r14, 0x30(r1)                   \n\t"   \
217
        "       l.lwz   r15, 0x34(r1)                   \n\t"   \
218
        "       l.lwz   r16, 0x38(r1)                   \n\t"   \
219
        "       l.lwz   r17, 0x3C(r1)                   \n\t"   \
220
        "       l.lwz   r18, 0x40(r1)                   \n\t"   \
221
        "       l.lwz   r19, 0x44(r1)                   \n\t"   \
222
        "       l.lwz   r20, 0x48(r1)                   \n\t"   \
223
        "       l.lwz   r21, 0x4C(r1)                   \n\t"   \
224
        "       l.lwz   r22, 0x50(r1)                   \n\t"   \
225
        "       l.lwz   r23, 0x54(r1)                   \n\t"   \
226
        "       l.lwz   r24, 0x58(r1)                   \n\t"   \
227
        "       l.lwz   r25, 0x5C(r1)                   \n\t"   \
228
        "       l.lwz   r26, 0x60(r1)                   \n\t"   \
229
        "       l.lwz   r27, 0x64(r1)                   \n\t"   \
230
        "       l.lwz   r28, 0x68(r1)                   \n\t"   \
231
        "       l.lwz   r29, 0x6C(r1)                   \n\t"   \
232
        "       l.lwz   r30, 0x70(r1)                   \n\t"   \
233
        "       l.lwz   r31, 0x74(r1)                   \n\t"   \
234
        "       # restore SPR_ESR_BASE(0), SPR_EPCR_BASE(0)\n\t"        \
235
        "       l.lwz   r3, 0x78(r1)                    \n\t"   \
236
        "       l.lwz   r4, 0x7C(r1)                    \n\t"   \
237
        "       l.mtspr r0, r3, (0<<11) + 64    \n\t"   \
238
        "       l.mtspr r0, r4, (0<<11) + 32    \n\t"   \
239
        "       # restore clobber register              \n\t"   \
240
        "       l.lwz   r3, 0x08(r1)                    \n\t"   \
241
        "       l.lwz   r4, 0x0C(r1)                    \n\t"   \
242
        "       l.lwz   r5, 0x10(r1)                    \n\t"   \
243
        "       l.rfe                                                   \n\t"   \
244
        "       l.nop                                                   \n\t"   \
245
        );
246
 
247
#endif /* PORTMACRO_H */

powered by: WebSVN 2.1.0

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