1 /* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */
3 * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org>
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
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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,
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
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.
30 * Digital Equipment Corporation. All rights reserved.
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
37 * 1) Any source code used, modified or distributed must reproduce and retain
38 * this copyright notice and list of conditions as they appear in the source
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
45 * prior written permission of Digital Equipment Corporation.
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
55 * negligence, tort, under statute, in equity, at law or otherwise, even if
56 * advised of the possibility of such damage.
60 /* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.14 1999/09/25 14:36:58 dawes Exp $ */
63 #if defined(linux) && (defined(__alpha__) || defined(__ia64__))
71 #define outb(p,v) _outb((v),(p))
73 #define outw(p,v) _outw((v),(p))
75 #define outl(p,v) _outl((v),(p))
77 #if defined(__sparc__)
82 static __inline__ void
87 __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
90 static __inline__ void
95 __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
98 static __inline__ void
103 __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
106 static __inline__ unsigned int
111 __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
115 static __inline__ unsigned int
120 __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
124 static __inline__ unsigned int
129 __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
134 unsigned int IOPortBase; /* Memory mapped I/O port area */
136 static __inline__ void
141 if ((unsigned short)port >= 0x400) return;
143 *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
146 static __inline__ void
151 if ((unsigned short)port >= 0x400) return;
153 *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
156 static __inline__ void
161 if ((unsigned short)port >= 0x400) return;
163 *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
166 static __inline__ unsigned int
170 if ((unsigned short)port >= 0x400) return((unsigned int)-1);
172 return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
175 static __inline__ unsigned int
179 if ((unsigned short)port >= 0x400) return((unsigned int)-1);
181 return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
184 static __inline__ unsigned int
188 if ((unsigned short)port >= 0x400) return((unsigned int)-1);
190 return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
192 #else /* __arm32__ */
193 #if defined(Lynx) && defined(__powerpc__)
194 extern unsigned char *ioBase;
199 __asm__ __volatile__ ("eieio");
207 *(uchar *)(ioBase + port) = value; eieio();
213 unsigned short value;
215 *(unsigned short *)(ioBase + port) = value; eieio();
223 *(unsigned long *)(ioBase + port) = value; eieio();
232 val = *((unsigned char *)(ioBase + port)); eieio();
236 static unsigned short
242 val = *((unsigned short *)(ioBase + port)); eieio();
252 val = *((unsigned long *)(ioBase + port)); eieio();
257 #if defined(__FreeBSD__) && defined(__alpha__)
259 #include <sys/types.h>
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);
270 static __inline__ void
275 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
278 static __inline__ void
283 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
286 static __inline__ void
291 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
294 static __inline__ unsigned int
299 __asm__ __volatile__("inb %1,%0" :
305 static __inline__ unsigned int
310 __asm__ __volatile__("inw %1,%0" :
316 static __inline__ unsigned int
321 __asm__ __volatile__("inl %1,%0" :
327 #else /* GCCUSESGAS */
329 static __inline__ void
334 __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
337 static __inline__ void
342 __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
345 static __inline__ void
350 __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
353 static __inline__ unsigned int
358 __asm__ __volatile__("in%B0 (%1)" :
364 static __inline__ unsigned int
369 __asm__ __volatile__("in%W0 (%1)" :
375 static __inline__ unsigned int
380 __asm__ __volatile__("in%L0 (%1)" :
386 #endif /* GCCUSESGAS */
387 #endif /* Lynx && __powerpc__ */
389 #endif /* linux && __sparc__ */
390 #endif /* linux && __alpha__ */
391 #endif /* __FreeBSD__ && __alpha__ */
393 #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__))
395 #define intr_disable()
396 #define intr_enable()
400 static __inline__ void
403 __asm__ __volatile__("cli");
406 static __inline__ void
409 __asm__ __volatile__("sti");
412 #endif /* else !linux && !__arm32__ */
416 #if defined(_MINIX) && defined(_ACK)
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 */
422 void outb(U16_t, U8_t);
424 void outw(U16_t, U16_t);
426 void outl(U16_t, U32_t);
428 #else /* not _MINIX and _ACK */
430 # if defined(__STDC__) && (__STDC__ == 1)
436 # include <sys/types.h>
442 # include <sys/inline.h>
444 # include "../common/scoasm.h"
446 #define intr_disable() asm("cli")
447 #define intr_enable() asm("sti")
449 #endif /* _MINIX and _ACK */
450 #endif /* __GNUC__ */