]>
Commit | Line | Data |
---|---|---|
c7de829c WD |
1 | /* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ |
2 | /* | |
3 | * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org> | |
4 | * | |
8bde7f77 WD |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
c7de829c WD |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included in | |
13 | * all copies or substantial portions of the Software. | |
8bde7f77 | 14 | * |
c7de829c WD |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
8bde7f77 WD |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | |
20 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
c7de829c | 21 | * SOFTWARE. |
8bde7f77 | 22 | * |
c7de829c WD |
23 | * Except as contained in this notice, the name of David Wexelblat shall not be |
24 | * used in advertising or otherwise to promote the sale, use or other dealings | |
25 | * in this Software without prior written authorization from David Wexelblat. | |
26 | * | |
27 | */ | |
28 | /* | |
29 | * Copyright 1997 | |
30 | * Digital Equipment Corporation. All rights reserved. | |
8bde7f77 WD |
31 | * This software is furnished under license and may be used and copied only in |
32 | * accordance with the following terms and conditions. Subject to these | |
33 | * conditions, you may download, copy, install, use, modify and distribute | |
34 | * this software in source and/or binary form. No title or ownership is | |
c7de829c WD |
35 | * transferred hereby. |
36 | * | |
8bde7f77 | 37 | * 1) Any source code used, modified or distributed must reproduce and retain |
c7de829c WD |
38 | * this copyright notice and list of conditions as they appear in the source |
39 | * file. | |
40 | * | |
8bde7f77 WD |
41 | * 2) No right is granted to use any trade name, trademark, or logo of Digital |
42 | * Equipment Corporation. Neither the "Digital Equipment Corporation" name | |
43 | * nor any trademark or logo of Digital Equipment Corporation may be used | |
44 | * to endorse or promote products derived from this software without the | |
c7de829c WD |
45 | * prior written permission of Digital Equipment Corporation. |
46 | * | |
8bde7f77 WD |
47 | * 3) This software is provided "AS-IS" and any express or implied warranties, |
48 | * including but not limited to, any implied warranties of merchantability, | |
49 | * fitness for a particular purpose, or non-infringement are disclaimed. In | |
50 | * no event shall DIGITAL be liable for any damages whatsoever, and in | |
51 | * particular, DIGITAL shall not be liable for special, indirect, | |
52 | * consequential, or incidental damages or damages for | |
53 | * lost profits, loss of revenue or loss of use, whether such damages arise | |
54 | * in contract, | |
55 | * negligence, tort, under statute, in equity, at law or otherwise, even if | |
56 | * advised of the possibility of such damage. | |
c7de829c WD |
57 | * |
58 | */ | |
59 | ||
60 | /* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.14 1999/09/25 14:36:58 dawes Exp $ */ | |
61 | ||
62 | #if defined(__GNUC__) | |
63 | #if defined(linux) && (defined(__alpha__) || defined(__ia64__)) | |
64 | #undef inb | |
65 | #define inb _inb | |
66 | #undef inw | |
67 | #define inw _inw | |
68 | #undef inl | |
69 | #define inl _inl | |
70 | #undef outb | |
71 | #define outb(p,v) _outb((v),(p)) | |
72 | #undef outw | |
73 | #define outw(p,v) _outw((v),(p)) | |
74 | #undef outl | |
75 | #define outl(p,v) _outl((v),(p)) | |
76 | #else | |
77 | #if defined(__sparc__) | |
78 | #ifndef ASI_PL | |
79 | #define ASI_PL 0x88 | |
80 | #endif | |
81 | ||
82 | static __inline__ void | |
83 | outb(port, val) | |
84 | unsigned long port; | |
85 | char val; | |
86 | { | |
87 | __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
88 | } | |
89 | ||
90 | static __inline__ void | |
91 | outw(port, val) | |
92 | unsigned long port; | |
93 | char val; | |
94 | { | |
95 | __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
96 | } | |
97 | ||
98 | static __inline__ void | |
99 | outl(port, val) | |
100 | unsigned long port; | |
101 | char val; | |
102 | { | |
103 | __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
104 | } | |
105 | ||
106 | static __inline__ unsigned int | |
107 | inb(port) | |
108 | unsigned long port; | |
109 | { | |
110 | unsigned char ret; | |
111 | __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
112 | return ret; | |
113 | } | |
114 | ||
115 | static __inline__ unsigned int | |
116 | inw(port) | |
117 | unsigned long port; | |
118 | { | |
119 | unsigned char ret; | |
120 | __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
121 | return ret; | |
122 | } | |
123 | ||
124 | static __inline__ unsigned int | |
125 | inl(port) | |
126 | unsigned long port; | |
127 | { | |
128 | unsigned char ret; | |
129 | __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
130 | return ret; | |
131 | } | |
132 | #else | |
133 | #ifdef __arm32__ | |
134 | unsigned int IOPortBase; /* Memory mapped I/O port area */ | |
135 | ||
136 | static __inline__ void | |
137 | outb(port, val) | |
138 | short port; | |
139 | char val; | |
140 | { | |
141 | if ((unsigned short)port >= 0x400) return; | |
142 | ||
143 | *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; | |
144 | } | |
145 | ||
146 | static __inline__ void | |
147 | outw(port, val) | |
148 | short port; | |
149 | short val; | |
150 | { | |
151 | if ((unsigned short)port >= 0x400) return; | |
152 | ||
153 | *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; | |
154 | } | |
155 | ||
156 | static __inline__ void | |
157 | outl(port, val) | |
158 | short port; | |
159 | int val; | |
160 | { | |
161 | if ((unsigned short)port >= 0x400) return; | |
162 | ||
163 | *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; | |
164 | } | |
165 | ||
166 | static __inline__ unsigned int | |
167 | inb(port) | |
168 | short port; | |
169 | { | |
170 | if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
171 | ||
172 | return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); | |
173 | } | |
174 | ||
175 | static __inline__ unsigned int | |
176 | inw(port) | |
177 | short port; | |
178 | { | |
179 | if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
180 | ||
181 | return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); | |
182 | } | |
183 | ||
184 | static __inline__ unsigned int | |
185 | inl(port) | |
186 | short port; | |
187 | { | |
188 | if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
189 | ||
190 | return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); | |
191 | } | |
192 | #else /* __arm32__ */ | |
193 | #if defined(Lynx) && defined(__powerpc__) | |
194 | extern unsigned char *ioBase; | |
195 | ||
196 | static volatile void | |
197 | eieio() | |
198 | { | |
199 | __asm__ __volatile__ ("eieio"); | |
200 | } | |
201 | ||
202 | static void | |
203 | outb(port, value) | |
204 | short port; | |
205 | unsigned char value; | |
206 | { | |
207 | *(uchar *)(ioBase + port) = value; eieio(); | |
208 | } | |
209 | ||
210 | static void | |
211 | outw(port, value) | |
212 | short port; | |
213 | unsigned short value; | |
214 | { | |
215 | *(unsigned short *)(ioBase + port) = value; eieio(); | |
216 | } | |
217 | ||
218 | static void | |
219 | outl(port, value) | |
220 | short port; | |
221 | unsigned long value; | |
222 | { | |
223 | *(unsigned long *)(ioBase + port) = value; eieio(); | |
224 | } | |
225 | ||
226 | static unsigned char | |
227 | inb(port) | |
228 | short port; | |
229 | { | |
230 | unsigned char val; | |
231 | ||
232 | val = *((unsigned char *)(ioBase + port)); eieio(); | |
233 | return(val); | |
234 | } | |
235 | ||
236 | static unsigned short | |
237 | inw(port) | |
238 | short port; | |
239 | { | |
240 | unsigned short val; | |
241 | ||
242 | val = *((unsigned short *)(ioBase + port)); eieio(); | |
243 | return(val); | |
244 | } | |
245 | ||
246 | static unsigned long | |
247 | inl(port) | |
248 | short port; | |
249 | { | |
250 | unsigned long val; | |
251 | ||
252 | val = *((unsigned long *)(ioBase + port)); eieio(); | |
253 | return(val); | |
254 | } | |
255 | ||
256 | #else | |
257 | #if defined(__FreeBSD__) && defined(__alpha__) | |
258 | ||
259 | #include <sys/types.h> | |
260 | ||
261 | extern void outb(u_int32_t port, u_int8_t val); | |
262 | extern void outw(u_int32_t port, u_int16_t val); | |
263 | extern void outl(u_int32_t port, u_int32_t val); | |
264 | extern u_int8_t inb(u_int32_t port); | |
265 | extern u_int16_t inw(u_int32_t port); | |
266 | extern u_int32_t inl(u_int32_t port); | |
267 | ||
268 | #else | |
269 | #ifdef GCCUSESGAS | |
270 | static __inline__ void | |
271 | outb(port, val) | |
272 | short port; | |
273 | char val; | |
274 | { | |
275 | __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); | |
276 | } | |
277 | ||
278 | static __inline__ void | |
279 | outw(port, val) | |
280 | short port; | |
281 | short val; | |
282 | { | |
283 | __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); | |
284 | } | |
285 | ||
286 | static __inline__ void | |
287 | outl(port, val) | |
288 | short port; | |
289 | unsigned int val; | |
290 | { | |
291 | __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); | |
292 | } | |
293 | ||
294 | static __inline__ unsigned int | |
295 | inb(port) | |
296 | short port; | |
297 | { | |
298 | unsigned char ret; | |
299 | __asm__ __volatile__("inb %1,%0" : | |
300 | "=a" (ret) : | |
301 | "d" (port)); | |
302 | return ret; | |
303 | } | |
304 | ||
305 | static __inline__ unsigned int | |
306 | inw(port) | |
307 | short port; | |
308 | { | |
309 | unsigned short ret; | |
310 | __asm__ __volatile__("inw %1,%0" : | |
311 | "=a" (ret) : | |
312 | "d" (port)); | |
313 | return ret; | |
314 | } | |
315 | ||
316 | static __inline__ unsigned int | |
317 | inl(port) | |
318 | short port; | |
319 | { | |
320 | unsigned int ret; | |
321 | __asm__ __volatile__("inl %1,%0" : | |
322 | "=a" (ret) : | |
323 | "d" (port)); | |
324 | return ret; | |
325 | } | |
326 | ||
327 | #else /* GCCUSESGAS */ | |
328 | ||
329 | static __inline__ void | |
330 | outb(port, val) | |
331 | short port; | |
332 | char val; | |
333 | { | |
334 | __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); | |
335 | } | |
336 | ||
337 | static __inline__ void | |
338 | outw(port, val) | |
339 | short port; | |
340 | short val; | |
341 | { | |
342 | __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); | |
343 | } | |
344 | ||
345 | static __inline__ void | |
346 | outl(port, val) | |
347 | short port; | |
348 | unsigned int val; | |
349 | { | |
350 | __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); | |
351 | } | |
352 | ||
353 | static __inline__ unsigned int | |
354 | inb(port) | |
355 | short port; | |
356 | { | |
357 | unsigned int ret; | |
358 | __asm__ __volatile__("in%B0 (%1)" : | |
8bde7f77 WD |
359 | "=a" (ret) : |
360 | "d" (port)); | |
c7de829c WD |
361 | return ret; |
362 | } | |
363 | ||
364 | static __inline__ unsigned int | |
365 | inw(port) | |
366 | short port; | |
367 | { | |
368 | unsigned int ret; | |
369 | __asm__ __volatile__("in%W0 (%1)" : | |
8bde7f77 WD |
370 | "=a" (ret) : |
371 | "d" (port)); | |
c7de829c WD |
372 | return ret; |
373 | } | |
374 | ||
375 | static __inline__ unsigned int | |
376 | inl(port) | |
377 | short port; | |
378 | { | |
379 | unsigned int ret; | |
380 | __asm__ __volatile__("in%L0 (%1)" : | |
8bde7f77 WD |
381 | "=a" (ret) : |
382 | "d" (port)); | |
c7de829c WD |
383 | return ret; |
384 | } | |
385 | ||
386 | #endif /* GCCUSESGAS */ | |
387 | #endif /* Lynx && __powerpc__ */ | |
388 | #endif /* arm32 */ | |
389 | #endif /* linux && __sparc__ */ | |
390 | #endif /* linux && __alpha__ */ | |
391 | #endif /* __FreeBSD__ && __alpha__ */ | |
392 | ||
393 | #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__)) | |
394 | ||
395 | #define intr_disable() | |
396 | #define intr_enable() | |
397 | ||
8bde7f77 | 398 | #else |
c7de829c WD |
399 | |
400 | static __inline__ void | |
401 | intr_disable() | |
402 | { | |
403 | __asm__ __volatile__("cli"); | |
404 | } | |
405 | ||
406 | static __inline__ void | |
407 | intr_enable() | |
408 | { | |
409 | __asm__ __volatile__("sti"); | |
410 | } | |
411 | ||
412 | #endif /* else !linux && !__arm32__ */ | |
413 | ||
414 | #else /* __GNUC__ */ | |
415 | ||
416 | #if defined(_MINIX) && defined(_ACK) | |
417 | ||
418 | /* inb, outb, inw and outw are defined in the library */ | |
419 | /* ... but I've no idea if the same is true for inl & outl */ | |
420 | ||
421 | u8_t inb(U16_t); | |
422 | void outb(U16_t, U8_t); | |
423 | u16_t inw(U16_t); | |
424 | void outw(U16_t, U16_t); | |
425 | u32_t inl(U16_t); | |
426 | void outl(U16_t, U32_t); | |
427 | ||
428 | #else /* not _MINIX and _ACK */ | |
429 | ||
430 | # if defined(__STDC__) && (__STDC__ == 1) | |
431 | # ifndef NCR | |
432 | # define asm __asm | |
433 | # endif | |
434 | # endif | |
435 | # ifdef SVR4 | |
436 | # include <sys/types.h> | |
437 | # ifndef __USLC__ | |
438 | # define __USLC__ | |
439 | # endif | |
440 | # endif | |
441 | #ifndef SCO325 | |
442 | # include <sys/inline.h> | |
443 | #else | |
444 | # include "../common/scoasm.h" | |
445 | #endif | |
446 | #define intr_disable() asm("cli") | |
447 | #define intr_enable() asm("sti") | |
448 | ||
449 | #endif /* _MINIX and _ACK */ | |
450 | #endif /* __GNUC__ */ |