summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/os-support')
-rw-r--r--hw/xfree86/os-support/README.OS-lib157
-rw-r--r--hw/xfree86/os-support/assyntax.h6
-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
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c119
-rw-r--r--hw/xfree86/os-support/linux/lnx_io.c225
-rw-r--r--hw/xfree86/os-support/linux/lnx_jstk.c77
-rw-r--r--hw/xfree86/os-support/linux/lnx_video.c1370
-rw-r--r--hw/xfree86/os-support/lynxos/lynx_init.c45
-rw-r--r--hw/xfree86/os-support/lynxos/lynx_io.c78
-rw-r--r--hw/xfree86/os-support/lynxos/lynx_mmap.c25
-rw-r--r--hw/xfree86/os-support/lynxos/lynx_video.c597
-rw-r--r--hw/xfree86/os-support/misc/xf86_IlHack.c5
-rw-r--r--hw/xfree86/os-support/misc/xf86_Util.c64
-rw-r--r--hw/xfree86/os-support/sco/VTsw_sco.c110
-rw-r--r--hw/xfree86/os-support/sco/sco_init.c503
-rw-r--r--hw/xfree86/os-support/sco/sco_io.c328
-rw-r--r--hw/xfree86/os-support/sco/sco_mouse.c384
-rw-r--r--hw/xfree86/os-support/sco/sco_video.c457
-rw-r--r--hw/xfree86/os-support/shared/VTsw_noop.c15
-rw-r--r--hw/xfree86/os-support/shared/VTsw_usl.c23
-rw-r--r--hw/xfree86/os-support/shared/bios_devmem.c96
-rw-r--r--hw/xfree86/os-support/shared/ioperm_noop.c35
-rw-r--r--hw/xfree86/os-support/shared/posix_tty.c820
-rw-r--r--hw/xfree86/os-support/shared/std_kbdEv.c17
-rw-r--r--hw/xfree86/os-support/shared/sysv_kbd.c33
-rw-r--r--hw/xfree86/os-support/sysv/sysv_init.c59
-rw-r--r--hw/xfree86/os-support/sysv/sysv_io.c50
-rw-r--r--hw/xfree86/os-support/sysv/sysv_video.c574
-rw-r--r--hw/xfree86/os-support/sysv/xqueue.c606
-rw-r--r--hw/xfree86/os-support/xf86_OSlib.h526
-rw-r--r--hw/xfree86/os-support/xf86_OSproc.h522
34 files changed, 5225 insertions, 3332 deletions
diff --git a/hw/xfree86/os-support/README.OS-lib b/hw/xfree86/os-support/README.OS-lib
index cf3a0cc7e..27af6b3f2 100644
--- a/hw/xfree86/os-support/README.OS-lib
+++ b/hw/xfree86/os-support/README.OS-lib
@@ -34,13 +34,10 @@ have been made in implementation.
at build time via Imakefile rules. This is alway
preferable to reproducing functions in more than one
OS library.
- amoeba/ OS support for the Amoeba operating system.
bsd/ OS support for the 386BSD/NetBSD/FreeBSD operating
systems.
bsdi/ OS support for the BSD/386 operating system.
linux/ OS support for the Linux operating system.
- mach/ OS support for the Mach and OSF/1 operating systems.
- minix/ OS support for the Minix operating system.
os2/ OS support for OS/2 2.11 and OS/2 Warp
sco/ OS support for the SCO SVR3.x operating system.
solx86/ OS support for the Solaris x86 operating system.
@@ -75,7 +72,7 @@ void xf86OpenConsole(void)
{
/*
* Open console device, activate VTs, etc, etc. Fill in requisite
- * pieces of x386Info. Most of this code comes from x386Init.c
+ * pieces of xf86Info. Most of this code comes from xf86Init.c
*/
}
@@ -124,8 +121,7 @@ Bool xf86LinearVidMem(void)
*/
}
-pointer xf86MapVidMem(int ScreenNum, int Region, pointer Base,
- unsigned long Size)
+pointer xf86MapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
/*
* Handle mapping the video memory. Returns (pointer *)0 for
@@ -134,8 +130,7 @@ pointer xf86MapVidMem(int ScreenNum, int Region, pointer Base,
*/
}
-void xf86UnMapVidMem(int ScreenNum, int Region, pointer Base,
- unsigned long Size)
+void xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
/*
* Handle unmapping the video memory. This should undo what
@@ -173,31 +168,11 @@ int xf86ReadBIOS(unsigned long Base, unsigned long Offset,
*/
}
-void xf86ClearIOPortList(int ScreenNum)
-{
- /*
- * Clears any list of I/O ports that the OS-layer may be maintaining.
- * Note: the value used for ScreenNum must be the scrnIndex field
- * of the screenInfoRec, because this is the only index that is
- * guaranteed to be valid and never change during the life of the
- * server. It is not the same as the index of pScreen in ScreenInfo.
- */
-}
-
-void xf86AddIOPorts(int ScreenNum, int NumPorts, unsigned *Ports)
-{
- /*
- * Adds NumPorts I/O ports listed in array Ports to a list that
- * the OS-layer may be maintaining. Successive calls to this
- * function are cumulative.
- */
-}
void xf86EnableIOPorts(int ScreenNum)
{
/*
- * Enables I/O permissions. The OS layer can either use a
- * previously created list of I/O ports to be used, or can
+ * Enables I/O permissions. The OS layer should
* enable all I/O port access.
*/
}
@@ -205,16 +180,7 @@ void xf86EnableIOPorts(int ScreenNum)
void xf86DisableIOPorts(int ScreenNum)
{
/*
- * Disables I/O permissions. Does not clear the list of I/O
- * ports, if any exists.
- */
-}
-
-void xf86DisableIOPrivs(void)
-{
- /*
- * Do whatever is necessary to disable I/O permissions after forking
- * a child process.
+ * Disables I/O permissions.
*/
}
@@ -323,7 +289,7 @@ void xf86KbdEvents(void)
{
/*
* Read characters from the keyboard device, and post the events
- * by calling x386PostKbdEvent(). Read as much as is available
+ * by calling xf86PostKbdEvent(). Read as much as is available
* without waiting.
*/
}
@@ -380,7 +346,7 @@ void xf86MouseEvents(void)
{
/*
* Read characters from the mouse device, and post the events
- * by calling x386PostMseEvent(). Read as much as is available
+ * by calling xf86PostMseEvent(). Read as much as is available
* without waiting. If the OS doesn't handle the mouse protocol
* translation, xf86MouseProtocol() may be called to do the
* translation and event posting. If the OS does handle the protocol
@@ -407,7 +373,7 @@ int xf86OsMouseEvents(void)
/*
* When supporting an OS-based mouse driver (as opposed to the
* server's internal mouse driver), read some events from the device
- * and post them to the DIX layer through x386PostMseEvent().
+ * and post them to the DIX layer through xf86PostMseEvent().
*
* This function only needs to be implemented if USE_OSMOUSE is
* defined for the OS.
@@ -427,11 +393,114 @@ void xf86OsMouseOption(int token, pointer lex_ptr)
*/
}
+/*
+ * The following functions are simply wrappers around the OS specific
+ * libc functions
+ */
+
+void *
+xf86memmove(void * dest, const void * src, INT32 n)
+{
+ return(memmove(dest,src,n));
+}
+
+void *
+xf86memset(void * s, int c, INT32 n)
+{
+ return(memset(s,c,n));
+}
+
+void *
+xf86memcpy(void * dest, const void * src, INT32 n)
+{
+ return(memcpy(dest,src,n));
+}
+
+int
+xf86memcmp(const void * s1, const void * s2, INT32 n)
+{
+ return(memcmp(s1,s2,n));
+}
+
+char *
+xf86strcat(char * dest, const char * src)
+{
+ return(strcat(dest,src));
+}
+
+char *
+xf86strcpy(char * dest, const char * src)
+{
+ return(strcpy(dest,src));
+}
+
+int
+xf86strcmp(const char * s1, const char * s2)
+{
+ return(strcmp(s1,s2));
+}
+
+int
+xf86strncmp(const char * s1, const char * s2, INT32 n)
+{
+ return(strncmp(s1,s2,n));
+}
+
+size_t
+xf86strlen(const char * s)
+{
+ return(strlen(s));
+}
+
+void
+xf86getsecs(INT32 * secs, INT32 * usecs)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ *secs = tv.tv_sec;
+ *usecs= tv.tv_usec;
+
+ return;
+}
+
+double
+xf86exp(double x)
+{
+ return(exp(x));
+}
+
+double
+xf86log(double x)
+{
+ return(log(x));
+}
+
+double
+xf86pow(double x, double y)
+{
+ return(pow(x,y));
+}
+
+double
+xf86sqrt(double x)
+{
+ return(sqrt(x));
+}
+
+double
+xf86cos(double x)
+{
+ return(cos(x));
+}
+
+
+
-$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.2 1996/12/23 06:48:59 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.10 2001/12/17 20:00:45 dawes Exp $
-$Xorg: README.OS-lib,v 1.3 2000/08/17 19:51:19 cpqbld Exp $
+$XConsortium: README.OS-lib /main/5 1996/02/21 17:50:28 kaleb $
diff --git a/hw/xfree86/os-support/assyntax.h b/hw/xfree86/os-support/assyntax.h
index ee2c23fa4..3ae8a7940 100644
--- a/hw/xfree86/os-support/assyntax.h
+++ b/hw/xfree86/os-support/assyntax.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.7.2.2 1997/05/11 02:56:22 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.12 1999/12/27 00:39:46 robin Exp $ */
#ifndef __ASSYNTAX_H__
#define __ASSYNTAX_H__
@@ -23,7 +23,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Xorg: assyntax.h,v 1.3 2000/08/17 19:51:19 cpqbld Exp $ */
+/* $XConsortium: assyntax.h /main/5 1996/02/21 17:50:49 kaleb $ */
/*
* assyntax.h
@@ -212,7 +212,7 @@
#endif /* ACK_ASSEMBLER */
-#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__)
+#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__)
#define GLNAME(a) a
#else
#define GLNAME(a) CONCAT(_,a)
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 */
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 1c0791abb..0ac8c6a8b 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.7.2.3 1998/02/06 22:36:51 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.14 2001/10/31 22:50:30 tsi Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,18 +23,17 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: lnx_init.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
+/* $XConsortium: lnx_init.c /main/7 1996/10/23 18:46:30 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"
+#include "lnx.h"
#ifdef USE_DEV_FB
extern char *getenv(const char *);
@@ -46,52 +45,50 @@ static Bool KeepTty = FALSE;
static int VTnum = -1;
static int activeVT = -1;
-extern void xf86VTRequest(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-
-void xf86OpenConsole()
+void
+xf86OpenConsole(void)
{
- int i, fd;
+ int i, fd = -1;
+ int result;
struct vt_mode VT;
char vtname[11];
struct vt_stat vts;
+ MessageType from = X_PROBED;
#ifdef USE_DEV_FB
struct fb_var_screeninfo var;
int fbfd;
#endif
+ char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+ char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
if (serverGeneration == 1)
{
/* check if we're run with euid==0 */
if (geteuid() != 0)
{
- FatalError("xf86OpenConsole: Server must be 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");
}
/*
* setup the virtual terminal manager
*/
- if (VTnum != -1)
- {
+ if (VTnum != -1) {
xf86Info.vtno = VTnum;
- }
- else
- {
- if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0)
+ from = X_CMDLINE;
+ } else {
+ i=0;
+ while (tty0[i] != NULL)
{
+ if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
+ break;
+ i++;
+ }
+ if (fd < 0)
FatalError(
"xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
strerror(errno));
- }
if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
- (xf86Info.vtno == -1))
- {
+ (xf86Info.vtno == -1)) {
FatalError("xf86OpenConsole: Cannot find a free VT\n");
}
close(fd);
@@ -107,21 +104,24 @@ void xf86OpenConsole()
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
FatalError("xf86OpenConsole: Unable to get screen info\n");
#endif
- ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- sprintf(vtname,"/dev/tty%d",xf86Info.vtno); /* /dev/tty1-64 */
-
- xf86Config(FALSE); /* Read XF86Config */
-
- if (!KeepTty)
- {
+ if (!KeepTty) {
setpgrp();
}
- if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
- {
- FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
- vtname, strerror(errno));
+ i=0;
+ while (vcs[i] != NULL)
+ {
+ sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (xf86Info.consoleFd < 0) {
+ FatalError("xf86OpenConsole: Cannot open virtual console %d (%s)\n",
+ xf86Info.vtno, strerror(errno));
}
/* change ownership of the vt */
@@ -131,7 +131,7 @@ void xf86OpenConsole()
* the current VT device we're running on is not "console", we want
* to grab all consoles too
*
- * Why is this needed?
+ * Why is this needed??
*/
chown("/dev/tty0", getuid(), getgid());
@@ -159,17 +159,21 @@ void xf86OpenConsole()
/*
* 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");
}
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
+ if (result < 0)
{
- FatalError ("xf86OpenConsole: VT_GETMODE failed\n");
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
}
signal(SIGUSR1, xf86VTRequest);
@@ -185,6 +189,10 @@ void xf86OpenConsole()
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
}
+
+ /* we really should have a InitOSInputDevices() function instead
+ * of Init?$#*&Device(). So I just place it here */
+
#ifdef USE_DEV_FB
/* copy info to new console */
var.yoffset=0;
@@ -200,19 +208,23 @@ void xf86OpenConsole()
/*
* 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");
}
}
return;
}
-void xf86CloseConsole()
+void
+xf86CloseConsole()
{
struct vt_mode VT;
@@ -238,10 +250,8 @@ void xf86CloseConsole()
return;
}
-int xf86ProcessArgument (argc, argv, i)
-int argc;
-char *argv[];
-int i;
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
{
/*
* Keep server from detaching from controlling tty. This is useful
@@ -265,7 +275,8 @@ int i;
return(0);
}
-void xf86UseMsg()
+void
+xf86UseMsg()
{
ErrorF("vtXX use the specified VT number\n");
ErrorF("-keeptty ");
diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c
index 57a2979c5..741b9a279 100644
--- a/hw/xfree86/os-support/linux/lnx_io.c
+++ b/hw/xfree86/os-support/linux/lnx_io.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.3 1996/12/23 06:50:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.24 2002/10/20 21:45:27 tsi Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
- * 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,23 +23,21 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: lnx_io.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
+/* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 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;
+#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
{
if (loudness && pitch)
{
@@ -50,20 +48,100 @@ int duration;
}
}
-void xf86SetKbdLeds(leds)
-int leds;
+void
+xf86SetKbdLeds(int leds)
{
- ioctl(xf86Info.consoleFd, KDSETLED, leds);
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
}
-int xf86GetKbdLeds()
+int
+xf86GetKbdLeds()
{
- int leds;
+ int leds = 0;
- ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+ ioctl(xf86Info.consoleFd, KDGETLED, &leds);
return(leds);
}
+/* kbd rate stuff based on kbdrate.c from Rik Faith <faith@cs.unc.edu> et.al.
+ * from util-linux-2.9t package */
+
+#include <linux/kd.h>
+#ifdef __sparc__
+#include <asm/param.h>
+#include <asm/kbio.h>
+#endif
+
+/* Deal with spurious kernel header change */
+#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42)
+# define rate period
+# endif
+#endif
+
+static int
+KDKBDREP_ioctl_ok(int rate, int delay) {
+#if defined(KDKBDREP) && !defined(__sparc__)
+ /* This ioctl is defined in <linux/kd.h> but is not
+ implemented anywhere - must be in some m68k patches. */
+ struct kbd_repeat kbdrep_s;
+
+ /* don't change, just test */
+ kbdrep_s.rate = -1;
+ kbdrep_s.delay = -1;
+ if (ioctl( 0, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+
+ /* do the change */
+ if (rate == 0) /* switch repeat off */
+ kbdrep_s.rate = 0;
+ else
+ kbdrep_s.rate = 10000 / rate; /* convert cps to msec */
+ if (kbdrep_s.rate < 1)
+ kbdrep_s.rate = 1;
+ kbdrep_s.delay = delay;
+ if (kbdrep_s.delay < 1)
+ kbdrep_s.delay = 1;
+
+ if (ioctl( 0, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+
+ return 1; /* success! */
+#else /* no KDKBDREP */
+ return 0;
+#endif /* KDKBDREP */
+}
+
+static int
+KIOCSRATE_ioctl_ok(int rate, int delay) {
+#ifdef KIOCSRATE
+ struct kbd_rate kbdrate_s;
+ int fd;
+
+ fd = open("/dev/kbd", O_RDONLY);
+ if (fd == -1)
+ return 0;
+
+ kbdrate_s.rate = (rate + 5) / 10; /* must be integer, so round up */
+ kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */
+ if (kbdrate_s.rate > 50)
+ kbdrate_s.rate = 50;
+
+ if (ioctl( fd, KIOCSRATE, &kbdrate_s ))
+ return 0;
+
+ close( fd );
+
+ return 1;
+#else /* no KIOCSRATE */
+ return 0;
+#endif /* KIOCSRATE */
+}
+
+#undef rate
+
#if NeedFunctionPrototypes
void xf86SetKbdRepeat(char rad)
#else
@@ -71,23 +149,101 @@ void xf86SetKbdRepeat(rad)
char rad;
#endif
{
- return;
+#ifdef __sparc__
+ int rate = 500; /* Default rate */
+ int delay = 200; /* Default delay */
+#else
+ int rate = 300; /* Default rate */
+ int delay = 250; /* Default delay */
+#endif
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+ int i;
+ int timeout;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+#endif
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate * 10;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+
+ if(KDKBDREP_ioctl_ok(rate, delay)) /* m68k? */
+ return;
+
+ if(KIOCSRATE_ioctl_ok(rate, delay)) /* sparc? */
+ return;
+
+ if (xf86IsPc98())
+ return;
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+
+ /* The ioport way */
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ timeout = KBC_TIMEOUT;
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ if (timeout == 0)
+ return;
+
+ outb(0x60, 0xf3); /* set typematic rate */
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ usleep(10000);
+ outb(0x60, value);
+
+#endif /* __alpha__ || __i386__ || __ia64__ */
}
static int kbdtrans;
static struct termios kbdtty;
-void xf86KbdInit()
+void
+xf86KbdInit()
{
ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
tcgetattr (xf86Info.consoleFd, &kbdtty);
}
-int xf86KbdOn()
+int
+xf86KbdOn()
{
struct termios nTty;
+#ifdef __powerpc__
+ if (xf86Info.kbdCustomKeycodes)
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW);
+ else
+#endif
ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
+
nTty = kbdtty;
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
nTty.c_oflag = 0;
@@ -101,36 +257,11 @@ int xf86KbdOn()
return(xf86Info.consoleFd);
}
-int xf86KbdOff()
+int
+xf86KbdOff()
{
ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
return(xf86Info.consoleFd);
}
-void xf86MouseInit(mouse)
-MouseDevPtr mouse;
-{
- return;
-}
-
-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));
- }
-
- xf86SetupMouse(mouse);
-
- /* Flush any pending input */
- tcflush(mouse->mseFd, TCIFLUSH);
-
- return(mouse->mseFd);
-}
diff --git a/hw/xfree86/os-support/linux/lnx_jstk.c b/hw/xfree86/os-support/linux/lnx_jstk.c
index ea308c159..2423bd45e 100644
--- a/hw/xfree86/os-support/linux/lnx_jstk.c
+++ b/hw/xfree86/os-support/linux/lnx_jstk.c
@@ -1,4 +1,4 @@
-/* $Xorg: lnx_jstk.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
+/* $XConsortium: lnx_jstk.c /main/7 1996/02/21 17:51:36 kaleb $ */
/* Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp */
/*
* Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
@@ -23,19 +23,31 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.6 1996/12/23 06:50:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.13 1998/07/25 16:56:43 dawes Exp $ */
-static const char rcs_id[] = "$Xorg: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp";
+static const char rcs_id[] = "Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp";
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
+#include <errno.h>
#define inline __inline__
#include <linux/joystick.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-extern int errno;
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
+
+#if !defined(JSIOCGTIMELIMIT)
+/* make 2.1.x joystick.h backward compatable */
+#define JSIOCGTIMELIMIT JS_GET_TIMELIMIT
+#define JSIOCSTIMELIMIT JS_SET_TIMELIMIT
+#define js_status JS_DATA_TYPE
+#endif
+
/***********************************************************************
*
@@ -50,33 +62,30 @@ int
xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY)
{
int fd;
- struct JS_DATA_TYPE js;
- extern int xf86Verbose;
+ struct js_status js;
#ifdef DEBUG
ErrorF("xf86JoystickOn %s\n", name);
#endif
- if ((fd = open(name, O_RDWR | O_NDELAY)) < 0)
+ if ((fd = open(name, O_RDWR | O_NDELAY, 0)) < 0)
{
- ErrorF("Cannot open joystick '%s' (%s)\n", name,
- strerror(errno));
+ xf86Msg(X_WARNING, "Cannot open joystick '%s' (%s)\n", name,
+ strerror(errno));
return -1;
}
if (*timeout == 0) {
- if (ioctl (fd, JS_GET_TIMELIMIT, timeout) == -1) {
- Error("joystick JS_GET_TIMELIMIT ioctl");
+ if (ioctl (fd, JSIOCGTIMELIMIT, timeout) == -1) {
+ Error("joystick JSIOCGTIMELIMIT ioctl");
}
else {
- if (xf86Verbose) {
- ErrorF("(--) Joystick: timeout value = %d\n", *timeout);
- }
+ xf86Msg(X_CONFIG, "Joystick: timeout value = %d\n", *timeout);
}
}
else {
- if (ioctl(fd, JS_SET_TIMELIMIT, timeout) == -1) {
- Error("joystick JS_SET_TIMELIMIT ioctl");
+ if (ioctl(fd, JSIOCSTIMELIMIT, timeout) == -1) {
+ Error("joystick JSIOCSTIMELIMIT ioctl");
}
}
@@ -84,17 +93,13 @@ xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY)
read(fd, &js, JS_RETURN);
if (*centerX < 0) {
*centerX = js.x;
- if (xf86Verbose) {
- ErrorF("(--) Joystick: CenterX set to %d\n", *centerX);
- }
+ xf86Msg(X_CONFIG, "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_CONFIG, "Joystick: CenterY set to %d\n", *centerY);
}
-
+
return fd;
}
@@ -123,9 +128,7 @@ xf86JoystickInit()
*/
int
-xf86JoystickOff(fd, doclose)
-int *fd;
-int doclose;
+xf86JoystickOff(int *fd, int doclose)
{
int oldfd;
@@ -146,14 +149,10 @@ 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 JS_DATA_TYPE js;
- int status;
+ struct js_status js;
+ int status;
status = read(fd, &js, JS_RETURN);
@@ -170,4 +169,16 @@ int *buttons;
return 1;
}
+#ifdef XFree86LOADER
+/*
+ * Entry point for XFree86 Loader
+ */
+void
+linux_jstkModuleInit(pointer *data, INT32 *magic)
+{
+ *magic = MAGIC_DONE;
+ *data = NULL;
+}
+#endif
+
/* end of lnx_jstk.c */
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index a29db8251..107d5595e 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.13.2.1 1997/05/11 05:04:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.64 2003/02/17 15:29:22 dawes Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: lnx_video.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
+/* $XConsortium: lnx_video.c /main/9 1996/10/19 18:06:34 kaleb $ */
#include "X.h"
#include "input.h"
@@ -32,603 +32,1065 @@
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
-
+#include "xf86OSpriv.h"
+#include "lnx.h"
#ifdef __alpha__
+#include "xf86Axp.h"
+#endif
-/*
- * The Jensen lacks dense memory, thus we have to address the bus via
- * the sparse addressing scheme.
- *
- * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
- */
-
-#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
-#define SPARSE (5)
-#define isJensen (1)
-#else
-#define isJensen (!_bus_base())
-#define SPARSE (7)
+#ifdef HAS_MTRR_SUPPORT
+#include <asm/mtrr.h>
#endif
-#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base())
-#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x)
-#else
-#define BUS_BASE 0
-#define JENSEN_SHIFT(x) (x)
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
#endif
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
+static Bool ExtendedEnabled = FALSE;
+
+#ifdef __ia64__
+
+#include "compiler.h"
+#include <sys/io.h>
+
+#elif !defined(__powerpc__) && \
+ !defined(__mc68000__) && \
+ !defined(__sparc__) && \
+ !defined(__mips__)
/*
- * Unfortunatly mmap without MAP_FIXED only works the first time :-(
- * This is now fixed in pl13 ALPHA, but still seems to have problems.
+ * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
+ * these.
*/
-#undef ONLY_MMAP_FIXED_WORKS
+extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
+extern int iopl(int __level);
-#ifdef ONLY_MMAP_FIXED_WORKS
-static pointer AllocAddress[MAXSCREENS][NUM_REGIONS];
#endif
-#if 0
-static struct xf86memMap {
- int offset;
- int memSize;
-} xf86memMaps[MAXSCREENS];
-#endif
+#ifdef __alpha__
-pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
-{
- pointer base;
- int fd;
+# ifdef LIBC_IS_FIXED
+extern void sethae(unsigned long hae);
+# else
+# include <unistd.h>
+# define sethae(x) syscall(301,x);
+# endif
-#ifdef ONLY_MMAP_FIXED_WORKS
-#ifdef __alpha__
- FatalError("xf86MapVidMem: Unexpected code for Alpha (pagesize=8k!)\n");
-#endif
- AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000);
- if (AllocAddress[ScreenNum][Region] == NULL)
- {
- FatalError("xf86MapVidMem: can't alloc framebuffer space\n");
- }
- base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region]
- & ~0xFFF) + 0x1000);
- if ((fd = open("/dev/mem", O_RDWR)) < 0)
- {
- FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
- strerror(errno));
- }
- base = (pointer)mmap((caddr_t)base, Size, PROT_READ|PROT_WRITE,
- MAP_FIXED|MAP_SHARED, fd, (off_t)Base);
-#else
- if ((fd = open("/dev/mem", O_RDWR)) < 0)
- {
- FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
- strerror(errno));
- }
- /* This requirers linux-0.99.pl10 or above */
- base = (pointer)mmap((caddr_t)0, JENSEN_SHIFT(Size),
- PROT_READ|PROT_WRITE,
- MAP_SHARED, fd,
- (off_t)(JENSEN_SHIFT((off_t)Base) + BUS_BASE));
-#endif
- close(fd);
- if ((long)base == -1)
- {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
- strerror(errno));
- }
-#if 0
- xf86memMaps[ScreenNum].offset = (int) Base;
- xf86memMaps[ScreenNum].memSize = Size;
-#endif
- return base;
-}
+/* define to test the Sparse addressing on a non-Jensen */
+# ifdef TEST_JENSEN_CODE
+# define isJensen (1)
+# else
+# define isJensen (axpSystem == JENSEN)
+# endif
-#if 0
-void xf86GetVidMemData(ScreenNum, Base, Size)
-int ScreenNum;
-int *Base;
-int *Size;
-{
- *Base = xf86memMaps[ScreenNum].offset;
- *Size = xf86memMaps[ScreenNum].memSize;
-}
-#endif
+# define BUS_BASE bus_base
-void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
-{
- munmap((caddr_t)JENSEN_SHIFT(Base), JENSEN_SHIFT(Size));
-#ifdef ONLY_MMAP_FIXED_WORKS
- xfree(AllocAddress[ScreenNum][Region]);
-#endif
-}
+#else
-Bool xf86LinearVidMem()
-{
- return(TRUE);
-}
+#define BUS_BASE (0)
+
+#endif /* __alpha__ */
/***************************************************************************/
-/* I/O Permissions section */
+/* Video Memory Mapping section */
/***************************************************************************/
-/*
- * Linux handles regular (<= 0x3ff) ports with the TSS I/O bitmap, and
- * extended ports with the iopl() system call.
- *
- * For testing, it's useful to enable only the ports we need, but for
- * production purposes, it's faster to enable all ports.
- */
-#define ALWAYS_USE_EXTENDED
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+#if defined (__alpha__)
+static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
+extern axpDevice lnxGetAXP(void);
+static void unmapVidMemSparse(int, pointer, unsigned long);
+# if defined(JENSEN_SUPPORT)
+static pointer mapVidMemJensen(int, unsigned long, unsigned long, int);
+static void unmapVidMemJensen(int, pointer, unsigned long);
+# endif
+static axpDevice axpSystem = -1;
+static Bool needSparse;
+static unsigned long hae_thresh;
+static unsigned long hae_mask;
+static unsigned long bus_base;
+static unsigned long sparse_size;
+#endif
-#ifdef ALWAYS_USE_EXTENDED
+#ifdef HAS_MTRR_SUPPORT
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
+#define SPLIT_WC_REGIONS 1
-void xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
-{
- if (!InitDone)
- {
- int i;
+static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
+static void undoWC(int, pointer);
+
+/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
+ driver will clean up when we exit. */
+#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */
+#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had
+ a problem. */
+static int mtrr_fd = MTRR_FD_UNOPENED;
- for (i = 0; i < MAXSCREENS; i++)
- ScreenEnabled[i] = FALSE;
- InitDone = TRUE;
+/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0,
+ and will fail on Linux 2.2 with MTRR support configured out,
+ so verbosity should be chosen appropriately. */
+static Bool
+mtrr_open(int verbosity)
+{
+ /* Only report absence of /proc/mtrr once. */
+ static Bool warned = FALSE;
+
+ char **fn;
+ static char *mtrr_files[] = {
+ "/dev/cpu/mtrr", /* Possible future name */
+ "/proc/mtrr", /* Current name */
+ NULL
+ };
+
+ if (mtrr_fd == MTRR_FD_UNOPENED) {
+ /* So open it. */
+ for (fn = mtrr_files; mtrr_fd < 0 && *fn; fn++)
+ mtrr_fd = open(*fn, O_WRONLY);
+
+ if (mtrr_fd < 0)
+ mtrr_fd = MTRR_FD_PROBLEM;
}
- return;
-}
+ if (mtrr_fd == MTRR_FD_PROBLEM) {
+ /* To make sure we only ever warn once, need to check
+ verbosity outside xf86MsgVerb */
+ if (!warned && verbosity <= xf86GetVerbosity()) {
+ xf86MsgVerb(X_WARNING, verbosity,
+ "System lacks support for changing MTRRs\n");
+ warned = TRUE;
+ }
-void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
-{
- return;
+ return FALSE;
+ }
+ else
+ return TRUE;
}
-void xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
+/*
+ * We maintain a list of WC regions for each physical mapping so they can
+ * be undone when unmapping.
+ */
- ScreenEnabled[ScreenNum] = TRUE;
+struct mtrr_wc_region {
+ struct mtrr_sentry sentry;
+ Bool added; /* added WC or removed it */
+ struct mtrr_wc_region * next;
+};
- if (ExtendedEnabled)
- return;
-
-#ifndef __mc68000__
- if (iopl(3))
- FatalError("%s: Failed to set IOPL for I/O\n",
- "xf86EnableIOPorts");
-#endif
- ExtendedEnabled = TRUE;
+static struct mtrr_wc_region *
+mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
+ MessageType from)
+{
+ /* Some BIOS writers thought that setting wc over the mmio
+ region of a graphics devices was a good idea. Try to fix
+ it. */
+
+ struct mtrr_gentry gent;
+ char buf[20];
+ struct mtrr_wc_region *wcreturn = NULL, *wcr;
+
+ /* Linux 2.0 users should not get a warning without -verbose */
+ if (!mtrr_open(2))
+ return NULL;
+
+ for (gent.regnum = 0;
+ ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0;
+ gent.regnum++) {
+ if (gent.type != MTRR_TYPE_WRCOMB
+ || gent.base + gent.size <= base
+ || base + size <= gent.base)
+ continue;
- return;
+ /* Found an overlapping region. Delete it. */
+
+ wcr = xalloc(sizeof(*wcr));
+ if (!wcr)
+ return NULL;
+ wcr->sentry.base = gent.base;
+ wcr->sentry.size = gent.size;
+ wcr->sentry.type = MTRR_TYPE_WRCOMB;
+ wcr->added = FALSE;
+
+ /* There is now a nicer ioctl-based way to do this,
+ but it isn't in current kernels. */
+ snprintf(buf, sizeof(buf), "disable=%u\n", gent.regnum);
+
+ if (write(mtrr_fd, buf, strlen(buf)) >= 0) {
+ xf86DrvMsg(screenNum, from,
+ "Removed MMIO write-combining range "
+ "(0x%lx,0x%lx)\n",
+ gent.base, gent.size);
+ wcr->next = wcreturn;
+ wcreturn = wcr;
+ } else {
+ xfree(wcr);
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to remove MMIO "
+ "write-combining range (0x%lx,0x%lx)\n",
+ gent.base, gent.size);
+ }
+ }
+ return wcreturn;
}
-void xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
+
+static struct mtrr_wc_region *
+mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
+ MessageType from)
{
- int i;
+ struct mtrr_wc_region *wcr;
- ScreenEnabled[ScreenNum] = FALSE;
+ /* Linux 2.0 should not warn, unless the user explicitly asks for
+ WC. */
+ if (!mtrr_open(from == X_CONFIG ? 0 : 2))
+ return NULL;
- if (!ExtendedEnabled)
- return;
+ wcr = xalloc(sizeof(*wcr));
+ if (!wcr)
+ return NULL;
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
+ wcr->sentry.base = base;
+ wcr->sentry.size = size;
+ wcr->sentry.type = MTRR_TYPE_WRCOMB;
+ wcr->added = TRUE;
+ wcr->next = NULL;
-#ifndef __mc68000__
- iopl(0);
-#endif
- ExtendedEnabled = FALSE;
+#if SPLIT_WC_REGIONS
+ /*
+ * Splits up the write-combining region if it is not aligned on a
+ * size boundary.
+ */
- return;
+ {
+ unsigned long lbase, d_size = 1;
+ unsigned long n_size = size;
+ unsigned long n_base = base;
+
+ for (lbase = n_base, d_size = 1; !(lbase & 1);
+ lbase = lbase >> 1, d_size <<= 1);
+ while (d_size > n_size)
+ d_size = d_size >> 1;
+#ifdef DEBUG
+ ErrorF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1);
+#endif
+ n_base += d_size;
+ n_size -= d_size;
+ if (n_size) {
+ xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: "
+ "base: 0x%lx, size: 0x%lx\n",base,size);
+ wcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from);
+ }
+ wcr->sentry.size = d_size;
+ }
+
+ /*****************************************************************/
+#endif /* SPLIT_WC_REGIONS */
+
+ if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &wcr->sentry) >= 0) {
+ /* Avoid printing on every VT switch */
+ if (xf86ServerIsInitialising()) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n",
+ base, size);
+ }
+ return wcr;
+ }
+ else {
+ xfree(wcr);
+
+ /* Don't complain about the VGA region: MTRR fixed
+ regions aren't currently supported, but might be in
+ the future. */
+ if ((unsigned long)base >= 0x100000) {
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to set up write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ }
+ return NULL;
+ }
}
-#else /* !ALWAYS_USE_EXTENDED */
-
-static unsigned *EnabledPorts[MAXSCREENS];
-static int NumEnabledPorts[MAXSCREENS];
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedPorts[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-
-void xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
+static void
+mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
{
- if (!InitDone)
- {
- xf86InitPortLists(EnabledPorts, NumEnabledPorts,
- ScreenEnabled, ExtendedPorts, MAXSCREENS);
- InitDone = TRUE;
- return;
+ struct mtrr_wc_region *p, *prev;
+
+ if (mtrr_fd > 0) {
+ p = wcr;
+ while (p) {
+ if (p->added)
+ ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
+ prev = p;
+ p = p->next;
+ xfree(prev);
+ }
}
- ExtendedPorts[ScreenNum] = FALSE;
- if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
- xfree(EnabledPorts[ScreenNum]);
- EnabledPorts[ScreenNum] = (unsigned *)NULL;
- NumEnabledPorts[ScreenNum] = 0;
}
-void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
+static pointer
+setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
{
- int i;
-
- if (!InitDone)
- {
- FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
- }
- EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum],
- (NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
- for (i = 0; i < NumPorts; i++)
- {
- EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
- Ports[i];
- if (Ports[i] > 0x3FF)
- ExtendedPorts[ScreenNum] = TRUE;
- }
- NumEnabledPorts[ScreenNum] += NumPorts;
+ if (enable)
+ return mtrr_add_wc_region(screenNum, base, size, from);
+ else
+ return mtrr_cull_wc_region(screenNum, base, size, from);
}
-void xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
+static void
+undoWC(int screenNum, pointer regioninfo)
{
- int i;
+ mtrr_undo_wc_region(screenNum, regioninfo);
+}
- if (ScreenEnabled[ScreenNum])
- return;
+#endif /* HAS_MTRR_SUPPORT */
- for (i = 0; i < MAXSCREENS; i++)
- {
- if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum))
- {
-#ifndef __mc68000__
- if (iopl(3))
- {
- FatalError("%s: Failed to set IOPL for extended I/O\n",
- "xf86EnableIOPorts");
- }
-#endif
- ExtendedEnabled = TRUE;
- break;
- }
- }
- /* Extended I/O was used, but not any more */
- if (ExtendedEnabled && i == MAXSCREENS)
- {
-#ifndef __mc68000__
- iopl(0);
-#endif
- ExtendedEnabled = FALSE;
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+#ifdef __alpha__
+ if (axpSystem == -1) {
+ axpSystem = lnxGetAXP();
+ if ((needSparse = (_bus_base_sparse() > 0))) {
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ sparse_size = xf86AXPParams[axpSystem].size;
+ }
+ bus_base = _bus_base();
}
- /*
- * Turn on non-extended ports even when using extended I/O
- * so they are there if extended I/O gets turned off when it's no
- * longer needed.
- */
- for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
- {
- unsigned port = EnabledPorts[ScreenNum][i];
+ if (isJensen) {
+# ifndef JENSEN_SUPPORT
+ FatalError("Jensen is not supported any more\n"
+ "If you are intereseted in fixing Jensen support\n"
+ "please contact xfree86@xfree86.org\n");
+# else
+ xf86Msg(X_INFO,"Machine type is Jensen\n");
+ pVidMem->mapMem = mapVidMemJensen;
+ pVidMem->unmapMem = unmapVidMemJensen;
+# endif /* JENSEN_SUPPORT */
+ } else if (needSparse) {
+ xf86Msg(X_INFO,"Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+ } else {
+ xf86Msg(X_INFO,"Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ }
+#else
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#endif /* __alpha__ */
- if (port > 0x3FF)
- continue;
- if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
- ScreenEnabled, MAXSCREENS))
- {
- if (ioperm(port, 1, TRUE) < 0)
- {
- FatalError("%s: Failed to enable I/O port 0x%x (%s)\n",
- "xf86EnableIOPorts", port, strerror(errno));
- }
- }
- }
- ScreenEnabled[ScreenNum] = TRUE;
- return;
+#ifdef HAS_MTRR_SUPPORT
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+#endif
+ pVidMem->initialised = TRUE;
}
-void xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
+#ifdef __sparc__
+/* Basically, you simply cannot do this on Sparc. You have to do something portable
+ * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
+ */
+static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ return NULL;
+}
+#else
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- int i;
+ pointer base;
+ int fd;
+ int mapflags = MAP_SHARED;
+ memType realBase, alignOff;
+
+ realBase = Base & ~(getpagesize() - 1);
+ alignOff = Base - realBase;
+#ifdef DEBUG
+ ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n",
+ Base,realBase,alignOff);
+#endif
+
+#if defined(__ia64__)
+#ifndef MAP_WRITECOMBINED
+#define MAP_WRITECOMBINED 0x00010000
+#endif
+#ifndef MAP_NONCACHED
+#define MAP_NONCACHED 0x00020000
+#endif
+ if(flags & VIDMEM_FRAMEBUFFER)
+ mapflags |= MAP_WRITECOMBINED;
+ else
+ mapflags |= MAP_NONCACHED;
+#endif
- if (!ScreenEnabled[ScreenNum])
- return;
+#if defined(__ia64__)
+ /* this will disappear when people upgrade their kernels */
+ if ((fd = open(DEV_MEM, O_RDWR|O_SYNC)) < 0)
+#else
+ if ((fd = open(DEV_MEM, O_RDWR)) < 0)
+#endif
+ {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+ /* This requires linux-0.99.pl10 or above */
+ base = mmap((caddr_t)0, Size + alignOff,
+ PROT_READ|PROT_WRITE,
+ mapflags, fd,
+ (off_t)(off_t)realBase + BUS_BASE);
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer"
+ " (0x%08x,0x%x) (%s)\n", Base, Size,
+ strerror(errno));
+ }
+#ifdef DEBUG
+ ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff);
+#endif
+ return (char *)base + alignOff;
+}
+#endif /* !(__sparc__) */
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ memType alignOff = (memType)Base
+ - ((memType)Base & ~(getpagesize() - 1));
+
+#ifdef DEBUG
+ ErrorF("alignment offset: %lx\n",alignOff);
+#endif
+ munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
+}
- ScreenEnabled[ScreenNum] = FALSE;
- for (i = 0; i < MAXSCREENS; i++)
- {
- if (ScreenEnabled[i] && ExtendedPorts[i])
- break;
- }
- if (ExtendedEnabled && i == MAXSCREENS)
- {
-#ifndef __mc68000__
- iopl(0);
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+#if defined(__powerpc__)
+volatile unsigned char *ioBase = NULL;
+
+#ifndef __NR_pciconfig_iobase
+#define __NR_pciconfig_iobase 200
#endif
- ExtendedEnabled = FALSE;
- }
- for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
- {
- unsigned port = EnabledPorts[ScreenNum][i];
- if (port > 0x3FF)
- continue;
+#endif
- if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
- ScreenEnabled, MAXSCREENS))
- {
- ioperm(port, 1, FALSE);
+void
+xf86EnableIO(void)
+{
+#if defined(__powerpc__)
+ int fd;
+ unsigned int ioBase_phys;
+#endif
+
+ if (ExtendedEnabled)
+ return;
+
+#if defined(__powerpc__)
+ ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
+
+ fd = open("/dev/mem", O_RDWR);
+ if (ioBase == NULL) {
+ ioBase = (volatile unsigned char *)mmap(0, 0x20000,
+ PROT_READ|PROT_WRITE, MAP_SHARED, fd,
+ ioBase_phys);
+/* Should this be fatal or just a warning? */
+#if 0
+ if (ioBase == MAP_FAILED) {
+ FatalError(
+ "xf86EnableIOPorts: Failed to map iobase (%s)\n",
+ strerror(errno));
}
+#endif
}
+ close(fd);
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
+ if (ioperm(0, 1024, 1) || iopl(3))
+ FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+# if !defined(__alpha__)
+ ioperm(0x40,4,0); /* trap access to the timer chip */
+ ioperm(0x60,4,0); /* trap access to the keyboard controller */
+# endif
+#endif
+ ExtendedEnabled = TRUE;
+
return;
}
-#endif /* ALWAYS_USE_EXTENDED */
-
-void xf86DisableIOPrivs()
+void
+xf86DisableIO(void)
{
-#ifndef __mc68000__
- if (ExtendedEnabled)
- iopl(0);
+ if (!ExtendedEnabled)
+ return;
+#if defined(__powerpc__)
+ munmap(ioBase, 0x20000);
+ ioBase = NULL;
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
+ iopl(0);
+ ioperm(0, 1024, 0);
#endif
+ ExtendedEnabled = FALSE;
+
return;
}
+
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
-Bool xf86DisableInterrupts()
+/* XXX The #ifdefs should be made simpler. */
+
+Bool
+xf86DisableInterrupts()
{
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
if (!ExtendedEnabled)
-#ifndef __mc68000__
- if (iopl(3))
+ if (iopl(3) || ioperm(0, 1024, 1))
return (FALSE);
#endif
-#if defined(__alpha__) || defined(__mc68000__)
-#else
-#ifdef __GNUC__
- __asm__ __volatile__("cli");
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
#else
+# ifdef __GNUC__
+# if defined(__ia64__)
+# if 0
+ __asm__ __volatile__ (";; rsm psr.i;; srlz.d" ::: "memory");
+# endif
+# else
+ __asm__ __volatile__("cli");
+# endif
+# else
asm("cli");
+# endif
#endif
-#endif
-#ifndef __mc68000__
- if (!ExtendedEnabled)
- iopl(0);
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
+
#endif
return (TRUE);
}
-void xf86EnableInterrupts()
+void
+xf86EnableInterrupts()
{
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
if (!ExtendedEnabled)
-#ifndef __mc68000__
- if (iopl(3))
+ if (iopl(3) || ioperm(0, 1024, 1))
return;
#endif
-#if defined(__alpha__) || defined(__mc68000__)
-#else
-#ifdef __GNUC__
- __asm__ __volatile__("sti");
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
#else
+# ifdef __GNUC__
+# if defined(__ia64__)
+# if 0
+ __asm__ __volatile__ (";; ssm psr.i;; srlz.d" ::: "memory");
+# endif
+# else
+ __asm__ __volatile__("sti");
+# endif
+# else
asm("sti");
+# endif
#endif
-#endif
-#ifndef __mc68000__
- if (!ExtendedEnabled)
- iopl(0);
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
#endif
return;
}
-#if defined(__alpha__)
+#if defined (__alpha__)
-static int xf86SparseShift = 5; /* default to all but JENSEN */
+#define vuip volatile unsigned int *
-pointer xf86MapVidMemSparse(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+extern int readDense8(pointer Base, register unsigned long Offset);
+extern int readDense16(pointer Base, register unsigned long Offset);
+extern int readDense32(pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+static int readSparse8(pointer Base, register unsigned long Offset);
+static int readSparse16(pointer Base, register unsigned long Offset);
+static int readSparse32(pointer Base, register unsigned long Offset);
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset);
+
+#define DENSE_BASE 0x2ff00000000UL
+#define SPARSE_BASE 0x30000000000UL
+
+static unsigned long msb_set = 0;
+
+static pointer
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- pointer base;
- int fd;
+ int fd;
+ unsigned long ret, rets = 0;
+
+ static Bool was_here = FALSE;
+
+ if (!was_here) {
+ was_here = TRUE;
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+ }
+
+ if ((fd = open(DEV_MEM, O_RDWR)) < 0) {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+
+#if 0
+ xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
+ Base, Size, flags);
+#endif
- if (!_bus_base()) xf86SparseShift = 7; /* Uh, oh, JENSEN... */
+ /* This requirers linux-0.99.pl10 or above */
+
+ /*
+ * Always do DENSE mmap, since read32/write32 currently require it.
+ */
+ ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd,
+ (off_t) (bus_base + Base));
+
+ /*
+ * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
+ * and SPARSE (which should require the use of read/write macros).
+ *
+ * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
+ * bytes worth of pagetable (32 pages).
+ */
+ if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
+ {
+ rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
+ Size << 5, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd,
+ (off_t) _bus_base_sparse() + (Base << 5));
+ }
- Size <<= xf86SparseShift;
- Base = (pointer)((unsigned long)Base << xf86SparseShift);
+ close(fd);
+
+ if (ret == (unsigned long)MAP_FAILED) {
+ FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
+ strerror(errno));
+ }
- if ((fd = open("/dev/mem", O_RDWR)) < 0)
+ if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
+ {
+ if (rets == (unsigned long)MAP_FAILED ||
+ rets != (SPARSE_BASE + (Base << 5)))
{
- FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
- strerror(errno));
+ FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
+ strerror(errno));
}
- /* This requirers linux-0.99.pl10 or above */
- base = (pointer)mmap((caddr_t)0, Size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, fd,
- (off_t)Base + _bus_base_sparse());
- close(fd);
- if ((long)base == -1)
- {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
- strerror(errno));
+ }
+
+#if 1
+ if (rets)
+ xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
+ Base, Size, ret, rets);
+ else
+ xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE only at 0x%lx\n",
+ Base, Size, ret);
+
+#endif
+ return (pointer) ret;
+}
+
+static void
+unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long Offset = (unsigned long)Base - DENSE_BASE;
+#if 1
+ xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
+ Base, Size);
+#endif
+ /* Unmap DENSE always. */
+ munmap((caddr_t)Base, Size);
+
+ /* Unmap SPARSE always, and ignore error in case we did not map it. */
+ munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5);
+}
+
+static int
+readSparse8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ shift = (Offset & 0x3) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
}
- return base;
+ }
+
+ mem_barrier();
+ result = *(vuip) (SPARSE_BASE + (Offset << 5));
+ result >>= shift;
+ return 0xffUL & result;
}
-void xf86UnMapVidMemSparse(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static int
+readSparse16(pointer Base, register unsigned long Offset)
{
- Size <<= xf86SparseShift;
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ shift = (Offset & 0x2) << 3;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
- munmap((caddr_t)Base, Size);
+ mem_barrier();
+ result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2)));
+ result >>= shift;
+ return 0xffffUL & result;
}
-#define vuip volatile unsigned int *
+static int
+readSparse32(pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ mem_barrier();
+ return *(vuip)((unsigned long)Base+(Offset));
+}
-extern void sethae(unsigned long hae);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+
+ write_mem_barrier();
+ *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
+}
-int xf86ReadSparse8(Base, Offset)
-pointer Base;
-unsigned long Offset;
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset)
{
- unsigned long result, shift;
- unsigned long msb = 0;
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
- shift = (Offset & 0x3) * 8;
- if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000UL;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
+ write_mem_barrier();
+ *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001;
+}
+
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
- result = *(vuip) ((unsigned long)Base + (Offset << xf86SparseShift));
- if (msb)
- sethae(0);
+ *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+ *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001;
+}
+
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
+ = readDense32;
+
+#ifdef JENSEN_SUPPORT
+
+static int
+readSparseJensen8(pointer Base, register unsigned long Offset);
+static int
+readSparseJensen16(pointer Base, register unsigned long Offset);
+static int
+readSparseJensen32(pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset);
+
+/*
+ * The Jensen lacks dense memory, thus we have to address the bus via
+ * the sparse addressing scheme.
+ *
+ * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
+ */
+
+#ifdef TEST_JENSEN_CODE
+#define SPARSE (5)
+#else
+#define SPARSE (7)
+#endif
+
+#define JENSEN_SHIFT(x) ((long)x<<SPARSE)
+
+static pointer
+mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+
+ xf86WriteMmio8 = writeSparseJensen8;
+ xf86WriteMmio16 = writeSparseJensen16;
+ xf86WriteMmio32 = writeSparseJensen32;
+ xf86WriteMmioNB8 = writeSparseJensenNB8;
+ xf86WriteMmioNB16 = writeSparseJensenNB16;
+ xf86WriteMmioNB32 = writeSparseJensenNB32;
+ xf86ReadMmio8 = readSparseJensen8;
+ xf86ReadMmio16 = readSparseJensen16;
+ xf86ReadMmio32 = readSparseJensen32;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) < 0) {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+ /* This requires linux-0.99.pl10 or above */
+ base = mmap((caddr_t)0, JENSEN_SHIFT(Size),
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd,
+ (off_t)(JENSEN_SHIFT((off_t)Base) + _bus_base_sparse()));
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer"
+ " (0x%08x,0x%x) (%s)\n", Base, Size,
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMemJensen(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, JENSEN_SHIFT(Size));
+}
+
+static int
+readSparseJensen8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+
+ mem_barrier();
+ shift = (Offset & 0x3) << 3;
+
+ result = *(vuip) ((unsigned long)Base + (Offset << SPARSE));
+
result >>= shift;
return 0xffUL & result;
}
-int xf86ReadSparse16(Base, Offset)
-pointer Base;
-unsigned long Offset;
+static int
+readSparseJensen16(pointer Base, register unsigned long Offset)
{
- unsigned long result, shift;
- unsigned long msb = 0;
+ register unsigned long result, shift;
+
+ mem_barrier();
+ shift = (Offset & 0x2) << 3;
+
+ result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2)));
- shift = (Offset & 0x2) * 8;
- if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000UL;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
- }
- result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2)));
- if (msb)
- sethae(0);
result >>= shift;
return 0xffffUL & result;
}
-int xf86ReadSparse32(Base, Offset)
-pointer Base;
-unsigned long Offset;
+static int
+readSparseJensen32(pointer Base, register unsigned long Offset)
{
- unsigned long result;
- unsigned long msb = 0;
+ register unsigned long result;
+
+ mem_barrier();
+ result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2)));
- if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000UL;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
- }
- result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2)));
- if (msb)
- sethae(0);
return result;
}
-void xf86WriteSparse8(Value, Base, Offset)
-int Value;
-pointer Base;
-unsigned long Offset;
+static void
+writeSparseJensen8(int Value, pointer Base, register unsigned long Offset)
{
- unsigned long msb = 0;
- unsigned int b = Value & 0xffU;
+ register unsigned int b = Value & 0xffU;
- if (xf86SparseShift != 7) { /* not JENSEN */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
- }
- *(vuip) ((unsigned long)Base + (Offset << xf86SparseShift)) = b * 0x01010101;
- if (msb)
- sethae(0);
+ write_mem_barrier();
+ *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
}
-void xf86WriteSparse16(Value, Base, Offset)
-int Value;
-pointer Base;
-unsigned long Offset;
+static void
+writeSparseJensen16(int Value, pointer Base, register unsigned long Offset)
{
- unsigned long msb = 0;
- unsigned int w = Value & 0xffffU;
+ register unsigned int w = Value & 0xffffU;
- if (xf86SparseShift != 7) { /* not JENSEN */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
- }
- *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2))) =
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
w * 0x00010001;
- if (msb)
- sethae(0);
}
-void xf86WriteSparse32(Value, Base, Offset)
-int Value;
-pointer Base;
-unsigned long Offset;
+static void
+writeSparseJensen32(int Value, pointer Base, register unsigned long Offset)
{
- unsigned long msb = 0;
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
+}
- if (xf86SparseShift != 7) { /* not JENSEN */
- if (Offset >= (1UL << 24)) {
- msb = Offset & 0xf8000000;
- Offset -= msb;
- if (msb) {
- sethae(msb);
- }
- }
- }
- *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2))) = Value;
- if (msb)
- sethae(0);
+static void
+writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int b = Value & 0xffU;
+
+ *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
}
+
+static void
+writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int w = Value & 0xffffU;
+
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
+}
+#endif /* JENSEN_SUPPORT */
+
#endif /* __alpha__ */
diff --git a/hw/xfree86/os-support/lynxos/lynx_init.c b/hw/xfree86/os-support/lynxos/lynx_init.c
index 6c0e00aa3..8565dcc5c 100644
--- a/hw/xfree86/os-support/lynxos/lynx_init.c
+++ b/hw/xfree86/os-support/lynxos/lynx_init.c
@@ -22,36 +22,33 @@
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c,v 3.1.6.1 1998/02/06 22:36:51 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c,v 3.3 1998/08/29 05:43:58 dawes Exp $ */
#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"
static int VTnum = -1;
-void xf86OpenConsole()
+void
+xf86OpenConsole()
{
struct vt_mode VT;
char vtname1[11];
- int i, fd, pgrp;
+ int fd, pgrp;
+ MessageType from = X_PROBED;
if (serverGeneration == 1)
{
/* check if we're 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");
}
/*
@@ -67,6 +64,7 @@ void xf86OpenConsole()
if (VTnum != -1)
{
xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
}
else
{
@@ -88,7 +86,7 @@ void xf86OpenConsole()
}
close(fd);
}
- ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
+ xf86Msg(from, "using VT number %d\n", xf86Info.vtno);
sprintf(vtname1,"/dev/atc%d",xf86Info.vtno);
@@ -104,19 +102,12 @@ void xf86OpenConsole()
/* change ownership of the vt */
chown(vtname1, getuid(), getgid());
- /* Reading Config after opening the VT get's rid of */
- /* problems with LynxOS VT handling (i.e. VT_OPENQUERY */
- /* without open() leaves the vtxx busy until next */
- /* open/close) */
-
- xf86Config(FALSE); /* Read XF86Config */
-
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
{
@@ -142,20 +133,21 @@ void xf86OpenConsole()
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
/*
* If the server doesn't have the VT when the reset occurs,
* this is to make sure we don't continue until the activate
* signal is received.
*/
- if (!xf86VTSema)
+ if (!xf86Screens[0]->vtSema)
sleep(5);
}
return;
}
-void xf86CloseConsole()
+void
+xf86CloseConsole()
{
struct vt_mode VT;
@@ -172,10 +164,8 @@ void xf86CloseConsole()
return;
}
-int xf86ProcessArgument (argc, argv, i)
-int argc;
-char *argv[];
-int i;
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
{
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
@@ -190,7 +180,8 @@ int i;
return(0);
}
-void xf86UseMsg()
+void
+xf86UseMsg()
{
ErrorF("vtXX use the specified VT number\n");
return;
diff --git a/hw/xfree86/os-support/lynxos/lynx_io.c b/hw/xfree86/os-support/lynxos/lynx_io.c
index e0134609e..e61ce76b7 100644
--- a/hw/xfree86/os-support/lynxos/lynx_io.c
+++ b/hw/xfree86/os-support/lynxos/lynx_io.c
@@ -21,25 +21,20 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c,v 3.3 1996/08/10 13:07:36 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c,v 3.10 2003/02/17 15:11:57 dawes Exp $ */
-#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"
#if defined(KDMKTONE) || defined(KIOCSOUND)
/* Lynx 2.2.1 has sophisticated atc stuff.... */
-void xf86SoundKbdBell(loudness, pitch, duration)
-int loudness;
-int pitch;
-int duration;
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
{
if (loudness && pitch)
{
@@ -73,10 +68,8 @@ int duration;
#define FREQ_LO(f) ((TIMER_CONSTANT / (f)) % 256)
#define FREQ_HI(f) ((TIMER_CONSTANT / (f)) / 256)
-void xf86SoundKbdBell(loudness, pitch, duration)
-int loudness;
-int pitch;
-int duration;
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
{
int flo = FREQ_LO(pitch);
int fhi = FREQ_HI(pitch);
@@ -93,28 +86,43 @@ int duration;
}
#endif
-void xf86SetKbdLeds(leds)
-int leds;
+void
+xf86SetKbdLeds(int leds)
{
+#ifdef KBD_SET_LEDS
+ ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds);
+#endif
}
-int xf86GetKbdLeds()
+int
+xf86GetKbdLeds()
{
+#ifdef KBD_SET_LEDS
+ int leds;
+
+ if (ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds) < 0)
+ return 0;
+
+ return leds;
+#endif
return 0;
}
-void xf86SetKbdRepeat(char rad)
+void
+xf86SetKbdRepeat(char rad)
{
}
static struct termio kbdtty;
-void xf86KbdInit()
+void
+xf86KbdInit()
{
ioctl(xf86Info.consoleFd, TCGETA, &kbdtty);
}
-int xf86KbdOn()
+int
+xf86KbdOn()
{
struct termio nTty;
@@ -136,7 +144,8 @@ int xf86KbdOn()
return(xf86Info.consoleFd);
}
-int xf86KbdOff()
+int
+xf86KbdOff()
{
/* disable scan mode */
ioctl(xf86Info.consoleFd, TIO_DISSCANMODE, NULL);
@@ -144,29 +153,10 @@ int xf86KbdOff()
return(xf86Info.consoleFd);
}
-void xf86MouseInit(mouse)
-MouseDevPtr mouse;
-{
- return;
-}
+#include "xf86OSKbd.h"
-int xf86MouseOn(mouse)
-MouseDevPtr mouse;
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
{
- 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));
- }
-
- /* assert DTR */
- ioctl(mouse->mseFd, TIOCSDTR, NULL);
-
- xf86SetupMouse(mouse);
-
- return(mouse->mseFd);
+ return FALSE;
}
diff --git a/hw/xfree86/os-support/lynxos/lynx_mmap.c b/hw/xfree86/os-support/lynxos/lynx_mmap.c
index 621f42c5d..dcf734965 100644
--- a/hw/xfree86/os-support/lynxos/lynx_mmap.c
+++ b/hw/xfree86/os-support/lynxos/lynx_mmap.c
@@ -21,11 +21,9 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c,v 3.2 1996/09/29 13:38:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c,v 3.6 2000/02/11 22:36:02 dawes Exp $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
@@ -35,26 +33,30 @@
* Read BIOS using smem_create facility
*/
-int xf86ReadBIOS(Base, Offset, Buf, Len)
-unsigned long Base;
-unsigned long Offset;
-unsigned char *Buf;
-int Len;
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
{
+#if defined(__powerpc__)
+ xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n");
+ return(-1);
+#else
char *p;
int mlen;
- mlen = (Offset + Len + 4095) & ~4096;
+ mlen = (Offset + Len + 4095) & ~4095;
p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
if (p == NULL)
{
/* check if there is a stale segment around */
if (smem_remove("BIOS-probe") == 0) {
- ErrorF("xf86ReadBios: removed stale smem_ segment\n");
+ xf86Msg(X_INFO,
+ "xf86ReadBios: removed stale smem_ segment\n");
p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
}
if (p == NULL) {
- ErrorF("xf86ReadBios: Failed to smem_create Base %x len %x %s \n",
+ xf86Msg(X_WARNING, "xf86ReadBios: Failed to smem_create "
+ "Base %x len %x %s \n",
Base, mlen, strerror(errno));
return(-1);
}
@@ -63,4 +65,5 @@ int Len;
smem_create(NULL, p, 0, SM_DETACH);
smem_remove("BIOS-probe");
return(Len);
+#endif
}
diff --git a/hw/xfree86/os-support/lynxos/lynx_video.c b/hw/xfree86/os-support/lynxos/lynx_video.c
index 94b2f0ecd..c667994b3 100644
--- a/hw/xfree86/os-support/lynxos/lynx_video.c
+++ b/hw/xfree86/os-support/lynxos/lynx_video.c
@@ -21,7 +21,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.2.4.1 1997/05/09 07:15:24 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.18 2002/12/14 04:41:14 dawes Exp $ */
#include "X.h"
#include "input.h"
@@ -30,6 +30,81 @@
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__powerpc__)
+
+# if defined(USE_MACHINE_ABSOLUTE)
+# include <machine/absolute.h>
+# else
+# define __USER_SPACE_INCLUDE
+# include <hw_absolute.h>
+# endif
+
+void ppcPciIoMap(int bus);
+#endif
+
+#if 0
+#define DEBUG
+#endif
+
+#ifdef HAS_MTRR_SUPPORT
+#include <sys/memrange.h>
+#define X_MTRR_ID "XFree86"
+
+static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
+static void undoWC(int, pointer);
+static Bool cleanMTRR(void);
+static int devMemFd = -1;
+#define MTRR_DEVICE "/dev/mtrr"
+#endif
+
+
+#if !defined(NO_MMAP)
+#include <sys/mman.h>
+
+int smem_remove(char *name)
+{
+ return(0);
+}
+
+char *smem_create(char *name, char *arg_addr, long size, int mode)
+{
+ int fd;
+ void *addr = 0;
+ char *retval;
+ size_t len = size;
+ int prot = PROT_READ|PROT_WRITE|PROT_UNCACHE;
+ int flags = MAP_SHARED;
+ off_t off = (off_t)arg_addr;
+
+ if ((fd = open("/dev/mem" , O_RDWR)) < 0)
+ {
+ retval = (char *)-1;
+ }
+ else
+ {
+ if (mode == SM_DETACH)
+ {
+ munmap(arg_addr, len);
+ retval = 0;
+ }
+ else
+ {
+ if ((retval = mmap (addr, len, prot, flags, fd, off) ) == MAP_FAILED)
+ {
+ retval = (char *)-1;
+ }
+ }
+
+ close(fd);
+ }
+
+ return(retval);
+}
+
+#endif
+
/***************************************************************************/
/* Video Memory Mapping section */
@@ -38,19 +113,24 @@
typedef struct
{
char name[16];
- pointer Base;
- long Size;
+ unsigned long Base;
+ unsigned long Size;
char *ptr;
int RefCnt;
}
_SMEMS;
-#define MAX_SMEMS 8
+#define MAX_SMEMS 16
static _SMEMS smems[MAX_SMEMS];
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
static void
-smemCleanup()
+smemCleanup(void)
{
int i;
@@ -60,18 +140,15 @@ smemCleanup()
(void)smem_remove(smems[i].name);
*smems[i].name = '\0';
smems[i].ptr = NULL;
- smems[i].Base = NULL;
+ smems[i].Base = 0;
smems[i].Size = 0;
smems[i].RefCnt = 0;
}
}
}
-pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static pointer
+MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
static int once;
int free_slot = -1;
@@ -86,14 +163,15 @@ unsigned long Size;
{
if (!*smems[i].name && free_slot == -1)
free_slot = i;
- if (smems[i].Base == Base && smems[i].Size == Size && *smems[i].name) {
+ if (smems[i].Base == Base && smems[i].Size == Size
+ && *smems[i].name) {
smems[i].RefCnt++;
return smems[i].ptr;
}
}
if (i == MAX_SMEMS && free_slot == -1)
{
- FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n",
+ FatalError("MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n",
Base, Size);
}
@@ -101,53 +179,85 @@ unsigned long Size;
sprintf(smems[i].name, "Video-%d", i);
smems[i].Base = Base;
smems[i].Size = Size;
- smems[i].ptr = smem_create(smems[i].name, Base, Size, SM_READ|SM_WRITE);
+
+ xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n",
+ Base, Size);
+
+#if defined(__powerpc__)
+ if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) {
+ Base = Base | PHYS_IO_MEM_START;
+ }
+#endif
+
+ smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE);
smems[i].RefCnt = 1;
if (smems[i].ptr == NULL)
{
/* check if there is a stale segment around */
if (smem_remove(smems[i].name) == 0) {
- ErrorF("xf86MapVidMem: removed stale smem_ segment %s\n",
- smems[i].name);
+ xf86Msg(X_INFO,
+ "MapVidMem: removed stale smem_ segment %s\n",
+ smems[i].name);
smems[i].ptr = smem_create(smems[i].name,
- Base, Size, SM_READ|SM_WRITE);
+ (char *)Base, Size, SM_READ|SM_WRITE);
}
if (smems[i].ptr == NULL) {
*smems[i].name = '\0';
- FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (%s)\n",
+ FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n",
Base, Size, strerror(errno));
}
}
+ xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n",
+ Base, Size, smems[i].ptr);
return smems[i].ptr;
}
-void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static void
+UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
int i;
+ xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n",
+ Base, Size);
for (i = 0; i < MAX_SMEMS; i++)
{
- if (*smems[i].name && smems[i].ptr == Base && smems[i].Size == Size)
+ if (*smems[i].name && smems[i].ptr == Base
+ && smems[i].Size == Size)
{
if (--smems[i].RefCnt > 0)
return;
+
(void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH);
+ xf86MsgVerb(X_INFO, 3,
+ "UnMapVidMem: smem_create(%s, 0x%08x, ... "
+ "SM_DETACH)\n", smems[i].name, smems[i].ptr);
(void)smem_remove(smems[i].name);
*smems[i].name = '\0';
smems[i].RefCnt = 0;
return;
}
}
- ErrorF("xf86UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", Base, Size);
+ xf86MsgVerb(X_WARNING, 2,
+ "UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n",
+ Base, Size);
}
-Bool xf86LinearVidMem()
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- return(TRUE);
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = MapVidMem;
+ pVidMem->unmapMem = UnMapVidMem;
+ pVidMem->setWC = 0;
+ pVidMem->undoWC = 0;
+#ifdef HAS_MTRR_SUPPORT
+ if (cleanMTRR()) {
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+ }
+#endif
+ pVidMem->initialised = TRUE;
}
@@ -155,13 +265,442 @@ Bool xf86LinearVidMem()
/* Interrupt Handling section */
/***************************************************************************/
-Bool xf86DisableInterrupts()
+Bool
+xf86DisableInterrupts()
{
return(TRUE);
}
-void xf86EnableInterrupts()
+void
+xf86EnableInterrupts()
+{
+ return;
+}
+
+/***************************************************************************/
+/* I/O Permissions section for PowerPC */
+/***************************************************************************/
+
+#if defined(__powerpc__)
+
+volatile unsigned char *ioBase = MAP_FAILED;
+volatile unsigned char *pciConfBase = MAP_FAILED;
+
+static int IOEnabled;
+
+
+static void
+removeIOSmem(void)
+{
+ smem_create(NULL, (char *) ioBase, 0, SM_DETACH);
+ smem_remove("IOBASE");
+ ioBase = MAP_FAILED;
+}
+
+void
+xf86EnableIO()
{
+ if (IOEnabled++ == 0) {
+ ioBase = (unsigned char *) smem_create("IOBASE",
+ (char *)PHYS_ISA_IO_SPACE, 64*1024, SM_READ|SM_WRITE);
+ if (ioBase == MAP_FAILED) {
+ --IOEnabled;
+ FatalError("xf86EnableIO: Failed to map I/O\n");
+ } else {
+#ifdef DEBUG
+ ErrorF("xf86EnableIO: mapped I/O at vaddr 0x%08x\n",
+ ioBase);
+#endif
+ atexit(removeIOSmem);
+ }
+ }
return;
}
+void
+xf86DisableIO()
+{
+ if (!IOEnabled)
+ return;
+
+ if (--IOEnabled == 0)
+ removeIOSmem();
+ return;
+}
+
+#if 0
+void
+xf86DisableIOPrivs(void)
+{
+ return;
+}
+#endif
+void
+ppcPciIoMap(int bus)
+{
+ xf86EnableIO();
+}
+
+#endif
+
+
+#ifdef HAS_MTRR_SUPPORT
+/* memory range (MTRR) support for LynxOS (taken from BSD MTRR support) */
+
+/*
+ * This code is experimental. Some parts may be overkill, and other parts
+ * may be incomplete.
+ */
+
+/*
+ * getAllRanges returns the full list of memory ranges with attributes set.
+ */
+
+static struct mem_range_desc *
+getAllRanges(int *nmr)
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+
+ /*
+ * Find how many ranges there are. If this fails, then the kernel
+ * probably doesn't have MTRR support.
+ */
+ mro.mo_arg[0] = 0;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro))
+ return NULL;
+ *nmr = mro.mo_arg[0];
+ mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
+ mro.mo_arg[0] = *nmr;
+ mro.mo_desc = mrd;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
+ xfree(mrd);
+ return NULL;
+ }
+ return mrd;
+}
+
+/*
+ * cleanMTRR removes any memory attribute that may be left by a previous
+ * X server. Normally there won't be any, but this takes care of the
+ * case where a server crashed without being able finish cleaning up.
+ */
+
+static Bool
+cleanMTRR()
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+ int nmr, i;
+
+ /* This shouldn't happen */
+ if (devMemFd < 0) {
+ if ((devMemFd = open(MTRR_DEVICE, O_RDONLY)) < 0) {
+perror("open MTRR");
+ return FALSE;
+ }
+ }
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return FALSE;
+
+ for (i = 0; i < nmr; i++) {
+ if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
+ (mrd[i].mr_flags & MDF_ACTIVE)) {
+#ifdef DEBUG
+ ErrorF("Clean for (0x%lx,0x%lx)\n",
+ (unsigned long)mrd[i].mr_base,
+ (unsigned long)mrd[i].mr_len);
+#endif
+ if (mrd[i].mr_flags & MDF_FIXACTIVE) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ mrd[i].mr_flags = MDF_UNCACHEABLE;
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = mrd + i;
+ ioctl(devMemFd, MEMRANGE_SET, &mro);
+ }
+ }
+#ifdef DEBUG
+ sleep(10);
+#endif
+ xfree(mrd);
+ return TRUE;
+}
+
+typedef struct x_RangeRec {
+ struct mem_range_desc mrd;
+ Bool wasWC;
+ struct x_RangeRec * next;
+} RangeRec, *RangePtr;
+
+static void
+freeRangeList(RangePtr range)
+{
+ RangePtr rp;
+
+ while (range) {
+ rp = range;
+ range = rp->next;
+ xfree(rp);
+ }
+}
+
+static RangePtr
+dupRangeList(RangePtr list)
+{
+ RangePtr new = NULL, rp, p;
+
+ rp = list;
+ while (rp) {
+ p = xnfalloc(sizeof(RangeRec));
+ *p = *rp;
+ p->next = new;
+ new = p;
+ rp = rp->next;
+ }
+ return new;
+}
+
+static RangePtr
+sortRangeList(RangePtr list)
+{
+ RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
+ unsigned long minBase;
+
+ /* Sort by base address */
+ rp1 = copy = dupRangeList(list);
+ while (rp1) {
+ minBase = rp1->mrd.mr_base;
+ minp = rp1;
+ minprev = NULL;
+ prev = rp1;
+ rp2 = rp1->next;
+ while (rp2) {
+ if (rp2->mrd.mr_base < minBase) {
+ minBase = rp2->mrd.mr_base;
+ minp = rp2;
+ minprev = prev;
+ }
+ prev = rp2;
+ rp2 = rp2->next;
+ }
+ if (minprev) {
+ minprev->next = minp->next;
+ rp1 = copy;
+ } else {
+ rp1 = minp->next;
+ }
+ minp->next = sorted;
+ sorted = minp;
+ }
+ return sorted;
+}
+
+/*
+ * findRanges returns a list of ranges that overlap the specified range.
+ */
+
+static void
+findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
+{
+ struct mem_range_desc *mrd;
+ int nmr, i;
+ RangePtr rp, *p;
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return;
+
+ for (i = 0; i < nmr; i++) {
+ if ((mrd[i].mr_flags & MDF_ACTIVE) &&
+ mrd[i].mr_base < base + size &&
+ mrd[i].mr_base + mrd[i].mr_len > base) {
+ if (mrd[i].mr_flags & MDF_WRITECOMBINE)
+ p = wcp;
+ else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
+ p = ucp;
+ else
+ continue;
+ rp = xnfalloc(sizeof(RangeRec));
+ rp->mrd = mrd[i];
+ rp->next = *p;
+ *p = rp;
+ }
+ }
+ xfree(mrd);
+}
+
+/*
+ * This checks if the existing overlapping ranges fully cover the requested
+ * range. Is this overkill?
+ */
+
+static Bool
+fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
+{
+ RangePtr rp1, sorted = NULL;
+ unsigned long end;
+
+ sorted = sortRangeList(overlap);
+ /* Look for gaps */
+ rp1 = sorted;
+ end = base + size;
+ while (rp1) {
+ if (rp1->mrd.mr_base > base) {
+ freeRangeList(sorted);
+ return FALSE;
+ } else {
+ base = rp1->mrd.mr_base + rp1->mrd.mr_len;
+ }
+ if (base >= end) {
+ freeRangeList(sorted);
+ return TRUE;
+ }
+ rp1 = rp1->next;
+ }
+ freeRangeList(sorted);
+ return FALSE;
+}
+
+static pointer
+addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /* See of the full range is already WC */
+ if (!uc && fullCoverage(base, size, wc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already set\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_WRITECOMBINE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to set write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n", base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = FALSE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /*
+ * See of the full range is already not WC, or if there is full
+ * coverage from UC ranges.
+ */
+ if (!wc || fullCoverage(base, size, uc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already clear\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_UNCACHEABLE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to remove write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ /* XXX Should then remove all of the overlapping WC ranges */
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Removed Write-combining range (0x%lx,0x%lx)\n",
+ base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = TRUE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ if (enable)
+ return addWC(screenNum, base, size, from);
+ else
+ return delWC(screenNum, base, size, from);
+}
+
+static void
+undoWC(int screenNum, pointer list)
+{
+ RangePtr rp;
+ struct mem_range_op mro;
+ Bool failed;
+
+ rp = list;
+ while (rp) {
+#ifdef DEBUG
+ ErrorF("Undo for (0x%lx,0x%lx), %d\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len, rp->wasWC);
+#endif
+ failed = FALSE;
+ if (rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_WRITECOMBINE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = &rp->mrd;
+
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ if (!rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_UNCACHEABLE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro))
+ failed = TRUE;
+ } else
+ failed = TRUE;
+ }
+ if (failed) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to restore MTRR range (0x%lx,0x%lx)\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len);
+ }
+ rp = rp->next;
+ }
+}
+
+#endif /* HAS_MTRR_SUPPORT */
+
diff --git a/hw/xfree86/os-support/misc/xf86_IlHack.c b/hw/xfree86/os-support/misc/xf86_IlHack.c
index 204fe4717..019156357 100644
--- a/hw/xfree86/os-support/misc/xf86_IlHack.c
+++ b/hw/xfree86/os-support/misc/xf86_IlHack.c
@@ -1,14 +1,15 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c,v 3.4 1996/12/23 06:50:24 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c,v 3.5 1998/07/25 16:56:51 dawes Exp $ */
/*
* This file is an incredible crock to get the normally-inline functions
* built into the server so that things can be debugged properly.
*
* Note: this doesn't work when using a compiler other than GCC.
*/
-/* $Xorg: xf86_IlHack.c,v 1.3 2000/08/17 19:51:25 cpqbld Exp $ */
+/* $XConsortium: xf86_IlHack.c /main/4 1996/02/21 17:52:26 kaleb $ */
#define static /**/
#define __inline__ /**/
#undef NO_INLINE
+#define DO_PROTOTYPES
#include "compiler.h"
diff --git a/hw/xfree86/os-support/misc/xf86_Util.c b/hw/xfree86/os-support/misc/xf86_Util.c
index a68d2ca89..7889617e3 100644
--- a/hw/xfree86/os-support/misc/xf86_Util.c
+++ b/hw/xfree86/os-support/misc/xf86_Util.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c,v 3.4 1996/12/23 06:50:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c,v 3.8 2001/10/28 03:34:02 tsi Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
@@ -21,7 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86_Util.c,v 1.3 2000/08/17 19:51:26 cpqbld Exp $ */
+/* $XConsortium: xf86_Util.c /main/5 1996/10/23 13:13:10 kaleb $ */
/*
* This file is for utility functions that will be shared by other pieces
@@ -31,70 +31,34 @@
#include <ctype.h>
-/*
- * A portable hack at implementing strcasecmp()
- * The characters '_', ' ', and '\t' are ignored in the comparison
- */
-int StrCaseCmp(s1, s2)
-const char *s1, *s2;
-{
- char c1, c2;
-
- if (*s1 == 0)
- if (*s2 == 0)
- return(0);
- else
- return(1);
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper(*s1) ? tolower(*s1) : *s1);
- c2 = (isupper(*s2) ? tolower(*s2) : *s2);
- while (c1 == c2)
- {
- if (c1 == '\0')
- return(0);
- s1++; s2++;
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper(*s1) ? tolower(*s1) : *s1);
- c2 = (isupper(*s2) ? tolower(*s2) : *s2);
- }
- return(c1 - c2);
-}
-
+/* To prevent empty source file warnings */
+int _xf86misc;
+#if 0
/* For use only with gcc */
#ifdef __GNUC__
#include "os.h"
-char *debug_alloca(file, line, size)
-char *file;
-int line;
-int size;
+char *
+debug_alloca(char *file, int line, int size)
{
char *ptr;
- ptr = (char *)Xalloc(size);
+ ptr = Xalloc(size);
ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line,
ptr, size);
return ptr;
}
-void debug_dealloca(file, line, ptr)
-char *file;
-int line;
-char *ptr;
+void
+debug_dealloca(char *file, int line, char *ptr)
{
ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr);
Xfree(ptr);
}
#endif
+#endif
#if defined(ISC) || defined(Lynx)
@@ -103,13 +67,15 @@ char *ptr;
/* Needed for apm_driver.c */
/* These functions are modeled after the functions inside gnu's libc */
-static double copysign(double x, double y)
+static double
+copysign(double x, double y)
{
x = fabs(x);
return y < 0 ? - x : x;
}
-double RInt(double x)
+double
+RInt(double x)
{
double s,t;
const double one = 1.0;
diff --git a/hw/xfree86/os-support/sco/VTsw_sco.c b/hw/xfree86/os-support/sco/VTsw_sco.c
index 386cd21ff..d06bd3949 100644
--- a/hw/xfree86/os-support/sco/VTsw_sco.c
+++ b/hw/xfree86/os-support/sco/VTsw_sco.c
@@ -1,4 +1,4 @@
-/* XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c,v 1.3 2001/06/30 22:41:49 tsi Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
* Copyright 1993 by David McCullough <davidm@stallion.oz.au>
@@ -22,73 +22,93 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: VTsw_sco.c,v 1.3 2000/08/17 19:51:28 cpqbld Exp $ */
+/* $XConsortium: VTsw_sco.c /main/2 1995/11/13 06:08:36 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+/* For the event driver prototypes */
+#include <sys/event.h>
+#include <mouse.h>
+
/*
* Handle the VT-switching interface for SCO
*/
/*
* This function is the signal handler for the VT-switching signal. It
- * is only referenced inside the OS-support layer.
+ * is only referenced inside the OS-support layer. NOTE: we do NOT need
+ * to re-arm the signal here, since we used sigaction() to set the signal
+ * disposition in sco_init.c. If we had used signal(), we would need to
+ * re-arm the signal here. All we need to do now is record the fact that
+ * we got the signal. XFree86 handles the rest.
*/
-void xf86VTRequest(sig)
-int sig;
+void
+xf86VTRequest(int sig)
{
- signal(sig, (void(*)())xf86VTRequest);
- xf86Info.vtRequestsPending = TRUE;
- return;
+ xf86Info.vtRequestsPending = TRUE;
+ return;
}
-Bool xf86VTSwitchPending()
+Bool
+xf86VTSwitchPending()
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
}
-Bool xf86VTSwitchAway()
+/*
+ * When we switch away, we need to flush and suspend the event driver
+ * before the VT_RELDISP. We also need to get the current LED status
+ * and preserve it, so that we can restore it when we come back.
+ */
+static int sco_ledstatus = -1;
+static unsigned int sco_ledstate = 0;
+
+Bool
+xf86VTSwitchAway()
{
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
- {
- return(FALSE);
- }
- else
- {
- return(TRUE);
- }
+ ev_flush();
+ ev_suspend();
+ sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate);
+
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
+ return(FALSE);
+ } else {
+ return(TRUE);
+ }
}
-Bool xf86VTSwitchTo()
+/*
+ * When we come back to the X server, we need to resume the event driver,
+ * and we need to restore the LED settings to what they were when we
+ * switched away.
+ */
+Bool
+xf86VTSwitchTo()
{
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- {
- return(FALSE);
- }
- else
- {
- /*
- * make sure the console driver thinks the console is in
- * graphics mode. Under mono we have to do the two as the
- * console driver only allows valid modes for the current
- * video card and Herc or vga are the only devices currently
- * supported.
- */
- if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0)
- if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0)
- {
- ErrorF("Failed to set graphics mode : %s\n",
- strerror(errno));
- }
+ ev_resume();
+
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
+ return(FALSE);
+ } else {
+ if (sco_ledstatus >= 0) {
+ ioctl (xf86Info.consoleFd, KDSETLED, &sco_ledstate);
+ }
+ sco_ledstatus = -1;
+
+ /*
+ * Convince the console driver this screen is in graphics mode,
+ * otherwise it assumes it can do more to the screen than it should.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
- return(TRUE);
- }
+ return TRUE;
+ }
}
diff --git a/hw/xfree86/os-support/sco/sco_init.c b/hw/xfree86/os-support/sco/sco_init.c
index a61dcdfce..389664647 100644
--- a/hw/xfree86/os-support/sco/sco_init.c
+++ b/hw/xfree86/os-support/sco/sco_init.c
@@ -1,261 +1,324 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c,v 3.10.2.1 1998/02/06 22:36:53 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c,v 3.14 2002/11/20 23:00:44 dawes Exp $ */
/*
- * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
*
* 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 David McCullough and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. David McCullough and
- * David Wexelblat makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH 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.
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
*
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON 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.
*/
-/* $Xorg: sco_init.c,v 1.3 2000/08/17 19:51:28 cpqbld Exp $ */
+/* $XConsortium$ */
+
+/* Re-written May 2001 to represent the current state of reality */
#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"
static Bool KeepTty = FALSE;
static int VTnum = -1;
+static char *vtdevice = NULL;
static int sco_console_mode = -1;
-extern void xf86VTRequest(
-#if NeedFunctionPrototypes
- int
-#endif
-);
+extern Bool mpxLock;
-void xf86OpenConsole()
+void
+xf86OpenConsole()
{
- int fd,wc;
- struct vt_mode VT;
- struct stat status;
- char vtname[11];
-
- if (serverGeneration == 1)
- {
- /* check if we're 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");
- }
-
- /*
- * setup the virtual terminal manager
- *
- * SCO vts start at tty01 which is vt00, if you could call them VT's.
- * We use the numbers 1..X as it fits nicer with the device naming
- * scheme.
- *
- * In os/osinit.c we took the precuation of not closing stdin so that
- * we can use the current vt if no vt was specified on the command line
- *
- * Under SCO VT_OPENQRY does nothing at all
- * if nothing was specified we try to determine the VT from stdin
- */
- if ((VTnum != -1) && (VTnum != 0))
- {
- wc = VTnum - 1;
- }
- else
- {
- if ((fstat(0, &status) >= 0) && (status.st_mode & S_IFCHR))
- {
- wc = minor(status.st_rdev);
- }
- else
- {
- ErrorF("%s: Failed to stat stdin, using tty02 (%s)\n",
- "xf86OpenConsole", strerror(errno));
- wc = 1; /* tty02 */
- }
- }
- ErrorF("(using VT number %d)\n\n", wc + 1);
-
- sprintf(vtname,"/dev/tty%02d", wc+1); /* /dev/tty[01-12] */
-
- if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) < 0)
- {
- FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
- vtname, strerror(errno));
- }
-
- /* now we can dispose of stdin */
-
- if (freopen(vtname, "r+", stdin) == (FILE *) NULL)
- {
- FatalError("xf86OpenConsole: Cannot reopen stdin as %s (%s)\n",
- vtname, strerror(errno));
- }
-
- /* now we can fixup stdout */
-
- if (freopen(vtname, "r+", stdout) == (FILE *) NULL)
- {
- FatalError("xf86OpenConsole: Cannot reopen stdout as %s (%s)\n",
- vtname, strerror(errno));
- }
-
- /* We activate the console just in case its not the one we are on */
- xf86Info.vtno = wc;
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, wc) != 0)
- {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
- }
-
- xf86Config(FALSE); /* Read XF86Config */
-
- if (!KeepTty)
- {
- setpgrp();
- }
-
- /*
- * now get the VT
- */
- if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0)
- {
- FatalError("xf86OpenConsole: VT_GETMODE failed on console (%s)\n",
- strerror(errno));
- }
- if (ioctl(xf86Info.consoleFd, VGA_IOPRIVL, 1) < 0)
- {
- FatalError("xf86OpenConsole: VGA_IOPRIVL failed for VGA acc (%s)\n",
- strerror(errno));
- }
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- {
- FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n",
+ int fd,i, ioctl_ret;
+ struct vt_mode VT;
+ static char vtname[32];
+ struct vid_info vidinf;
+ struct sigaction sigvtsw;
+
+ if (serverGeneration == 1) {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be setuid root\n");
+ }
+
+ /*
+ * Set up the virtual terminal (multiscreen in SCO parlance).
+ * For the actual console itself, screens are numbered from
+ * 1 to (usually) 16. However, it is possible to have a nested
+ * server, and it is also possible to be on a multi-console
+ * system such as MaxSpeed or SunRiver. Therefore, we should
+ * not make any assumptions about the TTY name we are on, and
+ * instead we rely on ttyname() to give us the real TTY name.
+ * Previously, XFree86 tried to determine the TTY name manually.
+ * This is wrong. The only time we need to futz with the TTY name
+ * if if we were given the name of a TTY to run on explicity on
+ * the command line.
+ */
+
+ if (VTnum == -1) {
+ /*
+ * We can query the current VT number using CONS_GETINFO.
+ */
+ char *ttn;
+
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (0, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: Not on a console device "
+ "or error querying device (%s)\n", strerror (errno));
+ }
+
+ VTnum = vidinf.m_num + 1; /* 0-based */
+ ttn = ttyname (0);
+
+ if (ttn == (char *)0) {
+ ErrorF ("xf86OpenConsole: Error determining TTY name (%s)\n",
+ strerror(errno));
+ snprintf (vtname, sizeof(vtname)-1, "/dev/tty%02d", VTnum);
+ } else {
+ strlcpy (vtname, ttn, sizeof(vtname));
+ }
+ vtdevice = vtname;
+ } else if (VTnum == -2 || VTnum >= 0) {
+ /*
+ * An explicit device was specified. Make sure its a console device.
+ */
+ if (VTnum != -2) {
+ snprintf (vtname, sizeof(vtname)-1, "/dev/tty%02d", VTnum);
+ vtdevice = vtname;
+ }
+
+ fd = open (vtdevice, O_RDWR | O_NDELAY, 0);
+ if (fd < 0) {
+ FatalError ("xf86OpenConsole: Can not open device '%s' (%s)\n",
+ vtdevice, strerror(errno));
+ }
+
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (fd, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: '%s' is not a console device "
+ "or error querying device (%s)\n", vtname, strerror (errno));
+ }
+ VTnum = vidinf.m_num + 1; /* 0-based */
+ close (fd); /* We're done with it for now */
+ }
+
+ ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
+
+ if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n", vtdevice,
strerror(errno));
- }
-
- signal(SIGUSR1, xf86VTRequest);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGUSR1;
- VT.waitv = 0;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
- }
- /*
- * make sure the console driver thinks the console is in graphics
- * mode. Under mono we have to do the two as the console driver only
- * allows valid modes for the current video card and Herc or vga are
- * the only devices currently supported.
- */
- if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0)
- if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0)
- {
- ErrorF("Failed to set graphics mode (%s)\n",
- strerror(errno));
- }
+ }
+ /* Dispose of stdin and stdout */
+ if (freopen(vtdevice, "r+", stdin) == (FILE *) NULL) {
+ FatalError("xf86OpenConsole: Cannot reopen stdin as %s (%s)\n",
+ vtdevice, strerror(errno));
}
- else
- {
- /* serverGeneration != 1 */
- /*
- * now get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
- }
+
+ if (freopen(vtname, "r+", stdout) == (FILE *) NULL) {
+ FatalError("xf86OpenConsole: Cannot reopen stdout as %s (%s)\n",
+ vtdevice, strerror(errno));
}
- return;
-}
-void xf86CloseConsole()
-{
- struct vt_mode VT;
+ /*
+ * We make 100% sure we use the correct VT number. This can get ugly
+ * where there are multi-consoles in use, so we make sure we query
+ * the kernel for the correct VT number. It knows best, we don't.
+ */
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: Failed to query console number (%s)\n",
+ strerror (errno));
+ }
+ xf86Info.vtno = vidinf.m_num;
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- if (sco_console_mode != -1)
- {
- ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
+ /* We activate the console just in case its not the one we are on */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
}
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+
+ /* Disassociate from controling TTY */
+ if (!KeepTty) {
+ setpgrp();
+ }
+
+ /*
+ * Now we get the current mode that the console device is on. We will
+ * use this later when we close the console device to restore it to
+ * that same mode.
+ */
+ if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
+ FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
+ strerror(errno));
}
- close(xf86Info.consoleFd); /* make the vt-manager happy */
- return;
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
+ }
+
+ sigvtsw.sa_handler = xf86VTRequest;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ /* NOTE: Using sigaction means we dont have to re-arm the signal */
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT; /* Not implemented */
+ VT.waitv = 0;
+
+ /*
+ * The SCO X server tries the following call 5 times. Lets do the same
+ * thing. It shouldn't really be required but sometimes things take a
+ * while to settle down when switching screens. *helpless shrug* I know
+ * its sucks but ...
+ */
+
+ ioctl_ret = 0;
+ for (i = 0; i < 5; i++) {
+ ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ if (ioctl_ret >= 0)
+ break;
+ usleep(999999); /* Dont use nap() - it forces linking with -lx */
+ }
+
+ if (ioctl_ret < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
+ }
+
+ /*
+ * Convince the console driver we are in graphics mode.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+ } else { /* serverGeneration != 1 */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+ }
}
-int xf86ProcessArgument(argc, argv, i)
-int argc;
-char *argv[];
-int i;
+/*
+ * Restore the console to its previous state. This may cause flicker if
+ * the screen was previous in a graphics mode, because we first set it
+ * to text mode. This has the advantage of getting the console driver
+ * to do a soft reset on the card, which really does help settle the
+ * video card down again after coming out of Xfree86.
+ */
+void
+xf86CloseConsole()
{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return(1);
- }
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
- {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- return(1);
- }
- if (!strcmp(argv[i], "-crt"))
- {
- if ((++i > argc) ||
- (sscanf(argv[i], "/dev/tty%2d", &VTnum) == 0))
- {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- else
- {
- return(2);
- }
- }
- return(0);
+ struct vt_mode VT;
+ struct sigaction sigvtsw;
+
+ /* Set text mode (possibly briefly) */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
+
+ /* Restore the original mode */
+ if (sco_console_mode != -1) {
+ ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
+ }
+
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
+
+ sigvtsw.sa_handler = SIG_DFL;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_AUTO;
+ VT.waitv = 0;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
+
+ close(xf86Info.consoleFd); /* We're done with the device */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals).
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return(1);
+ }
+
+ /*
+ * By default, the X server wants to bind itself to CPU 0. This makes
+ * sure that the server has full access to the I/O ports at IOPL 3.
+ * Some SMP systems have trouble with I/O on CPU's other than 0. If,
+ * however, you have a system that is well behaved, you can specify
+ * this argument and let the scheduler decide which CPU the server
+ * should run on.
+ */
+ if (!strcmp(argv[i], "-nompxlock")) {
+ mpxLock = FALSE;
+ return (1);
+ }
+
+ /*
+ * Specify the VT number to run on (NOT the device).
+ */
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ if (VTnum <= 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+
+ /*
+ * Use a device the user specifies.
+ */
+ if (!strcmp(argv[i], "-crt")) {
+ if (++i > argc) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ } else {
+ VTnum = -2;
+ vtdevice = argv[i];
+ return(2);
+ }
+ }
+ return(0);
}
-void xf86UseMsg()
+void
+xf86UseMsg()
{
ErrorF("vtXX use the specified VT number\n");
- ErrorF("-crt /dev/ttyXX use the specified VT number\n");
+ ErrorF("-crt DEVICE use the specified VT device\n");
+ ErrorF("-nompxlock dont bind X server to CPU 0\n");
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
- return;
}
diff --git a/hw/xfree86/os-support/sco/sco_io.c b/hw/xfree86/os-support/sco/sco_io.c
index 162d1b76b..a018e3434 100644
--- a/hw/xfree86/os-support/sco/sco_io.c
+++ b/hw/xfree86/os-support/sco/sco_io.c
@@ -1,117 +1,273 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c,v 3.3 1996/12/23 06:50:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c,v 3.10 2003/02/17 15:11:59 dawes Exp $ */
/*
- * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
- * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
*
* 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 David McCullough and David Dawes
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. David McCullough
- * and David Dawes makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID MCCULLOUGH AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID DAWES 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.
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
*
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON 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.
*/
-/* $Xorg: sco_io.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
+/* $XConsortium$ */
+
+/* Re-written May 2001 to represent the current state of reality */
-#define NEED_EVENTS
#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
#include "compiler.h"
-#include "xf86Procs.h"
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
-void xf86SoundKbdBell(loudness, pitch, duration)
-int loudness;
-int pitch;
-int duration;
+#include <sys/param.h>
+#include <sys/emap.h>
+#include <sys/nmap.h>
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch) {
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
+ usleep(duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ /*
+ * sleep the first time through under SCO. There appears to be a
+ * timing problem in the driver which causes the keyboard to be lost.
+ * This usleep stops it from occurring. NOTE: this was in the old code.
+ * I am not convinced it is true any longer, but it doesn't hurt to
+ * leave this in here.
+ */
+ static int once = 1;
+
+ if (once) {
+ usleep(100);
+ once = 0;
+ }
+
+ ioctl(xf86Info.consoleFd, KDSETLED, leds );
+}
+
+int
+xf86GetKbdLeds()
{
- if (loudness && pitch)
- {
- ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
- usleep(duration * loudness * 20);
- ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
- }
+ int leds;
+
+ ioctl (xf86Info.consoleFd, KDGETLED, &leds);
+ return leds;
+}
+
+/*
+ * Much of the code in this function is duplicated from the Linux code
+ * by Orest Zborowski <obz@Kodak.com> and David Dawes <dawes@xfree86.org>.
+ * Please see the file ../linux/lnx_io.c for full copyright information.
+ *
+ * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A
+ * and later have the required ioctl. 5.0.6A or higher is HIGHLY
+ * recommended. The console driver is quite a different beast on that OS.
+ */
+void
+xf86SetKbdRepeat(char rad)
+{
+#if defined(KBIO_SETRATE)
+ int i;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+ int delay = 250; /* Default delay */
+ int rate = 300; /* Default repeat rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate * 10;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ ioctl (xf86Info.consoleFd, KBIO_SETRATE, value);
+#endif /* defined(KBIO_SETRATE) */
}
-void xf86SetKbdLeds(leds)
-int leds;
+static Bool use_tcs = TRUE, use_kd = TRUE;
+static Bool no_nmap = TRUE, no_emap = TRUE;
+static int orig_getsc, orig_kbm;
+static struct termios orig_termios;
+static keymap_t keymap, noledmap;
+static uchar_t *sc_mapbuf;
+static uchar_t *sc_mapbuf2;
+
+void
+xf86KbdInit()
{
- /*
- * sleep the first time through under SCO. There appears to be a
- * timing problem in the driver which causes the keyboard to be lost.
- * This sleep stops it from occurring. The sleep could proably be
- * a lot shorter as even trace can fix the problem. You may
- * prefer a usleep(100).
- */
- static int once = 1;
-
- if (once)
- {
- sleep(1);
- once = 0;
- }
- ioctl(xf86Info.consoleFd, KDSETLED, leds );
+ orig_getsc = 0;
+ if (ioctl (xf86Info.consoleFd, TCGETSC, &orig_getsc) < 0)
+ use_tcs = FALSE;
+ if (ioctl (xf86Info.consoleFd, KDGKBMODE, &orig_kbm) < 0)
+ use_kd = FALSE;
+
+ if (!use_tcs && !use_kd)
+ FatalError ("xf86KbdInit: Could not determine keyboard mode\n");
+
+ /*
+ * One day this should be fixed to translate normal ASCII characters
+ * back into scancodes or into events that XFree86 wants, but not
+ * now. For the time being, we only support scancode mode screens.
+ */
+ if (use_tcs && !(orig_getsc & KB_ISSCANCODE))
+ FatalError ("xf86KbdInit: Keyboard can not send scancodes\n");
+
+ /*
+ * We need to get the original keyboard map and NUL out the lock
+ * modifiers. This prevents the scancode API from messing with
+ * the keyboard LED's. We restore the original map when we exit.
+ */
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &keymap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ }
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &noledmap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ } else {
+ int i, j;
+
+ for (i = 0; i < noledmap.n_keys; i++) {
+ for (j = 0; j < NUM_STATES; j++) {
+ if (IS_SPECIAL(noledmap, i, j) &&
+ ((noledmap.key[i].map[j] == K_CLK) ||
+ (noledmap.key[i].map[j] == K_NLK) ||
+ (noledmap.key[i].map[j] == K_SLK))) {
+ noledmap.key[i].map[j] = K_NOP;
+ }
+ }
+ }
+ }
+
+ if (ioctl (xf86Info.consoleFd, XCGETA, &orig_termios) < 0) {
+ FatalError ("xf86KbdInit: Failed to get terminal modes (%s)\n",
+ strerror(errno));
+ }
+
+ sc_mapbuf = xalloc (10*BSIZE);
+ sc_mapbuf2 = xalloc(10*BSIZE);
+
+ /* Get the emap */
+ if (ioctl (xf86Info.consoleFd, LDGMAP, sc_mapbuf) < 0) {
+ if (errno != ENAVAIL) {
+ FatalError ("xf86KbdInit: Failed to retrieve e-map (%s)\n",
+ strerror (errno));
+ }
+ no_emap = FALSE;
+ }
+
+ /* Get the nmap */
+ if (ioctl (xf86Info.consoleFd, NMGMAP, sc_mapbuf2) < 0) {
+ if (errno != ENAVAIL) {
+ FatalError ("xf86KbdInit: Failed to retrieve n-map (%s)\n",
+ strerror (errno));
+ }
+ no_nmap = FALSE;
+ }
}
-void xf86MouseInit(mouse)
-MouseDevPtr mouse;
+int
+xf86KbdOn()
{
- if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0)
- {
- if (xf86AllowMouseOpenFail) {
- ErrorF("Cannot open mouse (%s) - Continuing...\n",
- strerror(errno));
- return;
- }
- FatalError("Cannot open mouse (%s)\n", strerror(errno));
- }
+ struct termios newtio;
+
+ ioctl (xf86Info.consoleFd, LDNMAP); /* Turn e-mapping off */
+ ioctl (xf86Info.consoleFd, NMNMAP); /* Turn n-mapping off */
+
+ newtio = orig_termios; /* structure copy */
+ newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CREAD | CS8 | B9600;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME]=0;
+ newtio.c_cc[VMIN]=1;
+ cfsetispeed(&newtio, 9600);
+ cfsetospeed(&newtio, 9600);
+ ioctl(xf86Info.consoleFd, XCSETA, &newtio);
+
+ /* Now tell the keyboard driver to send us raw scancodes */
+ if (use_tcs) {
+ int nm = orig_getsc;
+ nm &= ~KB_XSCANCODE;
+ ioctl (xf86Info.consoleFd, TCSETSC, &nm);
+ }
+
+ if (use_kd)
+ ioctl (xf86Info.consoleFd, KDSKBMODE, K_RAW);
+
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &noledmap);
+
+ return(xf86Info.consoleFd);
}
-int xf86MouseOn(mouse)
-MouseDevPtr mouse;
+int
+xf86KbdOff()
{
- xf86SetupMouse(mouse);
+ /* Revert back to original translate scancode mode */
+ if (use_tcs)
+ ioctl (xf86Info.consoleFd, TCSETSC, &orig_getsc);
+ if (use_kd)
+ ioctl (xf86Info.consoleFd, KDSKBMODE, orig_kbm);
+
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &keymap);
- /* Flush any pending input */
- ioctl(mouse->mseFd, TCFLSH, 0);
+ if (no_emap)
+ ioctl (xf86Info.consoleFd, LDSMAP, sc_mapbuf);
+ if (no_nmap)
+ ioctl (xf86Info.consoleFd, NMSMAP, sc_mapbuf2);
- return(mouse->mseFd);
+ ioctl(xf86Info.consoleFd, XCSETA, &orig_termios);
+
+ return(xf86Info.consoleFd);
}
-int xf86MouseOff(mouse, doclose)
-MouseDevPtr mouse;
-Bool doclose;
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
{
- if (mouse->mseFd >= 0)
- {
- if (mouse->mseType == P_LOGI)
- {
- write(mouse->mseFd, "U", 1);
- xf86SetMouseSpeed(mouse, mouse->baudRate,
- mouse->oldBaudRate,
- xf86MouseCflags[P_LOGI]);
- }
- if (doclose)
- {
- close(mouse->mseFd);
- }
- }
- return(mouse->mseFd);
+ return FALSE;
}
diff --git a/hw/xfree86/os-support/sco/sco_mouse.c b/hw/xfree86/os-support/sco/sco_mouse.c
index 564852ae3..37b9eb5a8 100644
--- a/hw/xfree86/os-support/sco/sco_mouse.c
+++ b/hw/xfree86/os-support/sco/sco_mouse.c
@@ -1,175 +1,265 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c,v 3.8 1996/12/23 06:50:50 dawes Exp $ */
-
-
-
-
-
-/* $Xorg: sco_mouse.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c,v 3.13 2002/11/20 23:07:50 dawes Exp $ */
+/*
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
+ *
+ * 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 name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON 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$ */
-#define NEED_EVENTS
#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
-#include "xf86Procs.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "mipointer.h"
+#include <sys/event.h>
+#include <mouse.h>
-/******************************************************************************/
-#ifdef USE_OSMOUSE
-/******************************************************************************/
+static int
+SupportedInterfaces (void)
+{
+ /* FIXME: Is this correct? Should we just return MSE_MISC? */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_MISC | MSE_AUTO;
+}
-#include <sys/event.h>
-#include <mouse.h>
-#include "xf86_Config.h"
+static const char *internalNames[] = {
+ "OSMouse",
+ NULL
+};
-static dmask_t real_mask = (dmask_t) (D_REL | D_BUTTON);
-static int config_buttons = 0;
+static const char **
+BuiltinNames (void)
+{
+ return internalNames;
+}
-extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
- unsigned long start, unsigned long stop,
- ScreenPtr pScreen);
+static Bool
+CheckProtocol (const char *protocol)
+{
+ int i;
-/******************************************************************************/
-/*
- * Handle any XF86Config options for "OsMouse", How you treat errors
- * is up to you, they may or may not be Fatal
- */
+ for (i = 0; internalNames[i]; i++) {
+ if (xf86NameCmp (protocol, internalNames[i]) == 0)
+ return TRUE;
+ }
-void
-xf86OsMouseOption(lt, lp)
- int lt; /* type returned by gettoken */
- pointer lp; /* The lexical return symbol */
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol (void)
{
- if (lt != NUMBER) {
- ErrorF("%s: Invalid Argument to OsMouse, %s\n",
- "xf86OsMouseOption", "Number of buttons expected");
- return;
- }
- config_buttons = ((LexPtr)lp)->num;
+ return "OSMouse";
}
-/******************************************************************************/
-/*
- * xf86OsMouseProc --
- * Handle the initialization, etc. of a mouse
- */
+static const char *
+evtErrStr (int evterr)
+{
+ switch (evterr) {
+ case -1: return "error in config files";
+ case -2: return "no mouse devices to attach";
+ case -3: return "unable to open device";
+ case -4: return "unable to open event queue";
+ case -999: return "unable to initialize event driver";
+ default: return "unknown event driver error";
+ }
+}
-int
-xf86OsMouseProc(pPointer, what)
- DeviceIntPtr pPointer;
- int what;
+static int
+OsMouseProc (DeviceIntPtr pPointer, int what)
{
- unchar *map;
- int i, err, buttons;
- struct devinfo *dip;
- dmask_t dmask;
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unsigned char map[9];
+ dmask_t dmask;
+ MessageType from = X_CONFIG;
+ int evi;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
switch (what) {
- case DEVICE_INIT:
-
- pPointer->public.on = FALSE;
-
- if (ev_init() < 0)
- ErrorF("ev_init: Failed to initialize event driver\n");
-
- dmask = real_mask;
- xf86Info.mouseDev->mseFd = ev_open(&dmask);
- switch (xf86Info.mouseDev->mseFd) {
- case -1: FatalError("ev_open: Error in Configuration files\n");
- case -2: FatalError("ev_open: No mouse devices to attach\n");
- case -3: FatalError("ev_open: Unable to open a found device\n");
- case -4: FatalError("ev_open: unable to open an event queue\n");
- default:
- if (xf86Info.mouseDev->mseFd < 0)
- FatalError("ev_open: Failed to open device, reason unkown\n");
- break;
- }
- if (dmask != real_mask)
- FatalError("Could not attach the mouse device (0x%x)\n", dmask);
-
- dip = (struct devinfo *) NULL;
- if ((dip = ev_getdev(D_REL, dip)) == (struct devinfo *) NULL)
- FatalError("Could not find info on mouse device\n");
-
- buttons = config_buttons > 0 ? config_buttons : ((int) dip->buttons);
- buttons = buttons > 0 ? buttons : 3; /* just in case */
-
- ErrorF("%s OsMouse has %d buttons\n",
- buttons == config_buttons ? XCONFIG_GIVEN : XCONFIG_PROBED,
- buttons);
-
- map = (unchar *) xalloc(buttons + 1);
- if (map == (unchar *) NULL)
- FatalError("Failed to allocate OsMouse map structure\n");
-
- for (i = 1; i <= buttons; i++)
- map[i] = i;
-
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- buttons,
- miPointerGetMotionEvents,
- (PtrCtrlProcPtr)xf86MseCtrl,
- 0);
- xfree(map);
- ev_suspend(); /* suspend device until its turned on */
- break;
-
- case DEVICE_ON:
- ev_resume();
- AddEnabledDevice(xf86Info.mouseDev->mseFd);
- xf86Info.mouseDev->lastButtons = 0;
- xf86Info.mouseDev->emulateState = 0;
- pPointer->public.on = TRUE;
- break;
-
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- pPointer->public.on = FALSE;
- RemoveEnabledDevice(xf86Info.mouseDev->mseFd);
- if (what == DEVICE_CLOSE) {
- ev_close();
- xf86Info.mouseDev->mseFd = -1;
- } else
- ev_suspend();
- break;
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ dmask = D_REL | D_BUTTON;
+ if ((evi = ev_init()) < 0) {
+ FatalError ("OsMouseProc: Event driver initialization failed (%s)\n",
+ evtErrStr(evi));
}
-
+ pInfo->fd = ev_open (&dmask);
+ if (pInfo->fd < 0) {
+ FatalError ("OsMouseProc: DEVICE_INIT failed (%s)\n", evtErrStr(pInfo->fd));
+ }
+
+ pMse->buttons = xf86SetIntOption (pInfo->options, "Buttons", 0);
+ if (pMse->buttons == 0) {
+ pMse->buttons = 8;
+ from = X_DEFAULT;
+ }
+ xf86Msg (from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons);
+
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ map[4] = 6;
+ map[5] = 7;
+ map[6] = 8;
+ map[7] = 4;
+ map[8] = 5; /* Compatibile with SCO X server */
+
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, 8,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+
+ xf86MotionHistoryAllocate(pInfo);
+
+ ev_flush();
+ ev_suspend();
+ break;
+
+ case DEVICE_ON:
+ pMse->lastButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ ev_resume();
+ AddEnabledDevice (pInfo->fd);
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ pPointer->public.on = TRUE;
+ RemoveEnabledDevice (pInfo->fd);
+ if (what == DEVICE_CLOSE) {
+ ev_close();
+ pInfo->fd = -1;
+ } else {
+ ev_suspend();
+ }
+ break;
+ }
+
return Success;
}
-/******************************************************************************/
-/*
- * xf86OsMouseEvents --
- * Get some events from our queue. Process all outstanding events now.
- */
+static void
+OsMouseReadInput (InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ EVENT *evp;
+
+ pMse = pInfo->private;
+
+ while ((evp = ev_read()) != (EVENT *)0) {
+ int buttons = EV_BUTTONS(*evp);
+ int dx = EV_DX(*evp), dy = -(EV_DY(*evp)), dz = 0, dw = 0;
+
+ if (EV_TAG(*evp) & T_WHEEL) {
+ dz = (dy & 0x08) ? (dy & 0x0f) - 16 : (dy & 0x0f);
+ dx = dy = 0;
+ pMse->PostEvent (pInfo, buttons, dx, dy, dz, dw);
+ /* Simulate button release */
+ dz = 0;
+ buttons &= ~(WHEEL_FWD | WHEEL_BACK);
+ }
+
+ pMse->PostEvent (pInfo, buttons, dx, dy, dz, dw);
+ ev_pop();
+ }
+}
-void
-xf86OsMouseEvents()
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
{
- EVENT *evp;
- static long time = -1;
-
- while ((evp = ev_read()) != (EVENT *) NULL ) {
-#if DEBUG
- if (time == -1)
- time = EV_TIME(*evp);
- ErrorF("sco_event time(%ld) tag(%d) butts(%d) x(%ld) y(%ld)\n",
- EV_TIME(*evp) - time, EV_TAG(*evp), EV_BUTTONS(*evp),
- EV_DX(*evp), EV_DY(*evp));
-#endif
- xf86PostMseEvent(xf86Info.pMouse,EV_BUTTONS(*evp), EV_DX(*evp), -(EV_DY(*evp)));
- ev_pop();
- }
-
- xf86Info.inputPending = TRUE;
+ MouseDevPtr pMse;
+
+ /* This is called when the protocol is "OSMouse". */
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = ev_init();
+ if (pInfo->fd != -1) {
+ dmask_t dmask = (D_REL | D_BUTTON);
+ pInfo->fd = ev_open(&dmask);
+ } else {
+ pInfo->fd = -999;
+ }
+
+ if (pInfo->fd < 0) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open event manager (%s)\n",
+ pInfo->name, evtErrStr(pInfo->fd));
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open event manager (%s)\n",
+ pInfo->name, evtErrStr(pInfo->fd));
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ ev_close();
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = OsMouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
}
-/******************************************************************************/
-#endif /* USE_OSMOUSE */
-/******************************************************************************/
+OSMouseInfoPtr
+xf86OSMouseInit (int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+
+ return p;
+}
diff --git a/hw/xfree86/os-support/sco/sco_video.c b/hw/xfree86/os-support/sco/sco_video.c
index 14947fa85..eb4b80c48 100644
--- a/hw/xfree86/os-support/sco/sco_video.c
+++ b/hw/xfree86/os-support/sco/sco_video.c
@@ -1,29 +1,41 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c,v 3.2.2.1 1997/07/19 04:59:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c,v 3.8 2002/06/03 21:22:10 dawes Exp $ */
/*
- * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
*
* 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 David McCullough and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. David McCullough and
- * David Wexelblat makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
*
- * DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH 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.
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON 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$ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+/*
+ * This file contains the completely re-written SCO OpenServer video
+ * routines for XFree86 4.x. Much of this is based on the SCO X server
+ * code (which is an X11R5 server) and will probably only work on
+ * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com)
+ * email if you have any questions.
*
+ * Ideally, you should use OSR5.0.6A or later, with the updated console
+ * driver for 5.0.6A (its the default driver in 5.0.7 and later).
+ * However, if you are running on an older system, this code will detect
+ * that and adjust accordingly.
*/
-/* $Xorg: sco_video.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
#include "X.h"
#include "input.h"
@@ -32,253 +44,248 @@
#define _NEED_SYSI86
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86OSpriv.h"
#include "xf86_OSlib.h"
+#include <sys/ci/ciioctl.h>
+#define MPXNAME "/dev/atp1"
+#define BASECPU 1
+
+Bool mpxLock = TRUE;
+
+#define USE_VASMETHOD 1
+
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
-static struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS];
-static int ver_once = 1;
+static int sco_mcdone = 0, sco_ismc = 0;
/***************************************************************************/
/*
- * To map the video-memory, we use the MAP_CLASS ioctl.
- * Different drivers may have to do another one of these
- * for their own special registers (ie., ATI). To find
- * out which strings are valid look in /etc/conf/pack.d/cn/class.h
+ * To map the video memory, we first need to see if we are on a multi-console
+ * system. If we are, we need to try to use an existing video class in the
+ * kernel. We do this by retrieving the list of currently defined classes
+ * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will
+ * match the range of memory we desire. If we can't find one, we have an
+ * error and we abort.
*
- * if we fail to find one of these we try for the dmmap driver
+ * If we are not using a multi-console, we can simply use mmap() to map in
+ * the frame buffer, using the classs-access method as a fall-back only if
+ * the mmap() fails (it shouldn't). We always set the appropriate pointers
+ * in the config structure to point ot the right function to map and unmap
+ * the video memory. An alternative to using mmap() is to use the new
+ * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel
+ * to map the physical address to a virtual one, which it then returns.
+ * I am not 100% sure if this is faster or not, but it may prove easier to
+ * debug things. Just to be on the safe side, I have included both methods
+ * here, and the mmap() method can be used by setting USE_VASMETHOD to 0
+ * above.
*/
-struct {
- unsigned long base, size;
- char *class;
-} SCO_Mapping[] = {
- {0xA0000, 0x10000, "VGA"},
- {0xA0000, 0x20000, "SVGA"},
- {0xB0000, 0x08000, "HGA"},
- {0x0, 0x0, ""},
-};
+#if !defined(CONS_ADDVAS)
+# undef USE_VASMETHOD
+# define USE_VASMETHOD 0
+#endif
-/* ARGSUSED */
-pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static int
+scoIsMultiConsole (void)
{
- int i;
- char *class = (char *)NULL;
- pointer base;
-
- for (i=0; SCO_Mapping[i].base != 0; i++)
- {
- if (((pointer)SCO_Mapping[i].base == Base) &&
- (SCO_Mapping[i].size == Size))
- {
- class = SCO_Mapping[i].class;
- break;
- }
- }
- if (class == (char *)NULL)
- {
- int fd;
-
-#if defined(SVR4) || defined(SCO325)
- if ((fd = open(DEV_MEM, O_RDWR)) < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
- MAP_SHARED, fd, (off_t)Base);
- close(fd);
- if ((long)base == -1)
- {
- FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", Size, Base, strerror(errno));
- }
-
- return(base);
-#else
- MapDSC[ScreenNum][Region].vaddr = (char *) NULL;
- MapDSC[ScreenNum][Region].physaddr = (char *) Base;
- MapDSC[ScreenNum][Region].length = Size;
- MapDSC[ScreenNum][Region].ioflg = 1;
- if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) {
- if (ioctl(fd, KDMAPDISP, &MapDSC[ScreenNum][Region]) == -1)
- ErrorF("xf86MapVidMem: dmmap KDMAPDISP failed (%s)\n",
- strerror(errno));
- else {
- if (ver_once)
- ErrorF("Using dmmap version 0x%04x.\n",
- ioctl(fd, -1));
- ver_once = 0;
- close(fd);
- return(MapDSC[ScreenNum][Region].vaddr);
- }
- close(fd);
- }
- FatalError("xf86MapVidMem:No class map defined for (%x,%x)\n",
- Base, Size);
- /* NOTREACHED */
-#endif
- }
-
- base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class);
- if ((int)base == -1)
- {
- FatalError("xf86MapVidMem:Failed to map video mem class %s\n",
- class);
- /* NOTREACHED */
- }
- return(base);
+ int x;
+
+ if (sco_mcdone)
+ return sco_ismc;
+ x = access ("/usr/lib/vidconf/.multiconsole", F_OK);
+ if (x == 0)
+ sco_ismc = 1;
+ sco_mcdone = 1;
+ return sco_ismc;
}
/*
- * Nothing to do here if it wasn't mapped using the dmmap driver
+ * This maps memory using mmap()
*/
-/* ARGSUSED */
-void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static pointer
+mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- int fd;
-
-#if defined (SVR4) || defined(SCO325)
- munmap(Base, Size);
-#else /* SVR4 */
- if (MapDSC[ScreenNum][Region].vaddr) {
- if ((fd = open("/dev/dmmap", O_RDWR)) < 0) {
- if (ioctl(fd, KDUNMAPDISP, &MapDSC[ScreenNum][Region]) == -1)
- ErrorF("xf86UnMapVidMem: dmmap KDUNMAPDISP failed (%s)\n",
- strerror(errno));
- close(fd);
- }
- MapDSC[ScreenNum][Region].vaddr = (char *) NULL;
- MapDSC[ScreenNum][Region].physaddr = (char *) NULL;
- MapDSC[ScreenNum][Region].length = 0;
- MapDSC[ScreenNum][Region].ioflg = 0;
- }
+ int fd;
+ unsigned long realBase, alignOff;
+ pointer base;
+
+ fd = open (DEV_MEM, O_RDWR);
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM,
+ strerror(errno));
+ return 0; /* NOTREACHED */
+ }
+
+ realBase = Base & ~(getpagesize() - 1);
+ alignOff = Base - realBase;
+
+#ifdef DEBUG
+ ErrorF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff);
#endif
- return;
-}
-
-/* ARGSUSED */
-Bool xf86LinearVidMem()
-{
- int fd, ver;
-#if defined(SVR4) || defined(SCO325)
- return TRUE;
-#else
- if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) {
- ver = ioctl(fd, -1);
- close(fd);
- if (ver >= 0) {
- if (ver_once)
- ErrorF("Using dmmap version 0x%04x.\n", ver);
- ver_once = 0;
- return(TRUE);
- }
- }
- return(FALSE);
+ base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, (off_t)realBase);
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n",
+ Base, Size, strerror(errno));
+ return 0; /* NOTREACHED */
+ }
+
+#ifdef DEBUG
+ ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff);
#endif
+ return (pointer)((char *)base + alignOff);
}
-/***************************************************************************/
-/* I/O Permissions section */
-/***************************************************************************/
+#if (USE_VASMETHOD)
+/*
+ * This maps memory using the virtual address space (VAS) console calls.
+ */
+static pointer
+mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct vidvasmem vas;
+ pointer base;
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool IOEnabled = FALSE;
-static Bool InitDone = FALSE;
+ vas.base = (long)Base;
+ vas.size = (long)Size;
-void xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
-{
- int i;
-
- if (!InitDone)
- {
- for (i = 0; i < MAXSCREENS; i++)
- ScreenEnabled[i] = FALSE;
- InitDone = TRUE;
- }
+ base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas);
+ if (base == (pointer)-1) {
+ return mapVidMemMMAP(ScreenNum, Base, Size, flags);
+ }
+ return base;
}
+#endif /* USE_VASMETHOD */
+
+struct vidclass vidclasslist[] = {
+ { "VBE", "", 0xf0000000, 0x2000000, 0 },
+ { "P9000", "", 0xc0000000, 0x400000, 0 },
+ { "TULIP", "", 0x80000000, 0x400000, 0 },
+ { "VIPER", "", 0xa0000000, 0x400000, 0 },
+ { "S3T", "", 0xa0000000, 0x200000, 0 },
+ { "S3DT", "", 0x4000000, 0x400000, 0 },
+ { "MGA", "", 0x2200000, 0x4000, 0 },
+ { "CLVGA", "", 0xa0000, 0x20000, 0 },
+ { "OLIVE", "", 0xd8000000, 0x400000, 0 },
+ { "S3C", "", 0xa0000, 0x10000, 0 },
+ { "MGAVLB", "", 0xac000, 0x34000, 0 },
+ { "ATI8514", "", 0xFF000, 0x1000, 0 },
+ { "GXREGS", "", 0xb0000, 0x10000, 0 },
+ { "GX", "", 0xa0000, 0x10000, 0 },
+ { "CT64300", "", 0xa0000000, 0x400000, 0 },
+ { "SVGA", "", 0xa0000, 0x20000, 0 },
+ { "S3V", "", 0xa0000000, 0x400000, 0 },
+ { "8514A", "", 0xFF000, 0x1000, 0 },
+ { "VGA", "", 0xa0000, 0x10000, 0 },
+ { 0 }
+};
-/* ARGSUSED */
-void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
+static pointer
+mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
+ struct vidclass *vcp;
+ char *class = NULL;
+ pointer base;
+
+ for (vcp = vidclasslist; vcp->name; vcp++) {
+ if ((vcp->base == Base) && (vcp->size == Size)) {
+ class = vcp->name;
+ break;
+ }
+ }
+
+ if (class == NULL) {
+ /*
+ * As a fall-back, we will try and use the mmap() approach. This may
+ * prove to be the wrong thing to do, but time and testing will tell.
+ */
+ ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size);
+#if USE_VASMETHOD
+ return mapVidMemVAS(ScreenNum, Base, Size, flags);
+#else /* !USE_VASMETHOD */
+ return mapVidMemMMAP(ScreenNum, Base, Size, flags);
+#endif
+ }
+
+ /*
+ * We found a suitable class. Try and use it.
+ */
+ base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class);
+ if ((int)base == -1) {
+ FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class);
+ return 0; /* NOTREACHED */
+ }
+
+ return base;
}
-void xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- ScreenEnabled[ScreenNum] = TRUE;
-
- if (IOEnabled)
- return;
-
- if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
- FatalError("Failed to set IOPL for extended I/O\n");
- IOEnabled = TRUE;
- return;
-}
+/*
+ * Unmapping the video memory is easy. We always call munmap(), as it is
+ * safe to do so even if we haven't actually mapped in any pages via mmap().
+ * In the case where we used the video class, we don't need to do anything
+ * as the kernel will clean up the TSS when we exit, and will undo the
+ * vasbind() that was done when the class was originally mapped. If we used
+ * vasmap, we simply undo the map. Again, it is benign to call vasunmap
+ * even if we got the frame buffer via some other mechanism (like mmap).
+ */
-void xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- int i;
+#if USE_VASMETHOD
+ struct vidvasmem vas;
+ int x;
- ScreenEnabled[ScreenNum] = FALSE;
+ vas.base = (long)Base;
+ vas.size = (long)Size;
- if (!IOEnabled)
- return;
+ x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas);
+ if (x == 0)
+ return;
+#endif /* USE_VASMETHOD */
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
- sysi86(SI86V86, V86SC_IOPL, 0);
- IOEnabled = FALSE;
- return;
+ munmap(Base, Size);
}
-void xf86DisableIOPrivs()
+/*
+ * Set things up to point to our local functions. When the kernel gets
+ * MTRR support, we will need to add the required functions for that
+ * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0.
+ *
+ * We also want to lock the X server process to the base CPU in an MPX
+ * system, since we will be going to IOPL 3. Most engine drivers can cope
+ * with I/O access on any CPU but there are a few (AST Manhattan I believe)
+ * that can't, so the server needs to be locked to CPU0.
+ */
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- if (IOEnabled)
- sysi86(SI86V86, V86SC_IOPL, 0);
- return;
-}
+ int mpx_fd;
-/***************************************************************************/
-/* Interrupt Handling section */
-/***************************************************************************/
-
-Bool xf86DisableInterrupts()
-{
-#ifdef __GNUC__
- __asm__ __volatile__("cli");
-#else
- asm("cli");
-#endif /* __GNUC__ */
-
- return(TRUE);
+ if (scoIsMultiConsole ()) {
+ pVidMem->mapMem = mapVidMemVC;
+ } else {
+#if USE_VASMETHOD
+ pVidMem->mapMem = mapVidMemVAS;
+#else
+ pVidMem->mapMem = mapVidMemMMAP;
+#endif
+ }
+
+ pVidMem->unmapMem = unmapVidMem;
+ pVidMem->linearSupported = TRUE;
+ pVidMem->initialised = TRUE;
+
+ if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) {
+ if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0)
+ ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n",
+ strerror(errno));
+ close (mpx_fd);
+ }
}
-void xf86EnableInterrupts()
-{
-#ifdef __GNUC__
- __asm__ __volatile__("sti");
-#else
- asm("sti");
-#endif /* __GNUC__ */
-
- return;
-}
diff --git a/hw/xfree86/os-support/shared/VTsw_noop.c b/hw/xfree86/os-support/shared/VTsw_noop.c
index 960ca9935..265a45f91 100644
--- a/hw/xfree86/os-support/shared/VTsw_noop.c
+++ b/hw/xfree86/os-support/shared/VTsw_noop.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c,v 3.1 1996/12/23 06:50:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c,v 3.2 1998/07/25 16:56:59 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
@@ -21,11 +21,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: VTsw_noop.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
+/* $XConsortium: VTsw_noop.c /main/3 1996/02/21 17:53:25 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
@@ -35,17 +33,20 @@
* No-op functions for OSs without VTs
*/
-Bool xf86VTSwitchPending()
+Bool
+xf86VTSwitchPending()
{
return(FALSE);
}
-Bool xf86VTSwitchAway()
+Bool
+xf86VTSwitchAway()
{
return(FALSE);
}
-Bool xf86VTSwitchTo()
+Bool
+xf86VTSwitchTo()
{
return(TRUE);
}
diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c
index 47c4c5f9d..81aac54de 100644
--- a/hw/xfree86/os-support/shared/VTsw_usl.c
+++ b/hw/xfree86/os-support/shared/VTsw_usl.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.1 1996/12/23 06:50:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.4 2002/09/16 18:06:14 eich Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
@@ -21,11 +21,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: VTsw_usl.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
+/* $XConsortium: VTsw_usl.c /main/3 1996/02/21 17:53:28 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
@@ -40,20 +38,22 @@
* 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)
{
- signal(sig, (void(*)())xf86VTRequest);
+ signal(sig, (void(*)(int))xf86VTRequest);
xf86Info.vtRequestsPending = TRUE;
return;
}
-Bool xf86VTSwitchPending()
+Bool
+xf86VTSwitchPending()
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
}
-Bool xf86VTSwitchAway()
+Bool
+xf86VTSwitchAway()
{
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
@@ -66,7 +66,8 @@ Bool xf86VTSwitchAway()
}
}
-Bool xf86VTSwitchTo()
+Bool
+xf86VTSwitchTo()
{
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
diff --git a/hw/xfree86/os-support/shared/bios_devmem.c b/hw/xfree86/os-support/shared/bios_devmem.c
index f26d7a524..5c24b9751 100644
--- a/hw/xfree86/os-support/shared/bios_devmem.c
+++ b/hw/xfree86/os-support/shared/bios_devmem.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.3 1996/12/23 06:50:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.7 2000/09/19 12:46:22 eich Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
@@ -21,12 +21,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: bios_devmem.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
+/* $XConsortium: bios_devmem.c /main/5 1996/10/19 18:07:41 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
-
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
@@ -40,100 +37,37 @@
# define DEV_MEM "/dev/mem"
#endif
-int xf86ReadBIOS(Base, Offset, Buf, Len)
-unsigned long Base;
-unsigned long Offset;
-unsigned char *Buf;
-int Len;
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
{
-#ifdef __alpha__
- /*
- * The Alpha version uses "mmap" instead of "lseek/read",
- * because these (currently) don't work for BUS memory.
- * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
- * which is the KSEG address of the start of the DENSE memory
- * area.
- */
-
- /*
- * NOTE: there prolly ought to be more validity checks and all
- * re: boundaries and sizes and such...
- */
-
-/*
- * The Jensen lacks dense memory, thus we have to address the bus via
- * the sparse addressing scheme.
- *
- * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
- */
+ int fd;
-#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
-#define SPARSE (5)
-#define isJensen (1)
+#ifdef __ia64__
+ if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
#else
-#define isJensen (!_bus_base())
-#define SPARSE (7)
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
#endif
-
-extern unsigned long _bus_base(void);
-extern unsigned long _bus_base_sparse(void);
-#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base())
-#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x)
-
-#define SIZE (64*1024)
-
- caddr_t base;
- int fd;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
- {
- ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM,
- strerror(errno));
- return(-1);
- }
-
- base = mmap((caddr_t)0, JENSEN_SHIFT(SIZE), PROT_READ,
- MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE));
-
- if (base == (caddr_t)-1UL)
- {
- ErrorF("xf86ReadBios: Failed to mmap %s (%s)\n", DEV_MEM,
- strerror(errno));
- return(-1);
- }
-
- SlowBCopyFromBus(base+JENSEN_SHIFT(Offset), Buf, Len);
-
- munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(SIZE));
- close(fd);
- return(Len);
-
-#else /* __alpha__ */
-
- int fd;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
{
- ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM,
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
return(-1);
}
if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
{
- ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM,
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
+ DEV_MEM, strerror(errno));
close(fd);
return(-1);
}
if (read(fd, Buf, Len) != Len)
{
- ErrorF("xf86ReadBios: %s read failed (%s)\n", DEV_MEM,
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
+ DEV_MEM, strerror(errno));
close(fd);
return(-1);
}
close(fd);
return(Len);
-#endif /* __alpha__ */
}
diff --git a/hw/xfree86/os-support/shared/ioperm_noop.c b/hw/xfree86/os-support/shared/ioperm_noop.c
index 4451d6f38..c24f4f1b2 100644
--- a/hw/xfree86/os-support/shared/ioperm_noop.c
+++ b/hw/xfree86/os-support/shared/ioperm_noop.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.1 1996/12/23 06:50:59 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.4 2001/07/23 13:15:48 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
@@ -21,40 +21,27 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: ioperm_noop.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
+/* $XConsortium: ioperm_noop.c /main/3 1996/02/21 17:53:39 kaleb $ */
/*
- * Amoeba, Minix and 386BSD don't bother with I/O permissions,
+ * Some platforms don't bother with I/O permissions,
* or the permissions are implicit with opening/enabling the console.
*/
-void xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
-{
- return;
-}
-/* ARGSUSED */
-void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
-{
- return;
-}
+#include "X.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
-void xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
+void
+xf86EnableIO()
{
return;
}
-void xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
+void
+xf86DisableIO()
{
return;
}
-void xf86DisableIOPrivs()
-{
- return;
-}
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index 8e92511d3..a4f487025 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
+++ b/hw/xfree86/os-support/shared/posix_tty.c
@@ -1,174 +1,690 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.8.2.1 1998/02/07 14:27:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.28 2003/02/17 15:11:59 dawes Exp $ */
/*
- * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ * Copyright 1993-1999 by The XFree86 Project, Inc.
*
- * 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 name of David Dawes
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission.
- * David Dawes makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
*
- * DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL DAVID DAWES 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.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
*
*/
-/* $Xorg: posix_tty.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
-#define NEED_EVENTS
-#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
+/* $XConsortium: posix_tty.c /main/7 1996/10/19 18:07:47 kaleb $ */
-#include "xf86Procs.h"
+#include "X.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
-
-static Bool not_a_tty = FALSE;
-
-void xf86SetMouseSpeed(mouse, old, new, cflag)
-MouseDevPtr mouse;
-int old;
-int new;
-unsigned cflag;
-{
- struct termios tty;
- char *c;
-
- if (not_a_tty)
- return;
-
- if (tcgetattr(mouse->mseFd, &tty) < 0)
- {
- not_a_tty = TRUE;
- ErrorF("Warning: %s unable to get status of mouse fd (%s)\n",
- mouse->mseDevice, strerror(errno));
- return;
- }
-
- /* this will query the initial baudrate only once */
- if (mouse->oldBaudRate < 0) {
- switch (cfgetispeed(&tty))
- {
- case B9600:
- mouse->oldBaudRate = 9600;
- break;
- case B4800:
- mouse->oldBaudRate = 4800;
- break;
- case B2400:
- mouse->oldBaudRate = 2400;
- break;
- case B1200:
- default:
- mouse->oldBaudRate = 1200;
- break;
- }
- }
-
- tty.c_iflag = IGNBRK | IGNPAR;
- tty.c_oflag = 0;
- tty.c_lflag = 0;
- tty.c_cflag = (tcflag_t)cflag;
- tty.c_cc[VTIME] = 0;
- tty.c_cc[VMIN] = 1;
-
- switch (old)
- {
- case 9600:
- cfsetispeed(&tty, B9600);
- cfsetospeed(&tty, B9600);
- break;
- case 4800:
- cfsetispeed(&tty, B4800);
- cfsetospeed(&tty, B4800);
- break;
- case 2400:
- cfsetispeed(&tty, B2400);
- cfsetospeed(&tty, B2400);
- break;
- case 1200:
- default:
- cfsetispeed(&tty, B1200);
- cfsetospeed(&tty, B1200);
- }
-
- if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
- {
- if (xf86AllowMouseOpenFail) {
- ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
- strerror(errno));
- return;
+
+static int
+GetBaud (int baudrate)
+{
+#ifdef B300
+ if (baudrate == 300)
+ return B300;
+#endif
+#ifdef B1200
+ if (baudrate == 1200)
+ return B1200;
+#endif
+#ifdef B2400
+ if (baudrate == 2400)
+ return B2400;
+#endif
+#ifdef B4800
+ if (baudrate == 4800)
+ return B4800;
+#endif
+#ifdef B9600
+ if (baudrate == 9600)
+ return B9600;
+#endif
+#ifdef B19200
+ if (baudrate == 19200)
+ return B19200;
+#endif
+#ifdef B38400
+ if (baudrate == 38400)
+ return B38400;
+#endif
+#ifdef B57600
+ if (baudrate == 57600)
+ return B57600;
+#endif
+#ifdef B115200
+ if (baudrate == 115200)
+ return B115200;
+#endif
+#ifdef B230400
+ if (baudrate == 230400)
+ return B230400;
+#endif
+#ifdef B460800
+ if (baudrate == 460800)
+ return B460800;
+#endif
+ return (0);
+}
+
+int
+xf86OpenSerial (pointer options)
+{
+#ifdef Lynx
+ struct sgttyb ms_sgtty;
+#endif
+ struct termios t;
+ int fd, i;
+ char *dev;
+
+ dev = xf86SetStrOption (options, "Device", NULL);
+ if (!dev)
+ {
+ xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
+ return (-1);
+ }
+
+#ifndef Lynx
+ SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK | O_EXCL));
+#else
+ /* O_EXCL yields an EEXIST on LynxOS */
+ SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
+#endif
+ if (fd == -1)
+ {
+ xf86Msg (X_ERROR,
+ "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
+ dev, strerror (errno));
+ xfree(dev);
+ return (-1);
+ }
+
+ if (!isatty (fd))
+ {
+#if 1
+ /* Allow non-tty devices to be opened. */
+ xfree(dev);
+ return (fd);
+#else
+ xf86Msg (X_WARNING,
+ "xf86OpenSerial: Specified device %s is not a tty\n",
+ dev);
+ SYSCALL (close (fd));
+ errno = EINVAL;
+ xfree(dev);
+ return (-1);
+#endif
+ }
+
+#ifdef Lynx
+ /* LynxOS does not assert DTR without this */
+ ioctl (fd, TIOCGETP, (char *) &ms_sgtty);
+ ioctl (fd, TIOCSDTR, (char *) &ms_sgtty);
+#endif
+
+ /* set up default port parameters */
+ SYSCALL (tcgetattr (fd, &t));
+ t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\
+ |IGNCR|ICRNL|IXON);
+ t.c_oflag &= ~OPOST;
+ t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ t.c_cflag &= ~(CSIZE|PARENB);
+ t.c_cflag |= CS8|CLOCAL;
+
+ cfsetispeed (&t, B9600);
+ cfsetospeed (&t, B9600);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+
+ SYSCALL (tcsetattr (fd, TCSANOW, &t));
+
+ if (xf86SetSerial (fd, options) == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+
+ SYSCALL (i = fcntl (fd, F_GETFL, 0));
+ if (i == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+ i &= ~O_NONBLOCK;
+ SYSCALL (i = fcntl (fd, F_SETFL, i));
+ if (i == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+ xfree(dev);
+ return (fd);
+}
+
+int
+xf86SetSerial (int fd, pointer options)
+{
+ struct termios t;
+ int val;
+ const char *s;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL (tcgetattr (fd, &t));
+
+ if ((val = xf86SetIntOption (options, "BaudRate", 0)))
+ {
+ if ((baud = GetBaud (val)))
+ {
+ cfsetispeed (&t, baud);
+ cfsetospeed (&t, baud);
+ }
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option BaudRate value: %d\n", val);
+ return (-1);
+ }
+ }
+
+ if ((val = xf86SetIntOption (options, "StopBits", 0)))
+ {
+ switch (val)
+ {
+ case 1:
+ t.c_cflag &= ~(CSTOPB);
+ break;
+ case 2:
+ t.c_cflag |= CSTOPB;
+ break;
+ default:
+ xf86Msg (X_ERROR,
+ "Invalid Option StopBits value: %d\n", val);
+ return (-1);
+ break;
+ }
+ }
+
+ if ((val = xf86SetIntOption (options, "DataBits", 0)))
+ {
+ switch (val)
+ {
+ case 5:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS5;
+ break;
+ case 6:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS6;
+ break;
+ case 7:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS7;
+ break;
+ case 8:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS8;
+ break;
+ default:
+ xf86Msg (X_ERROR,
+ "Invalid Option DataBits value: %d\n", val);
+ return (-1);
+ break;
+ }
+ }
+
+ if ((s = xf86SetStrOption (options, "Parity", NULL)))
+ {
+ if (xf86NameCmp (s, "Odd") == 0)
+ {
+ t.c_cflag |= PARENB | PARODD;
+ }
+ else if (xf86NameCmp (s, "Even") == 0)
+ {
+ t.c_cflag |= PARENB;
+ t.c_cflag &= ~(PARODD);
}
- xf86FatalError("Unable to set status of mouse fd (%s)\n",
- strerror(errno));
- }
-
- switch (new)
- {
- case 9600:
- c = "*q";
- cfsetispeed(&tty, B9600);
- cfsetospeed(&tty, B9600);
- break;
- case 4800:
- c = "*p";
- cfsetispeed(&tty, B4800);
- cfsetospeed(&tty, B4800);
- break;
- case 2400:
- c = "*o";
- cfsetispeed(&tty, B2400);
- cfsetospeed(&tty, B2400);
- break;
- case 1200:
- default:
- c = "*n";
- cfsetispeed(&tty, B1200);
- cfsetospeed(&tty, B1200);
- }
-
- if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI)
- {
- if (write(mouse->mseFd, c, 2) != 2)
+ else if (xf86NameCmp (s, "None") == 0)
{
- if (xf86AllowMouseOpenFail) {
- ErrorF("Unable to write to mouse fd (%s) - Continuing...\n",
- strerror(errno));
- return;
- }
- xf86FatalError("Unable to write to mouse fd (%s)\n",
- strerror(errno));
+ t.c_cflag &= ~(PARENB);
+ }
+ else
+ {
+ xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n",
+ s);
+ return (-1);
}
}
- usleep(100000);
- if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
+ if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1)
+ {
+ t.c_cc[VMIN] = val;
+ }
+ if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1)
{
- if (xf86AllowMouseOpenFail) {
- ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
- strerror(errno));
- return;
+ t.c_cc[VTIME] = val;
+ }
+
+ if ((s = xf86SetStrOption (options, "FlowControl", NULL)))
+ {
+ xf86MarkOptionUsedByName (options, "FlowControl");
+ if (xf86NameCmp (s, "Xoff") == 0)
+ {
+ t.c_iflag |= IXOFF;
+ }
+ else if (xf86NameCmp (s, "Xon") == 0)
+ {
+ t.c_iflag |= IXON;
+ }
+ else if (xf86NameCmp (s, "XonXoff") == 0)
+ {
+ t.c_iflag |= IXON|IXOFF;
+ }
+ else if (xf86NameCmp (s, "None") == 0)
+ {
+ t.c_iflag &= ~(IXON | IXOFF);
}
- xf86FatalError("Unable to set status of mouse fd (%s)\n",
- strerror(errno));
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option FlowControl value: %s\n", s);
+ return (-1);
+ }
+ }
+
+ if ((xf86SetBoolOption (options, "ClearDTR", FALSE)))
+ {
+#ifdef CLEARDTR_SUPPORT
+# if !defined(Lynx) || defined(TIOCMBIC)
+ val = TIOCM_DTR;
+ SYSCALL (ioctl(fd, TIOCMBIC, &val));
+# else
+ SYSCALL (ioctl(fd, TIOCCDTR, NULL));
+# endif
+#else
+ xf86Msg (X_WARNING,
+ "Option ClearDTR not supported on this OS\n");
+ return (-1);
+#endif
+ xf86MarkOptionUsedByName (options, "ClearDTR");
+ }
+
+ if ((xf86SetBoolOption (options, "ClearRTS", FALSE)))
+ {
+#ifdef CLEARRTS_SUPPORT
+ val = TIOCM_RTS;
+ SYSCALL (ioctl(fd, TIOCMBIC, &val));
+#else
+ xf86Msg (X_WARNING,
+ "Option ClearRTS not supported on this OS\n");
+ return (-1);
+#endif
+ xf86MarkOptionUsedByName (options, "ClearRTS");
}
+
+ SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
+ return (r);
+}
+
+int
+xf86SetSerialSpeed (int fd, int speed)
+{
+ struct termios t;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL (tcgetattr (fd, &t));
+
+ if ((baud = GetBaud (speed)))
+ {
+ cfsetispeed (&t, baud);
+ cfsetospeed (&t, baud);
+ }
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option BaudRate value: %d\n", speed);
+ return (-1);
+ }
+
+ SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
+ return (r);
+}
+
+int
+xf86ReadSerial (int fd, void *buf, int count)
+{
+ int r;
+#ifdef DEBUG
+ int i;
+#endif
+ SYSCALL (r = read (fd, buf, count));
+#ifdef DEBUG
+ ErrorF("ReadingSerial: 0x%x",
+ (unsigned char)*(((unsigned char *)buf)));
+ for (i = 1; i < r; i++)
+ ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
+ ErrorF("\n");
+#endif
+ return (r);
+}
+
+int
+xf86WriteSerial (int fd, const void *buf, int count)
+{
+ int r;
+#ifdef DEBUG
+ int i;
+
+ ErrorF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf)));
+ for (i = 1; i < count; i++)
+ ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
+ ErrorF("\n");
+#endif
+ SYSCALL (r = write (fd, buf, count));
+ return (r);
+}
+
+int
+xf86CloseSerial (int fd)
+{
+ int r;
+
+ SYSCALL (r = close (fd));
+ return (r);
+}
+
+int
+xf86WaitForInput (int fd, int timeout)
+{
+ fd_set readfds;
+ struct timeval to;
+ int r;
+
+ FD_ZERO(&readfds);
+
+ if (fd >= 0) {
+ FD_SET(fd, &readfds);
+ }
+
+ to.tv_sec = timeout / 1000000;
+ to.tv_usec = timeout % 1000000;
+
+ if (fd >= 0) {
+ SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to));
+ }
+ else {
+ SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to));
+ }
+ xf86ErrorFVerb (9,"select returned %d\n", r);
+ return (r);
+}
+
+int
+xf86SerialSendBreak (int fd, int duration)
+{
+ int r;
+
+ SYSCALL (r = tcsendbreak (fd, duration));
+ return (r);
+
+}
+
+int
+xf86FlushInput(int fd)
+{
+ fd_set fds;
+ struct timeval timeout;
+ char c[4];
+
+#ifdef DEBUG
+ ErrorF("FlushingSerial\n");
+#endif
+ if (tcflush(fd, TCIFLUSH) == 0)
+ return 0;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
+ if (read(fd, &c, sizeof(c)) < 1)
+ return 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ }
+ return 0;
+}
+
+static struct states {
+ int xf;
+ int os;
+} modemStates[] = {
+#ifdef TIOCM_LE
+ { XF86_M_LE, TIOCM_LE },
+#endif
+#ifdef TIOCM_DTR
+ { XF86_M_DTR, TIOCM_DTR },
+#endif
+#ifdef TIOCM_RTS
+ { XF86_M_RTS, TIOCM_RTS },
+#endif
+#ifdef TIOCM_ST
+ { XF86_M_ST, TIOCM_ST },
+#endif
+#ifdef TIOCM_SR
+ { XF86_M_SR, TIOCM_SR },
+#endif
+#ifdef TIOCM_CTS
+ { XF86_M_CTS, TIOCM_CTS },
+#endif
+#ifdef TIOCM_CAR
+ { XF86_M_CAR, TIOCM_CAR },
+#elif defined(TIOCM_CD)
+ { XF86_M_CAR, TIOCM_CD },
+#endif
+#ifdef TIOCM_RNG
+ { XF86_M_RNG, TIOCM_RNG },
+#elif defined(TIOCM_RI)
+ { XF86_M_CAR, TIOCM_RI },
+#endif
+#ifdef TIOCM_DSR
+ { XF86_M_DSR, TIOCM_DSR },
+#endif
+};
+
+static int numStates = sizeof(modemStates) / sizeof(modemStates[0]);
+
+static int
+xf2osState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].xf)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int
+os2xfState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].os)
+ ret |= modemStates[i].xf;
+ return ret;
+}
+
+static int
+getOsStateMask(void)
+{
+ int i;
+ int ret = 0;
+ for (i = 0; i < numStates; i++)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int osStateMask = 0;
+
+int
+xf86SetSerialModemState(int fd, int state)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ if (!osStateMask)
+ osStateMask = getOsStateMask();
+
+ state = xf2osState(state);
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ s &= ~osStateMask;
+ s |= state;
+ SYSCALL((ret = ioctl(fd, TIOCMSET, &s)));
+ if (ret < 0)
+ return -1;
+ else
+ return 0;
+#endif
+}
+
+int
+xf86GetSerialModemState(int fd)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ return os2xfState(s);
+#endif
}
int
-xf86FlushInput(fd)
-int fd;
+xf86SerialModemSetBits(int fd, int bits)
{
- return tcflush(fd, TCIFLUSH);
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIS, &s)));
+ return ret;
+#endif
}
+int
+xf86SerialModemClearBits(int fd, int bits)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIC, &s)));
+ return ret;
+#endif
+}
diff --git a/hw/xfree86/os-support/shared/std_kbdEv.c b/hw/xfree86/os-support/shared/std_kbdEv.c
index bca8061db..329346910 100644
--- a/hw/xfree86/os-support/shared/std_kbdEv.c
+++ b/hw/xfree86/os-support/shared/std_kbdEv.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.1 1996/12/23 06:51:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.3 1999/05/07 02:56:23 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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,18 +23,15 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: std_kbdEv.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
+/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
-#define NEED_EVENTS
#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-void xf86KbdEvents()
+void
+xf86KbdEvents()
{
unsigned char rBuf[64];
int nBytes, i;
diff --git a/hw/xfree86/os-support/shared/sysv_kbd.c b/hw/xfree86/os-support/shared/sysv_kbd.c
index 2270be9f1..1bb2da386 100644
--- a/hw/xfree86/os-support/shared/sysv_kbd.c
+++ b/hw/xfree86/os-support/shared/sysv_kbd.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c,v 3.2 1996/12/23 06:51:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c,v 3.4 1999/01/14 13:05:11 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Dawes <dawes@XFree86.org>
@@ -23,20 +23,18 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: sysv_kbd.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
+/* $XConsortium: sysv_kbd.c /main/3 1996/02/21 17:53:59 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"
-int xf86GetKbdLeds()
+int
+xf86GetKbdLeds()
{
int leds;
@@ -44,12 +42,8 @@ int xf86GetKbdLeds()
return(leds);
}
-#if NeedFunctionPrototypes
-void xf86SetKbdRepeat(char rad)
-#else
-void xf86SetKbdRepeat(rad)
-char rad;
-#endif
+void
+xf86SetKbdRepeat(char rad)
{
#ifdef KDSETRAD
ioctl(xf86Info.consoleFd, KDSETRAD, rad);
@@ -60,14 +54,15 @@ static int kbdtrans;
static struct termio kbdtty;
static char *kbdemap = NULL;
-void xf86KbdInit()
+void
+xf86KbdInit()
{
#ifdef KDGKBMODE
ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
#endif
ioctl (xf86Info.consoleFd, TCGETA, &kbdtty);
#if defined(E_TABSZ) && !defined(SCO325)
- kbdemap = (char *)xalloc(E_TABSZ);
+ kbdemap = xalloc(E_TABSZ);
if (ioctl(xf86Info.consoleFd, LDGMAP, kbdemap) < 0)
{
xfree(kbdemap);
@@ -76,7 +71,8 @@ void xf86KbdInit()
#endif
}
-int xf86KbdOn()
+int
+xf86KbdOn()
{
struct termio nTty;
@@ -93,7 +89,8 @@ int xf86KbdOn()
return(xf86Info.consoleFd);
}
-int xf86KbdOff()
+int
+xf86KbdOff()
{
if (kbdemap)
{
diff --git a/hw/xfree86/os-support/sysv/sysv_init.c b/hw/xfree86/os-support/sysv/sysv_init.c
index a253ab0b0..1e9166712 100644
--- a/hw/xfree86/os-support/sysv/sysv_init.c
+++ b/hw/xfree86/os-support/sysv/sysv_init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c,v 3.4.2.1 1998/02/06 22:36:54 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c,v 3.5 1998/07/25 16:57:08 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,17 +23,15 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: sysv_init.c,v 1.3 2000/08/17 19:51:32 cpqbld Exp $ */
+/* $XConsortium: sysv_init.c /main/4 1996/02/21 17:54:31 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"
static Bool KeepTty = FALSE;
@@ -42,27 +40,21 @@ static Bool Protect0 = FALSE;
#endif
static int VTnum = -1;
-extern void xf86VTRequest(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-void xf86OpenConsole()
+void
+xf86OpenConsole()
{
int fd;
struct vt_mode VT;
char vtname1[10],vtname2[10];
+ MessageType from = X_PROBED;
if (serverGeneration == 1)
{
/* check if we're 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");
}
#ifdef SVR4
@@ -74,16 +66,18 @@ void xf86OpenConsole()
if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
{
- ErrorF("xf86OpenConsole: cannot open /dev/zero (%s)\n",
- strerror(errno));
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
}
else
{
if ((int)mmap(0, 0x1000, PROT_NONE,
MAP_FIXED | MAP_SHARED, fd, 0) == -1)
{
- ErrorF("xf86OpenConsole: failed to protect page 0 (%s)\n",
- strerror(errno));
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
}
close(fd);
}
@@ -95,6 +89,7 @@ void xf86OpenConsole()
if (VTnum != -1)
{
xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
}
else
{
@@ -111,13 +106,11 @@ void xf86OpenConsole()
}
close(fd);
}
- ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */
sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
- xf86Config(FALSE); /* Read XF86Config */
-
if (!KeepTty)
{
setpgrp();
@@ -141,11 +134,11 @@ void xf86OpenConsole()
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
{
@@ -174,24 +167,25 @@ void xf86OpenConsole()
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
- ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
}
/*
* If the server doesn't have the VT when the reset occurs,
* this is to make sure we don't continue until the activate
* signal is received.
*/
- if (!xf86VTSema)
+ if (!xf86Screens[0]->vtSema)
sleep(5);
}
return;
}
-void xf86CloseConsole()
+void
+xf86CloseConsole()
{
struct vt_mode VT;
@@ -209,10 +203,8 @@ void xf86CloseConsole()
return;
}
-int xf86ProcessArgument(argc, argv, i)
-int argc;
-char *argv[];
-int i;
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
{
/*
* Keep server from detaching from controlling tty. This is useful
@@ -248,7 +240,8 @@ int i;
return(0);
}
-void xf86UseMsg()
+void
+xf86UseMsg()
{
ErrorF("vtXX use the specified VT number\n");
ErrorF("-keeptty ");
diff --git a/hw/xfree86/os-support/sysv/sysv_io.c b/hw/xfree86/os-support/sysv/sysv_io.c
index 150290c40..d48efd76e 100644
--- a/hw/xfree86/os-support/sysv/sysv_io.c
+++ b/hw/xfree86/os-support/sysv/sysv_io.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c,v 3.4 1996/12/23 06:51:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c,v 3.11 2003/02/17 15:12:00 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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,23 +23,18 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: sysv_io.c,v 1.3 2000/08/17 19:51:32 cpqbld Exp $ */
+/* $XConsortium: sysv_io.c /main/8 1996/10/19 18:08:06 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;
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
{
if (loudness && pitch)
{
@@ -60,8 +55,8 @@ int duration;
}
}
-void xf86SetKbdLeds(leds)
-int leds;
+void
+xf86SetKbdLeds(int leds)
{
#ifdef KBIO_SETMODE
ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT);
@@ -70,29 +65,10 @@ int leds;
#endif
}
-void xf86MouseInit(mouse)
-MouseDevPtr mouse;
-{
- return;
-}
+#include "xf86OSKbd.h"
-int xf86MouseOn(mouse)
-MouseDevPtr mouse;
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
{
- 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));
- }
-
- xf86SetupMouse(mouse);
-
- /* Flush any pending input */
- ioctl(mouse->mseFd, TCFLSH, 0);
-
- return(mouse->mseFd);
+ return FALSE;
}
diff --git a/hw/xfree86/os-support/sysv/sysv_video.c b/hw/xfree86/os-support/sysv/sysv_video.c
index 7dd1575fc..ab604e95a 100644
--- a/hw/xfree86/os-support/sysv/sysv_video.c
+++ b/hw/xfree86/os-support/sysv/sysv_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.9 1996/12/23 06:51:27 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.20 2000/10/28 01:42:29 mvojkovi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -23,16 +23,19 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: sysv_video.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */
+/* $XConsortium: sysv_video.c /main/8 1996/10/25 11:38:09 kaleb $ */
#include "X.h"
-#include "input.h"
-#include "scrnintstr.h"
#define _NEED_SYSI86
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
#ifndef SI86IOPL
#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
@@ -46,53 +49,96 @@
/* Video Memory Mapping section */
/***************************************************************************/
-struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS];
-pointer AllocAddress[MAXSCREENS][NUM_REGIONS];
-#ifndef SVR4
-static int mmapFd = -2;
-#endif
-#if 0
-/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
-#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV)
-static struct xf86memMap {
- int offset;
- int memSize;
-} xf86memMaps[MAXSCREENS];
+/*
+ * XXX Support for SVR3 will need to be reworked if needed. In particular
+ * the Region parameter is no longer passed, and will need to be dealt
+ * with internally if required.
+ * OK, i'll rework that thing ... (clean it up a lot)
+ * SVR3 Support only with SVR3_MMAPDRV (mr)
+ *
+ */
+
+#ifdef HAS_SVR3_MMAPDRV
+#ifndef MMAP_DEBUG
+#define MMAP_DEBUG 3
#endif
+
+struct kd_memloc MapDSC;
+int mmapFd = -2;
+
+static int
+mmapStat(pointer Base, unsigned long Size) {
+
+ int nmmreg,i=0,region=-1;
+ mmapinfo_t *ibuf;
+
+ nmmreg = ioctl(mmapFd, GETNMMREG);
+
+ if(nmmreg <= 0)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "\nNo physical memory mapped currently.\n\n");
+ else {
+ if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL)
+ xf86Msg(X_WARNING,
+ "Couldn't allocate memory 4 mmapinfo_t\n");
+ else {
+ if(ioctl(mmapFd, GETMMREG, ibuf) != -1)
+ {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# mmapStat: [Size=%x,Base=%x]\n", Size, Base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# Physical Address Size Reference Count\n");
+ for(i = 0; i < nmmreg; i++) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "%-4d 0x%08X %5dk %5d ",
+ i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt);
+ if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!");
+ if (region==-1) region=i;
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ free(ibuf);
+ }
+ }
+ if (region == -1 && nmmreg > 0) region=region * i;
+ return(region);
+}
#endif
-Bool xf86LinearVidMem()
+
+static Bool
+linearVidMem()
{
#ifdef SVR4
return TRUE;
-#else
-#ifdef HAS_SVR3_MMAPDRV
- if(mmapFd >= 0)
- {
- return TRUE;
- }
+#elif defined(HAS_SVR3_MMAPDRV)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86LinearVidMem: MMAP 2.2.2 called\n");
+
+ if(mmapFd >= 0) return TRUE;
+
if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
{
if(ioctl(mmapFd, GETVERSION) < 0x0222) {
- ErrorF("xf86LinearVidMem: MMAP 2.2.2 or above required\n");
- ErrorF(" linear memory access disabled\n");
+ xf86Msg(X_WARNING,
+ "xf86LinearVidMem: MMAP 2.2.2 or above required\n");
+ xf86ErrorF("\tlinear memory access disabled\n");
return FALSE;
}
return TRUE;
}
- ErrorF("xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
- strerror(errno));
- ErrorF(" linear memory access disabled\n");
-#endif
+ xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
+ strerror(errno));
+ xf86ErrorF("\tlinear memory access disabled\n");
return FALSE;
#endif
}
-pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
pointer base;
int fd;
@@ -103,47 +149,40 @@ unsigned long Size;
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
DEV_MEM, strerror(errno));
}
- base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
- MAP_SHARED, fd, (off_t)Base);
+ base = mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, (off_t)Base);
close(fd);
- if ((long)base == -1)
+ if (base == MAP_FAILED)
{
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
"xf86MapVidMem", Size, Base, strerror(errno));
}
#else /* SVR4 */
#ifdef HAS_SVR3_MMAPDRV
- if (mmapFd == -2)
- {
- mmapFd = open("/dev/mmap", O_RDWR);
- }
-#endif
- if (mmapFd >= 0)
- {
- /* To force the MMAP driver to provide the address */
- base = (pointer)0;
- }
- else
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n");
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ if (ioctl(mmapFd, GETVERSION) == -1)
{
- AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000);
- if (AllocAddress[ScreenNum][Region] == (pointer)0)
- {
- FatalError("xf86MapVidMem: can't alloc framebuffer space\n");
- /* NOTREACHED */
- }
- base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region]
- & ~0xFFF) + 0x1000);
+ xf86LinearVidMem();
}
- MapDSC[ScreenNum][Region].vaddr = (char *)base;
- MapDSC[ScreenNum][Region].physaddr = (char *)Base;
- MapDSC[ScreenNum][Region].length = Size;
- MapDSC[ScreenNum][Region].ioflg = 1;
-
-#ifdef HAS_SVR3_MMAPDRV
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: Screen: %d\n", ScreenNum);
+ mmapStat(Base,Size);
+ /* To force the MMAP driver to provide the address */
+ base = (pointer)0;
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base);
+ MapDSC.vaddr = (char *)base;
+ MapDSC.physaddr = (char *)Base;
+ MapDSC.length = Size;
+ MapDSC.ioflg = 1;
if(mmapFd >= 0)
{
- if((base = (pointer)ioctl(mmapFd, MAP,
- &(MapDSC[ScreenNum][Region]))) == (pointer)-1)
+ if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1)
{
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
"xf86MapVidMem", Size, Base, strerror(errno));
@@ -151,152 +190,106 @@ unsigned long Size;
}
/* Next time we want the same address! */
- MapDSC[ScreenNum][Region].vaddr = (char *)base;
-#if 0
-/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
- xf86memMaps[ScreenNum].offset = (int) Base;
- xf86memMaps[ScreenNum].memSize = Size;
-#endif
- return((pointer)base);
+ MapDSC.vaddr = (char *)base;
}
-#endif
- if (ioctl(xf86Info.consoleFd, KDMAPDISP,
- &(MapDSC[ScreenNum][Region])) < 0)
- {
- FatalError("xf86MapVidMem: Failed to map video mem (%x,%x) (%s)\n",
- Base, Size, strerror(errno));
- /* NOTREACHED */
- }
-#endif /* SVR4 */
-#if 0
- xf86memMaps[ScreenNum].offset = (int) Base;
- xf86memMaps[ScreenNum].memSize = Size;
-#endif
- return((pointer)base);
-}
-#if 0
-/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
-#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV)
-void xf86GetVidMemData(ScreenNum, Base, Size)
-int ScreenNum;
-int *Base;
-int *Size;
-{
- *Base = xf86memMaps[ScreenNum].offset;
- *Size = xf86memMaps[ScreenNum].memSize;
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.length : %d\n", MapDSC.length);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n");
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return(base);
}
-#endif
-#endif
/* ARGSUSED */
-void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
-int ScreenNum;
-int Region;
-pointer Base;
-unsigned long Size;
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
#if defined (SVR4)
munmap(Base, Size);
#else /* SVR4 */
#ifdef HAS_SVR3_MMAPDRV
- if(mmapFd >= 0)
- {
- ioctl(mmapFd, UNMAPRM, MapDSC[ScreenNum][Region].vaddr);
- return;
- }
-#endif
- /* XXXX This is a problem because it unmaps all regions */
- ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0);
- xfree(AllocAddress[ScreenNum][Region]);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: UNMapping FrameBuffer\n");
+ mmapStat(Base,Size);
+ ioctl(mmapFd, UNMAPRM , Base);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base);
+#endif /* HAS_SVR3_MMAPDRV */
#endif /* SVR4 */
+ return;
}
-/* ARGSUSED */
-void xf86MapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
+#if defined(SVR4) && defined(i386) && !defined(sun)
+/*
+ * For some SVR4 versions, a 32-bit read is done for the first location
+ * in each page when the page is first mapped. If this is done while
+ * memory access is enabled for regions that have read side-effects,
+ * this can cause unexpected results, including lockups on some hardware.
+ * This function is called to make sure each page is mapped while it is
+ * safe to do so.
+ */
+
+/*
+ * XXX Should get this the correct way (see os/xalloc.c), but since this is
+ * for one platform I'll be lazy.
+ */
+#define X_PAGE_SIZE 4096
+
+static void
+readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
{
-#if !defined(SVR4)
-#ifdef HAS_SVR3_MMAPDRV
- if(mmapFd >= 0)
- {
- ioctl(mmapFd, MAP, &(MapDSC[ScreenNum][Region]));
- return;
- }
-#endif
- ioctl(xf86Info.consoleFd, KDMAPDISP, &(MapDSC[ScreenNum][Region]));
-#endif /* SVR4 */
- return;
+ unsigned long base, end, addr;
+ CARD32 val;
+
+ base = (unsigned long)Base;
+ end = base + Size;
+
+ for (addr = base; addr < end; addr += X_PAGE_SIZE)
+ val = *(volatile CARD32 *)addr;
}
+#endif
-/* ARGSUSED */
-void xf86UnMapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
-#if !defined(SVR4)
-#ifdef HAS_SVR3_MMAPDRV
- if(mmapFd > 0)
- {
- ioctl(mmapFd, UNMAP, MapDSC[ScreenNum][Region].vaddr);
- return;
- }
+ pVidMem->linearSupported = linearVidMem();
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#if defined(SVR4) && defined(i386) && !defined(sun)
+ pVidMem->readSideEffects = readSideEffects;
#endif
- ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0);
-#endif /* SVR4 */
- return;
+ pVidMem->initialised = TRUE;
}
-
+
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
-#define ALWAYS_USE_EXTENDED
-#ifdef ALWAYS_USE_EXTENDED
-
-static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void
-xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
-{
- if (!InitDone)
- {
- int i;
- for (i = 0; i < MAXSCREENS; i++)
- ScreenEnabled[i] = FALSE;
- InitDone = TRUE;
- }
- return;
-}
-
-void
-xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
-{
- return;
-}
-
-void
-xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
+xf86EnableIO()
{
int i;
- ScreenEnabled[ScreenNum] = TRUE;
-
if (ExtendedEnabled)
return;
if (SET_IOPL() < 0)
{
- FatalError("%s: Failed to set IOPL for extended I/O\n",
- "xf86EnableIOPorts");
+ FatalError(
+ "xf86EnableIO: Failed to set IOPL for extended I/O\n");
}
ExtendedEnabled = TRUE;
@@ -304,245 +297,23 @@ int ScreenNum;
}
void
-xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
+xf86DisableIO()
{
- int i;
-
- ScreenEnabled[ScreenNum] = FALSE;
-
if (!ExtendedEnabled)
return;
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
-
RESET_IOPL();
ExtendedEnabled = FALSE;
return;
}
-#else /* !ALWAYS_USE_EXTENDED */
-
-#define DISABLED 0
-#define NON_EXTENDED 1
-#define EXTENDED 2
-
-static unsigned *EnabledPorts[MAXSCREENS];
-static int NumEnabledPorts[MAXSCREENS];
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedPorts[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-static struct kd_disparam OrigParams;
-
-void xf86ClearIOPortList(ScreenNum)
-int ScreenNum;
-{
- if (!InitDone)
- {
- xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled,
- ExtendedPorts, MAXSCREENS);
- if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &OrigParams) < 0)
- {
- FatalError("%s: Could not get display parameters\n",
- "xf86ClearIOPortList");
- }
- InitDone = TRUE;
- return;
- }
- ExtendedPorts[ScreenNum] = FALSE;
- if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
- xfree(EnabledPorts[ScreenNum]);
- EnabledPorts[ScreenNum] = (unsigned *)NULL;
- NumEnabledPorts[ScreenNum] = 0;
-}
-
-void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
-int ScreenNum;
-int NumPorts;
-unsigned *Ports;
-{
- int i;
-
- if (!InitDone)
- {
- FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
- }
- EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum],
- (NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
- for (i = 0; i < NumPorts; i++)
- {
- EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
- Ports[i];
- if (Ports[i] > 0x3FF)
- ExtendedPorts[ScreenNum] = TRUE;
- }
- NumEnabledPorts[ScreenNum] += NumPorts;
-}
-
-void xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- struct kd_disparam param;
- int i, j;
-
- if (ScreenEnabled[ScreenNum])
- return;
-
- for (i = 0; i < MAXSCREENS; i++)
- {
- if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum))
- {
- if (SET_IOPL() < 0)
- {
- FatalError("%s: Failed to set IOPL for extended I/O\n",
- "xf86EnableIOPorts");
- }
- ExtendedEnabled = TRUE;
- break;
- }
- }
- /* If extended I/O was used, but isn't any more */
- if (ExtendedEnabled && i == MAXSCREENS)
- {
- RESET_IOPL();
- ExtendedEnabled = FALSE;
- }
- /*
- * Turn on non-extended ports even when using extended I/O
- * so they are there if extended I/O gets turned off when it's no
- * longer needed.
- */
- if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
- {
- FatalError("%s: Could not get display parameters\n",
- "xf86EnableIOPorts");
- }
- for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
- {
- unsigned port = EnabledPorts[ScreenNum][i];
-
- if (port > 0x3FF)
- continue;
-
- if (!xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
- ScreenEnabled, MAXSCREENS))
- {
- continue;
- }
- for (j=0; j < MKDIOADDR; j++)
- {
- if (param.ioaddr[j] == port)
- {
- break;
- }
- }
- if (j == MKDIOADDR)
- {
- if (ioctl(xf86Info.consoleFd, KDADDIO, port) < 0)
- {
- FatalError("%s: Failed to enable port 0x%x\n",
- "xf86EnableIOPorts", port);
- }
- }
- }
- if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
- {
- FatalError("xf86EnableIOPorts: I/O port enable failed (%s)\n",
- strerror(errno));
- }
- ScreenEnabled[ScreenNum] = TRUE;
- return;
-}
-
-void xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
-{
- struct kd_disparam param;
- int i, j;
-
- if (!ScreenEnabled[ScreenNum])
- return;
-
- ScreenEnabled[ScreenNum] = FALSE;
- for (i = 0; i < MAXSCREENS; i++)
- {
- if (ScreenEnabled[i] && ExtendedPorts[i])
- break;
- }
- if (ExtendedEnabled && i == MAXSCREENS)
- {
- RESET_IOPL();
- ExtendedEnabled = FALSE;
- }
- /* Turn off I/O before changing the access list */
- ioctl(xf86Info.consoleFd, KDDISABIO, 0);
- if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
- {
- ErrorF("%s: Could not get display parameters\n",
- "xf86DisableIOPorts");
- return;
- }
-
- for (i=0; i < MKDIOADDR; i++)
- {
- /* 0 indicates end of list */
- if (param.ioaddr[i] == 0)
- {
- break;
- }
- if (!xf86CheckPorts(param.ioaddr[i], EnabledPorts,
- NumEnabledPorts, ScreenEnabled, MAXSCREENS))
- {
- continue;
- }
- for (j=0; j < MKDIOADDR; j++)
- {
- if (param.ioaddr[i] == OrigParams.ioaddr[j])
- {
- /*
- * Port was one of the original ones; don't
- * touch it.
- */
- break;
- }
- }
- if (j == MKDIOADDR)
- {
- /*
- * We added this port, so remove it.
- */
- ioctl(xf86Info.consoleFd, KDDELIO, param.ioaddr[i]);
- }
- }
- /* If any other screens are enabled, turn I/O back on */
- for (i = 0; i < MAXSCREENS; i++)
- {
- if (ScreenEnabled[i])
- {
- ioctl(xf86Info.consoleFd, KDENABIO, 0);
- break;
- }
- }
- return;
-}
-#endif /* ALWAYS_USE_EXTENDED */
-
-void xf86DisableIOPrivs()
-{
- if (ExtendedEnabled)
- RESET_IOPL();
- return;
-}
-
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
-Bool xf86DisableInterrupts()
+Bool
+xf86DisableInterrupts()
{
if (!ExtendedEnabled)
{
@@ -565,7 +336,8 @@ Bool xf86DisableInterrupts()
return(TRUE);
}
-void xf86EnableInterrupts()
+void
+xf86EnableInterrupts()
{
if (!ExtendedEnabled)
{
diff --git a/hw/xfree86/os-support/sysv/xqueue.c b/hw/xfree86/os-support/sysv/xqueue.c
index 5e3c8e9fc..0478ee65e 100644
--- a/hw/xfree86/os-support/sysv/xqueue.c
+++ b/hw/xfree86/os-support/sysv/xqueue.c
@@ -1,38 +1,38 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c,v 3.8.2.1 1997/07/13 14:45:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c,v 3.20 2001/03/06 18:20:31 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993-1999 by The XFree86 Project, Inc.
*
* 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 name of Thomas Roell not be used in
+ * documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
+ * specific, written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
*
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE COPYRIGHT HOLDERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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.
*
*/
-/* $Xorg: xqueue.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */
+/* $XConsortium: xqueue.c /main/8 1996/10/19 18:08:11 kaleb $ */
-#define NEED_EVENTS
#include "X.h"
-#include "Xproto.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
-#include "xf86Procs.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xqueue.h"
#ifdef XQUEUE
@@ -43,19 +43,23 @@ static int xquePipe[2];
#endif
#ifdef XKB
+#include "inputstr.h"
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBstr.h>
#include <X11/extensions/XKBsrv.h>
extern Bool noXkbExtension;
#endif
-#ifdef XINPUT
-#include "xf86_Config.h"
#include "xf86Xinput.h"
-#endif
-extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
- unsigned long start, unsigned long stop,
- ScreenPtr pScreen);
+#include "mipointer.h"
+
+typedef struct {
+ int xquePending;
+ int xqueSema;
+} XqInfoRec, *XqInfoPtr;
+
+InputInfoPtr XqMouse = NULL;
+InputInfoPtr XqKeyboard = NULL;
#ifndef XQUEUE_ASYNC
/*
@@ -67,7 +71,7 @@ extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
static void
xf86XqueSignal(int signum)
{
- xf86Info.mouseDev->xquePending = 1;
+ ((XqInfoPtr)(((MouseDevPtr)(XqMouse->private))->mousePriv))->xquePending = 1;
/*
* This is a hack, but it is the only reliable way I can find of letting
* the main select() loop know that there is more input waiting. Receiving
@@ -78,223 +82,14 @@ xf86XqueSignal(int signum)
* Suggestions for better ways of dealing with this without going back to
* asynchronous event processing are welcome.
*/
- write(xquePipe[1], "X", 1);
- signal(SIGUSR2, xf86XqueSignal);
-}
-#endif
-
-
-/*
- * xf86XqueRequest --
- * Notice an i/o request from the xqueue.
- */
-
-void
-xf86XqueRequest()
-{
- xqEvent *XqueEvents = XqueQaddr->xq_events;
- int XqueHead = XqueQaddr->xq_head;
- char buf[100];
-
- while (XqueHead != XqueQaddr->xq_tail)
- {
-
- switch(XqueEvents[XqueHead].xq_type) {
-
- case XQ_BUTTON:
- xf86PostMseEvent(xf86Info.pMouse,
- ~(XqueEvents[XqueHead].xq_code) & 0x07, 0, 0);
- break;
-
- case XQ_MOTION:
- xf86PostMseEvent(xf86Info.pMouse,
- ~(XqueEvents[XqueHead].xq_code) & 0x07,
- XqueEvents[XqueHead].xq_x,
- XqueEvents[XqueHead].xq_y);
- break;
-
- case XQ_KEY:
- xf86PostKbdEvent(XqueEvents[XqueHead].xq_code);
- break;
-
- default:
- ErrorF("Unknown Xque Event: 0x%02x\n", XqueEvents[XqueHead].xq_type);
- }
-
- if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0;
- }
-
- /* reenable the signal-processing */
- xf86Info.inputPending = TRUE;
-#ifdef XQUEUE_ASYNC
- signal(SIGUSR2, (void (*)()) xf86XqueRequest);
-#else
-#if 0
- signal(SIGUSR2, (void (*)()) xf86XqueSignal);
-#endif
-#endif
-
-#ifndef XQUEUE_ASYNC
- {
- int rval;
-
- while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0)
#ifdef DEBUG
- ErrorF("Read %d bytes from xquePipe[0]\n", rval);
-#else
- ;
-#endif
- }
+ ErrorF("xf86XqueSignal\n");
#endif
-
- XqueQaddr->xq_head = XqueQaddr->xq_tail;
- xf86Info.mouseDev->xquePending = 0;
- XqueQaddr->xq_sigenable = 1; /* UNLOCK */
-}
-
-
-
-/*
- * xf86XqueEnable --
- * Enable the handling of the Xque
- */
-
-static int
-xf86XqueEnable()
-{
- static struct kd_quemode xqueMode;
- static Bool was_here = FALSE;
-
- if (!was_here) {
- if ((xqueFd = open("/dev/mouse", O_RDONLY|O_NDELAY)) < 0)
- {
- if (xf86AllowMouseOpenFail) {
- ErrorF("Cannot open /dev/mouse (%s) - Continuing...\n",
- strerror(errno));
- return (Success);
- } else {
- Error ("Cannot open /dev/mouse");
- return (!Success);
- }
- }
-#ifndef XQUEUE_ASYNC
- pipe(xquePipe);
- fcntl(xquePipe[0],F_SETFL,fcntl(xquePipe[0],F_GETFL,0)|O_NDELAY);
- fcntl(xquePipe[1],F_SETFL,fcntl(xquePipe[1],F_GETFL,0)|O_NDELAY);
-#endif
- was_here = TRUE;
- }
-
- if (xf86Info.mouseDev->xqueSema++ == 0)
- {
-#ifdef XQUEUE_ASYNC
- (void) signal(SIGUSR2, (void (*)()) xf86XqueRequest);
-#else
- (void) signal(SIGUSR2, (void (*)()) xf86XqueSignal);
-#endif
- xqueMode.qsize = 64; /* max events */
- xqueMode.signo = SIGUSR2;
- ioctl(xf86Info.consoleFd, KDQUEMODE, NULL);
-
- if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) {
- Error ("Cannot set KDQUEMODE");
- /* CONSTCOND */
- return (!Success);
- }
-
- XqueQaddr = (xqEventQueue *)xqueMode.qaddr;
- XqueQaddr->xq_sigenable = 1; /* UNLOCK */
- }
-
- return(Success);
-}
-
-
-
-/*
- * xf86XqueDisable --
- * disable the handling of the Xque
- */
-
-static int
-xf86XqueDisable()
-{
- if (xf86Info.mouseDev->xqueSema-- == 1)
- {
-
- XqueQaddr->xq_sigenable = 0; /* LOCK */
-
- if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
- Error ("Cannot unset KDQUEMODE");
- /* CONSTCOND */
- return (!Success);
- }
- }
-
- return(Success);
+ write(xquePipe[1], "X", 1);
+ signal(SIGUSR2, xf86XqueSignal);
}
-
-
-
-/*
- * xf86XqueMseProc --
- * Handle the initialization, etc. of a mouse
- */
-
-int
-xf86XqueMseProc(pPointer, what)
- DeviceIntPtr pPointer;
- int what;
-{
- MouseDevPtr mouse = MOUSE_DEV(pPointer);
- unchar map[4];
- int ret;
-
- mouse->device = pPointer;
-
- switch (what)
- {
- case DEVICE_INIT:
-
- pPointer->public.on = FALSE;
-
- map[1] = 1;
- map[2] = 2;
- map[3] = 3;
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- 3,
- miPointerGetMotionEvents,
- (PtrCtrlProcPtr)xf86MseCtrl,
- miPointerGetMotionBufferSize());
- break;
-
- case DEVICE_ON:
- mouse->lastButtons = 0;
- mouse->emulateState = 0;
- pPointer->public.on = TRUE;
- ret = xf86XqueEnable();
-#ifndef XQUEUE_ASYNC
- if (xquePipe[0] != -1)
- AddEnabledDevice(xquePipe[0]);
-#endif
- return(ret);
-
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- pPointer->public.on = FALSE;
- ret = xf86XqueDisable();
-#ifndef XQUEUE_ASYNC
- if (xquePipe[0] != -1)
- RemoveEnabledDevice(xquePipe[0]);
#endif
- return(ret);
- }
- return Success;
-}
-
-
/*
* xf86XqueKbdProc --
@@ -302,9 +97,7 @@ xf86XqueMseProc(pPointer, what)
*/
int
-xf86XqueKbdProc (pKeyboard, what)
- DeviceIntPtr pKeyboard; /* Keyboard to manipulate */
- int what; /* What to do to it */
+xf86XqueKbdProc(DeviceIntPtr pKeyboard, int what)
{
KeySymsRec keySyms;
CARD8 modMap[MAP_LENGTH];
@@ -381,12 +174,12 @@ xf86XqueKbdProc (pKeyboard, what)
case DEVICE_ON:
pKeyboard->public.on = TRUE;
xf86InitKBD(FALSE);
- return(xf86XqueEnable());
+ break;
case DEVICE_CLOSE:
case DEVICE_OFF:
pKeyboard->public.on = FALSE;
- return(xf86XqueDisable());
+ break;
}
return (Success);
@@ -403,4 +196,343 @@ xf86XqueEvents()
{
}
+
+#ifdef XQUEUE_ASYNC
+static void XqDoInput(int signum);
+#endif
+
+void
+XqReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ xqEvent *XqueEvents;
+ int XqueHead;
+ char buf[100];
+ signed char dx, dy;
+
+ if (xqueFd < 0)
+ return;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ XqueEvents = XqueQaddr->xq_events;
+ XqueHead = XqueQaddr->xq_head;
+
+ while (XqueHead != XqueQaddr->xq_tail) {
+ switch (XqueEvents[XqueHead].xq_type) {
+ case XQ_BUTTON:
+ pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
+ 0, 0, 0, 0);
+#ifdef DEBUG
+ ErrorF("xqueue: buttons: %d\n", ~(XqueEvents[XqueHead].xq_code) & 0x07);
+#endif
+ break;
+
+ case XQ_MOTION:
+ dx = (signed char)XqueEvents[XqueHead].xq_x;
+ dy = (signed char)XqueEvents[XqueHead].xq_y;
+ pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
+ (int)dx, (int)dy, 0, 0);
+#ifdef DEBUG
+ ErrorF("xqueue: Motion: (%d, %d) (buttons: %d)\n", dx, dy, ~(XqueEvents[XqueHead].xq_code) & 0x07);
+#endif
+ break;
+
+ case XQ_KEY:
+ /* XXX Need to deal with the keyboard part nicely. */
+#ifdef DEBUG
+ ErrorF("xqueue: key: %d\n", XqueEvents[XqueHead].xq_code);
+#endif
+ xf86PostKbdEvent(XqueEvents[XqueHead].xq_code);
+ break;
+ default:
+ xf86Msg(X_WARNING, "Unknown Xque Event: 0x%02x\n",
+ XqueEvents[XqueHead].xq_type);
+ }
+
+ if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0;
+ xf86Info.inputPending = TRUE;
+ }
+
+ /* reenable the signal-processing */
+#ifdef XQUEUE_ASYNC
+ signal(SIGUSR2, XqDoInput);
+#endif
+
+#ifndef XQUEUE_ASYNC
+ {
+ int rval;
+
+ while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0)
+#ifdef DEBUG
+ ErrorF("Read %d bytes from xquePipe[0]\n", rval);
+#else
+ ;
+#endif
+ }
+#endif
+
+#ifdef DEBUG
+ ErrorF("Leaving XqReadInput()\n");
+#endif
+ pXq->xquePending = 0;
+ XqueQaddr->xq_head = XqueQaddr->xq_tail;
+ XqueQaddr->xq_sigenable = 1; /* UNLOCK */
+}
+
+#ifdef XQUEUE_ASYNC
+static void
+XqDoInput(int signum)
+{
+ if (XqMouse)
+ XqReadInput(XqMouse);
+}
+#endif
+
+static void
+XqBlock(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ /*
+ * On MP SVR4 boxes, a race condition exists because the XQUEUE does
+ * not have anyway to lock it for exclusive access. This results in one
+ * processor putting something on the queue at the same time the other
+ * processor is taking it something off. The count of items in the queue
+ * can get off by 1. This just goes and checks to see if an extra event
+ * was put in the queue a during this period. The signal for this event
+ * was ignored while processing the previous event.
+ */
+
+ pInfo = blockData;
+ pMse = pInfo->private;
+ pXq = pMse-> mousePriv;
+ if (!pXq->xquePending) {
+#ifdef DEBUG
+ ErrorF("XqBlock: calling XqReadInput()\n");
+#endif
+ XqReadInput((InputInfoPtr)blockData);
+ } else {
+#ifdef DEBUG
+ ErrorF("XqBlock: not calling XqReadInput()\n");
+#endif
+ ;
+ }
+ /*
+ * Make sure that any events that come in here are passed on without.
+ * waiting for the next wakeup.
+ */
+ if (xf86Info.inputPending) {
+#ifdef DEBUG
+ ErrorF("XqBlock: calling ProcessInputEvents()\n");
+#endif
+ ProcessInputEvents();
+ } else {
+#ifdef DEBUG
+ ErrorF("XqBlock: not calling ProcessInputEvents()\n");
+#endif
+ ;
+ }
+}
+
+/*
+ * XqEnable --
+ * Enable the handling of the Xque
+ */
+
+static int
+XqEnable(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ static struct kd_quemode xqueMode;
+ static Bool was_here = FALSE;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ if (xqueFd < 0) {
+ if ((xqueFd = open("/dev/mouse", O_RDONLY | O_NDELAY)) < 0) {
+ if (xf86GetAllowMouseOpenFail()) {
+ xf86Msg(X_WARNING,
+ "%s: Cannot open /dev/mouse (%s) - Continuing...\n",
+ pInfo->name, strerror(errno));
+ return Success;
+ } else {
+ xf86Msg(X_ERROR, "%s: Cannot open /dev/mouse (%s)\n",
+ pInfo->name, strerror(errno));
+ return !Success;
+ }
+ }
+ }
+#ifndef XQUEUE_ASYNC
+ if (!was_here) {
+ pipe(xquePipe);
+ fcntl(xquePipe[0], F_SETFL, fcntl(xquePipe[0], F_GETFL, 0) | O_NDELAY);
+ fcntl(xquePipe[1], F_SETFL, fcntl(xquePipe[1], F_GETFL, 0) | O_NDELAY);
+ was_here = TRUE;
+ }
+#endif
+
+ if (pXq->xqueSema++ == 0) {
+#ifdef XQUEUE_ASYNC
+ (void) signal(SIGUSR2, XqDoInput);
+#else
+ (void) signal(SIGUSR2, xf86XqueSignal);
+#endif
+ xqueMode.qsize = 64; /* max events */
+ xqueMode.signo = SIGUSR2;
+ ioctl(xf86Info.consoleFd, KDQUEMODE, NULL);
+
+ if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) {
+ xf86Msg(X_ERROR, "%s: Cannot set KDQUEMODE", pInfo->name);
+ return !Success;
+ }
+ XqueQaddr = (xqEventQueue *)xqueMode.qaddr;
+ XqueQaddr->xq_sigenable = 1; /* UNLOCK */
+ }
+
+ return Success;
+}
+
+
+
+/*
+ * xf86XqueDisable --
+ * disable the handling of the Xque
+ */
+
+static int
+XqDisable(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ if (pXq->xqueSema-- == 1)
+ {
+ XqueQaddr->xq_sigenable = 0; /* LOCK */
+
+ if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
+ xf86Msg(X_ERROR, "%s: Cannot unset KDQUEMODE", pInfo->name);
+ return !Success;
+ }
+ }
+
+ if (xqueFd >= 0) {
+ close(xqueFd);
+ xqueFd = -1;
+ }
+
+ return Success;
+}
+
+/*
+ * XqMouseProc --
+ * Handle the initialization, etc. of a mouse
+ */
+
+static int
+XqMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unchar map[4];
+ int ret;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ 3,
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ RegisterBlockAndWakeupHandlers(XqBlock, (WakeupHandlerProcPtr)NoopDDA,
+ pInfo);
+ break;
+
+ case DEVICE_ON:
+ pMse->lastButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ ret = XqEnable(pInfo);
+#ifndef XQUEUE_ASYNC
+ if (xquePipe[0] != -1) {
+ pInfo->fd = xquePipe[0];
+ AddEnabledDevice(xquePipe[0]);
+ }
+#endif
+ return ret;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ ret = XqDisable(pInfo);
+#ifndef XQUEUE_ASYNC
+ if (xquePipe[0] != -1) {
+ RemoveEnabledDevice(xquePipe[0]);
+ pInfo->fd = -1;
+ }
+#endif
+ return ret;
+ }
+ return Success;
+}
+
+Bool
+XqueueMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+ pXq = pMse->mousePriv = xnfcalloc(sizeof(XqInfoRec), 1);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = XqMouseProc;
+#ifdef XQUEUE_ASYNC
+ pInfo->read_input = NULL;
+#else
+ pInfo->read_input = XqReadInput;
+#endif
+ pInfo->fd = -1;
+
+ XqMouse = pInfo;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
#endif /* XQUEUE */
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 72722a2c8..b35186724 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.36.2.5 1998/02/15 16:09:30 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.90 2002/05/31 18:46:00 dawes Exp $ */
/*
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1992 by David Dawes <dawes@XFree86.org>
@@ -9,7 +9,8 @@
* Copyright 1993 by Vrije Universiteit, The Netherlands
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
* Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
- * Copyright 1994, 1995 by The XFree86 Project, Inc
+ * Copyright 1997 by Takis Psarogiannakopoulos <takis@dpmms.cam.ac.uk>
+ * Copyright 1994-1998 by The XFree86 Project, Inc
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -31,7 +32,46 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86_OSlib.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */
+
+/*
+ * 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: xf86_OSlib.h /main/22 1996/10/27 11:06:31 kaleb $ */
+
+/*
+ * This is private, and should not be included by any drivers. Drivers
+ * may include xf86_OSproc.h to get prototypes for public interfaces.
+ */
#ifndef _XF86_OSLIB_H
#define _XF86_OSLIB_H
@@ -39,21 +79,43 @@
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
-#include "compiler.h"
-
-#if defined(MACH386) || defined(__OSF__)
-# undef NULL
-#endif /* MACH386 || __OSF__ */
+/*
+ * Define some things from the "ANSI" C wrappers that are needed in the
+ * the core server.
+ */
+#ifndef HAVE_WRAPPER_DECLS
+#define HAVE_WRAPPER_DECLS
+#undef usleep
+#define usleep(a) xf86usleep(a)
+extern void xf86usleep(unsigned long);
+extern int xf86getpagesize(void);
+extern int xf86GetErrno(void);
+typedef unsigned long xf86size_t;
+typedef signed long xf86ssize_t;
+#ifdef NEED_SNPRINTF
+extern int snprintf(char *str, size_t size, const char *format, ...);
+extern int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif
+#endif
#include <stdio.h>
#include <ctype.h>
+#include <stddef.h>
/**************************************************************************/
-/* SYSV386 (SVR3, SVR4) */
+/* SYSV386 (SVR3, SVR4) - But not Solaris8 */
/**************************************************************************/
-#if defined(SYSV) || defined(SVR4)
+#if (defined(SYSV) || defined(SVR4)) && \
+ !defined(DGUX) && \
+ !defined(__SOL8__) && \
+ (!defined(sun) || defined(i386))
# ifdef SCO325
-# define _SVID3
+# ifndef _SVID3
+# define _SVID3
+# endif
+# ifndef _NO_STATIC
+# define _NO_STATIC
+# endif
# endif
# include <sys/ioctl.h>
# include <signal.h>
@@ -64,9 +126,20 @@
# include <sys/param.h>
# endif
+# ifdef ISC
+# define TIOCMSET (TIOC|26) /* set all modem bits */
+# define TIOCMBIS (TIOC|27) /* bis modem bits */
+# define TIOCMBIC (TIOC|28) /* bic modem bits */
+# define TIOCMGET (TIOC|29) /* get all modem bits */
+# endif
+
# include <errno.h>
-# if defined(_NEED_SYSI86)
+# if defined(PowerMAX_OS)
+# define HAS_USL_VTS
+# include <sys/immu.h>
+# include <sys/sysmacros.h>
+# elif defined(_NEED_SYSI86)
# include <sys/immu.h>
# if !(defined (sun) && defined (i386) && defined (SVR4))
# include <sys/region.h>
@@ -77,22 +150,30 @@
# if defined(SVR4) && !defined(sun)
# include <sys/seg.h>
# endif /* SVR4 && !sun */
-# include <sys/v86.h>
+# if defined(sun) && defined (i386) && defined (SVR4) /* Solaris? */
+# if !defined(V86SC_IOPL) /* Solaris 7? */
+# include <sys/v86.h> /* Nope */
+# endif /* V86SC_IOPL */
+# else
+# include <sys/v86.h> /* Not solaris */
+# endif /* sun && i386 && SVR4 */
# if defined(sun) && defined (i386) && defined (SVR4)
# include <sys/psw.h>
# endif
# endif /* _NEED_SYSI86 */
-#if defined(HAS_SVR3_MMAPDRV)
-# include <sys/sysmacros.h>
-# if !defined(_NEED_SYSI86)
-# include <sys/immu.h>
-# include <sys/region.h>
+# if defined(HAS_SVR3_MMAPDRV)
+# include <sys/sysmacros.h>
+# if !defined(_NEED_SYSI86)
+# include <sys/immu.h>
+# include <sys/region.h>
+# endif
+# include <sys/mmap.h> /* MMAP driver header */
# endif
-# include <sys/mmap.h> /* MMAP driver header */
-#endif
-# define HAS_USL_VTS
+# if !defined(sun) || !defined(sparc)
+# define HAS_USL_VTS
+# endif
# if !defined(sun)
# include <sys/emap.h>
# endif
@@ -104,7 +185,7 @@
# define LED_CAP 0x01
# define LED_NUM 0x02
# define LED_SCR 0x04
-# else /* SCO */
+# elif defined(HAS_USL_VTS)
# include <sys/at_ansi.h>
# include <sys/kd.h>
# include <sys/vt.h>
@@ -123,6 +204,8 @@
# include <sys/mman.h>
# if !(defined(sun) && defined (i386) && defined (SVR4))
# define DEV_MEM "/dev/pmem"
+# elif defined(PowerMAX_OS)
+# define DEV_MEM "/dev/iomem"
# endif
# ifdef SCO325
# undef DEV_MEM
@@ -143,33 +226,115 @@
# endif
# if defined(ATT) && !defined(i386)
-# define i386 /* note defined in ANSI C mode */
+# define i386 /* not defined in ANSI C mode */
# endif /* ATT && !i386 */
-# if (defined(ATT) || defined(SVR4)) && !(defined(sun) && defined (i386) && defined (SVR4)) && !defined(SCO325)
-# define XQUEUE
+# if (defined(ATT) || defined(SVR4)) && !defined(sun) && !defined(SCO325)
+# ifndef XQUEUE
+# define XQUEUE
+# endif
# include <sys/xque.h>
# endif /* ATT || SVR4 */
-/* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */
-#if defined (sun) && defined (i386) && defined (SVR4)
-extern int xf86_solx86usleep(unsigned long);
-# define usleep(usec) xf86_solx86usleep(usec)
-#else
-# define usleep(usec) syscall(3112, (usec) / 1000 + 1)
-#endif /* sun && i386 && SVR4 */
-
# ifdef SYSV
# if !defined(ISC) || defined(ISC202) || defined(ISC22)
# define NEED_STRERROR
# endif
# endif
-#ifndef NULL
-# define NULL 0
-#endif
+#endif /* (SYSV || SVR4) && !DGUX */
+
+/**********
+ * Good ol' Solaris8, and its lack of VT support
+ ***********/
+
+#if defined(__SOL8__) || (defined(sun) && !defined(i386))
+# include <sys/mman.h>
+# include <errno.h>
+# ifdef i386
+# include <sys/sysi86.h>
+# endif
+# include <sys/psw.h>
+
+# include <termio.h>
+# include <sys/fbio.h>
+# include <sys/kbd.h>
+# include <sys/kbio.h>
+
+# define LED_CAP LED_CAPS_LOCK
+# define LED_NUM LED_NUM_LOCK
+# define LED_SCR LED_SCROLL_LOCK
+
+# include <signal.h>
+
+#endif /* __SOL8__ */
+
+
+
+/**************************************************************************/
+/* DG/ux R4.20MU03 Intel AViion Machines */
+/**************************************************************************/
+#if defined(DGUX) && defined(SVR4)
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <ctype.h>
+#include <termios.h> /* Use termios for BSD Flavor ttys */
+#include <sys/termios.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <errno.h>
+#include <sys/sysi86.h>
+#include <unistd.h>
+#include <sys/proc.h>
+#include <sys/map.h>
+#include <sys/sysmacros.h>
+#include <sys/mman.h> /* Memory handling */
+#include <sys/kd.h> /* definitios for KDENABIO KDDISABIO needed for IOPL s */
+#include <sys/kbd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/stream.h>
+#include <sys/ptms.h>
+
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <sys/stropts.h>
+#include <sys/sockio.h>
+
+
+#define POSIX_TTY
-#endif /* SYSV || SVR4 */
+#undef HAS_USL_VTS
+#undef USE_VT_SYSREQ
+#undef VT_ACKACQ
+
+#define LED_CAP KBD_LED_CAPS_LOCK
+#define LED_NUM KBD_LED_NUM_LOCK
+#define LED_SCR KBD_LED_SCROLL_LOCK
+
+#define KDGKBTYPE KBD_GET_LANGUAGE
+
+
+/* General keyboard types */
+# define KB_84 2
+# define KB_101 1 /* Because ioctl(dgkeybdFd,KBD_GET_LANGUAGE,&type) gives 1=US keyboard */
+# define KB_OTHER 3
+
+#define KDSETLED KBD_SET_LED
+#define KDGETLED KBD_GET_STATE
+#undef KDMKTONE
+#define KDMKTONE KBD_TONE_HIGH
+
+
+#undef DEV_MEM
+#define DEV_MEM "/dev/mem"
+#define CLEARDTR_SUPPORT
+
+#undef VT_SYSREQ_DEFAULT
+#define VT_SYSREQ_DEFAULT FALSE /* Make sure that we dont define any VTs since DG/ux has none */
+
+#endif /* DGUX && SVR4 */
/**************************************************************************/
/* Linux */
@@ -178,9 +343,11 @@ extern int xf86_solx86usleep(unsigned long);
# include <sys/ioctl.h>
# include <signal.h>
# include <termio.h>
+# ifdef __sparc__
+# include <sys/param.h>
+# endif
# include <errno.h>
-extern int errno;
# include <sys/stat.h>
@@ -228,6 +395,14 @@ extern int errno;
# include <termios.h>
# define POSIX_TTY
+# define CLEARDTR_SUPPORT
+
+/* LynxOS 2.5.1 has these */
+# ifdef LED_NUMLOCK
+# define LED_CAP LED_CAPSLOCK
+# define LED_NUM LED_NUMLOCK
+# define LED_SCR LED_SCROLLOCK
+# endif
#endif /* Lynx */
@@ -241,9 +416,6 @@ extern int errno;
#ifdef CSRG_BASED
# include <sys/ioctl.h>
-# if defined(__OpenBSD__) && defined(_status)
-# undef _status
-# endif
# include <signal.h>
# include <termios.h>
@@ -251,7 +423,6 @@ extern int errno;
# define POSIX_TTY
# include <errno.h>
-extern int errno;
# if !defined(LINKKIT)
/* Don't need this stuff for the Link Kit */
@@ -269,30 +440,38 @@ extern int errno;
# undef CONSOLE_X_BELL
# endif
# endif
-# ifdef CODRV_SUPPORT
-# define COMPAT_CO011
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-# include <machine/ioctl_pc.h>
-# else
-# include <sys/ioctl_pc.h>
-# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
-# endif /* CODRV_SUPPORT */
# ifdef SYSCONS_SUPPORT
# define COMPAT_SYSCONS
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# if defined(__NetBSD__) || defined(__OpenBSD__)
# include <machine/console.h>
# else
-# include <sys/console.h>
-# endif /* __FreeBSD__ || __NetBSD__ || defined(__OpenBSD__) */
+# if defined(__FreeBSD__)
+# include <osreldate.h>
+# if __FreeBSD_version >= 410000
+# include <sys/consio.h>
+# include <sys/kbio.h>
+# else
+# include <machine/console.h>
+# endif /* FreeBSD 4.1 RELEASE or lator */
+# else
+# include <sys/console.h>
+# endif
+# endif
# endif /* SYSCONS_SUPPORT */
# if defined(PCVT_SUPPORT)
# if !defined(SYSCONS_SUPPORT)
/* no syscons, so include pcvt specific header file */
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# if defined(__FreeBSD__)
# include <machine/pcvt_ioctl.h>
# else
-# include <sys/pcvt_ioctl.h>
-# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
+# if defined(__NetBSD__) || defined(__OpenBSD__)
+# if !defined(WSCONS_SUPPORT)
+# include <machine/pcvt_ioctl.h>
+# endif /* WSCONS_SUPPORT */
+# else
+# include <sys/pcvt_ioctl.h>
+# endif /* __NetBSD__ */
+# endif /* __FreeBSD__ || __OpenBSD__ */
# else /* pcvt and syscons: hard-code the ID magic */
# define VGAPCVTID _IOWR('V',113, struct pcvtid)
struct pcvtid {
@@ -301,9 +480,18 @@ extern int errno;
};
# endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
# endif /* PCVT_SUPPORT */
+# ifdef WSCONS_SUPPORT
+# include <dev/wscons/wsconsio.h>
+# include <dev/wscons/wsdisplay_usl_io.h>
+# endif /* WSCONS_SUPPORT */
# if defined(__FreeBSD__)
-# undef MOUSE_GETINFO
-# include <machine/mouse.h>
+# include <osreldate.h>
+# if __FreeBSD_version >= 500013
+# include <sys/mouse.h>
+# else
+# undef MOUSE_GETINFO
+# include <machine/mouse.h>
+# endif
# endif
/* Include these definitions in case ioctl_pc.h didn't get included */
# ifndef CONSOLE_X_MODE_ON
@@ -315,6 +503,25 @@ extern int errno;
# ifndef CONSOLE_X_BELL
# define CONSOLE_X_BELL _IOW('t',123,int[2])
# endif
+# ifndef CONSOLE_X_TV_ON
+# define CONSOLE_X_TV_ON _IOW('t',155,int)
+# define XMODE_RGB 0
+# define XMODE_NTSC 1
+# define XMODE_PAL 2
+# define XMODE_SECAM 3
+# endif
+# ifndef CONSOLE_X_TV_OFF
+# define CONSOLE_X_TV_OFF _IO('t',156)
+# endif
+#ifndef CONSOLE_GET_LINEAR_INFO
+# define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info)
+#endif
+#ifndef CONSOLE_GET_IO_INFO
+# define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info)
+#endif
+#ifndef CONSOLE_GET_MEM_INFO
+# define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info)
+#endif
# endif /* __bsdi__ */
# endif /* !LINKKIT */
@@ -329,111 +536,23 @@ extern int errno;
# endif
# endif /* __bsdi__ */
+#ifdef USE_I386_IOPL
+#include <machine/sysarch.h>
+#endif
+
# define CLEARDTR_SUPPORT
-# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
# define USE_VT_SYSREQ
# endif
-# ifndef NULL
-# define NULL 0
-# endif
-
#endif /* CSRG_BASED */
/**************************************************************************/
-/* Mach and OSF/1 */
-/**************************************************************************/
-#if defined(MACH386) || defined(__OSF__)
-# include <sys/ioctl.h>
-
-# include <signal.h>
-
-# include <errno.h>
-extern int errno;
-
-# if defined(__OSF__)
-# include <sys/param.h>
-# include <machine/kd.h>
-# else /* __OSF__ */
-# if !defined(__STDC__)
-# define __STDC__ 1
-# include <i386at/kd.h>
-# include <i386at/kd_queue.h>
-# undef __STDC__
-# else /* !__STDC__ */
-# include <i386at/kd.h>
-# include <i386at/kd_queue.h>
-# endif /* !__STDC__ */
-# include <sys/file.h>
-# define SEEK_SET L_SET
-# endif /* __OSF__ */
-
-# ifdef MACH386
-# define NEED_STRERROR
-# endif
-
-# include <sys/mman.h>
-# include <sys/stat.h>
-# define MOUSE_PROTOCOL_IN_KERNEL
-
-#endif /* MACH386 || __OSF__ */
-
-/**************************************************************************/
-/* Minix */
-/**************************************************************************/
-#if defined(MINIX)
-# include <sys/ioctl.h>
-# include <signal.h>
-
-# include <termios.h>
-# define termio termios
-# define POSIX_TTY
-
-# include <errno.h>
-
-# include <assert.h>
-# include <limits.h>
-# include <sys/memio.h>
-# include <sys/kbdio.h>
-
-# include <sys/stat.h>
-
-#endif /* MINIX */
-
-/**************************************************************************/
-/* Amoeba */
-/**************************************************************************/
-#if defined(AMOEBA)
-# define port am_port_t
-# include <amoeba.h>
-# include <cmdreg.h>
-# include <stderr.h>
-# include <ampolicy.h>
-# include <proc.h>
-# include <signal.h>
-# include <server/iop/iop.h>
-# include <errno.h>
-# undef port
-
-# undef _POSIX_SOURCE /* to get the BSD-compatible symbols */
-# include <sys/stat.h>
-
- /* keyboard types */
-# define KB_84 1
-# define KB_101 2
-# define KB_OTHER 3
-
-extern capability iopcap;
-# define MOUSE_PROTOCOL_IN_KERNEL
-
-#endif /* AMOEBA */
-
-/**************************************************************************/
/* OS/2 */
/**************************************************************************/
-/* currently OS/2 with EMX/GCC compiler only */
-#if defined(__EMX__)
+/* currently OS/2 with a modified EMX/GCC compiler only */
+#if defined(__UNIXOS2__)
# include <signal.h>
# include <errno.h>
# include <sys/stat.h>
@@ -468,9 +587,99 @@ extern char* __XOS2RedirRoot(char*);
#endif
/**************************************************************************/
+/* QNX4 */
+/**************************************************************************/
+/* This is the QNX code for Watcom 10.6 and QNX 4.x */
+#if defined(QNX4)
+#include <signal.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <ioctl.h>
+#include <sys/param.h>
+
+/* Warning: by default, the fd_set size is 32 in QNX! */
+#define FD_SETSIZE 256
+#include <sys/select.h>
+
+ /* keyboard types */
+# define KB_84 1
+# define KB_101 2
+# define KB_OTHER 3
+
+ /* LEDs */
+# define LED_CAP 0x04
+# define LED_NUM 0x02
+# define LED_SCR 0x01
+
+# define POSIX_TTY
+# define OSMOUSE_ONLY
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+#define TIOCM_DTR 0x0001 /* data terminal ready */
+#define TIOCM_RTS 0x0002 /* request to send */
+#define TIOCM_CTS 0x1000 /* clear to send */
+#define TIOCM_DSR 0x2000 /* data set ready */
+#define TIOCM_RI 0x4000 /* ring */
+#define TIOCM_RNG TIOCM_RI
+#define TIOCM_CD 0x8000 /* carrier detect */
+#define TIOCM_CAR TIOCM_CD
+#define TIOCM_LE 0x0100 /* line enable */
+#define TIOCM_ST 0x0200 /* secondary transmit */
+#define TIOCM_SR 0x0400 /* secondary receive */
+
+#endif
+
+/**************************************************************************/
+/* QNX/Neutrino */
+/**************************************************************************/
+/* This is the Neutrino code for for NTO2.0 and GCC */
+#if defined(__QNXNTO__)
+#include <signal.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <ioctl.h>
+#include <sys/param.h>
+
+/* Warning: by default, the fd_set size is 32 in NTO! */
+#define FD_SETSIZE 256
+#include <sys/select.h>
+
+ /* keyboard types */
+# define KB_84 1
+# define KB_101 2
+# define KB_OTHER 3
+
+# define POSIX_TTY
+
+#endif
+
+/**************************************************************************/
+/* GNU/Hurd */
+/**************************************************************************/
+#if defined(__GNU__)
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <sys/stat.h>
+#include <assert.h>
+
+#define POSIX_TTY
+#define USE_OSMOUSE
+
+#endif /* __GNU__ */
+
+/**************************************************************************/
/* Generic */
/**************************************************************************/
+#include <sys/wait.h> /* May need to adjust this for other OSs */
+
/*
* Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
* and it's safe, so just do it.
@@ -518,6 +727,10 @@ double RInt(
);
#endif
+#ifndef DEV_MEM
+#define DEV_MEM "/dev/mem"
+#endif
+
#ifndef VT_SYSREQ_DEFAULT
#define VT_SYSREQ_DEFAULT FALSE
#endif
@@ -528,6 +741,13 @@ double RInt(
# endif
#endif
+#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
+
+#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
+#ifndef NO_COMPILER_H
+#include "compiler.h"
+#endif
+
#endif /* _XF86_OSLIB_H */
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 9f5c49e27..4f067d5e0 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -1,4 +1,3 @@
-/* $Xorg: xf86_OSproc.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */
/*
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1992 by David Dawes <dawes@XFree86.org>
@@ -9,7 +8,7 @@
* Copyright 1993 by Vrije Universiteit, The Netherlands
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
* Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
- * Copyright 1994, 1995 by The XFree86 Project, Inc
+ * Copyright 1994-1999 by The XFree86 Project, Inc
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -32,36 +31,99 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.0.2.1 1998/02/07 14:27:24 dawes Exp $ */
+/*
+ * 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.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.55 2002/01/25 21:56:17 tsi Exp $ */
#ifndef _XF86_OSPROC_H
#define _XF86_OSPROC_H
+#ifdef XF86_OS_PRIVS
+#include "xf86Pci.h"
+#endif
+
/*
* The actual prototypes have been pulled into this seperate file so
* that they can can be used without pulling in all of the OS specific
* stuff like sys/stat.h, etc. This casues problem for loadable modules.
*/
-/* The Region arg to xf86[Un]Map* */
-#define NUM_REGIONS 4
-#define VGA_REGION 0
-#define LINEAR_REGION 1
-#define EXTENDED_REGION 2
-#define MMIO_REGION 3
+/*
+ * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The
+ * flags may be used as hints. For example it would be permissible to
+ * enable write combining for memory marked only for framebuffer use.
+ */
+
+#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */
+#define VIDMEM_MMIO 0x02 /* memory for I/O use */
+#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */
+#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */
+#define VIDMEM_SPARSE 0x10 /* sparse mapping required
+ * assumed when VIDMEM_MMIO is
+ * set. May be used with
+ * VIDMEM_FRAMEBUFFER) */
+#define VIDMEM_READONLY 0x20 /* read-only mapping
+ * used when reading BIOS images
+ * through xf86MapVidMem() */
+
+/*
+ * OS-independent modem state flags for xf86SetSerialModemState() and
+ * xf86GetSerialModemState().
+ */
+#define XF86_M_LE 0x001 /* line enable */
+#define XF86_M_DTR 0x002 /* data terminal ready */
+#define XF86_M_RTS 0x004 /* request to send */
+#define XF86_M_ST 0x008 /* secondary transmit */
+#define XF86_M_SR 0x010 /* secondary receive */
+#define XF86_M_CTS 0x020 /* clear to send */
+#define XF86_M_CAR 0x040 /* carrier detect */
+#define XF86_M_RNG 0x080 /* ring */
+#define XF86_M_DSR 0x100 /* data set ready */
+
+#ifdef XF86_OS_PRIVS
+extern void xf86WrapperInit(void);
+#endif
#ifndef NO_OSLIB_PROTOTYPES
/*
* This is to prevent re-entrancy to FatalError() when aborting.
* Anything that can be called as a result of AbortDDX() should use this
- * instead of FatalError(). (xf86Exiting gets set to TRUE the first time
- * AbortDDX() is called.)
+ * instead of FatalError().
*/
-extern Bool xf86Exiting;
-
#define xf86FatalError(a, b) \
- if (xf86Exiting) { \
+ if (dispatchException & DE_TERMINATE) { \
ErrorF(a, b); \
return; \
} else FatalError(a, b)
@@ -71,322 +133,134 @@ extern Bool xf86Exiting;
/***************************************************************************/
#include <X11/Xfuncproto.h>
+#include "opaque.h"
_XFUNCPROTOBEGIN
-/* xf86_Util.c */
-extern int StrCaseCmp(
-#if NeedFunctionPrototypes
- const char *,
- const char *
-#endif
-);
+/* public functions */
+extern Bool xf86LinearVidMem(void);
+extern Bool xf86CheckMTRR(int);
+extern pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
+extern void xf86UnMapVidMem(int, pointer, unsigned long);
+extern void xf86MapReadSideEffects(int, int, pointer, unsigned long);
+extern int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
+extern void xf86EnableIO(void);
+extern void xf86DisableIO(void);
+extern Bool xf86DisableInterrupts(void);
+extern void xf86EnableInterrupts(void);
+extern void xf86SetTVOut(int);
+extern void xf86SetRGBOut(void);
+extern void xf86SoundKbdBell(int, int, int);
+#if defined(QNX4)
+#pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi];
+#pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi];
+#endif
+extern void xf86BusToMem(unsigned char *, unsigned char *, int);
+extern void xf86MemToBus(unsigned char *, unsigned char *, int);
+extern void xf86IODelay(void);
+extern void xf86UDelay(long usec);
+extern void xf86SlowBcopy(unsigned char *, unsigned char *, int);
+extern int xf86OpenSerial(pointer options);
+extern int xf86SetSerial(int fd, pointer options);
+extern int xf86SetSerialSpeed(int fd, int speed);
+extern int xf86ReadSerial(int fd, void *buf, int count);
+extern int xf86WriteSerial(int fd, const void *buf, int count);
+extern int xf86CloseSerial(int fd);
+extern int xf86FlushInput(int fd);
+extern int xf86WaitForInput(int fd, int timeout);
+extern int xf86SerialSendBreak(int fd, int duration);
+extern int xf86SetSerialModemState(int fd, int state);
+extern int xf86GetSerialModemState(int fd);
+extern int xf86SerialModemSetBits(int fd, int bits);
+extern int xf86SerialModemClearBits(int fd, int bits);
+extern int xf86LoadKernelModule(const char *pathname);
-/* OS-support layer */
-extern void xf86OpenConsole(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86CloseConsole(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern Bool xf86VTSwitchPending(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern Bool xf86VTSwitchAway(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern Bool xf86VTSwitchTo(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern Bool xf86LinearVidMem(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern pointer xf86MapVidMem(
-#if NeedFunctionPrototypes
- int,
- int,
- pointer,
- unsigned long
-#endif
-);
-extern void xf86UnMapVidMem(
-#if NeedFunctionPrototypes
- int,
- int,
- pointer,
- unsigned long
-#endif
-);
-#if defined(__alpha__)
-/* entry points for SPARSE memory access routines */
-extern pointer xf86MapVidMemSparse(
-#if NeedFunctionPrototypes
- int,
- int,
- pointer,
- unsigned long
-#endif
-);
-extern void xf86UnMapVidMemSparse(
-#if NeedFunctionPrototypes
- int,
- int,
- pointer,
- unsigned long
-#endif
-);
-extern int xf86ReadSparse8(
-#if NeedFunctionPrototypes
- pointer,
- unsigned long
-#endif
-);
-extern int xf86ReadSparse16(
-#if NeedFunctionPrototypes
- pointer,
- unsigned long
-#endif
-);
-extern int xf86ReadSparse32(
-#if NeedFunctionPrototypes
- pointer,
- unsigned long
-#endif
-);
-extern void xf86WriteSparse8(
-#if NeedFunctionPrototypes
- int,
- pointer,
- unsigned long
-#endif
-);
-extern void xf86WriteSparse16(
-#if NeedFunctionPrototypes
- int,
- pointer,
- unsigned long
-#endif
-);
-extern void xf86WriteSparse32(
-#if NeedFunctionPrototypes
- int,
- pointer,
- unsigned long
-#endif
-);
-#endif /* __alpha__ */
-extern void xf86MapDisplay(
-#if NeedFunctionPrototypes
- int,
- int
-#endif
-);
-extern void xf86UnMapDisplay(
-#if NeedFunctionPrototypes
- int,
- int
-#endif
-);
-extern int xf86ReadBIOS(
-#if NeedFunctionPrototypes
- unsigned long,
- unsigned long,
- unsigned char *,
- int
-#endif
-);
-extern void xf86ClearIOPortList(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-extern void xf86AddIOPorts(
-#if NeedFunctionPrototypes
- int,
- int,
- unsigned *
-#endif
-);
-void xf86EnableIOPorts(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-void xf86DisableIOPorts(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-void xf86DisableIOPrivs(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern Bool xf86DisableInterrupts(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86EnableInterrupts(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern int xf86ProcessArgument(
-#if NeedFunctionPrototypes
- int,
- char **,
- int
-#endif
-);
-extern void xf86UseMsg(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86SoundKbdBell(
-#if NeedFunctionPrototypes
- int,
- int,
- int
-#endif
-);
-extern void xf86SetKbdLeds(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-extern int xf86GetKbdLeds(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86SetKbdRepeat(
-#if NeedFunctionPrototypes
- char
-#endif
-);
-extern void xf86KbdInit(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern int xf86KbdOn(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern int xf86KbdOff(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86KbdEvents(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86SetMouseSpeed(
-#if NeedFunctionPrototypes
- MouseDevPtr,
- int,
- int,
- unsigned
-#endif
-);
-extern void xf86MouseInit(
-#if NeedFunctionPrototypes
- MouseDevPtr
-#endif
-);
-extern int xf86MouseOn(
-#if NeedFunctionPrototypes
- MouseDevPtr
-#endif
-);
-extern int xf86MouseOff(
-#if NeedFunctionPrototypes
- MouseDevPtr,
- Bool
-#endif
-);
-extern void xf86MouseEvents(
-#if NeedFunctionPrototypes
- MouseDevPtr
-#endif
-);
-extern int xf86FlushInput(
-#if NeedFunctionPrototypes
- int
-#endif
-);
-extern int xf86XqueKbdProc(
-#if NeedFunctionPrototypes
- DeviceIntPtr,
- int
-#endif
-);
-extern int xf86XqueMseProc(
-#if NeedFunctionPrototypes
- DeviceIntPtr,
- int
-#endif
-);
-extern void xf86XqueEvents(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+/* AGP GART interface */
+typedef struct _AgpInfo {
+ CARD32 bridgeId;
+ CARD32 agpMode;
+ unsigned long base;
+ unsigned long size;
+ unsigned long totalPages;
+ unsigned long systemPages;
+ unsigned long usedPages;
+} AgpInfo, *AgpInfoPtr;
+
+extern Bool xf86AgpGARTSupported(void);
+extern AgpInfoPtr xf86GetAGPInfo(int screenNum);
+extern Bool xf86AcquireGART(int screenNum);
+extern Bool xf86ReleaseGART(int screenNum);
+extern int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical);
+extern Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset);
+extern Bool xf86UnbindGARTMemory(int screenNum, int key);
+extern Bool xf86EnableAGP(int screenNum, CARD32 mode);
+extern Bool xf86GARTCloseScreen(int screenNum);
+
+/* These routines are in shared/sigio.c and are not loaded as part of the
+ module. These routines are small, and the code if very POSIX-signal (or
+ OS-signal) specific, so it seemed better to provide more complex
+ wrappers than to wrap each individual function called. */
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+extern int xf86BlockSIGIO (void);
+extern void xf86UnblockSIGIO (int);
+#ifdef XFree86Server
+extern void xf86AssertBlockedSIGIO (char *);
+#endif
+extern Bool xf86SIGIOSupported (void);
+
+#ifdef XF86_OS_PRIVS
+typedef void (*PMClose)(void);
+extern void xf86OpenConsole(void);
+extern void xf86CloseConsole(void);
+extern Bool xf86VTSwitchPending(void);
+extern Bool xf86VTSwitchAway(void);
+extern Bool xf86VTSwitchTo(void);
+extern void xf86VTRequest(int sig);
+extern int xf86ProcessArgument(int, char **, int);
+extern void xf86UseMsg(void);
+extern void xf86SetKbdLeds(int);
+extern int xf86GetKbdLeds(void);
+extern void xf86SetKbdRepeat(char);
+extern void xf86KbdInit(void);
+extern int xf86KbdOn(void);
+extern int xf86KbdOff(void);
+extern void xf86KbdEvents(void);
+#ifdef XQUEUE
+extern int xf86XqueKbdProc(DeviceIntPtr, int);
+extern void xf86XqueEvents(void);
+#endif
+#ifdef WSCONS_SUPPORT
+extern void xf86WSKbdEvents(void);
+#endif
+extern PMClose xf86OSPMOpen(void);
+
+#ifdef NEED_OS_RAC_PROTOS
+/* RAC-related privs */
+/* internal to os-support layer */
+resPtr xf86StdBusAccWindowsFromOS(void);
+resPtr xf86StdPciAccWindowsFromOS(void);
+resPtr xf86StdIsaAccWindowsFromOS(void);
+resPtr xf86StdAccResFromOS(resPtr ret);
+
+/* available to the common layer */
+resPtr xf86BusAccWindowsFromOS(void);
+resPtr xf86PciBusAccWindowsFromOS(void);
+#ifdef INCLUDE_UNUSED
+resPtr xf86IsaBusAccWindowsFromOS(void);
+#endif
+resPtr xf86AccResFromOS(resPtr ret);
+#endif /* NEED_OS_RAC_PROTOS */
+
+extern Bool xf86GetPciSizeFromOS(PCITAG tag, int indx, int* bits);
+
+extern void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
+extern void xf86InitVidMem(void);
+
+#endif /* XF86_OS_PRIVS */
-/* These are privates */
-extern void xf86InitPortLists(
-#if NeedFunctionPrototypes
- unsigned **,
- int *,
- Bool *,
- Bool *,
- int
-#endif
-);
-extern Bool xf86CheckPorts(
-#if NeedFunctionPrototypes
- unsigned,
- unsigned **,
- int *,
- Bool *,
- int
-#endif
-);
-extern int xf86OsMouseProc(
-#if NeedFunctionPrototypes
- DeviceIntPtr,
- int
-#endif
-);
-extern void xf86OsMouseEvents(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void xf86OsMouseOption(
-#if NeedFunctionPrototypes
- int,
- pointer /* gets cast to LexPtr later, saves include file hassles */
-#endif
-);
_XFUNCPROTOEND
#endif /* NO_OSLIB_PROTOTYPES */