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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [IAR/] [RX600/] [port_asm.s] - Blame information for rev 582

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
#include "PriorityDefinitions.h"
55
 
56
        PUBLIC _prvStartFirstTask
57
        PUBLIC ___interrupt_27
58
 
59
        EXTERN _pxCurrentTCB
60
        EXTERN _vTaskSwitchContext
61
 
62
        RSEG CODE:CODE(4)
63
 
64
_prvStartFirstTask:
65
 
66
                /* When starting the scheduler there is nothing that needs moving to the
67
                interrupt stack because the function is not called from an interrupt.
68
                Just ensure the current stack is the user stack. */
69
                SETPSW          U
70
 
71
                /* Obtain the location of the stack associated with which ever task
72
                pxCurrentTCB is currently pointing to. */
73
                MOV.L           #_pxCurrentTCB, R15
74
                MOV.L           [R15], R15
75
                MOV.L           [R15], R0
76
 
77
                /* Restore the registers from the stack of the task pointed to by
78
                pxCurrentTCB. */
79
                POP                     R15
80
 
81
                /* Accumulator low 32 bits. */
82
                MVTACLO         R15
83
                POP                     R15
84
 
85
                /* Accumulator high 32 bits. */
86
                MVTACHI         R15
87
                POP                     R15
88
 
89
                /* Floating point status word. */
90
                MVTC            R15, FPSW
91
 
92
                /* R1 to R15 - R0 is not included as it is the SP. */
93
                POPM            R1-R15
94
 
95
                /* This pops the remaining registers. */
96
                RTE
97
                NOP
98
                NOP
99
 
100
/*-----------------------------------------------------------*/
101
 
102
/* The software interrupt - overwrite the default 'weak' definition. */
103
___interrupt_27:
104
 
105
                /* Re-enable interrupts. */
106
                SETPSW          I
107
 
108
                /* Move the data that was automatically pushed onto the interrupt stack when
109
                the interrupt occurred from the interrupt stack to the user stack.
110
 
111
                R15 is saved before it is clobbered. */
112
                PUSH.L          R15
113
 
114
                /* Read the user stack pointer. */
115
                MVFC            USP, R15
116
 
117
                /* Move the address down to the data being moved. */
118
                SUB                     #12, R15
119
                MVTC            R15, USP
120
 
121
                /* Copy the data across, R15, then PC, then PSW. */
122
                MOV.L           [ R0 ], [ R15 ]
123
                MOV.L           4[ R0 ], 4[ R15 ]
124
                MOV.L           8[ R0 ], 8[ R15 ]
125
 
126
                /* Move the interrupt stack pointer to its new correct position. */
127
                ADD             #12, R0
128
 
129
                /* All the rest of the registers are saved directly to the user stack. */
130
                SETPSW          U
131
 
132
                /* Save the rest of the general registers (R15 has been saved already). */
133
                PUSHM           R1-R14
134
 
135
                /* Save the FPSW and accumulator. */
136
                MVFC            FPSW, R15
137
                PUSH.L          R15
138
                MVFACHI         R15
139
                PUSH.L          R15
140
 
141
                /* Middle word. */
142
                MVFACMI R15
143
 
144
                /* Shifted left as it is restored to the low order word. */
145
                SHLL            #16, R15
146
                PUSH.L          R15
147
 
148
                /* Save the stack pointer to the TCB. */
149
                MOV.L           #_pxCurrentTCB, R15
150
                MOV.L           [ R15 ], R15
151
                MOV.L           R0, [ R15 ]
152
 
153
                /* Ensure the interrupt mask is set to the syscall priority while the kernel
154
                structures are being accessed. */
155
                MVTIPL          #configMAX_SYSCALL_INTERRUPT_PRIORITY
156
 
157
                /* Select the next task to run. */
158
                BSR.A           _vTaskSwitchContext
159
 
160
                /* Reset the interrupt mask as no more data structure access is required. */
161
                MVTIPL          #configKERNEL_INTERRUPT_PRIORITY
162
 
163
                /* Load the stack pointer of the task that is now selected as the Running
164
                state task from its TCB. */
165
                MOV.L           #_pxCurrentTCB,R15
166
                MOV.L           [ R15 ], R15
167
                MOV.L           [ R15 ], R0
168
 
169
                /* Restore the context of the new task.  The PSW (Program Status Word) and
170
                PC will be popped by the RTE instruction. */
171
                POP                     R15
172
                MVTACLO         R15
173
                POP                     R15
174
                MVTACHI         R15
175
                POP                     R15
176
                MVTC            R15, FPSW
177
                POPM            R1-R15
178
                RTE
179
                NOP
180
                NOP
181
 
182
/*-----------------------------------------------------------*/
183
 
184
                END
185
 

powered by: WebSVN 2.1.0

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