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