blob: eba2e3da9abe6195143cbffc960bd290511313a6 [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 Baechle35c700c2007-07-10 08:59:17 +010059#define __mips_mt_fpaff_switch_to(prev) do { (void) (prev); } while (0)
Ralf Baechled223a862007-07-10 17:33:02 +010060#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); \
Ralf Baechlea3692022007-07-10 17:33:02 +010070 if (cpu_has_userlocal) \
71 write_c0_userlocal(task_thread_info(current)->tp_value);\
Linus Torvalds1da177e2005-04-16 15:20:36 -070072} while(0)
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
75{
76 __u32 retval;
77
78 if (cpu_has_llsc && R10000_LLSC_WAR) {
79 unsigned long dummy;
80
81 __asm__ __volatile__(
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +000082 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 "1: ll %0, %3 # xchg_u32 \n"
Ralf Baechle72224242005-06-29 13:35:19 +000084 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 " move %2, %z4 \n"
Ralf Baechle72224242005-06-29 13:35:19 +000086 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 " sc %2, %1 \n"
88 " beqzl %2, 1b \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +000089 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
91 : "R" (*m), "Jr" (val)
92 : "memory");
93 } else if (cpu_has_llsc) {
94 unsigned long dummy;
95
96 __asm__ __volatile__(
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +000097 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 "1: ll %0, %3 # xchg_u32 \n"
Ralf Baechle72224242005-06-29 13:35:19 +000099 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 " move %2, %z4 \n"
Ralf Baechle72224242005-06-29 13:35:19 +0000101 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 " sc %2, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100103 " beqz %2, 2f \n"
104 " .subsection 2 \n"
105 "2: b 1b \n"
106 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000107 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
109 : "R" (*m), "Jr" (val)
110 : "memory");
111 } else {
112 unsigned long flags;
113
Ralf Baechle49edd092007-03-16 16:10:36 +0000114 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 retval = *m;
116 *m = val;
Ralf Baechle49edd092007-03-16 16:10:36 +0000117 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 }
119
Ralf Baechle17099b12007-07-14 13:24:05 +0100120 smp_llsc_mb();
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 return retval;
123}
124
Ralf Baechle875d43e2005-09-03 15:56:16 -0700125#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
127{
128 __u64 retval;
129
130 if (cpu_has_llsc && R10000_LLSC_WAR) {
131 unsigned long dummy;
132
133 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000134 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 "1: lld %0, %3 # xchg_u64 \n"
136 " move %2, %z4 \n"
137 " scd %2, %1 \n"
138 " beqzl %2, 1b \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000139 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
141 : "R" (*m), "Jr" (val)
142 : "memory");
143 } else if (cpu_has_llsc) {
144 unsigned long dummy;
145
146 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000147 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 "1: lld %0, %3 # xchg_u64 \n"
149 " move %2, %z4 \n"
150 " scd %2, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100151 " beqz %2, 2f \n"
152 " .subsection 2 \n"
153 "2: b 1b \n"
154 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000155 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
157 : "R" (*m), "Jr" (val)
158 : "memory");
159 } else {
160 unsigned long flags;
161
Ralf Baechle49edd092007-03-16 16:10:36 +0000162 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 retval = *m;
164 *m = val;
Ralf Baechle49edd092007-03-16 16:10:36 +0000165 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 }
167
Ralf Baechle17099b12007-07-14 13:24:05 +0100168 smp_llsc_mb();
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return retval;
171}
172#else
173extern __u64 __xchg_u64_unsupported_on_32bit_kernels(volatile __u64 * m, __u64 val);
174#define __xchg_u64 __xchg_u64_unsupported_on_32bit_kernels
175#endif
176
177/* This function doesn't exist, so you'll get a linker error
178 if something tries to do an invalid xchg(). */
179extern void __xchg_called_with_bad_pointer(void);
180
181static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
182{
183 switch (size) {
Ralf Baechle0cea0432006-03-03 09:42:05 +0000184 case 4:
185 return __xchg_u32(ptr, x);
186 case 8:
187 return __xchg_u64(ptr, x);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 }
189 __xchg_called_with_bad_pointer();
190 return x;
191}
192
193#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195#define __HAVE_ARCH_CMPXCHG 1
196
197static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
198 unsigned long new)
199{
200 __u32 retval;
201
202 if (cpu_has_llsc && R10000_LLSC_WAR) {
203 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000204 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000206 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 "1: ll %0, %2 # __cmpxchg_u32 \n"
208 " bne %0, %z3, 2f \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000209 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 " move $1, %z4 \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000211 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 " sc $1, %1 \n"
213 " beqzl $1, 1b \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 "2: \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000215 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000216 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 : "R" (*m), "Jr" (old), "Jr" (new)
218 : "memory");
219 } else if (cpu_has_llsc) {
220 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000221 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000223 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 "1: ll %0, %2 # __cmpxchg_u32 \n"
225 " bne %0, %z3, 2f \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000226 " .set mips0 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 " move $1, %z4 \n"
Ralf Baechlef99d3022005-08-25 16:22:09 +0000228 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 " sc $1, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100230 " beqz $1, 3f \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 "2: \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100232 " .subsection 2 \n"
233 "3: b 1b \n"
234 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000235 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000236 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 : "R" (*m), "Jr" (old), "Jr" (new)
238 : "memory");
239 } else {
240 unsigned long flags;
241
Ralf Baechle49edd092007-03-16 16:10:36 +0000242 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 retval = *m;
244 if (retval == old)
245 *m = new;
Ralf Baechle49edd092007-03-16 16:10:36 +0000246 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 }
248
Ralf Baechle17099b12007-07-14 13:24:05 +0100249 smp_llsc_mb();
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000250
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 return retval;
252}
253
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700254static inline unsigned long __cmpxchg_u32_local(volatile int * m,
255 unsigned long old, unsigned long new)
256{
257 __u32 retval;
258
259 if (cpu_has_llsc && R10000_LLSC_WAR) {
260 __asm__ __volatile__(
261 " .set push \n"
262 " .set noat \n"
263 " .set mips3 \n"
264 "1: ll %0, %2 # __cmpxchg_u32 \n"
265 " bne %0, %z3, 2f \n"
266 " .set mips0 \n"
267 " move $1, %z4 \n"
268 " .set mips3 \n"
269 " sc $1, %1 \n"
270 " beqzl $1, 1b \n"
271 "2: \n"
272 " .set pop \n"
273 : "=&r" (retval), "=R" (*m)
274 : "R" (*m), "Jr" (old), "Jr" (new)
275 : "memory");
276 } else if (cpu_has_llsc) {
277 __asm__ __volatile__(
278 " .set push \n"
279 " .set noat \n"
280 " .set mips3 \n"
281 "1: ll %0, %2 # __cmpxchg_u32 \n"
282 " bne %0, %z3, 2f \n"
283 " .set mips0 \n"
284 " move $1, %z4 \n"
285 " .set mips3 \n"
286 " sc $1, %1 \n"
287 " beqz $1, 1b \n"
288 "2: \n"
289 " .set pop \n"
290 : "=&r" (retval), "=R" (*m)
291 : "R" (*m), "Jr" (old), "Jr" (new)
292 : "memory");
293 } else {
294 unsigned long flags;
295
296 local_irq_save(flags);
297 retval = *m;
298 if (retval == old)
299 *m = new;
300 local_irq_restore(flags); /* implies memory barrier */
301 }
302
303 return retval;
304}
305
Ralf Baechle875d43e2005-09-03 15:56:16 -0700306#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
308 unsigned long new)
309{
310 __u64 retval;
311
Ralf Baechle904880e2006-10-13 11:32:50 +0100312 if (cpu_has_llsc && R10000_LLSC_WAR) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000314 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 " .set noat \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000316 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 "1: lld %0, %2 # __cmpxchg_u64 \n"
318 " bne %0, %z3, 2f \n"
319 " move $1, %z4 \n"
320 " scd $1, %1 \n"
321 " beqzl $1, 1b \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 "2: \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000323 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000324 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 : "R" (*m), "Jr" (old), "Jr" (new)
326 : "memory");
327 } else if (cpu_has_llsc) {
328 __asm__ __volatile__(
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000329 " .set push \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 " .set noat \n"
Maciej W. Rozyckic4559f62005-06-23 15:57:15 +0000331 " .set mips3 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 "1: lld %0, %2 # __cmpxchg_u64 \n"
333 " bne %0, %z3, 2f \n"
334 " move $1, %z4 \n"
335 " scd $1, %1 \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100336 " beqz $1, 3f \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 "2: \n"
Ralf Baechlef65e4fa2006-09-28 01:45:21 +0100338 " .subsection 2 \n"
339 "3: b 1b \n"
340 " .previous \n"
Maciej W. Rozyckiaac8aa72005-06-14 17:35:03 +0000341 " .set pop \n"
Ralf Baechle3e6cb2d2006-02-21 18:32:14 +0000342 : "=&r" (retval), "=R" (*m)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 : "R" (*m), "Jr" (old), "Jr" (new)
344 : "memory");
345 } else {
346 unsigned long flags;
347
Ralf Baechle49edd092007-03-16 16:10:36 +0000348 raw_local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 retval = *m;
350 if (retval == old)
351 *m = new;
Ralf Baechle49edd092007-03-16 16:10:36 +0000352 raw_local_irq_restore(flags); /* implies memory barrier */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 }
354
Ralf Baechle17099b12007-07-14 13:24:05 +0100355 smp_llsc_mb();
Ralf Baechle0004a9d2006-10-31 03:45:07 +0000356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 return retval;
358}
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700359
360static inline unsigned long __cmpxchg_u64_local(volatile int * m,
361 unsigned long old, unsigned long new)
362{
363 __u64 retval;
364
365 if (cpu_has_llsc && R10000_LLSC_WAR) {
366 __asm__ __volatile__(
367 " .set push \n"
368 " .set noat \n"
369 " .set mips3 \n"
370 "1: lld %0, %2 # __cmpxchg_u64 \n"
371 " bne %0, %z3, 2f \n"
372 " move $1, %z4 \n"
373 " scd $1, %1 \n"
374 " beqzl $1, 1b \n"
375 "2: \n"
376 " .set pop \n"
377 : "=&r" (retval), "=R" (*m)
378 : "R" (*m), "Jr" (old), "Jr" (new)
379 : "memory");
380 } else if (cpu_has_llsc) {
381 __asm__ __volatile__(
382 " .set push \n"
383 " .set noat \n"
384 " .set mips3 \n"
385 "1: lld %0, %2 # __cmpxchg_u64 \n"
386 " bne %0, %z3, 2f \n"
387 " move $1, %z4 \n"
388 " scd $1, %1 \n"
389 " beqz $1, 1b \n"
390 "2: \n"
391 " .set pop \n"
392 : "=&r" (retval), "=R" (*m)
393 : "R" (*m), "Jr" (old), "Jr" (new)
394 : "memory");
395 } else {
396 unsigned long flags;
397
398 local_irq_save(flags);
399 retval = *m;
400 if (retval == old)
401 *m = new;
402 local_irq_restore(flags); /* implies memory barrier */
403 }
404
405 return retval;
406}
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408#else
409extern unsigned long __cmpxchg_u64_unsupported_on_32bit_kernels(
410 volatile int * m, unsigned long old, unsigned long new);
411#define __cmpxchg_u64 __cmpxchg_u64_unsupported_on_32bit_kernels
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700412extern unsigned long __cmpxchg_u64_local_unsupported_on_32bit_kernels(
413 volatile int * m, unsigned long old, unsigned long new);
414#define __cmpxchg_u64_local __cmpxchg_u64_local_unsupported_on_32bit_kernels
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415#endif
416
417/* This function doesn't exist, so you'll get a linker error
418 if something tries to do an invalid cmpxchg(). */
419extern void __cmpxchg_called_with_bad_pointer(void);
420
421static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
422 unsigned long new, int size)
423{
424 switch (size) {
425 case 4:
426 return __cmpxchg_u32(ptr, old, new);
427 case 8:
428 return __cmpxchg_u64(ptr, old, new);
429 }
430 __cmpxchg_called_with_bad_pointer();
431 return old;
432}
433
Mathieu Desnoyers72323112007-05-08 00:34:47 -0700434static inline unsigned long __cmpxchg_local(volatile void * ptr,
435 unsigned long old, unsigned long new, int size)
436{
437 switch (size) {
438 case 4:
439 return __cmpxchg_u32_local(ptr, old, new);
440 case 8:
441 return __cmpxchg_u64_local(ptr, old, new);
442 }
443 __cmpxchg_called_with_bad_pointer();
444 return old;
445}
446
447#define cmpxchg(ptr,old,new) \
448 ((__typeof__(*(ptr)))__cmpxchg((ptr), \
449 (unsigned long)(old), (unsigned long)(new),sizeof(*(ptr))))
450
451#define cmpxchg_local(ptr,old,new) \
452 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), \
453 (unsigned long)(old), (unsigned long)(new),sizeof(*(ptr))))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Ralf Baechlee01402b2005-07-14 15:57:16 +0000455extern void set_handler (unsigned long offset, void *addr, unsigned long len);
456extern void set_uncached_handler (unsigned long offset, void *addr, unsigned long len);
Ralf Baechleef300e42007-05-06 18:31:18 +0100457
458typedef void (*vi_handler_t)(void);
459extern void *set_vi_handler (int n, vi_handler_t addr);
460
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461extern void *set_except_vector(int n, void *addr);
Ralf Baechle91b05e62006-03-29 18:53:00 +0100462extern unsigned long ebase;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463extern void per_cpu_trap_init(void);
464
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465extern int stop_a_enabled;
466
467/*
Nick Piggin4866cde2005-06-25 14:57:23 -0700468 * See include/asm-ia64/system.h; prevents deadlock on SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 * systems.
470 */
Nick Piggin4866cde2005-06-25 14:57:23 -0700471#define __ARCH_WANT_UNLOCKED_CTXSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
473#define arch_align_stack(x) (x)
474
475#endif /* _ASM_SYSTEM_H */