ctl_reg.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 1999, 2009
  4. *
  5. * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  6. */
  7. #ifndef __ASM_CTL_REG_H
  8. #define __ASM_CTL_REG_H
  9. #include <linux/const.h>
  10. #define CR0_CLOCK_COMPARATOR_SIGN _BITUL(63 - 10)
  11. #define CR0_EMERGENCY_SIGNAL_SUBMASK _BITUL(63 - 49)
  12. #define CR0_EXTERNAL_CALL_SUBMASK _BITUL(63 - 50)
  13. #define CR0_CLOCK_COMPARATOR_SUBMASK _BITUL(63 - 52)
  14. #define CR0_CPU_TIMER_SUBMASK _BITUL(63 - 53)
  15. #define CR0_SERVICE_SIGNAL_SUBMASK _BITUL(63 - 54)
  16. #define CR0_UNUSED_56 _BITUL(63 - 56)
  17. #define CR0_INTERRUPT_KEY_SUBMASK _BITUL(63 - 57)
  18. #define CR0_MEASUREMENT_ALERT_SUBMASK _BITUL(63 - 58)
  19. #define CR2_GUARDED_STORAGE _BITUL(63 - 59)
  20. #define CR14_UNUSED_32 _BITUL(63 - 32)
  21. #define CR14_UNUSED_33 _BITUL(63 - 33)
  22. #define CR14_CHANNEL_REPORT_SUBMASK _BITUL(63 - 35)
  23. #define CR14_RECOVERY_SUBMASK _BITUL(63 - 36)
  24. #define CR14_DEGRADATION_SUBMASK _BITUL(63 - 37)
  25. #define CR14_EXTERNAL_DAMAGE_SUBMASK _BITUL(63 - 38)
  26. #define CR14_WARNING_SUBMASK _BITUL(63 - 39)
  27. #ifndef __ASSEMBLY__
  28. #include <linux/bug.h>
  29. #define __ctl_load(array, low, high) do { \
  30. typedef struct { char _[sizeof(array)]; } addrtype; \
  31. \
  32. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  33. asm volatile( \
  34. " lctlg %1,%2,%0\n" \
  35. : \
  36. : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high) \
  37. : "memory"); \
  38. } while (0)
  39. #define __ctl_store(array, low, high) do { \
  40. typedef struct { char _[sizeof(array)]; } addrtype; \
  41. \
  42. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  43. asm volatile( \
  44. " stctg %1,%2,%0\n" \
  45. : "=Q" (*(addrtype *)(&array)) \
  46. : "i" (low), "i" (high)); \
  47. } while (0)
  48. static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
  49. {
  50. unsigned long reg;
  51. __ctl_store(reg, cr, cr);
  52. reg |= 1UL << bit;
  53. __ctl_load(reg, cr, cr);
  54. }
  55. static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
  56. {
  57. unsigned long reg;
  58. __ctl_store(reg, cr, cr);
  59. reg &= ~(1UL << bit);
  60. __ctl_load(reg, cr, cr);
  61. }
  62. void smp_ctl_set_bit(int cr, int bit);
  63. void smp_ctl_clear_bit(int cr, int bit);
  64. union ctlreg0 {
  65. unsigned long val;
  66. struct {
  67. unsigned long : 8;
  68. unsigned long tcx : 1; /* Transactional-Execution control */
  69. unsigned long pifo : 1; /* Transactional-Execution Program-
  70. Interruption-Filtering Override */
  71. unsigned long : 22;
  72. unsigned long : 3;
  73. unsigned long lap : 1; /* Low-address-protection control */
  74. unsigned long : 4;
  75. unsigned long edat : 1; /* Enhanced-DAT-enablement control */
  76. unsigned long : 2;
  77. unsigned long iep : 1; /* Instruction-Execution-Protection */
  78. unsigned long : 1;
  79. unsigned long afp : 1; /* AFP-register control */
  80. unsigned long vx : 1; /* Vector enablement control */
  81. unsigned long : 7;
  82. unsigned long sssm : 1; /* Service signal subclass mask */
  83. unsigned long : 9;
  84. };
  85. };
  86. union ctlreg2 {
  87. unsigned long val;
  88. struct {
  89. unsigned long : 33;
  90. unsigned long ducto : 25;
  91. unsigned long : 1;
  92. unsigned long gse : 1;
  93. unsigned long : 1;
  94. unsigned long tds : 1;
  95. unsigned long tdc : 2;
  96. };
  97. };
  98. #ifdef CONFIG_SMP
  99. # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
  100. # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
  101. #else
  102. # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
  103. # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
  104. #endif
  105. #endif /* __ASSEMBLY__ */
  106. #endif /* __ASM_CTL_REG_H */