aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm
diff options
context:
space:
mode:
authorBrian Gerst <brgerst@gmail.com>2010-02-05 09:37:09 -0500
committerH. Peter Anvin <hpa@zytor.com>2010-02-05 16:57:40 -0500
commit1c5b9069e12e20d2fe883076ae0bf73966492108 (patch)
treeb45f5db29d8c98c0a9123845971d58febd291949 /arch/x86/include/asm
parent910bf6ad0be3e1efbda0e9d358794937b52c9860 (diff)
x86: Merge io.h
io_32.h and io_64.h are now identical. Merge them into io.h. Signed-off-by: Brian Gerst <brgerst@gmail.com> LKML-Reference: <1265380629-3212-8-git-send-email-brgerst@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/include/asm')
-rw-r--r--arch/x86/include/asm/io.h155
-rw-r--r--arch/x86/include/asm/io_32.h161
-rw-r--r--arch/x86/include/asm/io_64.h161
3 files changed, 152 insertions, 325 deletions
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 73739322b6d0..a1dcfa3ab17d 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -1,8 +1,42 @@
1#ifndef _ASM_X86_IO_H 1#ifndef _ASM_X86_IO_H
2#define _ASM_X86_IO_H 2#define _ASM_X86_IO_H
3 3
4/*
5 * This file contains the definitions for the x86 IO instructions
6 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
7 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
8 * versions of the single-IO instructions (inb_p/inw_p/..).
9 *
10 * This file is not meant to be obfuscating: it's just complicated
11 * to (a) handle it all in a way that makes gcc able to optimize it
12 * as well as possible and (b) trying to avoid writing the same thing
13 * over and over again with slight variations and possibly making a
14 * mistake somewhere.
15 */
16
17/*
18 * Thanks to James van Artsdalen for a better timing-fix than
19 * the two short jumps: using outb's to a nonexistent port seems
20 * to guarantee better timings even on fast machines.
21 *
22 * On the other hand, I'd like to be sure of a non-existent port:
23 * I feel a bit unsafe about using 0x80 (should be safe, though)
24 *
25 * Linus
26 */
27
28 /*
29 * Bit simplified and optimized by Jan Hubicka
30 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
31 *
32 * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
33 * isa_read[wl] and isa_write[wl] fixed
34 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
35 */
36
4#define ARCH_HAS_IOREMAP_WC 37#define ARCH_HAS_IOREMAP_WC
5 38
39#include <linux/string.h>
6#include <linux/compiler.h> 40#include <linux/compiler.h>
7#include <asm-generic/int-ll64.h> 41#include <asm-generic/int-ll64.h>
8#include <asm/page.h> 42#include <asm/page.h>
@@ -173,11 +207,126 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
173extern void iounmap(volatile void __iomem *addr); 207extern void iounmap(volatile void __iomem *addr);
174 208
175 209
176#ifdef CONFIG_X86_32 210#ifdef __KERNEL__
177# include "io_32.h" 211
212#include <asm-generic/iomap.h>
213
214#include <linux/vmalloc.h>
215
216/*
217 * Convert a virtual cached pointer to an uncached pointer
218 */
219#define xlate_dev_kmem_ptr(p) p
220
221static inline void
222memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
223{
224 memset((void __force *)addr, val, count);
225}
226
227static inline void
228memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
229{
230 memcpy(dst, (const void __force *)src, count);
231}
232
233static inline void
234memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
235{
236 memcpy((void __force *)dst, src, count);
237}
238
239/*
240 * ISA space is 'always mapped' on a typical x86 system, no need to
241 * explicitly ioremap() it. The fact that the ISA IO space is mapped
242 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
243 * are physical addresses. The following constant pointer can be
244 * used as the IO-area pointer (it can be iounmapped as well, so the
245 * analogy with PCI is quite large):
246 */
247#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
248
249/*
250 * Cache management
251 *
252 * This needed for two cases
253 * 1. Out of order aware processors
254 * 2. Accidentally out of order processors (PPro errata #51)
255 */
256
257static inline void flush_write_buffers(void)
258{
259#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
260 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
261#endif
262}
263
264#endif /* __KERNEL__ */
265
266extern void native_io_delay(void);
267
268extern int io_delay_type;
269extern void io_delay_init(void);
270
271#if defined(CONFIG_PARAVIRT)
272#include <asm/paravirt.h>
178#else 273#else
179# include "io_64.h" 274
275static inline void slow_down_io(void)
276{
277 native_io_delay();
278#ifdef REALLY_SLOW_IO
279 native_io_delay();
280 native_io_delay();
281 native_io_delay();
180#endif 282#endif
283}
284
285#endif
286
287#define BUILDIO(bwl, bw, type) \
288static inline void out##bwl(unsigned type value, int port) \
289{ \
290 asm volatile("out" #bwl " %" #bw "0, %w1" \
291 : : "a"(value), "Nd"(port)); \
292} \
293 \
294static inline unsigned type in##bwl(int port) \
295{ \
296 unsigned type value; \
297 asm volatile("in" #bwl " %w1, %" #bw "0" \
298 : "=a"(value) : "Nd"(port)); \
299 return value; \
300} \
301 \
302static inline void out##bwl##_p(unsigned type value, int port) \
303{ \
304 out##bwl(value, port); \
305 slow_down_io(); \
306} \
307 \
308static inline unsigned type in##bwl##_p(int port) \
309{ \
310 unsigned type value = in##bwl(port); \
311 slow_down_io(); \
312 return value; \
313} \
314 \
315static inline void outs##bwl(int port, const void *addr, unsigned long count) \
316{ \
317 asm volatile("rep; outs" #bwl \
318 : "+S"(addr), "+c"(count) : "d"(port)); \
319} \
320 \
321static inline void ins##bwl(int port, void *addr, unsigned long count) \
322{ \
323 asm volatile("rep; ins" #bwl \
324 : "+D"(addr), "+c"(count) : "d"(port)); \
325}
326
327BUILDIO(b, b, char)
328BUILDIO(w, w, short)
329BUILDIO(l, , int)
181 330
182extern void *xlate_dev_mem_ptr(unsigned long phys); 331extern void *xlate_dev_mem_ptr(unsigned long phys);
183extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr); 332extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
diff --git a/arch/x86/include/asm/io_32.h b/arch/x86/include/asm/io_32.h
deleted file mode 100644
index e8177f3b87f6..000000000000
--- a/arch/x86/include/asm/io_32.h
+++ /dev/null
@@ -1,161 +0,0 @@
1#ifndef _ASM_X86_IO_32_H
2#define _ASM_X86_IO_32_H
3
4#include <linux/string.h>
5#include <linux/compiler.h>
6
7/*
8 * This file contains the definitions for the x86 IO instructions
9 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
10 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
11 * versions of the single-IO instructions (inb_p/inw_p/..).
12 *
13 * This file is not meant to be obfuscating: it's just complicated
14 * to (a) handle it all in a way that makes gcc able to optimize it
15 * as well as possible and (b) trying to avoid writing the same thing
16 * over and over again with slight variations and possibly making a
17 * mistake somewhere.
18 */
19
20/*
21 * Thanks to James van Artsdalen for a better timing-fix than
22 * the two short jumps: using outb's to a nonexistent port seems
23 * to guarantee better timings even on fast machines.
24 *
25 * On the other hand, I'd like to be sure of a non-existent port:
26 * I feel a bit unsafe about using 0x80 (should be safe, though)
27 *
28 * Linus
29 */
30
31 /*
32 * Bit simplified and optimized by Jan Hubicka
33 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
34 *
35 * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
36 * isa_read[wl] and isa_write[wl] fixed
37 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
38 */
39
40#ifdef __KERNEL__
41
42#include <asm-generic/iomap.h>
43
44#include <linux/vmalloc.h>
45
46/*
47 * Convert a virtual cached pointer to an uncached pointer
48 */
49#define xlate_dev_kmem_ptr(p) p
50
51static inline void
52memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
53{
54 memset((void __force *)addr, val, count);
55}
56
57static inline void
58memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
59{
60 memcpy(dst, (const void __force *)src, count);
61}
62
63static inline void
64memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
65{
66 memcpy((void __force *)dst, src, count);
67}
68
69/*
70 * ISA space is 'always mapped' on a typical x86 system, no need to
71 * explicitly ioremap() it. The fact that the ISA IO space is mapped
72 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
73 * are physical addresses. The following constant pointer can be
74 * used as the IO-area pointer (it can be iounmapped as well, so the
75 * analogy with PCI is quite large):
76 */
77#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
78
79/*
80 * Cache management
81 *
82 * This needed for two cases
83 * 1. Out of order aware processors
84 * 2. Accidentally out of order processors (PPro errata #51)
85 */
86
87static inline void flush_write_buffers(void)
88{
89#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
90 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
91#endif
92}
93
94#endif /* __KERNEL__ */
95
96extern void native_io_delay(void);
97
98extern int io_delay_type;
99extern void io_delay_init(void);
100
101#if defined(CONFIG_PARAVIRT)
102#include <asm/paravirt.h>
103#else
104
105static inline void slow_down_io(void)
106{
107 native_io_delay();
108#ifdef REALLY_SLOW_IO
109 native_io_delay();
110 native_io_delay();
111 native_io_delay();
112#endif
113}
114
115#endif
116
117#define BUILDIO(bwl, bw, type) \
118static inline void out##bwl(unsigned type value, int port) \
119{ \
120 asm volatile("out" #bwl " %" #bw "0, %w1" \
121 : : "a"(value), "Nd"(port)); \
122} \
123 \
124static inline unsigned type in##bwl(int port) \
125{ \
126 unsigned type value; \
127 asm volatile("in" #bwl " %w1, %" #bw "0" \
128 : "=a"(value) : "Nd"(port)); \
129 return value; \
130} \
131 \
132static inline void out##bwl##_p(unsigned type value, int port) \
133{ \
134 out##bwl(value, port); \
135 slow_down_io(); \
136} \
137 \
138static inline unsigned type in##bwl##_p(int port) \
139{ \
140 unsigned type value = in##bwl(port); \
141 slow_down_io(); \
142 return value; \
143} \
144 \
145static inline void outs##bwl(int port, const void *addr, unsigned long count) \
146{ \
147 asm volatile("rep; outs" #bwl \
148 : "+S"(addr), "+c"(count) : "d"(port)); \
149} \
150 \
151static inline void ins##bwl(int port, void *addr, unsigned long count) \
152{ \
153 asm volatile("rep; ins" #bwl \
154 : "+D"(addr), "+c"(count) : "d"(port)); \
155}
156
157BUILDIO(b, b, char)
158BUILDIO(w, w, short)
159BUILDIO(l, , int)
160
161#endif /* _ASM_X86_IO_32_H */
diff --git a/arch/x86/include/asm/io_64.h b/arch/x86/include/asm/io_64.h
deleted file mode 100644
index 6964a1c366d3..000000000000
--- a/arch/x86/include/asm/io_64.h
+++ /dev/null
@@ -1,161 +0,0 @@
1#ifndef _ASM_X86_IO_64_H
2#define _ASM_X86_IO_64_H
3
4#include <linux/string.h>
5#include <linux/compiler.h>
6
7/*
8 * This file contains the definitions for the x86 IO instructions
9 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
10 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
11 * versions of the single-IO instructions (inb_p/inw_p/..).
12 *
13 * This file is not meant to be obfuscating: it's just complicated
14 * to (a) handle it all in a way that makes gcc able to optimize it
15 * as well as possible and (b) trying to avoid writing the same thing
16 * over and over again with slight variations and possibly making a
17 * mistake somewhere.
18 */
19
20/*
21 * Thanks to James van Artsdalen for a better timing-fix than
22 * the two short jumps: using outb's to a nonexistent port seems
23 * to guarantee better timings even on fast machines.
24 *
25 * On the other hand, I'd like to be sure of a non-existent port:
26 * I feel a bit unsafe about using 0x80 (should be safe, though)
27 *
28 * Linus
29 */
30
31 /*
32 * Bit simplified and optimized by Jan Hubicka
33 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
34 *
35 * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
36 * isa_read[wl] and isa_write[wl] fixed
37 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
38 */
39
40#ifdef __KERNEL__
41
42#include <asm-generic/iomap.h>
43
44#include <linux/vmalloc.h>
45
46/*
47 * Convert a virtual cached pointer to an uncached pointer
48 */
49#define xlate_dev_kmem_ptr(p) p
50
51static inline void
52memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
53{
54 memset((void __force *)addr, val, count);
55}
56
57static inline void
58memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
59{
60 memcpy(dst, (const void __force *)src, count);
61}
62
63static inline void
64memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
65{
66 memcpy((void __force *)dst, src, count);
67}
68
69/*
70 * ISA space is 'always mapped' on a typical x86 system, no need to
71 * explicitly ioremap() it. The fact that the ISA IO space is mapped
72 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
73 * are physical addresses. The following constant pointer can be
74 * used as the IO-area pointer (it can be iounmapped as well, so the
75 * analogy with PCI is quite large):
76 */
77#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
78
79/*
80 * Cache management
81 *
82 * This needed for two cases
83 * 1. Out of order aware processors
84 * 2. Accidentally out of order processors (PPro errata #51)
85 */
86
87static inline void flush_write_buffers(void)
88{
89#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
90 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
91#endif
92}
93
94#endif /* __KERNEL__ */
95
96extern void native_io_delay(void);
97
98extern int io_delay_type;
99extern void io_delay_init(void);
100
101#if defined(CONFIG_PARAVIRT)
102#include <asm/paravirt.h>
103#else
104
105static inline void slow_down_io(void)
106{
107 native_io_delay();
108#ifdef REALLY_SLOW_IO
109 native_io_delay();
110 native_io_delay();
111 native_io_delay();
112#endif
113}
114
115#endif
116
117#define BUILDIO(bwl, bw, type) \
118static inline void out##bwl(unsigned type value, int port) \
119{ \
120 asm volatile("out" #bwl " %" #bw "0, %w1" \
121 : : "a"(value), "Nd"(port)); \
122} \
123 \
124static inline unsigned type in##bwl(int port) \
125{ \
126 unsigned type value; \
127 asm volatile("in" #bwl " %w1, %" #bw "0" \
128 : "=a"(value) : "Nd"(port)); \
129 return value; \
130} \
131 \
132static inline void out##bwl##_p(unsigned type value, int port) \
133{ \
134 out##bwl(value, port); \
135 slow_down_io(); \
136} \
137 \
138static inline unsigned type in##bwl##_p(int port) \
139{ \
140 unsigned type value = in##bwl(port); \
141 slow_down_io(); \
142 return value; \
143} \
144 \
145static inline void outs##bwl(int port, const void *addr, unsigned long count) \
146{ \
147 asm volatile("rep; outs" #bwl \
148 : "+S"(addr), "+c"(count) : "d"(port)); \
149} \
150 \
151static inline void ins##bwl(int port, void *addr, unsigned long count) \
152{ \
153 asm volatile("rep; ins" #bwl \
154 : "+D"(addr), "+c"(count) : "d"(port)); \
155}
156
157BUILDIO(b, b, char)
158BUILDIO(w, w, short)
159BUILDIO(l, , int)
160
161#endif /* _ASM_X86_IO_64_H */