blob: 9b3a8dd2c3db5ec0c1d2bc1520057ccff3dd6e75 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
Ralf Baechle0004a9d2006-10-31 03:45:07 +00006 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003, 06 by Ralf Baechle
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Kevin D. Kissell, kevink@mips.org and Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 2000 MIPS Technologies, Inc.
11 */
12#ifndef _ASM_SYSTEM_H
13#define _ASM_SYSTEM_H
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/types.h>
Ralf Baechle192ef362006-07-07 14:07:18 +010016#include <linux/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#include <asm/addrspace.h>
Ralf Baechle0004a9d2006-10-31 03:45:07 +000019#include <asm/barrier.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/cpu-features.h>
Ralf Baechlee50c0a82005-05-31 11:49:19 +000021#include <asm/dsp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/war.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Linus Torvalds1da177e2005-04-16 15:20:36 -070025/*
26 * switch_to(n) should switch tasks to task nr n, first
27 * checking that n isn't the current task, in which case it does nothing.
28 */
29extern asmlinkage void *resume(void *last, void *next, void *next_ti);
30
31struct task_struct;
32
Ralf Baechlef088fc82006-04-05 09:45:47 +010033#ifdef CONFIG_MIPS_MT_FPAFF
34
35/*
36 * Handle the scheduler resume end of FPU affinity management. We do this
37 * inline to try to keep the overhead down. If we have been forced to run on
38 * a "CPU" with an FPU because of a previous high level of FP computation,
39 * but did not actually use the FPU during the most recent time-slice (CU1
40 * isn't set), we undo the restriction on cpus_allowed.
41 *
42 * We're not calling set_cpus_allowed() here, because we have no need to
43 * force prompt migration - we're already switching the current CPU to a
44 * different thread.
45 */
46
Ralf Baechled223a862007-07-10 17:33:02 +010047#define __mips_mt_fpaff_switch_to(prev) \
Ralf Baechlef088fc82006-04-05 09:45:47 +010048do { \
49 if (cpu_has_fpu && \
50 (prev->thread.mflags & MF_FPUBOUND) && \
51 (!(KSTK_STATUS(prev) & ST0_CU1))) { \
52 prev->thread.mflags &= ~MF_FPUBOUND; \
53 prev->cpus_allowed = prev->thread.user_cpus_allowed; \
54 } \
Ralf Baechlef088fc82006-04-05 09:45:47 +010055 next->thread.emulated_fp = 0; \
Ralf Baechlef088fc82006-04-05 09:45:47 +010056} while(0)
57
58#else
Ralf Baechled223a862007-07-10 17:33:02 +010059#define __mips_mt_fpaff_switch_to(prev) do { (prev); } while (0)
60#endif
61
Ralf Baechlee50c0a82005-05-31 11:49:19 +000062#define switch_to(prev,next,last) \
63do { \
Ralf Baechled223a862007-07-10 17:33:02 +010064 __mips_mt_fpaff_switch_to(prev); \
Ralf Baechlee50c0a82005-05-31 11:49:19 +000065 if (cpu_has_dsp) \
66 __save_dsp(prev); \
Al Viro40bc9c62006-01-12 01:06:07 -080067 (last) = resume(prev, next, task_thread_info(next)); \
Ralf Baechlee50c0a82005-05-31 11:49:19 +000068 if (cpu_has_dsp) \
69 __restore_dsp(current); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070070} while(0)
71
Ingo Molnar4dc7a0b2006-01-12 01:05:27 -080072/*
73 * On SMP systems, when the scheduler does migration-cost autodetection,
74 * it needs a way to flush as much of the CPU's caches as possible.
75 *
76 * TODO: fill this in!
77 */
78static inline void sched_cacheflush(void)
79{
80}
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
83{
84 __u32 retval;
85
86 if (cpu_has_llsc && R10000_LLSC_WAR) {
87 unsigned long dummy;
88
89 __asm__ __volatile__(
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +000090 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 "1: ll %0, %3 # xchg_u32 \n"
Ralf Baechle72224242005-06-29 13:35:19 +000092 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 " move %2, %z4 \n"
Ralf Baechle72224242005-06-29 13:35:19 +000094 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 " sc %2, %1 \n"
96 " beqzl %2, 1b \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +000097 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
99 : "R" (*m), "Jr" (val)
100 : "memory");
101 } else if (cpu_has_llsc) {
102 unsigned long dummy;
103
104 __asm__ __volatile__(
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000105 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 "1: ll %0, %3 # xchg_u32 \n"
Ralf Baechle72224242005-06-29 13:35:19 +0000107 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 " move %2, %z4 \n"
Ralf Baechle72224242005-06-29 13:35:19 +0000109 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 " sc %2, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100111 " beqz %2, 2f \n"
112 " .subsection 2 \n"
113 "2: b 1b \n"
114 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000115 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
117 : "R" (*m), "Jr" (val)
118 : "memory");
119 } else {
120 unsigned long flags;
121
Ralf Baechle49edd092007-03-16 16:10:36 +0000122 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 retval = *m;
124 *m = val;
Ralf Baechle49edd092007-03-16 16:10:36 +0000125 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 }
127
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000128 smp_mb();
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 return retval;
131}
132
Ralf Baechle875d43e2005-09-03 15:56:16 -0700133#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
135{
136 __u64 retval;
137
138 if (cpu_has_llsc && R10000_LLSC_WAR) {
139 unsigned long dummy;
140
141 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000142 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 "1: lld %0, %3 # xchg_u64 \n"
144 " move %2, %z4 \n"
145 " scd %2, %1 \n"
146 " beqzl %2, 1b \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000147 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
149 : "R" (*m), "Jr" (val)
150 : "memory");
151 } else if (cpu_has_llsc) {
152 unsigned long dummy;
153
154 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000155 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 "1: lld %0, %3 # xchg_u64 \n"
157 " move %2, %z4 \n"
158 " scd %2, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100159 " beqz %2, 2f \n"
160 " .subsection 2 \n"
161 "2: b 1b \n"
162 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000163 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
165 : "R" (*m), "Jr" (val)
166 : "memory");
167 } else {
168 unsigned long flags;
169
Ralf Baechle49edd092007-03-16 16:10:36 +0000170 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 retval = *m;
172 *m = val;
Ralf Baechle49edd092007-03-16 16:10:36 +0000173 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 }
175
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000176 smp_mb();
177
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 return retval;
179}
180#else
181extern __u64 __xchg_u64_unsupported_on_32bit_kernels(volatile __u64 * m, __u64 val);
182#define __xchg_u64 __xchg_u64_unsupported_on_32bit_kernels
183#endif
184
185/* This function doesn't exist, so you'll get a linker error
186 if something tries to do an invalid xchg(). */
187extern void __xchg_called_with_bad_pointer(void);
188
189static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
190{
191 switch (size) {
Ralf Baechle0cea0432006-03-03 09:42:05 +0000192 case 4:
193 return __xchg_u32(ptr, x);
194 case 8:
195 return __xchg_u64(ptr, x);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 }
197 __xchg_called_with_bad_pointer();
198 return x;
199}
200
201#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203#define __HAVE_ARCH_CMPXCHG 1
204
205static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
206 unsigned long new)
207{
208 __u32 retval;
209
210 if (cpu_has_llsc && R10000_LLSC_WAR) {
211 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000212 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000214 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 "1: ll %0, %2 # __cmpxchg_u32 \n"
216 " bne %0, %z3, 2f \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000217 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 " move $1, %z4 \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000219 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 " sc $1, %1 \n"
221 " beqzl $1, 1b \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 "2: \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000223 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000224 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 : "R" (*m), "Jr" (old), "Jr" (new)
226 : "memory");
227 } else if (cpu_has_llsc) {
228 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000229 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000231 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 "1: ll %0, %2 # __cmpxchg_u32 \n"
233 " bne %0, %z3, 2f \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000234 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 " move $1, %z4 \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000236 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 " sc $1, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100238 " beqz $1, 3f \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 "2: \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100240 " .subsection 2 \n"
241 "3: b 1b \n"
242 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000243 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000244 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 : "R" (*m), "Jr" (old), "Jr" (new)
246 : "memory");
247 } else {
248 unsigned long flags;
249
Ralf Baechle49edd092007-03-16 16:10:36 +0000250 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 retval = *m;
252 if (retval == old)
253 *m = new;
Ralf Baechle49edd092007-03-16 16:10:36 +0000254 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 }
256
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000257 smp_mb();
258
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 return retval;
260}
261
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700262static inline unsigned long __cmpxchg_u32_local(volatile int * m,
263 unsigned long old, unsigned long new)
264{
265 __u32 retval;
266
267 if (cpu_has_llsc && R10000_LLSC_WAR) {
268 __asm__ __volatile__(
269 " .set push \n"
270 " .set noat \n"
271 " .set mips3 \n"
272 "1: ll %0, %2 # __cmpxchg_u32 \n"
273 " bne %0, %z3, 2f \n"
274 " .set mips0 \n"
275 " move $1, %z4 \n"
276 " .set mips3 \n"
277 " sc $1, %1 \n"
278 " beqzl $1, 1b \n"
279 "2: \n"
280 " .set pop \n"
281 : "=&r" (retval), "=R" (*m)
282 : "R" (*m), "Jr" (old), "Jr" (new)
283 : "memory");
284 } else if (cpu_has_llsc) {
285 __asm__ __volatile__(
286 " .set push \n"
287 " .set noat \n"
288 " .set mips3 \n"
289 "1: ll %0, %2 # __cmpxchg_u32 \n"
290 " bne %0, %z3, 2f \n"
291 " .set mips0 \n"
292 " move $1, %z4 \n"
293 " .set mips3 \n"
294 " sc $1, %1 \n"
295 " beqz $1, 1b \n"
296 "2: \n"
297 " .set pop \n"
298 : "=&r" (retval), "=R" (*m)
299 : "R" (*m), "Jr" (old), "Jr" (new)
300 : "memory");
301 } else {
302 unsigned long flags;
303
304 local_irq_save(flags);
305 retval = *m;
306 if (retval == old)
307 *m = new;
308 local_irq_restore(flags); /* implies memory barrier */
309 }
310
311 return retval;
312}
313
Ralf Baechle875d43e2005-09-03 15:56:16 -0700314#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
316 unsigned long new)
317{
318 __u64 retval;
319
Ralf Baechle904880e2006-10-13 11:32:50 +0100320 if (cpu_has_llsc && R10000_LLSC_WAR) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000322 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 " .set noat \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000324 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 "1: lld %0, %2 # __cmpxchg_u64 \n"
326 " bne %0, %z3, 2f \n"
327 " move $1, %z4 \n"
328 " scd $1, %1 \n"
329 " beqzl $1, 1b \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 "2: \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000331 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000332 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 : "R" (*m), "Jr" (old), "Jr" (new)
334 : "memory");
335 } else if (cpu_has_llsc) {
336 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000337 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000339 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 "1: lld %0, %2 # __cmpxchg_u64 \n"
341 " bne %0, %z3, 2f \n"
342 " move $1, %z4 \n"
343 " scd $1, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100344 " beqz $1, 3f \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 "2: \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100346 " .subsection 2 \n"
347 "3: b 1b \n"
348 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000349 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000350 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 : "R" (*m), "Jr" (old), "Jr" (new)
352 : "memory");
353 } else {
354 unsigned long flags;
355
Ralf Baechle49edd092007-03-16 16:10:36 +0000356 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 retval = *m;
358 if (retval == old)
359 *m = new;
Ralf Baechle49edd092007-03-16 16:10:36 +0000360 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 }
362
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000363 smp_mb();
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 return retval;
366}
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700367
368static inline unsigned long __cmpxchg_u64_local(volatile int * m,
369 unsigned long old, unsigned long new)
370{
371 __u64 retval;
372
373 if (cpu_has_llsc && R10000_LLSC_WAR) {
374 __asm__ __volatile__(
375 " .set push \n"
376 " .set noat \n"
377 " .set mips3 \n"
378 "1: lld %0, %2 # __cmpxchg_u64 \n"
379 " bne %0, %z3, 2f \n"
380 " move $1, %z4 \n"
381 " scd $1, %1 \n"
382 " beqzl $1, 1b \n"
383 "2: \n"
384 " .set pop \n"
385 : "=&r" (retval), "=R" (*m)
386 : "R" (*m), "Jr" (old), "Jr" (new)
387 : "memory");
388 } else if (cpu_has_llsc) {
389 __asm__ __volatile__(
390 " .set push \n"
391 " .set noat \n"
392 " .set mips3 \n"
393 "1: lld %0, %2 # __cmpxchg_u64 \n"
394 " bne %0, %z3, 2f \n"
395 " move $1, %z4 \n"
396 " scd $1, %1 \n"
397 " beqz $1, 1b \n"
398 "2: \n"
399 " .set pop \n"
400 : "=&r" (retval), "=R" (*m)
401 : "R" (*m), "Jr" (old), "Jr" (new)
402 : "memory");
403 } else {
404 unsigned long flags;
405
406 local_irq_save(flags);
407 retval = *m;
408 if (retval == old)
409 *m = new;
410 local_irq_restore(flags); /* implies memory barrier */
411 }
412
413 return retval;
414}
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416#else
417extern unsigned long __cmpxchg_u64_unsupported_on_32bit_kernels(
418 volatile int * m, unsigned long old, unsigned long new);
419#define __cmpxchg_u64 __cmpxchg_u64_unsupported_on_32bit_kernels
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700420extern unsigned long __cmpxchg_u64_local_unsupported_on_32bit_kernels(
421 volatile int * m, unsigned long old, unsigned long new);
422#define __cmpxchg_u64_local __cmpxchg_u64_local_unsupported_on_32bit_kernels
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423#endif
424
425/* This function doesn't exist, so you'll get a linker error
426 if something tries to do an invalid cmpxchg(). */
427extern void __cmpxchg_called_with_bad_pointer(void);
428
429static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
430 unsigned long new, int size)
431{
432 switch (size) {
433 case 4:
434 return __cmpxchg_u32(ptr, old, new);
435 case 8:
436 return __cmpxchg_u64(ptr, old, new);
437 }
438 __cmpxchg_called_with_bad_pointer();
439 return old;
440}
441
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700442static inline unsigned long __cmpxchg_local(volatile void * ptr,
443 unsigned long old, unsigned long new, int size)
444{
445 switch (size) {
446 case 4:
447 return __cmpxchg_u32_local(ptr, old, new);
448 case 8:
449 return __cmpxchg_u64_local(ptr, old, new);
450 }
451 __cmpxchg_called_with_bad_pointer();
452 return old;
453}
454
455#define cmpxchg(ptr,old,new) \
456 ((__typeof__(*(ptr)))__cmpxchg((ptr), \
457 (unsigned long)(old), (unsigned long)(new),sizeof(*(ptr))))
458
459#define cmpxchg_local(ptr,old,new) \
460 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), \
461 (unsigned long)(old), (unsigned long)(new),sizeof(*(ptr))))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
Ralf Baechlee01402b2005-07-14 15:57:16 +0000463extern void set_handler (unsigned long offset, void *addr, unsigned long len);
464extern void set_uncached_handler (unsigned long offset, void *addr, unsigned long len);
Ralf Baechleef300e42007-05-06 18:31:18 +0100465
466typedef void (*vi_handler_t)(void);
467extern void *set_vi_handler (int n, vi_handler_t addr);
468
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469extern void *set_except_vector(int n, void *addr);
Ralf Baechle91b05e62006-03-29 18:53:00 +0100470extern unsigned long ebase;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471extern void per_cpu_trap_init(void);
472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473extern int stop_a_enabled;
474
475/*
Nick Piggin4866cde2005-06-25 14:57:23 -0700476 * See include/asm-ia64/system.h; prevents deadlock on SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 * systems.
478 */
Nick Piggin4866cde2005-06-25 14:57:23 -0700479#define __ARCH_WANT_UNLOCKED_CTXSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
481#define arch_align_stack(x) (x)
482
483#endif /* _ASM_SYSTEM_H */