]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s
Update version number in preparation for official V8.2.0 release.
[freertos] / FreeRTOS / Source / portable / GCC / MicroBlaze / portasm.s
1 /*\r
2     FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
12 \r
13         ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18         ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40         the FAQ page "My application does not run, what could be wrong?".  Have you\r
41         defined configASSERT()?\r
42 \r
43         http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44         embedded software for free we request you assist our global community by\r
45         participating in the support forum.\r
46 \r
47         http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48         be as productive as possible as early as possible.  Now you can receive\r
49         FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50         Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69         .extern pxCurrentTCB\r
70         .extern vTaskISRHandler\r
71         .extern vTaskSwitchContext\r
72         .extern uxCriticalNesting\r
73         .extern pulISRStack\r
74 \r
75         .global __FreeRTOS_interrupt_handler\r
76         .global VPortYieldASM\r
77         .global vStartFirstTask\r
78 \r
79 \r
80 .macro portSAVE_CONTEXT\r
81         /* Make room for the context on the stack. */\r
82         addik r1, r1, -132\r
83         /* Save r31 so it can then be used. */\r
84         swi r31, r1, 4\r
85         /* Copy the msr into r31 - this is stacked later. */\r
86         mfs r31, rmsr\r
87         /* Stack general registers. */\r
88         swi r30, r1, 12\r
89         swi r29, r1, 16\r
90         swi r28, r1, 20\r
91         swi r27, r1, 24\r
92         swi r26, r1, 28\r
93         swi r25, r1, 32\r
94         swi r24, r1, 36\r
95         swi r23, r1, 40\r
96         swi r22, r1, 44\r
97         swi r21, r1, 48\r
98         swi r20, r1, 52\r
99         swi r19, r1, 56\r
100         swi r18, r1, 60\r
101         swi r17, r1, 64\r
102         swi r16, r1, 68\r
103         swi r15, r1, 72\r
104         swi r13, r1, 80\r
105         swi r12, r1, 84\r
106         swi r11, r1, 88\r
107         swi r10, r1, 92\r
108         swi r9, r1, 96\r
109         swi r8, r1, 100\r
110         swi r7, r1, 104\r
111         swi r6, r1, 108\r
112         swi r5, r1, 112\r
113         swi r4, r1, 116\r
114         swi r3, r1, 120\r
115         swi r2, r1, 124\r
116         /* Stack the critical section nesting value. */\r
117         lwi r3, r0, uxCriticalNesting\r
118         swi r3, r1, 128\r
119         /* Save the top of stack value to the TCB. */\r
120         lwi r3, r0, pxCurrentTCB\r
121         sw      r1, r0, r3\r
122         \r
123         .endm\r
124 \r
125 .macro portRESTORE_CONTEXT\r
126         /* Load the top of stack value from the TCB. */\r
127         lwi r3, r0, pxCurrentTCB\r
128         lw      r1, r0, r3      \r
129         /* Restore the general registers. */\r
130         lwi r31, r1, 4          \r
131         lwi r30, r1, 12         \r
132         lwi r29, r1, 16 \r
133         lwi r28, r1, 20 \r
134         lwi r27, r1, 24 \r
135         lwi r26, r1, 28 \r
136         lwi r25, r1, 32 \r
137         lwi r24, r1, 36 \r
138         lwi r23, r1, 40 \r
139         lwi r22, r1, 44 \r
140         lwi r21, r1, 48 \r
141         lwi r20, r1, 52 \r
142         lwi r19, r1, 56 \r
143         lwi r18, r1, 60 \r
144         lwi r17, r1, 64 \r
145         lwi r16, r1, 68 \r
146         lwi r15, r1, 72 \r
147         lwi r14, r1, 76 \r
148         lwi r13, r1, 80 \r
149         lwi r12, r1, 84 \r
150         lwi r11, r1, 88 \r
151         lwi r10, r1, 92 \r
152         lwi r9, r1, 96  \r
153         lwi r8, r1, 100 \r
154         lwi r7, r1, 104\r
155         lwi r6, r1, 108\r
156         lwi r5, r1, 112\r
157         lwi r4, r1, 116\r
158         lwi r2, r1, 124\r
159 \r
160         /* Load the critical nesting value. */\r
161         lwi r3, r1, 128\r
162         swi r3, r0, uxCriticalNesting\r
163 \r
164         /* Obtain the MSR value from the stack. */\r
165         lwi r3, r1, 8\r
166 \r
167         /* Are interrupts enabled in the MSR?  If so return using an return from \r
168         interrupt instruction to ensure interrupts are enabled only once the task\r
169         is running again. */\r
170         andi r3, r3, 2\r
171         beqid r3, 36\r
172         or r0, r0, r0\r
173 \r
174         /* Reload the rmsr from the stack, clear the enable interrupt bit in the\r
175         value before saving back to rmsr register, then return enabling interrupts\r
176         as we return. */\r
177         lwi r3, r1, 8\r
178         andi r3, r3, ~2\r
179         mts rmsr, r3\r
180         lwi r3, r1, 120\r
181         addik r1, r1, 132\r
182         rtid r14, 0\r
183         or r0, r0, r0\r
184 \r
185         /* Reload the rmsr from the stack, place it in the rmsr register, and\r
186         return without enabling interrupts. */\r
187         lwi r3, r1, 8\r
188         mts rmsr, r3\r
189         lwi r3, r1, 120\r
190         addik r1, r1, 132\r
191         rtsd r14, 0\r
192         or r0, r0, r0\r
193 \r
194         .endm\r
195 \r
196         .text\r
197         .align  2\r
198 \r
199 \r
200 __FreeRTOS_interrupt_handler:\r
201         portSAVE_CONTEXT\r
202         /* Entered via an interrupt so interrupts must be enabled in msr. */\r
203         ori r31, r31, 2\r
204         /* Stack msr. */\r
205         swi r31, r1, 8\r
206         /* Stack the return address.  As we entered via an interrupt we do\r
207         not need to modify the return address prior to stacking. */\r
208         swi r14, r1, 76\r
209         /* Now switch to use the ISR stack. */\r
210         lwi r3, r0, pulISRStack\r
211         add r1, r3, r0\r
212         bralid r15, vTaskISRHandler\r
213         or r0, r0, r0\r
214         portRESTORE_CONTEXT\r
215 \r
216 \r
217 VPortYieldASM:\r
218         portSAVE_CONTEXT\r
219         /* Stack msr. */\r
220         swi r31, r1, 8\r
221         /* Modify the return address so we return to the instruction after the\r
222         exception. */\r
223         addi r14, r14, 8\r
224         swi r14, r1, 76\r
225         /* Now switch to use the ISR stack. */\r
226         lwi r3, r0, pulISRStack\r
227         add r1, r3, r0\r
228         bralid r15, vTaskSwitchContext\r
229         or r0, r0, r0\r
230         portRESTORE_CONTEXT\r
231 \r
232 vStartFirstTask:\r
233         portRESTORE_CONTEXT\r
234         \r
235         \r
236 \r
237 \r
238 \r
239 \r