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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [GCC/] [STR75x/] [port.c] - Blame information for rev 572

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
 * Implementation of functions defined in portable.h for the ST STR75x ARM7
56
 * port.
57
 *----------------------------------------------------------*/
58
 
59
/* Library includes. */
60
#include "75x_tb.h"
61
#include "75x_eic.h"
62
 
63
/* Scheduler includes. */
64
#include "FreeRTOS.h"
65
#include "task.h"
66
 
67
/* Constants required to setup the initial stack. */
68
#define portINITIAL_SPSR                                ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */
69
#define portTHUMB_MODE_BIT                              ( ( portSTACK_TYPE ) 0x20 )
70
#define portINSTRUCTION_SIZE                    ( ( portSTACK_TYPE ) 4 )
71
 
72
/* Constants required to handle critical sections. */
73
#define portNO_CRITICAL_NESTING                 ( ( unsigned long ) 0 )
74
 
75
/* Prescale used on the timer clock when calculating the tick period. */
76
#define portPRESCALE 20
77
 
78
 
79
/*-----------------------------------------------------------*/
80
 
81
/* Setup the TB to generate the tick interrupts. */
82
static void prvSetupTimerInterrupt( void );
83
 
84
/*-----------------------------------------------------------*/
85
 
86
/*
87
 * Initialise the stack of a task to look exactly as if a call to
88
 * portSAVE_CONTEXT had been called.
89
 *
90
 * See header file for description.
91
 */
92
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
93
{
94
portSTACK_TYPE *pxOriginalTOS;
95
 
96
        pxOriginalTOS = pxTopOfStack;
97
 
98
        /* Setup the initial stack of the task.  The stack is set exactly as
99
        expected by the portRESTORE_CONTEXT() macro. */
100
 
101
        /* First on the stack is the return address - which in this case is the
102
        start of the task.  The offset is added to make the return address appear
103
        as it would within an IRQ ISR. */
104
        *pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE;
105
        pxTopOfStack--;
106
 
107
        *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaaaa;  /* R14 */
108
        pxTopOfStack--;
109
        *pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
110
        pxTopOfStack--;
111
        *pxTopOfStack = ( portSTACK_TYPE ) 0x12121212;  /* R12 */
112
        pxTopOfStack--;
113
        *pxTopOfStack = ( portSTACK_TYPE ) 0x11111111;  /* R11 */
114
        pxTopOfStack--;
115
        *pxTopOfStack = ( portSTACK_TYPE ) 0x10101010;  /* R10 */
116
        pxTopOfStack--;
117
        *pxTopOfStack = ( portSTACK_TYPE ) 0x09090909;  /* R9 */
118
        pxTopOfStack--;
119
        *pxTopOfStack = ( portSTACK_TYPE ) 0x08080808;  /* R8 */
120
        pxTopOfStack--;
121
        *pxTopOfStack = ( portSTACK_TYPE ) 0x07070707;  /* R7 */
122
        pxTopOfStack--;
123
        *pxTopOfStack = ( portSTACK_TYPE ) 0x06060606;  /* R6 */
124
        pxTopOfStack--;
125
        *pxTopOfStack = ( portSTACK_TYPE ) 0x05050505;  /* R5 */
126
        pxTopOfStack--;
127
        *pxTopOfStack = ( portSTACK_TYPE ) 0x04040404;  /* R4 */
128
        pxTopOfStack--;
129
        *pxTopOfStack = ( portSTACK_TYPE ) 0x03030303;  /* R3 */
130
        pxTopOfStack--;
131
        *pxTopOfStack = ( portSTACK_TYPE ) 0x02020202;  /* R2 */
132
        pxTopOfStack--;
133
        *pxTopOfStack = ( portSTACK_TYPE ) 0x01010101;  /* R1 */
134
        pxTopOfStack--;
135
 
136
        /* When the task starts is will expect to find the function parameter in
137
        R0. */
138
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
139
        pxTopOfStack--;
140
 
141
        /* The status register is set for system mode, with interrupts enabled. */
142
        *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;
143
 
144
        #ifdef THUMB_INTERWORK
145
        {
146
                /* We want the task to start in thumb mode. */
147
                *pxTopOfStack |= portTHUMB_MODE_BIT;
148
        }
149
        #endif
150
 
151
        pxTopOfStack--;
152
 
153
        /* Interrupt flags cannot always be stored on the stack and will
154
        instead be stored in a variable, which is then saved as part of the
155
        tasks context. */
156
        *pxTopOfStack = portNO_CRITICAL_NESTING;
157
 
158
        return pxTopOfStack;
159
}
160
/*-----------------------------------------------------------*/
161
 
162
portBASE_TYPE xPortStartScheduler( void )
163
{
164
extern void vPortISRStartFirstTask( void );
165
 
166
        /* Start the timer that generates the tick ISR.  Interrupts are disabled
167
        here already. */
168
        prvSetupTimerInterrupt();
169
 
170
        /* Start the first task. */
171
        vPortISRStartFirstTask();
172
 
173
        /* Should not get here! */
174
        return 0;
175
}
176
/*-----------------------------------------------------------*/
177
 
178
void vPortEndScheduler( void )
179
{
180
        /* It is unlikely that the ARM port will require this function as there
181
        is nothing to return to.  */
182
}
183
/*-----------------------------------------------------------*/
184
 
185
static void prvSetupTimerInterrupt( void )
186
{
187
EIC_IRQInitTypeDef  EIC_IRQInitStructure;
188
TB_InitTypeDef      TB_InitStructure;
189
 
190
        /* Setup the EIC for the TB. */
191
        EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE;
192
        EIC_IRQInitStructure.EIC_IRQChannel = TB_IRQChannel;
193
        EIC_IRQInitStructure.EIC_IRQChannelPriority = 1;
194
        EIC_IRQInit(&EIC_IRQInitStructure);
195
 
196
        /* Setup the TB for the generation of the tick interrupt. */
197
        TB_InitStructure.TB_Mode = TB_Mode_Timing;
198
        TB_InitStructure.TB_CounterMode = TB_CounterMode_Down;
199
        TB_InitStructure.TB_Prescaler = portPRESCALE - 1;
200
        TB_InitStructure.TB_AutoReload = ( ( configCPU_CLOCK_HZ / portPRESCALE ) / configTICK_RATE_HZ );
201
        TB_Init(&TB_InitStructure);
202
 
203
        /* Enable TB Update interrupt */
204
        TB_ITConfig(TB_IT_Update, ENABLE);
205
 
206
        /* Clear TB Update interrupt pending bit */
207
        TB_ClearITPendingBit(TB_IT_Update);
208
 
209
        /* Enable TB */
210
        TB_Cmd(ENABLE);
211
}
212
/*-----------------------------------------------------------*/
213
 
214
 
215
 
216
 
217
 
218
 
219
 

powered by: WebSVN 2.1.0

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