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
15ENTRY(s390_base_mcck_handler)
16	basr	%r13,0
170:	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
241:	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
31s390_base_mcck_handler_fn:
32	.quad	0
33	.previous
34
35ENTRY(s390_base_ext_handler)
36	stmg	%r0,%r15,__LC_SAVE_AREA_ASYNC
37	basr	%r13,0
380:	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
441:	lmg	%r0,%r15,__LC_SAVE_AREA_ASYNC
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
51s390_base_ext_handler_fn:
52	.quad	0
53	.previous
54
55ENTRY(s390_base_pgm_handler)
56	stmg	%r0,%r15,__LC_SAVE_AREA_SYNC
57	basr	%r13,0
580:	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_SYNC
65	lpswe	__LC_PGM_OLD_PSW
661:	lpswe	disabled_wait_psw-0b(%r13)
67
68	.align	8
69disabled_wait_psw:
70	.quad	0x0002000180000000,0x0000000000000000 + s390_base_pgm_handler
71
72	.section .bss
73	.align 8
74	.globl s390_base_pgm_handler_fn
75s390_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#
86ENTRY(diag308_reset)
87	larl	%r4,.Lctlregs		# Save control registers
88	stctg	%c0,%c15,0(%r4)
89	larl	%r4,.Lfpctl		# Floating point control register
90	stfpc	0(%r4)
91	larl	%r4,.Lrestart_psw	# Setup restart PSW at absolute 0
92	lghi	%r3,0
93	lg	%r4,0(%r4)		# Save PSW
94	sturg	%r4,%r3			# Use sturg, because of large pages
95	lghi	%r1,1
96	diag	%r1,%r1,0x308
97.Lrestart_part2:
98	lhi	%r0,0			# Load r0 with zero
99	lhi	%r1,2			# Use mode 2 = ESAME (dump)
100	sigp	%r1,%r0,0x12		# Switch to ESAME mode
101	sam64				# Switch to 64 bit addressing mode
102	larl	%r4,.Lctlregs		# Restore control registers
103	lctlg	%c0,%c15,0(%r4)
104	larl	%r4,.Lfpctl		# Restore floating point ctl register
105	lfpc	0(%r4)
106	br	%r14
107.align 16
108.Lrestart_psw:
109	.long	0x00080000,0x80000000 + .Lrestart_part2
110
111	.section .bss
112.align 8
113.Lctlregs:
114	.rept	16
115	.quad	0
116	.endr
117.Lfpctl:
118	.long	0
119	.previous
120
121#else /* CONFIG_64BIT */
122
123ENTRY(s390_base_mcck_handler)
124	basr	%r13,0
1250:	l	%r15,__LC_PANIC_STACK	# load panic stack
126	ahi	%r15,-STACK_FRAME_OVERHEAD
127	l	%r1,2f-0b(%r13)
128	l	%r1,0(%r1)
129	ltr	%r1,%r1
130	jz	1f
131	basr	%r14,%r1
1321:	lm	%r0,%r15,__LC_GPREGS_SAVE_AREA
133	lpsw	__LC_MCK_OLD_PSW
134
1352:	.long	s390_base_mcck_handler_fn
136
137	.section .bss
138	.align 4
139	.globl	s390_base_mcck_handler_fn
140s390_base_mcck_handler_fn:
141	.long	0
142	.previous
143
144ENTRY(s390_base_ext_handler)
145	stm	%r0,%r15,__LC_SAVE_AREA_ASYNC
146	basr	%r13,0
1470:	ahi	%r15,-STACK_FRAME_OVERHEAD
148	l	%r1,2f-0b(%r13)
149	l	%r1,0(%r1)
150	ltr	%r1,%r1
151	jz	1f
152	basr	%r14,%r1
1531:	lm	%r0,%r15,__LC_SAVE_AREA_ASYNC
154	ni	__LC_EXT_OLD_PSW+1,0xfd	# clear wait state bit
155	lpsw	__LC_EXT_OLD_PSW
156
1572:	.long	s390_base_ext_handler_fn
158
159	.section .bss
160	.align 4
161	.globl	s390_base_ext_handler_fn
162s390_base_ext_handler_fn:
163	.long	0
164	.previous
165
166ENTRY(s390_base_pgm_handler)
167	stm	%r0,%r15,__LC_SAVE_AREA_SYNC
168	basr	%r13,0
1690:	ahi	%r15,-STACK_FRAME_OVERHEAD
170	l	%r1,2f-0b(%r13)
171	l	%r1,0(%r1)
172	ltr	%r1,%r1
173	jz	1f
174	basr	%r14,%r1
175	lm	%r0,%r15,__LC_SAVE_AREA_SYNC
176	lpsw	__LC_PGM_OLD_PSW
177
1781:	lpsw	disabled_wait_psw-0b(%r13)
179
1802:	.long	s390_base_pgm_handler_fn
181
182disabled_wait_psw:
183	.align	8
184	.long	0x000a0000,0x00000000 + s390_base_pgm_handler
185
186	.section .bss
187	.align 4
188	.globl	s390_base_pgm_handler_fn
189s390_base_pgm_handler_fn:
190	.long	0
191	.previous
192
193#endif /* CONFIG_64BIT */
194