Linux 2.6.14.1
[linux/fpc-iii.git] / include / asm-sh64 / system.h
blob42510e496eb528f10894343e3b0dc3387f396255
1 #ifndef __ASM_SH64_SYSTEM_H
2 #define __ASM_SH64_SYSTEM_H
4 /*
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
7 * for more details.
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
25 typedef struct {
26 unsigned long seg;
27 } mm_segment_t;
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) \
35 do {\
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);\
41 } while(0)
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")
52 #define rmb() mb()
53 #define wmb() __asm__ __volatile__ ("synco": : :"memory")
54 #define read_barrier_depends() do { } while (0)
56 #ifdef CONFIG_SMP
57 #define smp_mb() mb()
58 #define smp_rmb() rmb()
59 #define smp_wmb() wmb()
60 #define smp_read_barrier_depends() read_barrier_depends()
61 #else
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 */
73 #ifndef HARD_CLI
74 #define SR_MASK_L 0x000000f0L
75 #define SR_MASK_LL 0x00000000000000f0LL
76 #else
77 #define SR_MASK_L 0x10000000L
78 #define SR_MASK_LL 0x0000000010000000LL
79 #endif
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"
87 "and %0, %1, %0\n\t"
88 "putcon %0, " __SR "\n\t"
89 : "=&r" (__dummy0)
90 : "r" (__dummy1));
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"
98 "or %0, %1, %0\n\t"
99 "putcon %0, " __SR "\n\t"
100 : "=&r" (__dummy0)
101 : "r" (__dummy1));
104 #define local_save_flags(x) \
105 (__extension__ ({ unsigned long long __dummy=SR_MASK_LL; \
106 __asm__ __volatile__( \
107 "getcon " __SR ", %0\n\t" \
108 "and %0, %1, %0" \
109 : "=&r" (x) \
110 : "r" (__dummy));}))
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" \
119 "and %0, %2, %0" \
120 : "=&r" (x), "=&r" (__d1) \
121 : "r" (__d2));}));
123 #define local_irq_restore(x) do { \
124 if ( ((x) & SR_MASK_L) == 0 ) /* dropping to 0 ? */ \
125 local_irq_enable(); /* yes...re-enable */ \
126 } while (0)
128 #define irqs_disabled() \
129 ({ \
130 unsigned long flags; \
131 local_save_flags(flags); \
132 (flags != 0); \
135 extern __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val)
137 unsigned long flags, retval;
139 local_irq_save(flags);
140 retval = *m;
141 *m = val;
142 local_irq_restore(flags);
143 return retval;
146 extern __inline__ unsigned long xchg_u8(volatile unsigned char * m, unsigned long val)
148 unsigned long flags, retval;
150 local_irq_save(flags);
151 retval = *m;
152 *m = val & 0xff;
153 local_irq_restore(flags);
154 return retval;
157 static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
159 switch (size) {
160 case 4:
161 return xchg_u32(ptr, x);
162 break;
163 case 1:
164 return xchg_u8(ptr, x);
165 break;
167 __xchg_called_with_bad_pointer();
168 return x;
171 /* XXX
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 */
188 #define PLS()
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 */