x86: Clean up mem*io functions.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / include / asm / io_64.h
blob1305525813fc5dd159900f93e80b0f6cdbea429d
1 #ifndef _ASM_X86_IO_64_H
2 #define _ASM_X86_IO_64_H
4 #include <linux/string.h>
5 #include <linux/compiler.h>
7 /*
8 * This file contains the definitions for the x86 IO instructions
9 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
10 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
11 * versions of the single-IO instructions (inb_p/inw_p/..).
13 * This file is not meant to be obfuscating: it's just complicated
14 * to (a) handle it all in a way that makes gcc able to optimize it
15 * as well as possible and (b) trying to avoid writing the same thing
16 * over and over again with slight variations and possibly making a
17 * mistake somewhere.
21 * Thanks to James van Artsdalen for a better timing-fix than
22 * the two short jumps: using outb's to a nonexistent port seems
23 * to guarantee better timings even on fast machines.
25 * On the other hand, I'd like to be sure of a non-existent port:
26 * I feel a bit unsafe about using 0x80 (should be safe, though)
28 * Linus
32 * Bit simplified and optimized by Jan Hubicka
33 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
35 * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
36 * isa_read[wl] and isa_write[wl] fixed
37 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
40 #ifdef __KERNEL__
42 #include <asm-generic/iomap.h>
44 #include <linux/vmalloc.h>
47 * Convert a virtual cached pointer to an uncached pointer
49 #define xlate_dev_kmem_ptr(p) p
51 static inline void
52 memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
54 memset((void __force *)addr, val, count);
57 static inline void
58 memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
60 memcpy(dst, (const void __force *)src, count);
63 static inline void
64 memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
66 memcpy((void __force *)dst, src, count);
70 * ISA space is 'always mapped' on a typical x86 system, no need to
71 * explicitly ioremap() it. The fact that the ISA IO space is mapped
72 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
73 * are physical addresses. The following constant pointer can be
74 * used as the IO-area pointer (it can be iounmapped as well, so the
75 * analogy with PCI is quite large):
77 #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
80 * Cache management
82 * This needed for two cases
83 * 1. Out of order aware processors
84 * 2. Accidentally out of order processors (PPro errata #51)
86 #define flush_write_buffers() do { } while (0)
88 #endif /* __KERNEL__ */
90 extern void native_io_delay(void);
92 extern int io_delay_type;
93 extern void io_delay_init(void);
95 #if defined(CONFIG_PARAVIRT)
96 #include <asm/paravirt.h>
97 #else
99 static inline void slow_down_io(void)
101 native_io_delay();
102 #ifdef REALLY_SLOW_IO
103 native_io_delay();
104 native_io_delay();
105 native_io_delay();
106 #endif
109 #endif
111 #define BUILDIO(bwl, bw, type) \
112 static inline void out##bwl(unsigned type value, int port) \
114 asm volatile("out" #bwl " %" #bw "0, %w1" \
115 : : "a"(value), "Nd"(port)); \
118 static inline unsigned type in##bwl(int port) \
120 unsigned type value; \
121 asm volatile("in" #bwl " %w1, %" #bw "0" \
122 : "=a"(value) : "Nd"(port)); \
123 return value; \
126 static inline void out##bwl##_p(unsigned type value, int port) \
128 out##bwl(value, port); \
129 slow_down_io(); \
132 static inline unsigned type in##bwl##_p(int port) \
134 unsigned type value = in##bwl(port); \
135 slow_down_io(); \
136 return value; \
139 static inline void outs##bwl(int port, const void *addr, unsigned long count) \
141 asm volatile("rep; outs" #bwl \
142 : "+S"(addr), "+c"(count) : "d"(port)); \
145 static inline void ins##bwl(int port, void *addr, unsigned long count) \
147 asm volatile("rep; ins" #bwl \
148 : "+D"(addr), "+c"(count) : "d"(port)); \
151 BUILDIO(b, b, char)
152 BUILDIO(w, w, short)
153 BUILDIO(l, , int)
155 #endif /* _ASM_X86_IO_64_H */