x86: asm/io.h: unify ioremap prototypes
[deliverable/linux.git] / arch / x86 / include / asm / io_32.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_IO_32_H
2#define _ASM_X86_IO_32_H
1da177e4 3
1da177e4
LT
4#include <linux/string.h>
5#include <linux/compiler.h>
6
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/..).
12 *
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.
18 */
19
20/*
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.
24 *
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)
27 *
28 * Linus
29 */
30
31 /*
32 * Bit simplified and optimized by Jan Hubicka
33 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
34 *
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>
38 */
39
40#define IO_SPACE_LIMIT 0xffff
41
42#define XQUAD_PORTIO_BASE 0xfe400000
43#define XQUAD_PORTIO_QUAD 0x40000 /* 256k per quad. */
44
45#ifdef __KERNEL__
46
47#include <asm-generic/iomap.h>
48
49#include <linux/vmalloc.h>
50
1da177e4
LT
51/*
52 * Convert a virtual cached pointer to an uncached pointer
53 */
54#define xlate_dev_kmem_ptr(p) p
55
3c215b66
AM
56static inline void
57memset_io(volatile void __iomem *addr, unsigned char val, int count)
1da177e4 58{
3c215b66 59 memset((void __force *)addr, val, count);
1da177e4 60}
3c215b66
AM
61
62static inline void
63memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
1da177e4 64{
3c215b66 65 __memcpy(dst, (const void __force *)src, count);
1da177e4 66}
3c215b66
AM
67
68static inline void
69memcpy_toio(volatile void __iomem *dst, const void *src, int count)
1da177e4 70{
3c215b66 71 __memcpy((void __force *)dst, src, count);
1da177e4
LT
72}
73
74/*
75 * ISA space is 'always mapped' on a typical x86 system, no need to
76 * explicitly ioremap() it. The fact that the ISA IO space is mapped
77 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
78 * are physical addresses. The following constant pointer can be
79 * used as the IO-area pointer (it can be iounmapped as well, so the
80 * analogy with PCI is quite large):
81 */
82#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
83
1da177e4
LT
84/*
85 * Cache management
86 *
87 * This needed for two cases
88 * 1. Out of order aware processors
89 * 2. Accidentally out of order processors (PPro errata #51)
90 */
dcd215c9 91
1da177e4
LT
92#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
93
94static inline void flush_write_buffers(void)
95{
dcd215c9 96 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
1da177e4
LT
97}
98
1da177e4
LT
99#else
100
622a9edd 101#define flush_write_buffers() do { } while (0)
1da177e4
LT
102
103#endif
104
105#endif /* __KERNEL__ */
106
b02aae9c 107extern void native_io_delay(void);
90a0a06a 108
6e7c4025
IM
109extern int io_delay_type;
110extern void io_delay_init(void);
111
d3561b7f
RR
112#if defined(CONFIG_PARAVIRT)
113#include <asm/paravirt.h>
1da177e4 114#else
d3561b7f 115
dcd215c9
JP
116static inline void slow_down_io(void)
117{
90a0a06a 118 native_io_delay();
1da177e4 119#ifdef REALLY_SLOW_IO
90a0a06a
RR
120 native_io_delay();
121 native_io_delay();
122 native_io_delay();
1da177e4 123#endif
1da177e4
LT
124}
125
d3561b7f
RR
126#endif
127
dcd215c9
JP
128#define __BUILDIO(bwl, bw, type) \
129static inline void out##bwl(unsigned type value, int port) \
130{ \
131 out##bwl##_local(value, port); \
132} \
133 \
134static inline unsigned type in##bwl(int port) \
135{ \
136 return in##bwl##_local(port); \
1da177e4 137}
1da177e4 138
dcd215c9
JP
139#define BUILDIO(bwl, bw, type) \
140static inline void out##bwl##_local(unsigned type value, int port) \
141{ \
142 asm volatile("out" #bwl " %" #bw "0, %w1" \
143 : : "a"(value), "Nd"(port)); \
144} \
145 \
146static inline unsigned type in##bwl##_local(int port) \
147{ \
148 unsigned type value; \
149 asm volatile("in" #bwl " %w1, %" #bw "0" \
150 : "=a"(value) : "Nd"(port)); \
151 return value; \
152} \
153 \
154static inline void out##bwl##_local_p(unsigned type value, int port) \
155{ \
156 out##bwl##_local(value, port); \
157 slow_down_io(); \
158} \
159 \
160static inline unsigned type in##bwl##_local_p(int port) \
161{ \
162 unsigned type value = in##bwl##_local(port); \
163 slow_down_io(); \
164 return value; \
165} \
166 \
167__BUILDIO(bwl, bw, type) \
168 \
169static inline void out##bwl##_p(unsigned type value, int port) \
170{ \
171 out##bwl(value, port); \
172 slow_down_io(); \
173} \
174 \
175static inline unsigned type in##bwl##_p(int port) \
176{ \
177 unsigned type value = in##bwl(port); \
178 slow_down_io(); \
179 return value; \
180} \
181 \
182static inline void outs##bwl(int port, const void *addr, unsigned long count) \
183{ \
184 asm volatile("rep; outs" #bwl \
185 : "+S"(addr), "+c"(count) : "d"(port)); \
186} \
187 \
188static inline void ins##bwl(int port, void *addr, unsigned long count) \
189{ \
190 asm volatile("rep; ins" #bwl \
191 : "+D"(addr), "+c"(count) : "d"(port)); \
1da177e4
LT
192}
193
dcd215c9
JP
194BUILDIO(b, b, char)
195BUILDIO(w, w, short)
196BUILDIO(l, , int)
1da177e4 197
1965aae3 198#endif /* _ASM_X86_IO_32_H */
This page took 0.818781 seconds and 5 git commands to generate.