]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm
Update version number to V8.0.0 (without the release candidate number).
[freertos] / FreeRTOS / Source / portable / Tasking / ARM_CM4F / port_asm.asm
1 ;/*\r
2 ;    FreeRTOS V8.0.0 - Copyright (C) 2014 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         msr basepri, r0\r
96         bl vTaskSwitchContext\r
97         mov r0, #0\r
98         msr basepri, r0\r
99         ldmia sp!, {r3}\r
100 \r
101         ;The first item in pxCurrentTCB is the task top of stack.\r
102         ldr r1, [r3]\r
103         ldr r0, [r1]\r
104 \r
105         ;Pop the core registers.\r
106         ldmia r0!, {r4-r11, r14}\r
107 \r
108         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
109         tst r14, #0x10\r
110         it eq\r
111         vldmiaeq r0!, {s16-s31}\r
112 \r
113         msr psp, r0\r
114         isb\r
115         bx r14\r
116 \r
117         .size   _vector_14, $-_vector_14\r
118         .endsec\r
119 \r
120 ;-----------------------------------------------------------\r
121 \r
122 ; This function is an XMC4000 silicon errata workaround.  It will get used when\r
123 ; the SILICON_BUG_PMC_CM_001 linker macro is defined.\r
124         .section .text\r
125         .thumb\r
126         .align 4\r
127 _lc_ref__vector_pp_14: .type func\r
128 \r
129         mrs r0, psp\r
130         isb\r
131 \r
132         ;Get the location of the current TCB.\r
133         ldr.w   r3, =pxCurrentTCB\r
134         ldr     r2, [r3]\r
135 \r
136         ;Is the task using the FPU context?  If so, push high vfp registers.\r
137         tst r14, #0x10\r
138         it eq\r
139         vstmdbeq r0!, {s16-s31}\r
140 \r
141         ;Save the core registers.\r
142         stmdb r0!, {r4-r11, r14}\r
143 \r
144         ;Save the new top of stack into the first member of the TCB.\r
145         str r0, [r2]\r
146 \r
147         stmdb sp!, {r3}\r
148         ldr.w r0, =ulMaxSyscallInterruptPriorityConst\r
149         msr basepri, r0\r
150         bl vTaskSwitchContext\r
151         mov r0, #0\r
152         msr basepri, r0\r
153         ldmia sp!, {r3}\r
154 \r
155         ;The first item in pxCurrentTCB is the task top of stack.\r
156         ldr r1, [r3]\r
157         ldr r0, [r1]\r
158 \r
159         ;Pop the core registers.\r
160         ldmia r0!, {r4-r11, r14}\r
161 \r
162         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
163         tst r14, #0x10\r
164         it eq\r
165         vldmiaeq r0!, {s16-s31}\r
166 \r
167         msr psp, r0\r
168         isb\r
169         push { lr }\r
170         pop { pc } ; XMC4000 specific errata workaround.  Do not used "bx lr" here.\r
171 \r
172         .size   _lc_ref__vector_pp_14, $-_lc_ref__vector_pp_14\r
173         .endsec\r
174 \r
175 ;-----------------------------------------------------------\r
176 \r
177         .section .text\r
178         .thumb\r
179         .align 4\r
180 SVC_Handler: .type func\r
181         ;Get the location of the current TCB.\r
182         ldr.w   r3, =pxCurrentTCB\r
183         ldr r1, [r3]\r
184         ldr r0, [r1]\r
185         ;Pop the core registers.\r
186         ldmia r0!, {r4-r11, r14}\r
187         msr psp, r0\r
188         isb\r
189         mov r0, #0\r
190         msr     basepri, r0\r
191         bx r14\r
192         .size   SVC_Handler, $-SVC_Handler\r
193         .endsec\r
194 \r
195 ;-----------------------------------------------------------\r
196 \r
197         .section .text\r
198         .thumb\r
199         .align 4\r
200 vPortStartFirstTask .type func\r
201         ;Use the NVIC offset register to locate the stack.\r
202         ldr.w r0, =0xE000ED08\r
203         ldr r0, [r0]\r
204         ldr r0, [r0]\r
205         ;Set the msp back to the start of the stack.\r
206         msr msp, r0\r
207         ;Call SVC to start the first task.\r
208         cpsie i\r
209         dsb\r
210         isb\r
211         svc 0\r
212         .size   vPortStartFirstTask, $-vPortStartFirstTask\r
213         .endsec\r
214 \r
215 ;-----------------------------------------------------------\r
216 \r
217         .section .text\r
218         .thumb\r
219         .align 4\r
220 vPortEnableVFP .type func\r
221         ;The FPU enable bits are in the CPACR.\r
222         ldr.w r0, =0xE000ED88\r
223         ldr     r1, [r0]\r
224 \r
225         ;Enable CP10 and CP11 coprocessors, then save back.\r
226         orr     r1, r1, #( 0xf << 20 )\r
227         str r1, [r0]\r
228         bx      r14\r
229         .size   vPortEnableVFP, $-vPortEnableVFP\r
230         .endsec\r
231 \r
232 ;-----------------------------------------------------------\r
233 \r
234         .section .text\r
235         .thumb\r
236         .align 4\r
237 ulPortSetInterruptMask:\r
238         mrs r0, basepri\r
239         ldr.w r1, =ulMaxSyscallInterruptPriorityConst\r
240         msr basepri, r1\r
241         bx r14\r
242         .size   ulPortSetInterruptMask, $-ulPortSetInterruptMask\r
243         .endsec\r
244 \r
245 ;-----------------------------------------------------------\r
246 \r
247         .section .text\r
248         .thumb\r
249         .align 4\r
250 vPortClearInterruptMask:\r
251         msr basepri, r0\r
252         bx r14\r
253         .size   vPortClearInterruptMask, $-vPortClearInterruptMask\r
254         .endsec\r
255 \r
256 ;-----------------------------------------------------------\r
257 \r
258         .end\r
259 \r