7 * This file contains the definitions for the x86 IO instructions
8 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
9 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
10 * versions of the single-IO instructions (inb_p/inw_p/..).
12 #if defined( __ROMCC__ ) && !defined (__GNUC__)
13 static inline void outb(uint8_t value, uint16_t port)
15 __builtin_outb(value, port);
18 static inline void outw(uint16_t value, uint16_t port)
20 __builtin_outw(value, port);
23 static inline void outl(uint32_t value, uint16_t port)
25 __builtin_outl(value, port);
29 static inline uint8_t inb(uint16_t port)
31 return __builtin_inb(port);
35 static inline uint16_t inw(uint16_t port)
37 return __builtin_inw(port);
40 static inline uint32_t inl(uint16_t port)
42 return __builtin_inl(port);
46 static inline void outb(uint8_t value, uint16_t port)
48 __asm__ __volatile__ ("outb %b0, %w1" : : "a" (value), "Nd" (port));
51 static inline void outw(uint16_t value, uint16_t port)
53 __asm__ __volatile__ ("outw %w0, %w1" : : "a" (value), "Nd" (port));
56 static inline void outl(uint32_t value, uint16_t port)
58 __asm__ __volatile__ ("outl %0, %w1" : : "a" (value), "Nd" (port));
61 static inline uint8_t inb(uint16_t port)
64 __asm__ __volatile__ ("inb %w1, %b0" : "=a"(value) : "Nd" (port));
68 static inline uint16_t inw(uint16_t port)
71 __asm__ __volatile__ ("inw %w1, %w0" : "=a"(value) : "Nd" (port));
75 static inline uint32_t inl(uint16_t port)
78 __asm__ __volatile__ ("inl %w1, %0" : "=a"(value) : "Nd" (port));
82 #endif /* __ROMCC__ && !__GNUC__*/
84 static inline void outsb(uint16_t port, const void *addr, unsigned long count)
86 __asm__ __volatile__ (
88 : "=S" (addr), "=c" (count)
89 : "d"(port), "0"(addr), "1" (count)
93 static inline void outsw(uint16_t port, const void *addr, unsigned long count)
95 __asm__ __volatile__ (
97 : "=S" (addr), "=c" (count)
98 : "d"(port), "0"(addr), "1" (count)
102 static inline void outsl(uint16_t port, const void *addr, unsigned long count)
104 __asm__ __volatile__ (
106 : "=S" (addr), "=c" (count)
107 : "d"(port), "0"(addr), "1" (count)
112 static inline void insb(uint16_t port, void *addr, unsigned long count)
114 __asm__ __volatile__ (
116 : "=D" (addr), "=c" (count)
117 : "d"(port), "0"(addr), "1" (count)
121 static inline void insw(uint16_t port, void *addr, unsigned long count)
123 __asm__ __volatile__ (
125 : "=D" (addr), "=c" (count)
126 : "d"(port), "0"(addr), "1" (count)
130 static inline void insl(uint16_t port, void *addr, unsigned long count)
132 __asm__ __volatile__ (
134 : "=D" (addr), "=c" (count)
135 : "d"(port), "0"(addr), "1" (count)
139 static inline void writeb(uint8_t b, volatile void *addr)
141 *(volatile uint8_t *) addr = b;
144 static inline void writew(uint16_t b, volatile void *addr)
146 *(volatile uint16_t *) addr = b;
149 static inline void writel(uint32_t b, volatile void *addr)
151 *(volatile uint32_t *) addr = b;
154 static inline uint8_t readb(const volatile void *addr)
156 return *(volatile uint8_t *) addr;
159 static inline uint16_t readw(const volatile void *addr)
161 return *(volatile uint16_t *) addr;
164 static inline uint32_t readl(const volatile void *addr)
166 return *(volatile uint32_t *) addr;