]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm
Update copyright date ready for tagging V10.1.0.
[freertos] / FreeRTOS / Source / portable / Tasking / ARM_CM4F / port_asm.asm
1 ;/*\r
2 ; * FreeRTOS Kernel V10.1.0\r
3 ; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4 ; *\r
5 ; * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6 ; * this software and associated documentation files (the "Software"), to deal in\r
7 ; * the Software without restriction, including without limitation the rights to\r
8 ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9 ; * the Software, and to permit persons to whom the Software is furnished to do so,\r
10 ; * subject to the following conditions:\r
11 ; *\r
12 ; * The above copyright notice and this permission notice shall be included in all\r
13 ; * copies or substantial portions of the Software.\r
14 ; *\r
15 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21 ; *\r
22 ; * http://www.FreeRTOS.org\r
23 ; * http://aws.amazon.com/freertos\r
24 ; *\r
25 ; * 1 tab == 4 spaces!\r
26 ; */\r
27 \r
28 \r
29         .extern pxCurrentTCB\r
30         .extern vTaskSwitchContext\r
31         .extern ulMaxSyscallInterruptPriorityConst\r
32 \r
33         .global _vector_14\r
34         .global _lc_ref__vector_pp_14\r
35         .global SVC_Handler\r
36         .global vPortStartFirstTask\r
37         .global vPortEnableVFP\r
38         .global ulPortSetInterruptMask\r
39         .global vPortClearInterruptMask\r
40 \r
41 ;-----------------------------------------------------------\r
42 \r
43         .section .text\r
44         .thumb\r
45         .align 4\r
46 _vector_14: .type func\r
47 \r
48         mrs r0, psp\r
49         isb\r
50 \r
51         ;Get the location of the current TCB.\r
52         ldr.w   r3, =pxCurrentTCB\r
53         ldr     r2, [r3]\r
54 \r
55         ;Is the task using the FPU context?  If so, push high vfp registers.\r
56         tst r14, #0x10\r
57         it eq\r
58         vstmdbeq r0!, {s16-s31}\r
59 \r
60         ;Save the core registers.\r
61         stmdb r0!, {r4-r11, r14}\r
62 \r
63         ;Save the new top of stack into the first member of the TCB.\r
64         str r0, [r2]\r
65 \r
66         stmdb sp!, {r0, r3}\r
67         ldr.w r0, =ulMaxSyscallInterruptPriorityConst\r
68         ldr r0, [r0]\r
69         msr basepri, r0\r
70         bl vTaskSwitchContext\r
71         mov r0, #0\r
72         msr basepri, r0\r
73         ldmia sp!, {r0, r3}\r
74 \r
75         ;The first item in pxCurrentTCB is the task top of stack.\r
76         ldr r1, [r3]\r
77         ldr r0, [r1]\r
78 \r
79         ;Pop the core registers.\r
80         ldmia r0!, {r4-r11, r14}\r
81 \r
82         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
83         tst r14, #0x10\r
84         it eq\r
85         vldmiaeq r0!, {s16-s31}\r
86 \r
87         msr psp, r0\r
88         isb\r
89         bx r14\r
90 \r
91         .size   _vector_14, $-_vector_14\r
92         .endsec\r
93 \r
94 ;-----------------------------------------------------------\r
95 \r
96 ; This function is an XMC4000 silicon errata workaround.  It will get used when\r
97 ; the SILICON_BUG_PMC_CM_001 linker macro is defined.\r
98         .section .text\r
99         .thumb\r
100         .align 4\r
101 _lc_ref__vector_pp_14: .type func\r
102 \r
103         mrs r0, psp\r
104         isb\r
105 \r
106         ;Get the location of the current TCB.\r
107         ldr.w   r3, =pxCurrentTCB\r
108         ldr     r2, [r3]\r
109 \r
110         ;Is the task using the FPU context?  If so, push high vfp registers.\r
111         tst r14, #0x10\r
112         it eq\r
113         vstmdbeq r0!, {s16-s31}\r
114 \r
115         ;Save the core registers.\r
116         stmdb r0!, {r4-r11, r14}\r
117 \r
118         ;Save the new top of stack into the first member of the TCB.\r
119         str r0, [r2]\r
120 \r
121         stmdb sp!, {r3}\r
122         ldr.w r0, =ulMaxSyscallInterruptPriorityConst\r
123         ldr r0, [r0]\r
124         msr basepri, r0\r
125         bl vTaskSwitchContext\r
126         mov r0, #0\r
127         msr basepri, r0\r
128         ldmia sp!, {r3}\r
129 \r
130         ;The first item in pxCurrentTCB is the task top of stack.\r
131         ldr r1, [r3]\r
132         ldr r0, [r1]\r
133 \r
134         ;Pop the core registers.\r
135         ldmia r0!, {r4-r11, r14}\r
136 \r
137         ;Is the task using the FPU context?  If so, pop the high vfp registers too.\r
138         tst r14, #0x10\r
139         it eq\r
140         vldmiaeq r0!, {s16-s31}\r
141 \r
142         msr psp, r0\r
143         isb\r
144         push { lr }\r
145         pop { pc } ; XMC4000 specific errata workaround.  Do not used "bx lr" here.\r
146 \r
147         .size   _lc_ref__vector_pp_14, $-_lc_ref__vector_pp_14\r
148         .endsec\r
149 \r
150 ;-----------------------------------------------------------\r
151 \r
152         .section .text\r
153         .thumb\r
154         .align 4\r
155 SVC_Handler: .type func\r
156         ;Get the location of the current TCB.\r
157         ldr.w   r3, =pxCurrentTCB\r
158         ldr r1, [r3]\r
159         ldr r0, [r1]\r
160         ;Pop the core registers.\r
161         ldmia r0!, {r4-r11, r14}\r
162         msr psp, r0\r
163         isb\r
164         mov r0, #0\r
165         msr     basepri, r0\r
166         bx r14\r
167         .size   SVC_Handler, $-SVC_Handler\r
168         .endsec\r
169 \r
170 ;-----------------------------------------------------------\r
171 \r
172         .section .text\r
173         .thumb\r
174         .align 4\r
175 vPortStartFirstTask .type func\r
176         ;Use the NVIC offset register to locate the stack.\r
177         ldr.w r0, =0xE000ED08\r
178         ldr r0, [r0]\r
179         ldr r0, [r0]\r
180         ;Set the msp back to the start of the stack.\r
181         msr msp, r0\r
182         ;Call SVC to start the first task.\r
183         cpsie i\r
184         cpsie f\r
185         dsb\r
186         isb\r
187         svc 0\r
188         .size   vPortStartFirstTask, $-vPortStartFirstTask\r
189         .endsec\r
190 \r
191 ;-----------------------------------------------------------\r
192 \r
193         .section .text\r
194         .thumb\r
195         .align 4\r
196 vPortEnableVFP .type func\r
197         ;The FPU enable bits are in the CPACR.\r
198         ldr.w r0, =0xE000ED88\r
199         ldr     r1, [r0]\r
200 \r
201         ;Enable CP10 and CP11 coprocessors, then save back.\r
202         orr     r1, r1, #( 0xf << 20 )\r
203         str r1, [r0]\r
204         bx      r14\r
205         .size   vPortEnableVFP, $-vPortEnableVFP\r
206         .endsec\r
207 \r
208 ;-----------------------------------------------------------\r
209 \r
210         .section .text\r
211         .thumb\r
212         .align 4\r
213 ulPortSetInterruptMask:\r
214         mrs r0, basepri\r
215         ldr.w r1, =ulMaxSyscallInterruptPriorityConst\r
216         ldr r1, [r1]\r
217         msr basepri, r1\r
218         bx r14\r
219         .size   ulPortSetInterruptMask, $-ulPortSetInterruptMask\r
220         .endsec\r
221 \r
222 ;-----------------------------------------------------------\r
223 \r
224         .section .text\r
225         .thumb\r
226         .align 4\r
227 vPortClearInterruptMask:\r
228         msr basepri, r0\r
229         bx r14\r
230         .size   vPortClearInterruptMask, $-vPortClearInterruptMask\r
231         .endsec\r
232 \r
233 ;-----------------------------------------------------------\r
234 \r
235         .end\r
236 \r