2 * Copyright IBM Corp. 1999, 2009
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 #ifndef __ASM_FACILITY_H
8 #define __ASM_FACILITY_H
10 #include <linux/string.h>
11 #include <linux/preempt.h>
12 #include <asm/lowcore.h>
14 #define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */
17 * The test_facility function uses the bit odering where the MSB is bit 0.
18 * That makes it easier to query facility bits with the bit number as
19 * documented in the Principles of Operation.
21 static inline int test_facility(unsigned long nr
)
25 if (nr
>= MAX_FACILITY_BIT
)
27 ptr
= (unsigned char *) &S390_lowcore
.stfle_fac_list
+ (nr
>> 3);
28 return (*ptr
& (0x80 >> (nr
& 7))) != 0;
32 * stfle - Store facility list extended
33 * @stfle_fac_list: array where facility list can be stored
34 * @size: size of passed in array in double words
36 static inline void stfle(u64
*stfle_fac_list
, int size
)
42 " .insn s,0xb2b10000,0(0)\n" /* stfl */
45 : "+m" (S390_lowcore
.stfl_fac_list
));
46 nr
= 4; /* bytes stored by stfl */
47 memcpy(stfle_fac_list
, &S390_lowcore
.stfl_fac_list
, 4);
48 if (S390_lowcore
.stfl_fac_list
& 0x01000000) {
49 /* More facility bits available with stfle */
50 register unsigned long reg0
asm("0") = size
- 1;
52 asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
54 : "a" (stfle_fac_list
)
56 nr
= (reg0
+ 1) * 8; /* # bytes stored by stfle */
58 memset((char *) stfle_fac_list
+ nr
, 0, size
* 8 - nr
);
62 #endif /* __ASM_FACILITY_H */