facility.h 1.6 KB

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