|
1 |
| -; /* |
2 |
| - * ; * FreeRTOS Kernel <DEVELOPMENT BRANCH> |
3 |
| - * ; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
4 |
| - * ; * |
5 |
| - * ; * SPDX-License-Identifier: MIT |
6 |
| - * ; * |
7 |
| - * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of |
8 |
| - * ; * this software and associated documentation files (the "Software"), to deal in |
9 |
| - * ; * the Software without restriction, including without limitation the rights to |
10 |
| - * ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
11 |
| - * ; * the Software, and to permit persons to whom the Software is furnished to do so, |
12 |
| - * ; * subject to the following conditions: |
13 |
| - * ; * |
14 |
| - * ; * The above copyright notice and this permission notice shall be included in all |
15 |
| - * ; * copies or substantial portions of the Software. |
16 |
| - * ; * |
17 |
| - * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 |
| - * ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
19 |
| - * ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
20 |
| - * ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
21 |
| - * ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
22 |
| - * ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 |
| - * ; * |
24 |
| - * ; * https://www.FreeRTOS.org |
25 |
| - * ; * https://github.com/FreeRTOS |
26 |
| - * ; * |
27 |
| - * ; */ |
28 |
| - |
29 |
| -EXTERN vTaskSwitchContext |
30 |
| -EXTERN ulCriticalNesting |
31 |
| -EXTERN pxCurrentTCB |
32 |
| -EXTERN ulPortTaskHasFPUContext |
33 |
| -EXTERN ulAsmAPIPriorityMask |
| 1 | +;/* |
| 2 | +; * FreeRTOS Kernel <DEVELOPMENT BRANCH> |
| 3 | +; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | +; * |
| 5 | +; * SPDX-License-Identifier: MIT |
| 6 | +; * |
| 7 | +; * Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 8 | +; * this software and associated documentation files (the "Software"), to deal in |
| 9 | +; * the Software without restriction, including without limitation the rights to |
| 10 | +; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 11 | +; * the Software, and to permit persons to whom the Software is furnished to do so, |
| 12 | +; * subject to the following conditions: |
| 13 | +; * |
| 14 | +; * The above copyright notice and this permission notice shall be included in all |
| 15 | +; * copies or substantial portions of the Software. |
| 16 | +; * |
| 17 | +; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 19 | +; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 20 | +; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 21 | +; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | +; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | +; * |
| 24 | +; * https://www.FreeRTOS.org |
| 25 | +; * https://github.com/FreeRTOS |
| 26 | +; * |
| 27 | +; */ |
| 28 | + |
| 29 | + EXTERN vTaskSwitchContext |
| 30 | + EXTERN ulCriticalNesting |
| 31 | + EXTERN pxCurrentTCB |
| 32 | + EXTERN ulPortTaskHasFPUContext |
| 33 | + EXTERN ulAsmAPIPriorityMask |
34 | 34 |
|
35 | 35 | portSAVE_CONTEXT macro
|
36 | 36 |
|
37 |
| -; |
38 |
| -Save the LR and SPSR onto the system mode stack before switching to |
39 |
| -; |
40 |
| -system mode to save the remaining system mode registers |
41 |
| -SRSDB sp !, # SYS_MODE |
42 |
| - CPS # SYS_MODE |
43 |
| - PUSH { |
44 |
| - R0 - R12, R14 |
45 |
| -} |
46 |
| - |
47 |
| -; |
48 |
| -Push the critical nesting count |
49 |
| -LDR R2, = ulCriticalNesting |
50 |
| - LDR R1, [ R2 ] |
51 |
| -PUSH { |
52 |
| - R1 |
53 |
| -} |
54 |
| - |
55 |
| -; |
56 |
| -Does the task have a floating point context that needs saving ? If |
57 |
| -; |
58 |
| -ulPortTaskHasFPUContext is 0 then no. |
59 |
| - LDR R2, = ulPortTaskHasFPUContext |
60 |
| - LDR R3, [ R2 ] |
61 |
| -CMP R3, # 0 |
62 |
| - |
63 |
| -; |
64 |
| -Save the floating point context, |
65 |
| - |
66 |
| -if any |
67 |
| -FMRXNE R1, FPSCR |
68 |
| - VPUSHNE { |
69 |
| - D0 - D15 |
70 |
| -} |
71 |
| - |
| 37 | + ; Save the LR and SPSR onto the system mode stack before switching to |
| 38 | + ; system mode to save the remaining system mode registers |
| 39 | + SRSDB sp!, #SYS_MODE |
| 40 | + CPS #SYS_MODE |
| 41 | + PUSH {R0-R12, R14} |
| 42 | + |
| 43 | + ; Push the critical nesting count |
| 44 | + LDR R2, =ulCriticalNesting |
| 45 | + LDR R1, [R2] |
| 46 | + PUSH {R1} |
| 47 | + |
| 48 | + ; Does the task have a floating point context that needs saving? If |
| 49 | + ; ulPortTaskHasFPUContext is 0 then no. |
| 50 | + LDR R2, =ulPortTaskHasFPUContext |
| 51 | + LDR R3, [R2] |
| 52 | + CMP R3, #0 |
| 53 | + |
| 54 | + ; Save the floating point context, if any |
| 55 | + FMRXNE R1, FPSCR |
| 56 | + VPUSHNE {D0-D15} |
72 | 57 | #if configFPU_D32 == 1
|
73 |
| -VPUSHNE { |
74 |
| - D16 - D31 |
75 |
| -} |
76 |
| -#endif; configFPU_D32 |
77 |
| -PUSHNE { |
78 |
| - R1 |
79 |
| -} |
80 |
| - |
81 |
| -; |
82 |
| -Save ulPortTaskHasFPUContext itself |
83 |
| - PUSH { |
84 |
| - R3 |
85 |
| -} |
86 |
| - |
87 |
| -; |
88 |
| -Save the stack pointer in the TCB |
89 |
| -LDR R0, = pxCurrentTCB |
90 |
| - LDR R1, [ R0 ] |
91 |
| -STR SP, [ R1 ] |
92 |
| - |
93 |
| -endm |
| 58 | + VPUSHNE {D16-D31} |
| 59 | +#endif ; configFPU_D32 |
| 60 | + PUSHNE {R1} |
| 61 | + |
| 62 | + ; Save ulPortTaskHasFPUContext itself |
| 63 | + PUSH {R3} |
| 64 | + |
| 65 | + ; Save the stack pointer in the TCB |
| 66 | + LDR R0, =pxCurrentTCB |
| 67 | + LDR R1, [R0] |
| 68 | + STR SP, [R1] |
| 69 | + |
| 70 | + endm |
94 | 71 |
|
95 | 72 | ; /**********************************************************************/
|
96 | 73 |
|
97 | 74 | portRESTORE_CONTEXT macro
|
98 | 75 |
|
99 |
| -; |
100 |
| -Set the SP to point to the stack of the task being restored. |
101 |
| - LDR R0, = pxCurrentTCB |
102 |
| - LDR R1, [ R0 ] |
103 |
| -LDR SP, [ R1 ] |
104 |
| - |
105 |
| -; |
106 |
| -Is there a floating point context to restore ? If the restored |
107 |
| -; |
108 |
| -ulPortTaskHasFPUContext is zero then no. |
109 |
| - LDR R0, = ulPortTaskHasFPUContext |
110 |
| - POP { |
111 |
| - R1 |
112 |
| -} |
113 |
| -STR R1, [ R0 ] |
114 |
| -CMP R1, # 0 |
115 |
| - |
116 |
| -; |
117 |
| -Restore the floating point context, |
118 |
| - |
119 |
| -if any |
120 |
| - POPNE { |
121 |
| - R0 |
122 |
| -} |
| 76 | + ; Set the SP to point to the stack of the task being restored. |
| 77 | + LDR R0, =pxCurrentTCB |
| 78 | + LDR R1, [R0] |
| 79 | + LDR SP, [R1] |
| 80 | + |
| 81 | + ; Is there a floating point context to restore? If the restored |
| 82 | + ; ulPortTaskHasFPUContext is zero then no. |
| 83 | + LDR R0, =ulPortTaskHasFPUContext |
| 84 | + POP {R1} |
| 85 | + STR R1, [R0] |
| 86 | + CMP R1, #0 |
123 | 87 |
|
| 88 | + ; Restore the floating point context, if any |
| 89 | + POPNE {R0} |
124 | 90 | #if configFPU_D32 == 1
|
125 |
| -VPOPNE { |
126 |
| - D16 - D31 |
127 |
| -} |
128 |
| -#endif; configFPU_D32 |
129 |
| -VPOPNE { |
130 |
| - D0 - D15 |
131 |
| -} |
132 |
| -VMSRNE FPSCR, R0 |
133 |
| - |
134 |
| -; |
135 |
| -Restore the critical section nesting depth |
136 |
| -LDR R0, = ulCriticalNesting |
137 |
| - POP { |
138 |
| - R1 |
139 |
| -} |
140 |
| -STR R1, [ R0 ] |
141 |
| - |
142 |
| -; |
143 |
| -Restore all system mode registers other than the SP( which is already |
144 |
| - ; |
145 |
| - being used ) |
146 |
| -POP |
147 |
| -{ |
148 |
| - R0 - R12, R14 |
149 |
| -} |
150 |
| - |
151 |
| -Return to the task code, loading CPSR on the way.CPSR has the interrupt |
152 |
| -; |
153 |
| -enable bit set appropriately |
154 |
| - |
155 |
| -for the task about to execute. |
156 |
| - RFEIA sp ! |
157 |
| - |
158 |
| -endm |
| 91 | + VPOPNE {D16-D31} |
| 92 | +#endif ; configFPU_D32 |
| 93 | + VPOPNE {D0-D15} |
| 94 | + VMSRNE FPSCR, R0 |
| 95 | + |
| 96 | + ; Restore the critical section nesting depth |
| 97 | + LDR R0, =ulCriticalNesting |
| 98 | + POP {R1} |
| 99 | + STR R1, [R0] |
| 100 | + |
| 101 | + ; Restore all system mode registers other than the SP (which is already |
| 102 | + ; being used) |
| 103 | + POP {R0-R12, R14} |
| 104 | + |
| 105 | + ; Return to the task code, loading CPSR on the way. CPSR has the interrupt |
| 106 | + ; enable bit set appropriately for the task about to execute. |
| 107 | + RFEIA sp! |
| 108 | + |
| 109 | + endm |
0 commit comments