x86-64: Use BUILDIO in io_64.h

Copied from io_32.h.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1265380629-3212-5-git-send-email-brgerst@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
Brian Gerst
2010-02-05 09:37:06 -05:00
committed by H. Peter Anvin
parent 2e16fc7728
commit 2b4df4d4f7

View File

@@ -104,86 +104,48 @@ static inline void slow_down_io(void)
#endif #endif
/* #define BUILDIO(bwl, bw, type) \
* Talk about misusing macros.. static inline void out##bwl(unsigned type value, int port) \
*/ { \
#define __OUT1(s, x) \ asm volatile("out" #bwl " %" #bw "0, %w1" \
static inline void out##s(unsigned x value, unsigned short port) { : : "a"(value), "Nd"(port)); \
} \
#define __OUT2(s, s1, s2) \ \
asm volatile ("out" #s " %" s1 "0,%" s2 "1" static inline unsigned type in##bwl(int port) \
{ \
#ifndef REALLY_SLOW_IO unsigned type value; \
#define REALLY_SLOW_IO asm volatile("in" #bwl " %w1, %" #bw "0" \
#define UNSET_REALLY_SLOW_IO : "=a"(value) : "Nd"(port)); \
#endif return value; \
} \
#define __OUT(s, s1, x) \ \
__OUT1(s, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ static inline void out##bwl##_p(unsigned type value, int port) \
} \ { \
__OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ out##bwl(value, port); \
slow_down_io(); \ slow_down_io(); \
} } \
\
#define __IN1(s) \ static inline unsigned type in##bwl##_p(int port) \
static inline RETURN_TYPE in##s(unsigned short port) \
{ \ { \
RETURN_TYPE _v; unsigned type value = in##bwl(port); \
#define __IN2(s, s1, s2) \
asm volatile ("in" #s " %" s2 "1,%" s1 "0"
#define __IN(s, s1, i...) \
__IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
return _v; \
} \
__IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
slow_down_io(); \ slow_down_io(); \
return _v; } return value; \
} \
#ifdef UNSET_REALLY_SLOW_IO \
#undef REALLY_SLOW_IO static inline void outs##bwl(int port, const void *addr, unsigned long count) \
#endif
#define __INS(s) \
static inline void ins##s(unsigned short port, void *addr, \
unsigned long count) \
{ \ { \
asm volatile ("rep ; ins" #s \ asm volatile("rep; outs" #bwl \
: "=D" (addr), "=c" (count) \ : "+S"(addr), "+c"(count) : "d"(port)); \
: "d" (port), "0" (addr), "1" (count)); \ } \
\
static inline void ins##bwl(int port, void *addr, unsigned long count) \
{ \
asm volatile("rep; ins" #bwl \
: "+D"(addr), "+c"(count) : "d"(port)); \
} }
#define __OUTS(s) \ BUILDIO(b, b, char)
static inline void outs##s(unsigned short port, const void *addr, \ BUILDIO(w, w, short)
unsigned long count) \ BUILDIO(l, , int)
{ \
asm volatile ("rep ; outs" #s \
: "=S" (addr), "=c" (count) \
: "d" (port), "0" (addr), "1" (count)); \
}
#define RETURN_TYPE unsigned char
__IN(b, "")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned short
__IN(w, "")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned int
__IN(l, "")
#undef RETURN_TYPE
__OUT(b, "b", char)
__OUT(w, "w", short)
__OUT(l, , int)
__INS(b)
__INS(w)
__INS(l)
__OUTS(b)
__OUTS(w)
__OUTS(l)
#endif /* _ASM_X86_IO_64_H */ #endif /* _ASM_X86_IO_64_H */