blob: eb84f11bdb30d6733c83520ac20d27870cd4a400 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
2 * U-boot - entry.h Routines for context saving and restoring
3 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
Aubrey Li155fd762007-04-05 18:31:18 +080021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 * MA 02110-1301 USA
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010023 */
24
25#ifndef __BLACKFIN_ENTRY_H
26#define __BLACKFIN_ENTRY_H
27
28#include <linux/config.h>
29#include <asm/setup.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010030
31/*
32 * Stack layout in 'ret_from_exception':
33 *
34 */
35
36/*
37 * Register %p2 is now set to the current task throughout
38 * the whole kernel.
39 */
40
41#ifdef __ASSEMBLY__
42
43#define LFLUSH_I_AND_D 0x00000808
44#define LSIGTRAP 5
45
46/* process bits for task_struct.flags */
47#define PF_TRACESYS_OFF 3
48#define PF_TRACESYS_BIT 5
49#define PF_PTRACED_OFF 3
50#define PF_PTRACED_BIT 4
51#define PF_DTRACE_OFF 1
52#define PF_DTRACE_BIT 5
53
54#define NEW_PT_REGS
55
56#if defined(NEW_PT_REGS)
57
58#define SAVE_ALL_INT save_context_no_interrupts
59#define SAVE_ALL_SYS save_context_no_interrupts
60#define SAVE_CONTEXT save_context_with_interrupts
61
62#define RESTORE_ALL restore_context_no_interrupts
63#define RESTORE_ALL_SYS restore_context_no_interrupts
64#define RESTORE_CONTEXT restore_context_with_interrupts
65
66#else
67
68#define SAVE_ALL_INT save_all_int
69#define SAVE_ALL_SYS save_all_sys
70#define SAVE_CONTEXT save_context
71#define RESTORE_ALL restore_context
72#define RESTORE_CONTEXT restore_context
73
74#endif
75
76/*
77 * Code to save processor context.
78 * We even save the register which are preserved by a function call
79 * - r4, r5, r6, r7, p3, p4, p5
80 */
81.macro save_context_with_interrupts
82 [--sp] = R0;
83 [--sp] = ( R7:0, P5:0 );
84 [--sp] = fp;
85 [--sp] = usp;
86
87 [--sp] = i0;
88 [--sp] = i1;
89 [--sp] = i2;
90 [--sp] = i3;
91
92 [--sp] = m0;
93 [--sp] = m1;
94 [--sp] = m2;
95 [--sp] = m3;
96
97 [--sp] = l0;
98 [--sp] = l1;
99 [--sp] = l2;
100 [--sp] = l3;
101
102 [--sp] = b0;
103 [--sp] = b1;
104 [--sp] = b2;
105 [--sp] = b3;
106 [--sp] = a0.x;
107 [--sp] = a0.w;
108 [--sp] = a1.x;
109 [--sp] = a1.w;
110
111 [--sp] = LC0;
112 [--sp] = LC1;
113 [--sp] = LT0;
114 [--sp] = LT1;
115 [--sp] = LB0;
116 [--sp] = LB1;
117
118 [--sp] = ASTAT;
119
120 [--sp] = r0; /* Skip reserved */
121 [--sp] = RETS;
122 [--sp] = RETI;
123 [--sp] = RETX;
124 [--sp] = RETN;
125 [--sp] = RETE;
126 [--sp] = SEQSTAT;
127 [--sp] = SYSCFG;
128 [--sp] = r0; /* Skip IPEND as well. */
129.endm
130
131.macro save_context_no_interrupts
132 [--sp] = R0;
133 [--sp] = ( R7:0, P5:0 );
134 [--sp] = fp;
135 [--sp] = usp;
136
137 [--sp] = i0;
138 [--sp] = i1;
139 [--sp] = i2;
140 [--sp] = i3;
141
142 [--sp] = m0;
143 [--sp] = m1;
144 [--sp] = m2;
145 [--sp] = m3;
146
147 [--sp] = l0;
148 [--sp] = l1;
149 [--sp] = l2;
150 [--sp] = l3;
151
152 [--sp] = b0;
153 [--sp] = b1;
154 [--sp] = b2;
155 [--sp] = b3;
156 [--sp] = a0.x;
157 [--sp] = a0.w;
158 [--sp] = a1.x;
159 [--sp] = a1.w;
160
161 [--sp] = LC0;
162 [--sp] = LC1;
163 [--sp] = LT0;
164 [--sp] = LT1;
165 [--sp] = LB0;
166 [--sp] = LB1;
167
168 [--sp] = ASTAT;
169
170 [--sp] = r0; /* Skip reserved */
171 [--sp] = RETS;
172 r0 = RETI;
173 [--sp] = r0;
174 [--sp] = RETX;
175 [--sp] = RETN;
176 [--sp] = RETE;
177 [--sp] = SEQSTAT;
178 [--sp] = SYSCFG;
179 [--sp] = r0; /* Skip IPEND as well. */
180.endm
181
182.macro restore_context_no_interrupts
183 sp += 4;
184 SYSCFG = [sp++];
185 SEQSTAT = [sp++];
186 RETE = [sp++];
187 RETN = [sp++];
188 RETX = [sp++];
189 r0 = [sp++];
190 RETI = r0;
191 RETS = [sp++];
192
193 sp += 4;
194
195 ASTAT = [sp++];
196
197 LB1 = [sp++];
198 LB0 = [sp++];
199 LT1 = [sp++];
200 LT0 = [sp++];
201 LC1 = [sp++];
202 LC0 = [sp++];
203
204 a1.w = [sp++];
205 a1.x = [sp++];
206 a0.w = [sp++];
207 a0.x = [sp++];
208 b3 = [sp++];
209 b2 = [sp++];
210 b1 = [sp++];
211 b0 = [sp++];
212
213 l3 = [sp++];
214 l2 = [sp++];
215 l1 = [sp++];
216 l0 = [sp++];
217
218 m3 = [sp++];
219 m2 = [sp++];
220 m1 = [sp++];
221 m0 = [sp++];
222
223 i3 = [sp++];
224 i2 = [sp++];
225 i1 = [sp++];
226 i0 = [sp++];
227
228 sp += 4;
229 fp = [sp++];
230
231 ( R7 : 0, P5 : 0) = [ SP ++ ];
232 sp += 4;
233.endm
234
235.macro restore_context_with_interrupts
236 sp += 4;
237 SYSCFG = [sp++];
238 SEQSTAT = [sp++];
239 RETE = [sp++];
240 RETN = [sp++];
241 RETX = [sp++];
242 RETI = [sp++];
243 RETS = [sp++];
244
245 sp += 4;
246
247 ASTAT = [sp++];
248
249 LB1 = [sp++];
250 LB0 = [sp++];
251 LT1 = [sp++];
252 LT0 = [sp++];
253 LC1 = [sp++];
254 LC0 = [sp++];
255
256 a1.w = [sp++];
257 a1.x = [sp++];
258 a0.w = [sp++];
259 a0.x = [sp++];
260 b3 = [sp++];
261 b2 = [sp++];
262 b1 = [sp++];
263 b0 = [sp++];
264
265 l3 = [sp++];
266 l2 = [sp++];
267 l1 = [sp++];
268 l0 = [sp++];
269
270 m3 = [sp++];
271 m2 = [sp++];
272 m1 = [sp++];
273 m0 = [sp++];
274
275 i3 = [sp++];
276 i2 = [sp++];
277 i1 = [sp++];
278 i0 = [sp++];
279
280 sp += 4;
281 fp = [sp++];
282
283 ( R7 : 0, P5 : 0) = [ SP ++ ];
284 sp += 4;
285.endm
286
287#if !defined(NEW_PT_REGS)
288/*
289 * a -1 in the orig_r0 field signifies
290 * that the stack frame is NOT for syscall
291 */
292.macro save_all_int
293/* reserved and disable the single step of SYSCFG, by Steven Chen 03/07/10 */
294 [--sp] = r0;
295 r0.l = 0x30; /* Errata for BF533 */
296 r0.h = 0x0;
297 syscfg = r0; /* disable single step flag in SYSCFG */
298 r0 = [sp++];
299 [--sp] = syscfg; /* store SYSCFG */
300
301 [--sp] = r0; /* Reserved for IPEND */
302 [--sp] = fp;
303 [--sp] = usp;
304 [--sp] = r0;
305
306 [--sp] = r0;
307 r0 = [sp + 8];
308 [--sp] = a0.x;
309 [--sp] = a1.x;
310 [--sp] = a0.w;
311 [--sp] = a1.w;
312 [--sp] = rets;
313 [--sp] = astat;
314 [--sp] = seqstat;
315 [--sp] = retx; /* current pc when exception happens */
316 [--sp] = ( r7:5, p5:0 );
317 [--sp] = r1;
318 [--sp] = r2;
319 [--sp] = r4;
320 [--sp] = r3;
321.endm
322
323.macro save_all_sys
324 [--sp] = r0;
325 [--sp] = r0;
326 [--sp] = a0.x;
327 [--sp] = a1.x;
328 [--sp] = a0.w;
329 [--sp] = a1.w;
330 [--sp] = rets;
331 [--sp] = astat;
332 [--sp] = seqstat;
333 [--sp] = retx; /* current pc when exception happens */
334 [--sp] = ( r7:5, p5:0 );
335 [--sp] = r1;
336 [--sp] = r2;
337 [--sp] = r4;
338 [--sp] = r3;
339.endm
340
341.macro restore_all
342 r3 = [sp++];
343 r4 = [sp++];
344 r2 = [sp++];
345 r1 = [sp++];
346 ( r7:5, p5:0 ) = [sp++];
347 retx = [sp++];
348 seqstat = [sp++];
349 astat = [sp++];
350 rets = [sp++];
351 a1.w = [sp++];
352 a0.w = [sp++];
353 a1.x = [sp++];
354 a0.x = [sp++];
355 sp += 4; /* orig r0 */
356 r0 = [sp++];
357
358 sp += 4;
359 fp = [sp++];
360 sp +=4; /* Skip the IPEND */
361
362 syscfg = [sp++];
363
364.endm
365
366#endif
367
368#define STR(X) STR1(X)
369#define STR1(X) #X
370
371#if defined(NEW_PT_REGS)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100372#define PT_OFF_ORIG_R0 208
373#define PT_OFF_SR 8
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100374#else
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100375#define PT_OFF_ORIG_R0 0x54
376#define PT_OFF_SR 0x38 /* seqstat in pt_regs */
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100377#endif
378
379#endif
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800380#endif