$NetBSD: patch-ab,v 1.4 2008/08/02 18:32:15 dholland Exp $ Add NetBSD and Solaris platforms Add inb() and outb() from XFree86 sources. Add NetBSD/x86_64 support. --- rio.cpp.orig 1999-06-11 12:26:46.000000000 -0400 +++ rio.cpp 2008-08-02 14:16:07.000000000 -0400 @@ -109,11 +109,101 @@ #define CLOCK_SECOND ((int)CLOCKS_PER_SEC) #define DELETEARRAY delete +#elif defined(__NetBSD__) + // NetBSD/i386,amd64 g++ + #include + #include + #include + //#include + #define OUTPORT(p,v) outb( p, v ) + #define INPORT(p) inb( p ) + #define CLOCK_SECOND CLOCKS_PER_SEC + #define DELETEARRAY delete[] + +#elif defined(__sun__) && defined(__svr4__) + // Solaris/i386 g++ + #include + #include + #include + #include + #include + #include + #define OUTPORT(p,v) outb( p, v ) + #define INPORT(p) inb( p ) + #define CLOCK_SECOND CLOCKS_PER_SEC + #define DELETEARRAY delete[] + #else // not supported #error ! ! compiler/platform not supported ! ! #endif +#if defined(__NetBSD__) +/* copied from the XFree86 sources */ +/* xc/programs/Xserver/hw/xfree86/common/compiler.h */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.4 1998/10/18 20:42:10 hohndel Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */ +/* also hacked by agc to do i386_iopl, and by dholland for x86_64_iopl */ +static int ports_enabled; + +static __inline__ unsigned int +inb(unsigned short int port) +{ + unsigned char ret; + + if (!ports_enabled) { +#ifdef __i386__ + i386_iopl(1); +#endif +#ifdef __x86_64__ + x86_64_iopl(1); +#endif + ports_enabled = 1; + } + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ void +outb(unsigned short int port, unsigned char val) +{ + if (!ports_enabled) { +#ifdef __i386__ + i386_iopl(1); +#endif +#ifdef __x86_64__ + x86_64_iopl(1); +#endif + ports_enabled = 1; + } + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} +#endif + // port offset constants #define OFFSET_PORT_DATA 0 #define OFFSET_PORT_STATUS 1