]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RXv2/port_asm.s
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / IAR / RXv2 / port_asm.s
1 /*\r
2     FreeRTOS V9.0.0rc2 - Copyright (C) 2016 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 \r
70 #include "PriorityDefinitions.h"\r
71 \r
72         PUBLIC _prvStartFirstTask\r
73         PUBLIC ___interrupt_27\r
74 \r
75         EXTERN _pxCurrentTCB\r
76         EXTERN _vTaskSwitchContext\r
77 \r
78         RSEG CODE:CODE(4)\r
79 \r
80 _prvStartFirstTask:\r
81 \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
85                 SETPSW          U\r
86 \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
90                 MOV.L           [R15], R15\r
91                 MOV.L           [R15], R0\r
92 \r
93                 /* Restore the registers from the stack of the task pointed to by\r
94                 pxCurrentTCB. */\r
95                 POP                     R15\r
96 \r
97                 /* Accumulator low 32 bits. */\r
98                 MVTACLO         R15, A0\r
99                 POP                     R15\r
100 \r
101                 /* Accumulator high 32 bits. */\r
102                 MVTACHI         R15, A0\r
103                 POP                     R15\r
104 \r
105                 /* Accumulator guard. */\r
106                 MVTACGU         R15, A0\r
107                 POP                     R15\r
108 \r
109                 /* Accumulator low 32 bits. */\r
110                 MVTACLO         R15, A1\r
111                 POP                     R15\r
112 \r
113                 /* Accumulator high 32 bits. */\r
114                 MVTACHI         R15, A1\r
115                 POP                     R15\r
116 \r
117                 /* Accumulator guard. */\r
118                 MVTACGU         R15, A1\r
119                 POP                     R15\r
120 \r
121                 /* Floating point status word. */\r
122                 MVTC            R15, FPSW\r
123 \r
124                 /* R1 to R15 - R0 is not included as it is the SP. */\r
125                 POPM            R1-R15\r
126 \r
127                 /* This pops the remaining registers. */\r
128                 RTE\r
129                 NOP\r
130                 NOP\r
131 \r
132 /*-----------------------------------------------------------*/\r
133 \r
134 /* The software interrupt - overwrite the default 'weak' definition. */\r
135 ___interrupt_27:\r
136 \r
137                 /* Re-enable interrupts. */\r
138                 SETPSW          I\r
139 \r
140                 /* Move the data that was automatically pushed onto the interrupt stack when\r
141                 the interrupt occurred from the interrupt stack to the user stack.\r
142 \r
143                 R15 is saved before it is clobbered. */\r
144                 PUSH.L          R15\r
145 \r
146                 /* Read the user stack pointer. */\r
147                 MVFC            USP, R15\r
148 \r
149                 /* Move the address down to the data being moved. */\r
150                 SUB             #12, R15\r
151                 MVTC            R15, USP\r
152 \r
153                 /* Copy the data across, R15, then PC, then PSW. */\r
154                 MOV.L           [ R0 ], [ R15 ]\r
155                 MOV.L           4[ R0 ], 4[ R15 ]\r
156                 MOV.L           8[ R0 ], 8[ R15 ]\r
157 \r
158                 /* Move the interrupt stack pointer to its new correct position. */\r
159                 ADD             #12, R0\r
160 \r
161                 /* All the rest of the registers are saved directly to the user stack. */\r
162                 SETPSW          U\r
163 \r
164                 /* Save the rest of the general registers (R15 has been saved already). */\r
165                 PUSHM           R1-R14\r
166 \r
167                 /* Save the FPSW and accumulator. */\r
168                 MVFC            FPSW, R15\r
169                 PUSH.L          R15\r
170                 MVFACGU         #0, A1, R15\r
171                 PUSH.L          R15\r
172                 MVFACHI         #0, A1, R15\r
173                 PUSH.L          R15\r
174                 /* Low order word. */\r
175                 MVFACLO         #0, A1, R15\r
176                 PUSH.L          R15\r
177                 MVFACGU         #0, A0, R15\r
178                 PUSH.L          R15\r
179                 MVFACHI         #0, A0, R15\r
180                 PUSH.L          R15\r
181                 /* Low order word. */\r
182                 MVFACLO         #0, A0, R15\r
183                 PUSH.L          R15\r
184 \r
185                 /* Save the stack pointer to the TCB. */\r
186                 MOV.L           #_pxCurrentTCB, R15\r
187                 MOV.L           [ R15 ], R15\r
188                 MOV.L           R0, [ R15 ]\r
189 \r
190                 /* Ensure the interrupt mask is set to the syscall priority while the kernel\r
191                 structures are being accessed. */\r
192                 MVTIPL          #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
193 \r
194                 /* Select the next task to run. */\r
195                 BSR.A           _vTaskSwitchContext\r
196 \r
197                 /* Reset the interrupt mask as no more data structure access is required. */\r
198                 MVTIPL          #configKERNEL_INTERRUPT_PRIORITY\r
199 \r
200                 /* Load the stack pointer of the task that is now selected as the Running\r
201                 state task from its TCB. */\r
202                 MOV.L           #_pxCurrentTCB,R15\r
203                 MOV.L           [ R15 ], R15\r
204                 MOV.L           [ R15 ], R0\r
205 \r
206                 /* Restore the context of the new task.  The PSW (Program Status Word) and\r
207                 PC will be popped by the RTE instruction. */\r
208                 POP             R15\r
209 \r
210                 /* Accumulator low 32 bits. */\r
211                 MVTACLO R15, A0\r
212                 POP             R15\r
213 \r
214                 /* Accumulator high 32 bits. */\r
215                 MVTACHI R15, A0\r
216                 POP             R15\r
217 \r
218                 /* Accumulator guard. */\r
219                 MVTACGU R15, A0\r
220                 POP             R15\r
221 \r
222                 /* Accumulator low 32 bits. */\r
223                 MVTACLO R15, A1\r
224                 POP             R15\r
225 \r
226                 /* Accumulator high 32 bits. */\r
227                 MVTACHI R15, A1\r
228                 POP             R15\r
229 \r
230                 /* Accumulator guard. */\r
231                 MVTACGU R15, A1\r
232                 POP             R15\r
233                 MVTC            R15, FPSW\r
234                 POPM            R1-R15\r
235                 RTE\r
236                 NOP\r
237                 NOP\r
238 \r
239 /*-----------------------------------------------------------*/\r
240 \r
241                 END\r
242 \r