]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RX100/port_asm.s
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / IAR / RX100 / 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 \r
104                 /* R1 to R15 - R0 is not included as it is the SP. */\r
105                 POPM            R1-R15\r
106 \r
107                 /* This pops the remaining registers. */\r
108                 RTE\r
109                 NOP\r
110                 NOP\r
111 \r
112 /*-----------------------------------------------------------*/\r
113 \r
114 /* The software interrupt - overwrite the default 'weak' definition. */\r
115 ___interrupt_27:\r
116 \r
117                 /* Re-enable interrupts. */\r
118                 SETPSW          I\r
119 \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
122 \r
123                 R15 is saved before it is clobbered. */\r
124                 PUSH.L          R15\r
125 \r
126                 /* Read the user stack pointer. */\r
127                 MVFC            USP, R15\r
128 \r
129                 /* Move the address down to the data being moved. */\r
130                 SUB                     #12, R15\r
131                 MVTC            R15, USP\r
132 \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
137 \r
138                 /* Move the interrupt stack pointer to its new correct position. */\r
139                 ADD             #12, R0\r
140 \r
141                 /* All the rest of the registers are saved directly to the user stack. */\r
142                 SETPSW          U\r
143 \r
144                 /* Save the rest of the general registers (R15 has been saved already). */\r
145                 PUSHM           R1-R14\r
146 \r
147                 /* Save the accumulator. */\r
148                 MVFACHI         R15\r
149                 PUSH.L          R15\r
150 \r
151                 /* Middle word. */\r
152                 MVFACMI R15\r
153 \r
154                 /* Shifted left as it is restored to the low order word. */\r
155                 SHLL            #16, R15\r
156                 PUSH.L          R15\r
157 \r
158                 /* Save the stack pointer to the TCB. */\r
159                 MOV.L           #_pxCurrentTCB, R15\r
160                 MOV.L           [ R15 ], R15\r
161                 MOV.L           R0, [ R15 ]\r
162 \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
166 \r
167                 /* Select the next task to run. */\r
168                 BSR.A           _vTaskSwitchContext\r
169 \r
170                 /* Reset the interrupt mask as no more data structure access is required. */\r
171                 MVTIPL          #configKERNEL_INTERRUPT_PRIORITY\r
172 \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
176                 MOV.L           [ R15 ], R15\r
177                 MOV.L           [ R15 ], R0\r
178 \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
181                 POP                     R15\r
182                 MVTACLO         R15\r
183                 POP                     R15\r
184                 MVTACHI         R15\r
185                 POPM            R1-R15\r
186                 RTE\r
187                 NOP\r
188                 NOP\r
189 \r
190 /*-----------------------------------------------------------*/\r
191 \r
192                 END\r
193 \r