2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 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. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
30 EXTERN usCriticalNesting
\r
32 #include "FreeRTOSConfig.h"
\r
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
35 ; Context save and restore macro definitions
\r
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
38 portSAVE_CONTEXT MACRO
\r
40 add -0x0C,sp ; prepare stack to save necessary values
\r
41 st.w lp,8[sp] ; store LP to stack
\r
43 st.w lp,4[sp] ; store EIPC to stack
\r
45 st.w lp,0[sp] ; store EIPSW to stack
\r
46 #if configDATA_MODE == 1 ; Using the Tiny data model
\r
47 prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers
\r
64 #else ; Using the Small/Large data model
\r
65 prepare {r20,r21,r22,r23,r24,r26,r27,r28,r29,r30},72,sp ; save general purpose registers
\r
81 #endif /* configDATA_MODE */
\r
84 MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack
\r
85 ld.w lw1(usCriticalNesting)[r1],r2
\r
87 MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB
\r
88 ld.w lw1(pxCurrentTCB)[r1],r2
\r
93 portRESTORE_CONTEXT MACRO
\r
95 MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address
\r
96 ld.w lw1(pxCurrentTCB)[r1],sp
\r
98 ld.w 0[r1],sp ; load stackpointer
\r
99 MOV sp,ep ; set stack pointer to element pointer
\r
100 sld.w 0[ep],r1 ; load usCriticalNesting value from stack
\r
101 MOVHI hi1(usCriticalNesting),r0,r2
\r
102 st.w r1,lw1(usCriticalNesting)[r2]
\r
103 sld.w 4[ep],r1 ; restore general purpose registers
\r
105 #if configDATA_MODE == 1 ; Using Tiny data model
\r
122 dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}
\r
123 #else ; Using Small/Large data model
\r
139 dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30}
\r
140 #endif /* configDATA_MODE */
\r
141 ld.w 0[sp],lp ; restore EIPSW from stack
\r
143 ld.w 4[sp],lp ; restore EIPC from stack
\r
145 ld.w 8[sp],lp ; restore LP from stack
\r
146 add 0x0C,sp ; set SP to right position
\r