Modifying X.Org Xserver DDX to allow to run X with ordinary user

permissions when no access to HW registers is required. For API changes
    which mostly involve the modifications to make the RRFunc (introduced
    with 6.8) more flexible please check Bugzilla #2407. NOTE: This patch
    applies changes to OS specific files for other OSes which I cannot
    test.
This commit is contained in:
Egbert Eich 2005-01-28 16:13:00 +00:00
parent 1562ec5cc3
commit d23c46dd3e
27 changed files with 539 additions and 327 deletions

View File

@ -3030,7 +3030,7 @@ void
xf86FindPrimaryDevice()
{
/* if no VGA device is found check for primary PCI device */
if (primaryBus.type == BUS_NONE)
if (primaryBus.type == BUS_NONE && xorgHWAccess)
CheckGenericGA();
if (primaryBus.type != BUS_NONE) {
char *bus;

View File

@ -38,6 +38,7 @@
#endif
#include "xf86.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
#include "xf86Priv.h"
#include "xf86PciData.h"
#define IN_XSERVER
@ -789,6 +790,24 @@ DoConfigure()
xfree(vlist);
for (i = 0; i < xf86NumDrivers; i++) {
xorgHWFlags flags;
if (!xf86DriverList[i]->driverFunc
|| !xf86DriverList[i]->driverFunc(NULL,
GET_REQUIRED_HW_INTERFACES,
&flags)
|| NEED_IO_ENABLED(flags)) {
xorgHWAccess = TRUE;
break;
}
}
/* Enable full I/O access */
if (xorgHWAccess) {
if(!xf86EnableIO())
/* oops, we have failed */
xorgHWAccess = FALSE;
}
/* Disable PCI devices */
xf86ResourceBrokerInit();
xf86AccessInit();
@ -803,6 +822,16 @@ DoConfigure()
/* Call all of the probe functions, reporting the results. */
for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
xorgHWFlags flags;
if (!xorgHWAccess) {
if (!xf86DriverList[CurrentDriver]->driverFunc
|| !xf86DriverList[CurrentDriver]->driverFunc(NULL,
GET_REQUIRED_HW_INTERFACES,
&flags)
|| NEED_IO_ENABLED(flags))
continue;
}
if (xf86DriverList[CurrentDriver]->Probe == NULL) continue;

View File

@ -40,6 +40,7 @@
#include "loaderProcs.h"
#include "xf86Config.h"
#endif /* XFree86LOADER */
#include "xf86_OSlib.h"
#include "xf86.h"
#include "xf86Priv.h"
@ -53,6 +54,7 @@ DoProbe()
{
int i;
Bool probeResult;
Bool ioEnableFailed = FALSE;
#ifdef XFree86LOADER
/* Find the list of video driver modules. */
@ -76,6 +78,24 @@ DoProbe()
/* Call all of the probe functions, reporting the results. */
for (i = 0; i < xf86NumDrivers; i++) {
if (!xorgHWAccess) {
xorgHWFlags flags;
if (!xf86DriverList[i]->driverFunc
|| !xf86DriverList[i]->driverFunc(NULL,
GET_REQUIRED_HW_INTERFACES,
&flags)
|| NEED_IO_ENABLED(flags)) {
if (ioEnableFailed)
continue;
if (!xf86EnableIO()) {
ioEnableFailed = TRUE;
continue;
}
xorgHWAccess = TRUE;
}
}
if (xf86DriverList[i]->Probe == NULL) continue;
xf86MsgVerb(X_INFO, 3, "Probing in driver %s\n",

View File

@ -1431,6 +1431,7 @@ xf86VTSwitch()
xf86Screens[i]->access = NULL;
xf86Screens[i]->busAccess = NULL;
}
if (xorgHWAccess)
xf86DisableIO();
}
} else {
@ -1443,6 +1444,7 @@ xf86VTSwitch()
prevSIGIO = xf86BlockSIGIO();
xf86OSPMClose = xf86OSPMOpen();
if (xorgHWAccess)
xf86EnableIO();
xf86AccessEnter();
xf86EnterServerState(SETUP);

View File

@ -238,6 +238,7 @@ Bool xf86MiscModInDevAllowNonLocal = FALSE;
#endif
RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
Bool xf86inSuspend = FALSE;
Bool xorgHWAccess = FALSE;
#ifdef DLOPEN_HACK
/*

View File

@ -83,7 +83,12 @@ xf86AddDriver(DriverPtr driver, pointer module, int flags)
xf86DriverList = xnfrealloc(xf86DriverList,
xf86NumDrivers * sizeof(DriverPtr));
xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
if (flags & HaveDriverFuncs)
*xf86DriverList[xf86NumDrivers - 1] = *driver;
else {
memcpy(xf86DriverList[xf86NumDrivers - 1], driver, sizeof(DriverRec1));
xf86DriverList[xf86NumDrivers - 1]->driverFunc = NULL;
}
xf86DriverList[xf86NumDrivers - 1]->module = module;
xf86DriverList[xf86NumDrivers - 1]->refCount = 0;
}
@ -209,6 +214,8 @@ xf86AllocateScreen(DriverPtr drv, int flags)
}
#endif
xf86Screens[i]->DriverFunc = drv->driverFunc;
return xf86Screens[i];
}

View File

@ -378,9 +378,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86OpenConsole();
/* Enable full I/O access */
xf86EnableIO();
/* Do a general bus probe. This will be a PCI probe for x86 platforms */
xf86BusProbe();
@ -446,12 +443,14 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
/*
* Call each of the Identify functions. The Identify functions print
* out some identifying information, and anything else that might be
* Call each of the Identify functions and call the driverFunc to check
* if HW access is required. The Identify functions print out some
* identifying information, and anything else that might be
* needed at this early stage.
*/
for (i = 0; i < xf86NumDrivers; i++)
for (i = 0; i < xf86NumDrivers; i++) {
xorgHWFlags flags;
/* The Identify function is mandatory, but if it isn't there continue */
if (xf86DriverList[i]->Identify != NULL)
xf86DriverList[i]->Identify(0);
@ -460,6 +459,21 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
: "noname");
}
if (!xorgHWAccess
&& (!xf86DriverList[i]->driverFunc
|| !xf86DriverList[i]->driverFunc(NULL,
GET_REQUIRED_HW_INTERFACES,
&flags)
|| NEED_IO_ENABLED(flags)))
xorgHWAccess = TRUE;
}
/* Enable full I/O access */
if (xorgHWAccess) {
if(!xf86EnableIO())
/* oops, we have failed */
xorgHWAccess = FALSE;
}
/*
* Locate bus slot that had register IO enabled at server startup
@ -475,13 +489,23 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
*/
for (i = 0; i < xf86NumDrivers; i++) {
xorgHWFlags flags;
if (!xorgHWAccess) {
if (!xf86DriverList[i]->driverFunc
|| !xf86DriverList[i]->driverFunc(NULL,
GET_REQUIRED_HW_INTERFACES,
&flags)
|| NEED_IO_ENABLED(flags))
continue;
}
if (xf86DriverList[i]->Probe != NULL)
xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
else {
xf86MsgVerb(X_WARNING, 0,
"Driver `%s' has no Probe function (ignoring)\n",
xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
: "noname");
xf86DriverList[i]->driverName
? xf86DriverList[i]->driverName : "noname");
}
xf86SetPciVideo(NULL,NONE);
}
@ -814,6 +838,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
/* Make sure full I/O access is enabled */
if (xorgHWAccess)
xf86EnableIO();
}
@ -896,7 +921,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86Screens[i]->DPMSSet = NULL;
xf86Screens[i]->LoadPalette = NULL;
xf86Screens[i]->SetOverscan = NULL;
xf86Screens[i]->RRFunc = NULL;
xf86Screens[i]->DriverFunc = NULL;
xf86Screens[i]->pScreen = NULL;
scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
if (scr_index == i) {
@ -1330,7 +1355,7 @@ ddxProcessArgument(int argc, char **argv, int i)
*/
/* First the options that are only allowed for root */
if (getuid() == 0)
if (getuid() == 0 || geteuid != 0)
{
if (!strcmp(argv[i], "-modulepath"))
{
@ -1636,7 +1661,7 @@ ddxProcessArgument(int argc, char **argv, int i)
}
if (!strcmp(argv[i], "-configure"))
{
if (getuid() != 0) {
if (getuid() != 0 && geteuid == 0) {
ErrorF("The '-configure' option can only be used by root.\n");
exit(1);
}
@ -1665,7 +1690,7 @@ ddxUseMsg()
ErrorF("\n");
ErrorF("\n");
ErrorF("Device Dependent Usage\n");
if (getuid() == 0)
if (getuid() == 0 || geteuid() != 0)
{
ErrorF("-modulepath paths specify the module search path\n");
ErrorF("-logfile file specify a log file name\n");

View File

@ -112,6 +112,7 @@ extern int xf86Verbose; /* verbosity level */
extern int xf86LogVerbose; /* log file verbosity level */
extern Bool xf86ProbeOnly;
extern Bool xf86DoProbe;
extern Bool xorgHWAccess;
extern RootWinPropPtr *xf86RegisteredPropertiesTable;

View File

@ -1,4 +1,4 @@
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.5 2004/08/13 18:24:07 sandmann Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.6 2004/12/04 00:42:52 kuhn Exp $ */
/*
* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $
*
@ -104,11 +104,11 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
}
/* If there is driver support for randr, let it set our supported rotations */
if(scrp->RRFunc) {
if(scrp->DriverFunc) {
xorgRRRotation RRRotation;
RRRotation.RRRotations = *rotations;
if (!(*scrp->RRFunc)(scrp, RR_GET_INFO, &RRRotation))
if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
return FALSE;
*rotations = RRRotation.RRRotations;
}
@ -216,14 +216,14 @@ xf86RandRSetConfig (ScreenPtr pScreen,
}
/* Have the driver do its thing. */
if (scrp->RRFunc) {
if (scrp->DriverFunc) {
xorgRRRotation RRRotation;
RRRotation.RRConfig.rotation = rotation;
RRRotation.RRConfig.rate = rate;
RRRotation.RRConfig.width = pSize->width;
RRRotation.RRConfig.height = pSize->height;
if (!(*scrp->RRFunc)(scrp, RR_SET_CONFIG, &RRRotation))
if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
return FALSE;
}

View File

@ -235,10 +235,60 @@ typedef struct x_ClockRanges {
int strategy;
} ClockRanges, *ClockRangesPtr;
/*
* The driverFunc. xorgDriverFuncOp specifies the action driver should
* perform. If requested option is not supported function should return
* FALSE. pointer can be used to pass arguments to the function or
* to return data to the caller.
*/
typedef struct _ScrnInfoRec *ScrnInfoPtr;
/* do not change order */
typedef enum {
RR_GET_INFO,
RR_SET_CONFIG,
GET_REQUIRED_HW_INTERFACES = 10
} xorgDriverFuncOp;
typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
pointer);
/* RR_GET_INFO, RR_SET_CONFIG */
typedef struct {
int rotation;
int rate;
int width;
int height;
} xorgRRConfig;
typedef union {
short RRRotations;
xorgRRConfig RRConfig;
} xorgRRRotation, *xorgRRRotationPtr;
/* GET_REQUIRED_HW_INTERFACES */
#define HW_IO 1
#define HW_MMIO 2
#define NEED_IO_ENABLED(x) (x & HW_IO)
typedef CARD32 xorgHWFlags;
/*
* The driver list struct. This contains the information required for each
* driver before a ScrnInfoRec has been allocated.
*/
struct _DriverRec;
typedef struct {
int driverVersion;
char * driverName;
void (*Identify)(int flags);
Bool (*Probe)(struct _DriverRec *drv, int flags);
const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
pointer module;
int refCount;
} DriverRec1;
typedef struct _DriverRec {
int driverVersion;
char * driverName;
@ -247,8 +297,15 @@ typedef struct _DriverRec {
const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
pointer module;
int refCount;
xorgDriverFuncProc *driverFunc;
} DriverRec, *DriverPtr;
/*
* AddDriver flags
*/
#define HaveDriverFuncs 1
#ifdef XFree86LOADER
/*
* The optional module list struct. This allows modules exporting helping
@ -737,24 +794,6 @@ typedef struct {
PixmapPtr pPix;
} DGADeviceRec, *DGADevicePtr;
typedef enum {
RR_GET_INFO,
RR_SET_CONFIG
} xorgRRFuncFlags;
typedef struct {
int rotation;
int rate;
int width;
int height;
} xorgRRConfig;
typedef union {
short RRRotations;
xorgRRConfig RRConfig;
} xorgRRRotation, *xorgRRRotationPtr;
/*
* Flags for driver Probe() functions.
*/
@ -765,7 +804,6 @@ typedef union {
/*
* Driver entry point types
*/
typedef struct _ScrnInfoRec *ScrnInfoPtr;
typedef Bool xf86ProbeProc (DriverPtr, int);
typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
@ -785,8 +823,6 @@ typedef int xf86HandleMessageProc (int, const char*, const char*, char**);
typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
typedef Bool xorgRRFuncProc (ScrnInfoPtr, xorgRRFuncFlags,
xorgRRRotationPtr);
/*
@ -942,7 +978,7 @@ typedef struct _ScrnInfoRec {
xf86DPMSSetProc *DPMSSet;
xf86LoadPaletteProc *LoadPalette;
xf86SetOverscanProc *SetOverscan;
xorgRRFuncProc *RRFunc;
xorgDriverFuncProc *DriverFunc;
/*
* This can be used when the minor ABI version is incremented.

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c,v 1.5 2003/04/03 16:50:04 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c,v 1.6 2003/12/30 15:18:30 herrb Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@ -117,11 +117,13 @@ has_bwx(void)
#endif
}
#else /* __NetBSD__ */
static unsigned long hae_thresh = (1UL << 24);
static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
static struct alpha_bus_window *abw;
static int abw_count = -1;
static void
init_abw()
init_abw(void)
{
if (abw_count < 0) {
abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
@ -142,7 +144,7 @@ has_bwx(void)
}
static unsigned long
dense_base()
dense_base(void)
{
if (abw_count < 0)
init_abw();
@ -154,7 +156,7 @@ dense_base()
}
static unsigned long
memory_base()
memory_base(void)
{
if (abw_count < 0)
init_abw();
@ -284,11 +286,13 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
pVidMem->mapMem = mapVidMemSparse;
pVidMem->unmapMem = unmapVidMemSparse;
#ifndef __NetBSD__
if (axpSystem == -1)
axpSystem = bsdGetAXP();
hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
hae_mask = xf86AXPParams[axpSystem].hae_mask;
sparse_size = xf86AXPParams[axpSystem].size;
#endif /* __NetBSD__ */
}
pVidMem->initialised = TRUE;
}
@ -314,7 +318,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
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)\n",
"xf86MapVidMem", DEV_MEM, Size, Base,
strerror(errno));
}
@ -324,7 +328,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
/* else, mmap /dev/vga */
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\n",
"xf86MapVidMem", Base);
}
base = mmap(0, Size,
@ -372,7 +376,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
if ((long)ptr == -1)
{
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));
return(-1);
}
@ -395,11 +399,12 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
extern int ioperm(unsigned long from, unsigned long num, int on);
void
Bool
xf86EnableIO()
{
ioperm(0, 65536, TRUE);
return;
if (!ioperm(0, 65536, TRUE))
return TRUE;
return FALSE;
}
void
@ -412,10 +417,11 @@ xf86DisableIO()
#ifdef USE_ALPHA_PIO
void
Bool
xf86EnableIO()
{
alpha_pci_io_enable(1);
return TRUE;
}
void
@ -490,6 +496,7 @@ struct parms {
u_int64_t hae;
};
#ifndef __NetBSD__
static int
sethae(u_int64_t hae)
{
@ -505,6 +512,7 @@ sethae(u_int64_t hae)
return -1;
#endif
}
#endif /* __NetBSD__ */
static pointer
mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
@ -553,7 +561,6 @@ readSparse8(pointer Base, register unsigned long Offset)
{
register unsigned long result, shift;
register unsigned long msb;
mem_barrier();
Offset += (unsigned long)Base - (unsigned long)memBase;
shift = (Offset & 0x3) << 3;
@ -561,11 +568,12 @@ readSparse8(pointer Base, register unsigned long Offset)
msb = Offset & hae_mask;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}
result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
result >>= shift;
return 0xffUL & result;
@ -584,7 +592,9 @@ readSparse16(pointer Base, register unsigned long Offset)
msb = Offset & hae_mask;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}
@ -612,7 +622,9 @@ writeSparse8(int Value, pointer Base, register unsigned long Offset)
msb = Offset & hae_mask;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}
@ -631,7 +643,9 @@ writeSparse16(int Value, pointer Base, register unsigned long Offset)
msb = Offset & hae_mask;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}
@ -659,7 +673,9 @@ writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
msb = Offset & hae_mask;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}
@ -677,7 +693,9 @@ writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
msb = Offset & hae_mask ;
Offset -= msb;
if (msb_set != msb) {
#ifndef __NetBSD__
sethae(msb);
#endif
msb_set = msb;
}
}

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c,v 1.2 2003/03/14 13:46:03 tsi Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c,v 1.1tsi Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@ -449,18 +449,19 @@ armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
#ifdef USE_DEV_IO
static int IoFd = -1;
void
Bool
xf86EnableIO()
{
if (IoFd >= 0)
return;
return TRUE;
if ((IoFd = open("/dev/io", O_RDWR)) == -1)
{
FatalError("xf86EnableIO: "
xf86Msg(X_WARNING,"xf86EnableIO: "
"Failed to open /dev/io for extended I/O\n");
return FALSE;
}
return;
return TRUE;
}
void
@ -478,14 +479,14 @@ xf86DisableIO()
#if defined(USE_ARC_MMAP) || defined(__arm32__)
void
Bool
xf86EnableIO()
{
int fd;
pointer base;
if (ExtendedEnabled)
return;
return TRUE;
if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
/* Try to map a page at the pccons I/O space */
@ -496,18 +497,20 @@ xf86EnableIO()
IOPortBase = base;
}
else {
FatalError("EnableIO: failed to mmap %s (%s)\n",
xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
"/dev/ttyC0", strerror(errno));
return FALSE;
}
}
else {
FatalError("EnableIO: failed to open %s (%s)\n",
xf86Msg("EnableIO: failed to open %s (%s)\n",
"/dev/ttyC0", strerror(errno));
return FALSE;
}
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void
@ -554,7 +557,7 @@ static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void
Bool
xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
@ -570,7 +573,7 @@ int ScreenNum;
ScreenEnabled[ScreenNum] = TRUE;
if (ExtendedEnabled)
return;
return TRUE;
#ifdef USE_ARC_MMAP
if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
@ -610,7 +613,7 @@ int ScreenNum;
(caddr_t)0x0, 0L)
- memInfoP->memInfo.u.map_info_mmap.internal_offset;
ExtendedEnabled = TRUE;
return;
return TRUE;
}
#ifdef USE_ARM32_MMAP
checkDevMem(TRUE);
@ -626,19 +629,21 @@ int ScreenNum;
if (IOPortBase == (unsigned int)-1)
{
FatalError("xf86EnableIOPorts: failed to open mem device or map IO base. \n\
xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
return FALSE;
}
#else
/* We don't have the IOBASE, so we can't map the address */
FatalError("xf86EnableIOPorts: failed to open mem device or map IO base. \n\
xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
Try building the server with USE_ARM32_MMAP defined\n");
return FALSE;
#endif
#endif
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void

View File

@ -331,25 +331,26 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
static Bool ExtendedEnabled = FALSE;
void
Bool
xf86EnableIO()
{
if (ExtendedEnabled)
return;
return TRUE;
if (i386_iopl(TRUE) < 0)
{
#ifndef __OpenBSD__
FatalError("%s: Failed to set IOPL for extended I/O",
xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
"xf86EnableIO");
#else
FatalError("%s: Failed to set IOPL for extended I/O\n%s",
xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
"xf86EnableIO", SYSCTL_MSG);
#endif
return FALSE;
}
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void
@ -373,25 +374,26 @@ xf86DisableIO()
static Bool ExtendedEnabled = FALSE;
void
Bool
xf86EnableIO()
{
if (ExtendedEnabled)
return;
return TRUE;
if (amd64_iopl(TRUE) < 0)
{
#ifndef __OpenBSD__
FatalError("%s: Failed to set IOPL for extended I/O",
xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
"xf86EnableIO");
#else
FatalError("%s: Failed to set IOPL for extended I/O\n%s",
xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
"xf86EnableIO", SYSCTL_MSG);
#endif
return FALSE;
}
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void
@ -414,18 +416,19 @@ xf86DisableIO()
#ifdef USE_DEV_IO
static int IoFd = -1;
void
Bool
xf86EnableIO()
{
if (IoFd >= 0)
return;
return TRUE;
if ((IoFd = open("/dev/io", O_RDWR)) == -1)
{
FatalError("xf86EnableIO: "
xf86Msg(X_WARNING,"xf86EnableIO: "
"Failed to open /dev/io for extended I/O");
return FALSE;
}
return;
return TRUE;
}
void

View File

@ -208,13 +208,6 @@
#define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */
#define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */
#ifdef PC98
#define outb(port,data) _outb(port,data)
#define outl(port,data) _outl(port,data)
#define inb(port) _inb(port)
#define inl(port) _inl(port)
#endif
/*
* Global data
*/
@ -833,90 +826,6 @@ pciGenFindFirst(void)
return pciGenFindNext();
}
#if defined (__powerpc__)
static int buserr_detected;
static
void buserr(int sig)
{
buserr_detected = 1;
}
#endif
CARD32
pciCfgMech1Read(PCITAG tag, int offset)
{
unsigned long rv = 0xffffffff;
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Read(tag=%08x,offset=%08x)\n", tag, offset);
#endif
#if defined(__powerpc__)
signal(SIGBUS, buserr);
buserr_detected = 0;
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
rv = inl(0xCFC);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
if (buserr_detected)
{
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Read() BUS ERROR\n");
#endif
return(0xffffffff);
}
else
#endif
return(rv);
}
void
pciCfgMech1Write(PCITAG tag, int offset, CARD32 val)
{
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Write(tag=%08x,offset=%08x,val=%08x)\n",
tag, offset,val);
#endif
#if defined(__powerpc__)
signal(SIGBUS, SIG_IGN);
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
#if defined(Lynx) && defined(__powerpc__)
outb(0x80, 0x00); /* without this the next access fails
* on my Powerstack system when we use
* assembler inlines for outl */
#endif
outl(0xCFC, val);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
#endif
}
void
pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask, CARD32 val)
{
unsigned long rv = 0xffffffff;
#if defined(__powerpc__)
signal(SIGBUS, buserr);
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
rv = inl(0xCFC);
rv = (rv & ~mask) | val;
outl(0xCFC, rv);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
#endif
}
CARD32
pciByteSwap(CARD32 u)
{

View File

@ -140,6 +140,7 @@
#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "Pci.h"
#ifdef PC98
@ -278,6 +279,8 @@ void ix86PciSelectCfgmech(void)
#endif
case PCIProbe1:
if (!xf86EnableIO())
return;
xf86MsgVerb(X_INFO, 2,
"PCI: Probing config type using method 1\n");
@ -449,6 +452,8 @@ void ix86PciSelectCfgmech(void)
break; /* } */
case PCIProbe2: /* { */
if (!xf86EnableIO())
return;
/* The scanpci-style detection method */
@ -481,6 +486,8 @@ void ix86PciSelectCfgmech(void)
break; /* } */
case PCIForceConfig1:
if (!xf86EnableIO())
return;
xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 1\n");
@ -490,6 +497,8 @@ void ix86PciSelectCfgmech(void)
return;
case PCIForceConfig2:
if (!xf86EnableIO())
return;
xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 2\n");

View File

@ -99,9 +99,9 @@ linuxPciInit()
}
static int
linuxPciOpenFile(PCITAG tag)
linuxPciOpenFile(PCITAG tag, Bool write)
{
static int lbus,ldev,lfunc,fd = -1;
static int lbus,ldev,lfunc,fd = -1,is_write = 0;
int bus, dev, func;
char file[32];
struct stat ignored;
@ -109,7 +109,8 @@ linuxPciOpenFile(PCITAG tag)
bus = PCI_BUS_FROM_TAG(tag);
dev = PCI_DEV_FROM_TAG(tag);
func = PCI_FUNC_FROM_TAG(tag);
if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) {
if (fd == -1 || (write && (!is_write))
|| bus != lbus || dev != ldev || func != lfunc) {
if (fd != -1)
close(fd);
if (bus < 256) {
@ -129,7 +130,19 @@ linuxPciOpenFile(PCITAG tag)
sprintf(file, "/proc/bus/pci/%04x/%02x.%1x",
bus, dev, func);
}
if (write) {
fd = open(file,O_RDWR);
if (fd != -1) is_write = TRUE;
} else switch (is_write) {
case TRUE:
fd = open(file,O_RDWR);
if (fd > -1)
break;
default:
fd = open(file,O_RDONLY);
is_write = FALSE;
}
lbus = bus;
ldev = dev;
lfunc = func;
@ -143,7 +156,7 @@ linuxPciCfgRead(PCITAG tag, int off)
int fd;
CARD32 val = 0xffffffff;
if (-1 != (fd = linuxPciOpenFile(tag))) {
if (-1 != (fd = linuxPciOpenFile(tag,FALSE))) {
lseek(fd,off,SEEK_SET);
read(fd,&val,4);
}
@ -155,7 +168,7 @@ linuxPciCfgWrite(PCITAG tag, int off, CARD32 val)
{
int fd;
if (-1 != (fd = linuxPciOpenFile(tag))) {
if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
lseek(fd,off,SEEK_SET);
val = PCI_CPU(val);
write(fd,&val,4);
@ -168,7 +181,7 @@ linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
int fd;
CARD32 val = 0xffffffff;
if (-1 != (fd = linuxPciOpenFile(tag))) {
if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
lseek(fd,off,SEEK_SET);
read(fd,&val,4);
val = PCI_CPU(val);
@ -336,7 +349,7 @@ xf86GetPciDomain(PCITAG Tag)
if (pPCI && (result = PCI_DOM_FROM_BUS(pPCI->busnum)))
return result;
if ((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0)) < 0)
if ((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0,FALSE)) < 0)
return 0;
if ((result = ioctl(fd, PCIIOC_CONTROLLER, 0)) < 0)
@ -359,7 +372,7 @@ linuxMapPci(int ScreenNum, int Flags, PCITAG Tag,
pPCI = xf86GetPciHostConfigFromTag(Tag);
if (((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0)) < 0) ||
if (((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0,FALSE)) < 0) ||
(ioctl(fd, mmap_ioctl, 0) < 0))
break;

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c,v 1.9 2002/08/27 22:07:07 tsi Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c,v 1.8 2002/07/24 19:06:52 tsi Exp $ */
/*
* ppcPci.c - PowerPC PCI access functions
*
@ -79,13 +79,14 @@ ppcPciInit()
#else
extern void motoppcPciInit(void);
static void motoppcPciInit(void);
motoppcPciInit();
#endif
}
#if defined(PowerMAX_OS)
/*
* Motorola PowerPC platform support
*
@ -101,6 +102,11 @@ ppcPciInit()
*/
static ADDRESS motoppcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS);
static ADDRESS motoppcHostAddrToBusAddr(PCITAG, PciAddrType, ADDRESS);
static CARD32 pciCfgMech1Read(PCITAG tag, int offset);
static void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
static void pciCfgMech1SetBits(PCITAG tag, int offset,
CARD32 mask, CARD32 val);
static pciBusFuncs_t motoppcFuncs0 = {
/* pciReadLong */ pciCfgMech1Read,
@ -126,7 +132,7 @@ static pciBusInfo_t motoppcPci0 = {
extern volatile unsigned char *ioBase;
void
static void
motoppcPciInit()
{
pciNumBuses = 1;
@ -134,6 +140,9 @@ motoppcPciInit()
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
if (!xf86EnableIO())
FatalError("motoppcPciInit: EnableIO failed\n");
if (ioBase == MAP_FAILED) {
ppcPciIoMap(0); /* Make inb/outb et al work for pci0 and its secondaries */
@ -210,3 +219,89 @@ motoppcHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
/*NOTREACHED*/
}
#if defined (__powerpc__)
static int buserr_detected;
static
void buserr(int sig)
{
buserr_detected = 1;
}
#endif
static CARD32
pciCfgMech1Read(PCITAG tag, int offset)
{
unsigned long rv = 0xffffffff;
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Read(tag=%08x,offset=%08x)\n", tag, offset);
#endif
#if defined(__powerpc__)
signal(SIGBUS, buserr);
buserr_detected = 0;
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
rv = inl(0xCFC);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
if (buserr_detected)
{
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Read() BUS ERROR\n");
#endif
return(0xffffffff);
}
else
#endif
return(rv);
}
static void
pciCfgMech1Write(PCITAG tag, int offset, CARD32 val)
{
#ifdef DEBUGPCI
ErrorF("pciCfgMech1Write(tag=%08x,offset=%08x,val=%08x)\n",
tag, offset,val);
#endif
#if defined(__powerpc__)
signal(SIGBUS, SIG_IGN);
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
#if defined(Lynx) && defined(__powerpc__)
outb(0x80, 0x00); /* without this the next access fails
* on my Powerstack system when we use
* assembler inlines for outl */
#endif
outl(0xCFC, val);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
#endif
}
static void
pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask, CARD32 val)
{
unsigned long rv = 0xffffffff;
#if defined(__powerpc__)
signal(SIGBUS, buserr);
#endif
outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
rv = inl(0xCFC);
rv = (rv & ~mask) | val;
outl(0xCFC, rv);
#if defined(__powerpc__)
signal(SIGBUS, SIG_DFL);
#endif
}
#endif /* PowerMAX_OS */

View File

@ -1,4 +1,4 @@
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.2 2004/04/23 19:54:08 eich Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.3 2005/01/14 18:42:26 eich Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.14 2001/10/31 22:50:30 tsi Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
@ -84,7 +84,6 @@ void
xf86OpenConsole(void)
{
int i, fd = -1;
int result;
struct vt_mode VT;
struct vt_stat vts;
MessageType from = X_PROBED;
@ -95,13 +94,12 @@ xf86OpenConsole(void)
char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
if (serverGeneration == 1)
{
/* check if we're run with euid==0 */
if (geteuid() != 0)
{
FatalError("xf86OpenConsole: Server must be suid root\n");
}
if (serverGeneration == 1) {
/* when KeepTty check if we're run with euid==0 */
if (KeepTty && geteuid() != 0)
FatalError("xf86OpenConsole:"
" Server must be suid root for option \"KeepTTY\"\n");
/*
* setup the virtual terminal manager
@ -110,20 +108,23 @@ xf86OpenConsole(void)
xf86Info.vtno = VTnum;
from = X_CMDLINE;
} else {
i=0;
while (tty0[i] != NULL)
{
while (tty0[i] != NULL) {
if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
break;
i++;
}
if (fd < 0)
FatalError(
"xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
strerror(errno));
if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
(xf86Info.vtno == -1)) {
FatalError("xf86OpenConsole: Cannot find a free VT\n");
FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
strerror(errno));
}
close(fd);
}
@ -132,43 +133,61 @@ xf86OpenConsole(void)
fb_dev_name=getenv("FRAMEBUFFER");
if (!fb_dev_name)
fb_dev_name="/dev/fb0current";
if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
fb_dev_name, strerror(errno));
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
FatalError("xf86OpenConsole: Unable to get screen info\n");
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var) < 0)
FatalError("xf86OpenConsole: Unable to get screen info %s\n",
strerror(errno));
#endif
xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
if (!KeepTty) {
setpgrp();
pid_t ppid = getppid();
pid_t ppgid;
ppgid = getpgid(ppid);
/*
* change to parent process group that pgid != pid so
* that setsid() doesn't fail and we become process
* group leader
*/
if (setpgid(0,ppgid) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
strerror(errno));
/* become process group leader */
if ((setsid() < 0))
xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
strerror(errno));
}
i=0;
while (vcs[i] != NULL)
{
while (vcs[i] != NULL) {
sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
break;
i++;
}
if (xf86Info.consoleFd < 0) {
FatalError("xf86OpenConsole: Cannot open virtual console %d (%s)\n",
xf86Info.vtno, strerror(errno));
}
if (xf86Info.consoleFd < 0)
FatalError("xf86OpenConsole: Cannot open virtual console"
" %d (%s)\n", xf86Info.vtno, strerror(errno));
/*
* Grab the vt ownership before we overwrite it.
* Hard coded /dev/tty0 into this function as well for below.
*/
if (!saveVtPerms()){
if (!saveVtPerms())
xf86Msg(X_WARNING,
"xf86OpenConsole: Could not save ownership of VT\n");
}
/* change ownership of the vt */
chown(vtname, getuid(), getgid());
if (chown(vtname, getuid(), getgid()) < 0)
xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
vtname, strerror(errno));
/*
* the current VT device we're running on is not "console", we want
@ -176,65 +195,63 @@ xf86OpenConsole(void)
*
* Why is this needed??
*/
chown("/dev/tty0", getuid(), getgid());
if (chown("/dev/tty0", getuid(), getgid()) < 0)
xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
strerror(errno));
/*
* Linux doesn't switch to an active vt after the last close of a vt,
* so we do this ourselves by remembering which is active now.
*/
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) == 0)
{
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
strerror(errno));
else
activeVT = vts.v_active;
}
if (!KeepTty)
{
#if 0
if (!KeepTty) {
/*
* Detach from the controlling tty to avoid char loss
*/
if ((i = open("/dev/tty",O_RDWR)) >= 0)
{
if ((i = open("/dev/tty",O_RDWR)) >= 0) {
ioctl(i, TIOCNOTTY, 0);
close(i);
}
}
#endif
/*
* now get the VT
*/
SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
if (result != 0)
{
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
SYSCALL(result =
ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
if (result != 0)
{
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
#if defined(DO_OS_FONTRESTORE)
lnx_savefont();
#endif
SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
if (result < 0)
{
FatalError("xf86OpenConsole: VT_GETMODE failed\n");
}
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed: %s\n",
strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
strerror(errno));
signal(SIGUSR1, xf86VTRequest);
VT.mode = VT_PROCESS;
VT.relsig = SIGUSR1;
VT.acqsig = SIGUSR1;
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
{
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
}
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
strerror(errno));
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
}
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
strerror(errno));
/* we really should have a InitOSInputDevices() function instead
* of Init?$#*&Device(). So I just place it here */
@ -247,24 +264,17 @@ xf86OpenConsole(void)
FatalError("Unable to set screen info\n");
close(fbfd);
#endif
}
else
{
/* serverGeneration != 1 */
} else { /* serverGeneration != 1 */
/*
* now get the VT
*/
SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
if (result != 0)
{
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
SYSCALL(result =
ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
if (result != 0)
{
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
strerror(errno));
}
return;
}
@ -277,31 +287,41 @@ xf86CloseConsole()
struct vt_stat vts;
int vtno = -1;
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) == 0)
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n",
strerror(errno));
else
vtno = vts.v_active;
#endif
#if 0
ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
#endif
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
{
/* Back to text mode ... */
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
strerror(errno));
else {
/* set dflt vt handling */
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
strerror(errno));
}
/*
* Perform a switch back to the active VT when we were started
*/
if (activeVT >= 0)
{
ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
if (activeVT >= 0) {
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
strerror(errno));
activeVT = -1;
}
#if defined(DO_OS_FONTRESTORE)
if (xf86Info.vtno == vtno)
if (xf86Info.vtno == vtno) /* check if we are active */
lnx_restorefont();
lnx_freefontdata();
#endif

View File

@ -215,6 +215,13 @@ SetKbdRepeat(InputInfoPtr pInfo, char rad)
#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
if (!xorgHWAccess) {
if (xf86EnableIO())
xorgHWAccess = TRUE;
else
return;
}
/* The ioport way */
for (i = 0; i < RATE_COUNT; i++)

View File

@ -490,7 +490,7 @@ volatile unsigned char *ioBase = NULL;
#endif
void
Bool
xf86EnableIO(void)
{
#if defined(__powerpc__)
@ -499,7 +499,7 @@ xf86EnableIO(void)
#endif
if (ExtendedEnabled)
return;
return TRUE;
#if defined(__powerpc__)
ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
@ -512,16 +512,20 @@ xf86EnableIO(void)
/* Should this be fatal or just a warning? */
#if 0
if (ioBase == MAP_FAILED) {
FatalError(
xf86Msg(X_WARNING,
"xf86EnableIOPorts: Failed to map iobase (%s)\n",
strerror(errno));
return FALSE;
}
#endif
}
close(fd);
#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
if (ioperm(0, 1024, 1) || iopl(3))
FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");
if (ioperm(0, 1024, 1) || iopl(3)) {
xf86Msg(X_WARNING,
"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
return FALSE;
}
# if !defined(__alpha__)
ioperm(0x40,4,0); /* trap access to the timer chip */
ioperm(0x60,4,0); /* trap access to the keyboard controller */
@ -529,7 +533,7 @@ xf86EnableIO(void)
#endif
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void

View File

@ -21,7 +21,7 @@
*
*/
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.18 2002/12/14 04:41:14 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.17 2000/10/28 01:42:27 mvojkovi Exp $ */
#include "X.h"
#include "input.h"
@ -297,7 +297,7 @@ removeIOSmem(void)
ioBase = MAP_FAILED;
}
void
Bool
xf86EnableIO()
{
if (IOEnabled++ == 0) {
@ -305,7 +305,8 @@ xf86EnableIO()
(char *)PHYS_ISA_IO_SPACE, 64*1024, SM_READ|SM_WRITE);
if (ioBase == MAP_FAILED) {
--IOEnabled;
FatalError("xf86EnableIO: Failed to map I/O\n");
xf86Msg(X_WARNING,"xf86EnableIO: Failed to map I/O\n");
return FALSE;
} else {
#ifdef DEBUG
ErrorF("xf86EnableIO: mapped I/O at vaddr 0x%08x\n",
@ -314,7 +315,7 @@ xf86EnableIO()
atexit(removeIOSmem);
}
}
return;
return TRUE;
}
void

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c,v 1.1 2002/06/03 21:22:10 dawes Exp $ */
/* $XFree86$ */
/*
* Copyright 2001 by J. Kean Johnston <jkj@caldera.com>
*
@ -62,14 +62,18 @@ extern long sysi86 (int cmd, ...);
static Bool IOEnabled = FALSE;
void xf86EnableIO(void)
Bool xf86EnableIO(void)
{
if (IOEnabled)
return;
return TRUE;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n");
return FALSE;
}
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
FatalError("Failed to set IOPL for extended I/O\n");
IOEnabled = TRUE;
return TRUE;
}
void xf86DisableIO(void)

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.4 2001/07/23 13:15:48 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.3 1998/07/25 16:57:00 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
@ -33,10 +33,10 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
void
Bool
xf86EnableIO()
{
return;
return TRUE;
}
void

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.3 2002/10/03 02:04:19 tsi Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.2 2001/10/28 03:34:03 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@ -147,18 +147,20 @@ xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
static Bool ExtendedEnabled = FALSE;
#endif
void
Bool
xf86EnableIO(void)
{
#ifdef i386
if (ExtendedEnabled)
return;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");
return TRUE;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
return FALSE;
}
ExtendedEnabled = TRUE;
#endif /* i386 */
return TRUE;
}
void

View File

@ -1,4 +1,4 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.21 2003/03/14 13:46:08 tsi Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.20tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@ -281,22 +281,23 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void
Bool
xf86EnableIO()
{
int i;
if (ExtendedEnabled)
return;
return TRUE;
if (SET_IOPL() < 0)
{
FatalError(
xf86Msg(X_WARNING,
"xf86EnableIO: Failed to set IOPL for extended I/O\n");
return FALSE;
}
ExtendedEnabled = TRUE;
return;
return TRUE;
}
void

View File

@ -125,6 +125,7 @@ extern void xf86WrapperInit(void);
#define xf86FatalError(a, b) \
if (dispatchException & DE_TERMINATE) { \
ErrorF(a, b); \
ErrorF("\n"); \
return; \
} else FatalError(a, b)
@ -144,7 +145,7 @@ extern pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
extern void xf86UnMapVidMem(int, pointer, unsigned long);
extern void xf86MapReadSideEffects(int, int, pointer, unsigned long);
extern int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
extern void xf86EnableIO(void);
extern Bool xf86EnableIO(void);
extern void xf86DisableIO(void);
extern Bool xf86DisableInterrupts(void);
extern void xf86EnableInterrupts(void);

View File

@ -195,7 +195,6 @@ main(int argc, char *argv[])
break;
}
xf86EnableIO();
pcrpp = xf86scanpci(0);
if (!pcrpp) {