1 #ifndef _ASM_SCORE_SYSTEM_H
2 #define _ASM_SCORE_SYSTEM_H
3 
4 #include <linux/types.h>
5 #include <linux/irqflags.h>
6 
7 struct pt_regs;
8 struct task_struct;
9 
10 extern void *resume(void *last, void *next, void *next_ti);
11 
12 #define switch_to(prev, next, last)				\
13 do {								\
14 	(last) = resume(prev, next, task_thread_info(next));	\
15 } while (0)
16 
17 #define finish_arch_switch(prev)	do {} while (0)
18 
19 typedef void (*vi_handler_t)(void);
20 extern unsigned long arch_align_stack(unsigned long sp);
21 
22 #define mb()		barrier()
23 #define rmb()		barrier()
24 #define wmb()		barrier()
25 #define smp_mb()	barrier()
26 #define smp_rmb()	barrier()
27 #define smp_wmb()	barrier()
28 
29 #define read_barrier_depends()		do {} while (0)
30 #define smp_read_barrier_depends()	do {} while (0)
31 
32 #define set_mb(var, value) 		do {var = value; wmb(); } while (0)
33 
34 #define __HAVE_ARCH_CMPXCHG	1
35 
36 #include <asm-generic/cmpxchg-local.h>
37 
38 #ifndef __ASSEMBLY__
39 
40 struct __xchg_dummy { unsigned long a[100]; };
41 #define __xg(x) ((struct __xchg_dummy *)(x))
42 
43 static inline
__xchg(volatile unsigned long * m,unsigned long val)44 unsigned long __xchg(volatile unsigned long *m, unsigned long val)
45 {
46 	unsigned long retval;
47 	unsigned long flags;
48 
49 	local_irq_save(flags);
50 	retval = *m;
51 	*m = val;
52 	local_irq_restore(flags);
53 	return retval;
54 }
55 
56 #define xchg(ptr, v)						\
57 	((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr),	\
58 					(unsigned long)(v)))
59 
__cmpxchg(volatile unsigned long * m,unsigned long old,unsigned long new)60 static inline unsigned long __cmpxchg(volatile unsigned long *m,
61 				unsigned long old, unsigned long new)
62 {
63 	unsigned long retval;
64 	unsigned long flags;
65 
66 	local_irq_save(flags);
67 	retval = *m;
68 	if (retval == old)
69 		*m = new;
70 	local_irq_restore(flags);
71 	return retval;
72 }
73 
74 #define cmpxchg(ptr, o, n)					\
75 	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr),	\
76 					(unsigned long)(o),	\
77 					(unsigned long)(n)))
78 
79 extern void __die(const char *, struct pt_regs *, const char *,
80 	const char *, unsigned long) __attribute__((noreturn));
81 extern void __die_if_kernel(const char *, struct pt_regs *, const char *,
82 	const char *, unsigned long);
83 
84 #define die(msg, regs)							\
85 	__die(msg, regs, __FILE__ ":", __func__, __LINE__)
86 #define die_if_kernel(msg, regs)					\
87 	__die_if_kernel(msg, regs, __FILE__ ":", __func__, __LINE__)
88 
89 #endif /* !__ASSEMBLY__ */
90 #endif /* _ASM_SCORE_SYSTEM_H */
91