comparison vidix/sysdep/AsmMacros_x86.h @ 22900:a9e111b88c4a

merged libdha and libvidix, moved all files from libdha to vidix directory
author ben
date Fri, 06 Apr 2007 15:20:49 +0000
parents libdha/sysdep/AsmMacros_x86.h@62705b2298ff
children 88bed2131f19
comparison
equal deleted inserted replaced
22899:515545f81186 22900:a9e111b88c4a
1 /*
2 This file is based on:
3 $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $
4 Modified for readability by Nick Kurshev
5 */
6
7 #ifndef __ASM_MACROS_X86_H
8 #define __ASM_MACROS_X86_H
9
10 //#if defined (WINNT)
11 //#error This stuff is not ported on your system
12 //#else
13
14 #include "config.h"
15
16 #ifdef CONFIG_DHAHELPER
17 #include <sys/ioctl.h>
18 #include "../kernelhelper/dhahelper.h"
19
20 extern int dhahelper_fd;
21 extern int dhahelper_initialized;
22 #endif
23
24 #ifdef CONFIG_SVGAHELPER
25 #include <sys/ioctl.h>
26 #include <svgalib_helper.h>
27
28 #ifndef SVGALIB_HELPER_IOC_MAGIC
29 /* svgalib 1.9.18+ compatibility ::atmos */
30 #define SVGALIB_HELPER_IOCSOUTB SVGAHELPER_OUTB
31 #define SVGALIB_HELPER_IOCSOUTW SVGAHELPER_OUTW
32 #define SVGALIB_HELPER_IOCSOUTL SVGAHELPER_OUTL
33 #define SVGALIB_HELPER_IOCGINB SVGAHELPER_INB
34 #define SVGALIB_HELPER_IOCGINW SVGAHELPER_INW
35 #define SVGALIB_HELPER_IOCGINL SVGAHELPER_INL
36 #endif
37
38 extern int svgahelper_fd;
39 extern int svgahelper_initialized;
40
41 static __inline__ void svga_outb(short port, char value)
42 {
43 io_t iov;
44
45 iov.val = value;
46 iov.port = port;
47 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTB, &iov);
48 }
49
50 static __inline__ void svga_outw(short port, char value)
51 {
52 io_t iov;
53
54 iov.val = value;
55 iov.port = port;
56 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTW, &iov);
57 }
58
59 static __inline__ void svga_outl(short port, unsigned int value)
60 {
61 io_t iov;
62
63 iov.val = value;
64 iov.port = port;
65 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTL, &iov);
66 }
67
68 static __inline__ unsigned int svga_inb(short port)
69 {
70 io_t iov;
71
72 iov.port = port;
73 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINB, &iov);
74
75 return iov.val;
76 }
77
78 static __inline__ unsigned int svga_inw(short port)
79 {
80 io_t iov;
81
82 iov.port = port;
83 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINW, &iov);
84
85 return iov.val;
86 }
87
88 static __inline__ unsigned int svga_inl(short port)
89 {
90 io_t iov;
91
92 iov.port = port;
93 ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINL, &iov);
94
95 return iov.val;
96 }
97 #endif /* CONIFG_SVGAHELPER */
98
99 static __inline__ void outb(short port,char val)
100 {
101 #ifdef CONFIG_SVGAHELPER
102 if (svgahelper_initialized == 1)
103 {
104 svga_outb(port, val);
105 return;
106 }
107 #endif
108
109 #ifdef CONFIG_DHAHELPER
110 if (dhahelper_initialized == 1)
111 {
112 dhahelper_port_t _port;
113
114 _port.operation = PORT_OP_WRITE;
115 _port.addr = port;
116 _port.size = 1;
117 _port.value = val;
118 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
119 return;
120 }
121 else
122 #endif
123 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
124 return;
125 }
126
127 static __inline__ void outw(short port,short val)
128 {
129 #ifdef CONFIG_SVGAHELPER
130 if (svgahelper_initialized == 1)
131 {
132 svga_outw(port, val);
133 return;
134 }
135 #endif
136
137 #ifdef CONFIG_DHAHELPER
138 if (dhahelper_initialized == 1)
139 {
140 dhahelper_port_t _port;
141
142 _port.operation = PORT_OP_WRITE;
143 _port.addr = port;
144 _port.size = 2;
145 _port.value = val;
146 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
147 return;
148 }
149 else
150 #endif
151 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
152 return;
153 }
154
155 static __inline__ void outl(short port,unsigned int val)
156 {
157 #ifdef CONFIG_SVGAHELPER
158 if (svgahelper_initialized == 1)
159 {
160 svga_outl(port, val);
161 return;
162 }
163 #endif
164
165 #ifdef CONFIG_DHAHELPER
166 if (dhahelper_initialized == 1)
167 {
168 dhahelper_port_t _port;
169
170 _port.operation = PORT_OP_WRITE;
171 _port.addr = port;
172 _port.size = 4;
173 _port.value = val;
174 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
175 return;
176 }
177 else
178 #endif
179 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
180 return;
181 }
182
183 static __inline__ unsigned int inb(short port)
184 {
185 unsigned char ret = 0;
186
187 #ifdef CONFIG_SVGAHELPER
188 if (svgahelper_initialized == 1)
189 {
190 return svga_inb(port);
191 }
192 #endif
193
194 #ifdef CONFIG_DHAHELPER
195 if (dhahelper_initialized == 1)
196 {
197 dhahelper_port_t _port;
198
199 _port.operation = PORT_OP_READ;
200 _port.addr = port;
201 _port.size = 1;
202 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
203 return _port.value;
204 }
205 else
206 #endif
207 __asm__ __volatile__("inb %1,%0" :
208 "=a" (ret) :
209 "d" (port));
210 return ret;
211 }
212
213 static __inline__ unsigned int inw(short port)
214 {
215 unsigned short ret = 0;
216
217 #ifdef CONFIG_SVGAHELPER
218 if (svgahelper_initialized == 1)
219 {
220 return svga_inw(port);
221 }
222 #endif
223
224 #ifdef CONFIG_DHAHELPER
225 if (dhahelper_initialized == 1)
226 {
227 dhahelper_port_t _port;
228
229 _port.operation = PORT_OP_READ;
230 _port.addr = port;
231 _port.size = 2;
232 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
233 return _port.value;
234 }
235 else
236 #endif
237 __asm__ __volatile__("inw %1,%0" :
238 "=a" (ret) :
239 "d" (port));
240 return ret;
241 }
242
243 static __inline__ unsigned int inl(short port)
244 {
245 unsigned int ret = 0;
246
247 #ifdef CONFIG_SVGAHELPER
248 if (svgahelper_initialized == 1)
249 {
250 return svga_inl(port);
251 }
252 #endif
253
254 #ifdef CONFIG_DHAHELPER
255 if (dhahelper_initialized == 1)
256 {
257 dhahelper_port_t _port;
258
259 _port.operation = PORT_OP_READ;
260 _port.addr = port;
261 _port.size = 4;
262 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
263 return _port.value;
264 }
265 else
266 #endif
267 __asm__ __volatile__("inl %1,%0" :
268 "=a" (ret) :
269 "d" (port));
270 return ret;
271 }
272
273 static __inline__ void intr_disable()
274 {
275 #ifdef CONFIG_SVGAHELPER
276 if (svgahelper_initialized == 1)
277 return;
278 #endif
279 __asm__ __volatile__("cli");
280 }
281
282 static __inline__ void intr_enable()
283 {
284 #ifdef CONFIG_SVGAHELPER
285 if (svgahelper_initialized == 1)
286 return;
287 #endif
288 __asm__ __volatile__("sti");
289 }
290
291 #endif
292
293 //#endif