5 * This file contains the definitions for the x86 IO instructions
6 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
7 * (insb/insw/insl/outsb/outsw/outsl).
9 * This file is not meant to be obfuscating: it's just complicated
10 * to (a) handle it all in a way that makes gcc able to optimize it
11 * as well as possible and (b) trying to avoid writing the same thing
12 * over and over again with slight variations and possibly making a
17 * Bit simplified and optimized by Jan Hubicka
18 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
22 * Talk about misusing macros..
25 extern inline void out##s(unsigned x value, unsigned short port) {
27 #define __OUT2(s,s1,s2) \
28 __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
30 #define __OUT(s,s1,x) \
31 __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); }
34 extern inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
36 #define __IN2(s,s1,s2) \
37 __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
39 #define __IN(s,s1,i...) \
40 __IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "Nd" (port) ,##i ); return _v; }
43 extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
44 { __asm__ __volatile__ ("cld ; rep ; ins" #s \
45 : "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
48 extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
49 { __asm__ __volatile__ ("cld ; rep ; outs" #s \
50 : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
52 #define RETURN_TYPE unsigned char
55 #define RETURN_TYPE unsigned short
58 #define RETURN_TYPE unsigned int