2 FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution and was contributed
\r
8 to the project by Technolution B.V. (www.technolution.nl,
\r
9 freertos-riscv@technolution.eu) under the terms of the FreeRTOS
\r
10 contributors license.
\r
12 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
13 the terms of the GNU General Public License (version 2) as published by the
\r
14 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
\r
16 ***************************************************************************
\r
17 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
18 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
19 >>! obliged to provide the source code for proprietary components !<<
\r
20 >>! outside of the FreeRTOS kernel. !<<
\r
21 ***************************************************************************
\r
23 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
24 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
25 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
26 link: http://www.freertos.org/a00114.html
\r
28 ***************************************************************************
\r
30 * FreeRTOS provides completely free yet professionally developed, *
\r
31 * robust, strictly quality controlled, supported, and cross *
\r
32 * platform software that is more than just the market leader, it *
\r
33 * is the industry''s de facto standard. *
\r
35 * Help yourself get started quickly while simultaneously helping *
\r
36 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
37 * tutorial book, reference manual, or both: *
\r
38 * http://www.FreeRTOS.org/Documentation *
\r
40 ***************************************************************************
\r
42 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
43 the FAQ page "My application does not run, what could be wrong?". Have you
\r
44 defined configASSERT()?
\r
46 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
47 embedded software for free we request you assist our global community by
\r
48 participating in the support forum.
\r
50 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
51 be as productive as possible as early as possible. Now you can receive
\r
52 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
53 Ltd, and the world's leading authority on the world's leading RTOS.
\r
55 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
56 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
57 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
59 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
60 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
62 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
63 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
64 licenses offer ticketed support, indemnification and commercial middleware.
\r
66 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
67 engineered and independently SIL3 certified version for use in safety and
\r
68 mission critical applications that require provable dependability.
\r
84 #define MSTATUS_PRV1 0x1800
\r
86 .global portSAVE_CONTEXT
\r
87 .global portRESTORE_CONTEXT
\r
89 //.global xPortStartScheduler
\r
91 .global vTaskIncrementTick
\r
92 .global vPortEndScheduler
\r
96 /* Macro for saving task context */
\r
97 .macro portSAVE_CONTEXT
\r
98 .global pxCurrentTCB
\r
99 /* make room in stack */
\r
100 addi sp, sp, -REGBYTES * 32
\r
104 STORE x2, 1 * REGBYTES(sp)
\r
105 STORE x3, 2 * REGBYTES(sp)
\r
106 STORE x4, 3 * REGBYTES(sp)
\r
107 STORE x5, 4 * REGBYTES(sp)
\r
108 STORE x6, 5 * REGBYTES(sp)
\r
109 STORE x7, 6 * REGBYTES(sp)
\r
110 STORE x8, 7 * REGBYTES(sp)
\r
111 STORE x9, 8 * REGBYTES(sp)
\r
112 STORE x10, 9 * REGBYTES(sp)
\r
113 STORE x11, 10 * REGBYTES(sp)
\r
114 STORE x12, 11 * REGBYTES(sp)
\r
115 STORE x13, 12 * REGBYTES(sp)
\r
116 STORE x14, 13 * REGBYTES(sp)
\r
117 STORE x15, 14 * REGBYTES(sp)
\r
118 STORE x16, 15 * REGBYTES(sp)
\r
119 STORE x17, 16 * REGBYTES(sp)
\r
120 STORE x18, 17 * REGBYTES(sp)
\r
121 STORE x19, 18 * REGBYTES(sp)
\r
122 STORE x20, 19 * REGBYTES(sp)
\r
123 STORE x21, 20 * REGBYTES(sp)
\r
124 STORE x22, 21 * REGBYTES(sp)
\r
125 STORE x23, 22 * REGBYTES(sp)
\r
126 STORE x24, 23 * REGBYTES(sp)
\r
127 STORE x25, 24 * REGBYTES(sp)
\r
128 STORE x26, 25 * REGBYTES(sp)
\r
129 STORE x27, 26 * REGBYTES(sp)
\r
130 STORE x28, 27 * REGBYTES(sp)
\r
131 STORE x29, 28 * REGBYTES(sp)
\r
132 STORE x30, 29 * REGBYTES(sp)
\r
133 STORE x31, 30 * REGBYTES(sp)
\r
135 /* Store current stackpointer in task control block (TCB) */
\r
136 LOAD t0, pxCurrentTCB //pointer
\r
140 /* Saves current error program counter (EPC) as task program counter */
\r
141 .macro portSAVE_EPC
\r
143 STORE t0, 31 * REGBYTES(sp)
\r
146 /* Saves current return adress (RA) as task program counter */
\r
148 STORE ra, 31 * REGBYTES(sp)
\r
151 /* Macro for restoring task context */
\r
152 .macro portRESTORE_CONTEXT
\r
154 .global pxCurrentTCB
\r
155 /* Load stack pointer from the current TCB */
\r
156 LOAD sp, pxCurrentTCB
\r
159 /* Load task program counter */
\r
160 LOAD t0, 31 * REGBYTES(sp)
\r
163 /* Restore registers,
\r
164 Skip global pointer because that does not change */
\r
166 LOAD x4, 3 * REGBYTES(sp)
\r
167 LOAD x5, 4 * REGBYTES(sp)
\r
168 LOAD x6, 5 * REGBYTES(sp)
\r
169 LOAD x7, 6 * REGBYTES(sp)
\r
170 LOAD x8, 7 * REGBYTES(sp)
\r
171 LOAD x9, 8 * REGBYTES(sp)
\r
172 LOAD x10, 9 * REGBYTES(sp)
\r
173 LOAD x11, 10 * REGBYTES(sp)
\r
174 LOAD x12, 11 * REGBYTES(sp)
\r
175 LOAD x13, 12 * REGBYTES(sp)
\r
176 LOAD x14, 13 * REGBYTES(sp)
\r
177 LOAD x15, 14 * REGBYTES(sp)
\r
178 LOAD x16, 15 * REGBYTES(sp)
\r
179 LOAD x17, 16 * REGBYTES(sp)
\r
180 LOAD x18, 17 * REGBYTES(sp)
\r
181 LOAD x19, 18 * REGBYTES(sp)
\r
182 LOAD x20, 19 * REGBYTES(sp)
\r
183 LOAD x21, 20 * REGBYTES(sp)
\r
184 LOAD x22, 21 * REGBYTES(sp)
\r
185 LOAD x23, 22 * REGBYTES(sp)
\r
186 LOAD x24, 23 * REGBYTES(sp)
\r
187 LOAD x25, 24 * REGBYTES(sp)
\r
188 LOAD x26, 25 * REGBYTES(sp)
\r
189 LOAD x27, 26 * REGBYTES(sp)
\r
190 LOAD x28, 27 * REGBYTES(sp)
\r
191 LOAD x29, 28 * REGBYTES(sp)
\r
192 LOAD x30, 29 * REGBYTES(sp)
\r
193 LOAD x31, 30 * REGBYTES(sp)
\r
195 addi sp, sp, REGBYTES * 32
\r
197 /* Enable global interupt */
\r
205 xPortStartScheduler:
\r
206 #ifdef __gracefulExit
\r
208 la t0, xStartContext
\r
210 STORE x2, 1 * REGBYTES(t0)
\r
211 STORE x3, 2 * REGBYTES(t0)
\r
212 STORE x4, 3 * REGBYTES(t0)
\r
213 STORE x5, 4 * REGBYTES(t0)
\r
214 STORE x6, 5 * REGBYTES(t0)
\r
215 STORE x7, 6 * REGBYTES(t0)
\r
216 STORE x8, 7 * REGBYTES(t0)
\r
217 STORE x9, 8 * REGBYTES(t0)
\r
218 STORE x10, 9 * REGBYTES(t0)
\r
219 STORE x11, 10 * REGBYTES(t0)
\r
220 STORE x12, 11 * REGBYTES(t0)
\r
221 STORE x13, 12 * REGBYTES(t0)
\r
222 STORE x14, 13 * REGBYTES(t0)
\r
223 STORE x15, 14 * REGBYTES(t0)
\r
224 STORE x16, 15 * REGBYTES(t0)
\r
225 STORE x17, 16 * REGBYTES(t0)
\r
226 STORE x18, 17 * REGBYTES(t0)
\r
227 STORE x19, 18 * REGBYTES(t0)
\r
228 STORE x20, 19 * REGBYTES(t0)
\r
229 STORE x21, 20 * REGBYTES(t0)
\r
230 STORE x22, 21 * REGBYTES(t0)
\r
231 STORE x23, 22 * REGBYTES(t0)
\r
232 STORE x24, 23 * REGBYTES(t0)
\r
233 STORE x25, 24 * REGBYTES(t0)
\r
234 STORE x26, 25 * REGBYTES(t0)
\r
235 STORE x27, 26 * REGBYTES(t0)
\r
236 STORE x28, 27 * REGBYTES(t0)
\r
237 STORE x29, 28 * REGBYTES(t0)
\r
238 STORE x30, 29 * REGBYTES(t0)
\r
239 STORE x31, 30 * REGBYTES(t0)
\r
241 jal vPortSetupTimer
\r
242 portRESTORE_CONTEXT
\r
246 #ifdef __gracefulExit
\r
247 /* Load current context from xStartContext */
\r
248 la t0, xStartContext
\r
250 LOAD x2, 1 * REGBYTES(t0)
\r
251 LOAD x3, 2 * REGBYTES(t0)
\r
252 LOAD x4, 3 * REGBYTES(t0)
\r
253 LOAD x5, 4 * REGBYTES(t0)
\r
254 LOAD x6, 5 * REGBYTES(t0)
\r
255 LOAD x7, 6 * REGBYTES(t0)
\r
256 LOAD x8, 7 * REGBYTES(t0)
\r
257 LOAD x9, 8 * REGBYTES(t0)
\r
258 LOAD x10, 9 * REGBYTES(t0)
\r
259 LOAD x11, 10 * REGBYTES(t0)
\r
260 LOAD x12, 11 * REGBYTES(t0)
\r
261 LOAD x13, 12 * REGBYTES(t0)
\r
262 LOAD x14, 13 * REGBYTES(t0)
\r
263 LOAD x15, 14 * REGBYTES(t0)
\r
264 LOAD x16, 15 * REGBYTES(t0)
\r
265 LOAD x17, 16 * REGBYTES(t0)
\r
266 LOAD x18, 17 * REGBYTES(t0)
\r
267 LOAD x19, 18 * REGBYTES(t0)
\r
268 LOAD x20, 19 * REGBYTES(t0)
\r
269 LOAD x21, 20 * REGBYTES(t0)
\r
270 LOAD x22, 21 * REGBYTES(t0)
\r
271 LOAD x23, 22 * REGBYTES(t0)
\r
272 LOAD x24, 23 * REGBYTES(t0)
\r
273 LOAD x25, 24 * REGBYTES(t0)
\r
274 LOAD x26, 25 * REGBYTES(t0)
\r
275 LOAD x27, 26 * REGBYTES(t0)
\r
276 LOAD x28, 27 * REGBYTES(t0)
\r
277 LOAD x29, 28 * REGBYTES(t0)
\r
278 LOAD x30, 39 * REGBYTES(t0)
\r
279 LOAD x31, 30 * REGBYTES(t0)
\r