2 * FreeRTOS Kernel V10.2.1
\r
3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\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
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\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
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
29 EXTERN usCriticalNesting
\r
31 #include "FreeRTOSConfig.h"
\r
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
34 ; Context save and restore macro definitions
\r
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
37 portSAVE_CONTEXT MACRO
\r
39 add -0x0C,sp ; prepare stack to save necessary values
\r
40 st.w lp,8[sp] ; store LP to stack
\r
42 st.w lp,4[sp] ; store EIPC to stack
\r
44 st.w lp,0[sp] ; store EIPSW to stack
\r
45 #if configDATA_MODE == 1 ; Using the Tiny data model
\r
46 prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers
\r
63 #else ; Using the Small/Large data model
\r
64 prepare {r20,r21,r22,r23,r24,r26,r27,r28,r29,r30},72,sp ; save general purpose registers
\r
80 #endif /* configDATA_MODE */
\r
83 MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack
\r
84 ld.w lw1(usCriticalNesting)[r1],r2
\r
86 MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB
\r
87 ld.w lw1(pxCurrentTCB)[r1],r2
\r
92 portRESTORE_CONTEXT MACRO
\r
94 MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address
\r
95 ld.w lw1(pxCurrentTCB)[r1],sp
\r
97 ld.w 0[r1],sp ; load stackpointer
\r
98 MOV sp,ep ; set stack pointer to element pointer
\r
99 sld.w 0[ep],r1 ; load usCriticalNesting value from stack
\r
100 MOVHI hi1(usCriticalNesting),r0,r2
\r
101 st.w r1,lw1(usCriticalNesting)[r2]
\r
102 sld.w 4[ep],r1 ; restore general purpose registers
\r
104 #if configDATA_MODE == 1 ; Using Tiny data model
\r
121 dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}
\r
122 #else ; Using Small/Large data model
\r
138 dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30}
\r
139 #endif /* configDATA_MODE */
\r
140 ld.w 0[sp],lp ; restore EIPSW from stack
\r
142 ld.w 4[sp],lp ; restore EIPC from stack
\r
144 ld.w 8[sp],lp ; restore LP from stack
\r
145 add 0x0C,sp ; set SP to right position
\r