]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s
Prepare for V7.2.0 release.
[freertos] / FreeRTOS / Source / portable / GCC / MicroBlaze / portasm.s
1 /*\r
2     FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
3 \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43     \r
44     ***************************************************************************\r
45      *                                                                       *\r
46      *    Having a problem?  Start by reading the FAQ "My application does   *\r
47      *    not run, what could be wrong?                                      *\r
48      *                                                                       *\r
49      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
50      *                                                                       *\r
51     ***************************************************************************\r
52 \r
53     \r
54     http://www.FreeRTOS.org - Documentation, training, latest information, \r
55     license and contact details.\r
56     \r
57     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
58     including FreeRTOS+Trace - an indispensable productivity tool.\r
59 \r
60     Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
61     the code with commercial support, indemnification, and middleware, under \r
62     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
63     provide a safety engineered and independently SIL3 certified version under \r
64     the SafeRTOS brand: http://www.SafeRTOS.com.\r
65 */\r
66         .extern pxCurrentTCB\r
67         .extern vTaskISRHandler\r
68         .extern vTaskSwitchContext\r
69         .extern uxCriticalNesting\r
70         .extern pulISRStack\r
71 \r
72         .global __FreeRTOS_interrupt_handler\r
73         .global VPortYieldASM\r
74         .global vStartFirstTask\r
75 \r
76 \r
77 .macro portSAVE_CONTEXT\r
78         /* Make room for the context on the stack. */\r
79         addik r1, r1, -132\r
80         /* Save r31 so it can then be used. */\r
81         swi r31, r1, 4\r
82         /* Copy the msr into r31 - this is stacked later. */\r
83         mfs r31, rmsr\r
84         /* Stack general registers. */\r
85         swi r30, r1, 12\r
86         swi r29, r1, 16\r
87         swi r28, r1, 20\r
88         swi r27, r1, 24\r
89         swi r26, r1, 28\r
90         swi r25, r1, 32\r
91         swi r24, r1, 36\r
92         swi r23, r1, 40\r
93         swi r22, r1, 44\r
94         swi r21, r1, 48\r
95         swi r20, r1, 52\r
96         swi r19, r1, 56\r
97         swi r18, r1, 60\r
98         swi r17, r1, 64\r
99         swi r16, r1, 68\r
100         swi r15, r1, 72\r
101         swi r13, r1, 80\r
102         swi r12, r1, 84\r
103         swi r11, r1, 88\r
104         swi r10, r1, 92\r
105         swi r9, r1, 96\r
106         swi r8, r1, 100\r
107         swi r7, r1, 104\r
108         swi r6, r1, 108\r
109         swi r5, r1, 112\r
110         swi r4, r1, 116\r
111         swi r3, r1, 120\r
112         swi r2, r1, 124\r
113         /* Stack the critical section nesting value. */\r
114         lwi r3, r0, uxCriticalNesting\r
115         swi r3, r1, 128\r
116         /* Save the top of stack value to the TCB. */\r
117         lwi r3, r0, pxCurrentTCB\r
118         sw      r1, r0, r3\r
119         \r
120         .endm\r
121 \r
122 .macro portRESTORE_CONTEXT\r
123         /* Load the top of stack value from the TCB. */\r
124         lwi r3, r0, pxCurrentTCB\r
125         lw      r1, r0, r3      \r
126         /* Restore the general registers. */\r
127         lwi r31, r1, 4          \r
128         lwi r30, r1, 12         \r
129         lwi r29, r1, 16 \r
130         lwi r28, r1, 20 \r
131         lwi r27, r1, 24 \r
132         lwi r26, r1, 28 \r
133         lwi r25, r1, 32 \r
134         lwi r24, r1, 36 \r
135         lwi r23, r1, 40 \r
136         lwi r22, r1, 44 \r
137         lwi r21, r1, 48 \r
138         lwi r20, r1, 52 \r
139         lwi r19, r1, 56 \r
140         lwi r18, r1, 60 \r
141         lwi r17, r1, 64 \r
142         lwi r16, r1, 68 \r
143         lwi r15, r1, 72 \r
144         lwi r14, r1, 76 \r
145         lwi r13, r1, 80 \r
146         lwi r12, r1, 84 \r
147         lwi r11, r1, 88 \r
148         lwi r10, r1, 92 \r
149         lwi r9, r1, 96  \r
150         lwi r8, r1, 100 \r
151         lwi r7, r1, 104\r
152         lwi r6, r1, 108\r
153         lwi r5, r1, 112\r
154         lwi r4, r1, 116\r
155         lwi r2, r1, 124\r
156 \r
157         /* Load the critical nesting value. */\r
158         lwi r3, r1, 128\r
159         swi r3, r0, uxCriticalNesting\r
160 \r
161         /* Obtain the MSR value from the stack. */\r
162         lwi r3, r1, 8\r
163 \r
164         /* Are interrupts enabled in the MSR?  If so return using an return from \r
165         interrupt instruction to ensure interrupts are enabled only once the task\r
166         is running again. */\r
167         andi r3, r3, 2\r
168         beqid r3, 36\r
169         or r0, r0, r0\r
170 \r
171         /* Reload the rmsr from the stack, clear the enable interrupt bit in the\r
172         value before saving back to rmsr register, then return enabling interrupts\r
173         as we return. */\r
174         lwi r3, r1, 8\r
175         andi r3, r3, ~2\r
176         mts rmsr, r3\r
177         lwi r3, r1, 120\r
178         addik r1, r1, 132\r
179         rtid r14, 0\r
180         or r0, r0, r0\r
181 \r
182         /* Reload the rmsr from the stack, place it in the rmsr register, and\r
183         return without enabling interrupts. */\r
184         lwi r3, r1, 8\r
185         mts rmsr, r3\r
186         lwi r3, r1, 120\r
187         addik r1, r1, 132\r
188         rtsd r14, 0\r
189         or r0, r0, r0\r
190 \r
191         .endm\r
192 \r
193         .text\r
194         .align  2\r
195 \r
196 \r
197 __FreeRTOS_interrupt_handler:\r
198         portSAVE_CONTEXT\r
199         /* Entered via an interrupt so interrupts must be enabled in msr. */\r
200         ori r31, r31, 2\r
201         /* Stack msr. */\r
202         swi r31, r1, 8\r
203         /* Stack the return address.  As we entered via an interrupt we do\r
204         not need to modify the return address prior to stacking. */\r
205         swi r14, r1, 76\r
206         /* Now switch to use the ISR stack. */\r
207         lwi r3, r0, pulISRStack\r
208         add r1, r3, r0\r
209         bralid r15, vTaskISRHandler\r
210         or r0, r0, r0\r
211         portRESTORE_CONTEXT\r
212 \r
213 \r
214 VPortYieldASM:\r
215         portSAVE_CONTEXT\r
216         /* Stack msr. */\r
217         swi r31, r1, 8\r
218         /* Modify the return address so we return to the instruction after the\r
219         exception. */\r
220         addi r14, r14, 8\r
221         swi r14, r1, 76\r
222         /* Now switch to use the ISR stack. */\r
223         lwi r3, r0, pulISRStack\r
224         add r1, r3, r0\r
225         bralid r15, vTaskSwitchContext\r
226         or r0, r0, r0\r
227         portRESTORE_CONTEXT\r
228 \r
229 vStartFirstTask:\r
230         portRESTORE_CONTEXT\r
231         \r
232         \r
233 \r
234 \r
235 \r
236 \r