0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <strings.h>
0012 #include <string.h>
0013 #include <stdlib.h>
0014 #include <stdio.h>
0015
0016 struct facility_def {
0017 char *name;
0018 int *bits;
0019 };
0020
0021 static struct facility_def facility_defs[] = {
0022 {
0023
0024
0025
0026
0027
0028 .name = "FACILITIES_ALS",
0029 .bits = (int[]){
0030 0,
0031 1,
0032 18,
0033 21,
0034 25,
0035 27,
0036 32,
0037 33,
0038 34,
0039 35,
0040 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
0041 45,
0042 #endif
0043 #ifdef CONFIG_HAVE_MARCH_ZEC12_FEATURES
0044 49,
0045 52,
0046 #endif
0047 #ifdef CONFIG_HAVE_MARCH_Z13_FEATURES
0048 53,
0049 #endif
0050 #ifdef CONFIG_HAVE_MARCH_Z14_FEATURES
0051 58,
0052 #endif
0053 #ifdef CONFIG_HAVE_MARCH_Z15_FEATURES
0054 61,
0055 #endif
0056 -1
0057 }
0058 },
0059 {
0060
0061
0062
0063
0064
0065
0066
0067 .name = "FACILITIES_KVM",
0068 .bits = (int[]){
0069 0,
0070 1,
0071 2,
0072 3,
0073 4,
0074 5,
0075 6,
0076 7,
0077 8,
0078 9,
0079 10,
0080 13,
0081 14,
0082 73,
0083 75,
0084 76,
0085 77,
0086 78,
0087 130,
0088 131,
0089 139,
0090 146,
0091 150,
0092 151,
0093 155,
0094 -1
0095 }
0096 },
0097 {
0098
0099
0100
0101
0102
0103
0104
0105 .name = "FACILITIES_KVM_CPUMODEL",
0106 .bits = (int[]){
0107 12,
0108 15,
0109 156,
0110 165,
0111 193,
0112 194,
0113 196,
0114 197,
0115 -1
0116 }
0117 },
0118 };
0119
0120 static void print_facility_list(struct facility_def *def)
0121 {
0122 unsigned int high, bit, dword, i;
0123 unsigned long long *array;
0124
0125 array = calloc(1, 8);
0126 if (!array)
0127 exit(EXIT_FAILURE);
0128 high = 0;
0129 for (i = 0; def->bits[i] != -1; i++) {
0130 bit = 63 - (def->bits[i] & 63);
0131 dword = def->bits[i] / 64;
0132 if (dword > high) {
0133 array = realloc(array, (dword + 1) * 8);
0134 if (!array)
0135 exit(EXIT_FAILURE);
0136 memset(array + high + 1, 0, (dword - high) * 8);
0137 high = dword;
0138 }
0139 array[dword] |= 1ULL << bit;
0140 }
0141 printf("#define %s ", def->name);
0142 for (i = 0; i <= high; i++)
0143 printf("_AC(0x%016llx,UL)%c", array[i], i < high ? ',' : '\n');
0144 free(array);
0145 }
0146
0147 static void print_facility_lists(void)
0148 {
0149 unsigned int i;
0150
0151 for (i = 0; i < sizeof(facility_defs) / sizeof(facility_defs[0]); i++)
0152 print_facility_list(&facility_defs[i]);
0153 }
0154
0155 int main(int argc, char **argv)
0156 {
0157 printf("#ifndef __ASM_S390_FACILITY_DEFS__\n");
0158 printf("#define __ASM_S390_FACILITY_DEFS__\n");
0159 printf("/*\n");
0160 printf(" * DO NOT MODIFY.\n");
0161 printf(" *\n");
0162 printf(" * This file was generated by %s\n", __FILE__);
0163 printf(" */\n\n");
0164 printf("#include <linux/const.h>\n\n");
0165 print_facility_lists();
0166 printf("\n#endif\n");
0167 return 0;
0168 }