aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include/asm/facility.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/include/asm/facility.h')
-rw-r--r--arch/s390/include/asm/facility.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/arch/s390/include/asm/facility.h b/arch/s390/include/asm/facility.h
new file mode 100644
index 000000000000..1e5b27edc0c9
--- /dev/null
+++ b/arch/s390/include/asm/facility.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright IBM Corp. 1999, 2009
3 *
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 */
6
7#ifndef __ASM_FACILITY_H
8#define __ASM_FACILITY_H
9
10#include <linux/string.h>
11#include <linux/preempt.h>
12#include <asm/lowcore.h>
13
14#define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */
15
16/*
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.
20 */
21static inline int test_facility(unsigned long nr)
22{
23 unsigned char *ptr;
24
25 if (nr >= MAX_FACILITY_BIT)
26 return 0;
27 ptr = (unsigned char *) &S390_lowcore.stfle_fac_list + (nr >> 3);
28 return (*ptr & (0x80 >> (nr & 7))) != 0;
29}
30
31/**
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
35 */
36static inline void stfle(u64 *stfle_fac_list, int size)
37{
38 unsigned long nr;
39
40 preempt_disable();
41 S390_lowcore.stfl_fac_list = 0;
42 asm volatile(
43 " .insn s,0xb2b10000,0(0)\n" /* stfl */
44 "0:\n"
45 EX_TABLE(0b, 0b)
46 : "=m" (S390_lowcore.stfl_fac_list));
47 nr = 4; /* bytes stored by stfl */
48 memcpy(stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
49 if (S390_lowcore.stfl_fac_list & 0x01000000) {
50 /* More facility bits available with stfle */
51 register unsigned long reg0 asm("0") = size - 1;
52
53 asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
54 : "+d" (reg0)
55 : "a" (stfle_fac_list)
56 : "memory", "cc");
57 nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
58 }
59 memset((char *) stfle_fac_list + nr, 0, size * 8 - nr);
60 preempt_enable();
61}
62
63#endif /* __ASM_FACILITY_H */