65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
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 *
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 *
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
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 *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * The above copyright notice and this permission notice shall be included in
65fea56f17cd614bc8908264df980a62e1931468vboxsync * all copies or substantial portions of the Software.
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
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 *
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 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef _COMPILER_H
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define _COMPILER_H
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__SUNPRO_C)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define DO_PROTOTYPES
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Map Sun compiler platform defines to gcc-style used in the code */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__amd64) && !defined(__amd64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __amd64__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__i386) && !defined(__i386__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __i386__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__sparc) && !defined(__sparc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __sparc__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__sparcv9) && !defined(__sparc64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __sparc64__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef _X_EXPORT
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <X11/Xfuncproto.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <pixman.h> /* for uint*_t types */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef __inline__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__GNUC__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* gcc has __inline__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__HIGHC__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __inline__ _Inline
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __inline__ /**/
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __inline__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef __inline
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__GNUC__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* gcc has __inline */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__HIGHC__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __inline _Inline
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __inline /**/
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __inline */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Support gcc's __FUNCTION__ for people using other compilers */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__GNUC__) && !defined(__FUNCTION__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __FUNCTION__ __func__ /* C99 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(NO_INLINE) || defined(DO_PROTOTYPES)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__arm__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync && !(defined(__alpha__) && defined(linux)) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync && !(defined(__ia64__) && defined(linux)) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inb(unsigned short);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inw(unsigned short);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inl(unsigned short);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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 int inb(unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inw(unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int inl(unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __SUNPRO_C
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__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__powerpc__) && !defined(__OpenBSD__)
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
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE || DO_PROTOTYPES */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef NO_INLINE
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __GNUC__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __i386__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __SSE__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __SSE2__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __alpha__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __amd64__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __ia64__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef __INTEL_COMPILER
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include "ia64intrin.h"
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() __mf()
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() __mf()
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __mips__
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* Note: sync instruction requires MIPS II instruction set */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() \
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__( \
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#define write_mem_barrier() mem_barrier()
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __powerpc__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(linux) && defined(__powerpc64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <linux/version.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <asm/memory.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* defined(linux) && defined(__powerpc64__) */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef eieio /* We deal with arch-specific eieio() routines above... */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* eieio */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() eieio()
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() eieio()
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined __sparc__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() /* XXX: nop for now */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() /* XXX: nop for now */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef mem_barrier
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() /* NOP */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef write_mem_barrier
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() /* NOP */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef NO_INLINE
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __GNUC__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Define some packed structures to use with unaligned accesses */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstruct __una_u64 {
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint64_t x __attribute__ ((packed));
65fea56f17cd614bc8908264df980a62e1931468vboxsync};
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstruct __una_u32 {
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint32_t x __attribute__ ((packed));
65fea56f17cd614bc8908264df980a62e1931468vboxsync};
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstruct __una_u16 {
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint16_t x __attribute__ ((packed));
65fea56f17cd614bc8908264df980a62e1931468vboxsync};
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Elemental unaligned loads */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint64_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldq_u(uint64_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u64 *ptr = (const struct __una_u64 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ptr->x;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint32_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldl_u(uint32_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u32 *ptr = (const struct __una_u32 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ptr->x;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint16_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldw_u(uint16_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync const struct __una_u16 *ptr = (const struct __una_u16 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ptr->x;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Elemental unaligned stores */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstq_u(uint64_t val, uint64_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync struct __una_u64 *ptr = (struct __una_u64 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync ptr->x = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstl_u(uint32_t val, uint32_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync struct __una_u32 *ptr = (struct __una_u32 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync ptr->x = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstw_u(uint16_t val, uint16_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync struct __una_u16 *ptr = (struct __una_u16 *) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync ptr->x = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !__GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <string.h> /* needed for memmove */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint64_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldq_u(uint64_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint64_t ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(&ret, p, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint32_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldl_u(uint32_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint32_t ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(&ret, p, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ uint16_t
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldw_u(uint16_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint16_t ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(&ret, p, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstq_u(uint64_t val, uint64_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint64_t tmp = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(p, &tmp, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstl_u(uint32_t val, uint32_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint32_t tmp = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(p, &tmp, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstw_u(uint16_t val, uint16_t * p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync uint16_t tmp = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync memmove(p, &tmp, sizeof(*p));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef NO_INLINE
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __GNUC__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef linux
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. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned long port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync _outb(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned long port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync _outw(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned long port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync _outl(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return _inb(port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return _inw(port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return _inl(port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* linux */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync && !defined(DO_PROTOTYPES)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__NetBSD__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <machine/pio.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __NetBSD__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <inttypes.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned short port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned short port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned short port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned char ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef ASI_PL
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define ASI_PL 0x88
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned long port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned long port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned long port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned long port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(port), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned char ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lduh [%1], %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("ld [%1], %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sth %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("st %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sth %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("st %0, [%1]": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr), "i"(ASI_PL));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __arm32__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define PORT_SIZE long
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define PORT_SIZE short
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned PORT_SIZE port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsync val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned PORT_SIZE port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsync val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned PORT_SIZE port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
65fea56f17cd614bc8908264df980a62e1931468vboxsync val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsync IOPortBase);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsync IOPortBase);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) +
65fea56f17cd614bc8908264df980a62e1931468vboxsync IOPortBase);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__mips__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef linux /* don't mess with other OSs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if X_BYTE_ORDER == X_BIG_ENDIAN
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lw %0, 0(%1)":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("sw %0, 0(%1)": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* !linux */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __mips__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef MAP_FAILED
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MAP_FAILED ((void *)-1)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT volatile unsigned char *ioBase;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync register unsigned char val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lbzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"b"(base), "r"(offset),
65fea56f17cd614bc8908264df980a62e1931468vboxsync "m"(*((volatile unsigned char *) base + offset)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync register unsigned short val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"b"(base), "r"(offset),
65fea56f17cd614bc8908264df980a62e1931468vboxsync "m"(*((volatile unsigned char *) base + offset)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync register unsigned short val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhbrx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"b"(base), "r"(offset),
65fea56f17cd614bc8908264df980a62e1931468vboxsync "m"(*((volatile unsigned char *) base + offset)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync register unsigned int val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lwzx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"b"(base), "r"(offset),
65fea56f17cd614bc8908264df980a62e1931468vboxsync "m"(*((volatile unsigned char *) base + offset)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync register unsigned int val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lwbrx %0,%1,%2\n\t" "eieio":"=r"(val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"b"(base), "r"(offset),
65fea56f17cd614bc8908264df980a62e1931468vboxsync "m"(*((volatile unsigned char *) base + offset)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync return val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__
65fea56f17cd614bc8908264df980a62e1931468vboxsync __volatile__("stbx %1,%2,%3\n\t":"=m"
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((volatile unsigned char *) base + offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "b"(base), "r"(offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__
65fea56f17cd614bc8908264df980a62e1931468vboxsync __volatile__("sthbrx %1,%2,%3\n\t":"=m"
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((volatile unsigned char *) base + offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "b"(base), "r"(offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__
65fea56f17cd614bc8908264df980a62e1931468vboxsync __volatile__("sthx %1,%2,%3\n\t":"=m"
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((volatile unsigned char *) base + offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "b"(base), "r"(offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__
65fea56f17cd614bc8908264df980a62e1931468vboxsync __volatile__("stwbrx %1,%2,%3\n\t":"=m"
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((volatile unsigned char *) base + offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "b"(base), "r"(offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__
65fea56f17cd614bc8908264df980a62e1931468vboxsync __volatile__("stwx %1,%2,%3\n\t":"=m"
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((volatile unsigned char *) base + offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "b"(base), "r"(offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB8(base, offset, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync eieio();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16Le(base, offset, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync eieio();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16Be(base, offset, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync eieio();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32Le(base, offset, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync eieio();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32Be(base, offset, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync eieio();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned short port, unsigned char value)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return;
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8((void *) ioBase, port, value);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned short port, unsigned short value)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return;
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Le((void *) ioBase, port, value);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned short port, unsigned int value)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return;
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Le((void *) ioBase, port, value);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio8((void *) ioBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio16Le((void *) ioBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (ioBase == MAP_FAILED)
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio32Le((void *) ioBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__arm__) && defined(__linux__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <sys/io.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf_outb(unsigned short port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync outb(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf_outw(unsigned short port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync outw(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf_outl(unsigned short port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync outl(val, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define outb xf_outb
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define outw xf_outw
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define outl xf_outl
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__nds32__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
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.
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define barrier() /* no barrier */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define PORT_SIZE long
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned char
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) ((unsigned char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lhi %0, [%1];\n\t" "wsbh %0, %0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned short
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) ((char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lwi %0, [%1];\n\t"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) ((unsigned char *) base + offset);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = ((unsigned long) base) + offset;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(NDS32_MMIO_SWAP)
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned PORT_SIZE port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8(IOPortBase, port, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned PORT_SIZE port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Swap(IOPortBase, port, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned PORT_SIZE port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Swap(IOPortBase, port, val);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio8(IOPortBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio16Swap(IOPortBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return xf86ReadMmio32Swap(IOPortBase, port);
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldq_u(unsigned long *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldl_u(unsigned int *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstq_u(unsigned long val, unsigned long *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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 :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstl_u(unsigned long val, unsigned int *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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 :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !NDS32_MMIO_SWAP */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned PORT_SIZE port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned char *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned PORT_SIZE port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned short *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned PORT_SIZE port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile unsigned int *) (((unsigned PORT_SIZE) (port))) = val;
65fea56f17cd614bc8908264df980a62e1931468vboxsync barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned PORT_SIZE port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldq_u(unsigned long *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned long
65fea56f17cd614bc8908264df980a62e1931468vboxsyncldl_u(unsigned int *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstq_u(unsigned long val, unsigned long *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstl_u(unsigned long val, unsigned int *p)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long addr = (unsigned long) p;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync :"r"(val), "r"(addr));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NDS32_MMIO_SWAP */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)) = (v)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define ldw_u(p) ((*(unsigned char *)(p)) | \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)<<8))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*((unsigned char *)(p)+1)) = ((v) >> 8)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define mem_barrier() /* XXX: nop for now */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define write_mem_barrier() /* XXX: nop for now */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* ix86 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__SUNPRO_C)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__) && !defined(__aarch64__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef GCCUSESGAS
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * If gcc uses gas rather than the native assembler, the syntax of these
65fea56f17cd614bc8908264df980a62e1931468vboxsync * inlines has to be different. DHD
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned short port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned short port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned short port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned char ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* GCCUSESGAS */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned short port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%B0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned short port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%W0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned short port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("out%L0 (%1)"::"a"(val), "d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned char ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%B0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned short ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%W0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ __volatile__("in%L0 (%1)":"=a"(ret):"d"(port));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync return ret;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* GCCUSESGAS */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutb(unsigned short port, unsigned char val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutw(unsigned short port, unsigned short val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncoutl(unsigned short port, unsigned int val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinb(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinw(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ unsigned int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncinl(unsigned short port)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync return 0;
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* FAKEIT */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __SUNPRO_C */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* ix86 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !GNUC */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(__STDC__) && (__STDC__ == 1)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef asm
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define asm __asm
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__SUNPRO_C)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <sys/inline.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if !defined(__HIGHC__) && !defined(__SUNPRO_C) || \
65fea56f17cd614bc8908264df980a62e1931468vboxsync defined(__USLC__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization outl
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization outw
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization outb
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization inl
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization inw
65fea56f17cd614bc8908264df980a62e1931468vboxsync#pragma asm partial_optimization inb
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __GNUC__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* NO_INLINE */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __alpha__
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* entry points for Mmio memory access routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio8) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio16) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef STANDALONE_MMIO
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int (*xf86ReadMmio32) (void *, unsigned long);
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Some DRI 3D drivers need MMIO_IN32. */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ int
65fea56f17cd614bc8908264df980a62e1931468vboxsyncxf86ReadMmio32(void *Base, unsigned long Offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync mem_barrier();
65fea56f17cd614bc8908264df980a62e1931468vboxsync return *(volatile unsigned int *) ((unsigned long) Base + (Offset));
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
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 *,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
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#ifndef STANDALONE_MMIO
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync do { \
65fea56f17cd614bc8908264df980a62e1931468vboxsync write_mem_barrier(); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync } while (0)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*xf86WriteMmio8)((CARD8)(val), base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*xf86WriteMmio16)((CARD16)(val), base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync MMIO_OUT32(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__powerpc__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync /*
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 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB8(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(PPC_MMIO_IS_BE) /* No byteswapping */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Be(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Be(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
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#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Le(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Le(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Be(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__sparc__) || defined(sparc) || defined(__sparc)
65fea56f17cd614bc8908264df980a62e1931468vboxsync /*
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 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8NB(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Be(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Be(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
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#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Le(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Le(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Be(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#elif defined(__nds32__)
65fea56f17cd614bc8908264df980a62e1931468vboxsync /*
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 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio8(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB8(base, offset, (CARD8)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined(NDS32_MMIO_SWAP) /* byteswapping */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16Swap(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32Swap(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
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#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio16(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB16(base, offset, (CARD16)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_ONB32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmioNB32(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync xf86WriteMmio32(base, offset, (CARD32)(val))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef N1213_HC /* for NDS32 N1213 hardcore */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncnds32_flush_icache(char *addr)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ volatile ("isync %0;"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "msync;"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "isb;"
65fea56f17cd614bc8908264df980a62e1931468vboxsync "cctl %0,L1I_VA_INVAL;" "isb;"::"r" (addr):"memory");
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else
65fea56f17cd614bc8908264df980a62e1931468vboxsyncstatic __inline__ void
65fea56f17cd614bc8908264df980a62e1931468vboxsyncnds32_flush_icache(char *addr)
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync __asm__ volatile ("isync %0;" "isb;"::"r" (addr):"memory");
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#else /* !__alpha__ && !__powerpc__ && !__sparc__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN8(base, offset) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN16(base, offset) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_IN32(base, offset) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT8(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT16(base, offset, val) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_OUT32(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
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* __alpha__ */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
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 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef __alpha__
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
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* _COMPILER_H */