system.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. #ifndef __ASM_ARM_SYSTEM_H
  2. #define __ASM_ARM_SYSTEM_H
  3. #ifdef __KERNEL__
  4. /*
  5. * This is used to ensure the compiler did actually allocate the register we
  6. * asked it for some inline assembly sequences. Apparently we can't trust
  7. * the compiler from one version to another so a bit of paranoia won't hurt.
  8. * This string is meant to be concatenated with the inline asm string and
  9. * will cause compilation to stop on mismatch. (From ARM32 - may come in handy)
  10. */
  11. #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
  12. #ifndef __ASSEMBLY__
  13. #include <linux/linkage.h>
  14. struct thread_info;
  15. struct task_struct;
  16. #if 0
  17. /* information about the system we're running on */
  18. extern unsigned int system_rev;
  19. extern unsigned int system_serial_low;
  20. extern unsigned int system_serial_high;
  21. extern unsigned int mem_fclk_21285;
  22. FIXME - sort this
  23. /*
  24. * We need to turn the caches off before calling the reset vector - RiscOS
  25. * messes up if we don't
  26. */
  27. #define proc_hard_reset() cpu_proc_fin()
  28. #endif
  29. struct pt_regs;
  30. void die(const char *msg, struct pt_regs *regs, int err)
  31. __attribute__((noreturn));
  32. void die_if_kernel(const char *str, struct pt_regs *regs, int err);
  33. void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
  34. struct pt_regs *),
  35. int sig, const char *name);
  36. #include <asm/proc-fns.h>
  37. #define xchg(ptr,x) \
  38. ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
  39. #define tas(ptr) (xchg((ptr),1))
  40. extern asmlinkage void __backtrace(void);
  41. #define set_cr(x) \
  42. __asm__ __volatile__( \
  43. "mcr p15, 0, %0, c1, c0, 0 @ set CR" \
  44. : : "r" (x) : "cc")
  45. #define get_cr() \
  46. ({ \
  47. unsigned int __val; \
  48. __asm__ __volatile__( \
  49. "mrc p15, 0, %0, c1, c0, 0 @ get CR" \
  50. : "=r" (__val) : : "cc"); \
  51. __val; \
  52. })
  53. extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
  54. extern unsigned long cr_alignment; /* defined in entry-armv.S */
  55. #define UDBG_UNDEFINED (1 << 0)
  56. #define UDBG_SYSCALL (1 << 1)
  57. #define UDBG_BADABORT (1 << 2)
  58. #define UDBG_SEGV (1 << 3)
  59. #define UDBG_BUS (1 << 4)
  60. extern unsigned int user_debug;
  61. #define vectors_base() (0)
  62. #define mb() __asm__ __volatile__ ("" : : : "memory")
  63. #define rmb() mb()
  64. #define wmb() mb()
  65. #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
  66. #define read_barrier_depends() do { } while(0)
  67. #define set_mb(var, value) do { var = value; mb(); } while (0)
  68. /*
  69. * We assume knowledge of how
  70. * spin_unlock_irq() and friends are implemented. This avoids
  71. * us needlessly decrementing and incrementing the preempt count.
  72. */
  73. #define prepare_arch_switch(next) local_irq_enable()
  74. #define finish_arch_switch(prev) spin_unlock(&(rq)->lock)
  75. /*
  76. * switch_to(prev, next) should switch from task `prev' to `next'
  77. * `prev' will never be the same as `next'. schedule() itself
  78. * contains the memory barrier to tell GCC not to cache `current'.
  79. */
  80. extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *);
  81. #define switch_to(prev,next,last) \
  82. do { \
  83. last = __switch_to(prev,task_thread_info(prev),task_thread_info(next)); \
  84. } while (0)
  85. /*
  86. * On SMP systems, when the scheduler does migration-cost autodetection,
  87. * it needs a way to flush as much of the CPU's caches as possible.
  88. *
  89. * TODO: fill this in!
  90. */
  91. static inline void sched_cacheflush(void)
  92. {
  93. }
  94. /*
  95. * Save the current interrupt enable state & disable IRQs
  96. */
  97. #define local_irq_save(x) \
  98. do { \
  99. unsigned long temp; \
  100. __asm__ __volatile__( \
  101. " mov %0, pc @ save_flags_cli\n" \
  102. " orr %1, %0, #0x08000000\n" \
  103. " and %0, %0, #0x0c000000\n" \
  104. " teqp %1, #0\n" \
  105. : "=r" (x), "=r" (temp) \
  106. : \
  107. : "memory"); \
  108. } while (0)
  109. /*
  110. * Enable IRQs (sti)
  111. */
  112. #define local_irq_enable() \
  113. do { \
  114. unsigned long temp; \
  115. __asm__ __volatile__( \
  116. " mov %0, pc @ sti\n" \
  117. " bic %0, %0, #0x08000000\n" \
  118. " teqp %0, #0\n" \
  119. : "=r" (temp) \
  120. : \
  121. : "memory"); \
  122. } while(0)
  123. /*
  124. * Disable IRQs (cli)
  125. */
  126. #define local_irq_disable() \
  127. do { \
  128. unsigned long temp; \
  129. __asm__ __volatile__( \
  130. " mov %0, pc @ cli\n" \
  131. " orr %0, %0, #0x08000000\n" \
  132. " teqp %0, #0\n" \
  133. : "=r" (temp) \
  134. : \
  135. : "memory"); \
  136. } while(0)
  137. /* Enable FIQs (stf) */
  138. #define __stf() do { \
  139. unsigned long temp; \
  140. __asm__ __volatile__( \
  141. " mov %0, pc @ stf\n" \
  142. " bic %0, %0, #0x04000000\n" \
  143. " teqp %0, #0\n" \
  144. : "=r" (temp)); \
  145. } while(0)
  146. /* Disable FIQs (clf) */
  147. #define __clf() do { \
  148. unsigned long temp; \
  149. __asm__ __volatile__( \
  150. " mov %0, pc @ clf\n" \
  151. " orr %0, %0, #0x04000000\n" \
  152. " teqp %0, #0\n" \
  153. : "=r" (temp)); \
  154. } while(0)
  155. /*
  156. * Save the current interrupt enable state.
  157. */
  158. #define local_save_flags(x) \
  159. do { \
  160. __asm__ __volatile__( \
  161. " mov %0, pc @ save_flags\n" \
  162. " and %0, %0, #0x0c000000\n" \
  163. : "=r" (x)); \
  164. } while (0)
  165. /*
  166. * restore saved IRQ & FIQ state
  167. */
  168. #define local_irq_restore(x) \
  169. do { \
  170. unsigned long temp; \
  171. __asm__ __volatile__( \
  172. " mov %0, pc @ restore_flags\n" \
  173. " bic %0, %0, #0x0c000000\n" \
  174. " orr %0, %0, %1\n" \
  175. " teqp %0, #0\n" \
  176. : "=&r" (temp) \
  177. : "r" (x) \
  178. : "memory"); \
  179. } while (0)
  180. #ifdef CONFIG_SMP
  181. #error SMP not supported
  182. #endif
  183. #define smp_mb() barrier()
  184. #define smp_rmb() barrier()
  185. #define smp_wmb() barrier()
  186. #define smp_read_barrier_depends() do { } while(0)
  187. #define clf() __clf()
  188. #define stf() __stf()
  189. #define irqs_disabled() \
  190. ({ \
  191. unsigned long flags; \
  192. local_save_flags(flags); \
  193. flags & PSR_I_BIT; \
  194. })
  195. static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
  196. {
  197. extern void __bad_xchg(volatile void *, int);
  198. switch (size) {
  199. case 1: return cpu_xchg_1(x, ptr);
  200. case 4: return cpu_xchg_4(x, ptr);
  201. default: __bad_xchg(ptr, size);
  202. }
  203. return 0;
  204. }
  205. #endif /* __ASSEMBLY__ */
  206. #define arch_align_stack(x) (x)
  207. #endif /* __KERNEL__ */
  208. #endif