aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2006-09-19 08:17:49 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2006-09-20 00:06:18 -0400
commit5adcaf50cf697aa4d0c731107003c1383b59b214 (patch)
treec4f93c02f43c325066a46e9d9221cac9d51125d8
parent73ea9e1bcb8eea4f3b2052fe7ccd7ee4b5a271a0 (diff)
[POWERPC] convert string i/o operations to C
This produces essentially the same code and will make the iSeries i/o consolidation easier. The count parameter is changed to long since that will produce the same (better) code on 32 and 64 bit builds. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/io.c117
-rw-r--r--arch/powerpc/kernel/misc.S95
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c7
-rw-r--r--include/asm-powerpc/io.h12
-rw-r--r--include/asm-ppc/io.h12
6 files changed, 130 insertions, 115 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8b3f4faf5768..8b133afbdc20 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -51,7 +51,7 @@ extra-$(CONFIG_8xx) := head_8xx.o
51extra-y += vmlinux.lds 51extra-y += vmlinux.lds
52 52
53obj-y += time.o prom.o traps.o setup-common.o \ 53obj-y += time.o prom.o traps.o setup-common.o \
54 udbg.o misc.o 54 udbg.o misc.o io.o
55obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o 55obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o
56obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o 56obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o
57obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o 57obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
new file mode 100644
index 000000000000..80a3209acef4
--- /dev/null
+++ b/arch/powerpc/kernel/io.c
@@ -0,0 +1,117 @@
1/*
2 * I/O string operations
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
4 * Copyright (C) 2006 IBM Corporation
5 *
6 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
7 * and Paul Mackerras.
8 *
9 * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
10 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
11 *
12 * Rewritten in C by Stephen Rothwell.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#include <linux/kernel.h>
20#include <linux/types.h>
21#include <linux/compiler.h>
22#include <linux/module.h>
23
24#include <asm/io.h>
25
26void _insb(volatile u8 __iomem *port, void *buf, long count)
27{
28 u8 *tbuf = buf;
29 u8 tmp;
30
31 if (unlikely(count <= 0))
32 return;
33 asm volatile("sync");
34 do {
35 tmp = *port;
36 asm volatile("eieio");
37 *tbuf++ = tmp;
38 } while (--count != 0);
39 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
40}
41EXPORT_SYMBOL(_insb);
42
43void _outsb(volatile u8 __iomem *port, const void *buf, long count)
44{
45 const u8 *tbuf = buf;
46
47 if (unlikely(count <= 0))
48 return;
49 asm volatile("sync");
50 do {
51 *port = *tbuf++;
52 } while (--count != 0);
53 asm volatile("sync");
54}
55EXPORT_SYMBOL(_outsb);
56
57void _insw_ns(volatile u16 __iomem *port, void *buf, long count)
58{
59 u16 *tbuf = buf;
60 u16 tmp;
61
62 if (unlikely(count <= 0))
63 return;
64 asm volatile("sync");
65 do {
66 tmp = *port;
67 asm volatile("eieio");
68 *tbuf++ = tmp;
69 } while (--count != 0);
70 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
71}
72EXPORT_SYMBOL(_insw_ns);
73
74void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count)
75{
76 const u16 *tbuf = buf;
77
78 if (unlikely(count <= 0))
79 return;
80 asm volatile("sync");
81 do {
82 *port = *tbuf++;
83 } while (--count != 0);
84 asm volatile("sync");
85}
86EXPORT_SYMBOL(_outsw_ns);
87
88void _insl_ns(volatile u32 __iomem *port, void *buf, long count)
89{
90 u32 *tbuf = buf;
91 u32 tmp;
92
93 if (unlikely(count <= 0))
94 return;
95 asm volatile("sync");
96 do {
97 tmp = *port;
98 asm volatile("eieio");
99 *tbuf++ = tmp;
100 } while (--count != 0);
101 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
102}
103EXPORT_SYMBOL(_insl_ns);
104
105void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
106{
107 const u32 *tbuf = buf;
108
109 if (unlikely(count <= 0))
110 return;
111 asm volatile("sync");
112 do {
113 *port = *tbuf++;
114 } while (--count != 0);
115 asm volatile("sync");
116}
117EXPORT_SYMBOL(_outsl_ns);
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 6feb391422ec..330c9dc7db86 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -43,98 +43,3 @@ _GLOBAL(add_reloc_offset)
43 add r3,r3,r5 43 add r3,r3,r5
44 mtlr r0 44 mtlr r0
45 blr 45 blr
46
47/*
48 * I/O string operations
49 *
50 * insb(port, buf, len)
51 * outsb(port, buf, len)
52 * insw(port, buf, len)
53 * outsw(port, buf, len)
54 * insl(port, buf, len)
55 * outsl(port, buf, len)
56 * insw_ns(port, buf, len)
57 * outsw_ns(port, buf, len)
58 * insl_ns(port, buf, len)
59 * outsl_ns(port, buf, len)
60 *
61 * The *_ns versions don't do byte-swapping.
62 */
63_GLOBAL(_insb)
64 sync
65 cmpwi 0,r5,0
66 mtctr r5
67 subi r4,r4,1
68 blelr-
6900: lbz r5,0(r3)
70 eieio
71 stbu r5,1(r4)
72 bdnz 00b
73 twi 0,r5,0
74 isync
75 blr
76
77_GLOBAL(_outsb)
78 cmpwi 0,r5,0
79 mtctr r5
80 subi r4,r4,1
81 blelr-
82 sync
8300: lbzu r5,1(r4)
84 stb r5,0(r3)
85 bdnz 00b
86 sync
87 blr
88
89_GLOBAL(_insw_ns)
90 sync
91 cmpwi 0,r5,0
92 mtctr r5
93 subi r4,r4,2
94 blelr-
9500: lhz r5,0(r3)
96 eieio
97 sthu r5,2(r4)
98 bdnz 00b
99 twi 0,r5,0
100 isync
101 blr
102
103_GLOBAL(_outsw_ns)
104 cmpwi 0,r5,0
105 mtctr r5
106 subi r4,r4,2
107 blelr-
108 sync
10900: lhzu r5,2(r4)
110 sth r5,0(r3)
111 bdnz 00b
112 sync
113 blr
114
115_GLOBAL(_insl_ns)
116 sync
117 cmpwi 0,r5,0
118 mtctr r5
119 subi r4,r4,4
120 blelr-
12100: lwz r5,0(r3)
122 eieio
123 stwu r5,4(r4)
124 bdnz 00b
125 twi 0,r5,0
126 isync
127 blr
128
129_GLOBAL(_outsl_ns)
130 cmpwi 0,r5,0
131 mtctr r5
132 subi r4,r4,4
133 blelr-
134 sync
13500: lwzu r5,4(r4)
136 stw r5,0(r3)
137 bdnz 00b
138 sync
139 blr
140
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 75429e580518..807193a3c784 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -95,13 +95,6 @@ EXPORT_SYMBOL(__strnlen_user);
95EXPORT_SYMBOL(copy_4K_page); 95EXPORT_SYMBOL(copy_4K_page);
96#endif 96#endif
97 97
98EXPORT_SYMBOL(_insb);
99EXPORT_SYMBOL(_outsb);
100EXPORT_SYMBOL(_insw_ns);
101EXPORT_SYMBOL(_outsw_ns);
102EXPORT_SYMBOL(_insl_ns);
103EXPORT_SYMBOL(_outsl_ns);
104
105#if defined(CONFIG_PPC32) && (defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)) 98#if defined(CONFIG_PPC32) && (defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE))
106EXPORT_SYMBOL(ppc_ide_md); 99EXPORT_SYMBOL(ppc_ide_md);
107#endif 100#endif
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 51a598747367..57e7d14d6563 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -143,12 +143,12 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
143#define readl_relaxed(addr) readl(addr) 143#define readl_relaxed(addr) readl(addr)
144#define readq_relaxed(addr) readq(addr) 144#define readq_relaxed(addr) readq(addr)
145 145
146extern void _insb(volatile u8 __iomem *port, void *buf, int ns); 146extern void _insb(volatile u8 __iomem *port, void *buf, long count);
147extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); 147extern void _outsb(volatile u8 __iomem *port, const void *buf, long count);
148extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns); 148extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count);
149extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns); 149extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count);
150extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl); 150extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count);
151extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl); 151extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
152 152
153static inline void mmiowb(void) 153static inline void mmiowb(void)
154{ 154{
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 9fac420f1648..3d9a9e6f3321 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -327,12 +327,12 @@ __do_out_asm(outl, "stwbrx")
327#define inl_p(port) inl((port)) 327#define inl_p(port) inl((port))
328#define outl_p(val, port) outl((val), (port)) 328#define outl_p(val, port) outl((val), (port))
329 329
330extern void _insb(volatile u8 __iomem *port, void *buf, int ns); 330extern void _insb(volatile u8 __iomem *port, void *buf, long count);
331extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); 331extern void _outsb(volatile u8 __iomem *port, const void *buf, long count);
332extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns); 332extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count);
333extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns); 333extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count);
334extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl); 334extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count);
335extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl); 335extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
336 336
337 337
338#define IO_SPACE_LIMIT ~0 338#define IO_SPACE_LIMIT ~0