0001
0002
0003
0004
0005 #include <linux/kernel.h>
0006 #include <asm/processor.h>
0007 #include <asm/facility.h>
0008 #include <asm/lowcore.h>
0009 #include <asm/sclp.h>
0010 #include "boot.h"
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 static unsigned long als[] = { FACILITIES_ALS };
0021
0022 static void u16_to_hex(char *str, u16 val)
0023 {
0024 int i, num;
0025
0026 for (i = 1; i <= 4; i++) {
0027 num = (val >> (16 - 4 * i)) & 0xf;
0028 if (num >= 10)
0029 num += 7;
0030 *str++ = '0' + num;
0031 }
0032 *str = '\0';
0033 }
0034
0035 static void print_machine_type(void)
0036 {
0037 static char mach_str[80] = "Detected machine-type number: ";
0038 char type_str[5];
0039 struct cpuid id;
0040
0041 get_cpu_id(&id);
0042 u16_to_hex(type_str, id.machine);
0043 strcat(mach_str, type_str);
0044 strcat(mach_str, "\n");
0045 sclp_early_printk(mach_str);
0046 }
0047
0048 static void u16_to_decimal(char *str, u16 val)
0049 {
0050 int div = 1;
0051
0052 while (div * 10 <= val)
0053 div *= 10;
0054 while (div) {
0055 *str++ = '0' + val / div;
0056 val %= div;
0057 div /= 10;
0058 }
0059 *str = '\0';
0060 }
0061
0062 void print_missing_facilities(void)
0063 {
0064 static char als_str[80] = "Missing facilities: ";
0065 unsigned long val;
0066 char val_str[6];
0067 int i, j, first;
0068
0069 first = 1;
0070 for (i = 0; i < ARRAY_SIZE(als); i++) {
0071 val = ~stfle_fac_list[i] & als[i];
0072 for (j = 0; j < BITS_PER_LONG; j++) {
0073 if (!(val & (1UL << (BITS_PER_LONG - 1 - j))))
0074 continue;
0075 if (!first)
0076 strcat(als_str, ",");
0077
0078
0079
0080
0081
0082 if (strlen(als_str) > 70) {
0083 strcat(als_str, "\n");
0084 sclp_early_printk(als_str);
0085 *als_str = '\0';
0086 }
0087 u16_to_decimal(val_str, i * BITS_PER_LONG + j);
0088 strcat(als_str, val_str);
0089 first = 0;
0090 }
0091 }
0092 strcat(als_str, "\n");
0093 sclp_early_printk(als_str);
0094 }
0095
0096 static void facility_mismatch(void)
0097 {
0098 sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
0099 print_machine_type();
0100 print_missing_facilities();
0101 sclp_early_printk("See Principles of Operations for facility bits\n");
0102 disabled_wait();
0103 }
0104
0105 void verify_facilities(void)
0106 {
0107 int i;
0108
0109 __stfle(stfle_fac_list, ARRAY_SIZE(stfle_fac_list));
0110 for (i = 0; i < ARRAY_SIZE(als); i++) {
0111 if ((stfle_fac_list[i] & als[i]) != als[i])
0112 facility_mismatch();
0113 }
0114 }