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 664

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 664 filepang
#define portYIELD_FROM_ISR()                    portYIELD()
87 572 jeremybenn
#define portYIELD()             {       \
88 664 filepang
        __asm__ __volatile__ ( "l.nop       " ); \
89 572 jeremybenn
        __asm__ __volatile__ ( "l.sys 0x0FCC" ); \
90
        __asm__ __volatile__ ( "l.nop       " ); \
91
}
92
#define portNOP()               __asm__ __volatile__ ( "l.nop" )
93
 
94
 
95
void vPortDisableInterrupts( void );
96
void vPortEnableInterrupts( void );
97
#define portDISABLE_INTERRUPTS()        vPortDisableInterrupts()
98
#define portENABLE_INTERRUPTS()         vPortEnableInterrupts()
99
 
100
/*-----------------------------------------------------------*/
101
// Critical section handling.
102 664 filepang
extern void vTaskEnterCritical( void );
103
extern void vTaskExitCritical( void );
104
#define portENTER_CRITICAL()            vTaskEnterCritical()
105
#define portEXIT_CRITICAL()                     vTaskExitCritical()
106 572 jeremybenn
 
107
/* Task function macros as described on the FreeRTOS.org WEB site. */
108
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
109
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
110
 
111
#ifdef __cplusplus
112
}
113
#endif
114
 
115
// Macro to save all registers, stack pointer into the TCB.
116
#define portSAVE_CONTEXT()                                              \
117
        asm volatile (                                                          \
118
        "       .global pxCurrentTCB                    \n\t"   \
119
        "       # make rooms in stack                   \n\t"   \
120 621 filepang
        "       l.addi  r1, r1, -128                    \n\t"   \
121 572 jeremybenn
        "       # early save r3-r5, these are clobber register\n\t" \
122
        "       l.sw    0x08(r1), r3                    \n\t"   \
123
        "       l.sw    0x0C(r1), r4                    \n\t"   \
124
        "       l.sw    0x10(r1), r5                    \n\t"   \
125
        "       # save SPR_ESR_BASE(0), SPR_EPCR_BASE(0)\n\t"   \
126
        "       l.mfspr r3, r0, (0<<11) + 64    \n\t"   \
127
        "       l.mfspr r4, r0, (0<<11) + 32    \n\t"   \
128
        "       l.sw    0x78(r1), r3                    \n\t"   \
129
        "       l.sw    0x7C(r1), r4                    \n\t"   \
130
        "       l.sw    0x00(r1), r9                    \n\t"   \
131
        "       # disable interrupts                    \n\t"   \
132
        "       l.jal vPortDisableInterrupts    \n\t"   \
133
        "       # Save Context                                  \n\t"   \
134
        "       l.sw    0x04(r1), r2                    \n\t"   \
135
        "       l.sw    0x14(r1), r6                    \n\t"   \
136
        "       l.sw    0x18(r1), r7                    \n\t"   \
137
        "       l.sw    0x1C(r1), r8                    \n\t"   \
138
        "       l.sw    0x20(r1), r10                   \n\t"   \
139
        "       l.sw    0x24(r1), r11                   \n\t"   \
140
        "       l.sw    0x28(r1), r12                   \n\t"   \
141
        "       l.sw    0x2C(r1), r13                   \n\t"   \
142
        "       l.sw    0x30(r1), r14                   \n\t"   \
143
        "       l.sw    0x34(r1), r15                   \n\t"   \
144
        "       l.sw    0x38(r1), r16                   \n\t"   \
145
        "       l.sw    0x3C(r1), r17                   \n\t"   \
146
        "       l.sw    0x40(r1), r18                   \n\t"   \
147
        "       l.sw    0x44(r1), r19                   \n\t"   \
148
        "       l.sw    0x48(r1), r20                   \n\t"   \
149
        "       l.sw    0x4C(r1), r21                   \n\t"   \
150
        "       l.sw    0x50(r1), r22                   \n\t"   \
151
        "       l.sw    0x54(r1), r23                   \n\t"   \
152
        "       l.sw    0x58(r1), r24                   \n\t"   \
153
        "       l.sw    0x5C(r1), r25                   \n\t"   \
154
        "       l.sw    0x60(r1), r26                   \n\t"   \
155
        "       l.sw    0x64(r1), r27                   \n\t"   \
156
        "       l.sw    0x68(r1), r28                   \n\t"   \
157
        "       l.sw    0x6C(r1), r29                   \n\t"   \
158
        "       l.sw    0x70(r1), r30                   \n\t"   \
159
        "       l.sw    0x74(r1), r31                   \n\t"   \
160
        "       # Save the top of stack in TCB  \n\t"   \
161
        "       l.movhi r3, hi(pxCurrentTCB)    \n\t"   \
162
        "       l.ori   r3, r3, lo(pxCurrentTCB)\n\t"   \
163
        "       l.lwz   r3, 0x0(r3)                             \n\t"   \
164
        "       l.sw    0x0(r3), r1                             \n\t"   \
165
        "       # restore clobber register              \n\t"   \
166
        "       l.lwz   r3, 0x08(r1)                    \n\t"   \
167
        "       l.lwz   r4, 0x0C(r1)                    \n\t"   \
168
        "       l.lwz   r5, 0x10(r1)                    \n\t"   \
169
        );
170
 
171
#define portRESTORE_CONTEXT()                                   \
172
        asm volatile (                                                          \
173
        "       .global pxCurrentTCB                    \n\t"   \
174
        "       # restore stack pointer                 \n\t"   \
175
        "       l.movhi r3, hi(pxCurrentTCB)    \n\t"   \
176
        "       l.ori   r3, r3, lo(pxCurrentTCB)\n\t"   \
177
        "       l.lwz   r3, 0x0(r3)                             \n\t"   \
178
        "       l.lwz   r1, 0x0(r3)                             \n\t"   \
179
        "       # restore context                               \n\t"   \
180
        "       l.lwz   r9, 0x00(r1)                    \n\t"   \
181
        "       l.lwz   r2, 0x04(r1)                    \n\t"   \
182
        "       l.lwz   r6, 0x14(r1)                    \n\t"   \
183
        "       l.lwz   r7, 0x18(r1)                    \n\t"   \
184
        "       l.lwz   r8, 0x1C(r1)                    \n\t"   \
185
        "       l.lwz   r10, 0x20(r1)                   \n\t"   \
186
        "       l.lwz   r11, 0x24(r1)                   \n\t"   \
187
        "       l.lwz   r12, 0x28(r1)                   \n\t"   \
188
        "       l.lwz   r13, 0x2C(r1)                   \n\t"   \
189
        "       l.lwz   r14, 0x30(r1)                   \n\t"   \
190
        "       l.lwz   r15, 0x34(r1)                   \n\t"   \
191
        "       l.lwz   r16, 0x38(r1)                   \n\t"   \
192
        "       l.lwz   r17, 0x3C(r1)                   \n\t"   \
193
        "       l.lwz   r18, 0x40(r1)                   \n\t"   \
194
        "       l.lwz   r19, 0x44(r1)                   \n\t"   \
195
        "       l.lwz   r20, 0x48(r1)                   \n\t"   \
196
        "       l.lwz   r21, 0x4C(r1)                   \n\t"   \
197
        "       l.lwz   r22, 0x50(r1)                   \n\t"   \
198
        "       l.lwz   r23, 0x54(r1)                   \n\t"   \
199
        "       l.lwz   r24, 0x58(r1)                   \n\t"   \
200
        "       l.lwz   r25, 0x5C(r1)                   \n\t"   \
201
        "       l.lwz   r26, 0x60(r1)                   \n\t"   \
202
        "       l.lwz   r27, 0x64(r1)                   \n\t"   \
203
        "       l.lwz   r28, 0x68(r1)                   \n\t"   \
204
        "       l.lwz   r29, 0x6C(r1)                   \n\t"   \
205
        "       l.lwz   r30, 0x70(r1)                   \n\t"   \
206
        "       l.lwz   r31, 0x74(r1)                   \n\t"   \
207
        "       # restore SPR_ESR_BASE(0), SPR_EPCR_BASE(0)\n\t"        \
208
        "       l.lwz   r3, 0x78(r1)                    \n\t"   \
209
        "       l.lwz   r4, 0x7C(r1)                    \n\t"   \
210
        "       l.mtspr r0, r3, (0<<11) + 64    \n\t"   \
211
        "       l.mtspr r0, r4, (0<<11) + 32    \n\t"   \
212
        "       # restore clobber register              \n\t"   \
213
        "       l.lwz   r3, 0x08(r1)                    \n\t"   \
214
        "       l.lwz   r4, 0x0C(r1)                    \n\t"   \
215
        "       l.lwz   r5, 0x10(r1)                    \n\t"   \
216 621 filepang
        "       l.addi  r1, r1, 128                             \n\t"   \
217 572 jeremybenn
        "       l.rfe                                                   \n\t"   \
218
        "       l.nop                                                   \n\t"   \
219
        );
220
 
221 664 filepang
#ifdef __cplusplus
222
}
223
#endif
224
 
225 572 jeremybenn
#endif /* PORTMACRO_H */

powered by: WebSVN 2.1.0

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