summaryrefslogtreecommitdiff
path: root/xserver/hw
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/hw')
-rw-r--r--xserver/hw/xfree86/common/compiler.h16
-rw-r--r--xserver/hw/xfree86/common/xf86Config.c7
-rw-r--r--xserver/hw/xfree86/common/xf86Events.c2
-rw-r--r--xserver/hw/xfree86/common/xf86Init.c49
-rw-r--r--xserver/hw/xfree86/common/xf86Xinput.c2
-rw-r--r--xserver/hw/xfree86/doc/man/Xorg.man.pre12
-rw-r--r--xserver/hw/xfree86/dummylib/Makefile.am5
-rw-r--r--xserver/hw/xfree86/dummylib/chownlock.c10
-rw-r--r--xserver/hw/xfree86/dummylib/dispatchException.c8
-rw-r--r--xserver/hw/xfree86/dummylib/privsep.c18
-rw-r--r--xserver/hw/xfree86/dummylib/serverGeneration.c8
-rw-r--r--xserver/hw/xfree86/dummylib/useMsg.c11
-rw-r--r--xserver/hw/xfree86/dummylib/xalloc.c17
-rw-r--r--xserver/hw/xfree86/loader/dixsym.c8
-rw-r--r--xserver/hw/xfree86/os-support/bsd/Makefile.am10
-rw-r--r--xserver/hw/xfree86/os-support/bsd/alpha_video.c12
-rw-r--r--xserver/hw/xfree86/os-support/bsd/arm_video.c715
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsdResource.c5
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsd_agp.c329
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsd_init.c89
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsd_kbd.c20
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsd_mouse.c12
-rw-r--r--xserver/hw/xfree86/os-support/bsd/hp300_video.c120
-rw-r--r--xserver/hw/xfree86/os-support/bsd/hppa_video.c123
-rw-r--r--xserver/hw/xfree86/os-support/bsd/i386_video.c105
-rw-r--r--xserver/hw/xfree86/os-support/bsd/ppc_video.c28
-rw-r--r--xserver/hw/xfree86/os-support/bsd/sparc64_video.c13
-rw-r--r--xserver/hw/xfree86/os-support/bus/Pci.h39
-rw-r--r--xserver/hw/xfree86/os-support/bus/freebsdPci.c4
-rw-r--r--xserver/hw/xfree86/os-support/shared/libc_wrapper.c2
-rw-r--r--xserver/hw/xfree86/os-support/shared/posix_tty.c9
-rw-r--r--xserver/hw/xfree86/os-support/shared/sigio.c3
-rw-r--r--xserver/hw/xfree86/os-support/xf86OSmouse.h1
-rw-r--r--xserver/hw/xfree86/utils/xorgcfg/startx.c9
-rw-r--r--xserver/hw/xfree86/utils/xorgcfg/stubs.c2
-rw-r--r--xserver/hw/xfree86/utils/xorgcfg/text-mode.c26
-rw-r--r--xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c32
37 files changed, 1190 insertions, 691 deletions
diff --git a/xserver/hw/xfree86/common/compiler.h b/xserver/hw/xfree86/common/compiler.h
index a330fadf4..e9472201b 100644
--- a/xserver/hw/xfree86/common/compiler.h
+++ b/xserver/hw/xfree86/common/compiler.h
@@ -387,7 +387,12 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
}
/* to flush the I-cache before jumping to code which just got loaded */
+#ifdef __FreeBSD__
# define PAL_imb 134
+#endif
+#ifdef __OpenBSD__
+#include <machine/pal.h>
+#endif
# define istream_mem_barrier() \
__asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
# define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
@@ -906,6 +911,13 @@ static __inline__ void stw_u(unsigned long val, unsigned short *p)
# else
# define PORT_SIZE short
# endif
+# if defined(__arm32__) && defined(__OpenBSD__)
+/*
+# include <machine/sysarch.h>
+*/
+ int arm_sync_icache(long addr, int len);
+# define arm_flush_cache(addr) arm_sync_icache((long)(addr), 4);
+# endif
unsigned int IOPortBase; /* Memory mapped I/O port area */
@@ -1365,7 +1377,7 @@ do { \
# define write_mem_barrier() /* NOP */
# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__vax__)
# ifdef GCCUSESGAS
/*
@@ -1474,7 +1486,7 @@ inl(unsigned short port)
# endif /* GCCUSESGAS */
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__vax__) */
static __inline__ void
outb(unsigned short port, unsigned char val)
diff --git a/xserver/hw/xfree86/common/xf86Config.c b/xserver/hw/xfree86/common/xf86Config.c
index f1055928e..c050def4e 100644
--- a/xserver/hw/xfree86/common/xf86Config.c
+++ b/xserver/hw/xfree86/common/xf86Config.c
@@ -1220,7 +1220,11 @@ configInputKbd(IDevPtr inputp)
" the \"wskbd\" keyboard protocol");
return FALSE;
}
+#ifndef X_PRIVSEP
xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
+#else
+ xf86Info.kbdFd = priv_open_device(s);
+#endif
if (xf86Info.kbdFd == -1) {
xf86ConfigError("cannot open \"%s\"", s);
xfree(s);
@@ -1264,7 +1268,8 @@ configInputKbd(IDevPtr inputp)
close(xf86Info.kbdFd);
return FALSE;
}
-#endif
+ close (xf86Info.kbdFd);
+#endif /* WSCONS_SUPPORT */
} else {
xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
xfree(s);
diff --git a/xserver/hw/xfree86/common/xf86Events.c b/xserver/hw/xfree86/common/xf86Events.c
index b1ee1e93e..4769daeb8 100644
--- a/xserver/hw/xfree86/common/xf86Events.c
+++ b/xserver/hw/xfree86/common/xf86Events.c
@@ -511,6 +511,7 @@ xf86PostKbdEvent(unsigned key)
}
} else
#endif /* i386 && SVR4 */
+#ifndef __OpenBSD__
{
switch (scanCode) {
case 0x59: scanCode = KEY_0x59; break;
@@ -543,6 +544,7 @@ xf86PostKbdEvent(unsigned key)
case 0x76: scanCode = KEY_0x76; break;
}
}
+#endif
}
else if (
diff --git a/xserver/hw/xfree86/common/xf86Init.c b/xserver/hw/xfree86/common/xf86Init.c
index 8f0a26dd7..6a9d2f38d 100644
--- a/xserver/hw/xfree86/common/xf86Init.c
+++ b/xserver/hw/xfree86/common/xf86Init.c
@@ -147,6 +147,10 @@ static InputDriverRec XF86KEYBOARD = {
};
#endif
+#ifdef X_PRIVSEP
+static Bool xf86KeepPriv = FALSE;
+#endif
+
static Bool
xf86CreateRootWindow(WindowPtr pWin)
{
@@ -1139,9 +1143,14 @@ InitInput(argc, argv)
* OS/Vendor-specific initialisations. Called from OsInit(), which
* is called by dix before establishing the well known sockets.
*/
+
+#ifdef X_PRIVSEP
+extern void xf86DropPriv(char *);
+extern void xf86PrivilegedInit(void);
+#endif
void
-OsVendorInit()
+OsVendorInit(void)
{
static Bool beenHere = FALSE;
@@ -1182,6 +1191,12 @@ OsVendorInit()
}
#endif
#endif
+#if defined(X_PRIVSEP)
+ if (!beenHere && !xf86KeepPriv && geteuid() == 0) {
+ xf86PrivilegedInit();
+ xf86DropPriv(display);
+ }
+#endif
beenHere = TRUE;
}
@@ -1349,8 +1364,9 @@ ddxProcessArgument(int argc, char **argv, int i)
FatalError("Required argument to %s not specified\n", argv[i]); \
}
- /* First the options that are only allowed for root */
- if (getuid() == 0 || geteuid() != 0)
+ /* First the options that are only allowed for root
+ or when the program is not privileged at all */
+ if (getuid() == 0 || !issetugid())
{
if (!strcmp(argv[i], "-modulepath"))
{
@@ -1390,6 +1406,11 @@ ddxProcessArgument(int argc, char **argv, int i)
argv[i], argv[i]);
}
xf86ConfigFile = argv[i + 1];
+#ifdef X_PRIVSEP
+ /* Cannot drop privs when -xf86config is used with unsafe path */
+ if (!xf86PathIsSafe(xf86ConfigFile))
+ xf86KeepPriv = TRUE;
+#endif
return 2;
}
if (!strcmp(argv[i],"-showunresolved"))
@@ -1646,18 +1667,35 @@ ddxProcessArgument(int argc, char **argv, int i)
if (!strcmp(argv[i], "-probe"))
{
xf86DoProbe = TRUE;
+#if 0
+ DoProbe(argc, argv, i);
+#endif
return 1;
}
if (!strcmp(argv[i], "-configure"))
{
- if (getuid() != 0 && geteuid() == 0) {
+ if (getuid() != 0 && issetugid()) {
ErrorF("The '-configure' option can only be used by root.\n");
exit(1);
}
xf86DoConfigure = TRUE;
xf86AllowMouseOpenFail = TRUE;
+#ifdef X_PRIVSEP
+ xf86KeepPriv = TRUE;
+#endif
return 1;
}
+#ifdef X_PRIVSEP
+ if (!strcmp(argv[i], "-keepPriv"))
+ {
+ if (getuid() != 0) {
+ ErrorF("The '-keepPriv' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86KeepPriv = TRUE;
+ return 1;
+ }
+#endif
if (!strcmp(argv[i], "-isolateDevice"))
{
int bus, device, func;
@@ -1737,6 +1775,9 @@ ddxUseMsg()
ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
ErrorF("-version show the server version\n");
+#ifdef X_PRIVSEP
+ ErrorF("-keepPriv don't revoque privs when running as root\n");
+#endif
/* OS-specific usage */
xf86UseMsg();
ErrorF("\n");
diff --git a/xserver/hw/xfree86/common/xf86Xinput.c b/xserver/hw/xfree86/common/xf86Xinput.c
index c56475b12..ad4fb8112 100644
--- a/xserver/hw/xfree86/common/xf86Xinput.c
+++ b/xserver/hw/xfree86/common/xf86Xinput.c
@@ -950,7 +950,7 @@ xf86PostMotionEvent(DeviceIntPtr device,
}
}
else if (dx || dy) {
- mult = pow((float)(dx*dx+dy*dy),
+ mult = pow((float)dx*(float)dx + (float)dy*(float)dy,
((float)(device->ptrfeed->ctrl.num) /
(float)(device->ptrfeed->ctrl.den) - 1.0) /
2.0) / 2.0;
diff --git a/xserver/hw/xfree86/doc/man/Xorg.man.pre b/xserver/hw/xfree86/doc/man/Xorg.man.pre
index b7fa990bb..8178043b5 100644
--- a/xserver/hw/xfree86/doc/man/Xorg.man.pre
+++ b/xserver/hw/xfree86/doc/man/Xorg.man.pre
@@ -270,6 +270,14 @@ is ignored if
.I bustype
is anything other than \(oqPCI\(cq.
.TP 8
+.B \-keepPriv
+Prevent the server from revoking its privileges. If this option is
+not specified, the X server will change its uid and gid either to
+those of the user who started it or to the \fI_x11\fP user and group
+if it was started by the super-user, after performing the
+initialisations that require super-user privileges. Only root can use
+this option.
+.TP 8
.B \-keeptty
Prevent the server from detaching its initial controlling terminal.
This option is only useful when debugging the server. Not all platforms
@@ -571,10 +579,10 @@ Libraries.
.B __projectroot__/lib/X11/fonts/\(**
Fonts.
.TP 30
-.B __projectroot__/share/X11/rgb.txt
+.B __projectroot__/lib/X11/rgb.txt
Color names to RGB mapping.
.TP 30
-.B __projectroot__/share/X11/XErrorDB
+.B __projectroot__/lib/X11/XErrorDB
Client error message database.
.TP 30
.B __projectroot__/lib/X11/app-defaults/\(**
diff --git a/xserver/hw/xfree86/dummylib/Makefile.am b/xserver/hw/xfree86/dummylib/Makefile.am
index d89ee59a8..be48277a1 100644
--- a/xserver/hw/xfree86/dummylib/Makefile.am
+++ b/xserver/hw/xfree86/dummylib/Makefile.am
@@ -13,11 +13,16 @@ STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c
endif
libdummy_nonserver_a_SOURCES = \
+ chownlock.c \
+ dispatchException.c \
fatalerror.c \
getvalidbios.c \
getemptypci.c \
logvwrite.c \
pcitestmulti.c \
+ privsep.c \
+ serverGeneration.c \
+ useMsg.c \
$(STRL_SRCS) \
verrorf.c \
xalloc.c \
diff --git a/xserver/hw/xfree86/dummylib/chownlock.c b/xserver/hw/xfree86/dummylib/chownlock.c
new file mode 100644
index 000000000..f4b01901f
--- /dev/null
+++ b/xserver/hw/xfree86/dummylib/chownlock.c
@@ -0,0 +1,10 @@
+/*
+ * Public domain
+ */
+/* $OpenBSD: chownlock.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+#include <sys/types.h>
+int
+ChownLock(uid_t uid, gid_t gid)
+{
+ return 0;
+}
diff --git a/xserver/hw/xfree86/dummylib/dispatchException.c b/xserver/hw/xfree86/dummylib/dispatchException.c
new file mode 100644
index 000000000..6ceb91e84
--- /dev/null
+++ b/xserver/hw/xfree86/dummylib/dispatchException.c
@@ -0,0 +1,8 @@
+/**
+ ** Public domain
+ **/
+/* $OpenBSD: dispatchException.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+
+#include "opaque.h"
+
+volatile char dispatchException;
diff --git a/xserver/hw/xfree86/dummylib/privsep.c b/xserver/hw/xfree86/dummylib/privsep.c
new file mode 100644
index 000000000..bb25d6d08
--- /dev/null
+++ b/xserver/hw/xfree86/dummylib/privsep.c
@@ -0,0 +1,18 @@
+/**
+ ** Public domain
+ **/
+/* $OpenBSD: privsep.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+#include <sys/types.h>
+#include <fcntl.h>
+
+int
+priv_init(uid_t uid, gid_t gid)
+{
+ return 0;
+}
+
+int
+priv_open_device(char *path)
+{
+ return open(path, O_RDWR);
+}
diff --git a/xserver/hw/xfree86/dummylib/serverGeneration.c b/xserver/hw/xfree86/dummylib/serverGeneration.c
new file mode 100644
index 000000000..07982b7bc
--- /dev/null
+++ b/xserver/hw/xfree86/dummylib/serverGeneration.c
@@ -0,0 +1,8 @@
+/**
+ ** Public domain
+ **/
+/* $OpenBSD: serverGeneration.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+
+#include "misc.h"
+
+unsigned long serverGeneration;
diff --git a/xserver/hw/xfree86/dummylib/useMsg.c b/xserver/hw/xfree86/dummylib/useMsg.c
new file mode 100644
index 000000000..a1ce12cc8
--- /dev/null
+++ b/xserver/hw/xfree86/dummylib/useMsg.c
@@ -0,0 +1,11 @@
+/**
+ ** Public Domain
+ **/
+/* $OpenBSD: useMsg.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+
+#include "os.h"
+
+void
+UseMsg(void)
+{
+}
diff --git a/xserver/hw/xfree86/dummylib/xalloc.c b/xserver/hw/xfree86/dummylib/xalloc.c
index b671d4dde..5a8d5b7d3 100644
--- a/xserver/hw/xfree86/dummylib/xalloc.c
+++ b/xserver/hw/xfree86/dummylib/xalloc.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/xalloc.c,v 1.1 2000/02/13 03:06:39 dawes Exp $ */
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
@@ -12,7 +13,7 @@
* Utility functions required by libxf86_os.
*/
-_X_EXPORT pointer
+pointer
Xalloc(unsigned long n)
{
if (!n)
@@ -20,7 +21,7 @@ Xalloc(unsigned long n)
return malloc(n);
}
-_X_EXPORT pointer
+pointer
Xrealloc(pointer p, unsigned long n)
{
if (!n)
@@ -28,7 +29,7 @@ Xrealloc(pointer p, unsigned long n)
return realloc(p, n);
}
-_X_EXPORT pointer
+pointer
Xcalloc(unsigned long n)
{
pointer r;
@@ -38,7 +39,7 @@ Xcalloc(unsigned long n)
return r;
}
-_X_EXPORT pointer
+pointer
XNFalloc(unsigned long n)
{
pointer r;
@@ -50,7 +51,7 @@ XNFalloc(unsigned long n)
}
-_X_EXPORT pointer
+pointer
XNFrealloc(pointer p, unsigned long n)
{
pointer r;
@@ -62,7 +63,7 @@ XNFrealloc(pointer p, unsigned long n)
}
-_X_EXPORT pointer
+pointer
XNFcalloc(unsigned long n)
{
pointer r;
@@ -74,13 +75,13 @@ XNFcalloc(unsigned long n)
}
-_X_EXPORT void
+void
Xfree(pointer p)
{
free(p);
}
-_X_EXPORT char *
+char *
Xstrdup(const char *s)
{
char *sd;
diff --git a/xserver/hw/xfree86/loader/dixsym.c b/xserver/hw/xfree86/loader/dixsym.c
index 27a3093b1..efb4dff59 100644
--- a/xserver/hw/xfree86/loader/dixsym.c
+++ b/xserver/hw/xfree86/loader/dixsym.c
@@ -90,6 +90,10 @@
extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
#endif
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *);
+#endif
+
extern Selection *CurrentSelections;
extern int NumCurrentSelections;
@@ -341,6 +345,10 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(AdjustWaitForDelay)
SYMVAR(noTestExtensions)
SYMFUNC(GiveUp)
+#ifdef X_PRIVSEP
+ /* privsep.c */
+ SYMFUNC(priv_open_device)
+#endif
#ifdef BIGREQS
SYMVAR(noBigReqExtension)
diff --git a/xserver/hw/xfree86/os-support/bsd/Makefile.am b/xserver/hw/xfree86/os-support/bsd/Makefile.am
index 20885e866..10ff44c4e 100644
--- a/xserver/hw/xfree86/os-support/bsd/Makefile.am
+++ b/xserver/hw/xfree86/os-support/bsd/Makefile.am
@@ -15,7 +15,7 @@ endif
RES_SOURCES = $(srcdir)/../shared/stdResource.c
if AGP
-AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c
+AGP_SOURCES = bsd_agp.c
else
AGP_SOURCES = $(srcdir)/../shared/agp_noop.c
endif
@@ -33,6 +33,14 @@ if ARM_VIDEO
ARCH_SOURCES = arm_video.c
endif
+if HP300_VIDEO
+ARCH_SOURCES = hp300_video.c
+endif
+
+if HPPA_VIDEO
+ARCH_SOURCES = hppa_video.c
+endif
+
if I386_VIDEO
ARCH_SOURCES = i386_video.c
endif
diff --git a/xserver/hw/xfree86/os-support/bsd/alpha_video.c b/xserver/hw/xfree86/os-support/bsd/alpha_video.c
index 5052b7862..6cb58fa4b 100644
--- a/xserver/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xserver/hw/xfree86/os-support/bsd/alpha_video.c
@@ -732,3 +732,15 @@ _X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
= readDense32;
+/*
+ * Do all things that need root privileges early
+ * and revoke those priviledges
+ */
+_X_EXPORT void
+xf86PrivilegedInit(void)
+{
+ xf86EnableIO();
+ checkDevMem(TRUE);
+ pciInit();
+ xf86OpenConsole();
+}
diff --git a/xserver/hw/xfree86/os-support/bsd/arm_video.c b/xserver/hw/xfree86/os-support/bsd/arm_video.c
index 4a3d5ca52..4c95b68aa 100644
--- a/xserver/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xserver/hw/xfree86/os-support/bsd/arm_video.c
@@ -1,3 +1,5 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c,v 1.6 2003/10/07 23:14:55 herrb Exp $ */
+/* $OpenBSD: arm_video.c,v 1.2 2006/11/28 20:29:31 matthieu Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,39 +25,6 @@
*
*/
-/*
- * The ARM32 code here carries the following copyright:
- *
- * Copyright 1997
- * Digital Equipment Corporation. All rights reserved.
- * This software is furnished under license and may be used and copied only in
- * accordance with the following terms and conditions. Subject to these
- * conditions, you may download, copy, install, use, modify and distribute
- * this software in source and/or binary form. No title or ownership is
- * transferred hereby.
- *
- * 1) Any source code used, modified or distributed must reproduce and retain
- * this copyright notice and list of conditions as they appear in the
- * source file.
- *
- * 2) No right is granted to use any trade name, trademark, or logo of Digital
- * Equipment Corporation. Neither the "Digital Equipment Corporation"
- * name nor any trademark or logo of Digital Equipment Corporation may be
- * used to endorse or promote products derived from this software without
- * the prior written permission of Digital Equipment Corporation.
- *
- * 3) This software is provided "AS-IS" and any express or implied warranties,
- * including but not limited to, any implied warranties of merchantability,
- * fitness for a particular purpose, or non-infringement are disclaimed.
- * In no event shall DIGITAL be liable for any damages whatsoever, and in
- * particular, DIGITAL shall not be liable for special, indirect,
- * consequential, or incidental damages or damages for lost profits, loss
- * of revenue or loss of use, whether such damages arise in contract,
- * negligence, tort, under statute, in equity, at law or otherwise, even
- * if advised of the possibility of such damage.
- *
- */
-
/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,625 +34,207 @@
#include <X11/X.h>
#include "xf86.h"
#include "xf86Priv.h"
+
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
-#ifdef __arm32__
-#include "machine/devmap.h"
-struct memAccess
-{
- int ioctl;
- struct map_info memInfo;
- pointer regionVirtBase;
- Bool Checked;
- Bool OK;
-};
-
-static pointer xf86MapInfoMap();
-static void xf86MapInfoUnmap();
-static struct memAccess *checkMapInfo();
-extern int vgaPhysLinearBase;
-
-/* A memAccess structure is needed for each possible region */
-struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
- FALSE, FALSE };
-struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
- FALSE, FALSE };
-struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
- FALSE, FALSE };
-#endif /* __arm32__ */
-
-#if defined(__NetBSD__) && !defined(MAP_FILE)
-#define MAP_FLAGS MAP_SHARED
-#else
-#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
-#endif
+#include "bus/Pci.h"
#ifndef MAP_FAILED
#define MAP_FAILED ((caddr_t)-1)
#endif
-
-#define BUS_BASE 0L
-#define BUS_BASE_BWX 0L
-
+#include <sys/param.h>
+#include <sys/sysctl.h>
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
-static Bool useDevMem = FALSE;
-static int devMemFd = -1;
-
-#define DEV_MEM "/dev/mem"
-
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
-/*
- * Check if /dev/mem can be mmap'd. If it can't print a warning when
- * "warn" is TRUE.
- */
-static void
-checkDevMem(Bool warn)
-{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
+#ifdef __OpenBSD__
+#undef DEV_MEM
+#define DEV_MEM "/dev/xf86"
+#endif
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
-
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
- {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED)
- {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- /* This should not happen */
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
- }
- }
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
-}
+static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
+static void ppcUnmapVidMem(int, pointer, unsigned long);
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
-
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = armMapVidMem;
- pVidMem->unmapVidMem = armUnmapVidMem;
-
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = ppcMapVidMem;
+ pVidMem->unmapMem = ppcUnmapVidMem;
pVidMem->initialised = TRUE;
}
+
+volatile unsigned char *ioBase = MAP_FAILED;
+
static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
+ int fd = xf86Info.screenFd;
pointer base;
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
+ Base, Size, fd);
+#endif
- checkDevMem(FALSE);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- 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",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return(base);
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%x outside allowable range\n",
- "xf86MapVidMem", Base);
- }
base = mmap(0, Size,
(flags & VIDMEM_READONLY) ?
PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.screenFd,
- (unsigned long)Base - 0xA0000);
+ MAP_SHARED, fd, Base);
if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return(base);
+ FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+
+ return base;
}
static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap((caddr_t)Base, Size);
+ munmap(Base, Size);
}
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
+static int kmem = -1;
-_X_EXPORT int
+int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
int Len)
{
- unsigned char *ptr;
- int psize;
- int mlen;
+ int rv;
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return(-1);
+ if (Base < 0x80000000) {
+ xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base);
+ return 0;
}
- psize = xf86getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return(-1);
- }
-#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
-#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return(Len);
-}
-
-
-/* XXX This needs to be updated for the ND */
-
-/*
-** Find out whether the console driver provides memory mapping information
-** for the specified region and return the map_info pointer. Print a warning if required.
-*/
-static struct memAccess *
-checkMapInfo(Bool warn, int Region)
-{
- struct memAccess *memAccP;
-
- switch (Region)
- {
- case VGA_REGION:
- memAccP = &vgaMemInfo;
- break;
-
- case LINEAR_REGION:
- memAccP = &linearMemInfo;
- break;
-
- case MMIO_REGION:
- memAccP = &ioMemInfo;
- break;
-
- default:
- return NULL;
- break;
- }
-
- if(!memAccP->Checked)
- {
- if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
- {
- if(warn)
- {
- xf86Msg(X_WARNING,
- "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
- Region, strerror(errno));
- }
- }
- else
- {
- if(memAccP->memInfo.u.map_info_mmap.map_offset
- != MAP_INFO_UNKNOWN)
- memAccP->OK = TRUE;
- }
- memAccP->Checked = TRUE;
- }
- if (memAccP->OK)
- {
- return memAccP;
- }
- else
- {
- return NULL;
- }
-}
-
-static pointer
-xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- Size = (unsigned long)Base + Size;
- }
- else
- {
- Size = mapInfoP->u.map_info_mmap.map_size;
- }
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- /* Need to remap if size is unknown because we may not have
- mapped the whole region initially */
- if(memInfoP->regionVirtBase == NULL ||
- mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- if((memInfoP->regionVirtBase =
- mmap((caddr_t)0,
- Size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- xf86Info.screenFd,
- (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
- == (pointer)-1)
- {
- FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
- mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
+ if (kmem == -1) {
+ kmem = open(DEV_MEM, 2);
+ if (kmem == -1) {
+ FatalError("xf86ReadBIOS: open %s", DEV_MEM);
}
- if(mapInfoP->u.map_info_mmap.internal_offset > 0)
- memInfoP->regionVirtBase +=
- mapInfoP->u.map_info_mmap.internal_offset;
- }
- break;
-
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-
- return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
-}
-
-static void
-xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- if(memInfoP->regionVirtBase != NULL)
- {
- if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
- Size = mapInfoP->u.map_info_mmap.map_size;
- munmap((caddr_t)memInfoP->regionVirtBase, Size);
- memInfoP->regionVirtBase = NULL;
- }
- break;
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-}
-
-static pointer
-armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- /*
- ** xf86 passes in a physical address offset from the start
- ** of physical memory, but xf86MapInfoMap expects an
- ** offset from the start of the specified region - it gets
- ** the physical address of the region from the display driver.
- */
- switch(Region)
- {
- case LINEAR_REGION:
- if (vgaPhysLinearBase)
- {
- Base -= vgaPhysLinearBase;
- }
- break;
- case VGA_REGION:
- Base -= 0xA0000;
- break;
- }
-
- base = xf86MapInfoMap(memInfoP, Base, Size);
- return (base);
- }
- return mapVidMem(ScreenNum, Base, Size, flags);
-}
-
-static void
-armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, Base, Size);
}
- unmapVidMem(ScreenNum, Base, Size);
-}
-
-#ifdef USE_DEV_IO
-static int IoFd = -1;
-
-_X_EXPORT Bool
-xf86EnableIO()
-{
- if (IoFd >= 0)
- return TRUE;
-
- if ((IoFd = open("/dev/io", O_RDWR)) == -1)
- {
- xf86Msg(X_WARNING,"xf86EnableIO: "
- "Failed to open /dev/io for extended I/O\n");
- return FALSE;
- }
- return TRUE;
-}
-
-_X_EXPORT void
-xf86DisableIO()
-{
- if (IoFd < 0)
- return;
-
- close(IoFd);
- IoFd = -1;
- return;
-}
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n",
+ Base, Offset, Len);
#endif
-#if defined(USE_ARC_MMAP) || defined(__arm32__)
-
-Bool
-xf86EnableIO()
-{
- int fd;
- pointer base;
-
- if (ExtendedEnabled)
- return TRUE;
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
- }
- else {
- xf86Msg("EnableIO: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
-
- ExtendedEnabled = TRUE;
-
- return TRUE;
+ lseek(kmem, Base + Offset, 0);
+ rv = read(kmem, Buf, Len);
+ return rv;
}
-void
-xf86DisableIO()
-{
- return;
-}
-
-#endif /* USE_ARC_MMAP */
-
-
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
-_X_EXPORT Bool
+Bool
xf86DisableInterrupts()
{
return(TRUE);
}
-_X_EXPORT void
+void
xf86EnableInterrupts()
{
return;
}
-
-
-#if 0
/*
- * XXX This is here for reference. It needs to be handled differently for the
- * ND.
+ * Do all initialisation that need root privileges
*/
-#if defined(USE_ARC_MMAP) || defined(__arm32__)
-
-#ifdef USE_ARM32_MMAP
-#define DEV_MEM_IOBASE 0x43000000
-#endif
-
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-
-Bool
-xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
- int fd;
- pointer base;
-
-#ifdef __arm32__
- struct memAccess *memInfoP;
- int *Size;
-#endif
-
- ScreenEnabled[ScreenNum] = TRUE;
-
- if (ExtendedEnabled)
- return TRUE;
-
-#ifdef USE_ARC_MMAP
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_ERROR,
- "EnableIOPorts: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
- }
- else {
- xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
-#endif
-
-#ifdef __arm32__
- IOPortBase = (unsigned int)-1;
-
- if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
- {
- /*
- * xf86MapInfoMap maps an offset from the start of video IO
- * space (e.g. 0x3B0), but IOPortBase is expected to map to
- * physical address 0x000, so subtract the start of video I/O
- * space from the result. This is safe for now becase we
- * actually mmap the start of the page, then the start of video
- * I/O space is added as an internal offset.
- */
- IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
- (caddr_t)0x0, 0L)
- - memInfoP->memInfo.u.map_info_mmap.internal_offset;
- ExtendedEnabled = TRUE;
- return TRUE;
- }
-#ifdef USE_ARM32_MMAP
- checkDevMem(TRUE);
-
- if (devMemFd >= 0 && useDevMem)
- {
- base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
- MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
-
- if (base != (pointer)-1)
- IOPortBase = (unsigned int)base;
- }
-
- if (IOPortBase == (unsigned int)-1)
- {
- 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 */
- 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 TRUE;
-}
-
void
-xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
-#ifdef __arm32__
- struct memAccess *memInfoP;
-#endif
-
- ScreenEnabled[ScreenNum] = FALSE;
-
-#ifdef __arm32__
- if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, 0);
+xf86PrivilegedInit(void)
+{
+ int mib[2];
+ char buf[128];
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_MACHINE;
+ len = sizeof(buf);
+ if (sysctl(mib, 2, buf, &len, NULL, 0) < 0) {
+ FatalError("Cannot get hw.machine");
+ }
+ if (strcmp(buf, "zaurus") != 0) {
+ /* Not Zaurus */
+ kmem = open(DEV_MEM, 2);
+ if (kmem == -1) {
+ ErrorF("errno: %d\n", errno);
+ FatalError("xf86PrivilegedInit: open %s", DEV_MEM);
+ }
}
-#endif
-
-#ifdef USE_ARM32_MMAP
- if (!ExtendedEnabled)
- return;
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
-
- munmap((caddr_t)IOPortBase, 0x400);
- IOPortBase = (unsigned int)-1;
- ExtendedEnabled = FALSE;
-#endif
-
- return;
+ pciInit();
+ xf86OpenConsole();
}
-#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
-#endif
-
-
+#ifdef __VFP_FP__
+/*
+ * force softfloat functions into binary,
+ * yes the protos/ret are all bogus.
+ */
+arm_softfloat()
+{
+void __adddf3();
+void __addsf3();
+void __eqdf2();
+void __eqsf2();
+void __extendsfdf2();
+void __fixdfsi();
+void __fixsfsi();
+void __fixunsdfsi();
+void __fixunssfsi();
+void __floatsidf();
+void __floatsisf();
+void __gedf2();
+void __gesf2();
+void __gtdf2();
+void __gtsf2();
+void __ledf2();
+void __lesf2();
+void __ltdf2();
+void __ltsf2();
+void __nedf2();
+void __negdf2();
+void __negsf2();
+void __nesf2();
+void __subdf3();
+void __subsf3();
+void __truncdfsf2();
+
+__adddf3();
+__addsf3();
+__eqdf2();
+__eqsf2();
+__extendsfdf2();
+__fixdfsi();
+__fixsfsi();
+__fixunsdfsi();
+__fixunssfsi();
+__floatsidf();
+__floatsisf();
+__gedf2();
+__gesf2();
+__gtdf2();
+__gtsf2();
+__ledf2();
+__lesf2();
+__ltdf2();
+__ltsf2();
+__nedf2();
+__negdf2();
+__negsf2();
+__nesf2();
+__subdf3();
+__subsf3();
+__truncdfsf2();
+}
+#endif /* __VFP_FP__ */
diff --git a/xserver/hw/xfree86/os-support/bsd/bsdResource.c b/xserver/hw/xfree86/os-support/bsd/bsdResource.c
index 37749c913..65aa9fde7 100644
--- a/xserver/hw/xfree86/os-support/bsd/bsdResource.c
+++ b/xserver/hw/xfree86/os-support/bsd/bsdResource.c
@@ -21,7 +21,8 @@ _X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
#ifdef INCLUDE_XF86_NO_DOMAIN
-#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
+#if defined(__alpha__) || defined(__sparc__) || defined(__sparc64__) \
+ || defined(__amd64__) || defined(__hppa__)
resPtr
xf86BusAccWindowsFromOS(void)
@@ -115,7 +116,7 @@ xf86AccResFromOS(resPtr ret)
return ret;
}
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__arm__) || defined(__mc68020__) /* XXX hp300 */ || defined(__vax__)
resPtr
xf86BusAccWindowsFromOS(void)
diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_agp.c b/xserver/hw/xfree86/os-support/bsd/bsd_agp.c
new file mode 100644
index 000000000..cc1231d9a
--- /dev/null
+++ b/xserver/hw/xfree86/os-support/bsd/bsd_agp.c
@@ -0,0 +1,329 @@
+/* $OpenBSD: bsd_agp.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for OpenBSD
+ *
+ * Copyright © 2000 VA Linux Systems, Inc.
+ * Copyright © 2001 The XFree86 Project, Inc.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.11 2003/04/03 22:47:42 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#include <sys/ioctl.h>
+#include <sys/agpio.h>
+
+/* AGP page size is independent of the host page size. */
+#ifndef AGP_PAGE_SIZE
+#define AGP_PAGE_SIZE 4096
+#endif
+
+static int gartFd = -1;
+static int acquiredScreen = -1;
+static Bool initDone = FALSE;
+
+/*
+ * Close /dev/agpgart. This frees all associated memory allocated during
+ * this server generation.
+ */
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ if(gartFd != -1) {
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
+ */
+static Bool
+GARTInit(int screenNum)
+{
+ struct _agp_info agpinf;
+
+ if (initDone)
+ return (gartFd != -1);
+
+ initDone = TRUE;
+
+ if (gartFd == -1)
+ gartFd = xf86Info.consoleFd;
+ else
+ return FALSE;
+
+ xf86AcquireGART(-1);
+ /* Check the kernel driver version. */
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno));
+ gartFd = -1;
+ return FALSE;
+ }
+ xf86ReleaseGART(-1);
+
+ return TRUE;
+}
+
+Bool
+xf86AgpGARTSupported()
+{
+ return GARTInit(-1);
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ struct _agp_info agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+
+ if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ memset((char*)&agpinf, 0, sizeof(agpinf));
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.bridge_id;
+ info->agpMode = agpinf.agp_mode;
+ info->base = agpinf.aper_base;
+ info->size = agpinf.aper_size;
+ info->totalPages = agpinf.pg_total;
+ info->systemPages = agpinf.pg_system;
+ info->usedPages = agpinf.pg_used;
+
+ xf86DrvMsg(screenNum, X_INFO, "Kernel reported %lu total, %lu used\n",
+ (unsigned long)agpinf.pg_total, (unsigned long)agpinf.pg_used);
+
+ return info;
+}
+
+/*
+ * XXX If multiple screens can acquire the GART, should we have a reference
+ * count instead of using acquiredScreen?
+ */
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (screenNum == -1 || acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ }
+ return TRUE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Linux driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+ if (screenNum == -1) {
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ struct _agp_allocate alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ */
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ /* XXX check for pages == 0? */
+
+ alloc.pg_count = pages;
+ alloc.type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = alloc.physical;
+
+ return alloc.key;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: "
+ "deallocation gart memory with key %d failed\n\t(%s)\n",
+ key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ struct _agp_bind bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86BindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.pg_start = pageOffset;
+ bind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* Unbind GART memory with "key" */
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ struct _agp_unbind unbind;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ unbind.priority = 0;
+ unbind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
+
+ return TRUE;
+}
+
+
+/* XXX Interface may change. */
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup setup;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ setup.agp_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %ld failed (%s)\n",
+ (unsigned long)mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_init.c b/xserver/hw/xfree86/os-support/bsd/bsd_init.c
index eb6d85053..782e3677b 100644
--- a/xserver/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xserver/hw/xfree86/os-support/bsd/bsd_init.c
@@ -38,6 +38,10 @@
#include <sys/utsname.h>
#include <sys/ioctl.h>
+#ifdef X_PRIVSEP
+#include "os.h"
+#include <pwd.h>
+#endif
#include <stdlib.h>
#include <errno.h>
@@ -164,12 +168,18 @@ xf86OpenConsole()
vtmode_t vtmode;
#endif
+#ifdef X_PRIVSEP
+ if (xf86Info.consoleFd != -1) {
+ return;
+ }
+#endif
if (serverGeneration == 1)
{
/* check if we are run with euid==0 */
- if (geteuid() != 0)
+ if (geteuid() != 0 && issetugid())
{
- FatalError("xf86OpenConsole: Server must be suid root");
+ FatalError("xf86OpenConsole: Server must either be suid root"
+ " or without privileges at all");
}
if (!KeepTty)
@@ -283,17 +293,17 @@ acquire_vt:
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
- signal(SIGUSR1, xf86VTRequest);
+ signal(SIGUSR2, xf86VTRequest);
vtmode.mode = VT_PROCESS;
- vtmode.relsig = SIGUSR1;
- vtmode.acqsig = SIGUSR1;
- vtmode.frsig = SIGUSR1;
+ vtmode.relsig = SIGUSR2;
+ vtmode.acqsig = SIGUSR2;
+ vtmode.frsig = SIGUSR2;
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
{
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
}
-#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
{
FatalError("xf86OpenConsole: KDENABIO failed (%s)",
@@ -308,8 +318,7 @@ acquire_vt:
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
case WSCONS:
- fprintf(stderr, "xf86OpenConsole\n");
- /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */
+ /* Nothing to do */
break;
#endif
}
@@ -510,7 +519,12 @@ xf86OpenPcvt()
vtprefix = "/dev/ttyC";
#endif
- fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ if (VTnum != -1) {
+ snprintf(vtname, sizeof(vtname), "%s%x", vtprefix, VTnum - 1);
+ fd = open(vtname, PCVT_CONSOLE_MODE, 0);
+ } else {
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ }
#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
if (fd < 0)
{
@@ -573,8 +587,14 @@ xf86OpenPcvt()
sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
{
- FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
}
if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
{
@@ -583,8 +603,8 @@ xf86OpenPcvt()
xf86Info.consType = PCVT;
#ifdef WSCONS_SUPPORT
xf86Msg(X_PROBED,
- "Using wscons driver in pcvt compatibility mode "
- "(version %d.%d)\n",
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
pcvt_version.rmajor, pcvt_version.rminor);
#else
xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
@@ -618,7 +638,7 @@ xf86OpenWScons()
#if defined(__NetBSD__)
sprintf(ttyname, "/dev/ttyE%d", i);
#elif defined(__OpenBSD__)
- sprintf(ttyname, "/dev/ttyC%d", i);
+ sprintf(ttyname, "/dev/ttyC%x", i);
#endif
if ((fd = open(ttyname, 2)) != -1)
break;
@@ -660,7 +680,7 @@ xf86CloseConsole()
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
}
-#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
{
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
@@ -692,6 +712,9 @@ xf86CloseConsole()
}
}
close(xf86Info.consoleFd);
+#ifdef X_PRIVSEP
+ xf86Info.consoleFd = -1;
+#endif
if (devConsoleFd >= 0)
close(devConsoleFd);
return;
@@ -735,3 +758,39 @@ xf86UseMsg()
ErrorF("don't detach controlling tty (for debugging only)\n");
return;
}
+
+#ifdef X_PRIVSEP
+/*
+ * Revoke privileges after init.
+ * If the X server is started as root (xdm case), then switch to _x11
+ * if it exists.
+ * Otherwise use the real uid.
+ */
+void
+xf86DropPriv(char *disp)
+{
+ struct passwd *pw;
+
+ /* revoke privileges */
+ if (getuid() == 0) {
+ /* Running as root */
+ pw = getpwnam("_x11");
+ if (!pw)
+ return;
+ /* give away lock file to unpriviledged user */
+ if (ChownLock(pw->pw_uid, pw->pw_gid) == -1) {
+ FatalError("Chown Lock");
+ }
+
+ /* Start privileged child */
+ if (priv_init(pw->pw_uid, pw->pw_gid) == -1) {
+ FatalError("priv_init");
+ }
+ } else {
+ /* Normal user */
+ if (priv_init(getuid(), getgid()) == -1) {
+ FatalError("priv_init");
+ }
+ }
+}
+#endif
diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c b/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c
index 65d577eb8..481e1071b 100644
--- a/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c
+++ b/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c
@@ -27,6 +27,8 @@
#include "atKeynames.h"
#include "bsd_kbd.h"
+extern int priv_open_device(char *);
+
extern Bool VTSwitchEnabled;
#ifdef USE_VT_SYSREQ
extern Bool VTSysreqToggle;
@@ -479,7 +481,11 @@ OpenKeyboard(InputInfoPtr pInfo)
pKbd->consType = xf86Info.consType;
}
} else {
+#ifndef X_PRIVSEP
pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+#else
+ pInfo->fd = priv_open_device(s);
+#endif
if (pInfo->fd == -1) {
xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
xfree(s);
@@ -526,12 +532,18 @@ OpenKeyboard(InputInfoPtr pInfo)
break;
#endif
#ifdef WSKBD_TYPE_SUN5
- case WSKBD_TYPE_SUN5:
- xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
- break;
+ case WSKBD_TYPE_SUN5:
+ printWsType("Sun5", pInfo->name);
+ break;
#endif
+ case WSKBD_TYPE_LK201:
+ printWsType("LK-201", pInfo->name);
+ break;
+ case WSKBD_TYPE_LK401:
+ printWsType("LK-401", pInfo->name);
+ break;
default:
- xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"",
+ xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"\n",
pInfo->name, pKbd->wsKbdType);
close(pInfo->fd);
return FALSE;
diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c b/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c
index 21fe1ff18..e1708e62a 100644
--- a/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c
+++ b/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c
@@ -67,6 +67,10 @@
#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i))
#endif /* USBMOUSE_SUPPORT */
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *path);
+#endif
+
#ifdef USBMOUSE_SUPPORT
static void usbSigioReadInput (int fd, void *closure);
#endif
@@ -284,7 +288,11 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
struct stat sb;
for (pdev = mouseDevs; *pdev; pdev++) {
+#ifndef X_PRIVSEP
SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+#else
+ fd = priv_open_device(*pdev);
+#endif
if (fd == -1) {
#ifdef DEBUG
ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
@@ -367,7 +375,11 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
const char **pdev;
for (pdev = mouseDevs; *pdev; pdev++) {
+#ifndef X_PRIVSEP
SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
+#else
+ fd = priv_open_device(*pdev);
+#endif
if (fd != -1) {
/* Set the Device option. */
pInfo->conf_idev->commonOptions =
diff --git a/xserver/hw/xfree86/os-support/bsd/hp300_video.c b/xserver/hw/xfree86/os-support/bsd/hp300_video.c
new file mode 100644
index 000000000..251674bce
--- /dev/null
+++ b/xserver/hw/xfree86/os-support/bsd/hp300_video.c
@@ -0,0 +1,120 @@
+/* $XFree86$ */
+/* $OpenBSD: hp300_video.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * 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 names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT 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: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#include "X.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer hp300MapVidMem(int, unsigned long, unsigned long, int);
+static void hp300UnmapVidMem(int, pointer, unsigned long);
+
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = hp300MapVidMem;
+ pVidMem->unmapMem = hp300UnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+
+volatile unsigned char *ioBase = MAP_FAILED;
+
+static pointer
+hp300MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+
+#ifdef DEBUG
+ ErrorF("mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd);
+#endif
+
+ base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+
+ return base;
+}
+
+
+static void
+hp300UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ return 0;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+ return;
+}
+
+/*
+ * Do all initialisation that need root privileges
+ */
+void
+xf86PrivilegedInit(void)
+{
+ /* pciInit(); */
+ xf86OpenConsole();
+}
diff --git a/xserver/hw/xfree86/os-support/bsd/hppa_video.c b/xserver/hw/xfree86/os-support/bsd/hppa_video.c
new file mode 100644
index 000000000..ce5211e84
--- /dev/null
+++ b/xserver/hw/xfree86/os-support/bsd/hppa_video.c
@@ -0,0 +1,123 @@
+/* $XFree86$ */
+/* $OpenBSD: hppa_video.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * 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 names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT 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: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#include "X.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+/* #include "bus/Pci.h" */
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer hppaMapVidMem(int, unsigned long, unsigned long, int);
+static void hppaUnmapVidMem(int, pointer, unsigned long);
+
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = hppaMapVidMem;
+ pVidMem->unmapMem = hppaUnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+
+volatile unsigned char *ioBase = MAP_FAILED;
+
+static pointer
+hppaMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+
+#ifdef DEBUG
+ ErrorF("mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd);
+#endif
+
+ base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+
+ return base;
+}
+
+
+static void
+hppaUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ return 0;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+ return;
+}
+
+/*
+ * Do all initialisation that need root privileges
+ */
+void
+xf86PrivilegedInit(void)
+{
+ /* pciInit(); */
+ xf86OpenConsole();
+}
diff --git a/xserver/hw/xfree86/os-support/bsd/i386_video.c b/xserver/hw/xfree86/os-support/bsd/i386_video.c
index f4ea3f5c9..f8409be18 100644
--- a/xserver/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xserver/hw/xfree86/os-support/bsd/i386_video.c
@@ -38,7 +38,6 @@
#ifdef HAS_MTRR_SUPPORT
#ifndef __NetBSD__
-#include <sys/types.h>
#include <sys/memrange.h>
#else
#include "memrange.h"
@@ -73,11 +72,11 @@
#ifdef __OpenBSD__
#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
"\tin /etc/sysctl.conf and reboot your machine\n" \
- "\trefer to xf86(4) for details"
+ "\trefer to xf86(4) for details\n"
#define SYSCTL_MSG2 \
"Check that you have set 'machdep.allowaperture=2'\n" \
"\tin /etc/sysctl.conf and reboot your machine\n" \
- "\trefer to xf86(4) for details"
+ "\trefer to xf86(4) for details\n"
#endif
/***************************************************************************/
@@ -126,78 +125,64 @@ checkDevMem(Bool warn)
return;
devMemChecked = TRUE;
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
- {
+#ifdef HAS_APERTURE_DRV
+ /* Try the aperture driver first */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
/* Try to map a page at the VGA address */
base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000);
-
- if (base != MAP_FAILED)
- {
+ MAP_FLAGS, fd, (off_t)0xA0000);
+
+ if (base != MAP_FAILED) {
munmap((caddr_t)base, 4096);
devMemFd = fd;
useDevMem = TRUE;
+ xf86Msg(X_PROBED, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
return;
} else {
- /* This should not happen */
- if (warn)
- {
+ if (warn) {
xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
+ DEV_APERTURE, strerror(errno));
}
- useDevMem = FALSE;
- return;
}
- }
-#ifndef HAS_APERTURE_DRV
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
}
- useDevMem = FALSE;
- return;
-#else
- /* Failed to open /dev/mem, try the aperture driver */
- if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0)
- {
+#endif
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
/* Try to map a page at the VGA address */
base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000);
+ MAP_FLAGS, fd, (off_t)0xA0000);
- if (base != MAP_FAILED)
- {
+ if (base != MAP_FAILED) {
munmap((caddr_t)base, 4096);
devMemFd = fd;
useDevMem = TRUE;
- xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
- DEV_APERTURE);
return;
} else {
-
- if (warn)
- {
+ if (warn) {
xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_APERTURE, strerror(errno));
+ DEV_MEM, strerror(errno));
}
}
- } else {
- if (warn)
- {
+ }
+ if (warn) {
+#ifndef HAS_APERTURE_DRV
+ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
+#else
#ifndef __OpenBSD__
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno));
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
#else /* __OpenBSD__ */
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno),
- SYSCTL_MSG);
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
+ SYSCTL_MSG);
#endif /* __OpenBSD__ */
- }
+
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
}
-
useDevMem = FALSE;
return;
-
#endif
}
@@ -265,8 +250,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
(flags & VIDMEM_READONLY) ?
PROT_READ : (PROT_READ | PROT_WRITE),
MAP_FLAGS, xf86Info.screenFd,
- (unsigned long)Base - 0xA0000
- );
+ (unsigned long)Base - 0xA0000);
if (base == MAP_FAILED)
{
FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
@@ -365,9 +349,12 @@ xf86DisableIO()
if (!ExtendedEnabled)
return;
- i386_iopl(FALSE);
- ExtendedEnabled = FALSE;
-
+ if (i386_iopl(FALSE) == 0) {
+ ExtendedEnabled = FALSE;
+ }
+ /* Otherwise, the X server has revoqued its root uid,
+ and thus cannot give up IO privileges any more */
+
return;
}
@@ -996,3 +983,17 @@ amd64undoWC(int screenNum, pointer list)
}
#endif /* OpenBSD/amd64 */
+#ifdef X_PRIVSEP
+/*
+ * Do all things that need root privileges early
+ * and revoke those privileges
+ */
+_X_EXPORT void
+xf86PrivilegedInit(void)
+{
+ checkDevMem(TRUE);
+ xf86EnableIO();
+ xf86OpenConsole();
+ xf86AgpGARTSupported();
+}
+#endif
diff --git a/xserver/hw/xfree86/os-support/bsd/ppc_video.c b/xserver/hw/xfree86/os-support/bsd/ppc_video.c
index ae65c8f15..04a8dc224 100644
--- a/xserver/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/xserver/hw/xfree86/os-support/bsd/ppc_video.c
@@ -83,7 +83,7 @@ ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
PROT_READ : (PROT_READ | PROT_WRITE),
MAP_SHARED, fd, Base);
if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)",
"xf86MapVidMem", Size, Base, strerror(errno));
return base;
@@ -95,12 +95,18 @@ ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
munmap(Base, Size);
}
+static int kmem = -1;
+
_X_EXPORT int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
int Len)
{
int rv;
- static int kmem = -1;
+
+ if (Base < 0x80000000) {
+ xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base);
+ return 0;
+ }
if (kmem == -1) {
kmem = open(DEV_MEM, 2);
@@ -138,3 +144,21 @@ xf86EnableInterrupts()
return;
}
+
+#ifdef X_PRIVSEP
+/*
+ * Do all initialisation that need root privileges
+ */
+_X_EXPORT void
+xf86PrivilegedInit(void)
+{
+ kmem = open(DEV_MEM, 2);
+ if (kmem == -1) {
+ xf86Msg(X_PROBED,
+ "no aperture driver access: only wsfb driver useable\n");
+ } else {
+ pciInit();
+ }
+ xf86OpenConsole();
+}
+#endif
diff --git a/xserver/hw/xfree86/os-support/bsd/sparc64_video.c b/xserver/hw/xfree86/os-support/bsd/sparc64_video.c
index 0cb9d4d56..d2ba20e35 100644
--- a/xserver/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/xserver/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -110,3 +110,16 @@ xf86EnableInterrupts()
return;
}
+
+#ifdef X_PRIVSEP
+/*
+ * Do all things that need root privileges early
+ * and revoke those privileges
+ */
+_X_EXPORT void
+xf86PrivilegedInit(void)
+{
+ pciInit();
+ xf86OpenConsole();
+}
+#endif
diff --git a/xserver/hw/xfree86/os-support/bus/Pci.h b/xserver/hw/xfree86/os-support/bus/Pci.h
index 7cc882d36..715ae5fda 100644
--- a/xserver/hw/xfree86/os-support/bus/Pci.h
+++ b/xserver/hw/xfree86/os-support/bus/Pci.h
@@ -250,11 +250,20 @@
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
+# if defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
#elif defined(__hppa__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
+# elif defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__ia64__)
# if defined(linux)
@@ -267,7 +276,11 @@
# endif
# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
#elif defined(__i386__) || defined(i386)
-# define ARCH_PCI_INIT ix86PciInit
+# if defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# else
+# define ARCH_PCI_INIT ix86PciInit
+# endif
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# if defined(linux)
@@ -278,6 +291,16 @@
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
+# elif defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__mc68020__)
+# if defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__mips__)
# if defined(linux)
@@ -327,9 +350,21 @@
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
-# if !defined(__FreeBSD__)
+# if !defined(__FreeBSD__) && !defined(__OpenBSD__)
# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
# endif
+#elif defined(__sparc64__)
+# if defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__vax__)
+# if defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
#elif defined(__amd64__) || defined(__amd64)
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# define ARCH_PCI_INIT freebsdPciInit
diff --git a/xserver/hw/xfree86/os-support/bus/freebsdPci.c b/xserver/hw/xfree86/os-support/bus/freebsdPci.c
index 61cb405a8..97782f296 100644
--- a/xserver/hw/xfree86/os-support/bus/freebsdPci.c
+++ b/xserver/hw/xfree86/os-support/bus/freebsdPci.c
@@ -118,7 +118,11 @@ static int pciFd = -1;
void
freebsdPciInit()
{
+#ifndef X_PRIVSEP
pciFd = open("/dev/pci", O_RDWR);
+#else
+ pciFd = priv_open_device("/dev/pci");
+#endif
if (pciFd < 0)
return;
diff --git a/xserver/hw/xfree86/os-support/shared/libc_wrapper.c b/xserver/hw/xfree86/os-support/shared/libc_wrapper.c
index 4c4af4c24..6ebac9e4c 100644
--- a/xserver/hw/xfree86/os-support/shared/libc_wrapper.c
+++ b/xserver/hw/xfree86/os-support/shared/libc_wrapper.c
@@ -1870,7 +1870,7 @@ xf86getpagesize()
if (pagesize == -1)
pagesize = getpagesize();
#endif
-#ifdef PAGE_SIZE
+#if defined(PAGE_SIZE) && !defined(__OpenBSD__) /* XXX */
if (pagesize == -1)
pagesize = PAGE_SIZE;
#endif
diff --git a/xserver/hw/xfree86/os-support/shared/posix_tty.c b/xserver/hw/xfree86/os-support/shared/posix_tty.c
index 6e1b54331..6d9cafe42 100644
--- a/xserver/hw/xfree86/os-support/shared/posix_tty.c
+++ b/xserver/hw/xfree86/os-support/shared/posix_tty.c
@@ -63,6 +63,10 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *);
+#endif
+
static int
GetBaud (int baudrate)
{
@@ -129,8 +133,11 @@ xf86OpenSerial (pointer options)
xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
return (-1);
}
-
+#ifndef X_PRIVSEP
SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
+#else
+ fd = priv_open_device (dev);
+#endif
if (fd == -1)
{
xf86Msg (X_ERROR,
diff --git a/xserver/hw/xfree86/os-support/shared/sigio.c b/xserver/hw/xfree86/os-support/shared/sigio.c
index f6c15c28f..c6fa6c752 100644
--- a/xserver/hw/xfree86/os-support/shared/sigio.c
+++ b/xserver/hw/xfree86/os-support/shared/sigio.c
@@ -101,6 +101,7 @@ xf86SIGIO (int sig)
int i;
fd_set ready;
struct timeval to;
+ int save_errno = errno; /* do not clobber the global errno */
int r;
ready = xf86SigIOMask;
@@ -117,6 +118,8 @@ xf86SIGIO (int sig)
if (r > 0) {
xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
}
+ /* restore global errno */
+ errno = save_errno;
}
static int
diff --git a/xserver/hw/xfree86/os-support/xf86OSmouse.h b/xserver/hw/xfree86/os-support/xf86OSmouse.h
index 600683866..bb42bf907 100644
--- a/xserver/hw/xfree86/os-support/xf86OSmouse.h
+++ b/xserver/hw/xfree86/os-support/xf86OSmouse.h
@@ -70,6 +70,7 @@ typedef enum {
PROT_BM,
PROT_AUTO,
PROT_SYSMOUSE,
+ PROT_SUNMOUSE,
PROT_NUMPROTOS /* This must always be last. */
} MouseProtocolID;
diff --git a/xserver/hw/xfree86/utils/xorgcfg/startx.c b/xserver/hw/xfree86/utils/xorgcfg/startx.c
index 7b730c9aa..983406a6e 100644
--- a/xserver/hw/xfree86/utils/xorgcfg/startx.c
+++ b/xserver/hw/xfree86/utils/xorgcfg/startx.c
@@ -108,8 +108,15 @@ startx(void)
XmuSnprintf(path, sizeof(path), "%s/"__XSERVERNAME__, XFree86_path);
else
XmuSnprintf(path, sizeof(path), "%s/bin/"__XSERVERNAME__, XFree86Dir);
- execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail",
+#ifndef X_PRIVSEP
+ execl(path, "X", ":8", /*"+xinerama",*/ "+accessx",
+ "-allowMouseOpenFail", "-nolisten", "tcp",
"-xf86config", XF86Config_path, (void *)NULL);
+#else
+ execl(path, "X", ":8", /*"+xinerama",*/ "+accessx",
+ "-allowMouseOpenFail", "-keepPriv", "-nolisten", "tcp",
+ "-xf86config", XF86Config_path, (void *)NULL);
+#endif
exit(-127);
} break;
case -1:
diff --git a/xserver/hw/xfree86/utils/xorgcfg/stubs.c b/xserver/hw/xfree86/utils/xorgcfg/stubs.c
index 47b2c2d5a..0250a8cc0 100644
--- a/xserver/hw/xfree86/utils/xorgcfg/stubs.c
+++ b/xserver/hw/xfree86/utils/xorgcfg/stubs.c
@@ -40,7 +40,7 @@
static char dummy;
#endif
-#if !defined(USE_MODULES)
+#if 0
/* these are defined in libdummy.a */
int
ErrorF(const char *fmt, ...)
diff --git a/xserver/hw/xfree86/utils/xorgcfg/text-mode.c b/xserver/hw/xfree86/utils/xorgcfg/text-mode.c
index 10f4b698f..c0de0ff89 100644
--- a/xserver/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/xserver/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -50,12 +50,12 @@
(strcmp((X), "keyboard") == 0))
#ifndef PROJECT_ROOT
-#define PROJECT_ROOT "/usr"
+#define PROJECT_ROOT "/usr/X11R6"
#endif
#ifndef XKB_RULES_DIR
#ifndef __UNIXOS2__
-#define XKB_RULES_DIR PROJECT_ROOT "/share/X11/xkb/rules"
+#define XKB_RULES_DIR PROJECT_ROOT "/lib/X11/xkb/rules"
#else
#define XKB_RULES_DIR XF86CONFIGDIR "/xkb/rules"
#endif
@@ -396,7 +396,7 @@ static char *protocols[] = {
static int
MouseConfig(void)
{
- int i, nlist, def, proto, emul;
+ int i, nlist, def, proto, emul, wheel;
char **list = NULL, *device, *str;
XF86ConfInputPtr *inputs = NULL;
XF86ConfInputPtr input = XF86Config->conf_input_lst;
@@ -544,6 +544,17 @@ MouseConfig(void)
return (i);
emul = !i;
+ ClearScreen();
+ refresh();
+ i = Dialog("Mouse Wheel configuration",
+ "If your mouse has a wheel, you can enable it now.\n"
+ "\n"
+ "Do you want to enable the mouse wheel?",
+ 10, 60, " Yes ", " No ", def);
+ if (i < 0)
+ return (i);
+ wheel = !i;
+
str = NULL;
option = xf86findOption(input->inp_option_lst, "Device");
if (option)
@@ -592,6 +603,15 @@ MouseConfig(void)
input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
XtNewString("Emulate3Buttons"), NULL);
+ if (wheel) {
+ option = xf86findOption(input->inp_option_lst, "ZAxisMapping");
+ if (option) {
+ XtFree((XtPointer)option->opt_val);
+ option->opt_val = XtNewString("4 5");
+ } else
+ input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+ XtNewString("ZAxisMapping"), XtNewString("4 5"));
+ }
option = xf86findOption(input->inp_option_lst, "Device");
if (option) {
XtFree((XtPointer)option->opt_val);
diff --git a/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c b/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c
index f00eea038..5806027ca 100644
--- a/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c
+++ b/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c
@@ -154,7 +154,7 @@ static int getuid() { return 0; }
* may be more irritated than Unix users
*/
#ifndef PROJECTROOT
-#define PROJECTROOT "/usr"
+#define PROJECTROOT "/usr/X11R6"
#endif
#define TREEROOT PROJECTROOT
#define TREEROOTLX TREEROOT "/lib/X11"
@@ -203,11 +203,18 @@ static int getuid() { return 0; }
#endif
#endif
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+/* OpenBSD/macppc now has support for Standard kbd protocol under wscons */
+# ifndef __powerpc__
+# define NEED_WSKBD
+# endif
+#endif
int config_mousetype; /* Mouse. */
int config_emulate3buttons;
int config_chordmiddle;
int config_cleardtrrts;
+int config_wheel;
char *config_pointerdevice;
int config_altmeta; /* Keyboard. */
int config_monitortype; /* Monitor. */
@@ -229,7 +236,7 @@ int config_virtualx24bpp, config_virtualy24bpp;
char *config_ramdac;
char *config_dacspeed;
char *config_clockchip;
-#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+#ifdef NEED_WSKBD
char *config_keyboard_dev = "/dev/wskbd0";
#endif
int config_xkbdisable = 0;
@@ -642,7 +649,7 @@ mouse_configuration(void) {
printf("\n");
- printf("Please answer the following question with either 'y' or 'n'.\n");
+ printf("Please answer the following questions with either 'y' or 'n'.\n");
printf("Do you want to enable Emulate3Buttons? ");
getstring(s);
if (answerisyes(s))
@@ -651,6 +658,14 @@ mouse_configuration(void) {
config_emulate3buttons = 0;
printf("\n");
+ printf("Do you want to configure a mouse wheel? ");
+ getstring(s);
+ if (answerisyes(s))
+ config_wheel = 1;
+ else
+ config_wheel = 0;
+ printf("\n");
+
#if (defined(sun) && (defined(__i386) || defined(__x86)))
/* SPARC & USB mice (VUID or AUTO protocols) default to /dev/mouse,
but PS/2 mice default to /dev/kdmouse */
@@ -709,7 +724,7 @@ static char *xkboptionstext =
"Do you want to select additional XKB options (group switcher,\n"
"group indicator, etc.)? ";
-#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+#ifdef NEED_WSKBD
static char *kbdevtext =
"Please enter the device name for your keyboard or just press enter\n"
"for the default of wskbd0\n\n";
@@ -724,7 +739,7 @@ keyboard_configuration(void)
int number, options[MAX_XKBOPTIONS], num_options;
XkbRF_RulesPtr rules;
-#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+#ifdef NEED_WSKBD
printf(kbdevtext);
getstring(s);
if (strlen(s) != 0) {
@@ -2589,7 +2604,7 @@ write_XF86Config(char *filename)
fprintf(f, "# Option \"LeftAlt\" \"Meta\"\n");
fprintf(f, "# Option \"RightAlt\" \"ModeShift\"\n");
}
-#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+#ifdef NEED_WSKBD
/* wscons keyoards need a protocol line */
fprintf(f, " Option \"Protocol\" \"wskbd\"\n");
fprintf(f, " Option \"Device\" \"%s\"\n", config_keyboard_dev);
@@ -2641,6 +2656,11 @@ write_XF86Config(char *filename)
fprintf(f, " Option \"ClearDTR\"\n");
fprintf(f, " Option \"ClearRTS\"\n\n");
}
+ fprintf(f, "# ZaxisMapping is an option for handling the wheel\n");
+ if (!config_wheel)
+ fprintf(f, "#");
+ fprintf(f, " Option \"ZAxisMapping\" \"4 5\"\n\n");
+
fprintf(f, "EndSection\n\n\n");
/*