aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/head_booke.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-07-14 16:52:54 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-08-19 20:12:27 -0400
commitee43eb788b3a06425fffb912677e2e1c8b00dd3b (patch)
tree7233cb47647837ab00af81270b3a16555d88a1f1 /arch/powerpc/kernel/head_booke.h
parent8aa34ab8b2dc96ca6c4feecfb87ed13f0d40ef98 (diff)
powerpc: Use names rather than numbers for SPRGs (v2)
The kernel uses SPRG registers for various purposes, typically in low level assembly code as scratch registers or to hold per-cpu global infos such as the PACA or the current thread_info pointer. We want to be able to easily shuffle the usage of those registers as some implementations have specific constraints realted to some of them, for example, some have userspace readable aliases, etc.. and the current choice isn't always the best. This patch should not change any code generation, and replaces the usage of SPRN_SPRGn everywhere in the kernel with a named replacement and adds documentation next to the definition of the names as to what those are used for on each processor family. The only parts that still use the original numbers are bits of KVM or suspend/resume code that just blindly needs to save/restore all the SPRGs. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/head_booke.h')
-rw-r--r--arch/powerpc/kernel/head_booke.h50
1 files changed, 20 insertions, 30 deletions
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 5f9febc8d143..50504ae39cb7 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -20,14 +20,14 @@
20#endif 20#endif
21 21
22#define NORMAL_EXCEPTION_PROLOG \ 22#define NORMAL_EXCEPTION_PROLOG \
23 mtspr SPRN_SPRG0,r10; /* save two registers to work with */\ 23 mtspr SPRN_SPRG_WSCRATCH0,r10;/* save two registers to work with */\
24 mtspr SPRN_SPRG1,r11; \ 24 mtspr SPRN_SPRG_WSCRATCH1,r11; \
25 mtspr SPRN_SPRG4W,r1; \ 25 mtspr SPRN_SPRG_WSCRATCH2,r1; \
26 mfcr r10; /* save CR in r10 for now */\ 26 mfcr r10; /* save CR in r10 for now */\
27 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ 27 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
28 andi. r11,r11,MSR_PR; \ 28 andi. r11,r11,MSR_PR; \
29 beq 1f; \ 29 beq 1f; \
30 mfspr r1,SPRN_SPRG3; /* if from user, start at top of */\ 30 mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\
31 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ 31 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\
32 ALLOC_STACK_FRAME(r1, THREAD_SIZE); \ 32 ALLOC_STACK_FRAME(r1, THREAD_SIZE); \
331: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ 331: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\
@@ -35,13 +35,13 @@
35 stw r10,_CCR(r11); /* save various registers */\ 35 stw r10,_CCR(r11); /* save various registers */\
36 stw r12,GPR12(r11); \ 36 stw r12,GPR12(r11); \
37 stw r9,GPR9(r11); \ 37 stw r9,GPR9(r11); \
38 mfspr r10,SPRN_SPRG0; \ 38 mfspr r10,SPRN_SPRG_RSCRATCH0; \
39 stw r10,GPR10(r11); \ 39 stw r10,GPR10(r11); \
40 mfspr r12,SPRN_SPRG1; \ 40 mfspr r12,SPRN_SPRG_RSCRATCH1; \
41 stw r12,GPR11(r11); \ 41 stw r12,GPR11(r11); \
42 mflr r10; \ 42 mflr r10; \
43 stw r10,_LINK(r11); \ 43 stw r10,_LINK(r11); \
44 mfspr r10,SPRN_SPRG4R; \ 44 mfspr r10,SPRN_SPRG_RSCRATCH2; \
45 mfspr r12,SPRN_SRR0; \ 45 mfspr r12,SPRN_SRR0; \
46 stw r10,GPR1(r11); \ 46 stw r10,GPR1(r11); \
47 mfspr r9,SPRN_SRR1; \ 47 mfspr r9,SPRN_SRR1; \
@@ -69,21 +69,11 @@
69 * providing configurations that micro-optimize space usage. 69 * providing configurations that micro-optimize space usage.
70 */ 70 */
71 71
72/* CRIT_SPRG only used in critical exception handling */ 72#define MC_STACK_BASE mcheckirq_ctx
73#define CRIT_SPRG SPRN_SPRG2
74/* MCHECK_SPRG only used in machine check exception handling */
75#define MCHECK_SPRG SPRN_SPRG6W
76
77#define MCHECK_STACK_BASE mcheckirq_ctx
78#define CRIT_STACK_BASE critirq_ctx 73#define CRIT_STACK_BASE critirq_ctx
79 74
80/* only on e500mc/e200 */ 75/* only on e500mc/e200 */
81#define DEBUG_STACK_BASE dbgirq_ctx 76#define DBG_STACK_BASE dbgirq_ctx
82#ifdef CONFIG_E200
83#define DEBUG_SPRG SPRN_SPRG6W
84#else
85#define DEBUG_SPRG SPRN_SPRG9
86#endif
87 77
88#define EXC_LVL_FRAME_OVERHEAD (THREAD_SIZE - INT_FRAME_SIZE - EXC_LVL_SIZE) 78#define EXC_LVL_FRAME_OVERHEAD (THREAD_SIZE - INT_FRAME_SIZE - EXC_LVL_SIZE)
89 79
@@ -110,7 +100,7 @@
110 * critical/machine check exception stack at low physical addresses. 100 * critical/machine check exception stack at low physical addresses.
111 */ 101 */
112#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \ 102#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
113 mtspr exc_level##_SPRG,r8; \ 103 mtspr SPRN_SPRG_WSCRATCH_##exc_level,r8; \
114 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \ 104 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
115 stw r9,GPR9(r8); /* save various registers */\ 105 stw r9,GPR9(r8); /* save various registers */\
116 mfcr r9; /* save CR in r9 for now */\ 106 mfcr r9; /* save CR in r9 for now */\
@@ -119,7 +109,7 @@
119 stw r9,_CCR(r8); /* save CR on stack */\ 109 stw r9,_CCR(r8); /* save CR on stack */\
120 mfspr r10,exc_level_srr1; /* check whether user or kernel */\ 110 mfspr r10,exc_level_srr1; /* check whether user or kernel */\
121 andi. r10,r10,MSR_PR; \ 111 andi. r10,r10,MSR_PR; \
122 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\ 112 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
123 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ 113 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
124 addi r11,r11,EXC_LVL_FRAME_OVERHEAD; /* allocate stack frame */\ 114 addi r11,r11,EXC_LVL_FRAME_OVERHEAD; /* allocate stack frame */\
125 beq 1f; \ 115 beq 1f; \
@@ -140,7 +130,7 @@
140 lwz r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r11); \ 130 lwz r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r11); \
141 stw r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r8); \ 131 stw r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r8); \
142 mr r11,r8; \ 132 mr r11,r8; \
1432: mfspr r8,exc_level##_SPRG; \ 1332: mfspr r8,SPRN_SPRG_RSCRATCH_##exc_level; \
144 stw r12,GPR12(r11); /* save various registers */\ 134 stw r12,GPR12(r11); /* save various registers */\
145 mflr r10; \ 135 mflr r10; \
146 stw r10,_LINK(r11); \ 136 stw r10,_LINK(r11); \
@@ -161,9 +151,9 @@
161#define CRITICAL_EXCEPTION_PROLOG \ 151#define CRITICAL_EXCEPTION_PROLOG \
162 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1) 152 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1)
163#define DEBUG_EXCEPTION_PROLOG \ 153#define DEBUG_EXCEPTION_PROLOG \
164 EXC_LEVEL_EXCEPTION_PROLOG(DEBUG, SPRN_DSRR0, SPRN_DSRR1) 154 EXC_LEVEL_EXCEPTION_PROLOG(DBG, SPRN_DSRR0, SPRN_DSRR1)
165#define MCHECK_EXCEPTION_PROLOG \ 155#define MCHECK_EXCEPTION_PROLOG \
166 EXC_LEVEL_EXCEPTION_PROLOG(MCHECK, SPRN_MCSRR0, SPRN_MCSRR1) 156 EXC_LEVEL_EXCEPTION_PROLOG(MC, SPRN_MCSRR0, SPRN_MCSRR1)
167 157
168/* 158/*
169 * Exception vectors. 159 * Exception vectors.
@@ -282,13 +272,13 @@ label:
282 mtspr SPRN_DSRR1,r9; \ 272 mtspr SPRN_DSRR1,r9; \
283 lwz r9,GPR9(r11); \ 273 lwz r9,GPR9(r11); \
284 lwz r12,GPR12(r11); \ 274 lwz r12,GPR12(r11); \
285 mtspr DEBUG_SPRG,r8; \ 275 mtspr SPRN_SPRG_WSCRATCH_DBG,r8; \
286 BOOKE_LOAD_EXC_LEVEL_STACK(DEBUG); /* r8 points to the debug stack */ \ 276 BOOKE_LOAD_EXC_LEVEL_STACK(DBG); /* r8 points to the debug stack */ \
287 lwz r10,GPR10(r8); \ 277 lwz r10,GPR10(r8); \
288 lwz r11,GPR11(r8); \ 278 lwz r11,GPR11(r8); \
289 mfspr r8,DEBUG_SPRG; \ 279 mfspr r8,SPRN_SPRG_RSCRATCH_DBG; \
290 \ 280 \
291 PPC_RFDI; \ 281 PPC_RFDI; \
292 b .; \ 282 b .; \
293 \ 283 \
294 /* continue normal handling for a debug exception... */ \ 284 /* continue normal handling for a debug exception... */ \
@@ -335,11 +325,11 @@ label:
335 mtspr SPRN_CSRR1,r9; \ 325 mtspr SPRN_CSRR1,r9; \
336 lwz r9,GPR9(r11); \ 326 lwz r9,GPR9(r11); \
337 lwz r12,GPR12(r11); \ 327 lwz r12,GPR12(r11); \
338 mtspr CRIT_SPRG,r8; \ 328 mtspr SPRN_SPRG_WSCRATCH_CRIT,r8; \
339 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \ 329 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
340 lwz r10,GPR10(r8); \ 330 lwz r10,GPR10(r8); \
341 lwz r11,GPR11(r8); \ 331 lwz r11,GPR11(r8); \
342 mfspr r8,CRIT_SPRG; \ 332 mfspr r8,SPRN_SPRG_RSCRATCH_CRIT; \
343 \ 333 \
344 rfci; \ 334 rfci; \
345 b .; \ 335 b .; \