255435663bf820299734afdce573fa52050e9d87
[linux-3.10.git] / arch / s390 / kernel / base.S
1 /*
2  *  arch/s390/kernel/base.S
3  *
4  *    Copyright IBM Corp. 2006,2007
5  *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6  *               Michael Holzheu <holzheu@de.ibm.com>
7  */
8
9 #include <linux/linkage.h>
10 #include <asm/asm-offsets.h>
11 #include <asm/ptrace.h>
12
13 #ifdef CONFIG_64BIT
14
15 ENTRY(s390_base_mcck_handler)
16         basr    %r13,0
17 0:      lg      %r15,__LC_PANIC_STACK   # load panic stack
18         aghi    %r15,-STACK_FRAME_OVERHEAD
19         larl    %r1,s390_base_mcck_handler_fn
20         lg      %r1,0(%r1)
21         ltgr    %r1,%r1
22         jz      1f
23         basr    %r14,%r1
24 1:      la      %r1,4095
25         lmg     %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)
26         lpswe   __LC_MCK_OLD_PSW
27
28         .section .bss
29         .align 8
30         .globl  s390_base_mcck_handler_fn
31 s390_base_mcck_handler_fn:
32         .quad   0
33         .previous
34
35 ENTRY(s390_base_ext_handler)
36         stmg    %r0,%r15,__LC_SAVE_AREA
37         basr    %r13,0
38 0:      aghi    %r15,-STACK_FRAME_OVERHEAD
39         larl    %r1,s390_base_ext_handler_fn
40         lg      %r1,0(%r1)
41         ltgr    %r1,%r1
42         jz      1f
43         basr    %r14,%r1
44 1:      lmg     %r0,%r15,__LC_SAVE_AREA
45         ni      __LC_EXT_OLD_PSW+1,0xfd # clear wait state bit
46         lpswe   __LC_EXT_OLD_PSW
47
48         .section .bss
49         .align 8
50         .globl s390_base_ext_handler_fn
51 s390_base_ext_handler_fn:
52         .quad   0
53         .previous
54
55 ENTRY(s390_base_pgm_handler)
56         stmg    %r0,%r15,__LC_SAVE_AREA
57         basr    %r13,0
58 0:      aghi    %r15,-STACK_FRAME_OVERHEAD
59         larl    %r1,s390_base_pgm_handler_fn
60         lg      %r1,0(%r1)
61         ltgr    %r1,%r1
62         jz      1f
63         basr    %r14,%r1
64         lmg     %r0,%r15,__LC_SAVE_AREA
65         lpswe   __LC_PGM_OLD_PSW
66 1:      lpswe   disabled_wait_psw-0b(%r13)
67
68         .align  8
69 disabled_wait_psw:
70         .quad   0x0002000180000000,0x0000000000000000 + s390_base_pgm_handler
71
72         .section .bss
73         .align 8
74         .globl s390_base_pgm_handler_fn
75 s390_base_pgm_handler_fn:
76         .quad   0
77         .previous
78
79 #
80 # Calls diag 308 subcode 1 and continues execution
81 #
82 # The following conditions must be ensured before calling this function:
83 # * Prefix register = 0
84 # * Lowcore protection is disabled
85 #
86 ENTRY(diag308_reset)
87         larl    %r4,.Lctlregs           # Save control registers
88         stctg   %c0,%c15,0(%r4)
89         larl    %r4,.Lrestart_psw       # Setup restart PSW at absolute 0
90         lghi    %r3,0
91         lg      %r4,0(%r4)              # Save PSW
92         sturg   %r4,%r3                 # Use sturg, because of large pages
93         lghi    %r1,1
94         diag    %r1,%r1,0x308
95 .Lrestart_part2:
96         lhi     %r0,0                   # Load r0 with zero
97         lhi     %r1,2                   # Use mode 2 = ESAME (dump)
98         sigp    %r1,%r0,0x12            # Switch to ESAME mode
99         sam64                           # Switch to 64 bit addressing mode
100         larl    %r4,.Lctlregs           # Restore control registers
101         lctlg   %c0,%c15,0(%r4)
102         br      %r14
103 .align 16
104 .Lrestart_psw:
105         .long   0x00080000,0x80000000 + .Lrestart_part2
106
107         .section .bss
108 .align 8
109 .Lctlregs:
110         .rept   16
111         .quad   0
112         .endr
113         .previous
114
115 #else /* CONFIG_64BIT */
116
117 ENTRY(s390_base_mcck_handler)
118         basr    %r13,0
119 0:      l       %r15,__LC_PANIC_STACK   # load panic stack
120         ahi     %r15,-STACK_FRAME_OVERHEAD
121         l       %r1,2f-0b(%r13)
122         l       %r1,0(%r1)
123         ltr     %r1,%r1
124         jz      1f
125         basr    %r14,%r1
126 1:      lm      %r0,%r15,__LC_GPREGS_SAVE_AREA
127         lpsw    __LC_MCK_OLD_PSW
128
129 2:      .long   s390_base_mcck_handler_fn
130
131         .section .bss
132         .align 4
133         .globl  s390_base_mcck_handler_fn
134 s390_base_mcck_handler_fn:
135         .long   0
136         .previous
137
138 ENTRY(s390_base_ext_handler)
139         stm     %r0,%r15,__LC_SAVE_AREA
140         basr    %r13,0
141 0:      ahi     %r15,-STACK_FRAME_OVERHEAD
142         l       %r1,2f-0b(%r13)
143         l       %r1,0(%r1)
144         ltr     %r1,%r1
145         jz      1f
146         basr    %r14,%r1
147 1:      lm      %r0,%r15,__LC_SAVE_AREA
148         ni      __LC_EXT_OLD_PSW+1,0xfd # clear wait state bit
149         lpsw    __LC_EXT_OLD_PSW
150
151 2:      .long   s390_base_ext_handler_fn
152
153         .section .bss
154         .align 4
155         .globl  s390_base_ext_handler_fn
156 s390_base_ext_handler_fn:
157         .long   0
158         .previous
159
160 ENTRY(s390_base_pgm_handler)
161         stm     %r0,%r15,__LC_SAVE_AREA
162         basr    %r13,0
163 0:      ahi     %r15,-STACK_FRAME_OVERHEAD
164         l       %r1,2f-0b(%r13)
165         l       %r1,0(%r1)
166         ltr     %r1,%r1
167         jz      1f
168         basr    %r14,%r1
169         lm      %r0,%r15,__LC_SAVE_AREA
170         lpsw    __LC_PGM_OLD_PSW
171
172 1:      lpsw    disabled_wait_psw-0b(%r13)
173
174 2:      .long   s390_base_pgm_handler_fn
175
176 disabled_wait_psw:
177         .align  8
178         .long   0x000a0000,0x00000000 + s390_base_pgm_handler
179
180         .section .bss
181         .align 4
182         .globl  s390_base_pgm_handler_fn
183 s390_base_pgm_handler_fn:
184         .long   0
185         .previous
186
187 #endif /* CONFIG_64BIT */