ctl_reg.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright IBM Corp. 1999, 2009
  3. *
  4. * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  5. */
  6. #ifndef __ASM_CTL_REG_H
  7. #define __ASM_CTL_REG_H
  8. #include <linux/bug.h>
  9. #define __ctl_load(array, low, high) { \
  10. typedef struct { char _[sizeof(array)]; } addrtype; \
  11. \
  12. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  13. asm volatile( \
  14. " lctlg %1,%2,%0\n" \
  15. : \
  16. : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high) \
  17. : "memory"); \
  18. }
  19. #define __ctl_store(array, low, high) { \
  20. typedef struct { char _[sizeof(array)]; } addrtype; \
  21. \
  22. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  23. asm volatile( \
  24. " stctg %1,%2,%0\n" \
  25. : "=Q" (*(addrtype *)(&array)) \
  26. : "i" (low), "i" (high)); \
  27. }
  28. static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
  29. {
  30. unsigned long reg;
  31. __ctl_store(reg, cr, cr);
  32. reg |= 1UL << bit;
  33. __ctl_load(reg, cr, cr);
  34. }
  35. static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
  36. {
  37. unsigned long reg;
  38. __ctl_store(reg, cr, cr);
  39. reg &= ~(1UL << bit);
  40. __ctl_load(reg, cr, cr);
  41. }
  42. void smp_ctl_set_bit(int cr, int bit);
  43. void smp_ctl_clear_bit(int cr, int bit);
  44. union ctlreg0 {
  45. unsigned long val;
  46. struct {
  47. unsigned long : 32;
  48. unsigned long : 3;
  49. unsigned long lap : 1; /* Low-address-protection control */
  50. unsigned long : 4;
  51. unsigned long edat : 1; /* Enhanced-DAT-enablement control */
  52. unsigned long : 4;
  53. unsigned long afp : 1; /* AFP-register control */
  54. unsigned long vx : 1; /* Vector enablement control */
  55. unsigned long : 17;
  56. };
  57. };
  58. #ifdef CONFIG_SMP
  59. # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
  60. # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
  61. #else
  62. # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
  63. # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
  64. #endif
  65. #endif /* __ASM_CTL_REG_H */