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
10 #define S390_GEN_FACILITIES_C
16 #include <asm/facilities_src.h>
18 static void print_facility_list(struct facility_def
*def
)
20 unsigned int high
, bit
, dword
, i
;
21 unsigned long long *array
;
27 for (i
= 0; def
->bits
[i
] != -1; i
++) {
28 bit
= 63 - (def
->bits
[i
] & 63);
29 dword
= def
->bits
[i
] / 64;
31 array
= realloc(array
, (dword
+ 1) * 8);
34 memset(array
+ high
+ 1, 0, (dword
- high
) * 8);
37 array
[dword
] |= 1ULL << bit
;
39 printf("#define %s ", def
->name
);
40 for (i
= 0; i
<= high
; i
++)
41 printf("_AC(0x%016llx,UL)%c", array
[i
], i
< high
? ',' : '\n');
45 static void print_facility_lists(void)
49 for (i
= 0; i
< sizeof(facility_defs
) / sizeof(facility_defs
[0]); i
++)
50 print_facility_list(&facility_defs
[i
]);
53 int main(int argc
, char **argv
)
55 printf("#ifndef __ASM_S390_FACILITIES__\n");
56 printf("#define __ASM_S390_FACILITIES__\n");
58 printf(" * DO NOT MODIFY.\n");
60 printf(" * This file was generated by %s\n", __FILE__
);
62 printf("#include <linux/const.h>\n\n");
63 print_facility_lists();