Commit 2b4df4d4 authored by Brian Gerst's avatar Brian Gerst Committed by H. Peter Anvin

x86-64: Use BUILDIO in io_64.h

Copied from io_32.h.
Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
LKML-Reference: <1265380629-3212-5-git-send-email-brgerst@gmail.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 2e16fc77
...@@ -104,86 +104,48 @@ static inline void slow_down_io(void) ...@@ -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) \
#define __OUTS(s) \
static inline void outs##s(unsigned short port, const void *addr, \
unsigned long count) \
{ \ { \
asm volatile ("rep ; outs" #s \ asm volatile("rep; ins" #bwl \
: "=S" (addr), "=c" (count) \ : "+D"(addr), "+c"(count) : "d"(port)); \
: "d" (port), "0" (addr), "1" (count)); \
} }
#define RETURN_TYPE unsigned char BUILDIO(b, b, char)
__IN(b, "") BUILDIO(w, w, short)
#undef RETURN_TYPE BUILDIO(l, , int)
#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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment