aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/io_64.h112
1 files changed, 37 insertions, 75 deletions
diff --git a/arch/x86/include/asm/io_64.h b/arch/x86/include/asm/io_64.h
index 040bf74d717d..4a94aef5acf1 100644
--- a/arch/x86/include/asm/io_64.h
+++ b/arch/x86/include/asm/io_64.h
@@ -104,86 +104,48 @@ static inline void slow_down_io(void)
104 104
105#endif 105#endif
106 106
107/* 107#define BUILDIO(bwl, bw, type) \
108 * Talk about misusing macros.. 108static inline void out##bwl(unsigned type value, int port) \
109 */ 109{ \
110#define __OUT1(s, x) \ 110 asm volatile("out" #bwl " %" #bw "0, %w1" \
111static inline void out##s(unsigned x value, unsigned short port) { 111 : : "a"(value), "Nd"(port)); \
112 112} \
113#define __OUT2(s, s1, s2) \ 113 \
114asm volatile ("out" #s " %" s1 "0,%" s2 "1" 114static inline unsigned type in##bwl(int port) \
115 115{ \
116#ifndef REALLY_SLOW_IO 116 unsigned type value; \
117#define REALLY_SLOW_IO 117 asm volatile("in" #bwl " %w1, %" #bw "0" \
118#define UNSET_REALLY_SLOW_IO 118 : "=a"(value) : "Nd"(port)); \
119#endif 119 return value; \
120 120} \
121#define __OUT(s, s1, x) \ 121 \
122 __OUT1(s, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ 122static inline void out##bwl##_p(unsigned type value, int port) \
123 } \ 123{ \
124 __OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ 124 out##bwl(value, port); \
125 slow_down_io(); \ 125 slow_down_io(); \
126} 126} \
127 127 \
128#define __IN1(s) \ 128static inline unsigned type in##bwl##_p(int port) \
129static inline RETURN_TYPE in##s(unsigned short port) \
130{ \ 129{ \
131 RETURN_TYPE _v; 130 unsigned type value = in##bwl(port); \
132 131 slow_down_io(); \
133#define __IN2(s, s1, s2) \ 132 return value; \
134 asm volatile ("in" #s " %" s2 "1,%" s1 "0" 133} \
135 134 \
136#define __IN(s, s1, i...) \ 135static inline void outs##bwl(int port, const void *addr, unsigned long count) \
137 __IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
138 return _v; \
139 } \
140 __IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
141 slow_down_io(); \
142 return _v; }
143
144#ifdef UNSET_REALLY_SLOW_IO
145#undef REALLY_SLOW_IO
146#endif
147
148#define __INS(s) \
149static inline void ins##s(unsigned short port, void *addr, \
150 unsigned long count) \
151{ \ 136{ \
152 asm volatile ("rep ; ins" #s \ 137 asm volatile("rep; outs" #bwl \
153 : "=D" (addr), "=c" (count) \ 138 : "+S"(addr), "+c"(count) : "d"(port)); \
154 : "d" (port), "0" (addr), "1" (count)); \ 139} \
155} 140 \
156 141static inline void ins##bwl(int port, void *addr, unsigned long count) \
157#define __OUTS(s) \
158static inline void outs##s(unsigned short port, const void *addr, \
159 unsigned long count) \
160{ \ 142{ \
161 asm volatile ("rep ; outs" #s \ 143 asm volatile("rep; ins" #bwl \
162 : "=S" (addr), "=c" (count) \ 144 : "+D"(addr), "+c"(count) : "d"(port)); \
163 : "d" (port), "0" (addr), "1" (count)); \
164} 145}
165 146
166#define RETURN_TYPE unsigned char 147BUILDIO(b, b, char)
167__IN(b, "") 148BUILDIO(w, w, short)
168#undef RETURN_TYPE 149BUILDIO(l, , int)
169#define RETURN_TYPE unsigned short
170__IN(w, "")
171#undef RETURN_TYPE
172#define RETURN_TYPE unsigned int
173__IN(l, "")
174#undef RETURN_TYPE
175
176__OUT(b, "b", char)
177__OUT(w, "w", short)
178__OUT(l, , int)
179
180__INS(b)
181__INS(w)
182__INS(l)
183
184__OUTS(b)
185__OUTS(w)
186__OUTS(l)
187
188 150
189#endif /* _ASM_X86_IO_64_H */ 151#endif /* _ASM_X86_IO_64_H */