iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / arch / s390 / tools / gen_facilities.c
blob0c85aedcf9b3bd1daf7681e7e28c68851ba07331
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Simple program to generate defines out of facility lists that use the bit
4 * numbering scheme from the Princples of Operations: most significant bit
5 * has bit number 0.
7 * Copyright IBM Corp. 2015, 2018
9 */
11 #include <strings.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <stdio.h>
16 struct facility_def {
17 char *name;
18 int *bits;
21 static struct facility_def facility_defs[] = {
24 * FACILITIES_ALS contains the list of facilities that are
25 * required to run a kernel that is compiled e.g. with
26 * -march=<machine>.
28 .name = "FACILITIES_ALS",
29 .bits = (int[]){
30 #ifdef CONFIG_HAVE_MARCH_Z900_FEATURES
31 0, /* N3 instructions */
32 1, /* z/Arch mode installed */
33 #endif
34 #ifdef CONFIG_HAVE_MARCH_Z990_FEATURES
35 18, /* long displacement facility */
36 #endif
37 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
38 21, /* extended-immediate facility */
39 25, /* store clock fast */
40 #endif
41 #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
42 27, /* mvcos */
43 32, /* compare and swap and store */
44 33, /* compare and swap and store 2 */
45 34, /* general instructions extension */
46 35, /* execute extensions */
47 #endif
48 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
49 45, /* fast-BCR, etc. */
50 #endif
51 #ifdef CONFIG_HAVE_MARCH_ZEC12_FEATURES
52 49, /* misc-instruction-extensions */
53 52, /* interlocked facility 2 */
54 #endif
55 #ifdef CONFIG_HAVE_MARCH_Z13_FEATURES
56 53, /* load-and-zero-rightmost-byte, etc. */
57 #endif
58 #ifdef CONFIG_HAVE_MARCH_Z14_FEATURES
59 58, /* miscellaneous-instruction-extension 2 */
60 #endif
61 -1 /* END */
66 * FACILITIES_KVM contains the list of facilities that are part
67 * of the default facility mask and list that are passed to the
68 * initial CPU model. If no CPU model is used, this, together
69 * with the non-hypervisor managed bits, is the maximum list of
70 * guest facilities supported by KVM.
72 .name = "FACILITIES_KVM",
73 .bits = (int[]){
74 0, /* N3 instructions */
75 1, /* z/Arch mode installed */
76 2, /* z/Arch mode active */
77 3, /* DAT-enhancement */
78 4, /* idte segment table */
79 5, /* idte region table */
80 6, /* ASN-and-LX reuse */
81 7, /* stfle */
82 8, /* enhanced-DAT 1 */
83 9, /* sense-running-status */
84 10, /* conditional sske */
85 13, /* ipte-range */
86 14, /* nonquiescing key-setting */
87 73, /* transactional execution */
88 75, /* access-exception-fetch/store indication */
89 76, /* msa extension 3 */
90 77, /* msa extension 4 */
91 78, /* enhanced-DAT 2 */
92 130, /* instruction-execution-protection */
93 131, /* enhanced-SOP 2 and side-effect */
94 139, /* multiple epoch facility */
95 146, /* msa extension 8 */
96 -1 /* END */
101 * FACILITIES_KVM_CPUMODEL contains the list of facilities
102 * that can be enabled by CPU model code if the host supports
103 * it. These facilities are not passed to the guest without
104 * CPU model support.
107 .name = "FACILITIES_KVM_CPUMODEL",
108 .bits = (int[]){
109 156, /* etoken facility */
110 -1 /* END */
115 static void print_facility_list(struct facility_def *def)
117 unsigned int high, bit, dword, i;
118 unsigned long long *array;
120 array = calloc(1, 8);
121 if (!array)
122 exit(EXIT_FAILURE);
123 high = 0;
124 for (i = 0; def->bits[i] != -1; i++) {
125 bit = 63 - (def->bits[i] & 63);
126 dword = def->bits[i] / 64;
127 if (dword > high) {
128 array = realloc(array, (dword + 1) * 8);
129 if (!array)
130 exit(EXIT_FAILURE);
131 memset(array + high + 1, 0, (dword - high) * 8);
132 high = dword;
134 array[dword] |= 1ULL << bit;
136 printf("#define %s ", def->name);
137 for (i = 0; i <= high; i++)
138 printf("_AC(0x%016llx,UL)%c", array[i], i < high ? ',' : '\n');
139 free(array);
142 static void print_facility_lists(void)
144 unsigned int i;
146 for (i = 0; i < sizeof(facility_defs) / sizeof(facility_defs[0]); i++)
147 print_facility_list(&facility_defs[i]);
150 int main(int argc, char **argv)
152 printf("#ifndef __ASM_S390_FACILITY_DEFS__\n");
153 printf("#define __ASM_S390_FACILITY_DEFS__\n");
154 printf("/*\n");
155 printf(" * DO NOT MODIFY.\n");
156 printf(" *\n");
157 printf(" * This file was generated by %s\n", __FILE__);
158 printf(" */\n\n");
159 printf("#include <linux/const.h>\n\n");
160 print_facility_lists();
161 printf("\n#endif\n");
162 return 0;