Index: config/cf/Imake.cf =================================================================== RCS file: /cvs/xorg/xc/config/cf/Imake.cf,v retrieving revision 1.2 diff -u -r1.2 Imake.cf --- config/cf/Imake.cf 23 Apr 2004 18:41:58 -0000 1.2 +++ config/cf/Imake.cf 18 Jul 2004 16:47:54 -0000 @@ -146,6 +146,12 @@ # undef __alpha__ # undef alpha # endif +# if defined(__amd64__) || defined(__x86_64__) +# define AMD64Architecture +# undef __amd64__ +# undef __x86_64__ +# undef amd64 +# endif # if defined(__mc68020__) || defined(mc68020) # define Mc68020Architecture # if defined(amiga) Index: config/cf/OpenBSD.cf =================================================================== RCS file: /cvs/xorg/xc/config/cf/OpenBSD.cf,v retrieving revision 1.4 diff -u -r1.4 OpenBSD.cf --- config/cf/OpenBSD.cf 16 Jun 2004 09:46:14 -0000 1.4 +++ config/cf/OpenBSD.cf 18 Jul 2004 16:47:55 -0000 @@ -432,6 +432,45 @@ #endif /* AlphaArchitecture */ +/* + * Definitions for the AMD64 architecture + */ +#ifdef AMD64Architecture + +# define HasWeakSymbols YES +# define HasSharedLibraries YES +# define HasDlopen YES + +# define XF86Server YES + +# ifndef DoLoadableServer +# define DoLoadableServer NO +# endif + +# ifndef HasNetBSDApertureDriver +# define HasNetBSDApertureDriver YES +# endif + +# define HasAgpGart YES + +# define ServerExtraSysLibs -lamd64 +# define ServerExtraDefines GccGasOption -D_XSERVER64 XFree86ServerDefines + + +# ifndef XFree86ConsoleDefines +# define XFree86ConsoleDefines -DWSCONS_SUPPORT -DPCVT_SUPPORT +# endif + +# ifndef HasMMXSupport +# define HasMMXSupport YES +# endif + +# ifndef HasX86Support +# define HasX86Support YES +# endif +# include + +#endif /* AMD64Architecture */ /* * Definitions for the i386 architecture Index: programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v retrieving revision 1.2 diff -u -r1.2 xf86_OSlib.h --- programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h 23 Apr 2004 19:54:07 -0000 1.2 +++ programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h 18 Jul 2004 16:48:17 -0000 @@ -532,7 +532,7 @@ # endif # endif /* __bsdi__ */ -#ifdef USE_I386_IOPL +#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) #include #endif Index: programs/Xserver/hw/xfree86/os-support/bsd/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v retrieving revision 1.3 diff -u -r1.3 Imakefile --- programs/Xserver/hw/xfree86/os-support/bsd/Imakefile 16 Jun 2004 09:39:14 -0000 1.3 +++ programs/Xserver/hw/xfree86/os-support/bsd/Imakefile 18 Jul 2004 16:48:17 -0000 @@ -41,6 +41,8 @@ #elif defined(OpenBSDArchitecture) # if defined(i386Architecture) IOPERMDEFINES = -DUSE_I386_IOPL +# elif defined(AMD64Architecture) + IOPERMDEFINES = -DUSE_AMD64_IOPL # else IOPERM_SRC = ioperm_noop.c IOPERM_OBJ = ioperm_noop.o Index: programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c,v retrieving revision 1.2 diff -u -r1.2 i386_video.c --- programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c 23 Apr 2004 19:54:07 -0000 1.2 +++ programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c 18 Jul 2004 16:48:19 -0000 @@ -46,6 +46,11 @@ #include #endif +#if defined(__OpenBSD__) && defined(__amd64__) +#include +#include +#endif + #include "xf86_OSlib.h" #include "xf86OSpriv.h" @@ -94,7 +99,11 @@ MessageType); static void NetBSDundoWC(int, pointer); #endif - +#if defined(__amd64__) && defined(__OpenBSD__) +static pointer amd64setWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void amd64undoWC(int, pointer); +#endif /* * Check if /dev/mem can be mmap'd. If it can't print a warning when @@ -206,6 +215,10 @@ pVidMem->setWC = NetBSDsetWC; pVidMem->undoWC = NetBSDundoWC; #endif +#if defined(__amd64__) && defined(__OpenBSD__) + pVidMem->setWC = amd64setWC; + pVidMem->undoWC = amd64undoWC; +#endif pVidMem->initialised = TRUE; } @@ -311,7 +324,6 @@ return(Len); } - #ifdef USE_I386_IOPL /***************************************************************************/ /* I/O Permissions section */ @@ -354,6 +366,51 @@ #endif /* USE_I386_IOPL */ +#ifdef USE_AMD64_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +void +xf86EnableIO() +{ + if (ExtendedEnabled) + return; + + if (amd64_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + FatalError("%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + FatalError("%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + } + ExtendedEnabled = TRUE; + + return; +} + +void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + if (amd64_iopl(FALSE) == 0) { + ExtendedEnabled = FALSE; + } + /* Otherwise, the X server has revoqued its root uid, + and thus cannot give up IO privileges any more */ + + return; +} + +#endif /* USE_AMD64_IOPL */ + #ifdef USE_DEV_IO static int IoFd = -1; @@ -471,7 +528,6 @@ } #endif - #ifdef HAS_MTRR_SUPPORT /* memory range (MTRR) support for FreeBSD */ @@ -879,3 +935,55 @@ xfree(mtrrp); } #endif + +#if defined(__OpenBSD__) && defined(__amd64__) +static pointer +amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (amd64_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +amd64undoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + amd64_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif /* OpenBSD/amd64 */ +