Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 *    Copyright IBM Corp. 2016
 4 */
 5#include <linux/kernel.h>
 6#include <asm/processor.h>
 7#include <asm/facility.h>
 8#include <asm/lowcore.h>
 9#include <asm/sclp.h>
10#include "boot.h"
11
 
 
 
 
 
 
 
 
12static unsigned long als[] = { FACILITIES_ALS };
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14static void u16_to_decimal(char *str, u16 val)
15{
16	int div = 1;
17
18	while (div * 10 <= val)
19		div *= 10;
20	while (div) {
21		*str++ = '0' + val / div;
22		val %= div;
23		div /= 10;
24	}
25	*str = '\0';
26}
27
28void print_missing_facilities(void)
29{
30	static char als_str[80] = "Missing facilities: ";
31	unsigned long val;
32	char val_str[6];
33	int i, j, first;
34
35	first = 1;
36	for (i = 0; i < ARRAY_SIZE(als); i++) {
37		val = ~stfle_fac_list[i] & als[i];
38		for (j = 0; j < BITS_PER_LONG; j++) {
39			if (!(val & (1UL << (BITS_PER_LONG - 1 - j))))
40				continue;
41			if (!first)
42				strcat(als_str, ",");
43			/*
44			 * Make sure we stay within one line. Consider that
45			 * each facility bit adds up to five characters and
46			 * z/VM adds a four character prefix.
47			 */
48			if (strlen(als_str) > 70) {
49				boot_printk("%s\n", als_str);
 
50				*als_str = '\0';
51			}
52			u16_to_decimal(val_str, i * BITS_PER_LONG + j);
53			strcat(als_str, val_str);
54			first = 0;
55		}
56	}
57	boot_printk("%s\n", als_str);
 
58}
59
60static void facility_mismatch(void)
61{
62	struct cpuid id;
63
64	get_cpu_id(&id);
65	boot_printk("The Linux kernel requires more recent processor hardware\n");
66	boot_printk("Detected machine-type number: %4x\n", id.machine);
67	print_missing_facilities();
68	boot_printk("See Principles of Operations for facility bits\n");
69	disabled_wait();
70}
71
72void verify_facilities(void)
73{
74	int i;
75
76	__stfle(stfle_fac_list, ARRAY_SIZE(stfle_fac_list));
77	for (i = 0; i < ARRAY_SIZE(als); i++) {
78		if ((stfle_fac_list[i] & als[i]) != als[i])
79			facility_mismatch();
80	}
81}
v5.9
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 *    Copyright IBM Corp. 2016
  4 */
  5#include <linux/kernel.h>
  6#include <asm/processor.h>
  7#include <asm/facility.h>
  8#include <asm/lowcore.h>
  9#include <asm/sclp.h>
 10#include "boot.h"
 11
 12/*
 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
 16 * code.
 17 * For temporary objects the stack (16k) should be used.
 18 */
 19
 20static unsigned long als[] = { FACILITIES_ALS };
 21
 22static void u16_to_hex(char *str, u16 val)
 23{
 24	int i, num;
 25
 26	for (i = 1; i <= 4; i++) {
 27		num = (val >> (16 - 4 * i)) & 0xf;
 28		if (num >= 10)
 29			num += 7;
 30		*str++ = '0' + num;
 31	}
 32	*str = '\0';
 33}
 34
 35static void print_machine_type(void)
 36{
 37	static char mach_str[80] = "Detected machine-type number: ";
 38	char type_str[5];
 39	struct cpuid id;
 40
 41	get_cpu_id(&id);
 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);
 46}
 47
 48static void u16_to_decimal(char *str, u16 val)
 49{
 50	int div = 1;
 51
 52	while (div * 10 <= val)
 53		div *= 10;
 54	while (div) {
 55		*str++ = '0' + val / div;
 56		val %= div;
 57		div /= 10;
 58	}
 59	*str = '\0';
 60}
 61
 62void print_missing_facilities(void)
 63{
 64	static char als_str[80] = "Missing facilities: ";
 65	unsigned long val;
 66	char val_str[6];
 67	int i, j, first;
 68
 69	first = 1;
 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))))
 74				continue;
 75			if (!first)
 76				strcat(als_str, ",");
 77			/*
 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.
 81			 */
 82			if (strlen(als_str) > 70) {
 83				strcat(als_str, "\n");
 84				sclp_early_printk(als_str);
 85				*als_str = '\0';
 86			}
 87			u16_to_decimal(val_str, i * BITS_PER_LONG + j);
 88			strcat(als_str, val_str);
 89			first = 0;
 90		}
 91	}
 92	strcat(als_str, "\n");
 93	sclp_early_printk(als_str);
 94}
 95
 96static void facility_mismatch(void)
 97{
 98	sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
 99	print_machine_type();
 
 
 
100	print_missing_facilities();
101	sclp_early_printk("See Principles of Operations for facility bits\n");
102	disabled_wait();
103}
104
105void verify_facilities(void)
106{
107	int i;
108
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])
112			facility_mismatch();
113	}
114}