1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright IBM Corp. 2016
5 #include <linux/kernel.h>
6 #include <asm/processor.h>
7 #include <asm/facility.h>
8 #include <asm/lowcore.h>
13 * The code within this file will be called very early. It may _not_
14 * access anything within the bss section, since that is not cleared
15 * yet and may contain data (e.g. initrd) that must be saved by other
17 * For temporary objects the stack (16k) should be used.
20 static unsigned long als
[] = { FACILITIES_ALS
};
22 static void u16_to_hex(char *str
, u16 val
)
26 for (i
= 1; i
<= 4; i
++) {
27 num
= (val
>> (16 - 4 * i
)) & 0xf;
35 static void print_machine_type(void)
37 static char mach_str
[80] = "Detected machine-type number: ";
42 u16_to_hex(type_str
, id
.machine
);
43 strcat(mach_str
, type_str
);
44 strcat(mach_str
, "\n");
45 sclp_early_printk(mach_str
);
48 static void u16_to_decimal(char *str
, u16 val
)
52 while (div
* 10 <= val
)
55 *str
++ = '0' + val
/ div
;
62 void print_missing_facilities(void)
64 static char als_str
[80] = "Missing facilities: ";
70 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
71 val
= ~S390_lowcore
.stfle_fac_list
[i
] & als
[i
];
72 for (j
= 0; j
< BITS_PER_LONG
; j
++) {
73 if (!(val
& (1UL << (BITS_PER_LONG
- 1 - j
))))
78 * Make sure we stay within one line. Consider that
79 * each facility bit adds up to five characters and
80 * z/VM adds a four character prefix.
82 if (strlen(als_str
) > 70) {
83 strcat(als_str
, "\n");
84 sclp_early_printk(als_str
);
87 u16_to_decimal(val_str
, i
* BITS_PER_LONG
+ j
);
88 strcat(als_str
, val_str
);
92 strcat(als_str
, "\n");
93 sclp_early_printk(als_str
);
96 static void facility_mismatch(void)
98 sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
100 print_missing_facilities();
101 sclp_early_printk("See Principles of Operations for facility bits\n");
105 void verify_facilities(void)
109 __stfle(S390_lowcore
.stfle_fac_list
, ARRAY_SIZE(S390_lowcore
.stfle_fac_list
));
110 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
111 if ((S390_lowcore
.stfle_fac_list
[i
] & als
[i
]) != als
[i
])