ctl_reg.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifdef CONFIG_64BIT
  10. # define __CTL_LOAD "lctlg"
  11. # define __CTL_STORE "stctg"
  12. #else
  13. # define __CTL_LOAD "lctl"
  14. # define __CTL_STORE "stctl"
  15. #endif
  16. #define __ctl_load(array, low, high) { \
  17. typedef struct { char _[sizeof(array)]; } addrtype; \
  18. \
  19. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  20. asm volatile( \
  21. __CTL_LOAD " %1,%2,%0\n" \
  22. : : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high));\
  23. }
  24. #define __ctl_store(array, low, high) { \
  25. typedef struct { char _[sizeof(array)]; } addrtype; \
  26. \
  27. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  28. asm volatile( \
  29. __CTL_STORE " %1,%2,%0\n" \
  30. : "=Q" (*(addrtype *)(&array)) \
  31. : "i" (low), "i" (high)); \
  32. }
  33. static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
  34. {
  35. unsigned long reg;
  36. __ctl_store(reg, cr, cr);
  37. reg |= 1UL << bit;
  38. __ctl_load(reg, cr, cr);
  39. }
  40. static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
  41. {
  42. unsigned long reg;
  43. __ctl_store(reg, cr, cr);
  44. reg &= ~(1UL << bit);
  45. __ctl_load(reg, cr, cr);
  46. }
  47. void smp_ctl_set_bit(int cr, int bit);
  48. void smp_ctl_clear_bit(int cr, int bit);
  49. union ctlreg0 {
  50. unsigned long val;
  51. struct {
  52. #ifdef CONFIG_64BIT
  53. unsigned long : 32;
  54. #endif
  55. unsigned long : 3;
  56. unsigned long lap : 1; /* Low-address-protection control */
  57. unsigned long : 4;
  58. unsigned long edat : 1; /* Enhanced-DAT-enablement control */
  59. unsigned long : 23;
  60. };
  61. };
  62. #ifdef CONFIG_SMP
  63. # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
  64. # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
  65. #else
  66. # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
  67. # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
  68. #endif
  69. #endif /* __ASM_CTL_REG_H */