summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/bsd
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/os-support/bsd')
-rw-r--r--hw/xfree86/os-support/bsd/bsd_VTsw.c20
-rw-r--r--hw/xfree86/os-support/bsd/bsd_init.c354
-rw-r--r--hw/xfree86/os-support/bsd/bsd_io.c204
-rw-r--r--hw/xfree86/os-support/bsd/bsd_jstk.c53
4 files changed, 307 insertions, 324 deletions
diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c
index 13e78ad34..adb101dc5 100644
--- a/hw/xfree86/os-support/bsd/bsd_VTsw.c
+++ b/hw/xfree86/os-support/bsd/bsd_VTsw.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c,v 3.5 1996/12/23 06:49:35 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c,v 3.6 1998/07/25 16:56:33 dawes Exp $ */
/*
* Derived from VTsw_usl.c which is
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,12 +23,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: bsd_VTsw.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */
+/* $XConsortium: bsd_VTsw.c /main/4 1996/02/21 17:50:57 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
-
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
@@ -42,8 +39,8 @@
* This function is the signal handler for the VT-switching signal. It
* is only referenced inside the OS-support layer.
*/
-void xf86VTRequest(sig)
-int sig;
+void
+xf86VTRequest(int sig)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
@@ -53,7 +50,8 @@ int sig;
return;
}
-Bool xf86VTSwitchPending()
+Bool
+xf86VTSwitchPending()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
@@ -63,7 +61,8 @@ Bool xf86VTSwitchPending()
return FALSE;
}
-Bool xf86VTSwitchAway()
+Bool
+xf86VTSwitchAway()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
@@ -77,7 +76,8 @@ Bool xf86VTSwitchAway()
return FALSE;
}
-Bool xf86VTSwitchTo()
+Bool
+xf86VTSwitchTo()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index 961fd0eac..236b6ffbb 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.8.2.1 1998/02/06 22:36:49 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.19 2002/05/05 18:54:02 herrb Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,24 +23,18 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: bsd_init.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */
+/* $XConsortium: bsd_init.c /main/8 1996/10/23 13:13:05 kaleb $ */
#include "X.h"
-#include "Xmd.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
-#include "xf86Procs.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-extern void xf86VTRequest(
-#if NeedFunctionPrototypes
- int
-#endif
-);
+#include <sys/utsname.h>
+#include <stdlib.h>
static Bool KeepTty = FALSE;
static int devConsoleFd = -1;
@@ -58,12 +52,6 @@ static int initialVT = -1;
#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
-#ifdef CODRV_SUPPORT
-/* Holger Veit's codrv console driver */
-#define CODRV_CONSOLE_DEV "/dev/kbd"
-#define CODRV_CONSOLE_MODE O_RDONLY|O_NDELAY
-#endif
-
#ifdef SYSCONS_SUPPORT
/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
@@ -81,6 +69,11 @@ static int initialVT = -1;
#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+/* NetBSD's new console driver */
+#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
+#endif
+
#define CHECK_DRIVER_MSG \
"Check your kernel's console driver configuration and /dev entries"
@@ -88,15 +81,15 @@ static char *supported_drivers[] = {
#ifdef PCCONS_SUPPORT
"pccons (with X support)",
#endif
-#ifdef CODRV_SUPPORT
- "codrv",
-#endif
#ifdef SYSCONS_SUPPORT
"syscons",
#endif
#ifdef PCVT_SUPPORT
"pcvt",
#endif
+#ifdef WSCONS_SUPPORT
+ "wscons",
+#endif
};
@@ -108,64 +101,43 @@ static char *supported_drivers[] = {
* an X server.
*/
-typedef int (*xf86ConsOpen_t)(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+typedef int (*xf86ConsOpen_t)(void);
#ifdef PCCONS_SUPPORT
-static int xf86OpenPccons(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+static int xf86OpenPccons(void);
#endif /* PCCONS_SUPPORT */
-#ifdef CODRV_SUPPORT
-static int xf86OpenCodrv(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-#endif /* CODRV_SUPPORT */
-
#ifdef SYSCONS_SUPPORT
-static int xf86OpenSyscons(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+static int xf86OpenSyscons(void);
#endif /* SYSCONS_SUPPORT */
#ifdef PCVT_SUPPORT
-static int xf86OpenPcvt(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+static int xf86OpenPcvt(void);
#endif /* PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+static int xf86OpenWScons(void);
+#endif
+
/*
* The sequence of the driver probes is important; start with the
* driver that is best distinguishable, and end with the most generic
* driver. (Otherwise, pcvt would also probe as syscons, and either
- * pcvt or syscons might succesfully probe as pccons. Only codrv is
- * at its own.)
+ * pcvt or syscons might succesfully probe as pccons.)
*/
static xf86ConsOpen_t xf86ConsTab[] = {
#ifdef PCVT_SUPPORT
xf86OpenPcvt,
#endif
-#ifdef CODRV_SUPPORT
- xf86OpenCodrv,
-#endif
#ifdef SYSCONS_SUPPORT
xf86OpenSyscons,
#endif
#ifdef PCCONS_SUPPORT
xf86OpenPccons,
#endif
+#ifdef WSCONS_SUPPORT
+ xf86OpenWScons,
+#endif
(xf86ConsOpen_t)NULL
};
@@ -173,10 +145,9 @@ static xf86ConsOpen_t xf86ConsTab[] = {
void
xf86OpenConsole()
{
- int i, fd;
-#ifdef CODRV_SUPPORT
- int onoff;
-#endif
+ int i, fd = -1;
+ int result;
+ struct utsname uts;
xf86ConsOpen_t *driver;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
vtmode_t vtmode;
@@ -187,10 +158,7 @@ xf86OpenConsole()
/* check if we are run with euid==0 */
if (geteuid() != 0)
{
- FatalError("xf86OpenConsole: Server must be running with root "
- "permissions\n"
- "You should be using Xwrapper to start the server or xdm.\n"
- "We strongly advise against making the server SUID root!\n");
+ FatalError("xf86OpenConsole: Server must be suid root\n");
}
if (!KeepTty)
@@ -211,7 +179,7 @@ xf86OpenConsole()
/* detect which driver we are running on */
for (driver = xf86ConsTab; *driver; driver++)
{
- if((fd = (*driver)()) >= 0)
+ if ((fd = (*driver)()) >= 0)
break;
}
@@ -231,28 +199,14 @@ xf86OpenConsole()
"%s: No console driver found\n\tSupported drivers: %s\n\t%s\n",
"xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
}
+#if 0 /* stdin is already closed in OsInit() */
fclose(stdin);
+#endif
xf86Info.consoleFd = fd;
xf86Info.screenFd = fd;
- xf86Config(FALSE); /* Read XF86Config */
-
switch (xf86Info.consType)
{
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- onoff = X_MODE_ON;
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff) < 0)
- {
- FatalError("%s: CONSOLE_X_MODE ON failed (%s)\n%s\n",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- if (xf86Info.consType == CODRV01X)
- ioctl(xf86Info.consoleFd, VGATAKECTRL, 0);
- break;
-#endif
#ifdef PCCONS_SUPPORT
case PCCONS:
if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
@@ -267,13 +221,24 @@ xf86OpenConsole()
*/
if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
{
- ErrorF("Warning: couldn't open /dev/console (%s)\n",
- strerror(errno));
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
}
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
+ uname (&uts);
+ if (strcmp(uts.sysname, "FreeBSD") == 0) {
+ i = atof(uts.release) * 100;
+ if (i >= 310) goto acquire_vt;
+ }
+ /* otherwise fall through */
case PCVT:
/*
* First activate the #1 VT. This is a hack to allow a server
@@ -284,21 +249,27 @@ xf86OpenConsole()
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_ACTIVATE failed\n");
}
sleep(1);
}
-
+
+acquire_vt:
/*
* now get the VT
*/
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
+ if (result != 0)
{
- ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
signal(SIGUSR1, xf86VTRequest);
@@ -311,17 +282,25 @@ xf86OpenConsole()
{
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
}
+#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
{
FatalError("xf86OpenConsole: KDENABIO failed (%s)\n",
strerror(errno));
}
+#endif
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
}
break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ fprintf(stderr, "xf86OpenConsole\n");
+ /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */
+ break;
+#endif
}
}
else
@@ -332,7 +311,7 @@ xf86OpenConsole()
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
}
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
@@ -363,10 +342,7 @@ xf86OpenPccons()
CHECK_DRIVER_MSG);
}
xf86Info.consType = PCCONS;
- if (xf86Verbose)
- {
- ErrorF("Using pccons driver with X support\n");
- }
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
}
return fd;
}
@@ -383,6 +359,7 @@ xf86OpenSyscons()
char vtname[12];
struct stat status;
long syscons_version;
+ MessageType from;
/* Check for syscons */
if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
@@ -397,6 +374,7 @@ xf86OpenSyscons()
}
xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
#ifdef VT_GETACTIVE
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
@@ -430,6 +408,7 @@ xf86OpenSyscons()
/*
* All VTs are in use. If initialVT was found, use it.
* Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
*/
if (initialVT != -1)
{
@@ -458,6 +437,7 @@ xf86OpenSyscons()
"or the use of the vtxx server option");
}
}
+ from = X_PROBED;
}
close(fd);
@@ -476,20 +456,17 @@ xf86OpenSyscons()
FatalError("xf86OpenSyscons: VT_GETMODE failed\n");
}
xf86Info.consType = SYSCONS;
- if (xf86Verbose)
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100)
{
- ErrorF("Using syscons driver with X support");
- if (syscons_version >= 0x100)
- {
- ErrorF(" (version %d.%d)\n", syscons_version >> 8,
+ xf86ErrorF(" (version %d.%d)\n", syscons_version >> 8,
syscons_version & 0xFF);
- }
- else
- {
- ErrorF(" (version 0.x)\n");
- }
- ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
}
+ else
+ {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
}
else
{
@@ -504,78 +481,6 @@ xf86OpenSyscons()
#endif /* SYSCONS_SUPPORT */
-#ifdef CODRV_SUPPORT
-
-static int
-xf86OpenCodrv()
-{
- int fd = -1, onoff = X_MODE_OFF;
- struct oldconsinfo ci;
-
- if ((fd = open(CODRV_CONSOLE_DEV, CODRV_CONSOLE_MODE, 0)) >= 0)
- {
- if (ioctl(fd, CONSOLE_X_MODE, &onoff) < 0)
- {
- FatalError("%s: CONSOLE_X_MODE on %s failed (%s)\n%s\n%s\n",
- "xf86OpenCodrv",
- CODRV_CONSOLE_DEV, strerror(errno),
- "Was expecting codrv driver",
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = CODRV011;
- }
- else
- {
- if (errno == EBUSY)
- {
- FatalError("xf86OpenCodrv: %s is already in use (codrv)\n",
- CODRV_CONSOLE_DEV);
- }
- }
- else
- {
- fd = -1;
- }
-
- if(fd >= 0)
- {
- /*
- * analyse whether this kernel has sufficient capabilities for
- * this xserver, if not don't proceed: it won't work. Also
- * find out which codrv version.
- */
-#define NECESSARY (CONS_HASKBD|CONS_HASKEYNUM|CONS_HASPX386)
- if ((ioctl(fd, OLDCONSGINFO, &ci) < 0 ||
- (ci.info1 & NECESSARY) != NECESSARY))
- {
- FatalError("xf86OpenCodrv: %s\n%s\n%s\n",
- "This Xserver has detected the codrv driver, but your",
- "kernel doesn't appear to have the required facilities",
- CHECK_DRIVER_MSG);
- }
- /* Check for codrv 0.1.2 or later */
- if (ci.info1 & CONS_CODRV2)
- {
- xf86Info.consType = CODRV01X;
- if (xf86Verbose)
- {
- ErrorF("Using codrv 0.1.2 (or later)\n");
- }
- }
- else
- {
- if (xf86Verbose)
- {
- ErrorF("Using codrv 0.1.1\n");
- }
- }
-#undef NECESSARY
- }
-
- return fd;
-}
-#endif /* CODRV_SUPPORT */
-
#ifdef PCVT_SUPPORT
static int
@@ -584,11 +489,25 @@ xf86OpenPcvt()
/* This looks much like syscons, since pcvt is API compatible */
int fd = -1;
vtmode_t vtmode;
- char vtname[12];
+ char vtname[12], *vtprefix;
struct stat status;
struct pcvtid pcvt_version;
- if ((fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0)) >= 0)
+#ifndef __OpenBSD__
+ vtprefix = "/dev/ttyv";
+#else
+ vtprefix = "/dev/ttyC";
+#endif
+
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
+ if (fd < 0)
+ {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
+ }
+#endif
+ if (fd >= 0)
{
if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
{
@@ -618,6 +537,7 @@ xf86OpenPcvt()
/*
* All VTs are in use. If initialVT was found, use it.
* Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
*/
if (initialVT != -1)
{
@@ -639,11 +559,7 @@ xf86OpenPcvt()
}
close(fd);
-#ifndef __OpenBSD__
- sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
-#else
- sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
-#endif
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
{
FatalError("xf86OpenPcvt: Cannot open %s (%s)\n",
@@ -654,11 +570,15 @@ xf86OpenPcvt()
FatalError("xf86OpenPcvt: VT_GETMODE failed\n");
}
xf86Info.consType = PCVT;
- if (xf86Verbose)
- {
- ErrorF("Using pcvt driver (version %d.%d)\n",
- pcvt_version.rmajor, pcvt_version.rminor);
- }
+#ifdef WSCONS_SUPPORT
+ xf86Msg(X_PROBED,
+ "Using wscons driver in pcvt compatibility mode "
+ "(version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#else
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
}
else
{
@@ -672,30 +592,49 @@ xf86OpenPcvt()
#endif /* PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+
+static int
+xf86OpenWScons()
+{
+ int fd = -1;
+ int mode = WSDISPLAYIO_MODE_MAPPED;
+ int i;
+ char ttyname[16];
+
+ /* XXX Is this ok? */
+ for (i = 0; i < 8; i++) {
+#if defined(__NetBSD__)
+ sprintf(ttyname, "/dev/ttyE%d", i);
+#elif defined(__OpenBSD__)
+ sprintf(ttyname, "/dev/ttyC%d", i);
+#endif
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
+ }
+ if (fd != -1) {
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s\n",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
+ }
+ return fd;
+}
+
+#endif /* WSCONS_SUPPORT */
void
xf86CloseConsole()
{
-#if defined(CODRV_SUPPORT)
- int onoff;
-#endif
#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
struct vt_mode VT;
#endif
switch (xf86Info.consType)
{
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- onoff = X_MODE_OFF;
- if (xf86Info.consType == CODRV01X)
- {
- ioctl (xf86Info.consoleFd, VGAGIVECTRL, 0);
- }
- ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff);
- break;
-#endif /* CODRV_SUPPORT */
#ifdef PCCONS_SUPPORT
case PCCONS:
ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
@@ -710,15 +649,25 @@ xf86CloseConsole()
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
}
+#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
{
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)\n",
strerror(errno));
}
+#endif
if (initialVT != -1)
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+ ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
+#endif
}
if (xf86Info.screenFd != xf86Info.consoleFd)
@@ -738,10 +687,7 @@ xf86CloseConsole()
}
int
-xf86ProcessArgument (argc, argv, i)
-int argc;
-char *argv[];
-int i;
+xf86ProcessArgument(int argc, char *argv[], int i)
{
/*
* Keep server from detaching from controlling tty. This is useful
diff --git a/hw/xfree86/os-support/bsd/bsd_io.c b/hw/xfree86/os-support/bsd/bsd_io.c
index 6741ba978..0f40ba707 100644
--- a/hw/xfree86/os-support/bsd/bsd_io.c
+++ b/hw/xfree86/os-support/bsd/bsd_io.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.12 1996/12/23 06:49:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.23 2002/10/21 20:38:04 herrb Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -23,29 +23,30 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: bsd_io.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */
+/* $XConsortium: bsd_io.c /main/11 1996/10/19 18:06:07 kaleb $ */
#define NEED_EVENTS
#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-void xf86SoundKbdBell(loudness, pitch, duration)
-int loudness;
-int pitch;
-int duration;
+#ifdef WSCONS_SUPPORT
+#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd)
+#endif
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
{
+#ifdef WSCONS_SUPPORT
+ struct wskbd_bell_data wsb;
+#endif
+
if (loudness && pitch)
{
-#ifdef CODRV_SUPPORT
- struct kbd_sound s;
-#endif
#ifdef PCCONS_SUPPORT
int data[2];
#endif
@@ -59,14 +60,6 @@ int duration;
ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
break;
#endif
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- s.pitch = pitch;
- s.duration = (duration * loudness) / 50;
- ioctl(xf86Info.consoleFd, KBDSETBELL, &s);
- break;
-#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
@@ -75,34 +68,43 @@ int duration;
(((unsigned long)duration*loudness/50)<<16));
break;
#endif
+#if defined (WSCONS_SUPPORT)
+ case WSCONS:
+ wsb.which = WSKBD_BELL_DOALL;
+ wsb.pitch = pitch;
+ wsb.period = duration;
+ wsb.volume = loudness;
+ ioctl(KBD_FD(xf86Info), WSKBDIO_COMPLEXBELL,
+ &wsb);
+ break;
+#endif
}
}
}
-void xf86SetKbdLeds(leds)
-int leds;
+void
+xf86SetKbdLeds(int leds)
{
switch (xf86Info.consType) {
case PCCONS:
break;
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
- ioctl(xf86Info.consoleFd, KBDSLEDS, &leds);
- break;
-#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSETLED, leds);
break;
#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(KBD_FD(xf86Info), WSKBDIO_SETLEDS, &leds);
+ break;
+#endif
}
}
-int xf86GetKbdLeds()
+int
+xf86GetKbdLeds()
{
int leds = 0;
@@ -110,40 +112,28 @@ int xf86GetKbdLeds()
case PCCONS:
break;
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- ioctl(xf86Info.consoleFd, KBDGLEDS, &leds);
- leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
- break;
-#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDGETLED, &leds);
break;
#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(KBD_FD(xf86Info), WSKBDIO_GETLEDS, &leds);
+ break;
+#endif
}
return(leds);
}
-#if NeedFunctionPrototypes
-void xf86SetKbdRepeat(char rad)
-#else
-void xf86SetKbdRepeat(rad)
-char rad;
-#endif
+void
+xf86SetKbdRepeat(char rad)
{
switch (xf86Info.consType) {
case PCCONS:
break;
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- ioctl(xf86Info.consoleFd, KBDSTPMAT, &rad);
- break;
-#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
@@ -153,15 +143,15 @@ char rad;
}
}
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
static struct termio kbdtty;
+#endif
-void xf86KbdInit()
+void
+xf86KbdInit()
{
switch (xf86Info.consType) {
- case CODRV011:
- case CODRV01X:
- break;
#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case PCCONS:
case SYSCONS:
@@ -169,18 +159,27 @@ void xf86KbdInit()
tcgetattr(xf86Info.consoleFd, &kbdtty);
break;
#endif
+#if defined WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd != -1)
+ xf86FlushInput(xf86Info.kbdFd);
+ else
+ tcgetattr(xf86Info.consoleFd, &kbdtty);
+ break;
+#endif
}
}
-int xf86KbdOn()
+int
+xf86KbdOn()
{
struct termios nTty;
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
- switch (xf86Info.consType) {
- case CODRV011:
- case CODRV01X:
- break;
+ switch (xf86Info.consType) {
#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
case SYSCONS:
@@ -202,17 +201,44 @@ int xf86KbdOn()
#endif
break;
#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd == -1) {
+ nTty = kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ option = WSKBD_RAW;
+ if (ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE,
+ &option) == -1)
+ FatalError("can't switch keyboard to raw mode. "
+ "Enable support for it in the kernel\n"
+ "or use for example:\n\n"
+ "Option \"Protocol\" \"wskbd\"\n"
+ "Option \"Device\" \"/dev/wskbd0\"\n"
+ "\nin your XF86Config(5) file\n");
+ } else {
+ return xf86Info.kbdFd;
+ }
+#endif
}
return(xf86Info.consoleFd);
}
-int xf86KbdOff()
+int
+xf86KbdOff()
{
- switch (xf86Info.consType) {
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
- case CODRV011:
- case CODRV01X:
- break;
+ switch (xf86Info.consType) {
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
@@ -225,33 +251,39 @@ int xf86KbdOff()
tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
break;
#endif
- }
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd != -1) {
+ return xf86Info.kbdFd;
+ } else {
+ option = WSKBD_TRANSLATED;
+ ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+ }
+ break;
+#endif
+ }
return(xf86Info.consoleFd);
}
-void xf86MouseInit(mouse)
-MouseDevPtr mouse;
+#ifdef WSCONS_SUPPORT
+
+#define NUMEVENTS 64
+
+void
+xf86WSKbdEvents(void)
{
+ static struct wscons_event events[NUMEVENTS];
+ int n, i;
+
+ n = read(xf86Info.kbdFd, events, sizeof events);
+ if (n <= 0)
return;
+ n /= sizeof(struct wscons_event);
+ for (i = 0; i < n; i++)
+ xf86PostWSKbdEvent(&events[i]);
}
-int xf86MouseOn(mouse)
-MouseDevPtr mouse;
-{
- if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0)
- {
- if (xf86AllowMouseOpenFail) {
- ErrorF("Cannot open mouse (%s) - Continuing...\n",
- strerror(errno));
- return(-2);
- }
- FatalError("Cannot open mouse (%s)\n", strerror(errno));
- }
+#endif /* WSCONS_SUPPORT */
- xf86SetupMouse(mouse);
- /* Flush any pending input */
- tcflush(mouse->mseFd, TCIFLUSH);
-
- return(mouse->mseFd);
-}
diff --git a/hw/xfree86/os-support/bsd/bsd_jstk.c b/hw/xfree86/os-support/bsd/bsd_jstk.c
index ab4a31420..7f24124dc 100644
--- a/hw/xfree86/os-support/bsd/bsd_jstk.c
+++ b/hw/xfree86/os-support/bsd/bsd_jstk.c
@@ -23,18 +23,22 @@
/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c,v 3.2 1996/01/12 14:34:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c,v 3.8 2002/08/06 13:20:47 herrb Exp $ */
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
+#include <errno.h>
#include <machine/joystick.h>
#include <fcntl.h>
-#define JS_RETURN sizeof(struct joystick)
+#ifdef XFree86LOADER
+#include "misc.h"
+#include "xf86_libc.h"
+#endif
+#include "xf86.h"
-extern int errno;
-extern int xf86Verbose;
+#define JS_RETURN sizeof(struct joystick)
/***********************************************************************
*
@@ -57,16 +61,16 @@ xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY)
ErrorF("xf86JoystickOn: %s\n", name);
#endif
- if ((status = open(name, O_RDWR | O_NDELAY)) < 0)
+ if ((status = open(name, O_RDWR | O_NDELAY, 0)) < 0)
{
- ErrorF("xf86JoystickOn: Cannot open joystick '%s' (%s)\n", name,
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86JoystickOn: Cannot open joystick '%s' (%s)\n",
+ name, strerror(errno));
return -1;
}
if (*timeout <= 0) {
/* Use the current setting */
- ioctl(status, JOY_GETTIMEOUT, &timeinmicros);
+ ioctl(status, JOY_GETTIMEOUT, (char *)&timeinmicros);
*timeout = timeinmicros / 1000;
if (*timeout == 0)
*timeout = 1;
@@ -78,8 +82,8 @@ xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY)
changed = 1;
}
- if (changed && xf86Verbose)
- ErrorF("(--) Joystick: timeout value = %d\n", *timeout);
+ if (changed)
+ xf86Msg(X_PROBED, "Joystick: timeout value = %d\n", *timeout);
timeinmicros = *timeout * 1000;
@@ -87,15 +91,11 @@ xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY)
read(status, &js, JS_RETURN);
if (*centerX < 0) {
*centerX = js.x;
- if (xf86Verbose) {
- ErrorF("(--) Joystick: CenterX set to %d\n", *centerX);
- }
+ xf86Msg(X_PROBED, "Joystick: CenterX set to %d\n", *centerX);
}
if (*centerY < 0) {
*centerY = js.y;
- if (xf86Verbose) {
- ErrorF("(--) Joystick: CenterY set to %d\n", *centerY);
- }
+ xf86Msg(X_PROBED, "Joystick: CenterY set to %d\n", *centerY);
}
return status;
@@ -126,9 +126,7 @@ xf86JoystickInit()
*/
int
-xf86JoystickOff(fd, doclose)
-int *fd;
-int doclose;
+xf86JoystickOff(int *fd, int doclose)
{
int oldfd;
@@ -149,11 +147,7 @@ int doclose;
*/
int
-xf86JoystickGetState(fd, x, y, buttons)
-int fd;
-int *x;
-int *y;
-int *buttons;
+xf86JoystickGetState(int fd, int *x, int *y, int *buttons)
{
struct joystick js;
int status;
@@ -177,4 +171,15 @@ int *buttons;
return 1;
}
+#ifdef XFree86LOADER
+/*
+ * Entry point for XFree86 Loader
+ */
+void
+bsd_jstkModuleInit(pointer *data, INT32 *magic)
+{
+ *magic = MAGIC_DONE;
+ *data = NULL;
+}
+#endif
/* end of bsd_jstk.c */