2 * FreeRTOS Kernel V10.6.2
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
30 EXTERN usCriticalNesting
32 #include "FreeRTOSConfig.h"
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 ; Context save and restore macro definitions
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 portSAVE_CONTEXT MACRO
40 add -0x0C,sp ; prepare stack to save necessary values
41 st.w lp,8[sp] ; store LP to stack
43 st.w lp,4[sp] ; store EIPC to stack
45 st.w lp,0[sp] ; store EIPSW to stack
46 #if configDATA_MODE == 1 ; Using the Tiny data model
47 prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers
64 #else ; Using the Small/Large data model
65 prepare {r20,r21,r22,r23,r24,r26,r27,r28,r29,r30},72,sp ; save general purpose registers
81 #endif /* configDATA_MODE */
84 MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack
85 ld.w lw1(usCriticalNesting)[r1],r2
87 MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB
88 ld.w lw1(pxCurrentTCB)[r1],r2
93 portRESTORE_CONTEXT MACRO
95 MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address
96 ld.w lw1(pxCurrentTCB)[r1],sp
98 ld.w 0[r1],sp ; load stackpointer
99 MOV sp,ep ; set stack pointer to element pointer
100 sld.w 0[ep],r1 ; load usCriticalNesting value from stack
101 MOVHI hi1(usCriticalNesting),r0,r2
102 st.w r1,lw1(usCriticalNesting)[r2]
103 sld.w 4[ep],r1 ; restore general purpose registers
105 #if configDATA_MODE == 1 ; Using Tiny data model
122 dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}
123 #else ; Using Small/Large data model
139 dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30}
140 #endif /* configDATA_MODE */
141 ld.w 0[sp],lp ; restore EIPSW from stack
143 ld.w 4[sp],lp ; restore EIPC from stack
145 ld.w 8[sp],lp ; restore LP from stack
146 add 0x0C,sp ; set SP to right position