This source file includes following definitions.
- __bus_inb
- __bus_outb
- inb
- inw
- inl
- outb
- outw
- outl
- readb
- readw
- readl
- writeb
- writew
- writel
- insb
- insw
- insl
- outsb
- outsw
- outsl
- memcpy_fromio
- memcpy_toio
- memset_io
1
2
3
4
5 #include <linux/kernel.h>
6
7 #include <asm/io.h>
8
9
10
11
12
13 #ifdef __is_local
14 #undef __bus_inb
15 unsigned int __bus_inb(unsigned long addr)
16 {
17 return ___bus_inb(addr);
18 }
19
20 #undef __bus_outb
21 void __bus_outb(unsigned char b, unsigned long addr)
22 {
23 ___bus_outb(b, addr);
24 }
25 #endif
26
27 #undef inb
28 unsigned int inb(unsigned long addr)
29 {
30 return __inb(addr);
31 }
32
33 #undef inw
34 unsigned int inw(unsigned long addr)
35 {
36 return __inw(addr);
37 }
38
39 #undef inl
40 unsigned int inl(unsigned long addr)
41 {
42 return __inl(addr);
43 }
44
45
46 #undef outb
47 void outb(unsigned char b, unsigned long addr)
48 {
49 __outb(b, addr);
50 }
51
52 #undef outw
53 void outw(unsigned short b, unsigned long addr)
54 {
55 __outw(b, addr);
56 }
57
58 #undef outl
59 void outl(unsigned int b, unsigned long addr)
60 {
61 __outl(b, addr);
62 }
63
64
65 #undef readb
66 unsigned long readb(unsigned long addr)
67 {
68 return __readb(addr);
69 }
70
71 #undef readw
72 unsigned long readw(unsigned long addr)
73 {
74 return __readw(addr);
75 }
76
77 #undef readl
78 unsigned long readl(unsigned long addr)
79 {
80 return __readl(addr);
81 }
82
83
84 #undef writeb
85 void writeb(unsigned char b, unsigned long addr)
86 {
87 __writeb(b, addr);
88 }
89
90 #undef writew
91 void writew(unsigned short b, unsigned long addr)
92 {
93 __writew(b, addr);
94 }
95
96 #undef writel
97 void writel(unsigned int b, unsigned long addr)
98 {
99 __writel(b, addr);
100 }
101
102
103
104
105
106 #undef insb
107 void insb (unsigned long port, void *dst, unsigned long count)
108 {
109 while (((unsigned long)dst) & 0x3) {
110 if (!count)
111 return;
112 count--;
113 *(unsigned char *) dst = inb(port);
114 ((unsigned char *) dst)++;
115 }
116
117 while (count >= 4) {
118 unsigned int w;
119 count -= 4;
120 w = inb(port);
121 w |= inb(port) << 8;
122 w |= inb(port) << 16;
123 w |= inb(port) << 24;
124 *(unsigned int *) dst = w;
125 ((unsigned int *) dst)++;
126 }
127
128 while (count) {
129 --count;
130 *(unsigned char *) dst = inb(port);
131 ((unsigned char *) dst)++;
132 }
133 }
134
135
136
137
138
139
140
141
142
143 #undef insw
144 void insw (unsigned long port, void *dst, unsigned long count)
145 {
146 if (((unsigned long)dst) & 0x3) {
147 if (((unsigned long)dst) & 0x1) {
148 panic("insw: memory not short aligned");
149 }
150 if (!count)
151 return;
152 count--;
153 *(unsigned short* ) dst = inw(port);
154 ((unsigned short *) dst)++;
155 }
156
157 while (count >= 2) {
158 unsigned int w;
159 count -= 2;
160 w = inw(port);
161 w |= inw(port) << 16;
162 *(unsigned int *) dst = w;
163 ((unsigned int *) dst)++;
164 }
165
166 if (count) {
167 *(unsigned short*) dst = inw(port);
168 }
169 }
170
171
172
173
174
175
176
177
178
179 #undef insl
180 void insl (unsigned long port, void *dst, unsigned long count)
181 {
182 if (((unsigned long)dst) & 0x3) {
183 panic("insl: memory not aligned");
184 }
185
186 while (count) {
187 --count;
188 *(unsigned int *) dst = inl(port);
189 ((unsigned int *) dst)++;
190 }
191 }
192
193
194
195
196
197
198
199 #undef outsb
200 void outsb(unsigned long port, void * src, unsigned long count)
201 {
202 while (count) {
203 count--;
204 outb(*(char *)src, port);
205 ((char *) src)++;
206 }
207 }
208
209
210
211
212
213
214
215 #undef outsw
216 void outsw (unsigned long port, void *src, unsigned long count)
217 {
218 if (((unsigned long)src) & 0x3) {
219 if (((unsigned long)src) & 0x1) {
220 panic("outsw: memory not short aligned");
221 }
222 outw(*(unsigned short*)src, port);
223 ((unsigned short *) src)++;
224 --count;
225 }
226
227 while (count >= 2) {
228 unsigned int w;
229 count -= 2;
230 w = *(unsigned int *) src;
231 ((unsigned int *) src)++;
232 outw(w >> 0, port);
233 outw(w >> 16, port);
234 }
235
236 if (count) {
237 outw(*(unsigned short *) src, port);
238 }
239 }
240
241
242
243
244
245
246
247
248 #undef outsw
249 void outsl (unsigned long port, void *src, unsigned long count)
250 {
251 if (((unsigned long)src) & 0x3) {
252 panic("outsw: memory not aligned");
253 }
254
255 while (count) {
256 --count;
257 outl(*(unsigned int *) src, port);
258 ((unsigned int *) src)++;
259 }
260 }
261
262
263
264
265
266
267 #undef memcpy_fromio
268 void memcpy_fromio(void * to, unsigned long from, unsigned long count)
269 {
270 while (count) {
271 count--;
272 *(char *) to = readb(from);
273 ((char *) to)++;
274 from++;
275 }
276 }
277
278
279
280
281
282 #undef memcpy_toio
283 void memcpy_toio(unsigned long to, void * from, unsigned long count)
284 {
285 while (count) {
286 count--;
287 writeb(*(char *) from, to);
288 ((char *) from)++;
289 to++;
290 }
291 }
292
293
294
295
296
297 #undef memset_io
298 void memset_io(unsigned long dst, int c, unsigned long count)
299 {
300 while (count) {
301 count--;
302 writeb(c, dst);
303 dst++;
304 }
305 }