system.h 7.7 KB

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