65fea56f17cd614bc8908264df980a62e1931468vboxsync * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Permission to use, copy, modify, distribute, and sell this software and its
65fea56f17cd614bc8908264df980a62e1931468vboxsync * documentation for any purpose is hereby granted without fee, provided that
65fea56f17cd614bc8908264df980a62e1931468vboxsync * the above copyright notice appear in all copies and that both that
65fea56f17cd614bc8908264df980a62e1931468vboxsync * copyright notice and this permission notice appear in supporting
65fea56f17cd614bc8908264df980a62e1931468vboxsync * documentation, and that the name of Thomas Roell not be used in
65fea56f17cd614bc8908264df980a62e1931468vboxsync * advertising or publicity pertaining to distribution of the software without
65fea56f17cd614bc8908264df980a62e1931468vboxsync * specific, written prior permission. Thomas Roell makes no representations
65fea56f17cd614bc8908264df980a62e1931468vboxsync * about the suitability of this software for any purpose. It is provided
65fea56f17cd614bc8908264df980a62e1931468vboxsync * "as is" without express or implied warranty.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
65fea56f17cd614bc8908264df980a62e1931468vboxsync * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
65fea56f17cd614bc8908264df980a62e1931468vboxsync * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65fea56f17cd614bc8908264df980a62e1931468vboxsync * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65fea56f17cd614bc8908264df980a62e1931468vboxsync * PERFORMANCE OF THIS SOFTWARE.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Permission is hereby granted, free of charge, to any person obtaining a
65fea56f17cd614bc8908264df980a62e1931468vboxsync * copy of this software and associated documentation files (the "Software"),
65fea56f17cd614bc8908264df980a62e1931468vboxsync * to deal in the Software without restriction, including without limitation
65fea56f17cd614bc8908264df980a62e1931468vboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * and/or sell copies of the Software, and to permit persons to whom the
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Software is furnished to do so, subject to the following conditions:
65fea56f17cd614bc8908264df980a62e1931468vboxsync * The above copyright notice and this permission notice shall be included in
65fea56f17cd614bc8908264df980a62e1931468vboxsync * all copies or substantial portions of the Software.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65fea56f17cd614bc8908264df980a62e1931468vboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
65fea56f17cd614bc8908264df980a62e1931468vboxsync * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
65fea56f17cd614bc8908264df980a62e1931468vboxsync * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
65fea56f17cd614bc8908264df980a62e1931468vboxsync * OTHER DEALINGS IN THE SOFTWARE.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Except as contained in this notice, the name of the copyright holder(s)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * and author(s) shall not be used in advertising or otherwise to promote
65fea56f17cd614bc8908264df980a62e1931468vboxsync * the sale, use or other dealings in this Software without prior written
65fea56f17cd614bc8908264df980a62e1931468vboxsync * authorization from the copyright holder(s) and author(s).
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Map Sun compiler platform defines to gcc-style used in the code */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* gcc has __inline__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __inline__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* gcc has __inline */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __inline */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Support gcc's __FUNCTION__ for people using other compilers */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__arm__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outb(unsigned short, unsigned char);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outw(unsigned short, unsigned short);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outl(unsigned short, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* __sparc__, __arm32__, __alpha__, __nds32__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outb(unsigned long, unsigned char);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outw(unsigned long, unsigned short);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outl(unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned char xf86ReadMmio8 (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned short xf86ReadMmio16Be (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned short xf86ReadMmio16Le (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int xf86ReadMmio32Be (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int xf86ReadMmio32Le (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio8 (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio16Be (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio16Le (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio32Be (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio8NB (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio16BeNB (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio16LeNB (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio32BeNB (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86WriteMmio32LeNB (void *, unsigned long, unsigned int);
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* _SUNPRO_C */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __arm__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern unsigned long ldq_u(unsigned long *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern unsigned long ldl_u(unsigned int *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern unsigned long ldw_u(unsigned short *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void stq_u(unsigned long, unsigned long *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void stl_u(unsigned long, unsigned int *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void stw_u(unsigned long, unsigned short *);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void mem_barrier(void);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void write_mem_barrier(void);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void stl_brx(unsigned long, volatile unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern void stw_brx(unsigned short, volatile unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern unsigned long ldl_brx(volatile unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern unsigned short ldw_brx(volatile unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __powerpc__ && !__OpenBSD */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE || DO_PROTOTYPES */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* Note: sync instruction requires MIPS II instruction set */
65fea56f17cd614bc8908264df980a62e1931468vboxsync ".set push\n\t" \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ".set noreorder\n\t" \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ".set mips2\n\t" \
65fea56f17cd614bc8908264df980a62e1931468vboxsync "sync\n\t" \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ".set pop" \
65fea56f17cd614bc8908264df980a62e1931468vboxsync : /* no output */ \
65fea56f17cd614bc8908264df980a62e1931468vboxsync : /* no input */ \
65fea56f17cd614bc8908264df980a62e1931468vboxsync : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* defined(linux) && defined(__powerpc64__) */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef eieio /* We deal with arch-specific eieio() routines above... */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* eieio */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Define some packed structures to use with unaligned accesses */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Elemental unaligned loads */
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u64 *ptr = (const struct __una_u64 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u32 *ptr = (const struct __una_u32 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u16 *ptr = (const struct __una_u16 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Elemental unaligned stores */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !__GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* note that the appropriate setup via "ioperm" needs to be done */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* *before* any inx/outx is done. */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void _outb(unsigned char val, unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void _outw(unsigned short val, unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void _outl(unsigned int val, unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int _inb(unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int _inw(unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int _inl(unsigned long port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* linux */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* inx/outx routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* note that the appropriate setup via "ioperm" needs to be done */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* *before* any inx/outx is done. */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outb(unsigned int port, unsigned char val);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outw(unsigned int port, unsigned short val);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void outl(unsigned int port, unsigned int val);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned char inb(unsigned int port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned short inw(unsigned int port);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inl(unsigned int port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __NetBSD__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sth %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("st %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sth %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("st %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
65fea56f17cd614bc8908264df980a62e1931468vboxsync_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sw %0, 0(%1)": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* !linux */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __mips__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lbzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhbrx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lwzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lwbrx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* for Linux on ARM, we use the LIBC inx/outx routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* note that the appropriate setup via "ioperm" needs to be done */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* *before* any inx/outx is done. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Assume all port access are aligned. We need to revise this implementation
65fea56f17cd614bc8908264df980a62e1931468vboxsync * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and
65fea56f17cd614bc8908264df980a62e1931468vboxsync * stw_u, they are assumed unaligned.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) ((unsigned char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhi %0, [%1];\n\t" "wsbh %0, %0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) ((char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) ((unsigned char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !NDS32_MMIO_SWAP */
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NDS32_MMIO_SWAP */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)) = (v)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* ix86 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__) && !defined(__aarch64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * If gcc uses gas rather than the native assembler, the syntax of these
65fea56f17cd614bc8908264df980a62e1931468vboxsync * inlines has to be different. DHD
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* GCCUSESGAS */
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%B0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%W0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%L0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%B0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%W0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%L0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* GCCUSESGAS */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* FAKEIT */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __SUNPRO_C */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* ix86 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !GNUC */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__HIGHC__) && !defined(__SUNPRO_C) || \
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* entry points for Mmio memory access routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio8) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio16) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio32) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Some DRI 3D drivers need MMIO_IN32. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) ((unsigned long) Base + (Offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmio8) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmio16) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmio32) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmioNB8) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmioNB16) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void (*xf86WriteMmioNB32) (int, void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Some macros to hide the system dependencies for MMIO accesses */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Changed to kill noise generated by gcc's -Wcast-align */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync } while (0)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * we provide byteswapping and no byteswapping functions here
65fea56f17cd614bc8908264df980a62e1931468vboxsync * with byteswapping as default,
65fea56f17cd614bc8908264df980a62e1931468vboxsync * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* byteswapping is the default */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__sparc__) || defined(sparc) || defined(__sparc)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Like powerpc, we provide byteswapping and no byteswapping functions
65fea56f17cd614bc8908264df980a62e1931468vboxsync * here with byteswapping as default, drivers that don't need byteswapping
65fea56f17cd614bc8908264df980a62e1931468vboxsync * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
65fea56f17cd614bc8908264df980a62e1931468vboxsync * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
65fea56f17cd614bc8908264df980a62e1931468vboxsync * of drivers?).
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* byteswapping is the default */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * we provide byteswapping and no byteswapping functions here
65fea56f17cd614bc8908264df980a62e1931468vboxsync * with no byteswapping as default; when endianness of CPU core
65fea56f17cd614bc8908264df980a62e1931468vboxsync * and I/O devices don't match, byte swapping is necessary
65fea56f17cd614bc8908264df980a62e1931468vboxsync * drivers that need byteswapping should define NDS32_MMIO_SWAP
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* no byteswapping is the default */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync "cctl %0,L1I_VA_INVAL;" "isb;"::"r" (addr):"memory");
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ volatile ("isync %0;" "isb;"::"r" (addr):"memory");
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !__alpha__ && !__powerpc__ && !__sparc__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __alpha__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync * With Intel, the version in os-support/misc/SlowBcopy.s is used.
65fea56f17cd614bc8908264df980a62e1931468vboxsync * This avoids port I/O during the copy (which causes problems with
65fea56f17cd614bc8908264df980a62e1931468vboxsync * some hardware).
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* __alpha__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __alpha__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* _COMPILER_H */