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
7 * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org>
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of David Wexelblat shall not be
28 * used in advertising or otherwise to promote the sale, use or other dealings
29 * in this Software without prior written authorization from David Wexelblat.
33 * Digital Equipment Corporation. All rights reserved.
34 * This software is furnished under license and may be used and copied only in
35 * accordance with the following terms and conditions. Subject to these
36 * conditions, you may download, copy, install, use, modify and distribute
37 * this software in source and/or binary form. No title or ownership is
40 * 1) Any source code used, modified or distributed must reproduce and retain
41 * this copyright notice and list of conditions as they appear in the source
44 * 2) No right is granted to use any trade name, trademark, or logo of Digital
45 * Equipment Corporation. Neither the "Digital Equipment Corporation" name
46 * nor any trademark or logo of Digital Equipment Corporation may be used
47 * to endorse or promote products derived from this software without the
48 * prior written permission of Digital Equipment Corporation.
50 * 3) This software is provided "AS-IS" and any express or implied warranties,
51 * including but not limited to, any implied warranties of merchantability,
52 * fitness for a particular purpose, or non-infringement are disclaimed. In
53 * no event shall DIGITAL be liable for any damages whatsoever, and in
54 * particular, DIGITAL shall not be liable for special, indirect,
55 * consequential, or incidental damages or damages for
56 * lost profits, loss of revenue or loss of use, whether such damages arise
58 * negligence, tort, under statute, in equity, at law or otherwise, even if
59 * advised of the possibility of such damage.
62 #ifndef MPLAYER_ASMMACROS_X86_H
63 #define MPLAYER_ASMMACROS_X86_H
67 #ifdef CONFIG_DHAHELPER
68 #include <sys/ioctl.h>
69 #include "vidix/dhahelper/dhahelper.h"
71 extern int dhahelper_fd
;
72 extern int dhahelper_initialized
;
75 #ifdef CONFIG_SVGAHELPER
76 #include <sys/ioctl.h>
77 #include <svgalib_helper.h>
79 #ifndef SVGALIB_HELPER_IOC_MAGIC
80 /* svgalib 1.9.18+ compatibility ::atmos */
81 #define SVGALIB_HELPER_IOCSOUTB SVGAHELPER_OUTB
82 #define SVGALIB_HELPER_IOCSOUTW SVGAHELPER_OUTW
83 #define SVGALIB_HELPER_IOCSOUTL SVGAHELPER_OUTL
84 #define SVGALIB_HELPER_IOCGINB SVGAHELPER_INB
85 #define SVGALIB_HELPER_IOCGINW SVGAHELPER_INW
86 #define SVGALIB_HELPER_IOCGINL SVGAHELPER_INL
89 extern int svgahelper_fd
;
90 extern int svgahelper_initialized
;
92 static __inline__
void svga_outb(short port
, char value
)
98 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTB
, &iov
);
101 static __inline__
void svga_outw(short port
, char value
)
107 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTW
, &iov
);
110 static __inline__
void svga_outl(short port
, unsigned int value
)
116 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTL
, &iov
);
119 static __inline__
unsigned int svga_inb(short port
)
124 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINB
, &iov
);
129 static __inline__
unsigned int svga_inw(short port
)
134 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINW
, &iov
);
139 static __inline__
unsigned int svga_inl(short port
)
144 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINL
, &iov
);
148 #endif /* CONIFG_SVGAHELPER */
150 static __inline__
void outb(short port
,char val
)
152 #ifdef CONFIG_SVGAHELPER
153 if (svgahelper_initialized
== 1)
155 svga_outb(port
, val
);
160 #ifdef CONFIG_DHAHELPER
161 if (dhahelper_initialized
== 1)
163 dhahelper_port_t _port
;
165 _port
.operation
= PORT_OP_WRITE
;
169 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
174 __asm__
volatile("outb %0,%1" : :"a" (val
), "d" (port
));
178 static __inline__
void outw(short port
,short val
)
180 #ifdef CONFIG_SVGAHELPER
181 if (svgahelper_initialized
== 1)
183 svga_outw(port
, val
);
188 #ifdef CONFIG_DHAHELPER
189 if (dhahelper_initialized
== 1)
191 dhahelper_port_t _port
;
193 _port
.operation
= PORT_OP_WRITE
;
197 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
202 __asm__
volatile("outw %0,%1" : :"a" (val
), "d" (port
));
206 static __inline__
void outl(short port
,unsigned int val
)
208 #ifdef CONFIG_SVGAHELPER
209 if (svgahelper_initialized
== 1)
211 svga_outl(port
, val
);
216 #ifdef CONFIG_DHAHELPER
217 if (dhahelper_initialized
== 1)
219 dhahelper_port_t _port
;
221 _port
.operation
= PORT_OP_WRITE
;
225 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
230 __asm__
volatile("outl %0,%1" : :"a" (val
), "d" (port
));
234 static __inline__
unsigned int inb(short port
)
236 unsigned char ret
= 0;
238 #ifdef CONFIG_SVGAHELPER
239 if (svgahelper_initialized
== 1)
241 return svga_inb(port
);
245 #ifdef CONFIG_DHAHELPER
246 if (dhahelper_initialized
== 1)
248 dhahelper_port_t _port
;
250 _port
.operation
= PORT_OP_READ
;
253 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
258 __asm__
volatile("inb %1,%0" :
264 static __inline__
unsigned int inw(short port
)
266 unsigned short ret
= 0;
268 #ifdef CONFIG_SVGAHELPER
269 if (svgahelper_initialized
== 1)
271 return svga_inw(port
);
275 #ifdef CONFIG_DHAHELPER
276 if (dhahelper_initialized
== 1)
278 dhahelper_port_t _port
;
280 _port
.operation
= PORT_OP_READ
;
283 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
288 __asm__
volatile("inw %1,%0" :
294 static __inline__
unsigned int inl(short port
)
296 unsigned int ret
= 0;
298 #ifdef CONFIG_SVGAHELPER
299 if (svgahelper_initialized
== 1)
301 return svga_inl(port
);
305 #ifdef CONFIG_DHAHELPER
306 if (dhahelper_initialized
== 1)
308 dhahelper_port_t _port
;
310 _port
.operation
= PORT_OP_READ
;
313 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
318 __asm__
volatile("inl %1,%0" :
324 static __inline__
void intr_disable(void)
326 #ifdef CONFIG_SVGAHELPER
327 if (svgahelper_initialized
== 1)
330 __asm__
volatile("cli");
333 static __inline__
void intr_enable(void)
335 #ifdef CONFIG_SVGAHELPER
336 if (svgahelper_initialized
== 1)
339 __asm__
volatile("sti");
342 #endif /* MPLAYER_ASMMACROS_X86_H */