system.h 7.8 KB

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