2 * S390 64-bit swsusp implementation
4 * Copyright IBM Corp. 2009
6 * Author(s): Hans-Joachim Picht <hans@linux.vnet.ibm.com>
7 * Michael Holzheu <holzheu@linux.vnet.ibm.com>
11 #include <asm/ptrace.h>
12 #include <asm/asm-offsets.h>
15 * Save register context in absolute 0 lowcore and call swsusp_save() to
16 * create in-memory kernel image. The context is saved in the designated
17 * "store status" memory locations (see POP).
18 * We return from this function twice. The first time during the suspend to
19 * disk process. The second time via the swsusp_arch_resume() function
20 * (see below) in the resume process.
21 * This function runs with disabled interrupts.
25 .globl swsusp_arch_suspend
27 stmg %r6,%r15,__SF_GPRS(%r15)
29 aghi %r15,-STACK_FRAME_OVERHEAD
30 stg %r1,__SF_BACKCHAIN(%r15)
33 stnsm __SF_EMPTY(%r15),0xfb
35 /* Store prefix register on stack */
38 /* Save prefix register contents for lowcore */
39 llgf %r4,__SF_EMPTY(%r15)
41 /* Get pointer to save area */
45 mvc 0x318(4,%r1),__SF_EMPTY(%r15) /* move prefix to lowcore */
46 stfpc 0x31c(%r1) /* store fpu control */
47 std 0,0x200(%r1) /* store f0 */
48 std 1,0x208(%r1) /* store f1 */
49 std 2,0x210(%r1) /* store f2 */
50 std 3,0x218(%r1) /* store f3 */
51 std 4,0x220(%r1) /* store f4 */
52 std 5,0x228(%r1) /* store f5 */
53 std 6,0x230(%r1) /* store f6 */
54 std 7,0x238(%r1) /* store f7 */
55 std 8,0x240(%r1) /* store f8 */
56 std 9,0x248(%r1) /* store f9 */
57 std 10,0x250(%r1) /* store f10 */
58 std 11,0x258(%r1) /* store f11 */
59 std 12,0x260(%r1) /* store f12 */
60 std 13,0x268(%r1) /* store f13 */
61 std 14,0x270(%r1) /* store f14 */
62 std 15,0x278(%r1) /* store f15 */
63 stam %a0,%a15,0x340(%r1) /* store access registers */
64 stctg %c0,%c15,0x380(%r1) /* store control registers */
65 stmg %r0,%r15,0x280(%r1) /* store general registers */
67 stpt 0x328(%r1) /* store timer */
68 stckc 0x330(%r1) /* store clock comparator */
71 stosm __SF_EMPTY(%r15),0x04
73 /* Set prefix page to zero */
74 xc __SF_EMPTY(4,%r15),__SF_EMPTY(%r15)
84 brasl %r14,swsusp_save
86 /* Restore prefix register and return */
89 lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15)
94 * Restore saved memory image to correct place and restore register context.
95 * Then we return to the function that called swsusp_arch_suspend().
96 * swsusp_arch_resume() runs with disabled interrupts.
98 .globl swsusp_arch_resume
100 stmg %r6,%r15,__SF_GPRS(%r15)
102 aghi %r15,-STACK_FRAME_OVERHEAD
103 stg %r1,__SF_BACKCHAIN(%r15)
106 /* Save boot cpu number */
107 brasl %r14,smp_get_phys_cpu_id
111 stnsm __SF_EMPTY(%r15),0xfb
113 /* Set prefix page to zero */
114 xc __SF_EMPTY(4,%r15),__SF_EMPTY(%r15)
117 /* Restore saved image */
118 larl %r1,restore_pblist
136 /* Restore registers */
137 lghi %r13,0x1000 /* %r1 = pointer to save arae */
139 spt 0x328(%r13) /* reprogram timer */
140 //sckc 0x330(%r13) /* set clock comparator */
142 lctlg %c0,%c15,0x380(%r13) /* load control registers */
143 lam %a0,%a15,0x340(%r13) /* load access registers */
145 lfpc 0x31c(%r13) /* load fpu control */
146 ld 0,0x200(%r13) /* load f0 */
147 ld 1,0x208(%r13) /* load f1 */
148 ld 2,0x210(%r13) /* load f2 */
149 ld 3,0x218(%r13) /* load f3 */
150 ld 4,0x220(%r13) /* load f4 */
151 ld 5,0x228(%r13) /* load f5 */
152 ld 6,0x230(%r13) /* load f6 */
153 ld 7,0x238(%r13) /* load f7 */
154 ld 8,0x240(%r13) /* load f8 */
155 ld 9,0x248(%r13) /* load f9 */
156 ld 10,0x250(%r13) /* load f10 */
157 ld 11,0x258(%r13) /* load f11 */
158 ld 12,0x260(%r13) /* load f12 */
159 ld 13,0x268(%r13) /* load f13 */
160 ld 14,0x270(%r13) /* load f14 */
161 ld 15,0x278(%r13) /* load f15 */
166 /* Pointer to save area */
171 lgr %r2,%r10 /* get cpu id */
173 brasl %r14,smp_switch_boot_cpu_in_resume
175 /* Restore prefix register */
179 stosm __SF_EMPTY(%r15),0x04
182 lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15)