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