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