aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/include')
-rw-r--r--arch/avr32/include/asm/atomic.h2
-rw-r--r--arch/avr32/include/asm/barrier.h27
-rw-r--r--arch/avr32/include/asm/bitops.h1
-rw-r--r--arch/avr32/include/asm/bug.h5
-rw-r--r--arch/avr32/include/asm/cmpxchg.h117
-rw-r--r--arch/avr32/include/asm/exec.h13
-rw-r--r--arch/avr32/include/asm/special_insns.h13
-rw-r--r--arch/avr32/include/asm/switch_to.h46
-rw-r--r--arch/avr32/include/asm/system.h184
9 files changed, 228 insertions, 180 deletions
diff --git a/arch/avr32/include/asm/atomic.h b/arch/avr32/include/asm/atomic.h
index e0ac2631c87e..61407279208a 100644
--- a/arch/avr32/include/asm/atomic.h
+++ b/arch/avr32/include/asm/atomic.h
@@ -15,7 +15,7 @@
15#define __ASM_AVR32_ATOMIC_H 15#define __ASM_AVR32_ATOMIC_H
16 16
17#include <linux/types.h> 17#include <linux/types.h>
18#include <asm/system.h> 18#include <asm/cmpxchg.h>
19 19
20#define ATOMIC_INIT(i) { (i) } 20#define ATOMIC_INIT(i) { (i) }
21 21
diff --git a/arch/avr32/include/asm/barrier.h b/arch/avr32/include/asm/barrier.h
new file mode 100644
index 000000000000..808001c9cf8c
--- /dev/null
+++ b/arch/avr32/include/asm/barrier.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_AVR32_BARRIER_H
9#define __ASM_AVR32_BARRIER_H
10
11#define mb() asm volatile("" : : : "memory")
12#define rmb() mb()
13#define wmb() asm volatile("sync 0" : : : "memory")
14#define read_barrier_depends() do { } while(0)
15#define set_mb(var, value) do { var = value; mb(); } while(0)
16
17#ifdef CONFIG_SMP
18# error "The AVR32 port does not support SMP"
19#else
20# define smp_mb() barrier()
21# define smp_rmb() barrier()
22# define smp_wmb() barrier()
23# define smp_read_barrier_depends() do { } while(0)
24#endif
25
26
27#endif /* __ASM_AVR32_BARRIER_H */
diff --git a/arch/avr32/include/asm/bitops.h b/arch/avr32/include/asm/bitops.h
index b70c19bab63a..ebe7ad3f490b 100644
--- a/arch/avr32/include/asm/bitops.h
+++ b/arch/avr32/include/asm/bitops.h
@@ -13,7 +13,6 @@
13#endif 13#endif
14 14
15#include <asm/byteorder.h> 15#include <asm/byteorder.h>
16#include <asm/system.h>
17 16
18/* 17/*
19 * clear_bit() doesn't provide any barrier for the compiler 18 * clear_bit() doesn't provide any barrier for the compiler
diff --git a/arch/avr32/include/asm/bug.h b/arch/avr32/include/asm/bug.h
index 2aa373cc61b5..85a92d099adb 100644
--- a/arch/avr32/include/asm/bug.h
+++ b/arch/avr32/include/asm/bug.h
@@ -70,4 +70,9 @@
70 70
71#include <asm-generic/bug.h> 71#include <asm-generic/bug.h>
72 72
73struct pt_regs;
74void die(const char *str, struct pt_regs *regs, long err);
75void _exception(long signr, struct pt_regs *regs, int code,
76 unsigned long addr);
77
73#endif /* __ASM_AVR32_BUG_H */ 78#endif /* __ASM_AVR32_BUG_H */
diff --git a/arch/avr32/include/asm/cmpxchg.h b/arch/avr32/include/asm/cmpxchg.h
new file mode 100644
index 000000000000..962a6aeab787
--- /dev/null
+++ b/arch/avr32/include/asm/cmpxchg.h
@@ -0,0 +1,117 @@
1/*
2 * Atomic operations that C can't guarantee us. Useful for
3 * resource counting etc.
4 *
5 * But use these as seldom as possible since they are slower than
6 * regular operations.
7 *
8 * Copyright (C) 2004-2006 Atmel Corporation
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#ifndef __ASM_AVR32_CMPXCHG_H
15#define __ASM_AVR32_CMPXCHG_H
16
17#define xchg(ptr,x) \
18 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
19
20extern void __xchg_called_with_bad_pointer(void);
21
22static inline unsigned long xchg_u32(u32 val, volatile u32 *m)
23{
24 u32 ret;
25
26 asm volatile("xchg %[ret], %[m], %[val]"
27 : [ret] "=&r"(ret), "=m"(*m)
28 : "m"(*m), [m] "r"(m), [val] "r"(val)
29 : "memory");
30 return ret;
31}
32
33static inline unsigned long __xchg(unsigned long x,
34 volatile void *ptr,
35 int size)
36{
37 switch(size) {
38 case 4:
39 return xchg_u32(x, ptr);
40 default:
41 __xchg_called_with_bad_pointer();
42 return x;
43 }
44}
45
46static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
47 unsigned long new)
48{
49 __u32 ret;
50
51 asm volatile(
52 "1: ssrf 5\n"
53 " ld.w %[ret], %[m]\n"
54 " cp.w %[ret], %[old]\n"
55 " brne 2f\n"
56 " stcond %[m], %[new]\n"
57 " brne 1b\n"
58 "2:\n"
59 : [ret] "=&r"(ret), [m] "=m"(*m)
60 : "m"(m), [old] "ir"(old), [new] "r"(new)
61 : "memory", "cc");
62 return ret;
63}
64
65extern unsigned long __cmpxchg_u64_unsupported_on_32bit_kernels(
66 volatile int * m, unsigned long old, unsigned long new);
67#define __cmpxchg_u64 __cmpxchg_u64_unsupported_on_32bit_kernels
68
69/* This function doesn't exist, so you'll get a linker error
70 if something tries to do an invalid cmpxchg(). */
71extern void __cmpxchg_called_with_bad_pointer(void);
72
73#define __HAVE_ARCH_CMPXCHG 1
74
75static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
76 unsigned long new, int size)
77{
78 switch (size) {
79 case 4:
80 return __cmpxchg_u32(ptr, old, new);
81 case 8:
82 return __cmpxchg_u64(ptr, old, new);
83 }
84
85 __cmpxchg_called_with_bad_pointer();
86 return old;
87}
88
89#define cmpxchg(ptr, old, new) \
90 ((typeof(*(ptr)))__cmpxchg((ptr), (unsigned long)(old), \
91 (unsigned long)(new), \
92 sizeof(*(ptr))))
93
94#include <asm-generic/cmpxchg-local.h>
95
96static inline unsigned long __cmpxchg_local(volatile void *ptr,
97 unsigned long old,
98 unsigned long new, int size)
99{
100 switch (size) {
101 case 4:
102 return __cmpxchg_u32(ptr, old, new);
103 default:
104 return __cmpxchg_local_generic(ptr, old, new, size);
105 }
106
107 return old;
108}
109
110#define cmpxchg_local(ptr, old, new) \
111 ((typeof(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(old), \
112 (unsigned long)(new), \
113 sizeof(*(ptr))))
114
115#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
116
117#endif /* __ASM_AVR32_CMPXCHG_H */
diff --git a/arch/avr32/include/asm/exec.h b/arch/avr32/include/asm/exec.h
new file mode 100644
index 000000000000..f467be8bf823
--- /dev/null
+++ b/arch/avr32/include/asm/exec.h
@@ -0,0 +1,13 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_AVR32_EXEC_H
9#define __ASM_AVR32_EXEC_H
10
11#define arch_align_stack(x) (x)
12
13#endif /* __ASM_AVR32_EXEC_H */
diff --git a/arch/avr32/include/asm/special_insns.h b/arch/avr32/include/asm/special_insns.h
new file mode 100644
index 000000000000..f922218dfaa5
--- /dev/null
+++ b/arch/avr32/include/asm/special_insns.h
@@ -0,0 +1,13 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_AVR32_SPECIAL_INSNS_H
9#define __ASM_AVR32_SPECIAL_INSNS_H
10
11#define nop() asm volatile("nop")
12
13#endif /* __ASM_AVR32_SPECIAL_INSNS_H */
diff --git a/arch/avr32/include/asm/switch_to.h b/arch/avr32/include/asm/switch_to.h
new file mode 100644
index 000000000000..9a8e9d5208d4
--- /dev/null
+++ b/arch/avr32/include/asm/switch_to.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_AVR32_SWITCH_TO_H
9#define __ASM_AVR32_SWITCH_TO_H
10
11/*
12 * Help PathFinder and other Nexus-compliant debuggers keep track of
13 * the current PID by emitting an Ownership Trace Message each time we
14 * switch task.
15 */
16#ifdef CONFIG_OWNERSHIP_TRACE
17#include <asm/ocd.h>
18#define finish_arch_switch(prev) \
19 do { \
20 ocd_write(PID, prev->pid); \
21 ocd_write(PID, current->pid); \
22 } while(0)
23#endif
24
25/*
26 * switch_to(prev, next, last) should switch from task `prev' to task
27 * `next'. `prev' will never be the same as `next'.
28 *
29 * We just delegate everything to the __switch_to assembly function,
30 * which is implemented in arch/avr32/kernel/switch_to.S
31 *
32 * mb() tells GCC not to cache `current' across this call.
33 */
34struct cpu_context;
35struct task_struct;
36extern struct task_struct *__switch_to(struct task_struct *,
37 struct cpu_context *,
38 struct cpu_context *);
39#define switch_to(prev, next, last) \
40 do { \
41 last = __switch_to(prev, &prev->thread.cpu_context + 1, \
42 &next->thread.cpu_context); \
43 } while (0)
44
45
46#endif /* __ASM_AVR32_SWITCH_TO_H */
diff --git a/arch/avr32/include/asm/system.h b/arch/avr32/include/asm/system.h
index 62d9ded01635..0d84f9e42fde 100644
--- a/arch/avr32/include/asm/system.h
+++ b/arch/avr32/include/asm/system.h
@@ -1,178 +1,6 @@
1/* 1/* FILE TO BE DELETED. DO NOT ADD STUFF HERE! */
2 * Copyright (C) 2004-2006 Atmel Corporation 2#include <asm/barrier.h>
3 * 3#include <asm/cmpxchg.h>
4 * This program is free software; you can redistribute it and/or modify 4#include <asm/exec.h>
5 * it under the terms of the GNU General Public License version 2 as 5#include <asm/special_insns.h>
6 * published by the Free Software Foundation. 6#include <asm/switch_to.h>
7 */
8#ifndef __ASM_AVR32_SYSTEM_H
9#define __ASM_AVR32_SYSTEM_H
10
11#include <linux/compiler.h>
12#include <linux/linkage.h>
13#include <linux/types.h>
14
15#include <asm/ptrace.h>
16#include <asm/sysreg.h>
17
18#define xchg(ptr,x) \
19 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
20
21#define nop() asm volatile("nop")
22
23#define mb() asm volatile("" : : : "memory")
24#define rmb() mb()
25#define wmb() asm volatile("sync 0" : : : "memory")
26#define read_barrier_depends() do { } while(0)
27#define set_mb(var, value) do { var = value; mb(); } while(0)
28
29/*
30 * Help PathFinder and other Nexus-compliant debuggers keep track of
31 * the current PID by emitting an Ownership Trace Message each time we
32 * switch task.
33 */
34#ifdef CONFIG_OWNERSHIP_TRACE
35#include <asm/ocd.h>
36#define finish_arch_switch(prev) \
37 do { \
38 ocd_write(PID, prev->pid); \
39 ocd_write(PID, current->pid); \
40 } while(0)
41#endif
42
43/*
44 * switch_to(prev, next, last) should switch from task `prev' to task
45 * `next'. `prev' will never be the same as `next'.
46 *
47 * We just delegate everything to the __switch_to assembly function,
48 * which is implemented in arch/avr32/kernel/switch_to.S
49 *
50 * mb() tells GCC not to cache `current' across this call.
51 */
52struct cpu_context;
53struct task_struct;
54extern struct task_struct *__switch_to(struct task_struct *,
55 struct cpu_context *,
56 struct cpu_context *);
57#define switch_to(prev, next, last) \
58 do { \
59 last = __switch_to(prev, &prev->thread.cpu_context + 1, \
60 &next->thread.cpu_context); \
61 } while (0)
62
63#ifdef CONFIG_SMP
64# error "The AVR32 port does not support SMP"
65#else
66# define smp_mb() barrier()
67# define smp_rmb() barrier()
68# define smp_wmb() barrier()
69# define smp_read_barrier_depends() do { } while(0)
70#endif
71
72#include <linux/irqflags.h>
73
74extern void __xchg_called_with_bad_pointer(void);
75
76static inline unsigned long xchg_u32(u32 val, volatile u32 *m)
77{
78 u32 ret;
79
80 asm volatile("xchg %[ret], %[m], %[val]"
81 : [ret] "=&r"(ret), "=m"(*m)
82 : "m"(*m), [m] "r"(m), [val] "r"(val)
83 : "memory");
84 return ret;
85}
86
87static inline unsigned long __xchg(unsigned long x,
88 volatile void *ptr,
89 int size)
90{
91 switch(size) {
92 case 4:
93 return xchg_u32(x, ptr);
94 default:
95 __xchg_called_with_bad_pointer();
96 return x;
97 }
98}
99
100static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
101 unsigned long new)
102{
103 __u32 ret;
104
105 asm volatile(
106 "1: ssrf 5\n"
107 " ld.w %[ret], %[m]\n"
108 " cp.w %[ret], %[old]\n"
109 " brne 2f\n"
110 " stcond %[m], %[new]\n"
111 " brne 1b\n"
112 "2:\n"
113 : [ret] "=&r"(ret), [m] "=m"(*m)
114 : "m"(m), [old] "ir"(old), [new] "r"(new)
115 : "memory", "cc");
116 return ret;
117}
118
119extern unsigned long __cmpxchg_u64_unsupported_on_32bit_kernels(
120 volatile int * m, unsigned long old, unsigned long new);
121#define __cmpxchg_u64 __cmpxchg_u64_unsupported_on_32bit_kernels
122
123/* This function doesn't exist, so you'll get a linker error
124 if something tries to do an invalid cmpxchg(). */
125extern void __cmpxchg_called_with_bad_pointer(void);
126
127#define __HAVE_ARCH_CMPXCHG 1
128
129static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
130 unsigned long new, int size)
131{
132 switch (size) {
133 case 4:
134 return __cmpxchg_u32(ptr, old, new);
135 case 8:
136 return __cmpxchg_u64(ptr, old, new);
137 }
138
139 __cmpxchg_called_with_bad_pointer();
140 return old;
141}
142
143#define cmpxchg(ptr, old, new) \
144 ((typeof(*(ptr)))__cmpxchg((ptr), (unsigned long)(old), \
145 (unsigned long)(new), \
146 sizeof(*(ptr))))
147
148#include <asm-generic/cmpxchg-local.h>
149
150static inline unsigned long __cmpxchg_local(volatile void *ptr,
151 unsigned long old,
152 unsigned long new, int size)
153{
154 switch (size) {
155 case 4:
156 return __cmpxchg_u32(ptr, old, new);
157 default:
158 return __cmpxchg_local_generic(ptr, old, new, size);
159 }
160
161 return old;
162}
163
164#define cmpxchg_local(ptr, old, new) \
165 ((typeof(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(old), \
166 (unsigned long)(new), \
167 sizeof(*(ptr))))
168
169#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
170
171struct pt_regs;
172void die(const char *str, struct pt_regs *regs, long err);
173void _exception(long signr, struct pt_regs *regs, int code,
174 unsigned long addr);
175
176#define arch_align_stack(x) (x)
177
178#endif /* __ASM_AVR32_SYSTEM_H */