2 FreeRTOS V9.0.0rc1 - Copyright (C) 2016 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.
\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
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
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
25 ***************************************************************************
\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
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
37 ***************************************************************************
\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
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
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
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
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
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
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
70 #include "PriorityDefinitions.h"
\r
72 PUBLIC _prvStartFirstTask
\r
73 PUBLIC ___interrupt_27
\r
75 EXTERN _pxCurrentTCB
\r
76 EXTERN _vTaskSwitchContext
\r
82 /* When starting the scheduler there is nothing that needs moving to the
\r
83 interrupt stack because the function is not called from an interrupt.
\r
84 Just ensure the current stack is the user stack. */
\r
87 /* Obtain the location of the stack associated with which ever task
\r
88 pxCurrentTCB is currently pointing to. */
\r
89 MOV.L #_pxCurrentTCB, R15
\r
93 /* Restore the registers from the stack of the task pointed to by
\r
97 /* Accumulator low 32 bits. */
\r
101 /* Accumulator high 32 bits. */
\r
104 /* R1 to R15 - R0 is not included as it is the SP. */
\r
107 /* This pops the remaining registers. */
\r
112 /*-----------------------------------------------------------*/
\r
114 /* The software interrupt - overwrite the default 'weak' definition. */
\r
117 /* Re-enable interrupts. */
\r
120 /* Move the data that was automatically pushed onto the interrupt stack when
\r
121 the interrupt occurred from the interrupt stack to the user stack.
\r
123 R15 is saved before it is clobbered. */
\r
126 /* Read the user stack pointer. */
\r
129 /* Move the address down to the data being moved. */
\r
133 /* Copy the data across, R15, then PC, then PSW. */
\r
134 MOV.L [ R0 ], [ R15 ]
\r
135 MOV.L 4[ R0 ], 4[ R15 ]
\r
136 MOV.L 8[ R0 ], 8[ R15 ]
\r
138 /* Move the interrupt stack pointer to its new correct position. */
\r
141 /* All the rest of the registers are saved directly to the user stack. */
\r
144 /* Save the rest of the general registers (R15 has been saved already). */
\r
147 /* Save the accumulator. */
\r
154 /* Shifted left as it is restored to the low order word. */
\r
158 /* Save the stack pointer to the TCB. */
\r
159 MOV.L #_pxCurrentTCB, R15
\r
163 /* Ensure the interrupt mask is set to the syscall priority while the kernel
\r
164 structures are being accessed. */
\r
165 MVTIPL #configMAX_SYSCALL_INTERRUPT_PRIORITY
\r
167 /* Select the next task to run. */
\r
168 BSR.A _vTaskSwitchContext
\r
170 /* Reset the interrupt mask as no more data structure access is required. */
\r
171 MVTIPL #configKERNEL_INTERRUPT_PRIORITY
\r
173 /* Load the stack pointer of the task that is now selected as the Running
\r
174 state task from its TCB. */
\r
175 MOV.L #_pxCurrentTCB,R15
\r
179 /* Restore the context of the new task. The PSW (Program Status Word) and
\r
180 PC will be popped by the RTE instruction. */
\r
190 /*-----------------------------------------------------------*/
\r