]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/V850ES/ISR_Support.h
b49c10493c103a62a9b2a9d90c4c9d18dcf406cd
[freertos] / FreeRTOS / Source / portable / IAR / V850ES / ISR_Support.h
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\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
11  *\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
15  *\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
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29         EXTERN pxCurrentTCB\r
30         EXTERN usCriticalNesting\r
31 \r
32 #include "FreeRTOSConfig.h"\r
33 \r
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
35 ; Context save and restore macro definitions\r
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
37 \r
38 portSAVE_CONTEXT MACRO\r
39 \r
40     add     -0x0C,sp                    ; prepare stack to save necessary values\r
41     st.w    lp,8[sp]                    ; store LP to stack\r
42     stsr    0,r31\r
43     st.w    lp,4[sp]                    ; store EIPC to stack\r
44     stsr    1,lp\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
48     sst.w   r19,72[ep]\r
49     sst.w   r18,68[ep]\r
50     sst.w   r17,64[ep]\r
51     sst.w   r16,60[ep]\r
52     sst.w   r15,56[ep]\r
53     sst.w   r14,52[ep]\r
54     sst.w   r13,48[ep]\r
55     sst.w   r12,44[ep]\r
56     sst.w   r11,40[ep]\r
57     sst.w   r10,36[ep]\r
58     sst.w   r9,32[ep]\r
59     sst.w   r8,28[ep]\r
60     sst.w   r7,24[ep]\r
61     sst.w   r6,20[ep]\r
62     sst.w   r5,16[ep]\r
63     sst.w   r4,12[ep]\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
66     sst.w   r19,68[ep]\r
67     sst.w   r18,64[ep]\r
68     sst.w   r17,60[ep]\r
69     sst.w   r16,56[ep]\r
70     sst.w   r15,52[ep]\r
71     sst.w   r14,48[ep]\r
72     sst.w   r13,44[ep]\r
73     sst.w   r12,40[ep]\r
74     sst.w   r11,36[ep]\r
75     sst.w   r10,32[ep]\r
76     sst.w   r9,28[ep]\r
77     sst.w   r8,24[ep]\r
78     sst.w   r7,20[ep]\r
79     sst.w   r6,16[ep]\r
80     sst.w   r5,12[ep]\r
81 #endif /* configDATA_MODE */\r
82     sst.w   r2,8[ep]\r
83     sst.w   r1,4[ep]\r
84     MOVHI   hi1(usCriticalNesting),r0,r1        ; save usCriticalNesting value to stack\r
85     ld.w    lw1(usCriticalNesting)[r1],r2\r
86     sst.w   r2,0[ep]\r
87     MOVHI   hi1(pxCurrentTCB),r0,r1                     ; save SP to top of current TCB\r
88     ld.w    lw1(pxCurrentTCB)[r1],r2\r
89     st.w    sp,0[r2]\r
90     ENDM\r
91 \r
92 \r
93 portRESTORE_CONTEXT MACRO\r
94 \r
95     MOVHI   hi1(pxCurrentTCB),r0,r1                     ; get Stackpointer address\r
96     ld.w    lw1(pxCurrentTCB)[r1],sp\r
97     MOV     sp,r1\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
104     sld.w   8[ep],r2\r
105 #if configDATA_MODE == 1                                        ; Using Tiny data model\r
106     sld.w   12[ep],r4\r
107     sld.w   16[ep],r5\r
108     sld.w   20[ep],r6\r
109     sld.w   24[ep],r7\r
110     sld.w   28[ep],r8\r
111     sld.w   32[ep],r9\r
112     sld.w   36[ep],r10\r
113     sld.w   40[ep],r11\r
114     sld.w   44[ep],r12\r
115     sld.w   48[ep],r13\r
116     sld.w   52[ep],r14\r
117     sld.w   56[ep],r15\r
118     sld.w   60[ep],r16\r
119     sld.w   64[ep],r17\r
120     sld.w   68[ep],r18\r
121     sld.w   72[ep],r19\r
122     dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}\r
123 #else                                                                           ; Using Small/Large data model\r
124     sld.w   12[ep],r5\r
125     sld.w   16[ep],r6\r
126     sld.w   20[ep],r7\r
127     sld.w   24[ep],r8\r
128     sld.w   28[ep],r9\r
129     sld.w   32[ep],r10\r
130     sld.w   36[ep],r11\r
131     sld.w   40[ep],r12\r
132     sld.w   44[ep],r13\r
133     sld.w   48[ep],r14\r
134     sld.w   52[ep],r15\r
135     sld.w   56[ep],r16\r
136     sld.w   60[ep],r17\r
137     sld.w   64[ep],r18\r
138     sld.w   68[ep],r19\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
142     ldsr    lp,1\r
143     ld.w    4[sp],lp                                            ; restore EIPC from stack\r
144     ldsr    lp,0\r
145     ld.w    8[sp],lp                                            ; restore LP from stack\r
146     add     0x0C,sp                                                     ; set SP to right position\r
147 \r
148     RETI\r
149 \r
150     ENDM\r