system.h 7.8 KB

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