]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RX600/port_asm.s
Update version number.
[freertos] / FreeRTOS / Source / portable / IAR / RX600 / port_asm.s
1 /*\r
2     FreeRTOS V7.5.1 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
5 \r
6     ***************************************************************************\r
7      *                                                                       *\r
8      *    FreeRTOS provides completely free yet professionally developed,    *\r
9      *    robust, strictly quality controlled, supported, and cross          *\r
10      *    platform software that has become a de facto standard.             *\r
11      *                                                                       *\r
12      *    Help yourself get started quickly and support the FreeRTOS         *\r
13      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
14      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
15      *                                                                       *\r
16      *    Thank you!                                                         *\r
17      *                                                                       *\r
18     ***************************************************************************\r
19 \r
20     This file is part of the FreeRTOS distribution.\r
21 \r
22     FreeRTOS is free software; you can redistribute it and/or modify it under\r
23     the terms of the GNU General Public License (version 2) as published by the\r
24     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
25 \r
26     >>! NOTE: The modification to the GPL is included to allow you to distribute\r
27     >>! a combined work that includes FreeRTOS without being obliged to provide\r
28     >>! the source code for proprietary components outside of the FreeRTOS\r
29     >>! kernel.\r
30 \r
31     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
32     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
33     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
34     link: http://www.freertos.org/a00114.html\r
35 \r
36     1 tab == 4 spaces!\r
37 \r
38     ***************************************************************************\r
39      *                                                                       *\r
40      *    Having a problem?  Start by reading the FAQ "My application does   *\r
41      *    not run, what could be wrong?"                                     *\r
42      *                                                                       *\r
43      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
44      *                                                                       *\r
45     ***************************************************************************\r
46 \r
47     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
48     license and Real Time Engineers Ltd. contact details.\r
49 \r
50     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
51     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
52     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
53 \r
54     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
55     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
56     licenses offer ticketed support, indemnification and middleware.\r
57 \r
58     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
59     engineered and independently SIL3 certified version for use in safety and\r
60     mission critical applications that require provable dependability.\r
61 \r
62     1 tab == 4 spaces!\r
63 */\r
64 \r
65 #include "PriorityDefinitions.h"\r
66 \r
67         PUBLIC _prvStartFirstTask\r
68         PUBLIC ___interrupt_27\r
69 \r
70         EXTERN _pxCurrentTCB\r
71         EXTERN _vTaskSwitchContext\r
72 \r
73         RSEG CODE:CODE(4)\r
74 \r
75 _prvStartFirstTask:\r
76 \r
77                 /* When starting the scheduler there is nothing that needs moving to the\r
78                 interrupt stack because the function is not called from an interrupt.\r
79                 Just ensure the current stack is the user stack. */\r
80                 SETPSW          U\r
81 \r
82                 /* Obtain the location of the stack associated with which ever task\r
83                 pxCurrentTCB is currently pointing to. */\r
84                 MOV.L           #_pxCurrentTCB, R15\r
85                 MOV.L           [R15], R15\r
86                 MOV.L           [R15], R0\r
87 \r
88                 /* Restore the registers from the stack of the task pointed to by\r
89                 pxCurrentTCB. */\r
90                 POP                     R15\r
91 \r
92                 /* Accumulator low 32 bits. */\r
93                 MVTACLO         R15\r
94                 POP                     R15\r
95 \r
96                 /* Accumulator high 32 bits. */\r
97                 MVTACHI         R15\r
98                 POP                     R15\r
99 \r
100                 /* Floating point status word. */\r
101                 MVTC            R15, FPSW\r
102 \r
103                 /* R1 to R15 - R0 is not included as it is the SP. */\r
104                 POPM            R1-R15\r
105 \r
106                 /* This pops the remaining registers. */\r
107                 RTE\r
108                 NOP\r
109                 NOP\r
110 \r
111 /*-----------------------------------------------------------*/\r
112 \r
113 /* The software interrupt - overwrite the default 'weak' definition. */\r
114 ___interrupt_27:\r
115 \r
116                 /* Re-enable interrupts. */\r
117                 SETPSW          I\r
118 \r
119                 /* Move the data that was automatically pushed onto the interrupt stack when\r
120                 the interrupt occurred from the interrupt stack to the user stack.\r
121 \r
122                 R15 is saved before it is clobbered. */\r
123                 PUSH.L          R15\r
124 \r
125                 /* Read the user stack pointer. */\r
126                 MVFC            USP, R15\r
127 \r
128                 /* Move the address down to the data being moved. */\r
129                 SUB                     #12, R15\r
130                 MVTC            R15, USP\r
131 \r
132                 /* Copy the data across, R15, then PC, then PSW. */\r
133                 MOV.L           [ R0 ], [ R15 ]\r
134                 MOV.L           4[ R0 ], 4[ R15 ]\r
135                 MOV.L           8[ R0 ], 8[ R15 ]\r
136 \r
137                 /* Move the interrupt stack pointer to its new correct position. */\r
138                 ADD             #12, R0\r
139 \r
140                 /* All the rest of the registers are saved directly to the user stack. */\r
141                 SETPSW          U\r
142 \r
143                 /* Save the rest of the general registers (R15 has been saved already). */\r
144                 PUSHM           R1-R14\r
145 \r
146                 /* Save the FPSW and accumulator. */\r
147                 MVFC            FPSW, R15\r
148                 PUSH.L          R15\r
149                 MVFACHI         R15\r
150                 PUSH.L          R15\r
151 \r
152                 /* Middle word. */\r
153                 MVFACMI R15\r
154 \r
155                 /* Shifted left as it is restored to the low order word. */\r
156                 SHLL            #16, R15\r
157                 PUSH.L          R15\r
158 \r
159                 /* Save the stack pointer to the TCB. */\r
160                 MOV.L           #_pxCurrentTCB, R15\r
161                 MOV.L           [ R15 ], R15\r
162                 MOV.L           R0, [ R15 ]\r
163 \r
164                 /* Ensure the interrupt mask is set to the syscall priority while the kernel\r
165                 structures are being accessed. */\r
166                 MVTIPL          #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
167 \r
168                 /* Select the next task to run. */\r
169                 BSR.A           _vTaskSwitchContext\r
170 \r
171                 /* Reset the interrupt mask as no more data structure access is required. */\r
172                 MVTIPL          #configKERNEL_INTERRUPT_PRIORITY\r
173 \r
174                 /* Load the stack pointer of the task that is now selected as the Running\r
175                 state task from its TCB. */\r
176                 MOV.L           #_pxCurrentTCB,R15\r
177                 MOV.L           [ R15 ], R15\r
178                 MOV.L           [ R15 ], R0\r
179 \r
180                 /* Restore the context of the new task.  The PSW (Program Status Word) and\r
181                 PC will be popped by the RTE instruction. */\r
182                 POP                     R15\r
183                 MVTACLO         R15\r
184                 POP                     R15\r
185                 MVTACHI         R15\r
186                 POP                     R15\r
187                 MVTC            R15, FPSW\r
188                 POPM            R1-R15\r
189                 RTE\r
190                 NOP\r
191                 NOP\r
192 \r
193 /*-----------------------------------------------------------*/\r
194 \r
195                 END\r
196 \r