]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/x86/include/asm/io_64.h
x86-64: Use BUILDIO in io_64.h
[net-next-2.6.git] / arch / x86 / include / asm / io_64.h
1 #ifndef _ASM_X86_IO_64_H
2 #define _ASM_X86_IO_64_H
3
4
5 /*
6  * This file contains the definitions for the x86 IO instructions
7  * inb/inw/inl/outb/outw/outl and the "string versions" of the same
8  * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
9  * versions of the single-IO instructions (inb_p/inw_p/..).
10  *
11  * This file is not meant to be obfuscating: it's just complicated
12  * to (a) handle it all in a way that makes gcc able to optimize it
13  * as well as possible and (b) trying to avoid writing the same thing
14  * over and over again with slight variations and possibly making a
15  * mistake somewhere.
16  */
17
18 /*
19  * Thanks to James van Artsdalen for a better timing-fix than
20  * the two short jumps: using outb's to a nonexistent port seems
21  * to guarantee better timings even on fast machines.
22  *
23  * On the other hand, I'd like to be sure of a non-existent port:
24  * I feel a bit unsafe about using 0x80 (should be safe, though)
25  *
26  *              Linus
27  */
28
29  /*
30   *  Bit simplified and optimized by Jan Hubicka
31   *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
32   *
33   *  isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
34   *  isa_read[wl] and isa_write[wl] fixed
35   *  - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
36   */
37
38 #ifdef __KERNEL__
39
40 #include <asm-generic/iomap.h>
41
42 #include <linux/vmalloc.h>
43
44 /*
45  * Convert a virtual cached pointer to an uncached pointer
46  */
47 #define xlate_dev_kmem_ptr(p)   p
48
49 void memset_io(volatile void __iomem *a, int b, size_t c);
50
51 void __memcpy_fromio(void *, unsigned long, unsigned);
52 static inline void memcpy_fromio(void *to, const volatile void __iomem *from,
53                                  unsigned len)
54 {
55         __memcpy_fromio(to, (unsigned long)from, len);
56 }
57
58 void __memcpy_toio(unsigned long, const void *, unsigned);
59 static inline void memcpy_toio(volatile void __iomem *to, const void *from,
60                                unsigned len)
61 {
62         __memcpy_toio((unsigned long)to, from, len);
63 }
64
65 /*
66  * ISA space is 'always mapped' on a typical x86 system, no need to
67  * explicitly ioremap() it. The fact that the ISA IO space is mapped
68  * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
69  * are physical addresses. The following constant pointer can be
70  * used as the IO-area pointer (it can be iounmapped as well, so the
71  * analogy with PCI is quite large):
72  */
73 #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
74
75 /*
76  *      Cache management
77  *
78  *      This needed for two cases
79  *      1. Out of order aware processors
80  *      2. Accidentally out of order processors (PPro errata #51)
81  */
82 #define flush_write_buffers() do { } while (0)
83
84 #endif /* __KERNEL__ */
85
86 extern void native_io_delay(void);
87
88 extern int io_delay_type;
89 extern void io_delay_init(void);
90
91 #if defined(CONFIG_PARAVIRT)
92 #include <asm/paravirt.h>
93 #else
94
95 static inline void slow_down_io(void)
96 {
97         native_io_delay();
98 #ifdef REALLY_SLOW_IO
99         native_io_delay();
100         native_io_delay();
101         native_io_delay();
102 #endif
103 }
104
105 #endif
106
107 #define BUILDIO(bwl, bw, type)                                          \
108 static inline void out##bwl(unsigned type value, int port)              \
109 {                                                                       \
110         asm volatile("out" #bwl " %" #bw "0, %w1"                       \
111                      : : "a"(value), "Nd"(port));                       \
112 }                                                                       \
113                                                                         \
114 static inline unsigned type in##bwl(int port)                           \
115 {                                                                       \
116         unsigned type value;                                            \
117         asm volatile("in" #bwl " %w1, %" #bw "0"                        \
118                      : "=a"(value) : "Nd"(port));                       \
119         return value;                                                   \
120 }                                                                       \
121                                                                         \
122 static inline void out##bwl##_p(unsigned type value, int port)          \
123 {                                                                       \
124         out##bwl(value, port);                                          \
125         slow_down_io();                                                 \
126 }                                                                       \
127                                                                         \
128 static inline unsigned type in##bwl##_p(int port)                       \
129 {                                                                       \
130         unsigned type value = in##bwl(port);                            \
131         slow_down_io();                                                 \
132         return value;                                                   \
133 }                                                                       \
134                                                                         \
135 static inline void outs##bwl(int port, const void *addr, unsigned long count) \
136 {                                                                       \
137         asm volatile("rep; outs" #bwl                                   \
138                      : "+S"(addr), "+c"(count) : "d"(port));            \
139 }                                                                       \
140                                                                         \
141 static inline void ins##bwl(int port, void *addr, unsigned long count)  \
142 {                                                                       \
143         asm volatile("rep; ins" #bwl                                    \
144                      : "+D"(addr), "+c"(count) : "d"(port));            \
145 }
146
147 BUILDIO(b, b, char)
148 BUILDIO(w, w, short)
149 BUILDIO(l, , int)
150
151 #endif /* _ASM_X86_IO_64_H */