]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / Tasking / ARM_CM4F / port_asm.asm
1 ;/*\r
2 ;    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3 ;    All rights reserved\r
4 ;\r
5 ;\r
6 ;    ***************************************************************************\r
7 ;     *                                                                       *\r
8 ;     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
9 ;     *    Complete, revised, and edited pdf reference manuals are also       *\r
10 ;     *    available.                                                         *\r
11 ;     *                                                                       *\r
12 ;     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
13 ;     *    ensuring you get running as quickly as possible and with an        *\r
14 ;     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
15 ;     *    the FreeRTOS project to continue with its mission of providing     *\r
16 ;     *    professional grade, cross platform, de facto standard solutions    *\r
17 ;     *    for microcontrollers - completely free of charge!                  *\r
18 ;     *                                                                       *\r
19 ;     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
20 ;     *                                                                       *\r
21 ;     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
22 ;     *                                                                       *\r
23 ;    ***************************************************************************\r
24 ;\r
25 ;\r
26 ;    This file is part of the FreeRTOS distribution.\r
27 ;\r
28 ;    FreeRTOS is free software; you can redistribute it and/or modify it under\r
29 ;    the terms of the GNU General Public License (version 2) as published by the\r
30 ;    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
31 ;    >>>NOTE<<< The modification to the GPL is included to allow you to\r
32 ;    distribute a combined work that includes FreeRTOS without being obliged to\r
33 ;    provide the source code for proprietary components outside of the FreeRTOS\r
34 ;    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
35 ;    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
36 ;    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
37 ;    more details. You should have received a copy of the GNU General Public\r
38 ;    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
39 ;    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
40 ;    by writing to Richard Barry, contact details for whom are available on the\r
41 ;    FreeRTOS WEB site.\r
42 ;\r
43 ;    1 tab == 4 spaces!\r
44 ;\r
45 ;    http://www.FreeRTOS.org - Documentation, latest information, license and\r
46 ;    contact details.\r
47 ;\r
48 ;    http://www.SafeRTOS.com - A version that is certified for use in safety\r
49 ;    critical systems.\r
50 ;\r
51 ;    http://www.OpenRTOS.com - Commercial support, development, porting,\r
52 ;    licensing and training services.\r
53 ;*/\r
54 \r
55 \r
56         .extern pxCurrentTCB\r
57         .extern vTaskSwitchContext\r
58         .extern ulMaxSyscallInterruptPriorityConst\r
59 \r
60         .global _vector_14\r
61         .global _lc_ref__vector_pp_14\r
62         .global SVC_Handler\r
63         .global vPortStartFirstTask\r
64         .global vPortEnableVFP\r
65         .global ulPortSetInterruptMask\r
66         .global vPortClearInterruptMask\r
67 \r
68 ;-----------------------------------------------------------\r
69 \r
70         .section .text\r
71         .thumb\r
72         .align 4\r
73 _vector_14: .type func\r
74 \r
75         mrs r0, psp\r
76         isb\r
77 \r
78         ;Get the location of the current TCB.\r
79         ldr.w   r3, =pxCurrentTCB\r
80         ldr     r2, [r3]\r
81 \r
82         ;Is the task using the FPU context?  If so, push high vfp registers.\r
83         tst r14, #0x10\r
84         it eq\r
85         vstmdbeq r0!, {s16-s31}\r
86 \r
87         ;Save the core registers.\r
88         stmdb r0!, {r4-r11, r14}\r
89 \r
90         ;Save the new top of stack into the first member of the TCB.\r
91         str r0, [r2]\r
92 \r
93         stmdb sp!, {r3}\r
94         ldr.w r0, =ulMaxSyscallInterruptPriorityConst\r
95         ldr r0, [r0]\r
96         msr basepri, r0\r
97         bl vTaskSwitchContext\r
98         mov r0, #0\r
99         msr basepri, r0\r
100         ldmia sp!, {r3}\r
101 \r
102         ;The first item in pxCurrentTCB is the task top of stack.\r
103         ldr r1, [r3]\r
104         ldr r0, [r1]\r
105 \r
106         ;Pop the core registers.\r
107         ldmia r0!, {r4-r11, r14}\r
108 \r
109         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
110         tst r14, #0x10\r
111         it eq\r
112         vldmiaeq r0!, {s16-s31}\r
113 \r
114         msr psp, r0\r
115         isb\r
116         bx r14\r
117 \r
118         .size   _vector_14, $-_vector_14\r
119         .endsec\r
120 \r
121 ;-----------------------------------------------------------\r
122 \r
123 ; This function is an XMC4000 silicon errata workaround.  It will get used when\r
124 ; the SILICON_BUG_PMC_CM_001 linker macro is defined.\r
125         .section .text\r
126         .thumb\r
127         .align 4\r
128 _lc_ref__vector_pp_14: .type func\r
129 \r
130         mrs r0, psp\r
131         isb\r
132 \r
133         ;Get the location of the current TCB.\r
134         ldr.w   r3, =pxCurrentTCB\r
135         ldr     r2, [r3]\r
136 \r
137         ;Is the task using the FPU context?  If so, push high vfp registers.\r
138         tst r14, #0x10\r
139         it eq\r
140         vstmdbeq r0!, {s16-s31}\r
141 \r
142         ;Save the core registers.\r
143         stmdb r0!, {r4-r11, r14}\r
144 \r
145         ;Save the new top of stack into the first member of the TCB.\r
146         str r0, [r2]\r
147 \r
148         stmdb sp!, {r3}\r
149         ldr.w r0, =ulMaxSyscallInterruptPriorityConst\r
150         ldr r0, [r0]\r
151         msr basepri, r0\r
152         bl vTaskSwitchContext\r
153         mov r0, #0\r
154         msr basepri, r0\r
155         ldmia sp!, {r3}\r
156 \r
157         ;The first item in pxCurrentTCB is the task top of stack.\r
158         ldr r1, [r3]\r
159         ldr r0, [r1]\r
160 \r
161         ;Pop the core registers.\r
162         ldmia r0!, {r4-r11, r14}\r
163 \r
164         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
165         tst r14, #0x10\r
166         it eq\r
167         vldmiaeq r0!, {s16-s31}\r
168 \r
169         msr psp, r0\r
170         isb\r
171         push { lr }\r
172         pop { pc } ; XMC4000 specific errata workaround.  Do not used "bx lr" here.\r
173 \r
174         .size   _lc_ref__vector_pp_14, $-_lc_ref__vector_pp_14\r
175         .endsec\r
176 \r
177 ;-----------------------------------------------------------\r
178 \r
179         .section .text\r
180         .thumb\r
181         .align 4\r
182 SVC_Handler: .type func\r
183         ;Get the location of the current TCB.\r
184         ldr.w   r3, =pxCurrentTCB\r
185         ldr r1, [r3]\r
186         ldr r0, [r1]\r
187         ;Pop the core registers.\r
188         ldmia r0!, {r4-r11, r14}\r
189         msr psp, r0\r
190         isb\r
191         mov r0, #0\r
192         msr     basepri, r0\r
193         bx r14\r
194         .size   SVC_Handler, $-SVC_Handler\r
195         .endsec\r
196 \r
197 ;-----------------------------------------------------------\r
198 \r
199         .section .text\r
200         .thumb\r
201         .align 4\r
202 vPortStartFirstTask .type func\r
203         ;Use the NVIC offset register to locate the stack.\r
204         ldr.w r0, =0xE000ED08\r
205         ldr r0, [r0]\r
206         ldr r0, [r0]\r
207         ;Set the msp back to the start of the stack.\r
208         msr msp, r0\r
209         ;Call SVC to start the first task.\r
210         cpsie i\r
211         cpsie f\r
212         dsb\r
213         isb\r
214         svc 0\r
215         .size   vPortStartFirstTask, $-vPortStartFirstTask\r
216         .endsec\r
217 \r
218 ;-----------------------------------------------------------\r
219 \r
220         .section .text\r
221         .thumb\r
222         .align 4\r
223 vPortEnableVFP .type func\r
224         ;The FPU enable bits are in the CPACR.\r
225         ldr.w r0, =0xE000ED88\r
226         ldr     r1, [r0]\r
227 \r
228         ;Enable CP10 and CP11 coprocessors, then save back.\r
229         orr     r1, r1, #( 0xf << 20 )\r
230         str r1, [r0]\r
231         bx      r14\r
232         .size   vPortEnableVFP, $-vPortEnableVFP\r
233         .endsec\r
234 \r
235 ;-----------------------------------------------------------\r
236 \r
237         .section .text\r
238         .thumb\r
239         .align 4\r
240 ulPortSetInterruptMask:\r
241         mrs r0, basepri\r
242         ldr.w r1, =ulMaxSyscallInterruptPriorityConst\r
243         ldr r1, [r1]\r
244         msr basepri, r1\r
245         bx r14\r
246         .size   ulPortSetInterruptMask, $-ulPortSetInterruptMask\r
247         .endsec\r
248 \r
249 ;-----------------------------------------------------------\r
250 \r
251         .section .text\r
252         .thumb\r
253         .align 4\r
254 vPortClearInterruptMask:\r
255         msr basepri, r0\r
256         bx r14\r
257         .size   vPortClearInterruptMask, $-vPortClearInterruptMask\r
258         .endsec\r
259 \r
260 ;-----------------------------------------------------------\r
261 \r
262         .end\r
263 \r