4164
|
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
|
4474
|
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
|
4164
|
24 static __inline__ void outb(short port,char val)
|
|
25 {
|
4474
|
26 #ifdef CONFIG_DHAHELPER
|
|
27 if (dhahelper_initialized == 1)
|
|
28 {
|
|
29 dhahelper_port_t _port;
|
|
30
|
|
31 _port.operation = PORT_OP_WRITE;
|
|
32 _port.addr = port;
|
|
33 _port.size = 1;
|
|
34 _port.value = val;
|
|
35 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
36 return;
|
|
37 }
|
|
38 else
|
|
39 #endif
|
4164
|
40 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
|
4474
|
41 return;
|
4164
|
42 }
|
|
43
|
|
44 static __inline__ void outw(short port,short val)
|
|
45 {
|
4474
|
46 #ifdef CONFIG_DHAHELPER
|
|
47 if (dhahelper_initialized == 1)
|
|
48 {
|
|
49 dhahelper_port_t _port;
|
|
50
|
|
51 _port.operation = PORT_OP_WRITE;
|
|
52 _port.addr = port;
|
|
53 _port.size = 2;
|
|
54 _port.value = val;
|
|
55 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
56 return;
|
|
57 }
|
|
58 else
|
|
59 #endif
|
4164
|
60 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
|
4474
|
61 return;
|
4164
|
62 }
|
|
63
|
|
64 static __inline__ void outl(short port,unsigned int val)
|
|
65 {
|
4474
|
66 #ifdef CONFIG_DHAHELPER
|
|
67 if (dhahelper_initialized == 1)
|
|
68 {
|
|
69 dhahelper_port_t _port;
|
|
70
|
|
71 _port.operation = PORT_OP_WRITE;
|
|
72 _port.addr = port;
|
|
73 _port.size = 4;
|
|
74 _port.value = val;
|
|
75 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
76 return;
|
|
77 }
|
|
78 else
|
|
79 #endif
|
4164
|
80 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
|
4474
|
81 return;
|
4164
|
82 }
|
|
83
|
|
84 static __inline__ unsigned int inb(short port)
|
|
85 {
|
|
86 unsigned char ret;
|
4474
|
87 #ifdef CONFIG_DHAHELPER
|
|
88 if (dhahelper_initialized == 1)
|
|
89 {
|
|
90 dhahelper_port_t _port;
|
|
91
|
|
92 _port.operation = PORT_OP_READ;
|
|
93 _port.addr = port;
|
|
94 _port.size = 1;
|
|
95 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
96 return _port.value;
|
|
97 }
|
|
98 else
|
|
99 #endif
|
4164
|
100 __asm__ __volatile__("inb %1,%0" :
|
|
101 "=a" (ret) :
|
|
102 "d" (port));
|
|
103 return ret;
|
|
104 }
|
|
105
|
|
106 static __inline__ unsigned int inw(short port)
|
|
107 {
|
|
108 unsigned short ret;
|
4474
|
109 #ifdef CONFIG_DHAHELPER
|
|
110 if (dhahelper_initialized == 1)
|
|
111 {
|
|
112 dhahelper_port_t _port;
|
|
113
|
|
114 _port.operation = PORT_OP_READ;
|
|
115 _port.addr = port;
|
|
116 _port.size = 2;
|
|
117 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
118 return _port.value;
|
|
119 }
|
|
120 else
|
|
121 #endif
|
4164
|
122 __asm__ __volatile__("inw %1,%0" :
|
|
123 "=a" (ret) :
|
|
124 "d" (port));
|
|
125 return ret;
|
|
126 }
|
|
127
|
|
128 static __inline__ unsigned int inl(short port)
|
|
129 {
|
|
130 unsigned int ret;
|
4474
|
131 #ifdef CONFIG_DHAHELPER
|
|
132 if (dhahelper_initialized == 1)
|
|
133 {
|
|
134 dhahelper_port_t _port;
|
|
135
|
|
136 _port.operation = PORT_OP_READ;
|
|
137 _port.addr = port;
|
|
138 _port.size = 4;
|
|
139 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
|
140 return _port.value;
|
|
141 }
|
|
142 else
|
|
143 #endif
|
4164
|
144 __asm__ __volatile__("inl %1,%0" :
|
|
145 "=a" (ret) :
|
|
146 "d" (port));
|
|
147 return ret;
|
|
148 }
|
|
149
|
|
150 static __inline__ void intr_disable()
|
|
151 {
|
|
152 __asm__ __volatile__("cli");
|
|
153 }
|
|
154
|
|
155 static __inline__ void intr_enable()
|
|
156 {
|
|
157 __asm__ __volatile__("sti");
|
|
158 }
|
|
159
|
|
160 #endif
|
|
161
|
|
162 #endif
|