1 #ifndef __ASM_SH64_SYSTEM_H
2 #define __ASM_SH64_SYSTEM_H
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 * include/asm-sh64/system.h
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 * Copyright (C) 2004 Richard Curnow
17 #include <linux/config.h>
18 #include <asm/registers.h>
19 #include <asm/processor.h>
22 * switch_to() should switch tasks to task nr n, first
29 extern struct task_struct
*sh64_switch_to(struct task_struct
*prev
,
30 struct thread_struct
*prev_thread
,
31 struct task_struct
*next
,
32 struct thread_struct
*next_thread
);
34 #define switch_to(prev,next,last) \
36 if (last_task_used_math != next) {\
37 struct pt_regs *regs = next->thread.uregs;\
38 if (regs) regs->sr |= SR_FD;\
40 last = sh64_switch_to(prev, &prev->thread, next, &next->thread);\
43 #define nop() __asm__ __volatile__ ("nop")
45 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
47 #define tas(ptr) (xchg((ptr), 1))
49 extern void __xchg_called_with_bad_pointer(void);
51 #define mb() __asm__ __volatile__ ("synco": : :"memory")
53 #define wmb() __asm__ __volatile__ ("synco": : :"memory")
54 #define read_barrier_depends() do { } while (0)
58 #define smp_rmb() rmb()
59 #define smp_wmb() wmb()
60 #define smp_read_barrier_depends() read_barrier_depends()
62 #define smp_mb() barrier()
63 #define smp_rmb() barrier()
64 #define smp_wmb() barrier()
65 #define smp_read_barrier_depends() do { } while (0)
66 #endif /* CONFIG_SMP */
68 #define set_rmb(var, value) do { xchg(&var, value); } while (0)
69 #define set_mb(var, value) set_rmb(var, value)
70 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
72 /* Interrupt Control */
74 #define SR_MASK_L 0x000000f0L
75 #define SR_MASK_LL 0x00000000000000f0LL
77 #define SR_MASK_L 0x10000000L
78 #define SR_MASK_LL 0x0000000010000000LL
81 static __inline__
void local_irq_enable(void)
83 /* cli/sti based on SR.BL */
84 unsigned long long __dummy0
, __dummy1
=~SR_MASK_LL
;
86 __asm__
__volatile__("getcon " __SR
", %0\n\t"
88 "putcon %0, " __SR
"\n\t"
93 static __inline__
void local_irq_disable(void)
95 /* cli/sti based on SR.BL */
96 unsigned long long __dummy0
, __dummy1
=SR_MASK_LL
;
97 __asm__
__volatile__("getcon " __SR
", %0\n\t"
99 "putcon %0, " __SR
"\n\t"
104 #define local_save_flags(x) \
105 (__extension__ ({ unsigned long long __dummy=SR_MASK_LL; \
106 __asm__ __volatile__( \
107 "getcon " __SR ", %0\n\t" \
112 #define local_irq_save(x) \
113 (__extension__ ({ unsigned long long __d2=SR_MASK_LL, __d1; \
114 __asm__ __volatile__( \
115 "getcon " __SR ", %1\n\t" \
116 "or %1, r63, %0\n\t" \
117 "or %1, %2, %1\n\t" \
118 "putcon %1, " __SR "\n\t" \
120 : "=&r" (x), "=&r" (__d1) \
123 #define local_irq_restore(x) do { \
124 if ( ((x) & SR_MASK_L) == 0 ) /* dropping to 0 ? */ \
125 local_irq_enable(); /* yes...re-enable */ \
128 #define irqs_disabled() \
130 unsigned long flags; \
131 local_save_flags(flags); \
135 static inline unsigned long xchg_u32(volatile int * m
, unsigned long val
)
137 unsigned long flags
, retval
;
139 local_irq_save(flags
);
142 local_irq_restore(flags
);
146 static inline unsigned long xchg_u8(volatile unsigned char * m
, unsigned long val
)
148 unsigned long flags
, retval
;
150 local_irq_save(flags
);
153 local_irq_restore(flags
);
157 static __inline__
unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
161 return xchg_u32(ptr
, x
);
164 return xchg_u8(ptr
, x
);
167 __xchg_called_with_bad_pointer();
172 * disable hlt during certain critical i/o operations
174 #define HAVE_DISABLE_HLT
175 void disable_hlt(void);
176 void enable_hlt(void);
179 #define smp_mb() barrier()
180 #define smp_rmb() barrier()
181 #define smp_wmb() barrier()
183 #ifdef CONFIG_SH_ALPHANUMERIC
184 /* This is only used for debugging. */
185 extern void print_seg(char *file
,int line
);
186 #define PLS() print_seg(__FILE__,__LINE__)
187 #else /* CONFIG_SH_ALPHANUMERIC */
189 #endif /* CONFIG_SH_ALPHANUMERIC */
191 #define PL() printk("@ <%s,%s:%d>\n",__FILE__,__FUNCTION__,__LINE__)
193 #define arch_align_stack(x) (x)
195 #endif /* __ASM_SH64_SYSTEM_H */