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 #ifndef __ASM_MACROS_X86_H
8 #define __ASM_MACROS_X86_H
11 //#error This stuff is not ported on your system
16 #ifdef CONFIG_DHAHELPER
17 #include <sys/ioctl.h>
18 #include "../kernelhelper/dhahelper.h"
20 extern int dhahelper_fd
;
21 extern int dhahelper_initialized
;
24 #ifdef CONFIG_SVGAHELPER
25 #include <sys/ioctl.h>
26 #include <svgalib_helper.h>
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
38 extern int svgahelper_fd
;
39 extern int svgahelper_initialized
;
41 static __inline__
void svga_outb(short port
, char value
)
47 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTB
, &iov
);
50 static __inline__
void svga_outw(short port
, char value
)
56 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTW
, &iov
);
59 static __inline__
void svga_outl(short port
, unsigned int value
)
65 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCSOUTL
, &iov
);
68 static __inline__
unsigned int svga_inb(short port
)
73 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINB
, &iov
);
78 static __inline__
unsigned int svga_inw(short port
)
83 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINW
, &iov
);
88 static __inline__
unsigned int svga_inl(short port
)
93 ioctl(svgahelper_fd
, SVGALIB_HELPER_IOCGINL
, &iov
);
97 #endif /* CONIFG_SVGAHELPER */
99 static __inline__
void outb(short port
,char val
)
101 #ifdef CONFIG_SVGAHELPER
102 if (svgahelper_initialized
== 1)
104 svga_outb(port
, val
);
109 #ifdef CONFIG_DHAHELPER
110 if (dhahelper_initialized
== 1)
112 dhahelper_port_t _port
;
114 _port
.operation
= PORT_OP_WRITE
;
118 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
123 __asm__
__volatile__("outb %0,%1" : :"a" (val
), "d" (port
));
127 static __inline__
void outw(short port
,short val
)
129 #ifdef CONFIG_SVGAHELPER
130 if (svgahelper_initialized
== 1)
132 svga_outw(port
, val
);
137 #ifdef CONFIG_DHAHELPER
138 if (dhahelper_initialized
== 1)
140 dhahelper_port_t _port
;
142 _port
.operation
= PORT_OP_WRITE
;
146 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
151 __asm__
__volatile__("outw %0,%1" : :"a" (val
), "d" (port
));
155 static __inline__
void outl(short port
,unsigned int val
)
157 #ifdef CONFIG_SVGAHELPER
158 if (svgahelper_initialized
== 1)
160 svga_outl(port
, val
);
165 #ifdef CONFIG_DHAHELPER
166 if (dhahelper_initialized
== 1)
168 dhahelper_port_t _port
;
170 _port
.operation
= PORT_OP_WRITE
;
174 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
179 __asm__
__volatile__("outl %0,%1" : :"a" (val
), "d" (port
));
183 static __inline__
unsigned int inb(short port
)
185 unsigned char ret
= 0;
187 #ifdef CONFIG_SVGAHELPER
188 if (svgahelper_initialized
== 1)
190 return svga_inb(port
);
194 #ifdef CONFIG_DHAHELPER
195 if (dhahelper_initialized
== 1)
197 dhahelper_port_t _port
;
199 _port
.operation
= PORT_OP_READ
;
202 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
207 __asm__
__volatile__("inb %1,%0" :
213 static __inline__
unsigned int inw(short port
)
215 unsigned short ret
= 0;
217 #ifdef CONFIG_SVGAHELPER
218 if (svgahelper_initialized
== 1)
220 return svga_inw(port
);
224 #ifdef CONFIG_DHAHELPER
225 if (dhahelper_initialized
== 1)
227 dhahelper_port_t _port
;
229 _port
.operation
= PORT_OP_READ
;
232 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
237 __asm__
__volatile__("inw %1,%0" :
243 static __inline__
unsigned int inl(short port
)
245 unsigned int ret
= 0;
247 #ifdef CONFIG_SVGAHELPER
248 if (svgahelper_initialized
== 1)
250 return svga_inl(port
);
254 #ifdef CONFIG_DHAHELPER
255 if (dhahelper_initialized
== 1)
257 dhahelper_port_t _port
;
259 _port
.operation
= PORT_OP_READ
;
262 if (ioctl(dhahelper_fd
, DHAHELPER_PORT
, &_port
) == 0)
267 __asm__
__volatile__("inl %1,%0" :
273 static __inline__
void intr_disable()
275 #ifdef CONFIG_SVGAHELPER
276 if (svgahelper_initialized
== 1)
279 __asm__
__volatile__("cli");
282 static __inline__
void intr_enable()
284 #ifdef CONFIG_SVGAHELPER
285 if (svgahelper_initialized
== 1)
288 __asm__
__volatile__("sti");