blob: 51fd0724e095cbf813fd9c8817d3e469be861893 [file] [log] [blame]
Becky Bruce63dafe52006-01-14 16:57:39 -06001#ifndef __HEAD_BOOKE_H__
2#define __HEAD_BOOKE_H__
3
Torez Smith471c70f2010-03-05 10:43:01 +00004#include <asm/ptrace.h> /* for STACK_FRAME_REGS_MARKER */
Scott Woodcfac5782011-12-20 15:34:40 +00005#include <asm/kvm_asm.h>
6
Becky Bruce63dafe52006-01-14 16:57:39 -06007/*
8 * Macros used for common Book-e exception handling
9 */
10
11#define SET_IVOR(vector_number, vector_label) \
12 li r26,vector_label@l; \
13 mtspr SPRN_IVOR##vector_number,r26; \
14 sync
15
Yuri Tikhonove1240122009-01-29 01:40:44 +000016#if (THREAD_SHIFT < 15)
17#define ALLOC_STACK_FRAME(reg, val) \
18 addi reg,reg,val
19#else
20#define ALLOC_STACK_FRAME(reg, val) \
21 addis reg,reg,val@ha; \
22 addi reg,reg,val@l
23#endif
24
Ashish Kalra1325a682011-04-22 16:48:27 -050025/*
26 * Macro used to get to thread save registers.
27 * Note that entries 0-3 are used for the prolog code, and the remaining
28 * entries are available for specific exception use in the event a handler
29 * requires more than 4 scratch registers.
30 */
31#define THREAD_NORMSAVE(offset) (THREAD_NORMSAVES + (offset * 4))
32
Scott Woodcfac5782011-12-20 15:34:40 +000033#define NORMAL_EXCEPTION_PROLOG(intno) \
Ashish Kalra1325a682011-04-22 16:48:27 -050034 mtspr SPRN_SPRG_WSCRATCH0, r10; /* save one register */ \
35 mfspr r10, SPRN_SPRG_THREAD; \
36 stw r11, THREAD_NORMSAVE(0)(r10); \
37 stw r13, THREAD_NORMSAVE(2)(r10); \
38 mfcr r13; /* save CR in r13 for now */\
Becky Bruce63dafe52006-01-14 16:57:39 -060039 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
40 andi. r11,r11,MSR_PR; \
Ashish Kalra1325a682011-04-22 16:48:27 -050041 mr r11, r1; \
Becky Bruce63dafe52006-01-14 16:57:39 -060042 beq 1f; \
Ashish Kalra1325a682011-04-22 16:48:27 -050043 /* if from user, start at top of this thread's kernel stack */ \
44 lwz r11, THREAD_INFO-THREAD(r10); \
45 ALLOC_STACK_FRAME(r11, THREAD_SIZE); \
461 : subi r11, r11, INT_FRAME_SIZE; /* Allocate exception frame */ \
47 stw r13, _CCR(r11); /* save various registers */ \
Becky Bruce63dafe52006-01-14 16:57:39 -060048 stw r12,GPR12(r11); \
49 stw r9,GPR9(r11); \
Ashish Kalra1325a682011-04-22 16:48:27 -050050 mfspr r13, SPRN_SPRG_RSCRATCH0; \
51 stw r13, GPR10(r11); \
52 lwz r12, THREAD_NORMSAVE(0)(r10); \
Becky Bruce63dafe52006-01-14 16:57:39 -060053 stw r12,GPR11(r11); \
Ashish Kalra1325a682011-04-22 16:48:27 -050054 lwz r13, THREAD_NORMSAVE(2)(r10); /* restore r13 */ \
Becky Bruce63dafe52006-01-14 16:57:39 -060055 mflr r10; \
56 stw r10,_LINK(r11); \
Becky Bruce63dafe52006-01-14 16:57:39 -060057 mfspr r12,SPRN_SRR0; \
Ashish Kalra1325a682011-04-22 16:48:27 -050058 stw r1, GPR1(r11); \
Becky Bruce63dafe52006-01-14 16:57:39 -060059 mfspr r9,SPRN_SRR1; \
Ashish Kalra1325a682011-04-22 16:48:27 -050060 stw r1, 0(r11); \
61 mr r1, r11; \
Becky Bruce63dafe52006-01-14 16:57:39 -060062 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
63 stw r0,GPR0(r11); \
Torez Smith471c70f2010-03-05 10:43:01 +000064 lis r10, STACK_FRAME_REGS_MARKER@ha;/* exception frame marker */ \
65 addi r10, r10, STACK_FRAME_REGS_MARKER@l; \
66 stw r10, 8(r11); \
Becky Bruce63dafe52006-01-14 16:57:39 -060067 SAVE_4GPRS(3, r11); \
68 SAVE_2GPRS(7, r11)
69
70/* To handle the additional exception priority levels on 40x and Book-E
Kumar Galabcf0b082008-04-30 03:49:55 -050071 * processors we allocate a stack per additional priority level.
Becky Bruce63dafe52006-01-14 16:57:39 -060072 *
73 * On 40x critical is the only additional level
74 * On 44x/e500 we have critical and machine check
75 * On e200 we have critical and debug (machine check occurs via critical)
76 *
77 * Additionally we reserve a SPRG for each priority level so we can free up a
78 * GPR to use as the base for indirect access to the exception stacks. This
79 * is necessary since the MMU is always on, for Book-E parts, and the stacks
80 * are offset from KERNELBASE.
81 *
Kumar Galaeb0cd5fd2008-04-09 06:06:11 -050082 * There is some space optimization to be had here if desired. However
83 * to allow for a common kernel with support for debug exceptions either
84 * going to critical or their own debug level we aren't currently
85 * providing configurations that micro-optimize space usage.
Becky Bruce63dafe52006-01-14 16:57:39 -060086 */
Becky Bruce63dafe52006-01-14 16:57:39 -060087
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +000088#define MC_STACK_BASE mcheckirq_ctx
Kumar Galabcf0b082008-04-30 03:49:55 -050089#define CRIT_STACK_BASE critirq_ctx
Becky Bruce63dafe52006-01-14 16:57:39 -060090
Kumar Gala3dfa8772008-06-16 09:41:32 -050091/* only on e500mc/e200 */
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +000092#define DBG_STACK_BASE dbgirq_ctx
Becky Bruce63dafe52006-01-14 16:57:39 -060093
Kumar Galafca622c2008-04-30 05:23:21 -050094#define EXC_LVL_FRAME_OVERHEAD (THREAD_SIZE - INT_FRAME_SIZE - EXC_LVL_SIZE)
Kumar Gala369e7572008-04-30 04:17:22 -050095
Becky Bruce63dafe52006-01-14 16:57:39 -060096#ifdef CONFIG_SMP
97#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
98 mfspr r8,SPRN_PIR; \
Kumar Galabcf0b082008-04-30 03:49:55 -050099 slwi r8,r8,2; \
100 addis r8,r8,level##_STACK_BASE@ha; \
101 lwz r8,level##_STACK_BASE@l(r8); \
Kumar Gala369e7572008-04-30 04:17:22 -0500102 addi r8,r8,EXC_LVL_FRAME_OVERHEAD;
Becky Bruce63dafe52006-01-14 16:57:39 -0600103#else
104#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
Kumar Galabcf0b082008-04-30 03:49:55 -0500105 lis r8,level##_STACK_BASE@ha; \
106 lwz r8,level##_STACK_BASE@l(r8); \
Kumar Gala369e7572008-04-30 04:17:22 -0500107 addi r8,r8,EXC_LVL_FRAME_OVERHEAD;
Becky Bruce63dafe52006-01-14 16:57:39 -0600108#endif
109
110/*
111 * Exception prolog for critical/machine check exceptions. This is a
112 * little different from the normal exception prolog above since a
113 * critical/machine check exception can potentially occur at any point
114 * during normal exception processing. Thus we cannot use the same SPRG
115 * registers as the normal prolog above. Instead we use a portion of the
116 * critical/machine check exception stack at low physical addresses.
117 */
Scott Woodcfac5782011-12-20 15:34:40 +0000118#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, intno, exc_level_srr0, exc_level_srr1) \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000119 mtspr SPRN_SPRG_WSCRATCH_##exc_level,r8; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600120 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
Kumar Gala369e7572008-04-30 04:17:22 -0500121 stw r9,GPR9(r8); /* save various registers */\
122 mfcr r9; /* save CR in r9 for now */\
123 stw r10,GPR10(r8); \
124 stw r11,GPR11(r8); \
125 stw r9,_CCR(r8); /* save CR on stack */\
126 mfspr r10,exc_level_srr1; /* check whether user or kernel */\
127 andi. r10,r10,MSR_PR; \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000128 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
Becky Bruce63dafe52006-01-14 16:57:39 -0600129 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
Kumar Gala369e7572008-04-30 04:17:22 -0500130 addi r11,r11,EXC_LVL_FRAME_OVERHEAD; /* allocate stack frame */\
131 beq 1f; \
132 /* COMING FROM USER MODE */ \
133 stw r9,_CCR(r11); /* save CR */\
134 lwz r10,GPR10(r8); /* copy regs from exception stack */\
135 lwz r9,GPR9(r8); \
136 stw r10,GPR10(r11); \
137 lwz r10,GPR11(r8); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600138 stw r9,GPR9(r11); \
Kumar Gala369e7572008-04-30 04:17:22 -0500139 stw r10,GPR11(r11); \
140 b 2f; \
141 /* COMING FROM PRIV MODE */ \
1421: lwz r9,TI_FLAGS-EXC_LVL_FRAME_OVERHEAD(r11); \
143 lwz r10,TI_PREEMPT-EXC_LVL_FRAME_OVERHEAD(r11); \
144 stw r9,TI_FLAGS-EXC_LVL_FRAME_OVERHEAD(r8); \
145 stw r10,TI_PREEMPT-EXC_LVL_FRAME_OVERHEAD(r8); \
146 lwz r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r11); \
147 stw r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r8); \
148 mr r11,r8; \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +00001492: mfspr r8,SPRN_SPRG_RSCRATCH_##exc_level; \
Kumar Gala369e7572008-04-30 04:17:22 -0500150 stw r12,GPR12(r11); /* save various registers */\
Becky Bruce63dafe52006-01-14 16:57:39 -0600151 mflr r10; \
152 stw r10,_LINK(r11); \
153 mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
154 stw r12,_DEAR(r11); /* since they may have had stuff */\
155 mfspr r9,SPRN_ESR; /* in them at the point where the */\
156 stw r9,_ESR(r11); /* exception was taken */\
157 mfspr r12,exc_level_srr0; \
158 stw r1,GPR1(r11); \
159 mfspr r9,exc_level_srr1; \
160 stw r1,0(r11); \
161 mr r1,r11; \
162 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
163 stw r0,GPR0(r11); \
164 SAVE_4GPRS(3, r11); \
165 SAVE_2GPRS(7, r11)
166
Scott Woodcfac5782011-12-20 15:34:40 +0000167#define CRITICAL_EXCEPTION_PROLOG(intno) \
168 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, intno, SPRN_CSRR0, SPRN_CSRR1)
Becky Bruce63dafe52006-01-14 16:57:39 -0600169#define DEBUG_EXCEPTION_PROLOG \
Scott Woodcfac5782011-12-20 15:34:40 +0000170 EXC_LEVEL_EXCEPTION_PROLOG(DBG, DEBUG, SPRN_DSRR0, SPRN_DSRR1)
Becky Bruce63dafe52006-01-14 16:57:39 -0600171#define MCHECK_EXCEPTION_PROLOG \
Scott Woodcfac5782011-12-20 15:34:40 +0000172 EXC_LEVEL_EXCEPTION_PROLOG(MC, MACHINE_CHECK, \
173 SPRN_MCSRR0, SPRN_MCSRR1)
Becky Bruce63dafe52006-01-14 16:57:39 -0600174
175/*
176 * Exception vectors.
177 */
178#define START_EXCEPTION(label) \
179 .align 5; \
180label:
181
182#define FINISH_EXCEPTION(func) \
183 bl transfer_to_handler_full; \
184 .long func; \
185 .long ret_from_except_full
186
Scott Woodcfac5782011-12-20 15:34:40 +0000187#define EXCEPTION(n, intno, label, hdlr, xfer) \
Becky Bruce63dafe52006-01-14 16:57:39 -0600188 START_EXCEPTION(label); \
Scott Woodcfac5782011-12-20 15:34:40 +0000189 NORMAL_EXCEPTION_PROLOG(intno); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600190 addi r3,r1,STACK_FRAME_OVERHEAD; \
191 xfer(n, hdlr)
192
Scott Woodcfac5782011-12-20 15:34:40 +0000193#define CRITICAL_EXCEPTION(n, intno, label, hdlr) \
194 START_EXCEPTION(label); \
195 CRITICAL_EXCEPTION_PROLOG(intno); \
196 addi r3,r1,STACK_FRAME_OVERHEAD; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600197 EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
198 NOCOPY, crit_transfer_to_handler, \
199 ret_from_crit_exc)
200
201#define MCHECK_EXCEPTION(n, label, hdlr) \
202 START_EXCEPTION(label); \
203 MCHECK_EXCEPTION_PROLOG; \
204 mfspr r5,SPRN_ESR; \
205 stw r5,_ESR(r11); \
206 addi r3,r1,STACK_FRAME_OVERHEAD; \
Benjamin Herrenschmidt47c0bd12007-12-21 15:39:21 +1100207 EXC_XFER_TEMPLATE(hdlr, n+4, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
Becky Bruce63dafe52006-01-14 16:57:39 -0600208 NOCOPY, mcheck_transfer_to_handler, \
209 ret_from_mcheck_exc)
210
211#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret) \
212 li r10,trap; \
213 stw r10,_TRAP(r11); \
214 lis r10,msr@h; \
215 ori r10,r10,msr@l; \
216 copyee(r10, r9); \
217 bl tfer; \
218 .long hdlr; \
219 .long ret
220
221#define COPY_EE(d, s) rlwimi d,s,0,16,16
222#define NOCOPY(d, s)
223
224#define EXC_XFER_STD(n, hdlr) \
225 EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \
226 ret_from_except_full)
227
228#define EXC_XFER_LITE(n, hdlr) \
229 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \
230 ret_from_except)
231
232#define EXC_XFER_EE(n, hdlr) \
233 EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \
234 ret_from_except_full)
235
236#define EXC_XFER_EE_LITE(n, hdlr) \
237 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
238 ret_from_except)
239
240/* Check for a single step debug exception while in an exception
241 * handler before state has been saved. This is to catch the case
242 * where an instruction that we are trying to single step causes
243 * an exception (eg ITLB/DTLB miss) and thus the first instruction of
244 * the exception handler generates a single step debug exception.
245 *
246 * If we get a debug trap on the first instruction of an exception handler,
247 * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
248 * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
249 * The exception handler was handling a non-critical interrupt, so it will
250 * save (and later restore) the MSR via SPRN_CSRR1, which will still have
251 * the MSR_DE bit set.
252 */
Kumar Galaeb0cd5fd2008-04-09 06:06:11 -0500253#define DEBUG_DEBUG_EXCEPTION \
254 START_EXCEPTION(DebugDebug); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600255 DEBUG_EXCEPTION_PROLOG; \
256 \
257 /* \
258 * If there is a single step or branch-taken exception in an \
259 * exception entry sequence, it was probably meant to apply to \
260 * the code where the exception occurred (since exception entry \
261 * doesn't turn off DE automatically). We simulate the effect \
262 * of turning off DE on entry to an exception handler by turning \
Kumar Galafec6a822008-06-11 13:07:26 -0500263 * off DE in the DSRR1 value and clearing the debug status. \
Becky Bruce63dafe52006-01-14 16:57:39 -0600264 */ \
265 mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
Roland McGrathec097c82009-05-28 21:26:38 +0000266 andis. r10,r10,(DBSR_IC|DBSR_BT)@h; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600267 beq+ 2f; \
268 \
269 lis r10,KERNELBASE@h; /* check if exception in vectors */ \
270 ori r10,r10,KERNELBASE@l; \
271 cmplw r12,r10; \
272 blt+ 2f; /* addr below exception vectors */ \
273 \
Kumar Galaeb0cd5fd2008-04-09 06:06:11 -0500274 lis r10,DebugDebug@h; \
275 ori r10,r10,DebugDebug@l; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600276 cmplw r12,r10; \
277 bgt+ 2f; /* addr above exception vectors */ \
278 \
279 /* here it looks like we got an inappropriate debug exception. */ \
2801: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CDRR1 value */ \
Roland McGrathec097c82009-05-28 21:26:38 +0000281 lis r10,(DBSR_IC|DBSR_BT)@h; /* clear the IC event */ \
Becky Bruce63dafe52006-01-14 16:57:39 -0600282 mtspr SPRN_DBSR,r10; \
283 /* restore state and get out */ \
284 lwz r10,_CCR(r11); \
285 lwz r0,GPR0(r11); \
286 lwz r1,GPR1(r11); \
287 mtcrf 0x80,r10; \
288 mtspr SPRN_DSRR0,r12; \
289 mtspr SPRN_DSRR1,r9; \
290 lwz r9,GPR9(r11); \
291 lwz r12,GPR12(r11); \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000292 mtspr SPRN_SPRG_WSCRATCH_DBG,r8; \
293 BOOKE_LOAD_EXC_LEVEL_STACK(DBG); /* r8 points to the debug stack */ \
Kumar Gala369e7572008-04-30 04:17:22 -0500294 lwz r10,GPR10(r8); \
295 lwz r11,GPR11(r8); \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000296 mfspr r8,SPRN_SPRG_RSCRATCH_DBG; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600297 \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000298 PPC_RFDI; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600299 b .; \
300 \
Kumar Galafec6a822008-06-11 13:07:26 -0500301 /* continue normal handling for a debug exception... */ \
Becky Bruce63dafe52006-01-14 16:57:39 -06003022: mfspr r4,SPRN_DBSR; \
303 addi r3,r1,STACK_FRAME_OVERHEAD; \
Kumar Gala663276b2008-04-30 20:44:53 +1000304 EXC_XFER_TEMPLATE(DebugException, 0x2008, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, debug_transfer_to_handler, ret_from_debug_exc)
Kumar Galaeb0cd5fd2008-04-09 06:06:11 -0500305
306#define DEBUG_CRIT_EXCEPTION \
307 START_EXCEPTION(DebugCrit); \
Scott Woodcfac5782011-12-20 15:34:40 +0000308 CRITICAL_EXCEPTION_PROLOG(DEBUG); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600309 \
310 /* \
311 * If there is a single step or branch-taken exception in an \
312 * exception entry sequence, it was probably meant to apply to \
313 * the code where the exception occurred (since exception entry \
314 * doesn't turn off DE automatically). We simulate the effect \
315 * of turning off DE on entry to an exception handler by turning \
316 * off DE in the CSRR1 value and clearing the debug status. \
317 */ \
318 mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
Roland McGrathec097c82009-05-28 21:26:38 +0000319 andis. r10,r10,(DBSR_IC|DBSR_BT)@h; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600320 beq+ 2f; \
321 \
322 lis r10,KERNELBASE@h; /* check if exception in vectors */ \
323 ori r10,r10,KERNELBASE@l; \
324 cmplw r12,r10; \
325 blt+ 2f; /* addr below exception vectors */ \
326 \
Roland McGrathec097c82009-05-28 21:26:38 +0000327 lis r10,DebugCrit@h; \
Kumar Galaeb0cd5fd2008-04-09 06:06:11 -0500328 ori r10,r10,DebugCrit@l; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600329 cmplw r12,r10; \
330 bgt+ 2f; /* addr above exception vectors */ \
331 \
332 /* here it looks like we got an inappropriate debug exception. */ \
3331: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CSRR1 value */ \
Roland McGrathec097c82009-05-28 21:26:38 +0000334 lis r10,(DBSR_IC|DBSR_BT)@h; /* clear the IC event */ \
Becky Bruce63dafe52006-01-14 16:57:39 -0600335 mtspr SPRN_DBSR,r10; \
336 /* restore state and get out */ \
337 lwz r10,_CCR(r11); \
338 lwz r0,GPR0(r11); \
339 lwz r1,GPR1(r11); \
340 mtcrf 0x80,r10; \
341 mtspr SPRN_CSRR0,r12; \
342 mtspr SPRN_CSRR1,r9; \
343 lwz r9,GPR9(r11); \
344 lwz r12,GPR12(r11); \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000345 mtspr SPRN_SPRG_WSCRATCH_CRIT,r8; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600346 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
Kumar Gala369e7572008-04-30 04:17:22 -0500347 lwz r10,GPR10(r8); \
348 lwz r11,GPR11(r8); \
Benjamin Herrenschmidtee43eb72009-07-14 20:52:54 +0000349 mfspr r8,SPRN_SPRG_RSCRATCH_CRIT; \
Becky Bruce63dafe52006-01-14 16:57:39 -0600350 \
351 rfci; \
352 b .; \
353 \
354 /* continue normal handling for a critical exception... */ \
3552: mfspr r4,SPRN_DBSR; \
356 addi r3,r1,STACK_FRAME_OVERHEAD; \
357 EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
Becky Bruce63dafe52006-01-14 16:57:39 -0600358
Benjamin Herrenschmidt1bc54c02008-07-08 15:54:40 +1000359#define DATA_STORAGE_EXCEPTION \
360 START_EXCEPTION(DataStorage) \
Scott Woodcfac5782011-12-20 15:34:40 +0000361 NORMAL_EXCEPTION_PROLOG(DATA_STORAGE); \
Benjamin Herrenschmidt1bc54c02008-07-08 15:54:40 +1000362 mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
363 stw r5,_ESR(r11); \
364 mfspr r4,SPRN_DEAR; /* Grab the DEAR */ \
Benjamin Herrenschmidta5464982012-03-07 16:48:45 +1100365 EXC_XFER_LITE(0x0300, handle_page_fault)
Benjamin Herrenschmidt1bc54c02008-07-08 15:54:40 +1000366
Becky Bruce63dafe52006-01-14 16:57:39 -0600367#define INSTRUCTION_STORAGE_EXCEPTION \
368 START_EXCEPTION(InstructionStorage) \
Scott Woodcfac5782011-12-20 15:34:40 +0000369 NORMAL_EXCEPTION_PROLOG(INST_STORAGE); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600370 mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
371 stw r5,_ESR(r11); \
372 mr r4,r12; /* Pass SRR0 as arg2 */ \
373 li r5,0; /* Pass zero as arg3 */ \
Benjamin Herrenschmidta5464982012-03-07 16:48:45 +1100374 EXC_XFER_LITE(0x0400, handle_page_fault)
Becky Bruce63dafe52006-01-14 16:57:39 -0600375
376#define ALIGNMENT_EXCEPTION \
377 START_EXCEPTION(Alignment) \
Scott Woodcfac5782011-12-20 15:34:40 +0000378 NORMAL_EXCEPTION_PROLOG(ALIGNMENT); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600379 mfspr r4,SPRN_DEAR; /* Grab the DEAR and save it */ \
380 stw r4,_DEAR(r11); \
381 addi r3,r1,STACK_FRAME_OVERHEAD; \
382 EXC_XFER_EE(0x0600, alignment_exception)
383
384#define PROGRAM_EXCEPTION \
385 START_EXCEPTION(Program) \
Scott Woodcfac5782011-12-20 15:34:40 +0000386 NORMAL_EXCEPTION_PROLOG(PROGRAM); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600387 mfspr r4,SPRN_ESR; /* Grab the ESR and save it */ \
388 stw r4,_ESR(r11); \
389 addi r3,r1,STACK_FRAME_OVERHEAD; \
390 EXC_XFER_STD(0x0700, program_check_exception)
391
392#define DECREMENTER_EXCEPTION \
393 START_EXCEPTION(Decrementer) \
Scott Woodcfac5782011-12-20 15:34:40 +0000394 NORMAL_EXCEPTION_PROLOG(DECREMENTER); \
Becky Bruce63dafe52006-01-14 16:57:39 -0600395 lis r0,TSR_DIS@h; /* Setup the DEC interrupt mask */ \
396 mtspr SPRN_TSR,r0; /* Clear the DEC interrupt */ \
397 addi r3,r1,STACK_FRAME_OVERHEAD; \
398 EXC_XFER_LITE(0x0900, timer_interrupt)
399
400#define FP_UNAVAILABLE_EXCEPTION \
401 START_EXCEPTION(FloatingPointUnavailable) \
Scott Woodcfac5782011-12-20 15:34:40 +0000402 NORMAL_EXCEPTION_PROLOG(FP_UNAVAIL); \
Michael Neuling6f3d8e62008-06-25 14:07:18 +1000403 beq 1f; \
404 bl load_up_fpu; /* if from user, just load it up */ \
405 b fast_exception_return; \
4061: addi r3,r1,STACK_FRAME_OVERHEAD; \
Becky Bruce66f2d022006-01-31 17:52:59 -0600407 EXC_XFER_EE_LITE(0x800, kernel_fp_unavailable_exception)
Becky Bruce63dafe52006-01-14 16:57:39 -0600408
Kumar Galafca622c2008-04-30 05:23:21 -0500409#ifndef __ASSEMBLY__
410struct exception_regs {
411 unsigned long mas0;
412 unsigned long mas1;
413 unsigned long mas2;
414 unsigned long mas3;
415 unsigned long mas6;
416 unsigned long mas7;
417 unsigned long srr0;
418 unsigned long srr1;
419 unsigned long csrr0;
420 unsigned long csrr1;
421 unsigned long dsrr0;
422 unsigned long dsrr1;
423 unsigned long saved_ksp_limit;
424};
425
426/* ensure this structure is always sized to a multiple of the stack alignment */
427#define STACK_EXC_LVL_FRAME_SIZE _ALIGN_UP(sizeof (struct exception_regs), 16)
428
429#endif /* __ASSEMBLY__ */
Becky Bruce63dafe52006-01-14 16:57:39 -0600430#endif /* __HEAD_BOOKE_H__ */