]>
git.ipfire.org Git - people/trikolon/ipfire-2.x.git/blob - src/hwinfo/src/int10/AsmMacros.h
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 $ */
65 #if defined(linux) && (defined(__alpha__) || defined(__ia64__))
76 static __inline__
unsigned int inb(unsigned long int p
) { return _inb(p
); };
77 static __inline__
unsigned int inw(unsigned long int p
) { return _inw(p
); };
78 static __inline__
unsigned int inl(unsigned long int p
) { return _inl(p
); };
79 static __inline__
void outb(unsigned long int p
, unsigned char v
) { _outb(v
,p
); };
80 static __inline__
void outw(unsigned long int p
, unsigned short v
) { _outw(v
,p
); };
81 static __inline__
void outl(unsigned long int p
, unsigned int v
) { _outl(v
,p
); };
85 #if defined(__sparc__)
90 static __inline__
void
95 __asm__
__volatile__("stba %0, [%1] %2" : : "r" (val
), "r" (port
), "i" (ASI_PL
));
98 static __inline__
void
103 __asm__
__volatile__("stha %0, [%1] %2" : : "r" (val
), "r" (port
), "i" (ASI_PL
));
106 static __inline__
void
111 __asm__
__volatile__("sta %0, [%1] %2" : : "r" (val
), "r" (port
), "i" (ASI_PL
));
114 static __inline__
unsigned int
119 __asm__
__volatile__("lduba [%1] %2, %0" : "=r" (ret
) : "r" (port
), "i" (ASI_PL
));
123 static __inline__
unsigned int
128 __asm__
__volatile__("lduha [%1] %2, %0" : "=r" (ret
) : "r" (port
), "i" (ASI_PL
));
132 static __inline__
unsigned int
137 __asm__
__volatile__("lda [%1] %2, %0" : "=r" (ret
) : "r" (port
), "i" (ASI_PL
));
142 unsigned int IOPortBase
; /* Memory mapped I/O port area */
144 static __inline__
void
149 if ((unsigned short)port
>= 0x400) return;
151 *(volatile unsigned char*)(((unsigned short)(port
))+IOPortBase
) = val
;
154 static __inline__
void
159 if ((unsigned short)port
>= 0x400) return;
161 *(volatile unsigned short*)(((unsigned short)(port
))+IOPortBase
) = val
;
164 static __inline__
void
169 if ((unsigned short)port
>= 0x400) return;
171 *(volatile unsigned long*)(((unsigned short)(port
))+IOPortBase
) = val
;
174 static __inline__
unsigned int
178 if ((unsigned short)port
>= 0x400) return((unsigned int)-1);
180 return(*(volatile unsigned char*)(((unsigned short)(port
))+IOPortBase
));
183 static __inline__
unsigned int
187 if ((unsigned short)port
>= 0x400) return((unsigned int)-1);
189 return(*(volatile unsigned short*)(((unsigned short)(port
))+IOPortBase
));
192 static __inline__
unsigned int
196 if ((unsigned short)port
>= 0x400) return((unsigned int)-1);
198 return(*(volatile unsigned long*)(((unsigned short)(port
))+IOPortBase
));
200 #else /* __arm32__ */
201 #if defined(Lynx) && defined(__powerpc__)
202 extern unsigned char *ioBase
;
207 __asm__
__volatile__ ("eieio");
215 *(uchar
*)(ioBase
+ port
) = value
; eieio();
221 unsigned short value
;
223 *(unsigned short *)(ioBase
+ port
) = value
; eieio();
231 *(unsigned long *)(ioBase
+ port
) = value
; eieio();
240 val
= *((unsigned char *)(ioBase
+ port
)); eieio();
244 static unsigned short
250 val
= *((unsigned short *)(ioBase
+ port
)); eieio();
260 val
= *((unsigned long *)(ioBase
+ port
)); eieio();
265 #if defined(__FreeBSD__) && defined(__alpha__)
267 #include <sys/types.h>
269 extern void outb(u_int32_t port
, u_int8_t val
);
270 extern void outw(u_int32_t port
, u_int16_t val
);
271 extern void outl(u_int32_t port
, u_int32_t val
);
272 extern u_int8_t
inb(u_int32_t port
);
273 extern u_int16_t
inw(u_int32_t port
);
274 extern u_int32_t
inl(u_int32_t port
);
278 static __inline__
void
283 __asm__
__volatile__("outb %0,%1" : :"a" (val
), "d" (port
));
286 static __inline__
void
291 __asm__
__volatile__("outw %0,%1" : :"a" (val
), "d" (port
));
294 static __inline__
void
299 __asm__
__volatile__("outl %0,%1" : :"a" (val
), "d" (port
));
302 static __inline__
unsigned int
307 __asm__
__volatile__("inb %1,%0" :
313 static __inline__
unsigned int
318 __asm__
__volatile__("inw %1,%0" :
324 static __inline__
unsigned int
329 __asm__
__volatile__("inl %1,%0" :
335 #else /* GCCUSESGAS */
337 static __inline__
void
342 __asm__
__volatile__("out%B0 (%1)" : :"a" (val
), "d" (port
));
345 static __inline__
void
350 __asm__
__volatile__("out%W0 (%1)" : :"a" (val
), "d" (port
));
353 static __inline__
void
358 __asm__
__volatile__("out%L0 (%1)" : :"a" (val
), "d" (port
));
361 static __inline__
unsigned int
366 __asm__
__volatile__("in%B0 (%1)" :
372 static __inline__
unsigned int
377 __asm__
__volatile__("in%W0 (%1)" :
383 static __inline__
unsigned int
388 __asm__
__volatile__("in%L0 (%1)" :
394 #endif /* GCCUSESGAS */
395 #endif /* Lynx && __powerpc__ */
397 #endif /* linux && __sparc__ */
398 #endif /* linux && __alpha__ */
399 #endif /* __FreeBSD__ && __alpha__ */
401 #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__))
403 #define intr_disable()
404 #define intr_enable()
408 static __inline__
void
411 __asm__
__volatile__("cli");
414 static __inline__
void
417 __asm__
__volatile__("sti");
420 #endif /* else !linux && !__arm32__ */
424 #if defined(_MINIX) && defined(_ACK)
426 /* inb, outb, inw and outw are defined in the library */
427 /* ... but I've no idea if the same is true for inl & outl */
430 void outb(U16_t
, U8_t
);
432 void outw(U16_t
, U16_t
);
434 void outl(U16_t
, U32_t
);
436 #else /* not _MINIX and _ACK */
438 # if defined(__STDC__) && (__STDC__ == 1)
444 # include <sys/types.h>
450 # include <sys/inline.h>
452 # include "../common/scoasm.h"
454 #define intr_disable() asm("cli")
455 #define intr_enable() asm("sti")
457 #endif /* _MINIX and _ACK */
458 #endif /* __GNUC__ */