aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/io.c
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 /arch/powerpc/kernel/io.c
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>
Diffstat (limited to 'arch/powerpc/kernel/io.c')
-rw-r--r--arch/powerpc/kernel/io.c117
1 files changed, 117 insertions, 0 deletions
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);