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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [MPLAB/] [PIC32MX/] [port_asm.S] - 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
#include 
55
#include 
56
#include "ISR_Support.h"
57
 
58
 
59
        .set    nomips16
60
        .set    noreorder
61
 
62
        .extern pxCurrentTCB
63
        .extern vTaskSwitchContext
64
        .extern vPortIncrementTick
65
        .extern xISRStackTop
66
 
67
        .global vPortStartFirstTask
68
        .global vPortYieldISR
69
        .global vT1InterruptHandler
70
 
71
 
72
/******************************************************************/
73
 
74
        .section        .FreeRTOS, "ax", @progbits
75
        .set            noreorder
76
        .set            noat
77
        .ent            vT1InterruptHandler
78
 
79
vT1InterruptHandler:
80
 
81
        portSAVE_CONTEXT
82
 
83
        jal             vPortIncrementTick
84
        nop
85
 
86
        portRESTORE_CONTEXT
87
 
88
        .end vT1InterruptHandler
89
 
90
/******************************************************************/
91
 
92
        .section        .FreeRTOS, "ax", @progbits
93
        .set            noreorder
94
        .set            noat
95
        .ent            xPortStartScheduler
96
 
97
vPortStartFirstTask:
98
 
99
        /* Simply restore the context of the highest priority task that has been
100
        created so far. */
101
        portRESTORE_CONTEXT
102
 
103
        .end xPortStartScheduler
104
 
105
 
106
 
107
/*******************************************************************/
108
 
109
        .section        .FreeRTOS, "ax", @progbits
110
        .set            noreorder
111
        .set            noat
112
        .ent            vPortYieldISR
113
 
114
vPortYieldISR:
115
 
116
        /* Make room for the context. First save the current status so we can
117
        manipulate it, and the cause and EPC registers so we capture their
118
        original values in case of interrupt nesting. */
119
        mfc0            k0, _CP0_CAUSE
120
        addiu           sp,     sp, -portCONTEXT_SIZE
121
        mfc0            k1, _CP0_STATUS
122
 
123
        /* Also save s6 and s5 so we can use them during this interrupt.  Any
124
        nesting interrupts should maintain the values of these registers
125
        across the ISR. */
126
        sw                      s6, 44(sp)
127
        sw                      s5, 40(sp)
128
        sw                      k1, portSTATUS_STACK_LOCATION(sp)
129
 
130
        /* Enable interrupts above the current priority. */
131
        srl                     k0, k0, 0xa
132
        ins             k1, k0, 10, 6
133
        ins                     k1, zero, 1, 4
134
 
135
        /* s5 is used as the frame pointer. */
136
        add                     s5, zero, sp
137
 
138
        /* Swap to the system stack.  This is not conditional on the nesting
139
        count as this interrupt is always the lowest priority and therefore
140
        the nesting is always 0. */
141
        la                      sp, xISRStackTop
142
        lw                      sp, (sp)
143
 
144
        /* Set the nesting count. */
145
        la                      k0, uxInterruptNesting
146
        addiu           s6, zero, 1
147
        sw                      s6, 0(k0)
148
 
149
        /* s6 holds the EPC value, this is saved with the rest of the context
150
        after interrupts are enabled. */
151
        mfc0            s6, _CP0_EPC
152
 
153
        /* Re-enable interrupts. */
154
        mtc0            k1, _CP0_STATUS
155
 
156
        /* Save the context into the space just created.  s6 is saved again
157
        here as it now contains the EPC value. */
158
        sw                      ra,     120(s5)
159
        sw                      s8, 116(s5)
160
        sw                      t9, 112(s5)
161
        sw                      t8,     108(s5)
162
        sw                      t7,     104(s5)
163
        sw                      t6, 100(s5)
164
        sw                      t5, 96(s5)
165
        sw                      t4, 92(s5)
166
        sw                      t3, 88(s5)
167
        sw                      t2, 84(s5)
168
        sw                      t1, 80(s5)
169
        sw                      t0, 76(s5)
170
        sw                      a3, 72(s5)
171
        sw                      a2, 68(s5)
172
        sw                      a1, 64(s5)
173
        sw                      a0, 60(s5)
174
        sw                      v1, 56(s5)
175
        sw                      v0, 52(s5)
176
        sw                      s7, 48(s5)
177
        sw                      s6, portEPC_STACK_LOCATION(s5)
178
        /* s5 and s6 has already been saved. */
179
        sw                      s4,     36(s5)
180
        sw                      s3, 32(s5)
181
        sw                      s2, 28(s5)
182
        sw                      s1, 24(s5)
183
        sw                      s0, 20(s5)
184
        sw                      $1, 16(s5)
185
 
186
        /* s7 is used as a scratch register as this should always be saved across
187
        nesting interrupts. */
188
        mfhi            s7
189
        sw                      s7, 12(s5)
190
        mflo            s7
191
        sw                      s7, 8(s5)
192
 
193
        /* Save the stack pointer to the task. */
194
        la                      s7, pxCurrentTCB
195
        lw                      s7, (s7)
196
        sw                      s5, (s7)
197
 
198
        /* Set the interrupt mask to the max priority that can use the API. */
199
        di
200
        mfc0            s7, _CP0_STATUS
201
        ori                     s7, s7, 1
202
        ori                     s6, s7, configMAX_SYSCALL_INTERRUPT_PRIORITY << 10
203
 
204
        /* This mtc0 re-enables interrupts, but only above
205
        configMAX_SYSCALL_INTERRUPT_PRIORITY. */
206
        mtc0            s6, _CP0_STATUS
207
 
208
        /* Clear the software interrupt in the core. */
209
        mfc0            s6, _CP0_CAUSE
210
        addiu       s4,zero,-257
211
        and                     s6, s6, s4
212
        mtc0            s6, _CP0_CAUSE
213
 
214
        /* Clear the interrupt in the interrupt controller. */
215
        la                      s6, IFS0CLR
216
        addiu           s4, zero, 2
217
        sw                      s4, (s6)
218
 
219
        jal                     vTaskSwitchContext
220
        nop
221
 
222
        /* Clear the interrupt mask again.  The saved status value is still in s7. */
223
        mtc0            s7, _CP0_STATUS
224
 
225
        /* Restore the stack pointer from the TCB. */
226
        la                      s0, pxCurrentTCB
227
        lw                      s0, (s0)
228
        lw                      s5, (s0)
229
 
230
        /* Restore the rest of the context. */
231
        lw                      s0, 8(s5)
232
        mtlo            s0
233
        lw                      s0, 12(s5)
234
        mthi            s0
235
        lw                      $1, 16(s5)
236
        lw                      s0, 20(s5)
237
        lw                      s1, 24(s5)
238
        lw                      s2, 28(s5)
239
        lw                      s3, 32(s5)
240
        lw                      s4, 36(s5)
241
        /* s5 is loaded later. */
242
        lw                      s6, 44(s5)
243
        lw                      s7, 48(s5)
244
        lw                      v0, 52(s5)
245
        lw                      v1, 56(s5)
246
        lw                      a0, 60(s5)
247
        lw                      a1, 64(s5)
248
        lw                      a2, 68(s5)
249
        lw                      a3, 72(s5)
250
        lw                      t0, 76(s5)
251
        lw                      t1, 80(s5)
252
        lw                      t2, 84(s5)
253
        lw                      t3, 88(s5)
254
        lw                      t4, 92(s5)
255
        lw                      t5, 96(s5)
256
        lw                      t6, 100(s5)
257
        lw                      t7, 104(s5)
258
        lw                      t8, 108(s5)
259
        lw                      t9, 112(s5)
260
        lw                      s8, 116(s5)
261
        lw                      ra, 120(s5)
262
 
263
        /* Protect access to the k registers, and others. */
264
        di
265
 
266
        /* Set nesting back to zero.  As the lowest priority interrupt this
267
        interrupt cannot have nested. */
268
        la                      k0, uxInterruptNesting
269
        sw                      zero, 0(k0)
270
 
271
        /* Switch back to use the real stack pointer. */
272
        add                     sp, zero, s5
273
 
274
        /* Restore the real s5 value. */
275
        lw                      s5, 40(sp)
276
 
277
        /* Pop the status and epc values. */
278
        lw                      k1, portSTATUS_STACK_LOCATION(sp)
279
        lw                      k0, portEPC_STACK_LOCATION(sp)
280
 
281
        /* Remove stack frame. */
282
        addiu           sp,     sp,     portCONTEXT_SIZE
283
 
284
        mtc0            k1, _CP0_STATUS
285
        ehb
286
        mtc0            k0, _CP0_EPC
287
        eret
288
        nop
289
 
290
        .end            vPortYieldISR
291
 
292
 
293
 

powered by: WebSVN 2.1.0

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