xref: /openbmc/linux/arch/s390/include/asm/lowcore.h (revision b627b4ed)
1 /*
2  *  include/asm-s390/lowcore.h
3  *
4  *  S390 version
5  *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6  *    Author(s): Hartmut Penner (hp@de.ibm.com),
7  *               Martin Schwidefsky (schwidefsky@de.ibm.com),
8  *               Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
9  */
10 
11 #ifndef _ASM_S390_LOWCORE_H
12 #define _ASM_S390_LOWCORE_H
13 
14 #define __LC_IPL_PARMBLOCK_PTR		0x0014
15 #define __LC_EXT_PARAMS			0x0080
16 #define __LC_CPU_ADDRESS		0x0084
17 #define __LC_EXT_INT_CODE		0x0086
18 
19 #define __LC_SVC_ILC			0x0088
20 #define __LC_SVC_INT_CODE		0x008a
21 #define __LC_PGM_ILC			0x008c
22 #define __LC_PGM_INT_CODE		0x008e
23 
24 #define __LC_PER_ATMID			0x0096
25 #define __LC_PER_ADDRESS		0x0098
26 #define __LC_PER_ACCESS_ID		0x00a1
27 #define __LC_AR_MODE_ID			0x00a3
28 
29 #define __LC_SUBCHANNEL_ID		0x00b8
30 #define __LC_SUBCHANNEL_NR		0x00ba
31 #define __LC_IO_INT_PARM		0x00bc
32 #define __LC_IO_INT_WORD		0x00c0
33 #define __LC_MCCK_CODE			0x00e8
34 
35 #define __LC_DUMP_REIPL			0x0e00
36 
37 #ifndef __s390x__
38 #define __LC_EXT_OLD_PSW		0x0018
39 #define __LC_SVC_OLD_PSW		0x0020
40 #define __LC_PGM_OLD_PSW		0x0028
41 #define __LC_MCK_OLD_PSW		0x0030
42 #define __LC_IO_OLD_PSW			0x0038
43 #define __LC_EXT_NEW_PSW		0x0058
44 #define __LC_SVC_NEW_PSW		0x0060
45 #define __LC_PGM_NEW_PSW		0x0068
46 #define __LC_MCK_NEW_PSW		0x0070
47 #define __LC_IO_NEW_PSW			0x0078
48 #define __LC_SAVE_AREA			0x0200
49 #define __LC_RETURN_PSW			0x0240
50 #define __LC_RETURN_MCCK_PSW		0x0248
51 #define __LC_SYNC_ENTER_TIMER		0x0250
52 #define __LC_ASYNC_ENTER_TIMER		0x0258
53 #define __LC_EXIT_TIMER			0x0260
54 #define __LC_USER_TIMER			0x0268
55 #define __LC_SYSTEM_TIMER		0x0270
56 #define __LC_STEAL_TIMER		0x0278
57 #define __LC_LAST_UPDATE_TIMER		0x0280
58 #define __LC_LAST_UPDATE_CLOCK		0x0288
59 #define __LC_CURRENT			0x0290
60 #define __LC_THREAD_INFO		0x0294
61 #define __LC_KERNEL_STACK		0x0298
62 #define __LC_ASYNC_STACK		0x029c
63 #define __LC_PANIC_STACK		0x02a0
64 #define __LC_KERNEL_ASCE		0x02a4
65 #define __LC_USER_ASCE			0x02a8
66 #define __LC_USER_EXEC_ASCE		0x02ac
67 #define __LC_CPUID			0x02b0
68 #define __LC_INT_CLOCK			0x02c8
69 #define __LC_IRB			0x0300
70 #define __LC_PFAULT_INTPARM		0x0080
71 #define __LC_CPU_TIMER_SAVE_AREA	0x00d8
72 #define __LC_CLOCK_COMP_SAVE_AREA	0x00e0
73 #define __LC_PSW_SAVE_AREA		0x0100
74 #define __LC_PREFIX_SAVE_AREA		0x0108
75 #define __LC_AREGS_SAVE_AREA		0x0120
76 #define __LC_FPREGS_SAVE_AREA		0x0160
77 #define __LC_GPREGS_SAVE_AREA		0x0180
78 #define __LC_CREGS_SAVE_AREA		0x01c0
79 #else /* __s390x__ */
80 #define __LC_LAST_BREAK			0x0110
81 #define __LC_EXT_OLD_PSW		0x0130
82 #define __LC_SVC_OLD_PSW		0x0140
83 #define __LC_PGM_OLD_PSW		0x0150
84 #define __LC_MCK_OLD_PSW		0x0160
85 #define __LC_IO_OLD_PSW			0x0170
86 #define __LC_EXT_NEW_PSW		0x01b0
87 #define __LC_SVC_NEW_PSW		0x01c0
88 #define __LC_PGM_NEW_PSW		0x01d0
89 #define __LC_MCK_NEW_PSW		0x01e0
90 #define __LC_IO_NEW_PSW			0x01f0
91 #define __LC_SAVE_AREA			0x0200
92 #define __LC_RETURN_PSW			0x0280
93 #define __LC_RETURN_MCCK_PSW		0x0290
94 #define __LC_SYNC_ENTER_TIMER		0x02a0
95 #define __LC_ASYNC_ENTER_TIMER		0x02a8
96 #define __LC_EXIT_TIMER			0x02b0
97 #define __LC_USER_TIMER			0x02b8
98 #define __LC_SYSTEM_TIMER		0x02c0
99 #define __LC_STEAL_TIMER		0x02c8
100 #define __LC_LAST_UPDATE_TIMER		0x02d0
101 #define __LC_LAST_UPDATE_CLOCK		0x02d8
102 #define __LC_CURRENT			0x02e0
103 #define __LC_THREAD_INFO		0x02e8
104 #define __LC_KERNEL_STACK		0x02f0
105 #define __LC_ASYNC_STACK		0x02f8
106 #define __LC_PANIC_STACK		0x0300
107 #define __LC_KERNEL_ASCE		0x0308
108 #define __LC_USER_ASCE			0x0310
109 #define __LC_USER_EXEC_ASCE		0x0318
110 #define __LC_CPUID			0x0320
111 #define __LC_INT_CLOCK			0x0340
112 #define __LC_VDSO_PER_CPU		0x0350
113 #define __LC_IRB			0x0380
114 #define __LC_PASTE			0x03c0
115 #define __LC_PFAULT_INTPARM		0x11b8
116 #define __LC_FPREGS_SAVE_AREA		0x1200
117 #define __LC_GPREGS_SAVE_AREA		0x1280
118 #define __LC_PSW_SAVE_AREA		0x1300
119 #define __LC_PREFIX_SAVE_AREA		0x1318
120 #define __LC_FP_CREG_SAVE_AREA		0x131c
121 #define __LC_TODREG_SAVE_AREA		0x1324
122 #define __LC_CPU_TIMER_SAVE_AREA	0x1328
123 #define __LC_CLOCK_COMP_SAVE_AREA	0x1331
124 #define __LC_AREGS_SAVE_AREA		0x1340
125 #define __LC_CREGS_SAVE_AREA		0x1380
126 #endif /* __s390x__ */
127 
128 #ifndef __ASSEMBLY__
129 
130 #include <asm/processor.h>
131 #include <linux/types.h>
132 #include <asm/sigp.h>
133 
134 void restart_int_handler(void);
135 void ext_int_handler(void);
136 void system_call(void);
137 void pgm_check_handler(void);
138 void mcck_int_handler(void);
139 void io_int_handler(void);
140 
141 struct save_area_s390 {
142 	u32	ext_save;
143 	u64	timer;
144 	u64	clk_cmp;
145 	u8	pad1[24];
146 	u8	psw[8];
147 	u32	pref_reg;
148 	u8	pad2[20];
149 	u32	acc_regs[16];
150 	u64	fp_regs[4];
151 	u32	gp_regs[16];
152 	u32	ctrl_regs[16];
153 }  __attribute__((packed));
154 
155 struct save_area_s390x {
156 	u64	fp_regs[16];
157 	u64	gp_regs[16];
158 	u8	psw[16];
159 	u8	pad1[8];
160 	u32	pref_reg;
161 	u32	fp_ctrl_reg;
162 	u8	pad2[4];
163 	u32	tod_reg;
164 	u64	timer;
165 	u64	clk_cmp;
166 	u8	pad3[8];
167 	u32	acc_regs[16];
168 	u64	ctrl_regs[16];
169 }  __attribute__((packed));
170 
171 union save_area {
172 	struct save_area_s390	s390;
173 	struct save_area_s390x	s390x;
174 };
175 
176 #define SAVE_AREA_BASE_S390	0xd4
177 #define SAVE_AREA_BASE_S390X	0x1200
178 
179 #ifndef __s390x__
180 #define SAVE_AREA_SIZE sizeof(struct save_area_s390)
181 #define SAVE_AREA_BASE SAVE_AREA_BASE_S390
182 #else
183 #define SAVE_AREA_SIZE sizeof(struct save_area_s390x)
184 #define SAVE_AREA_BASE SAVE_AREA_BASE_S390X
185 #endif
186 
187 struct _lowcore
188 {
189 #ifndef __s390x__
190 	/* 0x0000 - 0x01ff: defined by architecture */
191 	psw_t	restart_psw;			/* 0x0000 */
192 	__u32	ccw2[4];			/* 0x0008 */
193 	psw_t	external_old_psw;		/* 0x0018 */
194 	psw_t	svc_old_psw;			/* 0x0020 */
195 	psw_t	program_old_psw;		/* 0x0028 */
196 	psw_t	mcck_old_psw;			/* 0x0030 */
197 	psw_t	io_old_psw;			/* 0x0038 */
198 	__u8	pad_0x0040[0x0058-0x0040];	/* 0x0040 */
199 	psw_t	external_new_psw;		/* 0x0058 */
200 	psw_t	svc_new_psw;			/* 0x0060 */
201 	psw_t	program_new_psw;		/* 0x0068 */
202 	psw_t	mcck_new_psw;			/* 0x0070 */
203 	psw_t	io_new_psw;			/* 0x0078 */
204 	__u32	ext_params;			/* 0x0080 */
205 	__u16	cpu_addr;			/* 0x0084 */
206 	__u16	ext_int_code;			/* 0x0086 */
207 	__u16	svc_ilc;			/* 0x0088 */
208 	__u16	svc_code;			/* 0x008a */
209 	__u16	pgm_ilc;			/* 0x008c */
210 	__u16	pgm_code;			/* 0x008e */
211 	__u32	trans_exc_code;			/* 0x0090 */
212 	__u16	mon_class_num;			/* 0x0094 */
213 	__u16	per_perc_atmid;			/* 0x0096 */
214 	__u32	per_address;			/* 0x0098 */
215 	__u32	monitor_code;			/* 0x009c */
216 	__u8	exc_access_id;			/* 0x00a0 */
217 	__u8	per_access_id;			/* 0x00a1 */
218 	__u8	pad_0x00a2[0x00b8-0x00a2];	/* 0x00a2 */
219 	__u16	subchannel_id;			/* 0x00b8 */
220 	__u16	subchannel_nr;			/* 0x00ba */
221 	__u32	io_int_parm;			/* 0x00bc */
222 	__u32	io_int_word;			/* 0x00c0 */
223 	__u8	pad_0x00c4[0x00c8-0x00c4];	/* 0x00c4 */
224 	__u32	stfl_fac_list;			/* 0x00c8 */
225 	__u8	pad_0x00cc[0x00d4-0x00cc];	/* 0x00cc */
226 	__u32	extended_save_area_addr;	/* 0x00d4 */
227 	__u32	cpu_timer_save_area[2];		/* 0x00d8 */
228 	__u32	clock_comp_save_area[2];	/* 0x00e0 */
229 	__u32	mcck_interruption_code[2];	/* 0x00e8 */
230 	__u8	pad_0x00f0[0x00f4-0x00f0];	/* 0x00f0 */
231 	__u32	external_damage_code;		/* 0x00f4 */
232 	__u32	failing_storage_address;	/* 0x00f8 */
233 	__u8	pad_0x00fc[0x0100-0x00fc];	/* 0x00fc */
234 	__u32	st_status_fixed_logout[4];	/* 0x0100 */
235 	__u8	pad_0x0110[0x0120-0x0110];	/* 0x0110 */
236 
237 	/* CPU register save area: defined by architecture */
238 	__u32	access_regs_save_area[16];	/* 0x0120 */
239 	__u32	floating_pt_save_area[8];	/* 0x0160 */
240 	__u32	gpregs_save_area[16];		/* 0x0180 */
241 	__u32	cregs_save_area[16];		/* 0x01c0 */
242 
243 	/* Return psws. */
244 	__u32	save_area[16];			/* 0x0200 */
245 	psw_t	return_psw;			/* 0x0240 */
246 	psw_t	return_mcck_psw;		/* 0x0248 */
247 
248 	/* CPU time accounting values */
249 	__u64	sync_enter_timer;		/* 0x0250 */
250 	__u64	async_enter_timer;		/* 0x0258 */
251 	__u64	exit_timer;			/* 0x0260 */
252 	__u64	user_timer;			/* 0x0268 */
253 	__u64	system_timer;			/* 0x0270 */
254 	__u64	steal_timer;			/* 0x0278 */
255 	__u64	last_update_timer;		/* 0x0280 */
256 	__u64	last_update_clock;		/* 0x0288 */
257 
258 	/* Current process. */
259 	__u32	current_task;			/* 0x0290 */
260 	__u32	thread_info;			/* 0x0294 */
261 	__u32	kernel_stack;			/* 0x0298 */
262 
263 	/* Interrupt and panic stack. */
264 	__u32	async_stack;			/* 0x029c */
265 	__u32	panic_stack;			/* 0x02a0 */
266 
267 	/* Address space pointer. */
268 	__u32	kernel_asce;			/* 0x02a4 */
269 	__u32	user_asce;			/* 0x02a8 */
270 	__u32	user_exec_asce;			/* 0x02ac */
271 
272 	/* SMP info area */
273 	cpuid_t	cpu_id;				/* 0x02b0 */
274 	__u32	cpu_nr;				/* 0x02b8 */
275 	__u32	softirq_pending;		/* 0x02bc */
276 	__u32	percpu_offset;			/* 0x02c0 */
277 	__u32	ext_call_fast;			/* 0x02c4 */
278 	__u64	int_clock;			/* 0x02c8 */
279 	__u64	clock_comparator;		/* 0x02d0 */
280 	__u8	pad_0x02d8[0x0300-0x02d8];	/* 0x02d8 */
281 
282 	/* Interrupt response block */
283 	__u8	irb[64];			/* 0x0300 */
284 
285 	__u8	pad_0x0400[0x0e00-0x0400];	/* 0x0400 */
286 
287 	/*
288 	 * 0xe00 contains the address of the IPL Parameter Information
289 	 * block. Dump tools need IPIB for IPL after dump.
290 	 * Note: do not change the position of any fields in 0x0e00-0x0f00
291 	 */
292 	__u32	ipib;				/* 0x0e00 */
293 	__u32	ipib_checksum;			/* 0x0e04 */
294 
295 	/* Align to the top 1k of prefix area */
296 	__u8	pad_0x0e08[0x1000-0x0e08];	/* 0x0e08 */
297 #else /* !__s390x__ */
298 	/* 0x0000 - 0x01ff: defined by architecture */
299 	__u32	ccw1[2];			/* 0x0000 */
300 	__u32	ccw2[4];			/* 0x0008 */
301 	__u8	pad_0x0018[0x0080-0x0018];	/* 0x0018 */
302 	__u32	ext_params;			/* 0x0080 */
303 	__u16	cpu_addr;			/* 0x0084 */
304 	__u16	ext_int_code;			/* 0x0086 */
305 	__u16	svc_ilc;			/* 0x0088 */
306 	__u16	svc_code;			/* 0x008a */
307 	__u16	pgm_ilc;			/* 0x008c */
308 	__u16	pgm_code;			/* 0x008e */
309 	__u32	data_exc_code;			/* 0x0090 */
310 	__u16	mon_class_num;			/* 0x0094 */
311 	__u16	per_perc_atmid;			/* 0x0096 */
312 	addr_t	per_address;			/* 0x0098 */
313 	__u8	exc_access_id;			/* 0x00a0 */
314 	__u8	per_access_id;			/* 0x00a1 */
315 	__u8	op_access_id;			/* 0x00a2 */
316 	__u8	ar_access_id;			/* 0x00a3 */
317 	__u8	pad_0x00a4[0x00a8-0x00a4];	/* 0x00a4 */
318 	addr_t	trans_exc_code;			/* 0x00a8 */
319 	addr_t	monitor_code;			/* 0x00b0 */
320 	__u16	subchannel_id;			/* 0x00b8 */
321 	__u16	subchannel_nr;			/* 0x00ba */
322 	__u32	io_int_parm;			/* 0x00bc */
323 	__u32	io_int_word;			/* 0x00c0 */
324 	__u8	pad_0x00c4[0x00c8-0x00c4];	/* 0x00c4 */
325 	__u32	stfl_fac_list;			/* 0x00c8 */
326 	__u8	pad_0x00cc[0x00e8-0x00cc];	/* 0x00cc */
327 	__u32	mcck_interruption_code[2];	/* 0x00e8 */
328 	__u8	pad_0x00f0[0x00f4-0x00f0];	/* 0x00f0 */
329 	__u32	external_damage_code;		/* 0x00f4 */
330 	addr_t	failing_storage_address;	/* 0x00f8 */
331 	__u8	pad_0x0100[0x0120-0x0100];	/* 0x0100 */
332 	psw_t	restart_old_psw;		/* 0x0120 */
333 	psw_t	external_old_psw;		/* 0x0130 */
334 	psw_t	svc_old_psw;			/* 0x0140 */
335 	psw_t	program_old_psw;		/* 0x0150 */
336 	psw_t	mcck_old_psw;			/* 0x0160 */
337 	psw_t	io_old_psw;			/* 0x0170 */
338 	__u8	pad_0x0180[0x01a0-0x0180];	/* 0x0180 */
339 	psw_t	restart_psw;			/* 0x01a0 */
340 	psw_t	external_new_psw;		/* 0x01b0 */
341 	psw_t	svc_new_psw;			/* 0x01c0 */
342 	psw_t	program_new_psw;		/* 0x01d0 */
343 	psw_t	mcck_new_psw;			/* 0x01e0 */
344 	psw_t	io_new_psw;			/* 0x01f0 */
345 
346 	/* Entry/exit save area & return psws. */
347 	__u64	save_area[16];			/* 0x0200 */
348 	psw_t	return_psw;			/* 0x0280 */
349 	psw_t	return_mcck_psw;		/* 0x0290 */
350 
351 	/* CPU accounting and timing values. */
352 	__u64	sync_enter_timer;		/* 0x02a0 */
353 	__u64	async_enter_timer;		/* 0x02a8 */
354 	__u64	exit_timer;			/* 0x02b0 */
355 	__u64	user_timer;			/* 0x02b8 */
356 	__u64	system_timer;			/* 0x02c0 */
357 	__u64	steal_timer;			/* 0x02c8 */
358 	__u64	last_update_timer;		/* 0x02d0 */
359 	__u64	last_update_clock;		/* 0x02d8 */
360 
361 	/* Current process. */
362 	__u64	current_task;			/* 0x02e0 */
363 	__u64	thread_info;			/* 0x02e8 */
364 	__u64	kernel_stack;			/* 0x02f0 */
365 
366 	/* Interrupt and panic stack. */
367 	__u64	async_stack;			/* 0x02f8 */
368 	__u64	panic_stack;			/* 0x0300 */
369 
370 	/* Address space pointer. */
371 	__u64	kernel_asce;			/* 0x0308 */
372 	__u64	user_asce;			/* 0x0310 */
373 	__u64	user_exec_asce;			/* 0x0318 */
374 
375 	/* SMP info area */
376 	cpuid_t	cpu_id;				/* 0x0320 */
377 	__u32	cpu_nr;				/* 0x0328 */
378 	__u32	softirq_pending;		/* 0x032c */
379 	__u64	percpu_offset;			/* 0x0330 */
380 	__u64	ext_call_fast;			/* 0x0338 */
381 	__u64	int_clock;			/* 0x0340 */
382 	__u64	clock_comparator;		/* 0x0348 */
383 	__u64	vdso_per_cpu_data;		/* 0x0350 */
384 	__u8	pad_0x0358[0x0380-0x0358];	/* 0x0358 */
385 
386 	/* Interrupt response block. */
387 	__u8	irb[64];			/* 0x0380 */
388 
389 	/* Per cpu primary space access list */
390 	__u32	paste[16];			/* 0x03c0 */
391 
392 	__u8	pad_0x0400[0x0e00-0x0400];	/* 0x0400 */
393 
394 	/*
395 	 * 0xe00 contains the address of the IPL Parameter Information
396 	 * block. Dump tools need IPIB for IPL after dump.
397 	 * Note: do not change the position of any fields in 0x0e00-0x0f00
398 	 */
399 	__u64	ipib;				/* 0x0e00 */
400 	__u32	ipib_checksum;			/* 0x0e08 */
401 	__u8	pad_0x0e0c[0x11b8-0x0e0c];	/* 0x0e0c */
402 
403 	/* 64 bit extparam used for pfault/diag 250: defined by architecture */
404 	__u64	ext_params2;			/* 0x11B8 */
405 	__u8	pad_0x11c0[0x1200-0x11C0];	/* 0x11C0 */
406 
407 	/* CPU register save area: defined by architecture */
408 	__u64	floating_pt_save_area[16];	/* 0x1200 */
409 	__u64	gpregs_save_area[16];		/* 0x1280 */
410 	__u32	st_status_fixed_logout[4];	/* 0x1300 */
411 	__u8	pad_0x1310[0x1318-0x1310];	/* 0x1310 */
412 	__u32	prefixreg_save_area;		/* 0x1318 */
413 	__u32	fpt_creg_save_area;		/* 0x131c */
414 	__u8	pad_0x1320[0x1324-0x1320];	/* 0x1320 */
415 	__u32	tod_progreg_save_area;		/* 0x1324 */
416 	__u32	cpu_timer_save_area[2];		/* 0x1328 */
417 	__u32	clock_comp_save_area[2];	/* 0x1330 */
418 	__u8	pad_0x1338[0x1340-0x1338];	/* 0x1338 */
419 	__u32	access_regs_save_area[16];	/* 0x1340 */
420 	__u64	cregs_save_area[16];		/* 0x1380 */
421 
422 	/* align to the top of the prefix area */
423 	__u8	pad_0x1400[0x2000-0x1400];	/* 0x1400 */
424 #endif /* !__s390x__ */
425 } __attribute__((packed)); /* End structure*/
426 
427 #define S390_lowcore (*((struct _lowcore *) 0))
428 extern struct _lowcore *lowcore_ptr[];
429 
430 static inline void set_prefix(__u32 address)
431 {
432 	asm volatile("spx %0" : : "m" (address) : "memory");
433 }
434 
435 static inline __u32 store_prefix(void)
436 {
437 	__u32 address;
438 
439 	asm volatile("stpx %0" : "=m" (address));
440 	return address;
441 }
442 
443 #endif
444 
445 #endif
446