system.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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(next) local_irq_enable()
  76. #define finish_arch_switch(prev) spin_unlock(&(rq)->lock)
  77. /*
  78. * switch_to(prev, next) should switch from task `prev' to `next'
  79. * `prev' will never be the same as `next'. schedule() itself
  80. * contains the memory barrier to tell GCC not to cache `current'.
  81. */
  82. extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *);
  83. #define switch_to(prev,next,last) \
  84. do { \
  85. last = __switch_to(prev,task_thread_info(prev),task_thread_info(next)); \
  86. } while (0)
  87. /*
  88. * On SMP systems, when the scheduler does migration-cost autodetection,
  89. * it needs a way to flush as much of the CPU's caches as possible.
  90. *
  91. * TODO: fill this in!
  92. */
  93. static inline void sched_cacheflush(void)
  94. {
  95. }
  96. /*
  97. * Save the current interrupt enable state & disable IRQs
  98. */
  99. #define local_irq_save(x) \
  100. do { \
  101. unsigned long temp; \
  102. __asm__ __volatile__( \
  103. " mov %0, pc @ save_flags_cli\n" \
  104. " orr %1, %0, #0x08000000\n" \
  105. " and %0, %0, #0x0c000000\n" \
  106. " teqp %1, #0\n" \
  107. : "=r" (x), "=r" (temp) \
  108. : \
  109. : "memory"); \
  110. } while (0)
  111. /*
  112. * Enable IRQs (sti)
  113. */
  114. #define local_irq_enable() \
  115. do { \
  116. unsigned long temp; \
  117. __asm__ __volatile__( \
  118. " mov %0, pc @ sti\n" \
  119. " bic %0, %0, #0x08000000\n" \
  120. " teqp %0, #0\n" \
  121. : "=r" (temp) \
  122. : \
  123. : "memory"); \
  124. } while(0)
  125. /*
  126. * Disable IRQs (cli)
  127. */
  128. #define local_irq_disable() \
  129. do { \
  130. unsigned long temp; \
  131. __asm__ __volatile__( \
  132. " mov %0, pc @ cli\n" \
  133. " orr %0, %0, #0x08000000\n" \
  134. " teqp %0, #0\n" \
  135. : "=r" (temp) \
  136. : \
  137. : "memory"); \
  138. } while(0)
  139. /* Enable FIQs (stf) */
  140. #define __stf() do { \
  141. unsigned long temp; \
  142. __asm__ __volatile__( \
  143. " mov %0, pc @ stf\n" \
  144. " bic %0, %0, #0x04000000\n" \
  145. " teqp %0, #0\n" \
  146. : "=r" (temp)); \
  147. } while(0)
  148. /* Disable FIQs (clf) */
  149. #define __clf() do { \
  150. unsigned long temp; \
  151. __asm__ __volatile__( \
  152. " mov %0, pc @ clf\n" \
  153. " orr %0, %0, #0x04000000\n" \
  154. " teqp %0, #0\n" \
  155. : "=r" (temp)); \
  156. } while(0)
  157. /*
  158. * Save the current interrupt enable state.
  159. */
  160. #define local_save_flags(x) \
  161. do { \
  162. __asm__ __volatile__( \
  163. " mov %0, pc @ save_flags\n" \
  164. " and %0, %0, #0x0c000000\n" \
  165. : "=r" (x)); \
  166. } while (0)
  167. /*
  168. * restore saved IRQ & FIQ state
  169. */
  170. #define local_irq_restore(x) \
  171. do { \
  172. unsigned long temp; \
  173. __asm__ __volatile__( \
  174. " mov %0, pc @ restore_flags\n" \
  175. " bic %0, %0, #0x0c000000\n" \
  176. " orr %0, %0, %1\n" \
  177. " teqp %0, #0\n" \
  178. : "=&r" (temp) \
  179. : "r" (x) \
  180. : "memory"); \
  181. } while (0)
  182. #ifdef CONFIG_SMP
  183. #error SMP not supported
  184. #endif
  185. #define smp_mb() barrier()
  186. #define smp_rmb() barrier()
  187. #define smp_wmb() barrier()
  188. #define smp_read_barrier_depends() do { } while(0)
  189. #define clf() __clf()
  190. #define stf() __stf()
  191. #define irqs_disabled() \
  192. ({ \
  193. unsigned long flags; \
  194. local_save_flags(flags); \
  195. flags & PSR_I_BIT; \
  196. })
  197. static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
  198. {
  199. extern void __bad_xchg(volatile void *, int);
  200. switch (size) {
  201. case 1: return cpu_xchg_1(x, ptr);
  202. case 4: return cpu_xchg_4(x, ptr);
  203. default: __bad_xchg(ptr, size);
  204. }
  205. return 0;
  206. }
  207. #endif /* __ASSEMBLY__ */
  208. #define arch_align_stack(x) (x)
  209. #endif /* __KERNEL__ */
  210. #endif