diff options
author | Becky Bruce <bgill@freescale.com> | 2005-09-22 15:20:04 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-09-25 08:38:46 -0400 |
commit | feaf7cf153335fe7100b65ed6f4585c3574fe69a (patch) | |
tree | c57198f01b5f12ffe8ce90f4e1399505c1f84a02 /include/asm-ppc | |
parent | 2bfadee32f1501faa3184d574f6a769f17236c87 (diff) |
[PATCH] powerpc: merge atomic.h, memory.h
powerpc: Merge atomic.h and memory.h into powerpc
Merged atomic.h into include/powerpc. Moved asm-style HMT_ defines from
memory.h into ppc_asm.h, where there were already HMT_defines; moved c-style
HMT_ defines to processor.h. Renamed memory.h to synch.h to better reflect
its contents.
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Becky Bruce <becky.bruce@freescale.com>
Signed-off-by: Jon Loeliger <linuxppc@jdl.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-ppc')
-rw-r--r-- | include/asm-ppc/atomic.h | 214 | ||||
-rw-r--r-- | include/asm-ppc/io.h | 11 |
2 files changed, 1 insertions, 224 deletions
diff --git a/include/asm-ppc/atomic.h b/include/asm-ppc/atomic.h deleted file mode 100644 index eeafd505836e..000000000000 --- a/include/asm-ppc/atomic.h +++ /dev/null | |||
@@ -1,214 +0,0 @@ | |||
1 | /* | ||
2 | * PowerPC atomic operations | ||
3 | */ | ||
4 | |||
5 | #ifndef _ASM_PPC_ATOMIC_H_ | ||
6 | #define _ASM_PPC_ATOMIC_H_ | ||
7 | |||
8 | typedef struct { volatile int counter; } atomic_t; | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | #define ATOMIC_INIT(i) { (i) } | ||
13 | |||
14 | #define atomic_read(v) ((v)->counter) | ||
15 | #define atomic_set(v,i) (((v)->counter) = (i)) | ||
16 | |||
17 | extern void atomic_clear_mask(unsigned long mask, unsigned long *addr); | ||
18 | |||
19 | #ifdef CONFIG_SMP | ||
20 | #define SMP_SYNC "sync" | ||
21 | #define SMP_ISYNC "\n\tisync" | ||
22 | #else | ||
23 | #define SMP_SYNC "" | ||
24 | #define SMP_ISYNC | ||
25 | #endif | ||
26 | |||
27 | /* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx. | ||
28 | * The old ATOMIC_SYNC_FIX covered some but not all of this. | ||
29 | */ | ||
30 | #ifdef CONFIG_IBM405_ERR77 | ||
31 | #define PPC405_ERR77(ra,rb) "dcbt " #ra "," #rb ";" | ||
32 | #else | ||
33 | #define PPC405_ERR77(ra,rb) | ||
34 | #endif | ||
35 | |||
36 | static __inline__ void atomic_add(int a, atomic_t *v) | ||
37 | { | ||
38 | int t; | ||
39 | |||
40 | __asm__ __volatile__( | ||
41 | "1: lwarx %0,0,%3 # atomic_add\n\ | ||
42 | add %0,%2,%0\n" | ||
43 | PPC405_ERR77(0,%3) | ||
44 | " stwcx. %0,0,%3 \n\ | ||
45 | bne- 1b" | ||
46 | : "=&r" (t), "=m" (v->counter) | ||
47 | : "r" (a), "r" (&v->counter), "m" (v->counter) | ||
48 | : "cc"); | ||
49 | } | ||
50 | |||
51 | static __inline__ int atomic_add_return(int a, atomic_t *v) | ||
52 | { | ||
53 | int t; | ||
54 | |||
55 | __asm__ __volatile__( | ||
56 | "1: lwarx %0,0,%2 # atomic_add_return\n\ | ||
57 | add %0,%1,%0\n" | ||
58 | PPC405_ERR77(0,%2) | ||
59 | " stwcx. %0,0,%2 \n\ | ||
60 | bne- 1b" | ||
61 | SMP_ISYNC | ||
62 | : "=&r" (t) | ||
63 | : "r" (a), "r" (&v->counter) | ||
64 | : "cc", "memory"); | ||
65 | |||
66 | return t; | ||
67 | } | ||
68 | |||
69 | #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) | ||
70 | |||
71 | static __inline__ void atomic_sub(int a, atomic_t *v) | ||
72 | { | ||
73 | int t; | ||
74 | |||
75 | __asm__ __volatile__( | ||
76 | "1: lwarx %0,0,%3 # atomic_sub\n\ | ||
77 | subf %0,%2,%0\n" | ||
78 | PPC405_ERR77(0,%3) | ||
79 | " stwcx. %0,0,%3 \n\ | ||
80 | bne- 1b" | ||
81 | : "=&r" (t), "=m" (v->counter) | ||
82 | : "r" (a), "r" (&v->counter), "m" (v->counter) | ||
83 | : "cc"); | ||
84 | } | ||
85 | |||
86 | static __inline__ int atomic_sub_return(int a, atomic_t *v) | ||
87 | { | ||
88 | int t; | ||
89 | |||
90 | __asm__ __volatile__( | ||
91 | "1: lwarx %0,0,%2 # atomic_sub_return\n\ | ||
92 | subf %0,%1,%0\n" | ||
93 | PPC405_ERR77(0,%2) | ||
94 | " stwcx. %0,0,%2 \n\ | ||
95 | bne- 1b" | ||
96 | SMP_ISYNC | ||
97 | : "=&r" (t) | ||
98 | : "r" (a), "r" (&v->counter) | ||
99 | : "cc", "memory"); | ||
100 | |||
101 | return t; | ||
102 | } | ||
103 | |||
104 | static __inline__ void atomic_inc(atomic_t *v) | ||
105 | { | ||
106 | int t; | ||
107 | |||
108 | __asm__ __volatile__( | ||
109 | "1: lwarx %0,0,%2 # atomic_inc\n\ | ||
110 | addic %0,%0,1\n" | ||
111 | PPC405_ERR77(0,%2) | ||
112 | " stwcx. %0,0,%2 \n\ | ||
113 | bne- 1b" | ||
114 | : "=&r" (t), "=m" (v->counter) | ||
115 | : "r" (&v->counter), "m" (v->counter) | ||
116 | : "cc"); | ||
117 | } | ||
118 | |||
119 | static __inline__ int atomic_inc_return(atomic_t *v) | ||
120 | { | ||
121 | int t; | ||
122 | |||
123 | __asm__ __volatile__( | ||
124 | "1: lwarx %0,0,%1 # atomic_inc_return\n\ | ||
125 | addic %0,%0,1\n" | ||
126 | PPC405_ERR77(0,%1) | ||
127 | " stwcx. %0,0,%1 \n\ | ||
128 | bne- 1b" | ||
129 | SMP_ISYNC | ||
130 | : "=&r" (t) | ||
131 | : "r" (&v->counter) | ||
132 | : "cc", "memory"); | ||
133 | |||
134 | return t; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * atomic_inc_and_test - increment and test | ||
139 | * @v: pointer of type atomic_t | ||
140 | * | ||
141 | * Atomically increments @v by 1 | ||
142 | * and returns true if the result is zero, or false for all | ||
143 | * other cases. | ||
144 | */ | ||
145 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | ||
146 | |||
147 | static __inline__ void atomic_dec(atomic_t *v) | ||
148 | { | ||
149 | int t; | ||
150 | |||
151 | __asm__ __volatile__( | ||
152 | "1: lwarx %0,0,%2 # atomic_dec\n\ | ||
153 | addic %0,%0,-1\n" | ||
154 | PPC405_ERR77(0,%2)\ | ||
155 | " stwcx. %0,0,%2\n\ | ||
156 | bne- 1b" | ||
157 | : "=&r" (t), "=m" (v->counter) | ||
158 | : "r" (&v->counter), "m" (v->counter) | ||
159 | : "cc"); | ||
160 | } | ||
161 | |||
162 | static __inline__ int atomic_dec_return(atomic_t *v) | ||
163 | { | ||
164 | int t; | ||
165 | |||
166 | __asm__ __volatile__( | ||
167 | "1: lwarx %0,0,%1 # atomic_dec_return\n\ | ||
168 | addic %0,%0,-1\n" | ||
169 | PPC405_ERR77(0,%1) | ||
170 | " stwcx. %0,0,%1\n\ | ||
171 | bne- 1b" | ||
172 | SMP_ISYNC | ||
173 | : "=&r" (t) | ||
174 | : "r" (&v->counter) | ||
175 | : "cc", "memory"); | ||
176 | |||
177 | return t; | ||
178 | } | ||
179 | |||
180 | #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) | ||
181 | #define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0) | ||
182 | |||
183 | /* | ||
184 | * Atomically test *v and decrement if it is greater than 0. | ||
185 | * The function returns the old value of *v minus 1. | ||
186 | */ | ||
187 | static __inline__ int atomic_dec_if_positive(atomic_t *v) | ||
188 | { | ||
189 | int t; | ||
190 | |||
191 | __asm__ __volatile__( | ||
192 | "1: lwarx %0,0,%1 # atomic_dec_if_positive\n\ | ||
193 | addic. %0,%0,-1\n\ | ||
194 | blt- 2f\n" | ||
195 | PPC405_ERR77(0,%1) | ||
196 | " stwcx. %0,0,%1\n\ | ||
197 | bne- 1b" | ||
198 | SMP_ISYNC | ||
199 | "\n\ | ||
200 | 2:" : "=&r" (t) | ||
201 | : "r" (&v->counter) | ||
202 | : "cc", "memory"); | ||
203 | |||
204 | return t; | ||
205 | } | ||
206 | |||
207 | #define __MB __asm__ __volatile__ (SMP_SYNC : : : "memory") | ||
208 | #define smp_mb__before_atomic_dec() __MB | ||
209 | #define smp_mb__after_atomic_dec() __MB | ||
210 | #define smp_mb__before_atomic_inc() __MB | ||
211 | #define smp_mb__after_atomic_inc() __MB | ||
212 | |||
213 | #endif /* __KERNEL__ */ | ||
214 | #endif /* _ASM_PPC_ATOMIC_H_ */ | ||
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h index 7eb7cf6360bd..39caf067a31b 100644 --- a/include/asm-ppc/io.h +++ b/include/asm-ppc/io.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <asm/page.h> | 9 | #include <asm/page.h> |
10 | #include <asm/byteorder.h> | 10 | #include <asm/byteorder.h> |
11 | #include <asm/synch.h> | ||
11 | #include <asm/mmu.h> | 12 | #include <asm/mmu.h> |
12 | 13 | ||
13 | #define SIO_CONFIG_RA 0x398 | 14 | #define SIO_CONFIG_RA 0x398 |
@@ -440,16 +441,6 @@ extern inline void * phys_to_virt(unsigned long address) | |||
440 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | 441 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
441 | #define page_to_bus(page) (page_to_phys(page) + PCI_DRAM_OFFSET) | 442 | #define page_to_bus(page) (page_to_phys(page) + PCI_DRAM_OFFSET) |
442 | 443 | ||
443 | /* | ||
444 | * Enforce In-order Execution of I/O: | ||
445 | * Acts as a barrier to ensure all previous I/O accesses have | ||
446 | * completed before any further ones are issued. | ||
447 | */ | ||
448 | extern inline void eieio(void) | ||
449 | { | ||
450 | __asm__ __volatile__ ("eieio" : : : "memory"); | ||
451 | } | ||
452 | |||
453 | /* Enforce in-order execution of data I/O. | 444 | /* Enforce in-order execution of data I/O. |
454 | * No distinction between read/write on PPC; use eieio for all three. | 445 | * No distinction between read/write on PPC; use eieio for all three. |
455 | */ | 446 | */ |