2 ; * FreeRTOS Kernel V11.2.0
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
29 IMPORT ulCriticalNesting ;
37 LDR R0, =pxCurrentTCB ; Set the LR to the task stack. The location was...
38 LDR R0, [R0] ; ... stored in pxCurrentTCB
41 LDR R0, =ulCriticalNesting ; The critical nesting depth is the first item on...
42 LDMFD LR!, {R1} ; ...the stack. Load it into the ulCriticalNesting var.
45 LDMFD LR!, {R0} ; Get the SPSR from the stack.
48 LDMFD LR, {R0-R14}^ ; Restore all system mode registers for the task.
51 LDR LR, [LR, #+60] ; Restore the return address
53 ; And return - correcting the offset in the LR to obtain ...
54 SUBS PC, LR, #4 ; ...the correct address.
58 ; /**********************************************************************/
64 STMDB SP!, {R0} ; Store R0 first as we need to use it.
66 STMDB SP,{SP}^ ; Set R0 to point to the task stack pointer.
71 STMDB R0!, {LR} ; Push the return address onto the stack.
72 MOV LR, R0 ; Now we have saved LR we can use it instead of R0.
73 LDMIA SP!, {R0} ; Pop R0 so we can save it onto the system mode stack.
75 STMDB LR,{R0-LR}^ ; Push all the system mode registers onto the task stack.
79 MRS R0, SPSR ; Push the SPSR onto the task stack.
82 LDR R0, =ulCriticalNesting ;
86 LDR R0, =pxCurrentTCB ; Store the new top of stack for the task.