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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [GCC/] [CORTUS_APS3/] [port.c] - 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
/* Standard includes. */
55
#include <stdlib.h>
56
 
57
/* Kernel includes. */
58
#include "FreeRTOS.h"
59
#include "task.h"
60
 
61
/* Machine includes */
62
#include <machine/counter.h>
63
#include <machine/ic.h>
64
/*-----------------------------------------------------------*/
65
 
66
/* The initial PSR has the Previous Interrupt Enabled (PIEN) flag set. */
67
#define portINITIAL_PSR                 ( 0x00020000 )
68
 
69
/*-----------------------------------------------------------*/
70
 
71
/*
72
 * Perform any hardware configuration necessary to generate the tick interrupt.
73
 */
74
static void prvSetupTimerInterrupt( void );
75
/*-----------------------------------------------------------*/
76
 
77
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
78
{
79
        /* Make space on the stack for the context - this leaves a couple of spaces
80
        empty.  */
81
        pxTopOfStack -= 20;
82
 
83
        /* Fill the registers with known values to assist debugging. */
84
        pxTopOfStack[ 16 ] = portKERNEL_INTERRUPT_PRIORITY_LEVEL;
85
        pxTopOfStack[ 15 ] = portINITIAL_PSR;
86
        pxTopOfStack[ 14 ] = ( unsigned long ) pxCode;
87
        pxTopOfStack[ 13 ] = 0x00000000UL; /* R15. */
88
        pxTopOfStack[ 12 ] = 0x00000000UL; /* R14. */
89
        pxTopOfStack[ 11 ] = 0x0d0d0d0dUL;
90
        pxTopOfStack[ 10 ] = 0x0c0c0c0cUL;
91
        pxTopOfStack[ 9 ] = 0x0b0b0b0bUL;
92
        pxTopOfStack[ 8 ] = 0x0a0a0a0aUL;
93
        pxTopOfStack[ 7 ] = 0x09090909UL;
94
        pxTopOfStack[ 6 ] = 0x08080808UL;
95
        pxTopOfStack[ 5 ] = 0x07070707UL;
96
        pxTopOfStack[ 4 ] = 0x06060606UL;
97
        pxTopOfStack[ 3 ] = 0x05050505UL;
98
        pxTopOfStack[ 2 ] = 0x04040404UL;
99
        pxTopOfStack[ 1 ] = 0x03030303UL;
100
        pxTopOfStack[ 0 ] = ( unsigned long ) pvParameters;
101
 
102
        return pxTopOfStack;
103
}
104
/*-----------------------------------------------------------*/
105
 
106
portBASE_TYPE xPortStartScheduler( void )
107
{
108
        /* Set-up the timer interrupt. */
109
        prvSetupTimerInterrupt();
110
 
111
        /* Enable the TRAP yield. */
112
        irq[ portIRQ_TRAP_YIELD ].ien = 1;
113
        irq[ portIRQ_TRAP_YIELD ].ipl = portKERNEL_INTERRUPT_PRIORITY_LEVEL;
114
 
115
        /* Integrated Interrupt Controller: Enable all interrupts. */
116
        ic->ien = 1;
117
 
118
        /* Restore callee saved registers. */
119
        portRESTORE_CONTEXT();
120
 
121
        /* Should not get here. */
122
        return 0;
123
}
124
/*-----------------------------------------------------------*/
125
 
126
static void prvSetupTimerInterrupt( void )
127
{
128
        /* Enable timer interrupts */
129
        counter1->reload = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1;
130
        counter1->value = counter1->reload;
131
        counter1->mask = 1;
132
 
133
        /* Set the IRQ Handler priority and enable it. */
134
        irq[ IRQ_COUNTER1 ].ien = 1;
135
        irq[ IRQ_COUNTER1 ].ipl = portKERNEL_INTERRUPT_PRIORITY_LEVEL;
136
}
137
/*-----------------------------------------------------------*/
138
 
139
/* Trap 31 handler. */
140
void interrupt31_handler( void ) __attribute__((naked));
141
void interrupt31_handler( void )
142
{
143
        portSAVE_CONTEXT();
144
        __asm volatile ( "call vTaskSwitchContext" );
145
        portRESTORE_CONTEXT();
146
}
147
/*-----------------------------------------------------------*/
148
 
149
static void prvProcessTick( void ) __attribute__((noinline));
150
static void prvProcessTick( void )
151
{
152
        vTaskIncrementTick();
153
 
154
        #if configUSE_PREEMPTION == 1
155
                vTaskSwitchContext();
156
        #endif
157
 
158
        /* Clear the Tick Interrupt. */
159
        counter1->expired = 0;
160
}
161
/*-----------------------------------------------------------*/
162
 
163
/* Timer 1 interrupt handler, used for tick interrupt. */
164
void interrupt7_handler( void ) __attribute__((naked));
165
void interrupt7_handler( void )
166
{
167
        portSAVE_CONTEXT();
168
        prvProcessTick();
169
        portRESTORE_CONTEXT();
170
}
171
/*-----------------------------------------------------------*/
172
 
173
void vPortEndScheduler( void )
174
{
175
        /* Nothing to do. Unlikely to want to end. */
176
}
177
/*-----------------------------------------------------------*/

powered by: WebSVN 2.1.0

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