annotate libdha/sysdep/AsmMacros_x86.h @ 8193:83d3125cb382

A bit more sane range.
author rguyom
date Thu, 14 Nov 2002 21:57:34 +0000
parents 05ac3586db02
children 9dbb9c710480
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
1 /*
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
2 This file is based on:
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
3 $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
4 Modified for readability by Nick Kurshev
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
5 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
6
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
7 #ifndef __ASM_MACROS_X86_H
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
8 #define __ASM_MACROS_X86_H
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
9
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
10 #if defined (WINNT)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
11 #error This stuff is not ported on your system
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
12 #else
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
13
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
14 #include "config.h"
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
15
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
16 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
17 #include <sys/ioctl.h>
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
18 #include "../kernelhelper/dhahelper.h"
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
19
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
20 extern int dhahelper_fd;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
21 extern int dhahelper_initialized;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
22 #endif
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
23
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
24 static __inline__ void outb(short port,char val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
25 {
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
26 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
27 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
28 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
29 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
30
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
31 _port.operation = PORT_OP_WRITE;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
32 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
33 _port.size = 1;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
34 _port.value = val;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
35 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
36 return;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
37 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
38 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
39 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
40 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
41 return;
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
42 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
43
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
44 static __inline__ void outw(short port,short val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
45 {
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
46 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
47 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
48 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
49 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
50
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
51 _port.operation = PORT_OP_WRITE;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
52 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
53 _port.size = 2;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
54 _port.value = val;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
55 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
56 return;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
57 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
58 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
59 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
60 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
61 return;
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
62 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
63
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
64 static __inline__ void outl(short port,unsigned int val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
65 {
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
66 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
67 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
68 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
69 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
70
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
71 _port.operation = PORT_OP_WRITE;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
72 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
73 _port.size = 4;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
74 _port.value = val;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
75 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
76 return;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
77 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
78 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
79 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
80 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
81 return;
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
82 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
83
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
84 static __inline__ unsigned int inb(short port)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
85 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
86 unsigned char ret;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
87 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
88 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
89 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
90 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
91
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
92 _port.operation = PORT_OP_READ;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
93 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
94 _port.size = 1;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
95 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
96 return _port.value;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
97 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
98 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
99 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
100 __asm__ __volatile__("inb %1,%0" :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
101 "=a" (ret) :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
102 "d" (port));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
103 return ret;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
104 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
105
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
106 static __inline__ unsigned int inw(short port)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
107 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
108 unsigned short ret;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
109 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
110 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
111 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
112 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
113
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
114 _port.operation = PORT_OP_READ;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
115 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
116 _port.size = 2;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
117 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
118 return _port.value;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
119 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
120 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
121 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
122 __asm__ __volatile__("inw %1,%0" :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
123 "=a" (ret) :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
124 "d" (port));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
125 return ret;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
126 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
127
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
128 static __inline__ unsigned int inl(short port)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
129 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
130 unsigned int ret;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
131 #ifdef CONFIG_DHAHELPER
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
132 if (dhahelper_initialized == 1)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
133 {
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
134 dhahelper_port_t _port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
135
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
136 _port.operation = PORT_OP_READ;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
137 _port.addr = port;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
138 _port.size = 4;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
139 if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
140 return _port.value;
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
141 }
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
142 else
05ac3586db02 added support for dhahelper
alex
parents: 4164
diff changeset
143 #endif
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
144 __asm__ __volatile__("inl %1,%0" :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
145 "=a" (ret) :
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
146 "d" (port));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
147 return ret;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
148 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
149
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
150 static __inline__ void intr_disable()
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
151 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
152 __asm__ __volatile__("cli");
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
153 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
154
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
155 static __inline__ void intr_enable()
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
156 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
157 __asm__ __volatile__("sti");
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
158 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
159
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
160 #endif
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
161
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
162 #endif