diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-11-12 17:27:39 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-12-04 04:39:05 -0500 |
commit | 68a64357d15ae4f596e92715719071952006e83c (patch) | |
tree | dee519239225e92169ef77e4fad3be25c4dffe9d /arch/powerpc/kernel/io.c | |
parent | 3d1ea8e8cb4d497a2dd73176cc82095b8f193589 (diff) |
[POWERPC] Merge 32 and 64 bits asm-powerpc/io.h
powerpc: Merge 32 and 64 bits asm-powerpc/io.h
The rework on io.h done for the new hookable accessors made it easier,
so I just finished the work and merged 32 and 64 bits io.h for arch/powerpc.
arch/ppc still uses the old version in asm-ppc, there is just too much gunk
in there that I really can't be bothered trying to cleanup.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/io.c')
-rw-r--r-- | arch/powerpc/kernel/io.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c index c1aa07524c26..34ae11494ddc 100644 --- a/arch/powerpc/kernel/io.c +++ b/arch/powerpc/kernel/io.c | |||
@@ -117,3 +117,90 @@ void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count) | |||
117 | asm volatile("sync"); | 117 | asm volatile("sync"); |
118 | } | 118 | } |
119 | EXPORT_SYMBOL(_outsl_ns); | 119 | EXPORT_SYMBOL(_outsl_ns); |
120 | |||
121 | #define IO_CHECK_ALIGN(v,a) ((((unsigned long)(v)) & ((a) - 1)) == 0) | ||
122 | |||
123 | void _memset_io(volatile void __iomem *addr, int c, unsigned long n) | ||
124 | { | ||
125 | void *p = (void __force *)addr; | ||
126 | u32 lc = c; | ||
127 | lc |= lc << 8; | ||
128 | lc |= lc << 16; | ||
129 | |||
130 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
131 | while(n && !IO_CHECK_ALIGN(p, 4)) { | ||
132 | *((volatile u8 *)p) = c; | ||
133 | p++; | ||
134 | n--; | ||
135 | } | ||
136 | while(n >= 4) { | ||
137 | *((volatile u32 *)p) = lc; | ||
138 | p += 4; | ||
139 | n -= 4; | ||
140 | } | ||
141 | while(n) { | ||
142 | *((volatile u8 *)p) = c; | ||
143 | p++; | ||
144 | n--; | ||
145 | } | ||
146 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
147 | } | ||
148 | EXPORT_SYMBOL(_memset_io); | ||
149 | |||
150 | void _memcpy_fromio(void *dest, const volatile void __iomem *src, | ||
151 | unsigned long n) | ||
152 | { | ||
153 | void *vsrc = (void __force *) src; | ||
154 | |||
155 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
156 | while(n && (!IO_CHECK_ALIGN(vsrc, 4) || !IO_CHECK_ALIGN(dest, 4))) { | ||
157 | *((u8 *)dest) = *((volatile u8 *)vsrc); | ||
158 | __asm__ __volatile__ ("eieio" : : : "memory"); | ||
159 | vsrc++; | ||
160 | dest++; | ||
161 | n--; | ||
162 | } | ||
163 | while(n > 4) { | ||
164 | *((u32 *)dest) = *((volatile u32 *)vsrc); | ||
165 | __asm__ __volatile__ ("eieio" : : : "memory"); | ||
166 | vsrc += 4; | ||
167 | dest += 4; | ||
168 | n -= 4; | ||
169 | } | ||
170 | while(n) { | ||
171 | *((u8 *)dest) = *((volatile u8 *)vsrc); | ||
172 | __asm__ __volatile__ ("eieio" : : : "memory"); | ||
173 | vsrc++; | ||
174 | dest++; | ||
175 | n--; | ||
176 | } | ||
177 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
178 | } | ||
179 | EXPORT_SYMBOL(_memcpy_fromio); | ||
180 | |||
181 | void _memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n) | ||
182 | { | ||
183 | void *vdest = (void __force *) dest; | ||
184 | |||
185 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
186 | while(n && (!IO_CHECK_ALIGN(vdest, 4) || !IO_CHECK_ALIGN(src, 4))) { | ||
187 | *((volatile u8 *)vdest) = *((u8 *)src); | ||
188 | src++; | ||
189 | vdest++; | ||
190 | n--; | ||
191 | } | ||
192 | while(n > 4) { | ||
193 | *((volatile u32 *)vdest) = *((volatile u32 *)src); | ||
194 | src += 4; | ||
195 | vdest += 4; | ||
196 | n-=4; | ||
197 | } | ||
198 | while(n) { | ||
199 | *((volatile u8 *)vdest) = *((u8 *)src); | ||
200 | src++; | ||
201 | vdest++; | ||
202 | n--; | ||
203 | } | ||
204 | __asm__ __volatile__ ("sync" : : : "memory"); | ||
205 | } | ||
206 | EXPORT_SYMBOL(_memcpy_toio); | ||