1 #ifndef __ASM_ARM_SYSTEM_H
2 #define __ASM_ARM_SYSTEM_H
8 * This is used to ensure the compiler did actually allocate the register we
9 * asked it for some inline assembly sequences. Apparently we can't trust
10 * the compiler from one version to another so a bit of paranoia won't hurt.
11 * This string is meant to be concatenated with the inline asm string and
12 * will cause compilation to stop on mismatch. (From ARM32 - may come in handy)
14 #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
18 #include <linux/linkage.h>
24 /* information about the system we're running on */
25 extern unsigned int system_rev;
26 extern unsigned int system_serial_low;
27 extern unsigned int system_serial_high;
28 extern unsigned int mem_fclk_21285;
32 * We need to turn the caches off before calling the reset vector - RiscOS
33 * messes up if we don't
35 #define proc_hard_reset() cpu_proc_fin()
41 void die(const char *msg, struct pt_regs *regs, int err)
42 __attribute__((noreturn));
44 void die_if_kernel(const char *str, struct pt_regs *regs, int err);
46 void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
48 int sig, const char *name);
50 #include <asm/proc-fns.h>
53 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
55 extern asmlinkage void __backtrace(void);
58 __asm__ __volatile__( \
59 "mcr p15, 0, %0, c1, c0, 0 @ set CR" \
65 __asm__ __volatile__( \
66 "mrc p15, 0, %0, c1, c0, 0 @ get CR" \
67 : "=r" (__val) : : "cc"); \
71 extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
72 extern unsigned long cr_alignment; /* defined in entry-armv.S */
74 #define UDBG_UNDEFINED (1 << 0)
75 #define UDBG_SYSCALL (1 << 1)
76 #define UDBG_BADABORT (1 << 2)
77 #define UDBG_SEGV (1 << 3)
78 #define UDBG_BUS (1 << 4)
80 extern unsigned int user_debug;
82 #define vectors_base() (0)
84 #define mb() __asm__ __volatile__ ("" : : : "memory")
87 #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
89 #define read_barrier_depends() do { } while(0)
90 #define set_mb(var, value) do { var = value; mb(); } while (0)
93 * We assume knowledge of how
94 * spin_unlock_irq() and friends are implemented. This avoids
95 * us needlessly decrementing and incrementing the preempt count.
97 #define prepare_arch_switch(next) local_irq_enable()
98 #define finish_arch_switch(prev) spin_unlock(&(rq)->lock)
101 * switch_to(prev, next) should switch from task `prev' to `next'
102 * `prev' will never be the same as `next'. schedule() itself
103 * contains the memory barrier to tell GCC not to cache `current'.
105 extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *);
107 #define switch_to(prev,next,last) \
109 last = __switch_to(prev,task_thread_info(prev),task_thread_info(next)); \
113 * On SMP systems, when the scheduler does migration-cost autodetection,
114 * it needs a way to flush as much of the CPU's caches as possible.
116 * TODO: fill this in!
118 static inline void sched_cacheflush(void)
123 * Save the current interrupt enable state & disable IRQs
125 #define local_irq_save(x) \
127 unsigned long temp; \
128 __asm__ __volatile__( \
129 " mov %0, pc @ save_flags_cli\n" \
130 " orr %1, %0, #0x08000000\n" \
131 " and %0, %0, #0x0c000000\n" \
133 : "=r" (x), "=r" (temp) \
141 #define local_irq_enable() \
143 unsigned long temp; \
144 __asm__ __volatile__( \
145 " mov %0, pc @ sti\n" \
146 " bic %0, %0, #0x08000000\n" \
156 #define local_irq_disable() \
158 unsigned long temp; \
159 __asm__ __volatile__( \
160 " mov %0, pc @ cli\n" \
161 " orr %0, %0, #0x08000000\n" \
168 /* Enable FIQs (stf) */
170 #define __stf() do { \
171 unsigned long temp; \
172 __asm__ __volatile__( \
173 " mov %0, pc @ stf\n" \
174 " bic %0, %0, #0x04000000\n" \
179 /* Disable FIQs (clf) */
181 #define __clf() do { \
182 unsigned long temp; \
183 __asm__ __volatile__( \
184 " mov %0, pc @ clf\n" \
185 " orr %0, %0, #0x04000000\n" \
192 * Save the current interrupt enable state.
194 #define local_save_flags(x) \
196 __asm__ __volatile__( \
197 " mov %0, pc @ save_flags\n" \
198 " and %0, %0, #0x0c000000\n" \
204 * restore saved IRQ & FIQ state
206 #define local_irq_restore(x) \
208 unsigned long temp; \
209 __asm__ __volatile__( \
210 " mov %0, pc @ restore_flags\n" \
211 " bic %0, %0, #0x0c000000\n" \
212 " orr %0, %0, %1\n" \
221 #error SMP not supported
224 #define smp_mb() barrier()
225 #define smp_rmb() barrier()
226 #define smp_wmb() barrier()
227 #define smp_read_barrier_depends() do { } while(0)
229 #define clf() __clf()
230 #define stf() __stf()
232 #define irqs_disabled() \
234 unsigned long flags; \
235 local_save_flags(flags); \
239 static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
241 extern void __bad_xchg(volatile void *, int);
244 case 1: return cpu_xchg_1(x, ptr);
245 case 4: return cpu_xchg_4(x, ptr);
246 default: __bad_xchg(ptr, size);
251 #endif /* __ASSEMBLY__ */
253 #define arch_align_stack(x) (x)
255 #endif /* __KERNEL__ */