2 * Simple program to generate defines out of facility lists that use the bit
3 * numbering scheme from the Princples of Operations: most significant bit
6 * Copyright IBM Corp. 2015
20 static struct facility_def facility_defs[] = {
23 * FACILITIES_ALS contains the list of facilities that are
24 * required to run a kernel that is compiled e.g. with
27 .name = "FACILITIES_ALS",
29 #ifdef CONFIG_HAVE_MARCH_Z900_FEATURES
30 0, /* N3 instructions */
31 1, /* z/Arch mode installed */
33 #ifdef CONFIG_HAVE_MARCH_Z990_FEATURES
34 18, /* long displacement facility */
36 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
37 21, /* extended-immediate facility */
38 25, /* store clock fast */
40 #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
42 32, /* compare and swap and store */
43 33, /* compare and swap and store 2 */
44 34, /* general instructions extension */
45 35, /* execute extensions */
47 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
48 45, /* fast-BCR, etc. */
50 #ifdef CONFIG_HAVE_MARCH_ZEC12_FEATURES
51 49, /* misc-instruction-extensions */
52 52, /* interlocked facility 2 */
54 #ifdef CONFIG_HAVE_MARCH_Z13_FEATURES
55 53, /* load-and-zero-rightmost-byte, etc. */
57 #ifdef CONFIG_HAVE_MARCH_Z14_FEATURES
58 58, /* miscellaneous-instruction-extension 2 */
64 .name = "FACILITIES_KVM",
66 0, /* N3 instructions */
67 1, /* z/Arch mode installed */
68 2, /* z/Arch mode active */
69 3, /* DAT-enhancement */
70 4, /* idte segment table */
71 5, /* idte region table */
72 6, /* ASN-and-LX reuse */
74 8, /* enhanced-DAT 1 */
75 9, /* sense-running-status */
76 10, /* conditional sske */
78 14, /* nonquiescing key-setting */
79 73, /* transactional execution */
80 75, /* access-exception-fetch/store indication */
81 76, /* msa extension 3 */
82 77, /* msa extension 4 */
83 78, /* enhanced-DAT 2 */
84 130, /* instruction-execution-protection */
85 131, /* enhanced-SOP 2 and side-effect */
86 139, /* multiple epoch facility */
87 146, /* msa extension 8 */
93 static void print_facility_list(struct facility_def *def)
95 unsigned int high, bit, dword, i;
96 unsigned long long *array;
102 for (i = 0; def->bits[i] != -1; i++) {
103 bit = 63 - (def->bits[i] & 63);
104 dword = def->bits[i] / 64;
106 array = realloc(array, (dword + 1) * 8);
109 memset(array + high + 1, 0, (dword - high) * 8);
112 array[dword] |= 1ULL << bit;
114 printf("#define %s ", def->name);
115 for (i = 0; i <= high; i++)
116 printf("_AC(0x%016llx,UL)%c", array[i], i < high ? ',' : '\n');
120 static void print_facility_lists(void)
124 for (i = 0; i < sizeof(facility_defs) / sizeof(facility_defs[0]); i++)
125 print_facility_list(&facility_defs[i]);
128 int main(int argc, char **argv)
130 printf("#ifndef __ASM_S390_FACILITIES__\n");
131 printf("#define __ASM_S390_FACILITIES__\n");
133 printf(" * DO NOT MODIFY.\n");
135 printf(" * This file was generated by %s\n", __FILE__);
137 printf("#include <linux/const.h>\n\n");
138 print_facility_lists();
139 printf("\n#endif\n");