1 /*
2 * linux/arch/sh/kernel/io.c
3 *
4 * Copyright (C) 2000 Stuart Menefy
5 *
6 * Provide real functions which expand to whatever the header file defined.
7 * Also definitions of machine independant IO functions.
8 */
9
10 #include <asm/io.h>
11 #include <linux/module.h>
12
_inb(unsigned long port)13 unsigned char _inb(unsigned long port)
14 {
15 return __inb(port);
16 }
17 EXPORT_SYMBOL(_inb);
18
_inw(unsigned long port)19 unsigned short _inw(unsigned long port)
20 {
21 return __inw(port);
22 }
23 EXPORT_SYMBOL(_inw);
24
_inl(unsigned long port)25 unsigned int _inl(unsigned long port)
26 {
27 return __inl(port);
28 }
29 EXPORT_SYMBOL(_inl);
30
_outb(unsigned char b,unsigned long port)31 void _outb(unsigned char b, unsigned long port)
32 {
33 __outb(b, port);
34 }
35 EXPORT_SYMBOL(_outb);
36
_outw(unsigned short b,unsigned long port)37 void _outw(unsigned short b, unsigned long port)
38 {
39 __outw(b, port);
40 }
41 EXPORT_SYMBOL(_outw);
42
43
_outl(unsigned int b,unsigned long port)44 void _outl(unsigned int b, unsigned long port)
45 {
46 __outl(b, port);
47 }
48 EXPORT_SYMBOL(_outl);
49
50
_inb_p(unsigned long port)51 unsigned char _inb_p(unsigned long port)
52 {
53 return __inb_p(port);
54 }
55 EXPORT_SYMBOL(_inb_p);
56
_inw_p(unsigned long port)57 unsigned short _inw_p(unsigned long port)
58 {
59 return __inw_p(port);
60 }
61 EXPORT_SYMBOL(_inw_p);
62
63
_outb_p(unsigned char b,unsigned long port)64 void _outb_p(unsigned char b, unsigned long port)
65 {
66 __outb_p(b, port);
67 }
68 EXPORT_SYMBOL(_outb_p);
69
_outw_p(unsigned short b,unsigned long port)70 void _outw_p(unsigned short b, unsigned long port)
71 {
72 __outw_p(b, port);
73 }
74 EXPORT_SYMBOL(_outw_p);
75
_insb(unsigned long port,void * buffer,unsigned long count)76 void _insb(unsigned long port, void *buffer, unsigned long count)
77 {
78 return __insb(port, buffer, count);
79 }
80 EXPORT_SYMBOL(_insb);
81
_insw(unsigned long port,void * buffer,unsigned long count)82 void _insw(unsigned long port, void *buffer, unsigned long count)
83 {
84 __insw(port, buffer, count);
85 }
86 EXPORT_SYMBOL(_insw);
87
_insl(unsigned long port,void * buffer,unsigned long count)88 void _insl(unsigned long port, void *buffer, unsigned long count)
89 {
90 __insl(port, buffer, count);
91 }
92 EXPORT_SYMBOL(_insl);
93
_outsb(unsigned long port,const void * buffer,unsigned long count)94 void _outsb(unsigned long port, const void *buffer, unsigned long count)
95 {
96 __outsb(port, buffer, count);
97 }
98 EXPORT_SYMBOL(_outsb);
99
_outsw(unsigned long port,const void * buffer,unsigned long count)100 void _outsw(unsigned long port, const void *buffer, unsigned long count)
101 {
102 __outsw(port, buffer, count);
103 }
104 EXPORT_SYMBOL(_outsw);
105
_outsl(unsigned long port,const void * buffer,unsigned long count)106 void _outsl(unsigned long port, const void *buffer, unsigned long count)
107 {
108 __outsl(port, buffer, count);
109
110 }
111 EXPORT_SYMBOL(_outsl);
112
___raw_readb(unsigned long addr)113 unsigned char ___raw_readb(unsigned long addr)
114 {
115 return __readb(addr);
116 }
117 EXPORT_SYMBOL(___raw_readb);
118
___raw_readw(unsigned long addr)119 unsigned short ___raw_readw(unsigned long addr)
120 {
121 return __readw(addr);
122 }
123 EXPORT_SYMBOL(___raw_readw);
124
___raw_readl(unsigned long addr)125 unsigned int ___raw_readl(unsigned long addr)
126 {
127 return __readl(addr);
128 }
129 EXPORT_SYMBOL(___raw_readl);
130
_readb(unsigned long addr)131 unsigned char _readb(unsigned long addr)
132 {
133 unsigned long r = __readb(addr);
134 mb();
135 return r;
136 }
137 EXPORT_SYMBOL(_readb);
138
_readw(unsigned long addr)139 unsigned short _readw(unsigned long addr)
140 {
141 unsigned long r = __readw(addr);
142 mb();
143 return r;
144 }
145 EXPORT_SYMBOL(_readw);
146
_readl(unsigned long addr)147 unsigned int _readl(unsigned long addr)
148 {
149 unsigned long r = __readl(addr);
150 mb();
151 return r;
152 }
153 EXPORT_SYMBOL(_readl);
154
___raw_writeb(unsigned char b,unsigned long addr)155 void ___raw_writeb(unsigned char b, unsigned long addr)
156 {
157 __writeb(b, addr);
158 }
159
___raw_writew(unsigned short b,unsigned long addr)160 void ___raw_writew(unsigned short b, unsigned long addr)
161 {
162 __writew(b, addr);
163 }
164 EXPORT_SYMBOL(___raw_writew);
165
___raw_writel(unsigned int b,unsigned long addr)166 void ___raw_writel(unsigned int b, unsigned long addr)
167 {
168 __writel(b, addr);
169 }
170 EXPORT_SYMBOL(___raw_writel);
171
_writeb(unsigned char b,unsigned long addr)172 void _writeb(unsigned char b, unsigned long addr)
173 {
174 __writeb(b, addr);
175 mb();
176 }
177 EXPORT_SYMBOL(_writeb);
178
_writew(unsigned short b,unsigned long addr)179 void _writew(unsigned short b, unsigned long addr)
180 {
181 __writew(b, addr);
182 mb();
183 }
184 EXPORT_SYMBOL(_writew);
185
_writel(unsigned int b,unsigned long addr)186 void _writel(unsigned int b, unsigned long addr)
187 {
188 __writel(b, addr);
189 mb();
190 }
191 EXPORT_SYMBOL(_writel);
192
193 /*
194 * Copy data from IO memory space to "real" memory space.
195 * This needs to be optimized.
196 */
memcpy_fromio(void * to,unsigned long from,unsigned long count)197 void memcpy_fromio(void * to, unsigned long from, unsigned long count)
198 {
199 while (count) {
200 count--;
201 *(char *) to = readb(from);
202 ((char *) to)++;
203 from++;
204 }
205 }
206
207 /*
208 * Copy data from "real" memory space to IO memory space.
209 * This needs to be optimized.
210 */
memcpy_toio(unsigned long to,const void * from,unsigned long count)211 void memcpy_toio(unsigned long to, const void * from, unsigned long count)
212 {
213 while (count) {
214 count--;
215 writeb(*(char *) from, to);
216 ((char *) from)++;
217 to++;
218 }
219 }
220
221 /*
222 * "memset" on IO memory space.
223 * This needs to be optimized.
224 */
memset_io(unsigned long dst,int c,unsigned long count)225 void memset_io(unsigned long dst, int c, unsigned long count)
226 {
227 while (count) {
228 count--;
229 writeb(c, dst);
230 dst++;
231 }
232 }
233