xref: /linux/arch/s390/boot/pgm_check_info.c (revision 17cfcb68af3bc7d5e8ae08779b1853310a2949f3)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/string.h>
4 #include <asm/lowcore.h>
5 #include <asm/sclp.h>
6 #include "boot.h"
7 
8 const char hex_asc[] = "0123456789abcdef";
9 
10 #define add_val_as_hex(dst, val)					       \
11 	__add_val_as_hex(dst, (const unsigned char *)&val, sizeof(val))
12 
13 static char *__add_val_as_hex(char *dst, const unsigned char *src, size_t count)
14 {
15 	while (count--)
16 		dst = hex_byte_pack(dst, *src++);
17 	return dst;
18 }
19 
20 static char *add_str(char *dst, char *src)
21 {
22 	strcpy(dst, src);
23 	return dst + strlen(dst);
24 }
25 
26 void print_pgm_check_info(void)
27 {
28 	struct psw_bits *psw = &psw_bits(S390_lowcore.psw_save_area);
29 	unsigned short ilc = S390_lowcore.pgm_ilc >> 1;
30 	char buf[256];
31 	int row, col;
32 	char *p;
33 
34 	add_str(buf, "Linux version ");
35 	strlcat(buf, kernel_version, sizeof(buf));
36 	sclp_early_printk(buf);
37 
38 	p = add_str(buf, "Kernel fault: interruption code ");
39 	p = add_val_as_hex(buf + strlen(buf), S390_lowcore.pgm_code);
40 	p = add_str(p, " ilc:");
41 	*p++ = hex_asc_lo(ilc);
42 	add_str(p, "\n");
43 	sclp_early_printk(buf);
44 
45 	p = add_str(buf, "PSW : ");
46 	p = add_val_as_hex(p, S390_lowcore.psw_save_area.mask);
47 	p = add_str(p, " ");
48 	p = add_val_as_hex(p, S390_lowcore.psw_save_area.addr);
49 	add_str(p, "\n");
50 	sclp_early_printk(buf);
51 
52 	p = add_str(buf, "      R:");
53 	*p++ = hex_asc_lo(psw->per);
54 	p = add_str(p, " T:");
55 	*p++ = hex_asc_lo(psw->dat);
56 	p = add_str(p, " IO:");
57 	*p++ = hex_asc_lo(psw->io);
58 	p = add_str(p, " EX:");
59 	*p++ = hex_asc_lo(psw->ext);
60 	p = add_str(p, " Key:");
61 	*p++ = hex_asc_lo(psw->key);
62 	p = add_str(p, " M:");
63 	*p++ = hex_asc_lo(psw->mcheck);
64 	p = add_str(p, " W:");
65 	*p++ = hex_asc_lo(psw->wait);
66 	p = add_str(p, " P:");
67 	*p++ = hex_asc_lo(psw->pstate);
68 	p = add_str(p, " AS:");
69 	*p++ = hex_asc_lo(psw->as);
70 	p = add_str(p, " CC:");
71 	*p++ = hex_asc_lo(psw->cc);
72 	p = add_str(p, " PM:");
73 	*p++ = hex_asc_lo(psw->pm);
74 	p = add_str(p, " RI:");
75 	*p++ = hex_asc_lo(psw->ri);
76 	p = add_str(p, " EA:");
77 	*p++ = hex_asc_lo(psw->eaba);
78 	add_str(p, "\n");
79 	sclp_early_printk(buf);
80 
81 	for (row = 0; row < 4; row++) {
82 		p = add_str(buf, row == 0 ? "GPRS:" : "     ");
83 		for (col = 0; col < 4; col++) {
84 			p = add_str(p, " ");
85 			p = add_val_as_hex(p, S390_lowcore.gpregs_save_area[row * 4 + col]);
86 		}
87 		add_str(p, "\n");
88 		sclp_early_printk(buf);
89 	}
90 }
91