1 #include <linux/threads.h>
2 #include <asm/processor.h>
4 #include <asm/cputable.h>
5 #include <asm/thread_info.h>
6 #include <asm/ppc_asm.h>
7 #include <asm/asm-offsets.h>
11 * Structure for storing CPU registers on the save area.
17 #define SL_SPRG0 0x10 /* 4 sprg's */
38 #define SL_R12 0xb4 /* r12 to r31 */
39 #define SL_SIZE (SL_R12 + 80)
44 _GLOBAL(swsusp_save_area)
51 _GLOBAL(swsusp_arch_suspend)
53 lis r11,swsusp_save_area@h
54 ori r11,r11,swsusp_save_area@l
70 /* Get a stable timebase and save it */
83 stw r4,SL_SPRG0+4(r11)
85 stw r4,SL_SPRG0+8(r11)
87 stw r4,SL_SPRG0+12(r11)
93 stw r4,SL_DBAT0+4(r11)
97 stw r4,SL_DBAT1+4(r11)
101 stw r4,SL_DBAT2+4(r11)
105 stw r4,SL_DBAT3+4(r11)
109 stw r4,SL_IBAT0+4(r11)
113 stw r4,SL_IBAT1+4(r11)
117 stw r4,SL_IBAT2+4(r11)
121 stw r4,SL_IBAT3+4(r11)
123 BEGIN_MMU_FTR_SECTION
127 stw r4,SL_DBAT4+4(r11)
131 stw r4,SL_DBAT5+4(r11)
135 stw r4,SL_DBAT6+4(r11)
139 stw r4,SL_DBAT7+4(r11)
143 stw r4,SL_IBAT4+4(r11)
147 stw r4,SL_IBAT5+4(r11)
151 stw r4,SL_IBAT6+4(r11)
155 stw r4,SL_IBAT7+4(r11)
156 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
159 /* Backup various CPU config stuffs */
162 /* Call the low level suspend stuff (we should probably have made
167 /* Restore LR from the save area */
168 lis r11,swsusp_save_area@h
169 ori r11,r11,swsusp_save_area@l
177 _GLOBAL(swsusp_arch_resume)
179 #ifdef CONFIG_ALTIVEC
180 /* Stop pending alitvec streams and memory accesses */
183 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
187 /* Disable MSR:DR to make sure we don't take a TLB or
188 * hash miss during the copy, as our hash table will
189 * for a while be unusable. For .text, we assume we are
190 * covered by a BAT. This works only for non-G5 at this
191 * point. G5 will need a better approach, possibly using
192 * a small temporary hash table filled with large mappings,
193 * disabling the MMU completely isn't a good option for
194 * performance reasons.
195 * (Note that 750's may have the same performance issue as
196 * the G5 in this case, we should investigate using moving
197 * BATs for these CPUs)
201 rlwinm r0,r0,0,28,26 /* clear MSR_DR */
206 /* Load ptr the list of pages to copy in r3 */
207 lis r11,(restore_pblist - KERNELBASE)@h
208 ori r11,r11,restore_pblist@l
211 /* Copy the pages. This is a very basic implementation, to
212 * be replaced by something more cache efficient */
217 lwz r11,pbe_address(r3) /* source */
219 lwz r10,pbe_orig_address(r3) /* destination */
237 /* Do a very simple cache flush/inval of the L1 to ensure
238 * coherency of the icache
250 /* Now flush those cache lines */
260 /* Ok, we are now running with the kernel data of the old
261 * kernel fully restored. We can get to the save area
262 * easily now. As for the rest of the code, it assumes the
263 * loader kernel and the booted one are exactly identical
265 lis r11,swsusp_save_area@h
266 ori r11,r11,swsusp_save_area@l
270 /* Restore various CPU config stuffs */
271 bl __restore_cpu_setup
273 /* Restore the BATs, and SDR1. Then we can turn on the MMU.
274 * This is a bit hairy as we are running out of those BATs,
275 * but first, our code is probably in the icache, and we are
276 * writing the same value to the BAT, so that should be fine,
277 * though a better solution will have to be found long-term
283 lwz r4,SL_SPRG0+4(r11)
285 lwz r4,SL_SPRG0+8(r11)
287 lwz r4,SL_SPRG0+12(r11)
293 lwz r4,SL_DBAT0+4(r11)
297 lwz r4,SL_DBAT1+4(r11)
301 lwz r4,SL_DBAT2+4(r11)
305 lwz r4,SL_DBAT3+4(r11)
309 lwz r4,SL_IBAT0+4(r11)
313 lwz r4,SL_IBAT1+4(r11)
317 lwz r4,SL_IBAT2+4(r11)
321 lwz r4,SL_IBAT3+4(r11)
323 BEGIN_MMU_FTR_SECTION
326 lwz r4,SL_DBAT4+4(r11)
330 lwz r4,SL_DBAT5+4(r11)
334 lwz r4,SL_DBAT6+4(r11)
338 lwz r4,SL_DBAT7+4(r11)
342 lwz r4,SL_IBAT4+4(r11)
346 lwz r4,SL_IBAT5+4(r11)
350 lwz r4,SL_IBAT6+4(r11)
354 lwz r4,SL_IBAT7+4(r11)
356 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
361 1: addic. r4,r4,-0x1000
366 /* restore the MSR and turn on the MMU */
379 /* Kick decrementer */
383 /* Restore the callee-saved registers and return */
392 // XXX Note: we don't really need to call swsusp_resume
397 /* FIXME:This construct is actually not useful since we don't shut
398 * down the instruction MMU, we could just flip back MSR-DR on.