2 ; * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 ; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 ; * SPDX-License-Identifier: MIT
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:
14 ; * The above copyright notice and this permission notice shall be included in all
15 ; * copies or substantial portions of the Software.
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.
24 ; * https://www.FreeRTOS.org
25 ; * https://github.com/FreeRTOS
33 IMPORT ulCriticalNesting
35 IMPORT ulPortTaskHasFPUContext
36 IMPORT ulAsmAPIPriorityMask
43 ; Save the LR and SPSR onto the system mode stack before switching to
44 ; system mode to save the remaining system mode registers
49 ; Push the critical nesting count
50 LDR R2, =ulCriticalNesting
54 ; Does the task have a floating point context that needs saving? If
55 ; ulPortTaskHasFPUContext is 0 then no.
56 LDR R2, =ulPortTaskHasFPUContext
60 ; Save the floating point context, if any
66 ; Save ulPortTaskHasFPUContext itself
69 ; Save the stack pointer in the TCB
76 ; /**********************************************************************/
81 ; Set the SP to point to the stack of the task being restored.
86 ; Is there a floating point context to restore? If the restored
87 ; ulPortTaskHasFPUContext is zero then no.
88 LDR R0, =ulPortTaskHasFPUContext
93 ; Restore the floating point context, if any
99 ; Restore the critical section nesting depth
100 LDR R0, =ulCriticalNesting
104 ; Ensure the priority mask is correct for the critical nesting depth
108 LDRNE R4, =ulAsmAPIPriorityMask
111 ; Restore all system mode registers other than the SP (which is already
115 ; Return to the task code, loading CPSR on the way.