system.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #ifndef __PARISC_SYSTEM_H
  2. #define __PARISC_SYSTEM_H
  3. #include <asm/psw.h>
  4. /* The program status word as bitfields. */
  5. struct pa_psw {
  6. unsigned int y:1;
  7. unsigned int z:1;
  8. unsigned int rv:2;
  9. unsigned int w:1;
  10. unsigned int e:1;
  11. unsigned int s:1;
  12. unsigned int t:1;
  13. unsigned int h:1;
  14. unsigned int l:1;
  15. unsigned int n:1;
  16. unsigned int x:1;
  17. unsigned int b:1;
  18. unsigned int c:1;
  19. unsigned int v:1;
  20. unsigned int m:1;
  21. unsigned int cb:8;
  22. unsigned int o:1;
  23. unsigned int g:1;
  24. unsigned int f:1;
  25. unsigned int r:1;
  26. unsigned int q:1;
  27. unsigned int p:1;
  28. unsigned int d:1;
  29. unsigned int i:1;
  30. };
  31. #ifdef CONFIG_64BIT
  32. #define pa_psw(task) ((struct pa_psw *) ((char *) (task) + TASK_PT_PSW + 4))
  33. #else
  34. #define pa_psw(task) ((struct pa_psw *) ((char *) (task) + TASK_PT_PSW))
  35. #endif
  36. struct task_struct;
  37. extern struct task_struct *_switch_to(struct task_struct *, struct task_struct *);
  38. #define switch_to(prev, next, last) do { \
  39. (last) = _switch_to(prev, next); \
  40. } while(0)
  41. /* interrupt control */
  42. #define local_save_flags(x) __asm__ __volatile__("ssm 0, %0" : "=r" (x) : : "memory")
  43. #define local_irq_disable() __asm__ __volatile__("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
  44. #define local_irq_enable() __asm__ __volatile__("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
  45. #define local_irq_save(x) \
  46. __asm__ __volatile__("rsm %1,%0" : "=r" (x) :"i" (PSW_I) : "memory" )
  47. #define local_irq_restore(x) \
  48. __asm__ __volatile__("mtsm %0" : : "r" (x) : "memory" )
  49. #define irqs_disabled() \
  50. ({ \
  51. unsigned long flags; \
  52. local_save_flags(flags); \
  53. (flags & PSW_I) == 0; \
  54. })
  55. #define mfctl(reg) ({ \
  56. unsigned long cr; \
  57. __asm__ __volatile__( \
  58. "mfctl " #reg ",%0" : \
  59. "=r" (cr) \
  60. ); \
  61. cr; \
  62. })
  63. #define mtctl(gr, cr) \
  64. __asm__ __volatile__("mtctl %0,%1" \
  65. : /* no outputs */ \
  66. : "r" (gr), "i" (cr) : "memory")
  67. /* these are here to de-mystefy the calling code, and to provide hooks */
  68. /* which I needed for debugging EIEM problems -PB */
  69. #define get_eiem() mfctl(15)
  70. static inline void set_eiem(unsigned long val)
  71. {
  72. mtctl(val, 15);
  73. }
  74. #define mfsp(reg) ({ \
  75. unsigned long cr; \
  76. __asm__ __volatile__( \
  77. "mfsp " #reg ",%0" : \
  78. "=r" (cr) \
  79. ); \
  80. cr; \
  81. })
  82. #define mtsp(gr, cr) \
  83. __asm__ __volatile__("mtsp %0,%1" \
  84. : /* no outputs */ \
  85. : "r" (gr), "i" (cr) : "memory")
  86. /*
  87. ** This is simply the barrier() macro from linux/kernel.h but when serial.c
  88. ** uses tqueue.h uses smp_mb() defined using barrier(), linux/kernel.h
  89. ** hasn't yet been included yet so it fails, thus repeating the macro here.
  90. **
  91. ** PA-RISC architecture allows for weakly ordered memory accesses although
  92. ** none of the processors use it. There is a strong ordered bit that is
  93. ** set in the O-bit of the page directory entry. Operating systems that
  94. ** can not tolerate out of order accesses should set this bit when mapping
  95. ** pages. The O-bit of the PSW should also be set to 1 (I don't believe any
  96. ** of the processor implemented the PSW O-bit). The PCX-W ERS states that
  97. ** the TLB O-bit is not implemented so the page directory does not need to
  98. ** have the O-bit set when mapping pages (section 3.1). This section also
  99. ** states that the PSW Y, Z, G, and O bits are not implemented.
  100. ** So it looks like nothing needs to be done for parisc-linux (yet).
  101. ** (thanks to chada for the above comment -ggg)
  102. **
  103. ** The __asm__ op below simple prevents gcc/ld from reordering
  104. ** instructions across the mb() "call".
  105. */
  106. #define mb() __asm__ __volatile__("":::"memory") /* barrier() */
  107. #define rmb() mb()
  108. #define wmb() mb()
  109. #define smp_mb() mb()
  110. #define smp_rmb() mb()
  111. #define smp_wmb() mb()
  112. #define smp_read_barrier_depends() do { } while(0)
  113. #define read_barrier_depends() do { } while(0)
  114. #define set_mb(var, value) do { var = value; mb(); } while (0)
  115. #ifndef CONFIG_PA20
  116. /* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
  117. and GCC only guarantees 8-byte alignment for stack locals, we can't
  118. be assured of 16-byte alignment for atomic lock data even if we
  119. specify "__attribute ((aligned(16)))" in the type declaration. So,
  120. we use a struct containing an array of four ints for the atomic lock
  121. type and dynamically select the 16-byte aligned int from the array
  122. for the semaphore. */
  123. #define __PA_LDCW_ALIGNMENT 16
  124. #define __ldcw_align(a) ({ \
  125. unsigned long __ret = (unsigned long) &(a)->lock[0]; \
  126. __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \
  127. & ~(__PA_LDCW_ALIGNMENT - 1); \
  128. (volatile unsigned int *) __ret; \
  129. })
  130. #define __LDCW "ldcw"
  131. #else /*CONFIG_PA20*/
  132. /* From: "Jim Hull" <jim.hull of hp.com>
  133. I've attached a summary of the change, but basically, for PA 2.0, as
  134. long as the ",CO" (coherent operation) completer is specified, then the
  135. 16-byte alignment requirement for ldcw and ldcd is relaxed, and instead
  136. they only require "natural" alignment (4-byte for ldcw, 8-byte for
  137. ldcd). */
  138. #define __PA_LDCW_ALIGNMENT 4
  139. #define __ldcw_align(a) ((volatile unsigned int *)a)
  140. #define __LDCW "ldcw,co"
  141. #endif /*!CONFIG_PA20*/
  142. /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
  143. #define __ldcw(a) ({ \
  144. unsigned __ret; \
  145. __asm__ __volatile__(__LDCW " 0(%1),%0" \
  146. : "=r" (__ret) : "r" (a)); \
  147. __ret; \
  148. })
  149. #ifdef CONFIG_SMP
  150. # define __lock_aligned __attribute__((__section__(".data.lock_aligned")))
  151. #endif
  152. #define arch_align_stack(x) (x)
  153. #endif