diff options
Diffstat (limited to 'include/asm-x86/io_64.h')
-rw-r--r-- | include/asm-x86/io_64.h | 110 |
1 files changed, 68 insertions, 42 deletions
diff --git a/include/asm-x86/io_64.h b/include/asm-x86/io_64.h index db0be2011a3c..c2f5eef47b88 100644 --- a/include/asm-x86/io_64.h +++ b/include/asm-x86/io_64.h | |||
@@ -58,60 +58,75 @@ static inline void slow_down_io(void) | |||
58 | /* | 58 | /* |
59 | * Talk about misusing macros.. | 59 | * Talk about misusing macros.. |
60 | */ | 60 | */ |
61 | #define __OUT1(s,x) \ | 61 | #define __OUT1(s, x) \ |
62 | static inline void out##s(unsigned x value, unsigned short port) { | 62 | static inline void out##s(unsigned x value, unsigned short port) { |
63 | 63 | ||
64 | #define __OUT2(s,s1,s2) \ | 64 | #define __OUT2(s, s1, s2) \ |
65 | __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" | 65 | asm volatile ("out" #s " %" s1 "0,%" s2 "1" |
66 | 66 | ||
67 | #ifndef REALLY_SLOW_IO | 67 | #ifndef REALLY_SLOW_IO |
68 | #define REALLY_SLOW_IO | 68 | #define REALLY_SLOW_IO |
69 | #define UNSET_REALLY_SLOW_IO | 69 | #define UNSET_REALLY_SLOW_IO |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #define __OUT(s,s1,x) \ | 72 | #define __OUT(s, s1, x) \ |
73 | __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \ | 73 | __OUT1(s, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ |
74 | __OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ | 74 | } \ |
75 | slow_down_io(); } | 75 | __OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ |
76 | slow_down_io(); \ | ||
77 | } | ||
76 | 78 | ||
77 | #define __IN1(s) \ | 79 | #define __IN1(s) \ |
78 | static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v; | 80 | static inline RETURN_TYPE in##s(unsigned short port) \ |
81 | { \ | ||
82 | RETURN_TYPE _v; | ||
79 | 83 | ||
80 | #define __IN2(s,s1,s2) \ | 84 | #define __IN2(s, s1, s2) \ |
81 | __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" | 85 | asm volatile ("in" #s " %" s2 "1,%" s1 "0" |
82 | 86 | ||
83 | #define __IN(s,s1,i...) \ | 87 | #define __IN(s, s1, i...) \ |
84 | __IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); return _v; } \ | 88 | __IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \ |
85 | __IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \ | 89 | return _v; \ |
86 | slow_down_io(); return _v; } | 90 | } \ |
91 | __IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \ | ||
92 | slow_down_io(); \ | ||
93 | return _v; } | ||
87 | 94 | ||
88 | #ifdef UNSET_REALLY_SLOW_IO | 95 | #ifdef UNSET_REALLY_SLOW_IO |
89 | #undef REALLY_SLOW_IO | 96 | #undef REALLY_SLOW_IO |
90 | #endif | 97 | #endif |
91 | 98 | ||
92 | #define __INS(s) \ | 99 | #define __INS(s) \ |
93 | static inline void ins##s(unsigned short port, void * addr, unsigned long count) \ | 100 | static inline void ins##s(unsigned short port, void *addr, \ |
94 | { __asm__ __volatile__ ("rep ; ins" #s \ | 101 | unsigned long count) \ |
95 | : "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } | 102 | { \ |
103 | asm volatile ("rep ; ins" #s \ | ||
104 | : "=D" (addr), "=c" (count) \ | ||
105 | : "d" (port), "0" (addr), "1" (count)); \ | ||
106 | } | ||
96 | 107 | ||
97 | #define __OUTS(s) \ | 108 | #define __OUTS(s) \ |
98 | static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ | 109 | static inline void outs##s(unsigned short port, const void *addr, \ |
99 | { __asm__ __volatile__ ("rep ; outs" #s \ | 110 | unsigned long count) \ |
100 | : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } | 111 | { \ |
112 | asm volatile ("rep ; outs" #s \ | ||
113 | : "=S" (addr), "=c" (count) \ | ||
114 | : "d" (port), "0" (addr), "1" (count)); \ | ||
115 | } | ||
101 | 116 | ||
102 | #define RETURN_TYPE unsigned char | 117 | #define RETURN_TYPE unsigned char |
103 | __IN(b,"") | 118 | __IN(b, "") |
104 | #undef RETURN_TYPE | 119 | #undef RETURN_TYPE |
105 | #define RETURN_TYPE unsigned short | 120 | #define RETURN_TYPE unsigned short |
106 | __IN(w,"") | 121 | __IN(w, "") |
107 | #undef RETURN_TYPE | 122 | #undef RETURN_TYPE |
108 | #define RETURN_TYPE unsigned int | 123 | #define RETURN_TYPE unsigned int |
109 | __IN(l,"") | 124 | __IN(l, "") |
110 | #undef RETURN_TYPE | 125 | #undef RETURN_TYPE |
111 | 126 | ||
112 | __OUT(b,"b",char) | 127 | __OUT(b, "b", char) |
113 | __OUT(w,"w",short) | 128 | __OUT(w, "w", short) |
114 | __OUT(l,,int) | 129 | __OUT(l, , int) |
115 | 130 | ||
116 | __INS(b) | 131 | __INS(b) |
117 | __INS(w) | 132 | __INS(w) |
@@ -132,12 +147,12 @@ __OUTS(l) | |||
132 | * Change virtual addresses to physical addresses and vv. | 147 | * Change virtual addresses to physical addresses and vv. |
133 | * These are pretty trivial | 148 | * These are pretty trivial |
134 | */ | 149 | */ |
135 | static inline unsigned long virt_to_phys(volatile void * address) | 150 | static inline unsigned long virt_to_phys(volatile void *address) |
136 | { | 151 | { |
137 | return __pa(address); | 152 | return __pa(address); |
138 | } | 153 | } |
139 | 154 | ||
140 | static inline void * phys_to_virt(unsigned long address) | 155 | static inline void *phys_to_virt(unsigned long address) |
141 | { | 156 | { |
142 | return __va(address); | 157 | return __va(address); |
143 | } | 158 | } |
@@ -200,18 +215,22 @@ static inline __u8 __readb(const volatile void __iomem *addr) | |||
200 | { | 215 | { |
201 | return *(__force volatile __u8 *)addr; | 216 | return *(__force volatile __u8 *)addr; |
202 | } | 217 | } |
218 | |||
203 | static inline __u16 __readw(const volatile void __iomem *addr) | 219 | static inline __u16 __readw(const volatile void __iomem *addr) |
204 | { | 220 | { |
205 | return *(__force volatile __u16 *)addr; | 221 | return *(__force volatile __u16 *)addr; |
206 | } | 222 | } |
223 | |||
207 | static __always_inline __u32 __readl(const volatile void __iomem *addr) | 224 | static __always_inline __u32 __readl(const volatile void __iomem *addr) |
208 | { | 225 | { |
209 | return *(__force volatile __u32 *)addr; | 226 | return *(__force volatile __u32 *)addr; |
210 | } | 227 | } |
228 | |||
211 | static inline __u64 __readq(const volatile void __iomem *addr) | 229 | static inline __u64 __readq(const volatile void __iomem *addr) |
212 | { | 230 | { |
213 | return *(__force volatile __u64 *)addr; | 231 | return *(__force volatile __u64 *)addr; |
214 | } | 232 | } |
233 | |||
215 | #define readb(x) __readb(x) | 234 | #define readb(x) __readb(x) |
216 | #define readw(x) __readw(x) | 235 | #define readw(x) __readw(x) |
217 | #define readl(x) __readl(x) | 236 | #define readl(x) __readl(x) |
@@ -231,37 +250,44 @@ static inline void __writel(__u32 b, volatile void __iomem *addr) | |||
231 | { | 250 | { |
232 | *(__force volatile __u32 *)addr = b; | 251 | *(__force volatile __u32 *)addr = b; |
233 | } | 252 | } |
253 | |||
234 | static inline void __writeq(__u64 b, volatile void __iomem *addr) | 254 | static inline void __writeq(__u64 b, volatile void __iomem *addr) |
235 | { | 255 | { |
236 | *(__force volatile __u64 *)addr = b; | 256 | *(__force volatile __u64 *)addr = b; |
237 | } | 257 | } |
258 | |||
238 | static inline void __writeb(__u8 b, volatile void __iomem *addr) | 259 | static inline void __writeb(__u8 b, volatile void __iomem *addr) |
239 | { | 260 | { |
240 | *(__force volatile __u8 *)addr = b; | 261 | *(__force volatile __u8 *)addr = b; |
241 | } | 262 | } |
263 | |||
242 | static inline void __writew(__u16 b, volatile void __iomem *addr) | 264 | static inline void __writew(__u16 b, volatile void __iomem *addr) |
243 | { | 265 | { |
244 | *(__force volatile __u16 *)addr = b; | 266 | *(__force volatile __u16 *)addr = b; |
245 | } | 267 | } |
246 | #define writeq(val,addr) __writeq((val),(addr)) | 268 | |
247 | #define writel(val,addr) __writel((val),(addr)) | 269 | #define writeq(val, addr) __writeq((val), (addr)) |
248 | #define writew(val,addr) __writew((val),(addr)) | 270 | #define writel(val, addr) __writel((val), (addr)) |
249 | #define writeb(val,addr) __writeb((val),(addr)) | 271 | #define writew(val, addr) __writew((val), (addr)) |
272 | #define writeb(val, addr) __writeb((val), (addr)) | ||
250 | #define __raw_writeb writeb | 273 | #define __raw_writeb writeb |
251 | #define __raw_writew writew | 274 | #define __raw_writew writew |
252 | #define __raw_writel writel | 275 | #define __raw_writel writel |
253 | #define __raw_writeq writeq | 276 | #define __raw_writeq writeq |
254 | 277 | ||
255 | void __memcpy_fromio(void*,unsigned long,unsigned); | 278 | void __memcpy_fromio(void *, unsigned long, unsigned); |
256 | void __memcpy_toio(unsigned long,const void*,unsigned); | 279 | void __memcpy_toio(unsigned long, const void *, unsigned); |
257 | 280 | ||
258 | static inline void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned len) | 281 | static inline void memcpy_fromio(void *to, const volatile void __iomem *from, |
282 | unsigned len) | ||
259 | { | 283 | { |
260 | __memcpy_fromio(to,(unsigned long)from,len); | 284 | __memcpy_fromio(to, (unsigned long)from, len); |
261 | } | 285 | } |
262 | static inline void memcpy_toio(volatile void __iomem *to, const void *from, unsigned len) | 286 | |
287 | static inline void memcpy_toio(volatile void __iomem *to, const void *from, | ||
288 | unsigned len) | ||
263 | { | 289 | { |
264 | __memcpy_toio((unsigned long)to,from,len); | 290 | __memcpy_toio((unsigned long)to, from, len); |
265 | } | 291 | } |
266 | 292 | ||
267 | void memset_io(volatile void __iomem *a, int b, size_t c); | 293 | void memset_io(volatile void __iomem *a, int b, size_t c); |
@@ -276,7 +302,7 @@ void memset_io(volatile void __iomem *a, int b, size_t c); | |||
276 | */ | 302 | */ |
277 | #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) | 303 | #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) |
278 | 304 | ||
279 | #define flush_write_buffers() | 305 | #define flush_write_buffers() |
280 | 306 | ||
281 | extern int iommu_bio_merge; | 307 | extern int iommu_bio_merge; |
282 | #define BIO_VMERGE_BOUNDARY iommu_bio_merge | 308 | #define BIO_VMERGE_BOUNDARY iommu_bio_merge |