2 * PowerPC 64-bit swsusp implementation
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
9 #include <linux/threads.h>
10 #include <asm/processor.h>
12 #include <asm/cputable.h>
13 #include <asm/thread_info.h>
14 #include <asm/ppc_asm.h>
15 #include <asm/asm-offsets.h>
18 * Structure for storing CPU registers on the save area.
20 #define SL_r1 0x00 /* stack pointer */
49 #define SL_SPRG1 0x100
51 #define SL_SIZE SL_TCR+8
53 /* these macros rely on the save area being
54 * pointed to by r11 */
56 #define SAVE_SPR(register) \
57 mfspr r0, SPRN_##register ;\
58 std r0, SL_##register(r11)
59 #define RESTORE_SPR(register) \
60 ld r0, SL_##register(r11) ;\
61 mtspr SPRN_##register, r0
62 #define SAVE_SPECIAL(special) \
64 std r0, SL_##special(r11)
65 #define RESTORE_SPECIAL(special) \
66 ld r0, SL_##special(r11) ;\
68 #define SAVE_REGISTER(reg) \
69 std reg, SL_##reg(r11)
70 #define RESTORE_REGISTER(reg) \
73 /* space for storing cpu state */
81 .tc swsusp_save_area[TC],swsusp_save_area
83 .tc restore_pblist[TC],restore_pblist
87 _GLOBAL(swsusp_arch_suspend)
88 ld r11,swsusp_save_area_ptr@toc(r2)
116 #ifdef CONFIG_PPC_BOOK3S_64
119 END_FW_FTR_SECTION_IFCLR(FW_FEATURE_LPAR)
123 /* Save SPRG1, SPRG1 be used save paca */
127 /* we push the stack up 128 bytes but don't store the
128 * stack pointer on the stack like a real stackframe */
135 ld r11,swsusp_save_area_ptr@toc(r2)
142 _GLOBAL(swsusp_arch_resume)
143 /* Stop pending alitvec streams and memory accesses */
146 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
149 ld r12,restore_pblist_ptr@toc(r2)
156 ld r13,pbe_address(r12)
157 ld r14,pbe_orig_address(r12)
172 #ifdef CONFIG_PPC_BOOK3S_64
177 ori r3, r3, CONFIG_KERNEL_START>>48
191 ld r11,swsusp_save_area_ptr@toc(r2)
195 /* restore timebase */
198 /* get upper 32 bits of it */
200 /* clear tb lower to avoid wrap */
208 /* restore registers */
211 RESTORE_REGISTER(r12)
212 RESTORE_REGISTER(r13)
213 RESTORE_REGISTER(r14)
214 RESTORE_REGISTER(r15)
215 RESTORE_REGISTER(r16)
216 RESTORE_REGISTER(r17)
217 RESTORE_REGISTER(r18)
218 RESTORE_REGISTER(r19)
219 RESTORE_REGISTER(r20)
220 RESTORE_REGISTER(r21)
221 RESTORE_REGISTER(r22)
222 RESTORE_REGISTER(r23)
223 RESTORE_REGISTER(r24)
224 RESTORE_REGISTER(r25)
225 RESTORE_REGISTER(r26)
226 RESTORE_REGISTER(r27)
227 RESTORE_REGISTER(r28)
228 RESTORE_REGISTER(r29)
229 RESTORE_REGISTER(r30)
230 RESTORE_REGISTER(r31)
232 #ifdef CONFIG_PPC_BOOK3S_64
233 /* can't use RESTORE_SPECIAL(MSR) */
237 RESTORE_SPECIAL(SDR1)
238 END_FW_FTR_SECTION_IFCLR(FW_FEATURE_LPAR)
240 /* Restore SPRG1, be used to save paca */
246 /* Restore TCR and clear any pending bits in TSR. */
248 lis r0, (TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS)@h
251 /* Kick decrementer */
255 /* Invalidate all tlbs */
263 #ifdef CONFIG_PPC_BOOK3S_64
264 bl slb_flush_and_rebolt
269 ld r11,swsusp_save_area_ptr@toc(r2)