system.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. /*
  43. * On SMP systems, when the scheduler does migration-cost autodetection,
  44. * it needs a way to flush as much of the CPU's caches as possible.
  45. *
  46. * TODO: fill this in!
  47. */
  48. static inline void sched_cacheflush(void)
  49. {
  50. }
  51. /* interrupt control */
  52. #define local_save_flags(x) __asm__ __volatile__("ssm 0, %0" : "=r" (x) : : "memory")
  53. #define local_irq_disable() __asm__ __volatile__("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
  54. #define local_irq_enable() __asm__ __volatile__("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
  55. #define local_irq_save(x) \
  56. __asm__ __volatile__("rsm %1,%0" : "=r" (x) :"i" (PSW_I) : "memory" )
  57. #define local_irq_restore(x) \
  58. __asm__ __volatile__("mtsm %0" : : "r" (x) : "memory" )
  59. #define irqs_disabled() \
  60. ({ \
  61. unsigned long flags; \
  62. local_save_flags(flags); \
  63. (flags & PSW_I) == 0; \
  64. })
  65. #define mfctl(reg) ({ \
  66. unsigned long cr; \
  67. __asm__ __volatile__( \
  68. "mfctl " #reg ",%0" : \
  69. "=r" (cr) \
  70. ); \
  71. cr; \
  72. })
  73. #define mtctl(gr, cr) \
  74. __asm__ __volatile__("mtctl %0,%1" \
  75. : /* no outputs */ \
  76. : "r" (gr), "i" (cr) : "memory")
  77. /* these are here to de-mystefy the calling code, and to provide hooks */
  78. /* which I needed for debugging EIEM problems -PB */
  79. #define get_eiem() mfctl(15)
  80. static inline void set_eiem(unsigned long val)
  81. {
  82. mtctl(val, 15);
  83. }
  84. #define mfsp(reg) ({ \
  85. unsigned long cr; \
  86. __asm__ __volatile__( \
  87. "mfsp " #reg ",%0" : \
  88. "=r" (cr) \
  89. ); \
  90. cr; \
  91. })
  92. #define mtsp(gr, cr) \
  93. __asm__ __volatile__("mtsp %0,%1" \
  94. : /* no outputs */ \
  95. : "r" (gr), "i" (cr) : "memory")
  96. /*
  97. ** This is simply the barrier() macro from linux/kernel.h but when serial.c
  98. ** uses tqueue.h uses smp_mb() defined using barrier(), linux/kernel.h
  99. ** hasn't yet been included yet so it fails, thus repeating the macro here.
  100. **
  101. ** PA-RISC architecture allows for weakly ordered memory accesses although
  102. ** none of the processors use it. There is a strong ordered bit that is
  103. ** set in the O-bit of the page directory entry. Operating systems that
  104. ** can not tolerate out of order accesses should set this bit when mapping
  105. ** pages. The O-bit of the PSW should also be set to 1 (I don't believe any
  106. ** of the processor implemented the PSW O-bit). The PCX-W ERS states that
  107. ** the TLB O-bit is not implemented so the page directory does not need to
  108. ** have the O-bit set when mapping pages (section 3.1). This section also
  109. ** states that the PSW Y, Z, G, and O bits are not implemented.
  110. ** So it looks like nothing needs to be done for parisc-linux (yet).
  111. ** (thanks to chada for the above comment -ggg)
  112. **
  113. ** The __asm__ op below simple prevents gcc/ld from reordering
  114. ** instructions across the mb() "call".
  115. */
  116. #define mb() __asm__ __volatile__("":::"memory") /* barrier() */
  117. #define rmb() mb()
  118. #define wmb() mb()
  119. #define smp_mb() mb()
  120. #define smp_rmb() mb()
  121. #define smp_wmb() mb()
  122. #define smp_read_barrier_depends() do { } while(0)
  123. #define read_barrier_depends() do { } while(0)
  124. #define set_mb(var, value) do { var = value; mb(); } while (0)
  125. #define set_wmb(var, value) do { var = value; wmb(); } while (0)
  126. #ifndef CONFIG_PA20
  127. /* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
  128. and GCC only guarantees 8-byte alignment for stack locals, we can't
  129. be assured of 16-byte alignment for atomic lock data even if we
  130. specify "__attribute ((aligned(16)))" in the type declaration. So,
  131. we use a struct containing an array of four ints for the atomic lock
  132. type and dynamically select the 16-byte aligned int from the array
  133. for the semaphore. */
  134. #define __PA_LDCW_ALIGNMENT 16
  135. #define __ldcw_align(a) ({ \
  136. unsigned long __ret = (unsigned long) &(a)->lock[0]; \
  137. __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \
  138. (volatile unsigned int *) __ret; \
  139. })
  140. #define LDCW "ldcw"
  141. #else /*CONFIG_PA20*/
  142. /* From: "Jim Hull" <jim.hull of hp.com>
  143. I've attached a summary of the change, but basically, for PA 2.0, as
  144. long as the ",CO" (coherent operation) completer is specified, then the
  145. 16-byte alignment requirement for ldcw and ldcd is relaxed, and instead
  146. they only require "natural" alignment (4-byte for ldcw, 8-byte for
  147. ldcd). */
  148. #define __PA_LDCW_ALIGNMENT 4
  149. #define __ldcw_align(a) ((volatile unsigned int *)a)
  150. #define LDCW "ldcw,co"
  151. #endif /*!CONFIG_PA20*/
  152. /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
  153. #define __ldcw(a) ({ \
  154. unsigned __ret; \
  155. __asm__ __volatile__(LDCW " 0(%1),%0" : "=r" (__ret) : "r" (a)); \
  156. __ret; \
  157. })
  158. #ifdef CONFIG_SMP
  159. # define __lock_aligned __attribute__((__section__(".data.lock_aligned")))
  160. #endif
  161. #define KERNEL_START (0x10100000 - 0x1000)
  162. #define arch_align_stack(x) (x)
  163. #endif