Bugzilla #884: OpenBSD/amd64 support.
This commit is contained in:
parent
cc3e0173d9
commit
5fdff8b95e
|
@ -1,4 +1,4 @@
|
||||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c,v 1.3 2003/03/14 13:46:03 tsi Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c,v 1.4 2003/09/24 02:43:34 dawes Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
|
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
|
||||||
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
|
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
|
||||||
|
@ -46,6 +46,11 @@
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__) && defined(__amd64__)
|
||||||
|
#include <machine/mtrr.h>
|
||||||
|
#include <machine/sysarch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xf86_OSlib.h"
|
#include "xf86_OSlib.h"
|
||||||
#include "xf86OSpriv.h"
|
#include "xf86OSpriv.h"
|
||||||
|
|
||||||
|
@ -62,11 +67,11 @@
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
|
#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
|
||||||
"\tin /etc/sysctl.conf and reboot your machine\n" \
|
"\tin /etc/sysctl.conf and reboot your machine\n" \
|
||||||
"\trefer to xf86(4) for details\n"
|
"\trefer to xf86(4) for details"
|
||||||
#define SYSCTL_MSG2 \
|
#define SYSCTL_MSG2 \
|
||||||
"Check that you have set 'machdep.allowaperture=2'\n" \
|
"Check that you have set 'machdep.allowaperture=2'\n" \
|
||||||
"\tin /etc/sysctl.conf and reboot your machine\n" \
|
"\tin /etc/sysctl.conf and reboot your machine\n" \
|
||||||
"\trefer to xf86(4) for details\n"
|
"\trefer to xf86(4) for details"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -94,7 +99,11 @@ static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
|
||||||
MessageType);
|
MessageType);
|
||||||
static void NetBSDundoWC(int, pointer);
|
static void NetBSDundoWC(int, pointer);
|
||||||
#endif
|
#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
|
* Check if /dev/mem can be mmap'd. If it can't print a warning when
|
||||||
|
@ -205,6 +214,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
|
||||||
#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
|
#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
|
||||||
pVidMem->setWC = NetBSDsetWC;
|
pVidMem->setWC = NetBSDsetWC;
|
||||||
pVidMem->undoWC = NetBSDundoWC;
|
pVidMem->undoWC = NetBSDundoWC;
|
||||||
|
#endif
|
||||||
|
#if defined(__amd64__) && defined(__OpenBSD__)
|
||||||
|
pVidMem->setWC = amd64setWC;
|
||||||
|
pVidMem->undoWC = amd64undoWC;
|
||||||
#endif
|
#endif
|
||||||
pVidMem->initialised = TRUE;
|
pVidMem->initialised = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +233,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
|
||||||
{
|
{
|
||||||
if (devMemFd < 0)
|
if (devMemFd < 0)
|
||||||
{
|
{
|
||||||
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
|
FatalError("xf86MapVidMem: failed to open %s (%s)",
|
||||||
DEV_MEM, strerror(errno));
|
DEV_MEM, strerror(errno));
|
||||||
}
|
}
|
||||||
base = mmap((caddr_t)0, Size,
|
base = mmap((caddr_t)0, Size,
|
||||||
|
@ -229,7 +242,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
|
||||||
MAP_FLAGS, devMemFd, (off_t)Base);
|
MAP_FLAGS, devMemFd, (off_t)Base);
|
||||||
if (base == MAP_FAILED)
|
if (base == MAP_FAILED)
|
||||||
{
|
{
|
||||||
FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
|
FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
|
||||||
"xf86MapVidMem", DEV_MEM, Size, Base,
|
"xf86MapVidMem", DEV_MEM, Size, Base,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -239,7 +252,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
|
||||||
/* else, mmap /dev/vga */
|
/* else, mmap /dev/vga */
|
||||||
if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
|
if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
|
||||||
{
|
{
|
||||||
FatalError("%s: Address 0x%x outside allowable range\n",
|
FatalError("%s: Address 0x%lx outside allowable range",
|
||||||
"xf86MapVidMem", Base);
|
"xf86MapVidMem", Base);
|
||||||
}
|
}
|
||||||
base = mmap(0, Size,
|
base = mmap(0, Size,
|
||||||
|
@ -250,7 +263,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
|
||||||
);
|
);
|
||||||
if (base == MAP_FAILED)
|
if (base == MAP_FAILED)
|
||||||
{
|
{
|
||||||
FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
|
FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
return(base);
|
return(base);
|
||||||
|
@ -288,7 +301,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
|
||||||
if ((long)ptr == -1)
|
if ((long)ptr == -1)
|
||||||
{
|
{
|
||||||
xf86Msg(X_WARNING,
|
xf86Msg(X_WARNING,
|
||||||
"xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
|
"xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
|
||||||
DEV_MEM, Len, Base, Offset, strerror(errno));
|
DEV_MEM, Len, Base, Offset, strerror(errno));
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (Base < 0xa0000) {
|
if (Base < 0xa0000) {
|
||||||
|
@ -311,7 +324,6 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
|
||||||
return(Len);
|
return(Len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_I386_IOPL
|
#ifdef USE_I386_IOPL
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* I/O Permissions section */
|
/* I/O Permissions section */
|
||||||
|
@ -328,7 +340,7 @@ xf86EnableIO()
|
||||||
if (i386_iopl(TRUE) < 0)
|
if (i386_iopl(TRUE) < 0)
|
||||||
{
|
{
|
||||||
#ifndef __OpenBSD__
|
#ifndef __OpenBSD__
|
||||||
FatalError("%s: Failed to set IOPL for extended I/O\n",
|
FatalError("%s: Failed to set IOPL for extended I/O",
|
||||||
"xf86EnableIO");
|
"xf86EnableIO");
|
||||||
#else
|
#else
|
||||||
FatalError("%s: Failed to set IOPL for extended I/O\n%s",
|
FatalError("%s: Failed to set IOPL for extended I/O\n%s",
|
||||||
|
@ -354,6 +366,51 @@ xf86DisableIO()
|
||||||
|
|
||||||
#endif /* USE_I386_IOPL */
|
#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
|
#ifdef USE_DEV_IO
|
||||||
static int IoFd = -1;
|
static int IoFd = -1;
|
||||||
|
|
||||||
|
@ -366,7 +423,7 @@ xf86EnableIO()
|
||||||
if ((IoFd = open("/dev/io", O_RDWR)) == -1)
|
if ((IoFd = open("/dev/io", O_RDWR)) == -1)
|
||||||
{
|
{
|
||||||
FatalError("xf86EnableIO: "
|
FatalError("xf86EnableIO: "
|
||||||
"Failed to open /dev/io for extended I/O\n");
|
"Failed to open /dev/io for extended I/O");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +496,7 @@ xf86SetTVOut(int mode)
|
||||||
#endif /* PCCONS_SUPPORT */
|
#endif /* PCCONS_SUPPORT */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FatalError("Xf86SetTVOut: Unsupported console\n");
|
FatalError("Xf86SetTVOut: Unsupported console");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -464,14 +521,13 @@ xf86SetRGBOut()
|
||||||
#endif /* PCCONS_SUPPORT */
|
#endif /* PCCONS_SUPPORT */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FatalError("Xf86SetTVOut: Unsupported console\n");
|
FatalError("Xf86SetTVOut: Unsupported console");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_MTRR_SUPPORT
|
#ifdef HAS_MTRR_SUPPORT
|
||||||
/* memory range (MTRR) support for FreeBSD */
|
/* memory range (MTRR) support for FreeBSD */
|
||||||
|
|
||||||
|
@ -879,3 +935,55 @@ NetBSDundoWC(int screenNum, pointer list)
|
||||||
xfree(mtrrp);
|
xfree(mtrrp);
|
||||||
}
|
}
|
||||||
#endif
|
#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 */
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.93 2003/09/09 03:20:38 dawes Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.94 2003/11/03 05:11:51 tsi Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
|
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
|
||||||
* Copyright 1992 by David Dawes <dawes@XFree86.org>
|
* Copyright 1992 by David Dawes <dawes@XFree86.org>
|
||||||
|
@ -102,7 +102,7 @@ typedef signed long xf86ssize_t;
|
||||||
/* SYSV386 (SVR3, SVR4) - But not Solaris8 */
|
/* SYSV386 (SVR3, SVR4) - But not Solaris8 */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
#if (defined(SYSV) || defined(SVR4)) && \
|
#if (defined(SYSV) || defined(SVR4)) && \
|
||||||
!defined(DGUX) && \
|
!defined(DGUX) && !defined(sgi) && \
|
||||||
!defined(__SOL8__) && \
|
!defined(__SOL8__) && \
|
||||||
(!defined(sun) || defined(i386))
|
(!defined(sun) || defined(i386))
|
||||||
# ifdef SCO325
|
# ifdef SCO325
|
||||||
|
@ -532,7 +532,7 @@ extern int errno;
|
||||||
# endif
|
# endif
|
||||||
# endif /* __bsdi__ */
|
# endif /* __bsdi__ */
|
||||||
|
|
||||||
#ifdef USE_I386_IOPL
|
#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL)
|
||||||
#include <machine/sysarch.h>
|
#include <machine/sysarch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -670,6 +670,17 @@ extern char* __XOS2RedirRoot(char*);
|
||||||
|
|
||||||
#endif /* __GNU__ */
|
#endif /* __GNU__ */
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/* IRIX */
|
||||||
|
/**************************************************************************/
|
||||||
|
#if defined(sgi)
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* Generic */
|
/* Generic */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -717,9 +728,7 @@ extern int sys_nerr;
|
||||||
#if defined(ISC) || defined(Lynx)
|
#if defined(ISC) || defined(Lynx)
|
||||||
#define rint(x) RInt(x)
|
#define rint(x) RInt(x)
|
||||||
double RInt(
|
double RInt(
|
||||||
#if NeedFunctionPrototypes
|
|
||||||
double x
|
double x
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue