ctl_reg.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. : : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high));\
  16. }
  17. #define __ctl_store(array, low, high) { \
  18. typedef struct { char _[sizeof(array)]; } addrtype; \
  19. \
  20. BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
  21. asm volatile( \
  22. " stctg %1,%2,%0\n" \
  23. : "=Q" (*(addrtype *)(&array)) \
  24. : "i" (low), "i" (high)); \
  25. }
  26. static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
  27. {
  28. unsigned long reg;
  29. __ctl_store(reg, cr, cr);
  30. reg |= 1UL << bit;
  31. __ctl_load(reg, cr, cr);
  32. }
  33. static inline void __ctl_clear_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. void smp_ctl_set_bit(int cr, int bit);
  41. void smp_ctl_clear_bit(int cr, int bit);
  42. union ctlreg0 {
  43. unsigned long val;
  44. struct {
  45. unsigned long : 32;
  46. unsigned long : 3;
  47. unsigned long lap : 1; /* Low-address-protection control */
  48. unsigned long : 4;
  49. unsigned long edat : 1; /* Enhanced-DAT-enablement control */
  50. unsigned long : 23;
  51. };
  52. };
  53. #ifdef CONFIG_SMP
  54. # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
  55. # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
  56. #else
  57. # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
  58. # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
  59. #endif
  60. #endif /* __ASM_CTL_REG_H */