ctl_reg.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifdef CONFIG_SMP
  50. # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
  51. # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
  52. #else
  53. # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
  54. # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
  55. #endif
  56. #endif /* __ASM_CTL_REG_H */