system.h 5.8 KB

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