This source file includes following definitions.
- virt_to_phys
- phys_to_virt
1 #ifndef _ASM_IO_H
2 #define _ASM_IO_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #ifdef SLOW_IO_BY_JUMPING
29 #define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
30 #else
31 #define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
32 #endif
33
34 #ifdef REALLY_SLOW_IO
35 #define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
36 #else
37 #define SLOW_DOWN_IO __SLOW_DOWN_IO
38 #endif
39
40
41
42
43
44
45
46 extern inline unsigned long virt_to_phys(void * address)
47 {
48 return (unsigned long) address;
49 }
50
51 extern inline void * phys_to_virt(unsigned long address)
52 {
53 return (void *) address;
54 }
55
56
57
58
59 #define virt_to_bus virt_to_phys
60 #define bus_to_virt phys_to_virt
61
62
63
64
65
66 #define __OUT1(s,x) \
67 extern inline void __out##s(unsigned x value, unsigned short port) {
68
69 #define __OUT2(s,s1,s2) \
70 __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
71
72 #define __OUT(s,s1,x) \
73 __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
74 __OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "i" (port)); } \
75 __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
76 __OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "i" (port)); SLOW_DOWN_IO; }
77
78 #define __IN1(s) \
79 extern inline unsigned int __in##s(unsigned short port) { unsigned int _v;
80
81 #define __IN2(s,s1,s2) \
82 __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
83
84 #define __IN(s,s1,i...) \
85 __IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
86 __IN1(s##c) __IN2(s,s1,"") : "=a" (_v) : "i" (port) ,##i ); return _v; } \
87 __IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
88 __IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "i" (port) ,##i ); SLOW_DOWN_IO; return _v; }
89
90 #define __INS(s) \
91 extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
92 { __asm__ __volatile__ ("cld ; rep ; ins" #s \
93 : "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
94
95 #define __OUTS(s) \
96 extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
97 { __asm__ __volatile__ ("cld ; rep ; outs" #s \
98 : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
99
100 __IN(b,"b","0" (0))
101 __IN(w,"w","0" (0))
102 __IN(l,"")
103
104 __OUT(b,"b",char)
105 __OUT(w,"w",short)
106 __OUT(l,,int)
107
108 __INS(b)
109 __INS(w)
110 __INS(l)
111
112 __OUTS(b)
113 __OUTS(w)
114 __OUTS(l)
115
116
117
118
119
120
121 #define outb(val,port) \
122 ((__builtin_constant_p((port)) && (port) < 256) ? \
123 __outbc((val),(port)) : \
124 __outb((val),(port)))
125
126 #define inb(port) \
127 ((__builtin_constant_p((port)) && (port) < 256) ? \
128 __inbc(port) : \
129 __inb(port))
130
131 #define outb_p(val,port) \
132 ((__builtin_constant_p((port)) && (port) < 256) ? \
133 __outbc_p((val),(port)) : \
134 __outb_p((val),(port)))
135
136 #define inb_p(port) \
137 ((__builtin_constant_p((port)) && (port) < 256) ? \
138 __inbc_p(port) : \
139 __inb_p(port))
140
141 #define outw(val,port) \
142 ((__builtin_constant_p((port)) && (port) < 256) ? \
143 __outwc((val),(port)) : \
144 __outw((val),(port)))
145
146 #define inw(port) \
147 ((__builtin_constant_p((port)) && (port) < 256) ? \
148 __inwc(port) : \
149 __inw(port))
150
151 #define outw_p(val,port) \
152 ((__builtin_constant_p((port)) && (port) < 256) ? \
153 __outwc_p((val),(port)) : \
154 __outw_p((val),(port)))
155
156 #define inw_p(port) \
157 ((__builtin_constant_p((port)) && (port) < 256) ? \
158 __inwc_p(port) : \
159 __inw_p(port))
160
161 #define outl(val,port) \
162 ((__builtin_constant_p((port)) && (port) < 256) ? \
163 __outlc((val),(port)) : \
164 __outl((val),(port)))
165
166 #define inl(port) \
167 ((__builtin_constant_p((port)) && (port) < 256) ? \
168 __inlc(port) : \
169 __inl(port))
170
171 #define outl_p(val,port) \
172 ((__builtin_constant_p((port)) && (port) < 256) ? \
173 __outlc_p((val),(port)) : \
174 __outl_p((val),(port)))
175
176 #define inl_p(port) \
177 ((__builtin_constant_p((port)) && (port) < 256) ? \
178 __inlc_p(port) : \
179 __inl_p(port))
180
181 #endif