]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RX600/port_asm.s
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / IAR / RX600 / 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\r
99                 POP                     R15\r
100 \r
101                 /* Accumulator high 32 bits. */\r
102                 MVTACHI         R15\r
103                 POP                     R15\r
104 \r
105                 /* Floating point status word. */\r
106                 MVTC            R15, FPSW\r
107 \r
108                 /* R1 to R15 - R0 is not included as it is the SP. */\r
109                 POPM            R1-R15\r
110 \r
111                 /* This pops the remaining registers. */\r
112                 RTE\r
113                 NOP\r
114                 NOP\r
115 \r
116 /*-----------------------------------------------------------*/\r
117 \r
118 /* The software interrupt - overwrite the default 'weak' definition. */\r
119 ___interrupt_27:\r
120 \r
121                 /* Re-enable interrupts. */\r
122                 SETPSW          I\r
123 \r
124                 /* Move the data that was automatically pushed onto the interrupt stack when\r
125                 the interrupt occurred from the interrupt stack to the user stack.\r
126 \r
127                 R15 is saved before it is clobbered. */\r
128                 PUSH.L          R15\r
129 \r
130                 /* Read the user stack pointer. */\r
131                 MVFC            USP, R15\r
132 \r
133                 /* Move the address down to the data being moved. */\r
134                 SUB                     #12, R15\r
135                 MVTC            R15, USP\r
136 \r
137                 /* Copy the data across, R15, then PC, then PSW. */\r
138                 MOV.L           [ R0 ], [ R15 ]\r
139                 MOV.L           4[ R0 ], 4[ R15 ]\r
140                 MOV.L           8[ R0 ], 8[ R15 ]\r
141 \r
142                 /* Move the interrupt stack pointer to its new correct position. */\r
143                 ADD             #12, R0\r
144 \r
145                 /* All the rest of the registers are saved directly to the user stack. */\r
146                 SETPSW          U\r
147 \r
148                 /* Save the rest of the general registers (R15 has been saved already). */\r
149                 PUSHM           R1-R14\r
150 \r
151                 /* Save the FPSW and accumulator. */\r
152                 MVFC            FPSW, R15\r
153                 PUSH.L          R15\r
154                 MVFACHI         R15\r
155                 PUSH.L          R15\r
156 \r
157                 /* Middle word. */\r
158                 MVFACMI R15\r
159 \r
160                 /* Shifted left as it is restored to the low order word. */\r
161                 SHLL            #16, R15\r
162                 PUSH.L          R15\r
163 \r
164                 /* Save the stack pointer to the TCB. */\r
165                 MOV.L           #_pxCurrentTCB, R15\r
166                 MOV.L           [ R15 ], R15\r
167                 MOV.L           R0, [ R15 ]\r
168 \r
169                 /* Ensure the interrupt mask is set to the syscall priority while the kernel\r
170                 structures are being accessed. */\r
171                 MVTIPL          #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
172 \r
173                 /* Select the next task to run. */\r
174                 BSR.A           _vTaskSwitchContext\r
175 \r
176                 /* Reset the interrupt mask as no more data structure access is required. */\r
177                 MVTIPL          #configKERNEL_INTERRUPT_PRIORITY\r
178 \r
179                 /* Load the stack pointer of the task that is now selected as the Running\r
180                 state task from its TCB. */\r
181                 MOV.L           #_pxCurrentTCB,R15\r
182                 MOV.L           [ R15 ], R15\r
183                 MOV.L           [ R15 ], R0\r
184 \r
185                 /* Restore the context of the new task.  The PSW (Program Status Word) and\r
186                 PC will be popped by the RTE instruction. */\r
187                 POP                     R15\r
188                 MVTACLO         R15\r
189                 POP                     R15\r
190                 MVTACHI         R15\r
191                 POP                     R15\r
192                 MVTC            R15, FPSW\r
193                 POPM            R1-R15\r
194                 RTE\r
195                 NOP\r
196                 NOP\r
197 \r
198 /*-----------------------------------------------------------*/\r
199 \r
200                 END\r
201 \r