ctl_reg.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifdef CONFIG_64BIT
  9. #define __ctl_load(array, low, high) ({ \
  10. typedef struct { char _[sizeof(array)]; } addrtype; \
  11. asm volatile( \
  12. " lctlg %1,%2,%0\n" \
  13. : : "Q" (*(addrtype *)(&array)), \
  14. "i" (low), "i" (high)); \
  15. })
  16. #define __ctl_store(array, low, high) ({ \
  17. typedef struct { char _[sizeof(array)]; } addrtype; \
  18. asm volatile( \
  19. " stctg %1,%2,%0\n" \
  20. : "=Q" (*(addrtype *)(&array)) \
  21. : "i" (low), "i" (high)); \
  22. })
  23. #else /* CONFIG_64BIT */
  24. #define __ctl_load(array, low, high) ({ \
  25. typedef struct { char _[sizeof(array)]; } addrtype; \
  26. asm volatile( \
  27. " lctl %1,%2,%0\n" \
  28. : : "Q" (*(addrtype *)(&array)), \
  29. "i" (low), "i" (high)); \
  30. })
  31. #define __ctl_store(array, low, high) ({ \
  32. typedef struct { char _[sizeof(array)]; } addrtype; \
  33. asm volatile( \
  34. " stctl %1,%2,%0\n" \
  35. : "=Q" (*(addrtype *)(&array)) \
  36. : "i" (low), "i" (high)); \
  37. })
  38. #endif /* CONFIG_64BIT */
  39. #define __ctl_set_bit(cr, bit) ({ \
  40. unsigned long __dummy; \
  41. __ctl_store(__dummy, cr, cr); \
  42. __dummy |= 1UL << (bit); \
  43. __ctl_load(__dummy, cr, cr); \
  44. })
  45. #define __ctl_clear_bit(cr, bit) ({ \
  46. unsigned long __dummy; \
  47. __ctl_store(__dummy, cr, cr); \
  48. __dummy &= ~(1UL << (bit)); \
  49. __ctl_load(__dummy, cr, cr); \
  50. })
  51. #ifdef CONFIG_SMP
  52. extern void smp_ctl_set_bit(int cr, int bit);
  53. extern void smp_ctl_clear_bit(int cr, int bit);
  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 /* CONFIG_SMP */
  60. #endif /* __ASM_CTL_REG_H */