summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/vfb/InitInput.c7
-rw-r--r--hw/vfb/InitOutput.c129
-rw-r--r--hw/vfb/Xvfb.man.pre11
-rw-r--r--hw/xfree86/common/atKeynames.h159
-rw-r--r--hw/xfree86/common/compiler.h2367
-rw-r--r--hw/xfree86/common/xf86.h1080
-rw-r--r--hw/xfree86/common/xf86Config.c5588
-rw-r--r--hw/xfree86/common/xf86Cursor.c750
-rw-r--r--hw/xfree86/common/xf86Events.c1655
-rw-r--r--hw/xfree86/common/xf86Init.c1804
-rw-r--r--hw/xfree86/common/xf86Io.c304
-rw-r--r--hw/xfree86/common/xf86Kbd.c111
-rw-r--r--hw/xfree86/common/xf86KbdBSD.c896
-rw-r--r--hw/xfree86/common/xf86KbdLnx.c142
-rw-r--r--hw/xfree86/common/xf86KbdMach.c9
-rw-r--r--hw/xfree86/common/xf86Keymap.h356
-rw-r--r--hw/xfree86/common/xf86Priv.h321
-rw-r--r--hw/xfree86/common/xf86Version.h38
-rw-r--r--hw/xfree86/common/xf86XKB.c79
-rw-r--r--hw/xfree86/common/xf86Xinput.c1150
-rw-r--r--hw/xfree86/common/xf86Xinput.h379
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c1952
-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
-rw-r--r--hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c5
-rw-r--r--hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre6
-rw-r--r--hw/xfree86/utils/kbd_mode/sun-kbd_mode.c12
-rw-r--r--hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre5
-rw-r--r--hw/xfree86/utils/scanpci/scanpci.c2355
-rw-r--r--hw/xfree86/utils/xorgconfig/Cards1439
-rw-r--r--hw/xfree86/utils/xorgconfig/cards.c59
-rw-r--r--hw/xfree86/utils/xorgconfig/cards.h14
-rw-r--r--hw/xnest/Color.c2
-rw-r--r--hw/xnest/Cursor.c4
-rw-r--r--hw/xnest/Display.c9
-rw-r--r--hw/xnest/Display.h3
-rw-r--r--hw/xnest/Drawable.h3
-rw-r--r--hw/xnest/Events.c5
-rw-r--r--hw/xnest/Font.c2
-rw-r--r--hw/xnest/GC.c12
-rw-r--r--hw/xnest/GCOps.c2
-rw-r--r--hw/xnest/Handlers.c3
-rw-r--r--hw/xnest/Init.c40
-rw-r--r--hw/xnest/Keyboard.c135
-rw-r--r--hw/xnest/Pixmap.c16
-rw-r--r--hw/xnest/Screen.c56
-rw-r--r--hw/xnest/TestExt.c9
-rw-r--r--hw/xnest/Window.c14
-rw-r--r--hw/xnest/Xnest.h5
-rw-r--r--hw/xnest/Xnest.man.pre5
82 files changed, 17598 insertions, 14466 deletions
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 255c56f8e..71d879fa7 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -26,9 +26,11 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitInput.c,v 3.9 2001/12/14 19:59:45 dawes Exp $ */
#include "X11/X.h"
#define NEED_EVENTS
+#include "mi.h"
#include "X11/Xproto.h"
#include "scrnintstr.h"
#include "inputstr.h"
@@ -261,7 +263,6 @@ vfbKeybdProc(pDevice, onoff)
{
KeySymsRec keySyms;
CARD8 modMap[MAP_LENGTH];
- int i;
DevicePtr pDev = (DevicePtr)pDevice;
switch (onoff)
@@ -320,13 +321,13 @@ InitInput(argc, argv)
int argc;
char *argv[];
{
- DevicePtr p, k;
+ DeviceIntPtr p, k;
p = AddInputDevice(vfbMouseProc, TRUE);
k = AddInputDevice(vfbKeybdProc, TRUE);
RegisterPointerDevice(p);
RegisterKeyboardDevice(k);
miRegisterPointerDevice(screenInfo.screens[0], p);
- (void)mieqInit (k, p);
+ (void)mieqInit ((DevicePtr) k, (DevicePtr) p);
}
#ifdef XTESTEXT1
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index c2334e745..378728c0c 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -26,8 +26,9 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitOutput.c,v 3.22 2003/01/15 02:34:07 torrey Exp $ */
-#ifdef WIN32
+#if defined(WIN32)
#include <X11/Xwinsock.h>
#endif
#include <stdio.h>
@@ -38,7 +39,7 @@ from The Open Group.
#include "scrnintstr.h"
#include "servermd.h"
#define PSZ 8
-#include "cfb.h"
+#include "fb.h"
#include "mibstore.h"
#include "colormapst.h"
#include "gcstruct.h"
@@ -63,6 +64,7 @@ from The Open Group.
#endif /* HAS_SHM */
#include "dix.h"
#include "miline.h"
+#include "mfb.h"
extern char *display;
@@ -104,11 +106,14 @@ typedef struct
static int vfbNumScreens;
static vfbScreenInfo vfbScreens[MAXSCREENS];
static Bool vfbPixmapDepths[33];
+#ifdef HAS_MMAP
static char *pfbdir = NULL;
+#endif
typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType;
static fbMemType fbmemtype = NORMAL_MEMORY_FB;
static char needswap = 0;
static int lastScreen = -1;
+static Bool Render = TRUE;
#define swapcopy16(_dst, _src) \
if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \
@@ -178,6 +183,9 @@ ddxGiveUp()
}
}
break;
+#else /* HAS_MMAP */
+ case MMAPPED_FILE_FB:
+ break;
#endif /* HAS_MMAP */
#ifdef HAS_SHM
@@ -191,6 +199,9 @@ ddxGiveUp()
}
}
break;
+#else /* HAS_SHM */
+ case SHARED_MEMORY_FB:
+ break;
#endif /* HAS_SHM */
case NORMAL_MEMORY_FB:
@@ -208,16 +219,48 @@ AbortDDX()
ddxGiveUp();
}
+#ifdef __DARWIN__
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+
+void GlxExtensionInit();
+void GlxWrapInitVisuals(void *procPtr);
+
+void
+DarwinGlxExtensionInit()
+{
+ GlxExtensionInit();
+}
+
+void
+DarwinGlxWrapInitVisuals(
+ void *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+#endif
+
void
OsVendorInit()
{
}
void
+OsVendorFatalError()
+{
+}
+
+void
ddxUseMsg()
{
ErrorF("-screen scrn WxHxD set screen's width, height, depth\n");
ErrorF("-pixdepths list-of-int support given pixmap depths\n");
+#ifdef RENDER
+ ErrorF("+/-render turn on/of RENDER extension support"
+ "(default on)\n");
+#endif
ErrorF("-linebias n adjust thin line pixelization\n");
ErrorF("-blackpixel n pixel value for black\n");
ErrorF("-whitepixel n pixel value for white\n");
@@ -289,6 +332,18 @@ ddxProcessArgument (argc, argv, i)
return ret;
}
+ if (strcmp (argv[i], "+render") == 0) /* +render */
+ {
+ Render = TRUE;
+ return 1;
+ }
+
+ if (strcmp (argv[i], "-render") == 0) /* -render */
+ {
+ Render = FALSE;
+ return 1;
+ }
+
if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
{
Pixel pix;
@@ -389,9 +444,9 @@ vfbMultiDepthCreateGC(pGC)
switch (vfbBitsPerPixel(pGC->depth))
{
case 1: return mfbCreateGC (pGC);
- case 8: return cfbCreateGC (pGC);
- case 16: return cfb16CreateGC (pGC);
- case 32: return cfb32CreateGC (pGC);
+ case 8:
+ case 16:
+ case 32: return fbCreateGC (pGC);
default: return FALSE;
}
}
@@ -410,13 +465,9 @@ vfbMultiDepthGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
break;
case 8:
- cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- break;
case 16:
- cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- break;
case 32:
- cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
break;
}
return;
@@ -436,13 +487,9 @@ vfbMultiDepthGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
break;
case 8:
- cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
- break;
case 16:
- cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
- break;
case 32:
- cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ fbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
break;
}
}
@@ -546,21 +593,32 @@ vfbStoreColors(pmap, ndef, pdefs)
XWDColor *pXWDCmap;
int i;
- if (pmap != InstalledMaps[pmap->pScreen->myNum]) return;
+ if (pmap != InstalledMaps[pmap->pScreen->myNum])
+ {
+ return;
+ }
pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap;
if ((pmap->pVisual->class | DynamicClass) == DirectColor)
+ {
return;
+ }
for (i = 0; i < ndef; i++)
{
if (pdefs[i].flags & DoRed)
+ {
swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red);
+ }
if (pdefs[i].flags & DoGreen)
+ {
swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green);
+ }
if (pdefs[i].flags & DoBlue)
+ {
swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue);
+ }
}
}
@@ -649,7 +707,7 @@ vfbAllocateMmappedFramebuffer(pvfb)
PROT_READ|PROT_WRITE,
MAP_FILE|MAP_SHARED,
pvfb->mmap_fd, 0);
- if (-1 == (int)pvfb->pXWDHeader)
+ if (-1 == (long)pvfb->pXWDHeader)
{
perror("mmap");
ErrorF("mmap %s failed, errno %d", pvfb->mmap_file, errno);
@@ -684,7 +742,7 @@ vfbAllocateSharedMemoryFramebuffer(pvfb)
/* try to attach it */
pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0);
- if (-1 == (int)pvfb->pXWDHeader)
+ if (-1 == (long)pvfb->pXWDHeader)
{
perror("shmat");
ErrorF("shmat failed, errno %d", errno);
@@ -735,10 +793,14 @@ vfbAllocateFramebufferMemory(pvfb)
{
#ifdef HAS_MMAP
case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break;
+#else
+ case MMAPPED_FILE_FB: break;
#endif
#ifdef HAS_SHM
case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break;
+#else
+ case SHARED_MEMORY_FB: break;
#endif
case NORMAL_MEMORY_FB:
@@ -751,6 +813,7 @@ vfbAllocateFramebufferMemory(pvfb)
pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader
+ SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN);
pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors);
+
return pvfb->pfbMemory;
}
else
@@ -765,7 +828,6 @@ vfbWriteXWDFileHeader(pScreen)
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
XWDFileHeader *pXWDHeader = pvfb->pXWDHeader;
char hostname[XWD_WINDOW_NAME_LEN];
- VisualPtr pVisual;
unsigned long swaptest = 1;
int i;
@@ -867,6 +929,8 @@ vfbScreenInit(index, pScreen, argc, argv)
pbits = vfbAllocateFramebufferMemory(pvfb);
if (!pbits) return FALSE;
+ /* miSetPixmapDepths ();*/
+
switch (pvfb->bitsPerPixel)
{
case 1:
@@ -874,16 +938,14 @@ vfbScreenInit(index, pScreen, argc, argv)
dpix, dpiy, pvfb->paddedWidth * 8);
break;
case 8:
- ret = cfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpix, dpiy, pvfb->paddedWidth);
- break;
case 16:
- ret = cfb16ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpix, dpiy, pvfb->paddedWidth);
- break;
case 32:
- ret = cfb32ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpix, dpiy, pvfb->paddedWidth);
+ ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+ dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
+#ifdef RENDER
+ if (ret && Render)
+ fbPictureInit (pScreen, 0, 0);
+#endif
break;
default:
return FALSE;
@@ -891,6 +953,12 @@ vfbScreenInit(index, pScreen, argc, argv)
if (!ret) return FALSE;
+ miInitializeBackingStore(pScreen);
+
+ /*
+ * Circumvent the backing store that was just initialised. This amounts
+ * to a truely bizarre way of initialising SaveDoomedAreas and friends.
+ */
pScreen->CreateGC = vfbMultiDepthCreateGC;
pScreen->GetImage = vfbMultiDepthGetImage;
pScreen->GetSpans = vfbMultiDepthGetSpans;
@@ -915,7 +983,7 @@ vfbScreenInit(index, pScreen, argc, argv)
}
else
{
- ret = cfbCreateDefColormap(pScreen);
+ ret = fbCreateDefColormap(pScreen);
}
miSetZeroLineBias(pScreen, pvfb->lineBias);
@@ -933,7 +1001,6 @@ InitOutput(screenInfo, argc, argv)
{
int i;
int NumFormats = 0;
- FILE *pf = stderr;
/* initialize pixmap formats */
@@ -943,6 +1010,10 @@ InitOutput(screenInfo, argc, argv)
vfbPixmapDepths[vfbScreens[i].depth] = TRUE;
}
+ /* for RENDER we need 32bpp */
+ if (Render)
+ vfbPixmapDepths[32] = TRUE;
+
for (i = 1; i <= 32; i++)
{
if (vfbPixmapDepths[i])
diff --git a/hw/vfb/Xvfb.man.pre b/hw/vfb/Xvfb.man.pre
index 3d8d86156..e3e255298 100644
--- a/hw/vfb/Xvfb.man.pre
+++ b/hw/vfb/Xvfb.man.pre
@@ -22,7 +22,10 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
-.TH XVFB 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.9 2001/12/14 19:59:45 dawes Exp $
+.\"
+.TH XVFB 1 __xorgversion__
.SH NAME
Xvfb \- virtual framebuffer X server for X Version 11
.SH SYNOPSIS
@@ -46,9 +49,9 @@ that don't really need an X server but insist on having one anyway.
.SH BUILDING
To build \fIXvfb\fP, put the following in your host.def and remake.
.PP
-#define BuildServer YES /* if you aren't already building other servers */
+\&#define BuildServer YES /* if you aren't already building other servers */
.br
-#define XVirtualFramebufferServer YES
+\&#define XVirtualFramebufferServer YES
.SH OPTIONS
.PP
@@ -123,6 +126,6 @@ xwud -in /usr/tmp/Xvfb_screen0
Displays screen 0 of the server started by the preceding example.
.SH "SEE ALSO"
.PP
-X(1), Xserver(1), xwd(1), xwud(1), XWDFile.h
+X(__miscmansuffix__), Xserver(1), xwd(1), xwud(1), XWDFile.h
.SH AUTHORS
David P. Wiggins, The Open Group, Inc.
diff --git a/hw/xfree86/common/atKeynames.h b/hw/xfree86/common/atKeynames.h
index 24ae59a30..23760db5e 100644
--- a/hw/xfree86/common/atKeynames.h
+++ b/hw/xfree86/common/atKeynames.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.9 1996/12/23 06:43:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.18 2001/09/29 20:40:30 herrb Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,7 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: atKeynames.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
#ifndef _ATKEYNAMES_H
#define _ATKEYNAMES_H
@@ -29,13 +29,12 @@
#define XK_TECHNICAL
#define XK_KATAKANA
#include "keysym.h"
+#include "XF86keysym.h"
#define GLYPHS_PER_KEY 4
-#define NUM_KEYCODES 150
-#define NUM_STD_KEYCODES 127
+#define NUM_KEYCODES 248
#define MIN_KEYCODE 8
#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
-#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1)
#define AltMask Mod1Mask
#define NumLockMask Mod2Mask
@@ -46,8 +45,6 @@
#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
#define ModifierDown(k) ((keyc->state & (k)) == (k))
-#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */
-
/*
* NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
* sets of scancodes. Set3 can only be generated by a MF keyboard.
@@ -72,8 +69,6 @@
* ---------------- ---------- ------- ------ ------
*/
-#ifndef PC98
-
#define KEY_Escape /* Escape 0x01 */ 1
#define KEY_1 /* 1 ! 0x02 */ 2
#define KEY_2 /* 2 @ 0x03 */ 3
@@ -185,7 +180,7 @@
#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
#define KEY_Pause /* Pause 0x66 */ 102
#define KEY_Print /* Print 0x67 */ 103
-#define KEY_KP_Divide /* Didive 0x68 */ 104
+#define KEY_KP_Divide /* Divide 0x68 */ 104
#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
#define KEY_Break /* Break 0x6a */ 106
#define KEY_LMeta /* Left Meta 0x6b */ 107
@@ -194,142 +189,18 @@
#define KEY_F13 /* F13 0x6e */ 110
#define KEY_F14 /* F14 0x6f */ 111
#define KEY_F15 /* F15 0x70 */ 112
+#define KEY_HKTG /* Hirugana/Katakana tog 0x70 */ 112
#define KEY_F16 /* F16 0x71 */ 113
#define KEY_F17 /* F17 0x72 */ 114
#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
-#define KEY_SN_KP_7 /* ServerNumLock 7 0x80 */ 128
-#define KEY_SN_KP_8 /* ServerNumLock 8 0x81 */ 129
-#define KEY_SN_KP_9 /* ServerNumLock 9 0x82 */ 130
-#define KEY_SN_KP_4 /* ServerNumLock 4 0x83 */ 131
-#define KEY_SN_KP_5 /* ServerNumLock 5 0x84 */ 132
-#define KEY_SN_KP_6 /* ServerNumLock 6 0x85 */ 133
-#define KEY_SN_KP_1 /* ServerNumLock 1 0x86 */ 134
-#define KEY_SN_KP_2 /* ServerNumLock 2 0x87 */ 135
-#define KEY_SN_KP_3 /* ServerNumLock 4 0x88 */ 136
-#define KEY_SN_KP_0 /* ServerNumLock 0 0x89 */ 137
-#define KEY_SN_KP_Dec /* ServerNumLock Decimal 0x8a */ 138
-#define KEY_SN_KP_Home /* ServerNumLock Home 0x8b */ 139
-#define KEY_SN_KP_Up /* ServerNumLock Up 0x8c */ 140
-#define KEY_SN_KP_Prior /* ServerNumLock Prior 0x8d */ 141
-#define KEY_SN_KP_Left /* ServerNumLock Left 0x8e */ 142
-#define KEY_SN_KP_Begin /* ServerNumLock Begin 0x8f */ 143
-#define KEY_SN_KP_Right /* ServerNumLock Right 0x90 */ 144
-#define KEY_SN_KP_End /* ServerNumLock End 0x91 */ 145
-#define KEY_SN_KP_Down /* ServerNumLock Down 0x92 */ 146
-#define KEY_SN_KP_Next /* ServerNumLock Next 0x93 */ 147
-#define KEY_SN_KP_Ins /* ServerNumLock Ins 0x94 */ 148
-#define KEY_SN_KP_Del /* ServerNumLock Del 0x95 */ 149
-
-#else
-
-#define KEY_Escape /* Escape 0x01 */ 0
-#define KEY_1 /* 1 ! 0x02 */ 1
-#define KEY_2 /* 2 " 0x03 */ 2
-#define KEY_3 /* 3 # 0x04 */ 3
-#define KEY_4 /* 4 $ 0x05 */ 4
-#define KEY_5 /* 5 % 0x06 */ 5
-#define KEY_6 /* 6 & 0x07 */ 6
-#define KEY_7 /* 7 ' 0x08 */ 7
-#define KEY_8 /* 8 ( 0x09 */ 8
-#define KEY_9 /* 9 ) 0x0a */ 9
-#define KEY_0 /* 0 0x0b */ 10
-#define KEY_Minus /* - (Minus) = (Equal) 0x0c */ 11
-#define KEY_Hat /* ^ (Hat) ` 0x0d */ 12
-#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 13
-#define KEY_BackSpace /* Back Space 0x0e */ 14
-#define KEY_Tab /* Tab 0x0f */ 15
-#define KEY_Q /* Q 0x10 */ 16
-#define KEY_W /* W 0x11 */ 17
-#define KEY_E /* E 0x12 */ 18
-#define KEY_R /* R 0x13 */ 19
-#define KEY_T /* T 0x14 */ 20
-#define KEY_Y /* Y 0x15 */ 21
-#define KEY_U /* U 0x16 */ 22
-#define KEY_I /* I 0x17 */ 23
-#define KEY_O /* O 0x18 */ 24
-#define KEY_P /* P 0x19 */ 25
-#define KEY_At /* @ ~ 0x1a */ 26
-#define KEY_LBrace /* [ { 0x1b */ 27
-#define KEY_Enter /* Enter 0x1c */ 28
-#define KEY_A /* A 0x1d */ 29
-#define KEY_S /* S 0x1e */ 30
-#define KEY_D /* D 0x1f */ 31
-#define KEY_F /* F 0x20 */ 32
-#define KEY_G /* G 0x21 */ 33
-#define KEY_H /* H 0x22 */ 34
-#define KEY_J /* J 0x23 */ 35
-#define KEY_K /* K 0x24 */ 36
-#define KEY_L /* L 0x25 */ 37
-#define KEY_SemiColon /* ;(SemiColon) +(Plus) 0x26 */ 38
-#define KEY_Colon /* :(Colon) *(Quote) 0x27 */ 39
-#define KEY_RBrace /* ] } 0x28 */ 40
-#define KEY_Z /* Z 0x29 */ 41
-#define KEY_X /* X 0x2a */ 42
-#define KEY_C /* C 0x2b */ 43
-#define KEY_V /* V 0x2c */ 44
-#define KEY_B /* B 0x2d */ 45
-#define KEY_N /* N 0x2e */ 46
-#define KEY_M /* M 0x2f */ 47
-#define KEY_Comma /* , (Comma) < (Less) 0x30 */ 48
-#define KEY_Period /* . (Period) >(Greater)0x31 */ 49
-#define KEY_Slash /* / (Slash) ? 0x32 */ 50
-#define KEY_Under /* _ 0x33 */ 51
-#define KEY_Space /* (SpaceBar) 0x34 */ 52
-#define KEY_Xfer /* (XFER) 0x35 */ 53
-#define KEY_PgUp /* PgUp 0x36 */ 54
-#define KEY_Pgdown /* (Roll Down) 0x37 */ 55
-#define KEY_Insert /* Insert 0x38 */ 56
-#define KEY_Delete /* Delete 0x39 */ 57
-#define KEY_Up /* Up 0x3a */ 58
-#define KEY_Left /* Left 0x3b */ 59
-#define KEY_Right /* Right 0x3c */ 60
-#define KEY_Down /* Down 0x3d */ 61
-#define KEY_Home /* Home 0x3e */ 62
-#define KEY_Help /* Help 0x3f */ 63
-#define KEY_KP_Subtract /* - (Minus) 0x40 */ 64
-#define KEY_KP_Minus /* - */ 64
-#define KEY_KP_Divide /* / (Slash) 0x41 */ 65
-#define KEY_KP_7 /* 7 0x42 */ 66
-#define KEY_KP_8 /* 8 0x43 */ 67
-#define KEY_KP_9 /* 9 0x44 */ 68
-#define KEY_KP_Multiply /* * 0x45 */ 69
-#define KEY_KP_4 /* 4 0x46 */ 70
-#define KEY_KP_5 /* 5 0x47 */ 71
-#define KEY_KP_6 /* 6 0x48 */ 72
-#define KEY_KP_Add /* + (Plus) 0x49 */ 73
-#define KEY_KP_Plus /* + */ 73
-#define KEY_KP_1 /* 1 0x4a */ 74
-#define KEY_KP_2 /* 2 0x4b */ 75
-#define KEY_KP_3 /* 3 0x4c */ 76
-#define KEY_KP_Equal /* = 0x4d */ 77
-#define KEY_KP_0 /* 0 0x4e */ 78
-#define KEY_KP_Separator /* , 0x4f */ 79
-#define KEY_KP_Decimal /* . (Decimal) 0x50 */ 80
-#define KEY_Nfer /* (NFER) 0x51 */ 81
-#define KEY_F11 /* F11 0x52 */ 82
-#define KEY_F12 /* F12 0x53 */ 83
-#define KEY_F13 /* F13 0x54 */ 84
-#define KEY_F14 /* F14 0x55 */ 85
-#define KEY_F15 /* F15 0x56 */ 86
-#define KEY_Break /* (Stop) 0x60 */ 96
-#define KEY_Copy /* (Copy) 0x61 */ 97
-#define KEY_Begin /* Begin ?? */ 97
-#define KEY_F1 /* F1 0x62 */ 98
-#define KEY_F2 /* F2 0x63 */ 99
-#define KEY_F3 /* F3 0x64 */ 100
-#define KEY_F4 /* F4 0x65 */ 101
-#define KEY_F5 /* F5 0x66 */ 102
-#define KEY_F6 /* F6 0x67 */ 103
-#define KEY_F7 /* F7 0x68 */ 104
-#define KEY_F8 /* F8 0x69 */ 105
-#define KEY_F9 /* F9 0x6a */ 106
-#define KEY_F10 /* F10 0x6b */ 107
-#define KEY_ShiftL /* Shift(left) 0x70 */ 112
-#define KEY_CapsLock /* CapsLock 0x71 */ 113
-#define KEY_KanaLock /* Kana 0x72 */ 114
-#define KEY_Alt /* Alt(left) 0x73 */ 115
-#define KEY_LCtrl /* Ctrl(left) 0x74 */ 116
-
-#endif /* PC98 */
+#define KEY_BSlash2 /* \ _ 0x73 */ 115
+#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118
+#define KEY_XFER /* Kanji Transfer 0x79 */ 121
+#define KEY_NFER /* No Kanji Transfer 0x7b */ 123
+#define KEY_Yen /* Yen 0x7d */ 125
+
+/* These are for "notused" and "unknown" entries in translation maps. */
+#define KEY_NOTUSED 0
+#define KEY_UNKNOWN 255
#endif /* _ATKEYNAMES_H */
diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index f85ecd132..4dda2f6c6 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.2 1998/02/07 00:44:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.99 2003/01/29 15:23:20 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,182 +21,269 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: compiler.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */
+/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
#ifndef _COMPILER_H
-#define _COMPILER_H
-#ifndef __STDC__
-# ifdef signed
-# undef signed
+# if !defined(_XF86_ANSIC_H) && defined(XFree86Module)
+# error missing #include "xf86_ansic.h" before #include "compiler.h"
# endif
-# ifdef volatile
-# undef volatile
-# endif
-# ifdef const
-# undef const
-# endif
-# define signed /**/
-# ifdef __GNUC__
-# define volatile __volatile__
-# define const __const__
-# ifdef PC98
-# undef NO_INLINE
-# endif
-# else
-# define const /**/
-# ifdef PC98
+
+# define _COMPILER_H
+
+/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
+# ifndef __inline__
+# if defined(__GNUC__)
+ /* gcc has __inline__ */
+# elif defined(__HIGHC__)
+# define __inline__ _Inline
+# else
# define __inline__ /**/
# endif
-# endif /* __GNUC__ */
-#endif /* !__STDC__ */
-
-#if defined(IODEBUG) && defined(__GNUC__)
-#define outb RealOutb
-#define outw RealOutw
-#define outl RealOutl
-#define inb RealInb
-#define inw RealInw
-#define inl RealInl
-#endif
+# endif /* __inline__ */
+# ifndef __inline
+# if defined(__GNUC__)
+ /* gcc has __inline */
+# elif defined(__HIGHC__)
+# define __inline _Inline
+# else
+# define __inline /**/
+# endif
+# endif /* __inline */
+
+# if defined(IODEBUG) && defined(__GNUC__)
+# define outb RealOutb
+# define outw RealOutw
+# define outl RealOutl
+# define inb RealInb
+# define inw RealInw
+# define inl RealInl
+# endif
+
+# if defined(QNX4) /* Do this for now to keep Watcom happy */
+# define outb outp
+# define outw outpw
+# define outl outpd
+# define inb inp
+# define inw inpw
+# define inl inpd
+
+/* Define the ffs function for inlining */
+extern int ffs(unsigned long);
+# pragma aux ffs_ = \
+ "bsf edx, eax" \
+ "jnz bits_set" \
+ "xor eax, eax" \
+ "jmp exit1" \
+ "bits_set:" \
+ "mov eax, edx" \
+ "inc eax" \
+ "exit1:" \
+ __parm [eax] \
+ __modify [eax edx] \
+ __value [eax] \
+ ;
+# endif
+
+# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+
+# if !defined(__sparc__) && !defined(__arm32__) \
+ && !(defined(__alpha__) && defined(linux))
+
+extern void outb(unsigned short, unsigned char);
+extern void outw(unsigned short, unsigned short);
+extern void outl(unsigned short, unsigned int);
+extern unsigned int inb(unsigned short);
+extern unsigned int inw(unsigned short);
+extern unsigned int inl(unsigned short);
+
+# else /* __sparc__, __arm32__, __alpha__*/
+
+extern void outb(unsigned long, unsigned char);
+extern void outw(unsigned long, unsigned short);
+extern void outl(unsigned long, unsigned int);
+extern unsigned int inb(unsigned long);
+extern unsigned int inw(unsigned long);
+extern unsigned int inl(unsigned long);
+
+# endif /* __sparc__, __arm32__, __alpha__ */
+
+extern unsigned long ldq_u(unsigned long *);
+extern unsigned long ldl_u(unsigned int *);
+extern unsigned long ldw_u(unsigned short *);
+extern void stq_u(unsigned long, unsigned long *);
+extern void stl_u(unsigned long, unsigned int *);
+extern void stw_u(unsigned long, unsigned short *);
+extern void mem_barrier(void);
+extern void write_mem_barrier(void);
+extern void stl_brx(unsigned long, volatile unsigned char *, int);
+extern void stw_brx(unsigned short, volatile unsigned char *, int);
+extern unsigned long ldl_brx(volatile unsigned char *, int);
+extern unsigned short ldw_brx(volatile unsigned char *, int);
+
+# endif
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && defined(__alpha__)
-#ifdef NO_INLINE
-
-extern void outb();
-extern void outw();
-extern void outl();
-extern unsigned int inb();
-extern unsigned int inw();
-extern unsigned int inl();
-#if NeedFunctionPrototypes
-extern unsigned char rdinx(unsigned short int, unsigned char);
-extern void wrinx(unsigned short int, unsigned char, unsigned char);
-extern void modinx(unsigned short int, unsigned char, unsigned char, unsigned char);
-extern int testrg(unsigned short int, unsigned char);
-extern int testinx2(unsigned short int, unsigned char, unsigned char);
-extern int testinx(unsigned short int, unsigned char);
-#else /* NeedFunctionProtoypes */
-extern unsigned char rdinx();
-extern void wrinx();
-extern void modinx();
-extern int testrg();
-extern int testinx2();
-extern int testinx();
-#endif /* NeedFunctionProtoypes */
-
-#else /* NO_INLINE */
-
-#ifdef __GNUC__
-
-#if defined(linux) && defined(__alpha__)
+# ifdef linux
/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
/* note that the appropriate setup via "ioperm" needs to be done */
/* *before* any inx/outx is done. */
+extern void (*_alpha_outb)(char val, unsigned long port);
static __inline__ void
-outb(port, val)
- unsigned short port;
- char val;
+outb(unsigned long port, unsigned char val)
{
- extern void _outb(char val, unsigned short port);
- _outb(val, port);
+ _alpha_outb(val, port);
}
+extern void (*_alpha_outw)(short val, unsigned long port);
static __inline__ void
-outw(port, val)
- unsigned short port;
- short val;
+outw(unsigned long port, unsigned short val)
{
- extern void _outw(short val, unsigned short port);
- _outw(val, port);
+ _alpha_outw(val, port);
}
+extern void (*_alpha_outl)(int val, unsigned long port);
static __inline__ void
-outl(port, val)
- unsigned short port;
- int val;
+outl(unsigned long port, unsigned int val)
{
- extern void _outl(int val, unsigned short port);
- _outl(val, port);
+ _alpha_outl(val, port);
}
+extern unsigned int (*_alpha_inb)(unsigned long port);
static __inline__ unsigned int
-inb(port)
- unsigned short port;
+inb(unsigned long port)
{
- extern unsigned int _inb(unsigned short port);
- return _inb(port);
+ return _alpha_inb(port);
}
+extern unsigned int (*_alpha_inw)(unsigned long port);
static __inline__ unsigned int
-inw(port)
- unsigned short port;
+inw(unsigned long port)
{
- extern unsigned int _inw(unsigned short port);
- return _inw(port);
+ return _alpha_inw(port);
}
+extern unsigned int (*_alpha_inl)(unsigned long port);
static __inline__ unsigned int
-inl(port)
- unsigned short port;
+inl(unsigned long port)
{
- extern unsigned int _inl(unsigned short port);
- return _inl(port);
+ return _alpha_inl(port);
}
+# endif /* linux */
+
+# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+ && !defined(DO_PROTOTYPES)
+
+/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
+/* inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern void outb(unsigned int port, unsigned char val);
+extern void outw(unsigned int port, unsigned short val);
+extern void outl(unsigned int port, unsigned int val);
+extern unsigned char inb(unsigned int port);
+extern unsigned short inw(unsigned int port);
+extern unsigned int inl(unsigned int port);
+
+# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+
+
+#if defined(__NetBSD__)
+#include <machine/pio.h>
+#endif /* __NetBSD__ */
/*
* inline functions to do unaligned accesses
* from linux/include/asm-alpha/unaligned.h
*/
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads. Define some
+ * packed structures to talk about such things with.
+ */
+
+struct __una_u64 { unsigned long x __attribute__((packed)); };
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+/*
+ * Elemental unaligned loads
+ */
+/* let's try making these things static */
+
static __inline__ unsigned long ldq_u(unsigned long * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
+ return ptr->x;
+# else
unsigned long r1,r2;
__asm__("ldq_u %0,%3\n\t"
"ldq_u %1,%4\n\t"
"extql %0,%2,%0\n\t"
- "extqh %1,%2,%1\n\t"
- "bis %1,%0,%0"
+ "extqh %1,%2,%1"
:"=&r" (r1), "=&r" (r2)
:"r" (r11),
"m" (*r11),
- "m" (*(unsigned long *)(7+(char *) r11)));
- return r1;
+ "m" (*(const unsigned long *)(7+(char *) r11)));
+ return r1 | r2;
+# endif
}
static __inline__ unsigned long ldl_u(unsigned int * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+ return ptr->x;
+# else
unsigned long r1,r2;
__asm__("ldq_u %0,%3\n\t"
"ldq_u %1,%4\n\t"
"extll %0,%2,%0\n\t"
- "extlh %1,%2,%1\n\t"
- "bis %1,%0,%0"
+ "extlh %1,%2,%1"
:"=&r" (r1), "=&r" (r2)
:"r" (r11),
"m" (*r11),
- "m" (*(unsigned long *)(3+(char *) r11)));
- return r1;
+ "m" (*(const unsigned long *)(3+(char *) r11)));
+ return r1 | r2;
+# endif
}
static __inline__ unsigned long ldw_u(unsigned short * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+ return ptr->x;
+# else
unsigned long r1,r2;
__asm__("ldq_u %0,%3\n\t"
"ldq_u %1,%4\n\t"
"extwl %0,%2,%0\n\t"
- "extwh %1,%2,%1\n\t"
- "bis %1,%0,%0"
+ "extwh %1,%2,%1"
:"=&r" (r1), "=&r" (r2)
:"r" (r11),
"m" (*r11),
- "m" (*(unsigned long *)(1+(char *) r11)));
- return r1;
+ "m" (*(const unsigned long *)(1+(char *) r11)));
+ return r1 | r2;
+# endif
}
+/*
+ * Elemental unaligned stores
+ */
+
static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u64 *ptr = (struct __una_u64 *) r11;
+ ptr->x = r5;
+# else
unsigned long r1,r2,r3,r4;
__asm__("ldq_u %3,%1\n\t"
@@ -213,10 +300,15 @@ static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
"=m" (*(unsigned long *)(7+(char *) r11)),
"=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
:"r" (r5), "r" (r11));
+# endif
}
static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u32 *ptr = (struct __una_u32 *) r11;
+ ptr->x = r5;
+# else
unsigned long r1,r2,r3,r4;
__asm__("ldq_u %3,%1\n\t"
@@ -233,10 +325,15 @@ static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
"=m" (*(unsigned long *)(3+(char *) r11)),
"=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
:"r" (r5), "r" (r11));
+# endif
}
static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u16 *ptr = (struct __una_u16 *) r11;
+ ptr->x = r5;
+# else
unsigned long r1,r2,r3,r4;
__asm__("ldq_u %3,%1\n\t"
@@ -253,66 +350,551 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
"=m" (*(unsigned long *)(1+(char *) r11)),
"=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
:"r" (r5), "r" (r11));
+# endif
}
-#define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
-#ifdef __ELF__
-#define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory")
-#else /* ECOFF gas 2.6 doesn't know "wmb" :-( */
-#define write_mem_barrier() mem_barrier()
-#endif
+/* to flush the I-cache before jumping to code which just got loaded */
+# define PAL_imb 134
+# define istream_mem_barrier() \
+ __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
+# define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
+# ifdef __ELF__
+# define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory")
+# else /* ECOFF gas 2.6 doesn't know "wmb" :-( */
+# define write_mem_barrier() mem_barrier()
+# endif
+
+
+# elif defined(linux) && defined(__ia64__)
+
+# include <inttypes.h>
+
+# include <sys/io.h>
+
+struct __una_u64 { uint64_t x __attribute__((packed)); };
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };
+
+static __inline__ unsigned long
+__uldq (const unsigned long * r11)
+{
+ const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
+ return ptr->x;
+}
+
+static __inline__ unsigned long
+__uldl (const unsigned int * r11)
+{
+ const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+ return ptr->x;
+}
+
+static __inline__ unsigned long
+__uldw (const unsigned short * r11)
+{
+ const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+ return ptr->x;
+}
+
+static __inline__ void
+__ustq (unsigned long r5, unsigned long * r11)
+{
+ struct __una_u64 *ptr = (struct __una_u64 *) r11;
+ ptr->x = r5;
+}
+
+static __inline__ void
+__ustl (unsigned long r5, unsigned int * r11)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) r11;
+ ptr->x = r5;
+}
+
+static __inline__ void
+__ustw (unsigned long r5, unsigned short * r11)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) r11;
+ ptr->x = r5;
+}
+
+# define ldq_u(p) __uldq(p)
+# define ldl_u(p) __uldl(p)
+# define ldw_u(p) __uldw(p)
+# define stq_u(v,p) __ustq(v,p)
+# define stl_u(v,p) __ustl(v,p)
+# define stw_u(v,p) __ustw(v,p)
+
+# define mem_barrier() __asm__ __volatile__ ("mf" ::: "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("mf" ::: "memory")
+
+/*
+ * This is overkill, but for different reasons depending on where it is used.
+ * This is thus general enough to be used everywhere cache flushes are needed.
+ * It doesn't handle memory access serialisation by other processors, though.
+ */
+# define ia64_flush_cache(Addr) \
+ __asm__ __volatile__ ( \
+ "fc %0;;;" \
+ "sync.i;;;" \
+ "mf;;;" \
+ "srlz.i;;;" \
+ :: "r"(Addr) : "memory")
+
+# undef outb
+# undef outw
+# undef outl
+
+# define outb(a,b) _outb(b,a)
+# define outw(a,b) _outw(b,a)
+# define outl(a,b) _outl(b,a)
+
+# elif defined(linux) && defined(__x86_64__)
+
+# include <inttypes.h>
+
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+
+# define mem_barrier() \
+ __asm__ __volatile__ ("lock; addl $0,0(%%rsp)": : :"memory")
+# define write_mem_barrier() \
+ __asm__ __volatile__ ("": : :"memory")
+
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# elif (defined(linux) || defined(Lynx) || defined(sun) || defined(__OpenBSD__)) && defined(__sparc__)
+
+# if !defined(Lynx)
+# ifndef ASI_PL
+# define ASI_PL 0x88
+# endif
+
+# define barrier() __asm__ __volatile__(".word 0x8143e00a": : :"memory")
+
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
-#else /* defined(linux) && defined(__alpha__) */
-#if defined(__mips__)
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned char ret;
+
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduh [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("ld [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+# endif /* !Lynx */
+
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads. Define some
+ * packed structures to talk about such things with.
+ */
+
+# if defined(__arch64__) || defined(__sparcv9)
+struct __una_u64 { unsigned long x __attribute__((packed)); };
+# endif
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+static __inline__ unsigned long ldq_u(unsigned long *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+# if defined(__arch64__) || defined(__sparcv9)
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+# else
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+# endif
+ return ptr->x;
+# else
+ unsigned long ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ unsigned long ldl_u(unsigned int *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+ return ptr->x;
+# else
+ unsigned int ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ unsigned long ldw_u(unsigned short *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+ return ptr->x;
+# else
+ unsigned short ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ void stq_u(unsigned long val, unsigned long *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+# if defined(__arch64__) || defined(__sparcv9)
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+# else
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+# endif
+ ptr->x = val;
+# else
+ unsigned long tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+# else
+ unsigned int tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+# else
+ unsigned short tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+# define mem_barrier() /* XXX: nop for now */
+# define write_mem_barrier() /* XXX: nop for now */
+
+# elif defined(__mips__) || defined(__arm32__)
+#ifdef __arm32__
+#define PORT_SIZE long
+#else
+#define PORT_SIZE short
+#endif
unsigned int IOPortBase; /* Memory mapped I/O port area */
static __inline__ void
-outb(port, val)
- short port;
- char val;
+outb(unsigned PORT_SIZE port, unsigned char val)
{
- *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
+ *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
}
static __inline__ void
-outw(port, val)
- short port;
- short val;
+outw(unsigned PORT_SIZE port, unsigned short val)
{
- *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
+ *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
}
static __inline__ void
-outl(port, val)
- short port;
- int val;
+outl(unsigned PORT_SIZE port, unsigned int val)
{
- *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
+ *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
}
static __inline__ unsigned int
-inb(port)
- short port;
+inb(unsigned PORT_SIZE port)
{
- return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
+ return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
}
static __inline__ unsigned int
-inw(port)
- short port;
+inw(unsigned PORT_SIZE port)
{
- return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
+ return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
}
static __inline__ unsigned int
-inl(port)
- short port;
+inl(unsigned PORT_SIZE port)
{
- return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
+ return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
}
+# if defined(__mips__)
static __inline__ unsigned long ldq_u(unsigned long * r11)
{
unsigned long r1;
@@ -349,511 +931,409 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
return r1;
}
-#define stq_u(v,p) stl_u(v,p)
-#define stl_u(v,p) ((unsigned char *)(p)) = (v); \
- ((unsigned char *)(p)+1) = ((v) >> 8); \
- ((unsigned char *)(p)+2) = ((v) >> 16); \
- ((unsigned char *)(p)+3) = ((v) >> 24)
+# ifdef linux /* don't mess with other OSs */
-#define stw_u(v,p) ((unsigned char *)(p)) = (v); \
- ((unsigned char *)(p)+1) = ((v) >> 8)
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads (and we don't support older
+ * versions anyway. Define some packed structures to talk about such things
+ * with.
+ */
-#define mem_barrier() /* NOP */
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
-#else /* defined(mips) */
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+}
-#define ldq_u(p) (*((unsigned long *)(p)))
-#define ldl_u(p) (*((unsigned int *)(p)))
-#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned int *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
-#define mem_barrier() /* NOP */
-#define write_mem_barrier() /* NOP */
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+}
-#if !defined(FAKEIT) && !defined(__mc68000__)
-#ifdef GCCUSESGAS
+# if X_BYTE_ORDER == X_BIG_ENDIAN
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
-/*
- * If gcc uses gas rather than the native assembler, the syntax of these
- * inlines has to be different. DHD
- */
-#ifndef PC98
+ __asm__ __volatile__("lw %0, 0(%1)"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
static __inline__ void
-#if NeedFunctionPrototypes
-outb(
-unsigned short int port,
-unsigned char val)
-#else
-outb(port, val)
-unsigned short int port;
-unsigned char val;
-#endif /* NeedFunctionPrototypes */
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sw %0, 0(%1)"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+# endif
+
+# define mem_barrier() \
+ __asm__ __volatile__( \
+ "# prevent instructions being moved around\n\t" \
+ ".set\tnoreorder\n\t" \
+ "# 8 nops to fool the R4400 pipeline\n\t" \
+ "nop;nop;nop;nop;nop;nop;nop;nop\n\t" \
+ ".set\treorder" \
+ : /* no output */ \
+ : /* no input */ \
+ : "memory")
+# define write_mem_barrier() mem_barrier()
+
+# else /* !linux */
+
+# define stq_u(v,p) stl_u(v,p)
+# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8); \
+ (*(unsigned char *)(p)+2) = ((v) >> 16); \
+ (*(unsigned char *)(p)+3) = ((v) >> 24)
+
+# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8)
+
+# define mem_barrier() /* NOP */
+# endif /* !linux */
+# endif /* __mips__ */
+
+# if defined(__arm32__)
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+# endif /* __arm32__ */
+
+# elif (defined(Lynx) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__)) && defined(__powerpc__)
+
+# ifndef MAP_FAILED
+# define MAP_FAILED ((void *)-1)
+# endif
+
+extern volatile unsigned char *ioBase;
+
+# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned char val;
+ __asm__ __volatile__(
+ "lbzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
}
-
-static __inline__ void
-#if NeedFunctionPrototypes
-outw(
-unsigned short int port,
-unsigned short int val)
-#else
-outw(port, val)
-unsigned short int port;
-unsigned short int val;
-#endif /* NeedFunctionPrototypes */
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
}
-static __inline__ void
-#if NeedFunctionPrototypes
-outl(
-unsigned short int port,
-unsigned int val)
-#else
-outl(port, val)
-unsigned short int port;
-unsigned int val;
-#endif /* NeedFunctionPrototypes */
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inb(
-unsigned short int port)
-#else
-inb(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inw(
-unsigned short int port)
-#else
-inw(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
{
- unsigned short int ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
}
-static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inl(
-unsigned short int port)
-#else
-inl(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+static __inline__ void
+xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ __asm__ __volatile__(
+ "stbx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
}
-#else /* PC98 */
+static __inline__ void
+xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
static __inline__ void
-#if NeedFunctionPrototypes
-_outb(
-unsigned short int port,
-unsigned char val)
-#else
-_outb(port, val)
-unsigned short int port;
-unsigned char val;
-#endif /* NeedFunctionPrototypes */
+xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
{
- __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port));
+ __asm__ __volatile__(
+ "sthx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
}
static __inline__ void
-#if NeedFunctionPrototypes
-_outw(
-unsigned short int port,
-unsigned short int val)
-#else
-_outw(port, val)
-unsigned short int port;
-unsigned short int val;
-#endif /* NeedFunctionPrototypes */
+xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
{
- __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port));
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
}
-
+
static __inline__ void
-#if NeedFunctionPrototypes
-_outl(
-unsigned short int port,
-unsigned int val)
-#else
-_outl(port, val)
-unsigned short int port;
-unsigned int val;
-#endif /* NeedFunctionPrototypes */
+xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__(
+ "stwx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
}
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ xf86WriteMmioNB8(base, offset, val);
+ eieio();
+}
-static __inline__ unsigned int
-#if NeedFunctionPrototypes
-_inb(
-unsigned short int port)
-#else
-_inb(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ xf86WriteMmioNB16Le(base, offset, val);
+ eieio();
}
-static __inline__ unsigned int
-#if NeedFunctionPrototypes
-_inw(
-unsigned short int port)
-#else
-_inw(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ xf86WriteMmioNB16Be(base, offset, val);
+ eieio();
}
-static __inline__ unsigned int
-#if NeedFunctionPrototypes
-_inl(
-unsigned short int port)
-#else
-_inl(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ xf86WriteMmioNB32Le(base, offset, val);
+ eieio();
}
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Be(base, offset, val);
+ eieio();
+}
-#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
-#define PW_PORT 0x600
-extern short chipID;
-#if NeedFunctionPrototypes
-extern void *mmioBase;
-#else
-extern unsigned char *mmioBase;
-#endif
-extern unsigned short _port_tbl[];
-#define port_convert(x) _port_tbl[(unsigned short)x]
-#endif
-#if defined(PC98_WAB) || defined(PC98_GANB_WAP)
-static __inline__ unsigned short
-port_convert(unsigned short port)
+static __inline__ void
+outb(unsigned short port, unsigned char value)
{
- port <<= 8;
- port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
- port |= 0xE0;
- return port;
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio8((void *)ioBase, port, value);
}
-#endif /* PC98_WAB || PC98_GANB_WAP */
-
-#if defined(PC98_WABEP)
-static __inline__ unsigned short
-port_convert(unsigned short port)
+
+static __inline__ void
+outw(unsigned short port, unsigned short value)
{
- port &= 0x7f; /* Mask 0000 0000 0111 1111 */
- port |= 0x0f00;
- return port;
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio16Le((void *)ioBase, port, value);
}
-#endif /* PC98_WABEP */
-#ifdef PC98_WSNA
-static __inline__ unsigned short
-port_convert(unsigned short port)
+static __inline__ void
+outl(unsigned short port, unsigned int value)
{
- port <<= 8;
- port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
- port |= 0xE2;
- return port;
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio32Le((void *)ioBase, port, value);
}
-#endif /* PC98_WSNA */
-#ifdef PC98_NKVNEC
-#ifdef PC98_NEC_CIRRUS2
-static __inline__ unsigned short
-port_convert(unsigned short port)
+static __inline__ unsigned int
+inb(unsigned short port)
{
- port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
- return port;
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio8((void *)ioBase, port);
}
-#else
-static __inline__ unsigned short
-port_convert(unsigned short port)
+
+static __inline__ unsigned int
+inw(unsigned short port)
{
- port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
- return port;
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio16Le((void *)ioBase, port);
}
-#endif /* PC98_NEC_CIRRUS2 */
-#endif /* PC98_NKVNEC */
-#if defined(PC98_TGUI) || defined(PC98_MGA)
-#if NeedFunctionPrototypes
-extern void *mmioBase;
-#else
-extern unsigned char *mmioBase;
-#endif
-#endif
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio32Le((void *)ioBase, port);
+}
-static __inline__ void
-#if NeedFunctionPrototypes
-outb(
-unsigned short port,
-unsigned char val)
-#else
-outb(port, val)
-unsigned short port;
-unsigned char val;
-#endif /* NeedFunctionPrototypes */
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
+# define ldq_u(p) ldl_u(p)
+# define ldl_u(p) ((*(unsigned char *)(p)) | \
+ (*((unsigned char *)(p)+1)<<8) | \
+ (*((unsigned char *)(p)+2)<<16) | \
+ (*((unsigned char *)(p)+3)<<24))
+# define ldw_u(p) ((*(unsigned char *)(p)) | \
+ (*((unsigned char *)(p)+1)<<8))
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
-#else
+# define stq_u(v,p) stl_u(v,p)
+# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*((unsigned char *)(p)+1)) = ((v) >> 8); \
+ (*((unsigned char *)(p)+2)) = ((v) >> 16); \
+ (*((unsigned char *)(p)+3)) = ((v) >> 24)
+# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*((unsigned char *)(p)+1)) = ((v) >> 8)
+
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+# else /* ix86 */
+
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)
+# ifdef GCCUSESGAS
+
+/*
+ * If gcc uses gas rather than the native assembler, the syntax of these
+ * inlines has to be different. DHD
+ */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
__asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-#endif
}
-static __inline__ void
-#if NeedFunctionPrototypes
-outw(
-unsigned short port,
-unsigned short val)
-#else
-outw(port, val)
-unsigned short port;
-unsigned short val;
-#endif /* NeedFunctionPrototypes */
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
-#else
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
__asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-#endif
}
static __inline__ void
-#if NeedFunctionPrototypes
-outl(
-unsigned short port,
-unsigned int val)
-#else
-outl(port, val)
-unsigned short port;
-unsigned int val;
-#endif /* NeedFunctionPrototypes */
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
-#else
+outl(unsigned short port, unsigned int val)
+{
__asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-#endif
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inb(
-unsigned short port)
-#else
-inb(port)
-unsigned short port;
-#endif /* NeedFunctionPrototypes */
+inb(unsigned short port)
{
unsigned char ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned char *)((char *)mmioBase+(port));
-#else
__asm__ __volatile__("inb %1,%0" :
"=a" (ret) :
"d" (port));
-#endif
return ret;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inw(
-unsigned short port)
-#else
-inw(port)
-unsigned short port;
-#endif /* NeedFunctionPrototypes */
+inw(unsigned short port)
{
unsigned short ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned short *)((char *)mmioBase+(port));
-#else
__asm__ __volatile__("inw %1,%0" :
"=a" (ret) :
"d" (port));
-#endif
return ret;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inl(
-unsigned short port)
-#else
-inl(port)
-unsigned short port;
-#endif /* NeedFunctionPrototypes */
+inl(unsigned short port)
{
unsigned int ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned int *)((char *)mmioBase+(port));
-#else
__asm__ __volatile__("inl %1,%0" :
"=a" (ret) :
"d" (port));
-#endif
return ret;
}
-#endif /* PC98 */
-
-#else /* GCCUSESGAS */
+# else /* GCCUSESGAS */
static __inline__ void
-#if NeedFunctionPrototypes
-outb(
-unsigned short int port,
-unsigned char val)
-#else
-outb(port, val)
-unsigned short int port;
-unsigned char val;
-#endif /* NeedFunctionPrototypes */
+outb(unsigned short port, unsigned char val)
{
__asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
}
static __inline__ void
-#if NeedFunctionPrototypes
-outw(
-unsigned short int port,
-unsigned short int val)
-#else
-outw(port, val)
-unsigned short int port;
-unsigned short int val;
-#endif /* NeedFunctionPrototypes */
+outw(unsigned short port, unsigned short val)
{
__asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
}
static __inline__ void
-#if NeedFunctionPrototypes
-outl(
-unsigned short int port,
-unsigned int val)
-#else
-outl(port, val)
-unsigned short int port;
-unsigned int val;
-#endif /* NeedFunctionPrototypes */
+outl(unsigned short port, unsigned int val)
{
__asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inb(
-unsigned short int port)
-#else
-inb(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inb(unsigned short port)
{
unsigned char ret;
__asm__ __volatile__("in%B0 (%1)" :
@@ -863,15 +1343,9 @@ unsigned short int port;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inw(
-unsigned short int port)
-#else
-inw(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inw(unsigned short port)
{
- unsigned short int ret;
+ unsigned short ret;
__asm__ __volatile__("in%W0 (%1)" :
"=a" (ret) :
"d" (port));
@@ -879,13 +1353,7 @@ unsigned short int port;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inl(
-unsigned short int port)
-#else
-inl(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inl(unsigned short port)
{
unsigned int ret;
__asm__ __volatile__("in%L0 (%1)" :
@@ -894,567 +1362,382 @@ unsigned short int port;
return ret;
}
-#endif /* GCCUSESGAS */
+# endif /* GCCUSESGAS */
-#else /* !defined(FAKEIT) && !defined(__mc68000__) */
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/
static __inline__ void
-#if NeedFunctionPrototypes
-outb(
-unsigned short int port,
-unsigned char val)
-#else
-outb(port, val)
-unsigned short int port;
-unsigned char val;
-#endif /* NeedFunctionPrototypes */
+outb(unsigned short port, unsigned char val)
{
}
static __inline__ void
-#if NeedFunctionPrototypes
-outw(
-unsigned short int port,
-unsigned short int val)
-#else
-outw(port, val)
-unsigned short int port;
-unsigned short int val;
-#endif /* NeedFunctionPrototypes */
+outw(unsigned short port, unsigned short val)
{
}
static __inline__ void
-#if NeedFunctionPrototypes
-outl(
-unsigned short int port,
-unsigned int val)
-#else
-outl(port, val)
-unsigned short int port;
-unsigned int val;
-#endif /* NeedFunctionPrototypes */
+outl(unsigned short port, unsigned int val)
{
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inb(
-unsigned short int port)
-#else
-inb(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inb(unsigned short port)
{
return 0;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inw(
-unsigned short int port)
-#else
-inw(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inw(unsigned short port)
{
return 0;
}
static __inline__ unsigned int
-#if NeedFunctionPrototypes
-inl(
-unsigned short int port)
-#else
-inl(port)
-unsigned short int port;
-#endif /* NeedFunctionPrototypes */
+inl(unsigned short port)
{
return 0;
}
-#endif /* FAKEIT */
-
-#endif /* defined(mips) */
-#endif /* defined(AlphaArchitecture) && defined(LinuxArchitecture) */
-
-#else /* __GNUC__ */
-#if !defined(AMOEBA) && !defined(MINIX)
-# if defined(__STDC__) && (__STDC__ == 1)
-# ifndef asm
-# define asm __asm
-# endif
-# endif
-# ifdef SVR4
-# include <sys/types.h>
-# ifndef __HIGHC__
-# ifndef __USLC__
-# define __USLC__
-# endif
-# endif
-# endif
-# ifndef PC98
-# ifndef SCO325
-# include <sys/inline.h>
-# else
-# include "scoasm.h"
-# endif
-# else
-#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
-#define PW_PORT 0x600
-extern short chipID;
-#if NeedFunctionPrototypes
-extern void *mmioBase;
-#else
-extern unsigned char *mmioBase;
-#endif
-extern unsigned short _port_tbl[];
-#define port_convert(x) _port_tbl[(unsigned short)x]
-#endif
-
-#if defined(PC98_TGUI) || defined(PC98_MGA)
-#if NeedFunctionPrototypes
-extern void *mmioBase;
-#else
-extern unsigned char *mmioBase;
-#endif
-#endif
-
-asm void _outl(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- outl (%dx)
-%reg port; mem val;
- movl port, %edx
- movl val, %eax
- outl (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- outl (%dx)
-%mem port,val;
- movw port, %dx
- movl val, %eax
- outl (%dx)
-}
-
-asm void _outw(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- data16
- outl (%dx)
-%reg port; mem val;
- movl port, %edx
- movw val, %ax
- data16
- outl (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- data16
- outl (%dx)
-%mem port,val;
- movw port, %dx
- movw val, %ax
- data16
- outl (%dx)
-}
-
-asm void _outb(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- outb (%dx)
-%reg port; mem val;
- movl port, %edx
- movb val, %al
- outb (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- outb (%dx)
-%mem port,val;
- movw port, %dx
- movb val, %al
- outb (%dx)
-}
-
-asm int _inl(port)
-{
-%reg port;
- movl port, %edx
- inl (%dx)
-%mem port;
- movw port, %dx
- inl (%dx)
-}
-
-asm int _inw(port)
-{
-%reg port;
- subl %eax, %eax
- movl port, %edx
- data16
- inl (%dx)
-%mem port;
- subl %eax, %eax
- movw port, %dx
- data16
- inl (%dx)
-}
-
-asm int _inb(port)
-{
-%reg port;
- subl %eax, %eax
- movl port, %edx
- inb (%dx)
-%mem port;
- subl %eax, %eax
- movw port, %dx
- inb (%dx)
-}
-
-#if defined(PC98_WAB) || defined(PC98_GANB_WAP)
-static unsigned short
-port_convert(unsigned short port)
-{
- port <<= 8;
- port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
- port |= 0xE0;
- return port;
-}
-#endif /* PC98_WAB || PC98_GANB_WAP */
-
-#if defined(PC98_WABEP)
-static unsigned short
-port_convert(unsigned short port)
-{
- port &= 0x7f; /* Mask 0000 0000 0111 1111 */
- port |= 0x0f00;
- return port;
-}
-#endif /* PC98_WABEP */
-
-#ifdef PC98_WSNA
-static unsigned short
-port_convert(unsigned short port)
-{
- port <<= 8;
- port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
- port |= 0xE2;
- return port;
-}
-#endif /* PC98_WSNA */
-
-#ifdef PC98_NKVNEC
-#ifdef PC98_NEC_CIRRUS2
-static unsigned short
-port_convert(unsigned short port)
-{
- port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
- return port;
-}
-#else
-static unsigned short
-port_convert(unsigned short port)
-{
- port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
- return port;
-}
-#endif /* PC98_NEC_CIRRUS2 */
-#endif /* PC98_NKVNEC */
-
-static void outl(port,val)
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
+# endif /* FAKEIT */
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
-#else
- _outl(port,val);
-#endif
-}
-
-static void outw(port,val)
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
-#else
- _outw(port,val);
-#endif
-}
-
-static void outb(port,val)
-{
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
-#else
- _outb(port,val);
-#endif
-}
-
-static int inl(port)
-{
- unsigned int ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned int *)((char *)mmioBase+(port));
-#else
- ret = _inl(port);
-#endif
- return ret;
-}
-
-static int inw(port)
-{
- unsigned short ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned short *)((char *)mmioBase+(port));
-#else
- ret = _inw(port);
-#endif
- return ret;
-}
-
-static int inb(port)
-{
- unsigned char ret;
-
-#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
- defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
- defined(PC98_XKB) || defined(PC98_NEC)
- unsigned short tmp;
- tmp=port_convert(port);
- port=tmp;
-#endif
-
-#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
- ret =*(volatile unsigned char *)((char *)mmioBase+(port));
-#else
- ret = _inb(port);
-#endif
- return ret;
-}
-
-
-# endif /* PC98 */
-# if !defined(__HIGHC__) && !defined(SCO325)
-# pragma asm partial_optimization outl
-# pragma asm partial_optimization outw
-# pragma asm partial_optimization outb
-# pragma asm partial_optimization inl
-# pragma asm partial_optimization inw
-# pragma asm partial_optimization inb
-# endif
-#endif
-#define ldq_u(p) (*((unsigned long *)(p)))
-#define ldl_u(p) (*((unsigned int *)(p)))
-#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned int *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
-#define mem_barrier() /* NOP */
-#define write_mem_barrier() /* NOP */
-#endif /* __GNUC__ */
-
-#if defined(IODEBUG) && defined(__GNUC__)
-#undef inb
-#undef inw
-#undef inl
-#undef outb
-#undef outw
-#undef outl
-#define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
-#define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
-#define inl(a) __extension__ ({unsigned long __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
-
-#define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b))
-#define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b))
-#define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b))
-#endif
+# endif /* ix86 */
+# elif defined(__powerpc__) /* && !__GNUC__ */
/*
- * This header sometimes gets included where is isn't needed, and on some
- * OSs this causes problems because the following functions generate
- * references to inb() and outb() which can't be resolved. Defining
- * NO_COMPILER_H_EXTRAS avoids this problem.
+ * NON-GCC PowerPC - Presumed to be PowerMAX OS for now
*/
+# ifndef PowerMAX_OS
+# error - Non-gcc PowerPC and !PowerMAXOS ???
+# endif
-#ifndef NO_COMPILER_H_EXTRAS
+# define PPCIO_DEBUG 0
+# define PPCIO_INLINE 1
+# define USE_ABS_MACRO 1
/*
- *-----------------------------------------------------------------------
- * Port manipulation convenience functions
- *-----------------------------------------------------------------------
+ * Use compiler intrinsics to access certain PPC machine instructions
*/
+# define eieio() __inst_eieio()
+# define stw_brx(val,base,ndx) __inst_sthbrx(val,base,ndx)
+# define stl_brx(val,base,ndx) __inst_stwbrx(val,base,ndx)
+# define ldw_brx(base,ndx) __inst_lhbrx(base,ndx)
+# define ldl_brx(base,ndx) __inst_lwbrx(base,ndx)
+
+# define ldq_u(p) (*((unsigned long long *)(p)))
+# define ldl_u(p) (*((unsigned long *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+extern volatile unsigned char *ioBase;
+
+# if !defined(abs) && defined(USE_ABS_MACRO)
+# define abs(x) ((x) >= 0 ? (x) : -(x))
+# endif
-#ifndef __GNUC__
-#define __inline__ /**/
+# undef inb
+# undef inw
+# undef inl
+# undef outb
+# undef outw
+# undef outl
+
+# if PPCIO_DEBUG
+
+extern void debug_outb(unsigned int a, unsigned char b, int line, char *file);
+extern void debug_outw(unsigned int a, unsigned short w, int line, char *file);
+extern void debug_outl(unsigned int a, unsigned int l, int line, char *file);
+extern unsigned char debug_inb(unsigned int a, int line, char *file);
+extern unsigned short debug_inw(unsigned int a, int line, char *file);
+extern unsigned int debug_inl(unsigned int a, int line, char *file);
+
+# define outb(a,b) debug_outb(a,b, __LINE__, __FILE__)
+# define outw(a,w) debug_outw(a,w, __LINE__, __FILE__)
+# define outl(a,l) debug_outl(a,l, __LINE__, __FILE__)
+# define inb(a) debug_inb(a, __LINE__, __FILE__)
+# define inw(a) debug_inw(a, __LINE__, __FILE__)
+# define inl(a) debug_inl(a, __LINE__, __FILE__)
+
+# else /* !PPCIO_DEBUG */
+
+extern unsigned char inb(unsigned int a);
+extern unsigned short inw(unsigned int a);
+extern unsigned int inl(unsigned int a);
+
+# if PPCIO_INLINE
+
+# define outb(a,b) \
+ (*((volatile unsigned char *)(ioBase + (a))) = (b), eieio())
+# define outw(a,w) (stw_brx((w),ioBase,(a)), eieio())
+# define outl(a,l) (stl_brx((l),ioBase,(a)), eieio())
+
+# else /* !PPCIO_INLINE */
+
+extern void outb(unsigned int a, unsigned char b);
+extern void outw(unsigned int a, unsigned short w);
+extern void outl(unsigned int a, unsigned int l);
+
+# endif /* PPCIO_INLINE */
+
+# endif /* !PPCIO_DEBUG */
+
+# else /* !GNUC && !PPC */
+# if !defined(QNX4)
+# if defined(__STDC__) && (__STDC__ == 1)
+# ifndef asm
+# define asm __asm
+# endif
+# endif
+# ifdef SVR4
+#if 0
+# include <sys/types.h>
#endif
+# ifndef __HIGHC__
+# ifndef __USLC__
+# define __USLC__
+# endif
+# endif
+# endif
+# ifndef SCO325
+# if defined(USL)
+# if defined(IN_MODULE)
+# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
+# define ushort unsigned short
+# define ushort_t unsigned short
+# define ulong unsigned long
+# define ulong_t unsigned long
+# define uint_t unsigned int
+# define uchar_t unsigned char
+# else
+# include <sys/types.h>
+# endif /* IN_MODULE */
+# endif /* USL */
+# include <sys/inline.h>
+# else
+# include "scoasm.h"
+# endif
+# if !defined(__HIGHC__) && !defined(SCO325)
+# pragma asm partial_optimization outl
+# pragma asm partial_optimization outw
+# pragma asm partial_optimization outb
+# pragma asm partial_optimization inl
+# pragma asm partial_optimization inw
+# pragma asm partial_optimization inb
+# endif
+# endif
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+# endif /* __GNUC__ */
+
+# if defined(QNX4)
+# include <sys/types.h>
+extern unsigned inb(unsigned port);
+extern unsigned inw(unsigned port);
+extern unsigned inl(unsigned port);
+extern void outb(unsigned port, unsigned val);
+extern void outw(unsigned port, unsigned val);
+extern void outl(unsigned port, unsigned val);
+# endif /* QNX4 */
+
+# if defined(IODEBUG) && defined(__GNUC__)
+# undef inb
+# undef inw
+# undef inl
+# undef outb
+# undef outw
+# undef outl
+# define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+# define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+# define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+
+# define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b))
+# define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b))
+# define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b))
+# endif
-/*
- * rdinx - read the indexed byte port 'port', index 'ind', and return its value
- */
-static __inline__ unsigned char
-#ifdef __STDC__
-rdinx(unsigned short int port, unsigned char ind)
-#else
-rdinx(port, ind)
-unsigned short int port;
-unsigned char ind;
-#endif
-{
- if (port == 0x3C0) /* reset attribute flip-flop */
- (void) inb(0x3DA);
- outb(port, ind);
- return(inb(port+1));
-}
-
-/*
- * wrinx - write 'val' to port 'port', index 'ind'
- */
-static __inline__ void
-#ifdef __STDC__
-wrinx(unsigned short int port, unsigned char ind, unsigned char val)
-#else
-wrinx(port, ind, val)
-unsigned short int port;
-unsigned char ind, val;
-#endif
-{
- outb(port, ind);
- outb(port+1, val);
-}
+# endif /* NO_INLINE */
+
+# ifdef __alpha__
+/* entry points for Mmio memory access routines */
+extern int (*xf86ReadMmio8)(void *, unsigned long);
+extern int (*xf86ReadMmio16)(void *, unsigned long);
+extern int (*xf86ReadMmio32)(void *, unsigned long);
+extern void (*xf86WriteMmio8)(int, void *, unsigned long);
+extern void (*xf86WriteMmio16)(int, void *, unsigned long);
+extern void (*xf86WriteMmio32)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB8)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB16)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB32)(int, void *, unsigned long);
+extern void xf86JensenMemToBus(char *, long, long, int);
+extern void xf86JensenBusToMem(char *, char *, unsigned long, int);
+extern void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
+extern void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
+
+/* Some macros to hide the system dependencies for MMIO accesses */
+/* Changed to kill noise generated by gcc's -Wcast-align */
+# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
+# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
+# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
+
+# if defined (JENSEN_SUPPORT)
+# define MMIO_OUT32(base, offset, val) \
+ (*xf86WriteMmio32)((CARD32)(val), base, offset)
+# define MMIO_ONB32(base, offset, val) \
+ (*xf86WriteMmioNB32)((CARD32)(val), base, offset)
+# else
+# define MMIO_OUT32(base, offset, val) \
+ do { \
+ write_mem_barrier(); \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
+ } while (0)
+# define MMIO_ONB32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# endif
-/*
- * modinx - in register 'port', index 'ind', set the bits in 'mask' as in 'new';
- * the other bits are unchanged.
- */
-static __inline__ void
-#ifdef __STDC__
-modinx(unsigned short int port, unsigned char ind,
- unsigned char mask, unsigned char new)
-#else
-modinx(port, ind, mask, new)
-unsigned short int port;
-unsigned char ind, mask, new;
-#endif
-{
- unsigned char tmp;
+# define MMIO_OUT8(base, offset, val) \
+ (*xf86WriteMmio8)((CARD8)(val), base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ (*xf86WriteMmio16)((CARD16)(val), base, offset)
+# define MMIO_ONB8(base, offset, val) \
+ (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
+# define MMIO_ONB16(base, offset, val) \
+ (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
+# define MMIO_MOVE32(base, offset, val) \
+ MMIO_OUT32(base, offset, val)
+
+# elif defined(__powerpc__)
+ /*
+ * we provide byteswapping and no byteswapping functions here
+ * with byteswapping as default,
+ * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmioNB8(base, offset, (CARD8)(val))
+
+# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
+# endif
- tmp = (rdinx(port, ind) & ~mask) | (new & mask);
- wrinx(port, ind, tmp);
-}
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+static __inline__ void ppc_flush_icache(char *addr)
+{
+ __asm__ volatile (
+ "dcbf 0,%0;"
+ "sync;"
+ "icbi 0,%0;"
+ "sync;"
+ "isync;"
+ : : "r"(addr) : "memory");
+}
+
+# elif defined(__sparc__)
+ /*
+ * Like powerpc, we provide byteswapping and no byteswapping functions
+ * here with byteswapping as default, drivers that don't need byteswapping
+ * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
+ * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
+ * of drivers?).
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmio8NB(base, offset, (CARD8)(val))
+
+# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
+# endif
-/*
- * tstrg - returns true iff the bits in 'mask' of register 'port' are
- * readable & writable.
- */
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
-static __inline__ int
-#ifdef __STDC__
-testrg(unsigned short int port, unsigned char mask)
-#else
-tstrg(port, mask)
-unsigned short int port;
-unsigned char mask;
-#endif
-{
- unsigned char old, new1, new2;
+# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
- old = inb(port);
- outb(port, old & ~mask);
- new1 = inb(port) & mask;
- outb(port, old | mask);
- new2 = inb(port) & mask;
- outb(port, old);
- return((new1 == 0) && (new2 == mask));
-}
+# define MMIO_IN8(base, offset) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
+# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
+# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-/*
- * testinx2 - returns true iff the bits in 'mask' of register 'port', index
- * 'ind' are readable & writable.
- */
-static __inline__ int
-#ifdef __STDC__
-testinx2(unsigned short int port, unsigned char ind, unsigned char mask)
-#else
-testinx2(port, ind, mask)
-unsigned short int port;
-unsigned char ind, mask;
-#endif
-{
- unsigned char old, new1, new2;
+# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
- old = rdinx(port, ind);
- wrinx(port, ind, old & ~mask);
- new1 = rdinx(port, ind) & mask;
- wrinx(port, ind, old | mask);
- new2 = rdinx(port, ind) & mask;
- wrinx(port, ind, old);
- return((new1 == 0) && (new2 == mask));
-}
+# endif /* __alpha__ */
/*
- * testinx - returns true iff all bits of register 'port', index 'ind' are
- * readable & writable.
+ * With Intel, the version in os-support/misc/SlowBcopy.s is used.
+ * This avoids port I/O during the copy (which causes problems with
+ * some hardware).
*/
-static __inline__ int
-#ifdef __STDC__
-testinx(unsigned short int port, unsigned char ind)
-#else
-testinx(port, ind, mask)
-unsigned short int port;
-unsigned char ind;
-#endif
-{
- return(testinx2(port, ind, 0xFF));
-}
-#endif /* NO_COMPILER_H_EXTRAS */
+# ifdef __alpha__
+# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+# else /* __alpha__ */
+# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# endif /* __alpha__ */
-#endif /* NO_INLINE */
#endif /* _COMPILER_H */
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index ba00913d8..119adc5a6 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -1,743 +1,407 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.47.2.8 1998/02/24 19:05:53 hohndel Exp $ */
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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
- * 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.
- *
- * THOMAS ROELL 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
- * 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: xf86.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */
-
-#ifndef _XF86_H
-#define _XF86_H
-
-#include "misc.h"
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "xf86_Option.h"
-
-/*
- * structure common for all modes
- */
-typedef struct _DispM {
- struct _DispM *prev,*next;
- char *name; /* identifier of this mode */
- /* These are the values that the user sees/provides */
- int Clock; /* pixel clock */
- int HDisplay; /* horizontal timing */
- int HSyncStart;
- int HSyncEnd;
- int HTotal;
- int HSkew;
- int VDisplay; /* vertical timing */
- int VSyncStart;
- int VSyncEnd;
- int VTotal;
- int Flags;
- /* These are the values the hardware uses */
- int SynthClock; /* Actual clock freq to be programmed */
- int CrtcHDisplay;
- int CrtcHSyncStart;
- int CrtcHSyncEnd;
- int CrtcHTotal;
- int CrtcHSkew;
- int CrtcVDisplay;
- int CrtcVSyncStart;
- int CrtcVSyncEnd;
- int CrtcVTotal;
- Bool CrtcHAdjusted;
- Bool CrtcVAdjusted;
- int PrivSize;
- INT32 *Private;
-} DisplayModeRec, *DisplayModePtr;
-
-#define V_PHSYNC 0x0001
-#define V_NHSYNC 0x0002
-#define V_PVSYNC 0x0004
-#define V_NVSYNC 0x0008
-#define V_INTERLACE 0x0010
-#define V_DBLSCAN 0x0020
-#define V_CSYNC 0x0040
-#define V_PCSYNC 0x0080
-#define V_NCSYNC 0x0100
-#define V_HSKEW 0x0200 /* hskew provided */
-#define V_PIXMUX 0x1000
-#define V_DBLCLK 0x2000
-#define V_CLKDIV2 0x4000
-
-/* The monitor description */
-
-#define MAX_HSYNC 8
-#define MAX_VREFRESH 8
-
-typedef struct { float hi, lo; } range;
-
-typedef struct {
- char *id;
- char *vendor;
- char *model;
- float EMPTY;
- int n_hsync;
- range hsync[MAX_HSYNC];
- int n_vrefresh;
- range vrefresh[MAX_VREFRESH];
- DisplayModePtr Modes, Last; /* Start and end of monitor's mode list */
-} MonRec, *MonPtr;
-
-#define MAXCLOCKS 128
-#define MAXDACSPEEDS 4 /* for <= 8, 16, 24, 32bpp */
-
-/* Set default max allowed clock to 90MHz */
-#define DEFAULT_MAX_CLOCK 90000
-
-/*
- * the graphic device
- */
-typedef struct {
- Bool configured;
- int tmpIndex;
- int scrnIndex;
- Bool (* Probe)(
-#if NeedNestedPrototypes
- void
-#endif
-);
- Bool (* Init)(
-#if NeedNestedPrototypes
- int scr_index,
- ScreenPtr pScreen,
- int argc,
- char **argv
-#endif
-);
- int (* ValidMode)(
-#if NeedNestedPrototypes
- DisplayModePtr target,
- Bool verbose,
- int flag
-#endif
-);
- void (* EnterLeaveVT)(
-#if NeedNestedPrototypes
- int,
- int
-#endif
-);
- void (* EnterLeaveMonitor)(
-#if NeedNestedPrototypes
- int
-#endif
-);
- void (* EnterLeaveCursor)(
-#if NeedNestedPrototypes
- int
-#endif
-);
- void (* AdjustFrame)(
-#if NeedNestedPrototypes
- int x,
- int y
-#endif
-);
- Bool (* SwitchMode)(
-#if NeedNestedPrototypes
- DisplayModePtr modes
-#endif
-);
- void (* DPMSSet)(
-#if NeedNestedPrototypes
- int level
-#endif
-);
- void (* PrintIdent)(
-#if NeedNestedPrototypes
- void
-#endif
-);
- int depth;
- xrgb weight;
- int bitsPerPixel;
- int defaultVisual;
- int virtualX,virtualY;
- int displayWidth;
- int frameX0, frameY0, frameX1, frameY1;
- OFlagSet options;
- OFlagSet clockOptions;
- OFlagSet xconfigFlag;
- char *chipset;
- char *ramdac;
- int dacSpeeds[MAXDACSPEEDS];
- int dacSpeedBpp;
- int clocks;
- int clock[MAXCLOCKS];
- int maxClock;
- int videoRam;
- int BIOSbase; /* Base address of video BIOS */
- unsigned long MemBase; /* Frame buffer base address */
- int width, height; /* real display dimensions */
- unsigned long speedup; /* Use SpeedUp code */
- DisplayModePtr modes;
- MonPtr monitor;
- char *clockprog;
- int textclock;
- Bool bankedMono; /* display supports banking for mono server */
- char *name;
- xrgb blackColour;
- xrgb whiteColour;
- int *validTokens;
- char *patchLevel;
- unsigned int IObase; /* AGX - video card I/O reg base */
- unsigned int DACbase; /* AGX - dac I/O reg base */
- unsigned long COPbase; /* AGX - coprocessor memory base */
- unsigned int POSbase; /* AGX - I/O address of POS regs */
- int instance; /* AGX - XGA video card instance number */
- int s3Madjust;
- int s3Nadjust;
- int s3MClk;
- int chipID;
- int chipRev;
- unsigned long VGAbase; /* AGX - 64K aperture memory address */
- int s3RefClk;
- int s3BlankDelay;
- int textClockFreq;
- char *DCConfig;
- char *DCOptions;
- int MemClk; /* General flag used for memory clocking */
- int LCDClk;
-#ifdef XFreeXDGA
- int directMode;
- void (*setBank)(
-#if NeedNestedPrototypes
- int
-#endif
- );
- unsigned long physBase;
- int physSize;
-#endif
-#ifdef XF86SETUP
- void *device; /* This should be GDevPtr, but it causes
- problems with include file order */
-#endif
-} ScrnInfoRec, *ScrnInfoPtr;
-
-typedef struct {
- int token; /* id of the token */
- char *name; /* pointer to the LOWERCASED name */
-} SymTabRec, *SymTabPtr;
-
-#define VGA_DRIVER 1
-#define V256_DRIVER 2
-#define WGA_DRIVER 3
-#define XGA_DRIVER 4
-
-#define ENTER 1
-#define LEAVE 0
-
-/* These are possible return values for xf86CheckMode() and ValidMode() */
-#define MODE_OK 0
-#define MODE_HSYNC 1 /* hsync out of range */
-#define MODE_VSYNC 2 /* vsync out of range */
-#define MODE_BAD 255 /* unspecified reason */
-
-/* These are the possible flags for ValidMode */
-#define MODE_USED 1 /* this mode is really being used in the */
- /* modes line of the Display Subsection */
-#define MODE_SUGGESTED 2 /* this mode is included in the available*/
- /* modes in the Monitor Section */
-#define MODE_VID 3 /* this is called from the VidMode extension */
-
-/* Indicates the level of DPMS support */
-typedef enum {
- DPMSSupportUnknown,
- DPMSNotSupported,
- DPMSFullSupport
-} DPMSSupportStatus;
-
-/* flags for xf86LookupMode */
-#define LOOKUP_DEFAULT 0 /* Use default mode lookup method */
-#define LOOKUP_BEST_REFRESH 1 /* Pick modes with best refresh */
-#define LOOKUP_NO_INTERLACED 2 /* Ignore interlaced modes */
-#define LOOKUP_FORCE_DEFAULT 4 /* Force default lookup method */
-
-#define INTERLACE_REFRESH_WEIGHT 1.5
-
-/* SpeedUp options */
-
-#define SPEEDUP_FILLBOX 1
-#define SPEEDUP_FILLRECT 2
-#define SPEEDUP_BITBLT 4
-#define SPEEDUP_LINE 8
-#define SPEEDUP_TEGBLT8 0x10
-#define SPEEDUP_RECTSTIP 0x20
-
-/*
- * This is the routines where SpeedUp is quicker than fXF86. The problem is
- * that the SpeedUp fillbox is better for drawing vertical and horizontal
- * line segments, and the fXF86 version is significantly better for
- * more general lines
- */
-#define SPEEDUP_BEST (SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \
- SPEEDUP_LINE | SPEEDUP_TEGBLT8 | \
- SPEEDUP_RECTSTIP)
-/*
-#define SPEEDUP_BEST (SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \
- SPEEDUP_BITBLT | SPEEDUP_LINE | \
- SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
-*/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.169 2003/02/13 10:49:38 eich Exp $ */
/*
- * SpeedUp routines which are not dependent on the screen virtual resolution
+ * Copyright (c) 1997 by The XFree86 Project, Inc.
*/
-#ifndef SPEEDUP_ANYWIDTH
-#define SPEEDUP_ANYWIDTH (SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \
- SPEEDUP_LINE | SPEEDUP_FILLBOX)
-#endif
/*
- * SpeedUp routines which are not dependent on ET4000
+ * This file contains declarations for public XFree86 functions and variables,
+ * and definitions of public macros.
+ *
+ * "public" means available to video drivers.
*/
-#ifndef SPEEDUP_ANYCHIPSET
-#define SPEEDUP_ANYCHIPSET (SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
-#endif
-
-/* All SpeedUps */
-#define SPEEDUP_ALL (SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \
- SPEEDUP_BITBLT | SPEEDUP_LINE | \
- SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
-
-/* SpeedUp flags used if SpeedUp is not in XF86Config */
-#define SPEEDUP_DEFAULT SPEEDUP_ALL
-
-extern Bool xf86VTSema;
-/* Mouse device private record */
-
-#define MSE_MAPTOX (-1)
-#define MSE_MAPTOY (-2)
-#define MSE_MAXBUTTONS 12
-#define MSE_DFLTBUTTONS 3
-
-typedef struct _MouseDevRec {
- DeviceProc mseProc; /* procedure for initializing */
- void (* mseEvents)(
-#if NeedNestedPrototypes
- struct _MouseDevRec *
-#endif
- ); /* proc for processing events */
- DeviceIntPtr device;
- int mseFd;
- char *mseDevice;
- int mseType;
- int mseModel;
- int baudRate;
- int oldBaudRate;
- int sampleRate;
- int lastButtons;
- int threshold, num, den; /* acceleration */
- int buttons; /* # of buttons */
- int emulateState; /* automata state for 2 button mode */
- Bool emulate3Buttons;
- int emulate3Timeout; /* Timeout for 3 button emulation */
- Bool chordMiddle;
- int mouseFlags; /* Flags to Clear after opening mouse dev */
- int truebuttons; /* Arg to maintain before emulate3buttons timer callback */
-
- int resolution;
- int negativeZ;
- int positiveZ;
-#ifndef MOUSE_PROTOCOL_IN_KERNEL
- unsigned char protoPara[7];
-#endif
-
-#ifndef CSRG_BASED
- /* xque part */
- int xquePending; /* was xqueFd, but nothing uses that */
- int xqueSema;
-#endif
-#ifdef XINPUT
- struct _LocalDeviceRec *local;
-#endif
-} MouseDevRec, *MouseDevPtr;
+#ifndef _XF86_H
+#define _XF86_H
-#ifdef XINPUT
-#define MOUSE_DEV(dev) (MouseDevPtr) PRIVATE(dev)
+#include "xf86str.h"
+#include "xf86Opt.h"
+#include <X11/Xfuncproto.h>
+#ifndef IN_MODULE
+#include <stdarg.h>
#else
-#define MOUSE_DEV(dev) (MouseDevPtr) (dev)->public.devicePrivate
+#include "xf86_ansic.h"
+#endif
+
+#include "propertyst.h"
+
+/* General parameters */
+extern int xf86DoConfigure;
+extern Bool xf86DoConfigurePass1;
+extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
+extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
+extern int xf86PixmapIndex;
+extern Bool xf86ResAccessEnter;
+extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
+extern const unsigned char byte_reversed[256];
+extern PropertyPtr *xf86RegisteredPropertiesTable;
+extern ScrnInfoPtr xf86CurrentScreen;
+extern Bool pciSlotClaimed;
+extern Bool isaSlotClaimed;
+extern Bool fbSlotClaimed;
+#ifdef __sparc__
+extern Bool sbusSlotClaimed;
+#endif
+extern confDRIRec xf86ConfigDRI;
+extern Bool xf86inSuspend;
+
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
+
+#define XF86FLIP_PIXELS() \
+ do { \
+ if (xf86GetFlipPixels()) { \
+ pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+ pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+ } \
+ while (0)
+
+#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
+
+#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
+ (((p) == Pix24Use32) ? 32 : 0))
+
+/* variables for debugging */
+#ifdef BUILDDEBUG
+extern char* xf86p8bit[];
+extern CARD32 xf86DummyVar1;
+extern CARD32 xf86DummyVar2;
+extern CARD32 xf86DummyVar3;
#endif
-/* Global data */
-/* xf86Init.c */
-extern double xf86rGamma, xf86gGamma, xf86bGamma;
-
-#ifdef XF86VIDMODE
-extern Bool xf86VidModeEnabled;
-extern Bool xf86VidModeAllowNonLocal;
-#endif
-#ifdef XF86MISC
-extern Bool xf86MiscModInDevEnabled;
-extern Bool xf86MiscModInDevAllowNonLocal;
-#endif
-
-/* PCI probe flags */
-
-
-typedef enum {
- PCIProbe1 = 0,
- PCIProbe2,
- PCIForceConfig1,
- PCIForceConfig2
-} PciProbeType;
-
-extern PciProbeType xf86PCIFlags;
-
/* Function Prototypes */
#ifndef _NO_XF86_PROTOTYPES
-/* xf86Init.c */
-void InitOutput(
-#if NeedFunctionPrototypes
- ScreenInfo *pScreenInfo,
- int argc,
- char **argv
-#endif
-);
-
-void InitInput(
-#if NeedFunctionPrototypes
- int argc,
- char **argv
-#endif
-);
-
-void ddxGiveUp(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-void AbortDDX(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-int ddxProcessArgument(
-#if NeedFunctionPrototypes
- int argc,
- char *argv[],
- int i
-#endif
-);
-
-void ddxUseMsg(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-/* xf86Config.c */
-unsigned int StrToUL(
-#if NeedFunctionPrototypes
- char *str
-#endif
-);
-
-#ifndef CONFIG_RETURN_TYPE
-#ifdef XF86SETUP
-#define CONFIG_RETURN_TYPE int
-#else
-#define CONFIG_RETURN_TYPE void
-#endif
-#endif
-
-CONFIG_RETURN_TYPE xf86Config(
-#if NeedFunctionPrototypes
- int vtopen
-#endif
-);
-
-CONFIG_RETURN_TYPE configPointerSection(
-#if NeedFunctionPrototypes
- MouseDevPtr /*mouse_dev*/,
- int /*end_tag*/,
- char** /*devicename*/
-#endif
-);
-
-Bool xf86LookupMode(
-#if NeedFunctionPrototypes
- DisplayModePtr target,
- ScrnInfoPtr driver,
- int flags
-#endif
-);
-
-void xf86VerifyOptions(
-#if NeedFunctionPrototypes
- OFlagSet *allowedOptions,
- ScrnInfoPtr driver
-#endif
-);
-
-int xf86CheckMode(
-#if NeedFunctionPrototypes
- ScrnInfoPtr scrp,
- DisplayModePtr dispmp,
- MonPtr monp,
- int verbose
-#endif
-);
-
-int xf86GetNearestClock(
-#if NeedFunctionPrototypes
- ScrnInfoPtr Screen,
- int Frequency
-#endif
-);
-
+/* xf86Bus.c */
+
+Bool xf86CheckPciSlot(int bus, int device, int func);
+int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active);
+Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
+ int *func);
+Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
+void xf86FormatPciBusNumber(int busnum, char *buffer);
+pciVideoPtr *xf86GetPciVideoInfo(void);
+pciConfigPtr *xf86GetPciConfigInfo(void);
+void xf86SetPciVideo(pciVideoPtr, resType);
+void xf86PrintResList(int verb, resPtr list);
+resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
+int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86GetIsaInfoForScreen(int scrnIndex);
+int xf86GetFbInfoForScreen(int scrnIndex);
+Bool xf86ParseIsaBusString(const char *busID);
+int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+void xf86EnableAccess(ScrnInfoPtr pScrn);
+void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
+Bool xf86IsPrimaryPci(pciVideoPtr pPci);
+Bool xf86IsPrimaryIsa(void);
+int xf86CheckPciGAType(pciVideoPtr pPci);
+/* new RAC */
+resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex);
+resPtr xf86JoinResLists(resPtr rlist1, resPtr rlist2);
+resPtr xf86DupResList(const resPtr rlist);
+void xf86FreeResList(resPtr rlist);
+void xf86ClaimFixedResources(resList list, int entityIndex);
+Bool xf86DriverHasEntities(DriverPtr drvp);
+void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
+ int instance);
+int xf86GetNumEntityInstances(int entityIndex);
+GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
+void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
+int xf86GetPciEntity(int bus, int dev, int func);
+Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer);
+void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
+resPtr xf86RegisterResources(int entityIndex, resList list,
+ unsigned long Access);
+Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs);
+Bool xf86IsEntityPrimary(int entityIndex);
+Bool xf86FixPciResource(int entityIndex, int prt, memType alignment,
+ unsigned long type);
+resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
+resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
+void xf86EnterServerState(xf86State state);
+resRange xf86GetBlock(unsigned long type, memType size,
+ memType window_start, memType window_end,
+ memType align_mask, resPtr avoid);
+resRange xf86GetSparse(unsigned long type, memType fixed_bits,
+ memType decode_mask, memType address_mask,
+ resPtr avoid);
+memType xf86ChkConflict(resRange *rgp, int entityIndex);
+Bool xf86IsPciDevPresent(int bus, int dev, int func);
+ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
+Bool xf86NoSharedResources(int screenIndex, resType res);
+resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
+pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
+ char n, pciVideoPtr pvp_exclude);
+pciVideoPtr xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
+ char n, pciVideoPtr pvp_exclude);
+#ifdef INCLUDE_DEPRECATED
+void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable);
+#endif
+void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
+Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
+#ifdef async
+Bool xf86QueueAsyncEvent(void (*func)(pointer),pointer arg);
+#endif
+
+int xf86GetLastScrnFlag(int entityIndex);
+void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
+Bool xf86IsEntityShared(int entityIndex);
+void xf86SetEntityShared(int entityIndex);
+Bool xf86IsEntitySharable(int entityIndex);
+void xf86SetEntitySharable(int entityIndex);
+Bool xf86IsPrimInitDone(int entityIndex);
+void xf86SetPrimInitDone(int entityIndex);
+void xf86ClearPrimInitDone(int entityIndex);
+int xf86AllocateEntityPrivateIndex(void);
+DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
+
+/* xf86Configure.c */
+GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
+ void *busData, int chipset);
+GDevPtr xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo,
+ int chipset);
+
/* xf86Cursor.c */
-void xf86InitViewport(
-#if NeedFunctionPrototypes
- ScrnInfoPtr pScr
-#endif
-);
-
-void xf86SetViewport(
-#if NeedFunctionPrototypes
- ScreenPtr pScreen,
- int x,
- int y
-#endif
-);
-
-void xf86LockZoom(
-#if NeedFunctionPrototypes
- ScreenPtr pScreen,
- int lock
-#endif
-);
-
-void xf86ZoomViewport(
-#if NeedFunctionPrototypes
- ScreenPtr pScreen,
- int zoom
-#endif
-);
-
-/* xf86Dl.c */
-void*
-xf86LoadModule(
-#if NeedFunctionPrototypes
- const char * file,
- const char * path
-#endif
-);
-
-/* xf86Events.c */
-int TimeSinceLastInputEvent(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-void SetTimeSinceLastInputEvent(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-void ProcessInputEvents(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-void xf86PostKbdEvent(
-#if NeedFunctionPrototypes
- unsigned key
-#endif
-);
-
-void xf86PostMseEvent(
-#if NeedFunctionPrototypes
- DeviceIntPtr device,
- int buttons,
- int dx,
- int dy
-#endif
-);
+void xf86LockZoom(ScreenPtr pScreen, int lock);
+void xf86InitViewport(ScrnInfoPtr pScr);
+void xf86SetViewport(ScreenPtr pScreen, int x, int y);
+void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
+Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
+void *xf86GetPointerScreenFuncs(void);
+void xf86InitOrigins(void);
+void xf86ReconfigureLayout(void);
+
+/* xf86DPMS.c */
-void xf86Block(
-#if NeedFunctionPrototypes
- pointer blockData,
- OSTimePtr pTimeout,
- pointer pReadmask
-#endif
-);
+Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
-void xf86Wakeup(
-#if NeedFunctionPrototypes
- pointer blockData,
- int err,
- pointer pReadmask
-#endif
-);
+/* xf86DGA.c */
-void xf86SigHandler(
-#if NeedFunctionPrototypes
- int signo
-#endif
-);
-
-/* xf86Io.c */
-void xf86KbdBell(
-#if NeedFunctionPrototypes
- int percent,
- DeviceIntPtr pKeyboard,
- pointer ctrl,
- int unused
-#endif
-);
-
-void xf86KbdLeds(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
+ int num);
+xf86SetDGAModeProc xf86SetDGAMode;
-void xf86KbdCtrl(
-#if NeedFunctionPrototypes
- DevicePtr pKeyboard,
- KeybdCtrl *ctrl
-#endif
-);
-
-void xf86InitKBD(
-#if NeedFunctionPrototypes
- Bool init
-#endif
-);
-
-int xf86KbdProc(
-#if NeedFunctionPrototypes
- DeviceIntPtr pKeyboard,
- int what
-#endif
-);
-
-void xf86MseCtrl(
-#if NeedFunctionPrototypes
- DevicePtr pPointer,
- PtrCtrl *ctrl
-#endif
-);
-
-int GetMotionEvents(
-#if NeedFunctionPrototypes
- DeviceIntPtr,
- xTimecoord *,
- unsigned long,
- unsigned long,
- ScreenPtr
-#endif
-);
+/* xf86Events.c */
-int xf86MseProc(
-#if NeedFunctionPrototypes
- DeviceIntPtr pPointer,
- int what
-#endif
-);
+void SetTimeSinceLastInputEvent(void);
+pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+int xf86RemoveInputHandler(pointer handler);
+void xf86DisableInputHandler(pointer handler);
+void xf86EnableInputHandler(pointer handler);
+void xf86InterceptSignals(int *signo);
+Bool xf86EnableVTSwitch(Bool new);
+Bool xf86CommonSpecialKey(int key, Bool down, int modifiers);
+void xf86ProcessActionEvent(ActionEvent action, void *arg);
+
+/* xf86Helper.c */
+
+void xf86AddDriver(DriverPtr driver, pointer module, int flags);
+void xf86DeleteDriver(int drvIndex);
+ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
+void xf86DeleteScreen(int scrnIndex, int flags);
+int xf86AllocateScrnInfoPrivateIndex(void);
+Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
+Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
+ int depth24flags);
+void xf86PrintDepthBpp(ScrnInfoPtr scrp);
+Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
+void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+void xf86SetBlackWhitePixels(ScreenPtr pScreen);
+void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
+void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, va_list args);
+void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, ...);
+void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...);
+void xf86MsgVerb(MessageType type, int verb, const char *format, ...);
+void xf86Msg(MessageType type, const char *format, ...);
+void xf86ErrorFVerb(int verb, const char *format, ...);
+void xf86ErrorF(const char *format, ...);
+const char *xf86TokenToString(SymTabPtr table, int token);
+int xf86StringToToken(SymTabPtr table, const char *string);
+void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+ SymTabPtr chips);
+int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
+int xf86MatchPciInstances(const char *driverName, int vendorID,
+ SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities);
+int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
+ IsaChipsets *ISAchipsets, DriverPtr drvp,
+ FindIsaDevProc FindIsaDevice, GDevPtr *devList,
+ int numDevs, int **foundEntities);
+void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+ Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool),
+ IOADDRESS vertsyncreg, int maskval,
+ int knownclkindex, int knownclkvalue);
+void xf86SetPriority(Bool up);
+const char *xf86GetVisualName(int visual);
+int xf86GetVerbosity(void);
+Pix24Flags xf86GetPix24(void);
+int xf86GetDepth(void);
+rgb xf86GetWeight(void);
+Gamma xf86GetGamma(void);
+Bool xf86GetFlipPixels(void);
+const char *xf86GetServerName(void);
+Bool xf86ServerIsExiting(void);
+Bool xf86ServerIsResetting(void);
+Bool xf86ServerIsInitialising(void);
+Bool xf86ServerIsOnlyDetecting(void);
+Bool xf86ServerIsOnlyProbing(void);
+Bool xf86CaughtSignal(void);
+Bool xf86GetVidModeAllowNonLocal(void);
+Bool xf86GetVidModeEnabled(void);
+Bool xf86GetModInDevAllowNonLocal(void);
+Bool xf86GetModInDevEnabled(void);
+Bool xf86GetAllowMouseOpenFail(void);
+Bool xf86IsPc98(void);
+void xf86DisableRandR(void);
+CARD32 xf86GetVersion(void);
+CARD32 xf86GetModuleVersion(pointer module);
+pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+pointer xf86LoadOneModule(char *name, pointer optlist);
+void xf86UnloadSubModule(pointer mod);
+Bool xf86LoaderCheckSymbol(const char *name);
+void xf86LoaderReqSymLists(const char **, ...);
+void xf86LoaderReqSymbols(const char *, ...);
+void xf86LoaderRefSymLists(const char **, ...);
+void xf86LoaderRefSymbols(const char *, ...);
+void xf86SetBackingStore(ScreenPtr pScreen);
+void xf86SetSilkenMouse(ScreenPtr pScreen);
+int xf86NewSerialNumber(WindowPtr p, pointer unused);
+pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options);
+void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
+ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex,PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+ int entityIndex,PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn,
+ int entityIndex, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+Bool xf86IsScreenPrimary(int scrnIndex);
+int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len,
+ pointer value);
+Bool xf86IsUnblank(int mode);
+
+#ifdef XFree86LOADER
+void xf86AddModuleInfo(ModuleInfoPtr info, pointer module);
+void xf86DeleteModuleInfo(int idx);
+#endif
+
+/* xf86Debug.c */
+#ifdef BUILDDEBUG
+ void xf86Break1(void);
+void xf86Break2(void);
+void xf86Break3(void);
+CARD8 xf86PeekFb8(CARD8 *p);
+CARD16 xf86PeekFb16(CARD16 *p);
+CARD32 xf86PeekFb32(CARD32 *p);
+void xf86PokeFb8(CARD8 *p, CARD8 v);
+void xf86PokeFb16(CARD16 *p, CARD16 v);
+void xf86PokeFb32(CARD16 *p, CARD32 v);
+CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset);
+CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset);
+CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset);
+void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v);
+void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v);
+void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v);
+extern void xf86SPTimestamp(xf86TsPtr* timestamp, char* string);
+extern void xf86STimestamp(xf86TsPtr* timestamp);
+#endif
+
+/* xf86Init.c */
-void xf86MseEvents(
-#if NeedFunctionPrototypes
- MouseDevPtr mouse
-#endif
-);
+PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
+int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
-CARD32 GetTimeInMillis(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+/* xf86Mode.c */
-void OsVendorInit(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int DivFactor, int MulFactor, int *divider);
+const char *xf86ModeStatusToString(ModeStatus status);
+ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy);
+ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
+ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX,
+ int virtualY);
+ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ int flags);
+int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch,
+ int minHeight, int maxHeight, int pitchInc,
+ int virtualX, int virtualY, int apertureSize,
+ LookupModeFlags strategy);
+void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+void xf86PruneDriverModes(ScrnInfoPtr scrp);
+void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+void xf86PrintModes(ScrnInfoPtr scrp);
+void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
-/* xf86_Mouse.c */
-Bool xf86MouseSupported(
-#if NeedFunctionPrototypes
- int mousetype
-#endif
-);
+/* xf86Option.c */
-void xf86SetupMouse(
-#if NeedFunctionPrototypes
- MouseDevPtr mouse
-#endif
-);
+void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
-void xf86MouseProtocol(
-#if NeedFunctionPrototypes
- DeviceIntPtr device,
- unsigned char *rBuf,
- int nBytes
-#endif
-);
-#ifdef XINPUT
-void xf86MouseCtrl(
-#if NeedFunctionPrototypes
- DeviceIntPtr device,
- PtrCtrl *ctrl
-#endif
-);
+/* xf86RandR.c */
+#ifdef RANDR
+Bool xf86RandRInit (ScreenPtr pScreen);
+void xf86RandRSetInitialMode (ScreenPtr pScreen);
#endif
-/* xf86_PnPMouse.c */
-int xf86GetPnPMouseProtocol(
-#if NeedFunctionPrototypes
- MouseDevPtr mouse
-#endif
-);
+/* xf86VidModeExtentionInit.c */
-/* xf86Kbd.c */
-Bool LegalModifier(
-#if NeedFunctionPrototypes
- unsigned int key,
- DevicePtr pDev
-#endif
-);
+Bool VidModeExtensionInit(ScreenPtr pScreen);
-void xf86KbdGetMapping(
-#if NeedFunctionPrototypes
- KeySymsPtr pKeySyms,
- CARD8 *pModMap
-#endif
-);
#endif /* _NO_XF86_PROTOTYPES */
-/* End of Prototypes */
-
#endif /* _XF86_H */
-
-
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index e523dd0fc..1738222f5 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1,245 +1,98 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.269 2003/02/20 04:36:07 dawes Exp $ */
+
+
/*
- * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.113.2.17 1998/02/24 19:05:54 hohndel Exp $
+ * Copyright 1991-2002 by The XFree86 Project, Inc.
+ * Copyright 1997 by Metro Link, Inc.
*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Loosely based on code bearing the following copyright:
*
- * 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
- * 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.
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
- * THOMAS ROELL 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
- * 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.
+ * <Put copyright message here>
+ *
+ * Author: Dirk Hohndel <hohndel@XFree86.Org> and others.
*/
-/* $Xorg: xf86Config.c,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */
-
-#ifndef X_NOT_STDC_ENV
-#include <stdlib.h>
-#else
-extern double atof();
-extern char *getenv();
-#endif
-
-#define NEED_EVENTS 1
-#include "X.h"
-#include "Xproto.h"
-#include "Xmd.h"
-#include "input.h"
-#include "servermd.h"
-#include "scrnintstr.h"
-#ifdef DPMSExtension
-#include "opaque.h"
-extern CARD32 DPMSStandbyTime;
-extern CARD32 DPMSSuspendTime;
-extern CARD32 DPMSOffTime;
+#ifdef XF86DRI
+#include <sys/types.h>
+#include <grp.h>
#endif
-#define NO_COMPILER_H_EXTRAS
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#define INIT_CONFIG
-#include "xf86_Config.h"
-
-#ifdef XKB
-#include "inputstr.h"
-#include "XKBsrv.h"
-#endif
-
-#ifdef XF86SETUP
-#include "xfsconf.h"
-#endif
+#include "globals.h"
#ifdef XINPUT
#include "xf86Xinput.h"
-
-#ifndef XF86SETUP
-extern DeviceAssocRec mouse_assoc;
-#endif
+extern DeviceAssocRec mouse_assoc;
#endif
-#ifdef NEED_RETURN_VALUE
-#define HANDLE_RETURN(xx) if (xx == RET_ERROR) return RET_ERROR
-#else
-#define HANDLE_RETURN(xx) xx
+#ifdef XKB
+#define XKB_IN_SERVER
+#include "XKBsrv.h"
#endif
-#define CONFIG_BUF_LEN 1024
-
-static FILE * configFile = NULL;
-static int configStart = 0; /* start of the current token */
-static int configPos = 0; /* current readers position */
-static int configLineNo = 0; /* linenumber */
-static char *configBuf,*configRBuf; /* buffer for lines */
-static char *configPath; /* path to config file */
-static char *fontPath = NULL; /* font path */
-static char *modulePath = NULL; /* module path */
-static int pushToken = LOCK_TOKEN;
-static LexRec val; /* global return value */
-static char DCerr;
-static int scr_index = 0;
-
-#ifdef XF86SETUP
-#define STATIC_OR_NOT
-#else
-#define STATIC_OR_NOT static
+#ifdef RENDER
+#include "picture.h"
#endif
-STATIC_OR_NOT int n_monitors = 0;
-STATIC_OR_NOT MonPtr monitor_list = NULL;
-STATIC_OR_NOT int n_devices = 0;
-STATIC_OR_NOT GDevPtr device_list = NULL;
-
-static int screenno = -100; /* some little number ... */
-extern char *defaultFontPath;
-extern char *rgbPath;
-
-extern Bool xf86fpFlag, xf86coFlag, xf86sFlag;
-extern Bool xf86ScreensOpen;
-
-extern int defaultColorVisualClass;
-extern CARD32 defaultScreenSaverTime, ScreenSaverTime;
-
-char *xf86VisualNames[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor"
-};
-
-static CONFIG_RETURN_TYPE configFilesSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configServerFlagsSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configKeyboardSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configDeviceSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configScreenSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configDisplaySubsection(
-#if NeedFunctionPrototypes
- DispPtr disp
-#endif
-);
-static CONFIG_RETURN_TYPE configMonitorSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static CONFIG_RETURN_TYPE configDynamicModuleSection(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-static char *xf86DCSaveLine(
-#if NeedFunctionPrototypes
-char *,
-int
-#endif
-);
-static char *xf86DCOption(
-#if NeedFunctionPrototypes
-char *,
-LexRec
-#endif
-);
-static char * xf86DCConcatOption(
-#if NeedFunctionPrototypes
-char *,
-char *
-#endif
-);
-#ifndef XF86SETUP
-static
-#endif
-CONFIG_RETURN_TYPE findConfigFile(
-#if NeedFunctionPrototypes
- char *filename,
- FILE **fp
-#endif
-);
-static int getScreenIndex(
-#if NeedFunctionPrototypes
- int token
-#endif
-);
-static int getStringToken(
-#if NeedFunctionPrototypes
- SymTabRec tab[]
-#endif
-);
-static CONFIG_RETURN_TYPE readVerboseMode(
-#if NeedFunctionPrototypes
- MonPtr monp
-#endif
-);
-static Bool validateGraphicsToken(
-#if NeedFunctionPrototypes
- int *validTokens,
- int token
-#endif
-);
-extern char * xf86GetPathElem(
-#if NeedFunctionPrototypes
- char **pnt
-#endif
-);
-static DisplayModePtr xf86PruneModes(
-#if NeedFunctionPrototypes
- MonPtr monp,
- DisplayModePtr allmodes,
- ScrnInfoPtr scrp,
- Bool card
-#endif
-);
-static char * xf86ValidateFontPath(
-#if NeedFunctionPrototypes
- char * /* path */
-#endif
-);
-#ifdef XINPUT
-extern CONFIG_RETURN_TYPE xf86ConfigExtendedInputSection(
-#if NeedFunctionPrototypes
- LexPtr pval
-#endif
-);
+#if (defined(i386) || defined(__i386__)) && \
+ (defined(__FreeBSD__) || defined(__NetBSD__) || defined(linux) || \
+ (defined(SVR4) && !defined(sun)) || defined(__GNU__))
+#define SUPPORT_PC98
#endif
-#ifdef XKB
-extern char *XkbInitialMap;
+/*
+ * These paths define the way the config file search is done. The escape
+ * sequences are documented in parser/scan.c.
+ */
+#ifndef ROOT_CONFIGPATH
+#define ROOT_CONFIGPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "%E," "%F," \
+ "/etc/X11/%F," "%P/etc/X11/%F," \
+ "%D/%X," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef USER_CONFIGPATH
+#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \
+ "/etc/X11/%G," "%P/etc/X11/%G," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+
+static char *fontPath = NULL;
+
+/* Forward declarations */
+static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
+ int scrnum, MessageType from);
+static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
+static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
+ Bool active);
+static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input,
+ MessageType from);
+static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
+static Bool addDefaultModes(MonPtr monitorp);
+#ifdef XF86DRI
+static Bool configDRI(XF86ConfDRIPtr drip);
#endif
-#define DIR_FILE "/fonts.dir"
-
/*
* xf86GetPathElem --
* Extract a single element from the font path string starting at
@@ -247,9 +100,8 @@ extern char *XkbInitialMap;
* updated to point to the start of the next element, or set to
* NULL if there are no more.
*/
-char *
-xf86GetPathElem(pnt)
- char **pnt;
+static char *
+xf86GetPathElem(char **pnt)
{
char *p1;
@@ -263,46 +115,6 @@ xf86GetPathElem(pnt)
}
/*
- * StrToUL --
- *
- * A portable, but restricted, version of strtoul(). It only understands
- * hex, octal, and decimal. But it's good enough for our needs.
- */
-unsigned int StrToUL(str)
-char *str;
-{
- int base = 10;
- char *p = str;
- unsigned int tot = 0;
-
- if (*p == '0') {
- p++;
- if (*p == 'x') {
- p++;
- base = 16;
- }
- else
- base = 8;
- }
- while (*p) {
- if ((*p >= '0') && (*p <= ((base == 8)?'7':'9'))) {
- tot = tot * base + (*p - '0');
- }
- else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) {
- tot = tot * base + 10 + (*p - 'a');
- }
- else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) {
- tot = tot * base + 10 + (*p - 'A');
- }
- else {
- return(tot);
- }
- p++;
- }
- return(tot);
-}
-
-/*
* xf86ValidateFontPath --
* Validates the user-specified font path. Each element that
* begins with a '/' is checked to make sure the directory exists.
@@ -310,31 +122,30 @@ char *str;
* is checked. If either check fails, an error is printed and the
* element is removed from the font path.
*/
-#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type))
+
+#define DIR_FILE "/fonts.dir"
static char *
-xf86ValidateFontPath(path)
- char *path;
+xf86ValidateFontPath(char *path)
{
char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
struct stat stat_buf;
int flag;
int dirlen;
- tmp_path = (char *)Xcalloc(strlen(path)+1);
+ tmp_path = xcalloc(1,strlen(path)+1);
out_pnt = tmp_path;
path_elem = NULL;
next = path;
while (next != NULL) {
path_elem = xf86GetPathElem(&next);
-#ifndef __EMX__
if (*path_elem == '/') {
- dir_elem = (char *)Xcalloc(strlen(path_elem) + 1);
+#ifndef __UNIXOS2__
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
if ((p1 = strchr(path_elem, ':')) != 0)
#else
/* OS/2 must prepend X11ROOT */
- if (*path_elem == '/') {
path_elem = (char*)__XOS2RedirRoot(path_elem);
- dir_elem = (char*)xcalloc(1, strlen(path_elem) + 1);
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
if (p1 = strchr(path_elem+2, ':'))
#endif
dirlen = p1 - path_elem;
@@ -344,29 +155,32 @@ xf86ValidateFontPath(path)
dir_elem[dirlen] = '\0';
flag = stat(dir_elem, &stat_buf);
if (flag == 0)
- if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR))
+ if (!S_ISDIR(stat_buf.st_mode))
flag = -1;
if (flag != 0) {
- ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem);
- ErrorF(" Entry deleted from font path.\n");
+ xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xfree(dir_elem);
continue;
}
else {
- p1 = (char *)xalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
+ p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
strcpy(p1, dir_elem);
strcat(p1, DIR_FILE);
flag = stat(p1, &stat_buf);
if (flag == 0)
- if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
+ if (!S_ISREG(stat_buf.st_mode))
flag = -1;
-#ifndef __EMX__
+#ifndef __UNIXOS2__
xfree(p1);
#endif
if (flag != 0) {
- ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n",
- dir_elem);
- ErrorF(" Entry deleted from font path.\n");
- ErrorF(" (Run 'mkfontdir' on \"%s\").\n", dir_elem);
+ xf86Msg(X_WARNING,
+ "`fonts.dir' not found (or not valid) in \"%s\".\n",
+ dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
+ xfree(dir_elem);
continue;
}
}
@@ -385,3550 +199,2138 @@ xf86ValidateFontPath(path)
return(tmp_path);
}
+
/*
- * xf86GetToken --
- * Read next Token form the config file. Handle the global variable
- * pushToken.
+ * use the datastructure that the parser provides and pick out the parts
+ * that we need at this point
*/
-int
-xf86GetToken(tab)
- SymTabRec tab[];
+char **
+xf86ModulelistFromConfig(pointer **optlist)
{
- int c, i;
-
- /*
- * First check whether pushToken has a different value than LOCK_TOKEN.
- * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the other
- * case the next token must be read from the input.
- */
- if (pushToken == EOF) return(EOF);
- else if (pushToken == LOCK_TOKEN)
- {
-
- c = configBuf[configPos];
-
- /*
- * Get start of next Token. EOF is handled, whitespaces & comments are
- * skipped.
- */
- do {
- if (!c) {
- if (fgets(configBuf,CONFIG_BUF_LEN-1,configFile) == NULL)
- {
- return( pushToken = EOF );
- }
- configLineNo++;
- configStart = configPos = 0;
+ int count = 0;
+ char **modulearray;
+ pointer *optarray;
+ XF86LoadPtr modp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ if (xf86configptr->conf_modules) {
+ /*
+ * Walk the list of modules in the "Module" section to determine how
+ * many we have.
+ */
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
}
-#ifndef __EMX__
- while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n'));
-#else
- while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n')
- || (c=='\r'));
-#endif
- if (c == '#') c = '\0';
- } while (!c);
-
- /* GJA -- handle '-' and ','
- * Be careful: "-hsync" is a keyword.
- */
- if ( (c == ',') && !isalpha(configBuf[configPos]) ) {
- configStart = configPos; return COMMA;
- } else if ( (c == '-') && !isalpha(configBuf[configPos]) ) {
- configStart = configPos; return DASH;
- }
+ }
+ if (count == 0)
+ return NULL;
- configStart = configPos;
- /*
- * Numbers are returned immediately ...
- */
- if (isdigit(c))
- {
- int base;
-
- if (c == '0')
- if ((configBuf[configPos] == 'x') ||
- (configBuf[configPos] == 'X'))
- base = 16;
- else
- base = 8;
- else
- base = 10;
-
- configRBuf[0] = c; i = 1;
- while (isdigit(c = configBuf[configPos++]) ||
- (c == '.') || (c == 'x') ||
- ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
- ((c >= 'A') && (c <= 'F')))))
- configRBuf[i++] = c;
- configPos--; /* GJA -- one too far */
- configRBuf[i] = '\0';
- val.num = StrToUL(configRBuf);
- val.realnum = atof(configRBuf);
- return(NUMBER);
- }
-
- /*
- * All Strings START with a \" ...
- */
- else if (c == '\"')
- {
- i = -1;
- do {
- configRBuf[++i] = (c = configBuf[configPos++]);
-#ifndef __EMX__
- } while ((c != '\"') && (c != '\n') && (c != '\0'));
-#else
- } while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
-#endif
- configRBuf[i] = '\0';
- val.str = (char *)xalloc(strlen(configRBuf) + 1);
- strcpy(val.str, configRBuf); /* private copy ! */
- return(STRING);
- }
-
- /*
- * ... and now we MUST have a valid token. The search is
- * handled later along with the pushed tokens.
- */
- else
- {
- configRBuf[0] = c;
- i = 0;
- do {
- configRBuf[++i] = (c = configBuf[configPos++]);;
-#ifndef __EMX__
- } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\0'));
-#else
- } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') );
-#endif
- configRBuf[i] = '\0'; i=0;
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ optarray = xnfalloc((count + 1) * sizeof(pointer));
+ count = 0;
+ if (xf86configptr->conf_modules) {
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ modulearray[count] = modp->load_name;
+ optarray[count] = modp->load_opt;
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
}
-
}
- else
- {
-
- /*
- * Here we deal with pushed tokens. Reinitialize pushToken again. If
- * the pushed token was NUMBER || STRING return them again ...
- */
- int temp = pushToken;
- pushToken = LOCK_TOKEN;
+ modulearray[count] = NULL;
+ optarray[count] = NULL;
+ if (optlist)
+ *optlist = optarray;
+ else
+ xfree(optarray);
+ return modulearray;
+}
+
+
+char **
+xf86DriverlistFromConfig()
+{
+ int count = 0;
+ int j;
+ char **modulearray;
+ screenLayoutPtr slp;
- if (temp == COMMA || temp == DASH) return(temp);
- if (temp == NUMBER || temp == STRING) return(temp);
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
}
-
- /*
- * Joop, at last we have to lookup the token ...
- */
- if (tab)
- {
- i = 0;
- while (tab[i].token != -1)
- if (StrCaseCmp(configRBuf,tab[i].name) == 0)
- return(tab[i].token);
- else
- i++;
+
+ /*
+ * Walk the list of driver lines in active "Device" sections to
+ * determine now many implicitly loaded modules there are.
+ *
+ */
+ if (xf86ConfigLayout.screens) {
+ slp = xf86ConfigLayout.screens;
+ while ((slp++)->screen) {
+ count++;
+ }
}
-
- return(ERROR_TOKEN); /* Error catcher */
-}
-/*
- * xf86GetToken --
- * Lookup a string if it is actually a token in disguise.
- */
-static int
-getStringToken(tab)
- SymTabRec tab[];
-{
- int i;
+ /*
+ * Handle the set of inactive "Device" sections.
+ */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j++].identifier)
+ count++;
- for ( i = 0 ; tab[i].token != -1 ; i++ ) {
- if ( ! StrCaseCmp(tab[i].name,val.str) ) return tab[i].token;
- }
- return(ERROR_TOKEN);
-}
+ if (count == 0)
+ return NULL;
-/*
- * getScreenIndex --
- * Given the screen token, returns the index in xf86Screens, or -1 if
- * the screen type is not applicable to this server.
- */
-static int
-getScreenIndex(token)
- int token;
-{
- int i;
-
- for (i = 0; xf86ScreenNames[i] >= 0 && xf86ScreenNames[i] != token; i++)
- ;
- if (xf86ScreenNames[i] < 0)
- return(-1);
- else
- return(i);
-}
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ slp = xf86ConfigLayout.screens;
+ while (slp->screen) {
+ modulearray[count] = slp->screen->device->driver;
+ count++;
+ slp++;
+ }
-/*
- * validateGraphicsToken --
- * If token is a graphics token, check it is in the list of validTokens
- * XXXX This needs modifying to work as it did with the old format
- */
-static Bool
-validateGraphicsToken(validTokens, token)
- int *validTokens;
- int token;
-{
- int i;
+ j = 0;
- for (i = 0; ScreenTab[i].token >= 0 && ScreenTab[i].token != token; i++)
- ;
- if (ScreenTab[i].token < 0)
- return(FALSE); /* Not a graphics token */
+ while (xf86ConfigLayout.inactives[j].identifier)
+ modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
- for (i = 0; validTokens[i] >= 0 && validTokens[i] != token; i++)
- ;
- return(validTokens[i] >= 0);
-}
+ modulearray[count] = NULL;
-/*
- * xf86TokenToString --
- * returns the string corresponding to token
- */
-char *
-xf86TokenToString(table, token)
- SymTabPtr table;
- int token;
-{
- int i;
-
- for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
- ;
- if (table[i].token < 0)
- return("unknown");
- else
- return(table[i].name);
-}
-
-/*
- * xf86StringToToken --
- * returns the string corresponding to token
- */
-int
-xf86StringToToken(table, string)
- SymTabPtr table;
- char *string;
-{
- int i;
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
- for (i = 0; table[i].token >= 0 && StrCaseCmp(string, table[i].name); i++)
- ;
- return(table[i].token);
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
}
-
-/*
- * xf86ConfigError --
- * Print a READABLE ErrorMessage!!! All information that is
- * interesting is printed. Even a pointer to the erroneous place is
- * printed. Maybe our e-mail will be less :-)
- */
-#ifdef XF86SETUP
-int
-XF86SetupXF86ConfigError(msg)
-#else
-void
-xf86ConfigError(msg)
-#endif
- char *msg;
-{
- int i,j;
- ErrorF( "\nConfig Error: %s:%d\n\n%s", configPath, configLineNo, configBuf);
- for (i = 1, j = 1; i < configStart; i++, j++)
- if (configBuf[i-1] != '\t')
- ErrorF(" ");
- else
- do
- ErrorF(" ");
- while (((j++)%8) != 0);
- for (i = configStart; i <= configPos; i++) ErrorF("^");
- ErrorF("\n%s\n", msg);
-#ifdef NEED_RETURN_VALUE
- return RET_ERROR;
-#else
- exit(-1); /* simple exit ... */
-#endif
-}
-#ifndef XF86SETUP
-void
-xf86DeleteMode(infoptr, dispmp)
-ScrnInfoPtr infoptr;
-DisplayModePtr dispmp;
+Bool
+xf86BuiltinInputDriver(const char *name)
{
- if(infoptr->modes == dispmp)
- infoptr->modes = dispmp->next;
-
- if(dispmp->next == dispmp)
- FatalError("No valid modes found.\n");
-
- ErrorF("%s %s: Removing mode \"%s\" from list of valid modes.\n",
- XCONFIG_PROBED, infoptr->name, dispmp->name);
- dispmp->prev->next = dispmp->next;
- dispmp->next->prev = dispmp->prev;
-
- xfree(dispmp->name);
- xfree(dispmp);
+ if (xf86NameCmp(name, "keyboard") == 0)
+ return TRUE;
+ else
+ return FALSE;
}
-#endif
-/*
- * findConfigFile --
- * Locate the XF86Config file. Abort if not found.
- */
-#ifndef XF86SETUP
-static
-#endif
-CONFIG_RETURN_TYPE
-findConfigFile(filename, fp)
- char *filename;
- FILE **fp;
-{
-#define configFile (*fp)
-#define MAXPTRIES 6
- char *home = NULL;
- char *xconfig = NULL;
- char *xwinhome = NULL;
- char *configPaths[MAXPTRIES];
- int pcount = 0, idx;
- /*
- * First open if necessary the config file.
- * If the -xf86config flag was used, use the name supplied there (root only).
- * If $XF86CONFIG is a pathname, use it as the name of the config file (root)
- * If $XF86CONFIG is set but doesn't contain a '/', append it to 'XF86Config'
- * and search the standard places (root only).
- * If $XF86CONFIG is not set, just search the standard places.
- */
- while (!configFile) {
+char **
+xf86InputDriverlistFromConfig()
+{
+ int count = 0;
+ char **modulearray;
+ IDevPtr idp;
/*
- * configPaths[0] is used as a buffer for -xf86config
- * and $XF86CONFIG if it contains a path
- * configPaths[1...MAXPTRIES-1] is used to store the paths of each of
- * the other attempts
- */
- for (pcount = idx = 0; idx < MAXPTRIES; idx++)
- configPaths[idx] = NULL;
-
- /*
- * First check if the -xf86config option was used.
- */
- configPaths[pcount] = (char *)xalloc(PATH_MAX);
-#ifndef __EMX__
- if (getuid() == 0 && xf86ConfigFile[0])
-#else
- if (xf86ConfigFile[0])
-#endif
- {
- strcpy(configPaths[pcount], xf86ConfigFile);
- if ((configFile = fopen(configPaths[pcount], "r")) != 0)
- break;
- else
- FatalError(
- "Cannot read file \"%s\" specified by the -xf86config flag\n",
- configPaths[pcount]);
- }
- /*
- * Check if XF86CONFIG is set.
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
*/
-#ifndef __EMX__
- if (getuid() == 0
- && (xconfig = getenv("XF86CONFIG")) != 0
- && index(xconfig, '/'))
-#else
- /* no root available, and filenames start with drive letter */
- if ((xconfig = getenv("XF86CONFIG")) != 0
- && isalpha(xconfig[0])
- && xconfig[1]==':')
-#endif
- {
- strcpy(configPaths[pcount], xconfig);
- if ((configFile = fopen(configPaths[pcount], "r")) != 0)
- break;
- else
- FatalError(
- "Cannot read file \"%s\" specified by XF86CONFIG variable\n",
- configPaths[pcount]);
- }
-
-#ifndef __EMX__
- /*
- * ~/XF86Config ...
- */
- if (getuid() == 0 && (home = getenv("HOME"))) {
- configPaths[++pcount] = (char *)xalloc(PATH_MAX);
- strcpy(configPaths[pcount],home);
- strcat(configPaths[pcount],"/XF86Config");
- if (xconfig) strcat(configPaths[pcount],xconfig);
- if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break;
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
}
/*
- * /etc/XF86Config
- */
- configPaths[++pcount] = (char *)xalloc(PATH_MAX);
- strcpy(configPaths[pcount], "/etc/XF86Config");
- if (xconfig) strcat(configPaths[pcount],xconfig);
- if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break;
-
- /*
- * $(LIBDIR)/XF86Config.<hostname>
+ * Walk the list of driver lines in active "InputDevice" sections to
+ * determine now many implicitly loaded modules there are.
*/
+ if (xf86ConfigLayout.inputs) {
+ idp = xf86ConfigLayout.inputs;
+ while (idp->identifier) {
+ if (!xf86BuiltinInputDriver(idp->driver))
+ count++;
+ idp++;
+ }
+ }
- configPaths[++pcount] = (char *)xalloc(PATH_MAX);
- if (getuid() == 0 && (xwinhome = getenv("XWINHOME")) != NULL)
- sprintf(configPaths[pcount], "%s/lib/X11/XF86Config", xwinhome);
- else
- strcpy(configPaths[pcount], SERVER_CONFIG_FILE);
- if (getuid() == 0 && xconfig) strcat(configPaths[pcount],xconfig);
- strcat(configPaths[pcount], ".");
-#ifdef AMOEBA
- {
- extern char *XServerHostName;
+ if (count == 0)
+ return NULL;
- strcat(configPaths[pcount], XServerHostName);
- }
-#else
- gethostname(configPaths[pcount]+strlen(configPaths[pcount]),
- MAXHOSTNAMELEN);
-#endif
- if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break;
-#endif /* !__EMX__ */
-
/*
- * $(LIBDIR)/XF86Config
+ * allocate the memory and walk the list again to fill in the pointers
*/
- configPaths[++pcount] = (char *)xalloc(PATH_MAX);
-#ifndef __EMX__
- if (getuid() == 0 && xwinhome)
- sprintf(configPaths[pcount], "%s/lib/X11/XF86Config", xwinhome);
- else
- strcpy(configPaths[pcount], SERVER_CONFIG_FILE);
- if (getuid() == 0 && xconfig) strcat(configPaths[pcount],xconfig);
-#else
- /* we explicitly forbid numerous config files everywhere for OS/2;
- * users should consider them lucky to have one in a standard place
- * and another one with the -xf86config option
- */
- xwinhome = getenv("X11ROOT"); /* get drive letter */
- if (!xwinhome) FatalError("X11ROOT environment variable not set\n");
- strcpy(configPaths[pcount], __XOS2RedirRoot("/XFree86/lib/X11/XConfig"));
-#endif
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ idp = xf86ConfigLayout.inputs;
+ while (idp->identifier) {
+ if (!xf86BuiltinInputDriver(idp->driver)) {
+ modulearray[count] = idp->driver;
+ count++;
+ }
+ idp++;
+ }
+ modulearray[count] = NULL;
- if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break;
-
- ErrorF("\nCould not find config file!\n");
- ErrorF("- Tried:\n");
- for (idx = 1; idx <= pcount; idx++)
- if (configPaths[idx] != NULL)
- ErrorF(" %s\n", configPaths[idx]);
- FatalError("No config file found!\n%s", getuid() == 0 ? "" :
- "Note, the X server no longer looks for XF86Config in $HOME");
- }
- strcpy(filename, configPaths[pcount]);
- if (xf86Verbose) {
- ErrorF("XF86Config: %s\n", filename);
- ErrorF("%s stands for supplied, %s stands for probed/default values\n",
- XCONFIG_GIVEN, XCONFIG_PROBED);
- }
- for (idx = 0; idx <= pcount; idx++)
- if (configPaths[idx] != NULL)
- xfree(configPaths[idx]);
-#undef configFile
-#undef MAXPTRIES
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
}
-static DisplayModePtr pNew, pLast;
-static Bool graphFound = FALSE;
/*
- * xf86GetNearestClock --
- * Find closest clock to given frequency (in kHz). This assumes the
- * number of clocks is greater than zero.
+ * Generate a compiled-in list of driver names. This is used to produce a
+ * consistent probe order. For the loader server, we also look for vendor-
+ * provided modules, pre-pending them to our own list.
*/
-int
-xf86GetNearestClock(Screen, Frequency)
- ScrnInfoPtr Screen;
- int Frequency;
+static char **
+GenerateDriverlist(char * dirname, char * drivernames)
{
- int NearestClock = 0;
- int MinimumGap = abs(Frequency - Screen->clock[0]);
- int i;
- for (i = 1; i < Screen->clocks; i++)
- {
- int Gap = abs(Frequency - Screen->clock[i]);
- if (Gap < MinimumGap)
+ char *cp, **driverlist;
+ int count;
+
+ /* Count the number needed */
+ count = 0;
+ cp = drivernames;
+ while (*cp) {
+ while (*cp && isspace(*cp)) cp++;
+ if (!*cp) break;
+ count++;
+ while (*cp && !isspace(*cp)) cp++;
+ }
+
+ if (!count)
+ return NULL;
+
+ /* Now allocate the array of pointers to 0-terminated driver names */
+ driverlist = (char **)xnfalloc((count + 1) * sizeof(char *));
+ count = 0;
+ cp = drivernames;
+ while (*cp) {
+ while (*cp && isspace(*cp)) cp++;
+ if (!*cp) break;
+ driverlist[count++] = cp;
+ while (*cp && !isspace(*cp)) cp++;
+ if (!*cp) break;
+ *cp++ = 0;
+ }
+ driverlist[count] = NULL;
+
+#ifdef XFree86LOADER
{
- MinimumGap = Gap;
- NearestClock = i;
+ const char *subdirs[] = {NULL, NULL};
+ static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL};
+ char **dlist, **clist, **dcp, **ccp;
+ int size;
+
+ subdirs[0] = dirname;
+
+ /* Get module list */
+ dlist = LoaderListDirs(subdirs, patlist);
+ if (!dlist) {
+ xfree(driverlist);
+ return NULL; /* No modules, no list */
+ }
+
+ clist = driverlist;
+
+ /* The resulting list cannot be longer than the module list */
+ for (dcp = dlist, count = 0; *dcp++; count++);
+ driverlist = (char **)xnfalloc((size = count + 1) * sizeof(char *));
+
+ /* First, add modules not in compiled-in list */
+ for (count = 0, dcp = dlist; *dcp; dcp++) {
+ for (ccp = clist; ; ccp++) {
+ if (!*ccp) {
+ driverlist[count++] = *dcp;
+ if (count >= size)
+ driverlist = (char**)
+ xnfrealloc(driverlist, ++size * sizeof(char*));
+ break;
+ }
+ if (!strcmp(*ccp, *dcp))
+ break;
+ }
+ }
+
+ /* Next, add compiled-in names that are also modules */
+ for (ccp = clist; *ccp; ccp++) {
+ for (dcp = dlist; *dcp; dcp++) {
+ if (!strcmp(*ccp, *dcp)) {
+ driverlist[count++] = *ccp;
+ if (count >= size)
+ driverlist = (char**)
+ xnfrealloc(driverlist, ++size * sizeof(char*));
+ break;
+ }
+ }
+ }
+
+ driverlist[count] = NULL;
+ xfree(clist);
+ xfree(dlist);
}
- }
- return NearestClock;
+#endif /* XFree86LOADER */
+
+ return driverlist;
}
-/*
- * xf86Config --
- * Fill some internal structure with userdefined setups. Many internal
- * Structs are initialized. The drivers are selected and initialized.
- * if (! vtopen), XF86Config is read, but devices are not probed.
- * if (vtopen), devices are probed (and modes resolved).
- * The vtopen argument was added so that XF86Config information could be
- * made available before the VT is opened.
- */
-CONFIG_RETURN_TYPE
-xf86Config (vtopen)
- int vtopen;
+
+char **
+xf86DriverlistFromCompile(void)
{
- int token;
- int i, j;
-#if defined(SYSV) || defined(linux)
- int xcpipe[2];
-#endif
-#ifdef XINPUT
- LocalDevicePtr local;
-#endif
-
- if (!vtopen)
- {
+ static char **driverlist = NULL;
+ static Bool generated = FALSE;
- OFLG_ZERO(&GenericXF86ConfigFlag);
- configBuf = (char*)xalloc(CONFIG_BUF_LEN);
- configRBuf = (char*)xalloc(CONFIG_BUF_LEN);
- configPath = (char*)xalloc(PATH_MAX);
-
- configBuf[0] = '\0'; /* sanity ... */
-
- /*
- * Read the XF86Config file with the real uid to avoid security problems
- *
- * For SYSV we fork, and send the data back to the parent through a pipe
- */
-#if defined(SYSV) || defined(linux)
- if (getuid() != 0) {
- if (pipe(xcpipe))
- FatalError("Pipe failed (%s)\n", strerror(errno));
- switch (fork()) {
- case -1:
- FatalError("Fork failed (%s)\n", strerror(errno));
- break;
- case 0: /* child */
- close(xcpipe[0]);
- setuid(getuid());
- HANDLE_RETURN(findConfigFile(configPath, &configFile));
- {
- unsigned char pbuf[CONFIG_BUF_LEN];
- int nbytes;
-
- /* Pass the filename back as the first line */
- strcat(configPath, "\n");
- if (write(xcpipe[1], configPath, strlen(configPath)) < 0)
- FatalError("Child error writing to pipe (%s)\n", strerror(errno));
- while ((nbytes = fread(pbuf, 1, CONFIG_BUF_LEN, configFile)) > 0)
- if (write(xcpipe[1], pbuf, nbytes) < 0)
- FatalError("Child error writing to pipe (%s)\n", strerror(errno));
- }
- close(xcpipe[1]);
- fclose(configFile);
- exit(0);
- break;
- default: /* parent */
- close(xcpipe[1]);
- configFile = (FILE *)fdopen(xcpipe[0], "r");
- if (fgets(configPath, PATH_MAX, configFile) == NULL)
- FatalError("Error reading config file\n");
- configPath[strlen(configPath) - 1] = '\0';
- }
- }
- else {
- HANDLE_RETURN(findConfigFile(configPath, &configFile));
- }
-#else /* ! (SYSV || linux) */
- {
-#ifndef __EMX__ /* in OS/2 we don't care about uids */
- int real_uid = getuid();
+ /* This string is modified in-place */
+ static char drivernames[] = DRIVERS;
- if (real_uid) {
-#ifdef MINIX
- setuid(getuid());
-#else
-#if !defined(SVR4) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
- setruid(0);
-#endif
- seteuid(real_uid);
-#endif /* MINIX */
+ if (!generated) {
+ generated = TRUE;
+ driverlist = GenerateDriverlist("drivers", drivernames);
}
-#endif /* __EMX__ */
- HANDLE_RETURN(findConfigFile(configPath, &configFile));
-#if defined(MINIX) || defined(__EMX__)
- /* no need to restore the uid to root */
-#else
- if (real_uid) {
- seteuid(0);
-#if !defined(SVR4) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
- setruid(real_uid);
-#endif
+ return driverlist;
+}
+
+
+char **
+xf86InputDriverlistFromCompile(void)
+{
+ static char **driverlist = NULL;
+ static Bool generated = FALSE;
+
+ /* This string is modified in-place */
+ static char drivernames[] = IDRIVERS;
+
+ if (!generated) {
+ generated = TRUE;
+ driverlist = GenerateDriverlist("input", drivernames);
}
-#endif /* MINIX */
- }
-#endif /* SYSV || linux */
- xf86Info.sharedMonitor = FALSE;
- xf86Info.kbdProc = NULL;
- xf86Info.notrapSignals = FALSE;
- xf86Info.caughtSignal = FALSE;
-
- /* Allocate mouse device */
-#if defined(XINPUT) && !defined(XF86SETUP)
- local = mouse_assoc.device_allocate();
- xf86Info.mouseLocal = (pointer) local;
- xf86Info.mouseDev = (MouseDevPtr) local->private;
- xf86Info.mouseDev->mseProc = NULL;
-#else
- xf86Info.mouseDev = (MouseDevPtr) Xcalloc(sizeof(MouseDevRec));
-#endif
-
- while ((token = xf86GetToken(TopLevelTab)) != EOF) {
- switch(token) {
- case SECTION:
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("section name string expected");
- if ( StrCaseCmp(val.str, "files") == 0 ) {
- HANDLE_RETURN(configFilesSection());
- } else if ( StrCaseCmp(val.str, "serverflags") == 0 ) {
- HANDLE_RETURN(configServerFlagsSection());
- } else if ( StrCaseCmp(val.str, "keyboard") == 0 ) {
- HANDLE_RETURN(configKeyboardSection());
- } else if ( StrCaseCmp(val.str, "pointer") == 0 ) {
- HANDLE_RETURN(configPointerSection(xf86Info.mouseDev, ENDSECTION, NULL));
- } else if ( StrCaseCmp(val.str, "device") == 0 ) {
- HANDLE_RETURN(configDeviceSection());
- } else if ( StrCaseCmp(val.str, "monitor") == 0 ) {
- HANDLE_RETURN(configMonitorSection());
- } else if ( StrCaseCmp(val.str, "screen") == 0 ) {
- HANDLE_RETURN(configScreenSection());
-#ifdef XINPUT
- } else if ( StrCaseCmp(val.str, "xinput") == 0 ) {
- HANDLE_RETURN(xf86ConfigExtendedInputSection(&val));
-#endif
- } else if ( StrCaseCmp(val.str, "module") == 0 ) {
- HANDLE_RETURN(configDynamicModuleSection());
- } else {
- xf86ConfigError("not a recognized section name");
- }
- break;
- }
- }
-
- fclose(configFile);
- xfree(configBuf);
- xfree(configRBuf);
- xfree(configPath);
-
- /* These aren't needed after the XF86Config file has been read */
-#ifndef XF86SETUP
- if (monitor_list)
- xfree(monitor_list);
- if (device_list)
- xfree(device_list);
-#endif
- if (modulePath)
- xfree(modulePath);
-
-#if defined(SYSV) || defined(linux)
- if (getuid() != 0) {
- /* Wait for the child */
- wait(NULL);
- }
-#endif
-
+
+ return driverlist;
+}
+
+
+/*
+ * xf86ConfigError --
+ * Print a READABLE ErrorMessage!!! All information that is
+ * available is printed.
+ */
+static void
+xf86ConfigError(char *msg, ...)
+{
+ va_list ap;
+
+ ErrorF("\nConfig Error:\n");
+ va_start(ap, msg);
+ VErrorF(msg, ap);
+ va_end(ap);
+ ErrorF("\n");
+ return;
+}
+
+static Bool
+configFiles(XF86ConfFilesPtr fileconf)
+{
+ MessageType pathFrom = X_DEFAULT;
+
+ /* FontPath */
+
/* Try XF86Config FontPath first */
- if (!xf86fpFlag)
- if (fontPath) {
- char *f = xf86ValidateFontPath(fontPath);
+ if (!xf86fpFlag) {
+ if (fileconf) {
+ if (fileconf->file_fontpath) {
+ char *f = xf86ValidateFontPath(fileconf->file_fontpath);
+ pathFrom = X_CONFIG;
if (*f)
defaultFontPath = f;
- else
- ErrorF(
- "Warning: FontPath is completely invalid. Using compiled-in default.\n"
- );
- xfree(fontPath);
- fontPath = (char *)NULL;
- }
- else
- ErrorF("Warning: No FontPath specified, using compiled-in default.\n");
- else /* Use fontpath specified with '-fp' */
- {
- OFLG_CLR (XCONFIG_FONTPATH, &GenericXF86ConfigFlag);
+ else {
+ xf86Msg(X_WARNING,
+ "FontPath is completely invalid. Using compiled-in default.\n");
+ fontPath = NULL;
+ pathFrom = X_DEFAULT;
+ }
+ }
+ } else {
+ xf86Msg(X_WARNING,
+ "No FontPath specified. Using compiled-in default.\n");
+ pathFrom = X_DEFAULT;
+ }
+ } else {
+ /* Use fontpath specified with '-fp' */
if (fontPath)
{
- xfree(fontPath);
- fontPath = (char *)NULL;
+ fontPath = NULL;
}
+ pathFrom = X_CMDLINE;
}
- if (!fontPath) {
- /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+ if (!fileconf) {
+ /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
could be static, so we make a copy. */
- char *f = (char *)xalloc(strlen(defaultFontPath) + 1);
+ char *f = xnfalloc(strlen(defaultFontPath) + 1);
f[0] = '\0';
strcpy (f, defaultFontPath);
defaultFontPath = xf86ValidateFontPath(f);
xfree(f);
+ } else {
+ if (fileconf) {
+ if (!fileconf->file_fontpath) {
+ /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+ could be static, so we make a copy. */
+ char *f = xnfalloc(strlen(defaultFontPath) + 1);
+ f[0] = '\0';
+ strcpy (f, defaultFontPath);
+ defaultFontPath = xf86ValidateFontPath(f);
+ xfree(f);
+ }
+ }
}
- else
- xfree(fontPath);
/* If defaultFontPath is still empty, exit here */
if (! *defaultFontPath)
- FatalError("No valid FontPath could be found\n");
- if (xf86Verbose)
- ErrorF("%s FontPath set to \"%s\"\n",
- OFLG_ISSET(XCONFIG_FONTPATH, &GenericXF86ConfigFlag) ? XCONFIG_GIVEN :
- XCONFIG_PROBED, defaultFontPath);
-
- if (!xf86Info.kbdProc)
- FatalError("You must specify a keyboard in XF86Config");
- if (!xf86Info.mouseDev->mseProc)
- FatalError("You must specify a mouse in XF86Config");
-
- if (!graphFound)
- {
- Bool needcomma = FALSE;
+ FatalError("No valid FontPath could be found.");
- ErrorF("\nYou must provide a \"Screen\" section in XF86Config for at\n");
- ErrorF("least one of the following graphics drivers: ");
- for (i = 0; i < xf86MaxScreens; i++)
- {
- if (xf86Screens[i])
- {
- ErrorF("%s%s", needcomma ? ", " : "",
- xf86TokenToString(DriverTab, xf86ScreenNames[i]));
- needcomma = TRUE;
- }
+ xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath);
+
+ /* RgbPath */
+
+ pathFrom = X_DEFAULT;
+
+ if (xf86coFlag)
+ pathFrom = X_CMDLINE;
+ else if (fileconf) {
+ if (fileconf->file_rgbpath) {
+ rgbPath = fileconf->file_rgbpath;
+ pathFrom = X_CONFIG;
}
- ErrorF("\n");
- FatalError("No configured graphics devices");
}
- }
-#ifndef XF86SETUP
- else /* if (vtopen) */
- {
- /*
- * Probe all configured screens for letting them resolve their modes
- */
- xf86ScreensOpen = TRUE;
- for ( i=0; i < xf86MaxScreens; i++ )
- if (xf86Screens[i] && xf86Screens[i]->configured &&
- (xf86Screens[i]->configured = (xf86Screens[i]->Probe)())){
- /* if driver doesn't report error do it here */
- if(xf86DCGetToken(xf86Screens[i]->DCConfig,NULL,DeviceTab) != EOF){
- xf86DCConfigError("Unknown device section keyword");
- FatalError("\n");
- }
- if(xf86Screens[i]->DCOptions){
- xf86DCGetOption(xf86Screens[i]->DCOptions,NULL);
- FatalError("\n");
- }
- xf86InitViewport(xf86Screens[i]);
+
+ xf86Msg(pathFrom, "RgbPath set to \"%s\"\n", rgbPath);
+
+ if (fileconf && fileconf->file_inputdevs) {
+ xf86InputDeviceList = fileconf->file_inputdevs;
+ xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n",
+ xf86InputDeviceList);
+ }
+
+
+#ifdef XFree86LOADER
+ /* ModulePath */
+
+ if (fileconf) {
+ if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
+ xf86ModulePath = fileconf->file_modulepath;
+ xf86ModPathFrom = X_CONFIG;
}
+ }
+ xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
+#endif
+
+#if 0
+ /* LogFile */
/*
- * Now sort the drivers to match the order of the ScreenNumbers
- * requested by the user. (sorry, slow bubble-sort here)
- * Note, that after this sorting the first driver that is not configured
- * can be used as last-mark for all configured ones.
+ * XXX The problem with this is that the log file is already open.
+ * One option might be to copy the exiting contents to the new location.
+ * and re-open it. The down side is that the default location would
+ * already have been overwritten. Another option would be to start with
+ * unique temporary location, then copy it once the correct name is known.
+ * A problem with this is what happens if the server exits before that
+ * happens.
*/
- for ( j = 0; j < xf86MaxScreens-1; j++)
- for ( i=0; i < xf86MaxScreens-j-1; i++ )
- if (!xf86Screens[i] || !xf86Screens[i]->configured ||
- (xf86Screens[i+1] && xf86Screens[i+1]->configured &&
- (xf86Screens[i+1]->tmpIndex < xf86Screens[i]->tmpIndex)))
- {
- ScrnInfoPtr temp = xf86Screens[i+1];
- xf86Screens[i+1] = xf86Screens[i];
- xf86Screens[i] = temp;
- }
+ if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
+ xf86LogFile = fileconf->file_logfile;
+ xf86LogFileFrom = X_CONFIG;
+ }
+#endif
+
+ return TRUE;
+}
- }
-#endif /* XF86SETUP */
+typedef enum {
+ FLAG_NOTRAPSIGNALS,
+ FLAG_DONTVTSWITCH,
+ FLAG_DONTZAP,
+ FLAG_DONTZOOM,
+ FLAG_DISABLEVIDMODE,
+ FLAG_ALLOWNONLOCAL,
+ FLAG_DISABLEMODINDEV,
+ FLAG_MODINDEVALLOWNONLOCAL,
+ FLAG_ALLOWMOUSEOPENFAIL,
+ FLAG_VTINIT,
+ FLAG_VTSYSREQ,
+ FLAG_XKBDISABLE,
+ FLAG_PCIPROBE1,
+ FLAG_PCIPROBE2,
+ FLAG_PCIFORCECONFIG1,
+ FLAG_PCIFORCECONFIG2,
+ FLAG_PCIFORCENONE,
+ FLAG_PCIOSCONFIG,
+ FLAG_SAVER_BLANKTIME,
+ FLAG_DPMS_STANDBYTIME,
+ FLAG_DPMS_SUSPENDTIME,
+ FLAG_DPMS_OFFTIME,
+ FLAG_PIXMAP,
+ FLAG_PC98,
+ FLAG_ESTIMATE_SIZES_AGGRESSIVELY,
+ FLAG_NOPM,
+ FLAG_XINERAMA,
+ FLAG_ALLOW_DEACTIVATE_GRABS,
+ FLAG_ALLOW_CLOSEDOWN_GRABS,
+ FLAG_LOG,
+ FLAG_RENDER_COLORMAP_MODE,
+ FLAG_HANDLE_SPECIAL_KEYS,
+ FLAG_RANDR
+} FlagValues;
+
+static OptionInfoRec FlagOptions[] = {
+ { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DISABLEMODINDEV, "DisableModInDev", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_MODINDEVALLOWNONLOCAL, "AllowNonLocalModInDev", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_VTINIT, "VTInit", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_XKBDISABLE, "XkbDisable", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIPROBE1, "PciProbe1" , OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIPROBE2, "PciProbe2", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCECONFIG1, "PciForceConfig1", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCECONFIG2, "PciForceConfig2", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCENONE, "PciForceNone", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIOSCONFIG, "PciOsConfig", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PC98, "PC98", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOW_DEACTIVATE_GRABS,"AllowDeactivateGrabs", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOW_CLOSEDOWN_GRABS, "AllowClosedownGrabs", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_LOG, "Log", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_HANDLE_SPECIAL_KEYS, "HandleSpecialKeys", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RANDR, "RandR", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
+#if defined(i386) || defined(__i386__)
+static Bool
+detectPC98(void)
+{
+#ifdef SUPPORT_PC98
+ unsigned char buf[2];
+
+ if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
+ return FALSE;
+ if ((buf[0] == 0x98) && (buf[1] == 0x21))
+ return TRUE;
+ else
+ return FALSE;
+#else
+ return FALSE;
#endif
}
+#endif /* __i386__ */
-static char* prependRoot(char *pathname)
+static Bool
+configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
{
-#ifndef __EMX__
- return pathname;
+ XF86OptionPtr optp, tmp;
+ int i;
+ Pix24Flags pix24 = Pix24DontCare;
+ Bool value;
+ MessageType from;
+
+ /*
+ * Merge the ServerLayout and ServerFlags options. The former have
+ * precedence over the latter.
+ */
+ optp = NULL;
+ if (flagsconf && flagsconf->flg_option_lst)
+ optp = xf86optionListDup(flagsconf->flg_option_lst);
+ if (layoutopts) {
+ tmp = xf86optionListDup(layoutopts);
+ if (optp)
+ optp = xf86optionListMerge(optp, tmp);
+ else
+ optp = tmp;
+ }
+
+ xf86ProcessOptions(-1, optp, FlagOptions);
+
+ xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
+
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_DEACTIVATE_GRABS,
+ &(xf86Info.grabInfo.allowDeactivate));
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_CLOSEDOWN_GRABS,
+ &(xf86Info.grabInfo.allowClosedown));
+
+ /*
+ * Set things up based on the config file information. Some of these
+ * settings may be overridden later when the command line options are
+ * checked.
+ */
+#ifdef XF86VIDMODE
+ if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
+ xf86Info.vidModeEnabled = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
+ xf86Info.vidModeAllowNonLocal = value;
+#endif
+
+#ifdef XF86MISC
+ if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEMODINDEV, &value))
+ xf86Info.miscModInDevEnabled = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_MODINDEVALLOWNONLOCAL, &value))
+ xf86Info.miscModInDevAllowNonLocal = value;
+#endif
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
+ xf86Info.allowMouseOpenFail = value;
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
+#ifdef USE_VT_SYSREQ
+ xf86Info.vtSysreq = value;
+ xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
#else
- /* XXXX caveat: multiple path components in line */
- return (char*)__XOS2RedirRoot(pathname);
+ if (value)
+ xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
#endif
-}
+ }
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_XKBDISABLE, &value)) {
+#ifdef XKB
+ noXkbExtension = value;
+ xf86Msg(X_CONFIG, "Xkb %s\n", value ? "disabled" : "enabled");
+#else
+ if (!value)
+ xf86Msg(X_WARNING, "Xserver doesn't support XKB\n");
+#endif
+ }
+
+ xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT);
+
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1))
+ xf86Info.pciFlags = PCIProbe1;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2))
+ xf86Info.pciFlags = PCIProbe2;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG1))
+ xf86Info.pciFlags = PCIForceConfig1;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2))
+ xf86Info.pciFlags = PCIForceConfig2;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG))
+ xf86Info.pciFlags = PCIOsConfig;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCENONE))
+ xf86Info.pciFlags = PCIForceNone;
+
+ xf86Info.pmFlag = TRUE;
+ if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
+ xf86Info.pmFlag = !value;
+ {
+ const char *s;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
+ if (!xf86NameCmp(s,"flush")) {
+ xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
+ xf86Info.log = LogFlush;
+ } else if (!xf86NameCmp(s,"sync")) {
+ xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
+ xf86Info.log = LogSync;
+ } else {
+ xf86Msg(X_WARNING,"Unknown Log option\n");
+ }
+ }
+ }
-static CONFIG_RETURN_TYPE
-configFilesSection()
-{
- int token;
- int i, j;
- int k, l;
- char *str;
-
- while ((token = xf86GetToken(FilesTab)) != ENDSECTION) {
- switch (token) {
- case FONTPATH:
- OFLG_SET(XCONFIG_FONTPATH,&GenericXF86ConfigFlag);
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("Font path component expected");
- j = FALSE;
- str = prependRoot(val.str);
- if (fontPath == NULL)
- {
- fontPath = (char *)xalloc(1);
- fontPath[0] = '\0';
- i = strlen(str) + 1;
- }
- else
- {
- i = strlen(fontPath) + strlen(str) + 1;
- if (fontPath[strlen(fontPath)-1] != ',')
+#ifdef RENDER
+ {
+ const char *s;
+
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
+ int policy = PictureParseCmapPolicy (s);
+ if (policy == PictureCmapPolicyInvalid)
+ xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
+ else
{
- i++;
- j = TRUE;
+ xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
+ PictureCmapPolicy = policy;
}
}
- fontPath = (char *)xrealloc(fontPath, i);
- if (j)
- strcat(fontPath, ",");
-
- strcat(fontPath, str);
- xfree(val.str);
- break;
-
- case RGBPATH:
- OFLG_SET(XCONFIG_RGBPATH, &GenericXF86ConfigFlag);
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("RGB path expected");
- if (!xf86coFlag)
- rgbPath = val.str;
- break;
-
- case MODULEPATH:
- OFLG_SET(XCONFIG_MODULEPATH, &GenericXF86ConfigFlag);
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("Module path expected");
- l = FALSE;
- str = prependRoot(val.str);
- if (modulePath == NULL) {
- modulePath = (char *)xalloc(1);
- modulePath[0] = '\0';
- k = strlen(str) + 1;
- }
- else
- {
- k = strlen(modulePath) + strlen(str) + 1;
- if (modulePath[strlen(modulePath)-1] != ',')
- {
- k++;
- l = TRUE;
+ }
+#endif
+ {
+ const char *s;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
+ if (!xf86NameCmp(s,"always")) {
+ xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
+ xf86Info.ddxSpecialKeys = SKAlways;
+ } else if (!xf86NameCmp(s,"whenneeded")) {
+ xf86Msg(X_CONFIG, "Special keys handled in DDX only if needed\n");
+ xf86Info.ddxSpecialKeys = SKWhenNeeded;
+ } else if (!xf86NameCmp(s,"never")) {
+ xf86Msg(X_CONFIG, "Never handling special keys in DDX\n");
+ xf86Info.ddxSpecialKeys = SKNever;
+ } else {
+ xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
}
- }
- modulePath = (char *)xrealloc(modulePath, k);
- if (l)
- strcat(modulePath, ",");
-
- strcat(modulePath, str);
- xfree(val.str);
- break;
+ }
+ }
+#ifdef RANDR
+ xf86Info.disableRandR = FALSE;
+ xf86Info.randRFrom = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
+ xf86Info.disableRandR = !value;
+ xf86Info.randRFrom = X_CONFIG;
+ }
+#endif
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i);
+ if (i >= 0)
+ xf86Info.estimateSizesAggressively = i;
+ else
+ xf86Info.estimateSizesAggressively = 0;
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
+ if (i >= 0)
+ ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
+#ifdef DPMSExtension
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
+ if (i >= 0)
+ DPMSStandbyTime = defaultDPMSStandbyTime = i * MILLI_PER_MIN;
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
+ if (i >= 0)
+ DPMSSuspendTime = defaultDPMSSuspendTime = i * MILLI_PER_MIN;
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
+ if (i >= 0)
+ DPMSOffTime = defaultDPMSOffTime = i * MILLI_PER_MIN;
+#endif
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
+ switch (i) {
+ case 24:
+ pix24 = Pix24Use24;
+ break;
+ case 32:
+ pix24 = Pix24Use32;
+ break;
+ case -1:
+ break;
default:
- xf86ConfigError("File section keyword expected");
- break;
+ xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+ return FALSE;
}
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
+ if (xf86Pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = xf86Pix24;
+ xf86Info.pix24From = X_CMDLINE;
+ } else if (pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = pix24;
+ xf86Info.pix24From = X_CONFIG;
+ } else {
+ xf86Info.pixmap24 = Pix24DontCare;
+ xf86Info.pix24From = X_DEFAULT;
+ }
+#if defined(i386) || defined(__i386__)
+ if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
+ xf86Info.pc98 = value;
+ if (value) {
+ xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
+ }
+ } else
+ if (detectPC98()) {
+ xf86Info.pc98 = TRUE;
+ xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
+ }
#endif
-}
-static CONFIG_RETURN_TYPE
-configServerFlagsSection()
-{
- int token;
-
- xf86Info.dontZap = FALSE;
- xf86Info.dontZoom = FALSE;
-
- while ((token = xf86GetToken(ServerFlagsTab)) != ENDSECTION) {
- switch (token) {
- case NOTRAPSIGNALS:
- xf86Info.notrapSignals=TRUE;
- break;
- case DONTZAP:
- xf86Info.dontZap = TRUE;
- break;
- case DONTZOOM:
- xf86Info.dontZoom = TRUE;
- break;
-#ifdef XF86VIDMODE
- case DISABLEVIDMODE:
- xf86VidModeEnabled = FALSE;
- break;
- case ALLOWNONLOCAL:
- xf86VidModeAllowNonLocal = TRUE;
- break;
-#endif
-#ifdef XF86MISC
- case DISABLEMODINDEV:
- xf86MiscModInDevEnabled = FALSE;
- break;
- case MODINDEVALLOWNONLOCAL:
- xf86MiscModInDevAllowNonLocal = TRUE;
- break;
-#endif
- case ALLOWMOUSEOPENFAIL:
- xf86AllowMouseOpenFail = TRUE;
- break;
- case PCIPROBE1:
- xf86PCIFlags = PCIProbe1;
- break;
- case PCIPROBE2:
- xf86PCIFlags = PCIProbe2;
- break;
- case PCIFORCECONFIG1:
- xf86PCIFlags = PCIForceConfig1;
- break;
- case PCIFORCECONFIG2:
- xf86PCIFlags = PCIForceConfig2;
- break;
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
- default:
- xf86ConfigError("Server flags section keyword expected");
- break;
+#ifdef PANORAMIX
+ from = X_DEFAULT;
+ if (!noPanoramiXExtension)
+ from = X_CMDLINE;
+ else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
+ noPanoramiXExtension = !value;
+ from = X_CONFIG;
}
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
+ if (!noPanoramiXExtension)
+ xf86Msg(from, "Xinerama: enabled\n");
#endif
+
+ return TRUE;
}
-static CONFIG_RETURN_TYPE
-configKeyboardSection()
+/*
+ * XXX This function is temporary, and will be removed when the keyboard
+ * driver is converted into a regular input driver.
+ */
+static Bool
+configInputKbd(IDevPtr inputp)
{
- int token, ntoken;
-
+ char *s;
+ MessageType from = X_DEFAULT;
+ Bool customKeycodesDefault = FALSE;
+ int verb = 0;
+
/* Initialize defaults */
- xf86Info.serverNumLock = FALSE;
xf86Info.xleds = 0L;
xf86Info.kbdDelay = 500;
xf86Info.kbdRate = 30;
- xf86Info.kbdProc = (DeviceProc)0;
+
+ xf86Info.kbdProc = NULL;
xf86Info.vtinit = NULL;
xf86Info.vtSysreq = VT_SYSREQ_DEFAULT;
- xf86Info.specialKeyMap = (int *)xalloc((RIGHTCTL - LEFTALT + 1) *
- sizeof(int));
- xf86Info.specialKeyMap[LEFTALT - LEFTALT] = KM_META;
- xf86Info.specialKeyMap[RIGHTALT - LEFTALT] = KM_META;
- xf86Info.specialKeyMap[SCROLLLOCK - LEFTALT] = KM_COMPOSE;
- xf86Info.specialKeyMap[RIGHTCTL - LEFTALT] = KM_CONTROL;
-#if defined(SVR4) && defined(i386) && !defined(PC98)
+#if defined(SVR4) && defined(i386)
xf86Info.panix106 = FALSE;
#endif
-#ifdef XKB
- xf86Info.xkbkeymap = NULL;
- xf86Info.xkbtypes = "default";
-#ifndef PC98
- xf86Info.xkbcompat = "default";
- xf86Info.xkbkeycodes = "xfree86";
- xf86Info.xkbsymbols = "us(pc101)";
- xf86Info.xkbgeometry = "pc";
-#else
- xf86Info.xkbcompat = "pc98";
- xf86Info.xkbkeycodes = "xfree98";
- xf86Info.xkbsymbols = "nec/jp(pc98)";
- xf86Info.xkbgeometry = "nec(pc98)";
-#endif
- xf86Info.xkbcomponents_specified = False;
- xf86Info.xkbrules = "xfree86";
- xf86Info.xkbmodel = NULL;
- xf86Info.xkblayout = NULL;
- xf86Info.xkbvariant = NULL;
- xf86Info.xkboptions = NULL;
-#endif
-
- while ((token = xf86GetToken(KeyboardTab)) != ENDSECTION) {
- switch (token) {
- case KPROTOCOL:
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("Keyboard protocol name expected");
- if ( StrCaseCmp(val.str,"standard") == 0 ) {
- xf86Info.kbdProc = xf86KbdProc;
-#ifdef AMOEBA
- xf86Info.kbdEvents = NULL;
-#else
- xf86Info.kbdEvents = xf86KbdEvents;
+ xf86Info.kbdCustomKeycodes = FALSE;
+#ifdef WSCONS_SUPPORT
+ xf86Info.kbdFd = -1;
#endif
- } else if ( StrCaseCmp(val.str,"xqueue") == 0 ) {
+#ifdef XKB
+ if (!xf86IsPc98()) {
+ xf86Info.xkbrules = "xfree86";
+ xf86Info.xkbmodel = "pc105";
+ xf86Info.xkblayout = "us";
+ xf86Info.xkbvariant = NULL;
+ xf86Info.xkboptions = NULL;
+ } else {
+ xf86Info.xkbrules = "xfree98";
+ xf86Info.xkbmodel = "pc98";
+ xf86Info.xkblayout = "nec/jp";
+ xf86Info.xkbvariant = NULL;
+ xf86Info.xkboptions = NULL;
+ }
+ xf86Info.xkbcomponents_specified = FALSE;
+ /* Should discourage the use of these. */
+ xf86Info.xkbkeymap = NULL;
+ xf86Info.xkbtypes = NULL;
+ xf86Info.xkbcompat = NULL;
+ xf86Info.xkbkeycodes = NULL;
+ xf86Info.xkbsymbols = NULL;
+ xf86Info.xkbgeometry = NULL;
+#endif
+
+ s = xf86SetStrOption(inputp->commonOptions, "Protocol", "standard");
+ if (xf86NameCmp(s, "standard") == 0) {
+ xf86Info.kbdProc = xf86KbdProc;
+ xf86Info.kbdEvents = xf86KbdEvents;
+ xfree(s);
+ } else if (xf86NameCmp(s, "xqueue") == 0) {
#ifdef XQUEUE
- xf86Info.kbdProc = xf86XqueKbdProc;
- xf86Info.kbdEvents = xf86XqueEvents;
- xf86Info.mouseDev->xqueSema = 0;
- if (xf86Verbose)
- ErrorF("%s Xqueue selected for keyboard input\n",
- XCONFIG_GIVEN);
-#endif
- } else {
- xf86ConfigError("Not a valid keyboard protocol name");
- }
- break;
- case AUTOREPEAT:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Autorepeat delay expected");
- xf86Info.kbdDelay = val.num;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Autorepeat rate expected");
- xf86Info.kbdRate = val.num;
- break;
- case SERVERNUM:
- xf86Info.serverNumLock = TRUE;
- break;
-
- case XLEDS:
- while ((token= xf86GetToken(NULL)) == NUMBER)
- xf86Info.xleds |= 1L << (val.num-1);
- pushToken = token;
- break;
- case LEFTALT:
- case RIGHTALT:
- case SCROLLLOCK:
- case RIGHTCTL:
- ntoken = xf86GetToken(KeyMapTab);
- if ((ntoken == EOF) || (ntoken == STRING) || (ntoken == NUMBER))
- xf86ConfigError("KeyMap type token expected");
- else {
- switch(ntoken) {
- case KM_META:
- case KM_COMPOSE:
- case KM_MODESHIFT:
- case KM_MODELOCK:
- case KM_SCROLLLOCK:
- case KM_CONTROL:
- xf86Info.specialKeyMap[token - LEFTALT] = ntoken;
- break;
- default:
- xf86ConfigError("Illegal KeyMap type");
- break;
- }
- }
- break;
- case VTINIT:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("VTInit string expected");
- xf86Info.vtinit = val.str;
- if (xf86Verbose)
- ErrorF("%s VTInit: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case VTSYSREQ:
-#ifdef USE_VT_SYSREQ
- xf86Info.vtSysreq = TRUE;
- if (xf86Verbose && !VT_SYSREQ_DEFAULT)
- ErrorF("%s VTSysReq enabled\n", XCONFIG_GIVEN);
-#else
- xf86ConfigError("VTSysReq not supported on this OS");
+ xf86Info.kbdProc = xf86XqueKbdProc;
+ xf86Info.kbdEvents = xf86XqueEvents;
+ xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
+#endif
+ xfree(s);
+#ifdef WSCONS_SUPPORT
+ } else if (xf86NameCmp(s, "wskbd") == 0) {
+ xf86Info.kbdProc = xf86KbdProc;
+ xf86Info.kbdEvents = xf86WSKbdEvents;
+ xfree(s);
+ s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
+ xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
+ if (s == NULL) {
+ xf86ConfigError("A \"device\" option is required with"
+ " the \"wskbd\" keyboard protocol");
+ return FALSE;
+ }
+ xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
+ if (xf86Info.kbdFd == -1) {
+ xf86ConfigError("cannot open \"%s\"", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ /* Find out keyboard type */
+ if (ioctl(xf86Info.kbdFd, WSKBDIO_GTYPE, &xf86Info.wsKbdType) == -1) {
+ xf86ConfigError("cannot get keyboard type");
+ close(xf86Info.kbdFd);
+ return FALSE;
+ }
+ switch (xf86Info.wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ xf86Msg(X_PROBED, "Keyboard type: XT\n");
+ break;
+ case WSKBD_TYPE_PC_AT:
+ xf86Msg(X_PROBED, "Keyboard type: AT\n");
+ break;
+ case WSKBD_TYPE_USB:
+ xf86Msg(X_PROBED, "Keyboard type: USB\n");
+ break;
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ xf86Msg(X_PROBED, "Keyboard type: ADB\n");
+ break;
#endif
- break;
-
-#ifdef XKB
- case XKBDISABLE:
- noXkbExtension = TRUE;
- if (xf86Verbose)
- ErrorF("%s XKB: disabled\n", XCONFIG_GIVEN);
- break;
-
- case XKBKEYMAP:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBKeymap string expected");
- xf86Info.xkbkeymap = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: keymap: \"%s\" (overrides other XKB settings)\n",
- XCONFIG_GIVEN, val.str);
- break;
-
- case XKBCOMPAT:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBCompat string expected");
- xf86Info.xkbcompat = val.str;
- xf86Info.xkbcomponents_specified = True;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: compat: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBTYPES:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBTypes string expected");
- xf86Info.xkbtypes = val.str;
- xf86Info.xkbcomponents_specified = True;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: types: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBKEYCODES:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBKeycodes string expected");
- xf86Info.xkbkeycodes = val.str;
- xf86Info.xkbcomponents_specified = True;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: keycodes: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBGEOMETRY:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBGeometry string expected");
- xf86Info.xkbgeometry = val.str;
- xf86Info.xkbcomponents_specified = True;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: geometry: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBSYMBOLS:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBSymbols string expected");
- xf86Info.xkbsymbols = val.str;
- xf86Info.xkbcomponents_specified = True;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: symbols: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBRULES:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBRules string expected");
- xf86Info.xkbrules = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: rules: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBMODEL:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBModel string expected");
- xf86Info.xkbmodel = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: model: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBLAYOUT:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBLayout string expected");
- xf86Info.xkblayout = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: layout: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBVARIANT:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBVariant string expected");
- xf86Info.xkbvariant = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: variant: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
-
- case XKBOPTIONS:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBOptions string expected");
- xf86Info.xkboptions = val.str;
- if (xf86Verbose && !XkbInitialMap)
- ErrorF("%s XKB: options: \"%s\"\n", XCONFIG_GIVEN, val.str);
- break;
+#ifdef WSKBD_TYPE_SUN
+ case WSKBD_TYPE_SUN:
+ xf86Msg(X_PROBED, "Keyboard type: Sun\n");
+ break;
#endif
-#if defined(SVR4) && defined(i386) && !defined(PC98)
- case PANIX106:
- xf86Info.panix106 = TRUE;
- if (xf86Verbose)
- ErrorF("%s PANIX106: enabled\n", XCONFIG_GIVEN);
- break;
+ default:
+ xf86ConfigError("Unsupported wskbd type \"%d\"",
+ xf86Info.wsKbdType);
+ close(xf86Info.kbdFd);
+ return FALSE;
+ }
#endif
+ } else {
+ xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
+ xfree(s);
+ return FALSE;
+ }
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
+ s = xf86SetStrOption(inputp->commonOptions, "AutoRepeat", NULL);
+ if (s) {
+ if (sscanf(s, "%d %d", &xf86Info.kbdDelay, &xf86Info.kbdRate) != 2) {
+ xf86ConfigError("\"%s\" is not a valid AutoRepeat value", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ }
- default:
- xf86ConfigError("Keyboard section keyword expected");
- break;
+ s = xf86SetStrOption(inputp->commonOptions, "XLeds", NULL);
+ if (s) {
+ char *l, *end;
+ unsigned int i;
+ l = strtok(s, " \t\n");
+ while (l) {
+ i = strtoul(l, &end, 0);
+ if (*end == '\0')
+ xf86Info.xleds |= 1L << (i - 1);
+ else {
+ xf86ConfigError("\"%s\" is not a valid XLeds value", l);
+ xfree(s);
+ return FALSE;
+ }
+ l = strtok(NULL, " \t\n");
}
+ xfree(s);
}
- if (xf86Info.kbdProc == (DeviceProc)0)
- {
- xf86ConfigError("No keyboard device given");
+
+#ifdef XKB
+ from = X_DEFAULT;
+ if (noXkbExtension)
+ from = X_CMDLINE;
+ else if (xf86FindOption(inputp->commonOptions, "XkbDisable")) {
+ xf86Msg(X_WARNING, "KEYBOARD: XKB should be disabled in the "
+ "ServerFlags section instead\n"
+ "\tof in the \"keyboard\" InputDevice section.\n");
+ noXkbExtension =
+ xf86SetBoolOption(inputp->commonOptions, "XkbDisable", FALSE);
+ from = X_CONFIG;
}
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
-}
-
-CONFIG_RETURN_TYPE
-configPointerSection(MouseDevPtr mouse_dev,
- int end_tag,
- char **devicename) /* used by extended device */
-{
- int token;
- int mtoken;
- int i;
- char *mouseType = "unknown";
-
- /* Set defaults */
- mouse_dev->baudRate = 1200;
- mouse_dev->oldBaudRate = -1;
- mouse_dev->sampleRate = 0;
- mouse_dev->resolution = 0;
- mouse_dev->buttons = MSE_DFLTBUTTONS;
- mouse_dev->emulate3Buttons = FALSE;
- mouse_dev->emulate3Timeout = 50;
- mouse_dev->chordMiddle = FALSE;
- mouse_dev->mouseFlags = 0;
- mouse_dev->mseProc = (DeviceProc)0;
- mouse_dev->mseDevice = NULL;
- mouse_dev->mseType = -1;
- mouse_dev->mseModel = 0;
- mouse_dev->negativeZ = 0;
- mouse_dev->positiveZ = 0;
-
- while ((token = xf86GetToken(PointerTab)) != end_tag) {
- switch (token) {
-
- case PROTOCOL:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mouse name expected");
-#if defined(USE_OSMOUSE) || defined(OSMOUSE_ONLY)
- if ( StrCaseCmp(val.str,"osmouse") == 0 ) {
- if (xf86Verbose)
- ErrorF("%s OsMouse selected for mouse input\n", XCONFIG_GIVEN);
- /*
- * allow an option to be passed to the OsMouse routines
- */
- if ((i = xf86GetToken(NULL)) != ERROR_TOKEN)
- xf86OsMouseOption(i, (pointer) &val);
- else
- pushToken = i;
- mouse_dev->mseProc = xf86OsMouseProc;
- mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86OsMouseEvents;
- break;
+ if (noXkbExtension)
+ xf86Msg(from, "XKB: disabled\n");
+
+#define NULL_IF_EMPTY(s) (s[0] ? s : (xfree(s), (char *)NULL))
+
+ if (!noXkbExtension && !XkbInitialMap) {
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeymap", NULL))) {
+ xf86Info.xkbkeymap = NULL_IF_EMPTY(s);
+ xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" "
+ "(overrides other XKB settings)\n", xf86Info.xkbkeymap);
+ } else {
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbCompat", NULL))) {
+ xf86Info.xkbcompat = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", s);
}
-#endif
-#ifdef XQUEUE
- if ( StrCaseCmp(val.str,"xqueue") == 0 ) {
- mouse_dev->mseProc = xf86XqueMseProc;
- mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86XqueEvents;
- mouse_dev->xqueSema = 0;
- if (xf86Verbose)
- ErrorF("%s Xqueue selected for mouse input\n",
- XCONFIG_GIVEN);
- break;
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbTypes", NULL))) {
+ xf86Info.xkbtypes = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", s);
}
-#endif
-#ifndef OSMOUSE_ONLY
-#if defined(MACH) || defined(AMOEBA)
- mouseType = (char *) xalloc (strlen (val.str) + 1);
- strcpy (mouseType, val.str);
-#else
- mouseType = (char *)strdup(val.str); /* GJA -- should we free this? */
-#endif
- mtoken = getStringToken(MouseTab); /* Which mouse? */
-#ifdef AMOEBA
- mouse_dev->mseProc = xf86MseProc;
- mouse_dev->mseEvents = NULL;
-#else
- mouse_dev->mseProc = xf86MseProc;
- mouse_dev->mseEvents = xf86MseEvents;
-#endif
- mouse_dev->mseType = mtoken - MICROSOFT;
- if (!xf86MouseSupported(mouse_dev->mseType))
- {
- xf86ConfigError("Mouse type not supported by this OS");
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeycodes", NULL))) {
+ xf86Info.xkbkeycodes = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", s);
}
-#else /* OSMOUSE_ONLY */
- xf86ConfigError("Mouse type not supported by this OS");
-#endif /* OSMOUSE_ONLY */
-#ifdef MACH386
- /* Don't need to specify the device for MACH -- should always be this */
- mouse_dev->mseDevice = "/dev/mouse";
-#endif
- break;
-#ifndef OSMOUSE_ONLY
- case PDEVICE:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mouse device expected");
- mouse_dev->mseDevice = val.str;
- break;
- case BAUDRATE:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Baudrate expected");
- if (mouse_dev->mseType + MICROSOFT == LOGIMAN)
- {
- /*
- * XXXX This should be extended to other mouse types -- most
- * support only 1200. Should also disallow baudrate for bus mice
- */
- /* Moan if illegal baud rate! [CHRIS-211092] */
- if ((val.num != 1200) && (val.num != 9600))
- xf86ConfigError("Only 1200 or 9600 Baud are supported by MouseMan");
- }
- else if (val.num%1200 != 0 || val.num < 1200 || val.num > 9600)
- xf86ConfigError("Baud rate must be one of 1200, 2400, 4800, or 9600");
- mouse_dev->baudRate = val.num;
- break;
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbGeometry", NULL))) {
+ xf86Info.xkbgeometry = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", s);
+ }
- case SAMPLERATE:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Sample rate expected");
-#if 0
- if (mouse_dev->mseType + MICROSOFT == LOGIMAN)
- {
- /* XXXX Most mice don't allow this */
- /* Moan about illegal sample rate! [CHRIS-211092] */
- xf86ConfigError("Selection of sample rate is not supported by MouseMan");
- }
-#endif
- mouse_dev->sampleRate = val.num;
- break;
-
- case PRESOLUTION:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Resolution expected");
- if (val.num <= 0)
- xf86ConfigError("Resolution must be a positive value");
- mouse_dev->resolution = val.num;
- break;
-#endif /* OSMOUSE_ONLY */
- case EMULATE3:
- if (mouse_dev->chordMiddle)
- xf86ConfigError("Can't use Emulate3Buttons with ChordMiddle");
- mouse_dev->emulate3Buttons = TRUE;
- break;
-
- case EM3TIMEOUT:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("3 button emulation timeout expected");
- mouse_dev->emulate3Timeout = val.num;
- break;
-
-#ifndef OSMOUSE_ONLY
- case CHORDMIDDLE:
- if (mouse_dev->mseType + MICROSOFT == MICROSOFT ||
- mouse_dev->mseType + MICROSOFT == LOGIMAN)
- {
- if (mouse_dev->emulate3Buttons)
- xf86ConfigError("Can't use ChordMiddle with Emulate3Buttons");
- mouse_dev->chordMiddle = TRUE;
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbSymbols", NULL))) {
+ xf86Info.xkbsymbols = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", s);
}
- else
- xf86ConfigError("ChordMiddle is only supported for Microsoft and MouseMan");
- break;
- case CLEARDTR:
-#ifdef CLEARDTR_SUPPORT
- if (mouse_dev->mseType + MICROSOFT == MOUSESYS)
- mouse_dev->mouseFlags |= MF_CLEAR_DTR;
- else
- xf86ConfigError("ClearDTR only supported for MouseSystems mouse");
-#else
- xf86ConfigError("ClearDTR not supported on this OS");
-#endif
- break;
- case CLEARRTS:
-#ifdef CLEARDTR_SUPPORT
- if (mouse_dev->mseType + MICROSOFT == MOUSESYS)
- mouse_dev->mouseFlags |= MF_CLEAR_RTS;
- else
- xf86ConfigError("ClearRTS only supported for MouseSystems mouse");
-#else
- xf86ConfigError("ClearRTS not supported on this OS");
-#endif
- break;
-#endif /* OSMOUSE_ONLY */
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbRules", NULL))) {
+ xf86Info.xkbrules = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", s);
+ }
- case DEVICE_NAME:
- if (!devicename) /* not called for an extended device */
- xf86ConfigError("Pointer section keyword expected");
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbModel", NULL))) {
+ xf86Info.xkbmodel = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", s);
+ }
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("Option string expected");
- *devicename = strdup(val.str);
- break;
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbLayout", NULL))) {
+ xf86Info.xkblayout = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", s);
+ }
-#ifndef XF86SETUP
-#ifdef XINPUT
- case ALWAYSCORE:
- xf86AlwaysCore(mouse_dev->local, TRUE);
- break;
-#endif
-#endif
-
- case ZAXISMAPPING:
- switch (xf86GetToken(ZMapTab)) {
- case NUMBER:
- if (val.num <= 0 || val.num > MSE_MAXBUTTONS)
- xf86ConfigError("Button number (1..12) expected");
- mouse_dev->negativeZ = 1 << (val.num - 1);
- if (xf86GetToken(NULL) != NUMBER ||
- val.num <= 0 || val.num > MSE_MAXBUTTONS)
- xf86ConfigError("Button number (1..12) expected");
- mouse_dev->positiveZ = 1 << (val.num - 1);
- break;
- case XAXIS:
- mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOX;
- break;
- case YAXIS:
- mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOY;
- break;
- default:
- xf86ConfigError("Button number (1..12), X or Y expected");
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbVariant", NULL))) {
+ xf86Info.xkbvariant = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", s);
}
- break;
-
- case PBUTTONS:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Number of buttons (1..12) expected");
- if (val.num <= 0 || val.num > MSE_MAXBUTTONS)
- xf86ConfigError("Number of buttons must be a positive value (1..12)");
- mouse_dev->buttons = val.num;
- break;
-
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
-
- default:
- xf86ConfigError("Pointer section keyword expected");
- break;
- }
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbOptions", NULL))) {
+ xf86Info.xkboptions = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", s);
+ }
+ }
}
- /* Print log and make sanity checks */
-
- if (mouse_dev->mseProc == (DeviceProc)0)
- {
- xf86ConfigError("No mouse protocol given");
+#undef NULL_IF_EMPTY
+#endif
+#if defined(SVR4) && defined(i386)
+ if ((xf86Info.panix106 =
+ xf86SetBoolOption(inputp->commonOptions, "Panix106", FALSE))) {
+ xf86Msg(X_CONFIG, "PANIX106: enabled\n");
}
-
+#endif
+
/*
- * if mseProc is set and mseType isn't, then using Xqueue or OSmouse.
- * Otherwise, a mouse device is required.
+ * This was once a compile time option (ASSUME_CUSTOM_KEYCODES)
+ * defaulting to 1 on Linux/PPC. It is no longer necessary, but for
+ * backwards compatibility we provide 'Option "CustomKeycodes"'
+ * and try to autoprobe on Linux/PPC.
*/
- if (mouse_dev->mseType >= 0 && !mouse_dev->mseDevice)
+ from = X_DEFAULT;
+ verb = 2;
+#if defined(__linux__) && defined(__powerpc__)
{
- xf86ConfigError("No mouse device given");
- }
-
- switch (mouse_dev->negativeZ) {
- case 0: /* none */
- case MSE_MAPTOX:
- case MSE_MAPTOY:
- break;
- default: /* buttons */
- for (i = 0; mouse_dev->negativeZ != (1 << i); ++i)
- ;
- if (i + 1 > mouse_dev->buttons)
- mouse_dev->buttons = i + 1;
- for (i = 0; mouse_dev->positiveZ != (1 << i); ++i)
- ;
- if (i + 1 > mouse_dev->buttons)
- mouse_dev->buttons = i + 1;
- break;
- }
-
- if (xf86Verbose && mouse_dev->mseType >= 0)
- {
- Bool formatFlag = FALSE;
- ErrorF("%s Mouse: type: %s, device: %s",
- XCONFIG_GIVEN, mouseType, mouse_dev->mseDevice);
- if (mouse_dev->mseType != P_BM
- && mouse_dev->mseType != P_PS2
- && mouse_dev->mseType != P_IMPS2
- && mouse_dev->mseType != P_THINKINGPS2
- && mouse_dev->mseType != P_MMANPLUSPS2
- && mouse_dev->mseType != P_GLIDEPOINTPS2
- && mouse_dev->mseType != P_NETPS2
- && mouse_dev->mseType != P_NETSCROLLPS2
- && mouse_dev->mseType != P_SYSMOUSE)
- {
- formatFlag = TRUE;
- ErrorF(", baudrate: %d", mouse_dev->baudRate);
- }
- if (mouse_dev->sampleRate)
- {
- ErrorF(formatFlag ? "\n%s Mouse: samplerate: %d" : "%ssamplerate: %d",
- formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->sampleRate);
- formatFlag = !formatFlag;
- }
- if (mouse_dev->resolution)
- {
- ErrorF(formatFlag ? "\n%s Mouse: resolution: %d" : "%sresolution: %d",
- formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->resolution);
- formatFlag = !formatFlag;
- }
- ErrorF(formatFlag ? "\n%s Mouse: buttons: %d" : "%sbuttons: %d",
- formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->buttons);
- formatFlag = !formatFlag;
- if (mouse_dev->emulate3Buttons)
- {
- ErrorF(formatFlag ? "\n%s Mouse: 3 button emulation (timeout: %dms)" :
- "%s3 button emulation (timeout: %dms)",
- formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->emulate3Timeout);
- formatFlag = !formatFlag;
- }
- if (mouse_dev->chordMiddle)
- ErrorF(formatFlag ? "\n%s Mouse: Chorded middle button" :
- "%sChorded middle button",
- formatFlag ? XCONFIG_GIVEN : ", ");
- ErrorF("\n");
-
- switch (mouse_dev->negativeZ) {
- case 0: /* none */
- break;
- case MSE_MAPTOX:
- ErrorF("%s Mouse: zaxismapping: X\n", XCONFIG_GIVEN);
- break;
- case MSE_MAPTOY:
- ErrorF("%s Mouse: zaxismapping: Y\n", XCONFIG_GIVEN);
- break;
- default: /* buttons */
- for (i = 0; mouse_dev->negativeZ != (1 << i); ++i)
- ;
- ErrorF("%s Mouse: zaxismapping: (-)%d", XCONFIG_GIVEN, i + 1);
- for (i = 0; mouse_dev->positiveZ != (1 << i); ++i)
- ;
- ErrorF(" (+)%d\n", i + 1);
- break;
+ FILE *f;
+
+ f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
+ if (f) {
+ if (fgetc(f) == '0') {
+ customKeycodesDefault = TRUE;
+ from = X_PROBED;
+ verb = 1;
+ }
+ fclose(f);
}
}
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
#endif
+ if (xf86FindOption(inputp->commonOptions, "CustomKeycodes")) {
+ from = X_CONFIG;
+ verb = 1;
+ }
+ xf86Info.kbdCustomKeycodes =
+ xf86SetBoolOption(inputp->commonOptions, "CustomKeycodes",
+ customKeycodesDefault);
+ xf86MsgVerb(from, verb, "Keyboard: CustomKeycode %s\n",
+ xf86Info.kbdCustomKeycodes ? "enabled" : "disabled");
+
+ return TRUE;
}
-
-static CONFIG_RETURN_TYPE
-configDeviceSection()
-{
- int token;
- int i;
- GDevPtr devp;
- /* Allocate one more device */
- if ( device_list == NULL ) {
- device_list = (GDevPtr) xalloc(sizeof(GDevRec));
- } else {
- device_list = (GDevPtr) xrealloc(device_list,
- (n_devices+1) * sizeof(GDevRec));
- }
- devp = &(device_list[n_devices]); /* Point to the last device */
- n_devices++;
-
- /* Pre-init the newly created device */
- devp->identifier = NULL;
- devp->board = NULL;
- devp->vendor = NULL;
- devp->chipset = NULL;
- devp->ramdac = NULL;
- for (i=0; i<MAXDACSPEEDS; i++)
- devp->dacSpeeds[i] = 0;
- OFLG_ZERO(&(devp->options));
- OFLG_ZERO(&(devp->xconfigFlag));
- devp->videoRam = 0;
- devp->speedup = SPEEDUP_DEFAULT;
- OFLG_ZERO(&(devp->clockOptions));
- devp->clocks = 0;
- devp->clockprog = NULL;
- devp->textClockValue = -1;
- /* GJA -- We initialize the following fields to known values.
- * If later on we find they contain different values,
- * they might be interesting to print.
- */
- devp->IObase = 0;
- devp->DACbase = 0;
- devp->COPbase = 0;
- devp->POSbase = 0;
- devp->instance = 0;
- devp->BIOSbase = 0;
- devp->VGAbase = 0;
- devp->MemBase = 0;
- devp->s3Madjust = 0;
- devp->s3Nadjust = 0;
- devp->s3MClk = 0;
- devp->chipID = 0;
- devp->chipRev = 0;
- devp->s3RefClk = 0;
- devp->s3BlankDelay = -1;
- devp->DCConfig = NULL;
- devp->DCOptions = NULL;
- devp->MemClk = 0;
- devp->LCDClk = 0;
-
- while ((token = xf86GetToken(DeviceTab)) != ENDSECTION) {
- devp->DCConfig = xf86DCSaveLine(devp->DCConfig, token);
- switch (token) {
-
- case IDENTIFIER:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("identifier name expected");
- devp->identifier = val.str;
- break;
-
- case VENDOR:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("vendor name expected");
- devp->vendor = val.str;
- break;
-
- case BOARD:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("board name expected");
- devp->board = val.str;
- break;
-
- case CHIPSET:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Chipset string expected");
- devp->chipset = val.str;
- OFLG_SET(XCONFIG_CHIPSET,&(devp->xconfigFlag));
- break;
-
- case RAMDAC:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("RAMDAC string expected");
- devp->ramdac = val.str;
- OFLG_SET(XCONFIG_RAMDAC,&(devp->xconfigFlag));
- break;
-
- case DACSPEED:
- for (i=0; i<MAXDACSPEEDS; i++)
- devp->dacSpeeds[i] = 0;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("DAC speed(s) expected");
- else {
- devp->dacSpeeds[0] = (int)(val.realnum * 1000.0 + 0.5);
- for(i=1; i<MAXDACSPEEDS; i++) {
- if (xf86GetToken(NULL) == NUMBER)
- devp->dacSpeeds[i] = (int)(val.realnum * 1000.0 + 0.5);
- else {
- pushToken = token;
- break;
+static Bool
+checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
+{
+ Bool havePointer = FALSE, haveKeyboard = FALSE;
+ Bool foundPointer = FALSE, foundKeyboard = FALSE;
+ IDevPtr indp;
+ IDevRec Pointer, Keyboard;
+ XF86ConfInputPtr confInput;
+ int count = 0;
+ MessageType from = X_DEFAULT;
+
+ /* Check if a core pointer or core keyboard is needed. */
+ for (indp = servlayoutp->inputs; indp->identifier; indp++) {
+ if ((indp->commonOptions &&
+ xf86FindOption(indp->commonOptions, "CorePointer")) ||
+ (indp->extraOptions &&
+ xf86FindOption(indp->extraOptions, "CorePointer"))) {
+ havePointer = TRUE;
+ }
+ if ((indp->commonOptions &&
+ xf86FindOption(indp->commonOptions, "CoreKeyboard")) ||
+ (indp->extraOptions &&
+ xf86FindOption(indp->extraOptions, "CoreKeyboard"))) {
+ haveKeyboard = TRUE;
+ }
+ count++;
+ }
+ if (!havePointer) {
+ if (xf86PointerName) {
+ confInput = xf86findInput(xf86PointerName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86PointerName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ } else {
+ from = X_DEFAULT;
+ confInput = xf86findInput(CONF_IMPLICIT_POINTER,
+ xf86configptr->conf_input_lst);
+ if (!confInput && implicitLayout) {
+ confInput = xf86findInputByDriver("mouse",
+ xf86configptr->conf_input_lst);
}
- }
- }
- OFLG_SET(XCONFIG_DACSPEED,&(devp->xconfigFlag));
- break;
-
- case CLOCKCHIP:
- /* Only allow one Clock string */
- if (OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions)))
- {
- xf86ConfigError("Only one Clock chip may be specified.");
- break;
- }
- if (devp->clocks == 0)
- {
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected");
- i = 0;
- while (xf86_ClockOptionTab[i].token != -1)
- {
- if (StrCaseCmp(val.str, xf86_ClockOptionTab[i].name) == 0)
- {
- OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions));
- OFLG_SET(xf86_ClockOptionTab[i].token,
- &(devp->clockOptions));
- break;
- }
- i++;
- }
- if (xf86_ClockOptionTab[i].token == -1) {
- xf86ConfigError("Unknown clock chip");
- break;
- }
- }
- else
- {
- xf86ConfigError("Clocks previously specified by value");
- }
- break;
-
- case CLOCKS:
- OFLG_SET(XCONFIG_CLOCKS,&(devp->xconfigFlag));
- if ((token = xf86GetToken(NULL)) == STRING)
- {
- xf86ConfigError("Use ClockChip to specify a programmable clock");
- break;
- }
- if (OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions)))
- {
- xf86ConfigError("Clock previously specified as programmable");
- break;
- }
- for (i = devp->clocks; token == NUMBER && i < MAXCLOCKS; i++) {
- devp->clock[i] = (int)(val.realnum * 1000.0 + 0.5);
- token = xf86GetToken(NULL);
- }
-
- devp->clocks = i;
- pushToken = token;
- break;
-
- case OPTION:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected");
- i = 0;
- while (xf86_OptionTab[i].token != -1)
- {
- if (StrCaseCmp(val.str, xf86_OptionTab[i].name) == 0)
- {
- OFLG_SET(xf86_OptionTab[i].token, &(devp->options));
- break;
}
- i++;
- }
- if (xf86_OptionTab[i].token == -1)
- /*xf86ConfigError("Unknown option string");*/
- devp->DCOptions = xf86DCOption(devp->DCOptions,val);
- break;
-
- case VIDEORAM:
- OFLG_SET(XCONFIG_VIDEORAM,&(devp->xconfigFlag));
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Video RAM size expected");
- devp->videoRam = val.num;
- break;
-
- case SPEEDUP:
- OFLG_SET(XCONFIG_SPEEDUP,&(devp->xconfigFlag));
- if ((token = xf86GetToken(NULL)) == STRING)
- if (!strcmp(val.str,"all"))
- devp->speedup = SPEEDUP_ALL;
+ if (confInput)
+ foundPointer = configInput(&Pointer, confInput, from);
+ }
+ if (!haveKeyboard) {
+ if (xf86KeyboardName) {
+ confInput = xf86findInput(xf86KeyboardName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86KeyboardName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ } else {
+ from = X_DEFAULT;
+ confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
+ xf86configptr->conf_input_lst);
+ if (!confInput && implicitLayout) {
+ confInput = xf86findInputByDriver("keyboard",
+ xf86configptr->conf_input_lst);
+ }
+ }
+ if (confInput)
+ foundKeyboard = configInput(&Keyboard, confInput, from);
+ }
+ if (foundPointer) {
+ count++;
+ indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec));
+ indp[count - 1] = Pointer;
+ indp[count - 1].extraOptions = xf86addNewOption(NULL, "CorePointer", NULL);
+ indp[count].identifier = NULL;
+ servlayoutp->inputs = indp;
+ } else if (!havePointer) {
+ if (implicitLayout)
+ xf86Msg(X_ERROR, "Unable to find a core pointer device\n");
else
- if (!strcmp(val.str,"best"))
- devp->speedup = SPEEDUP_BEST;
- else
- if (!strcmp(val.str,"none"))
- devp->speedup = 0;
- else
- xf86ConfigError("Unrecognised SpeedUp option");
- else
- {
- pushToken = token;
- if ((token = xf86GetToken(NULL)) == NUMBER)
- devp->speedup = val.num;
+ xf86Msg(X_ERROR, "No core pointer device specified\n");
+ return FALSE;
+ }
+ if (foundKeyboard) {
+ count++;
+ indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec));
+ indp[count - 1] = Keyboard;
+ indp[count - 1].extraOptions = xf86addNewOption(NULL, "CoreKeyboard", NULL);
+ indp[count].identifier = NULL;
+ servlayoutp->inputs = indp;
+ } else if (!haveKeyboard) {
+ if (implicitLayout)
+ xf86Msg(X_ERROR, "Unable to find a core keyboard device\n");
else
- {
- pushToken = token;
- devp->speedup = SPEEDUP_ALL;
- }
- }
- break;
-
- case NOSPEEDUP:
- OFLG_SET(XCONFIG_SPEEDUP,&(devp->xconfigFlag));
- devp->speedup = 0;
- break;
-
- case CLOCKPROG:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("ClockProg string expected");
- if (val.str[0] != '/')
- FatalError("Full pathname must be given for ClockProg \"%s\"\n",
- val.str);
- if (access(val.str, X_OK) < 0)
- {
- if (access(val.str, F_OK) < 0)
- FatalError("ClockProg \"%s\" does not exist\n", val.str);
- else
- FatalError("ClockProg \"%s\" is not executable\n", val.str);
- }
- {
- struct stat stat_buf;
- stat(val.str, &stat_buf);
- if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
- FatalError("ClockProg \"%s\" is not a regular file\n", val.str);
- }
- devp->clockprog = val.str;
- if (xf86GetToken(NULL) == NUMBER)
- {
- devp->textClockValue = (int)(val.realnum * 1000.0 + 0.5);
- }
- else
- {
- pushToken = token;
- }
- break;
-
- case BIOSBASE:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("BIOS base address expected");
- devp->BIOSbase = val.num;
- OFLG_SET(XCONFIG_BIOSBASE, &(devp->xconfigFlag));
- break;
-
- case MEMBASE:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Memory base address expected");
- devp->MemBase = val.num;
- OFLG_SET(XCONFIG_MEMBASE, &(devp->xconfigFlag));
- break;
-
- case IOBASE:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Direct access register I/O base address expected");
- devp->IObase = val.num;
- OFLG_SET(XCONFIG_IOBASE, &(devp->xconfigFlag));
- break;
-
- case DACBASE:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("DAC base I/O address expected");
- devp->DACbase = val.num;
- OFLG_SET(XCONFIG_DACBASE, &(devp->xconfigFlag));
- break;
-
- case COPBASE:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Coprocessor base memory address expected");
- devp->COPbase = val.num;
- OFLG_SET(XCONFIG_COPBASE, &(devp->xconfigFlag));
- break;
-
- case POSBASE:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("POS base address expected");
- devp->POSbase = val.num;
- OFLG_SET(XCONFIG_POSBASE, &(devp->xconfigFlag));
- break;
-
- case INSTANCE:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Video adapter instance number expected");
- devp->instance = val.num;
- OFLG_SET(XCONFIG_INSTANCE, &(devp->xconfigFlag));
- break;
-
- case S3MNADJUST:
- if ((token = xf86GetToken(NULL)) == DASH) { /* negative number */
- token = xf86GetToken(NULL);
- val.num = -val.num;
- }
- if (token != NUMBER || val.num<-31 || val.num>31)
- xf86ConfigError("M adjust (max. 31) expected");
- devp->s3Madjust = val.num;
-
- if ((token = xf86GetToken(NULL)) == DASH) { /* negative number */
- token = xf86GetToken(NULL);
- val.num = -val.num;
- }
- if (token == NUMBER) {
- if (val.num<-255 || val.num>255)
- xf86ConfigError("N adjust (max. 255) expected");
- else
- devp->s3Nadjust = val.num;
- }
- else pushToken = token;
- break;
-
- case S3MCLK:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("MCLK value in MHz expected");
- devp->s3MClk = (int)(val.realnum * 1000.0 + 0.5);
- break;
-
- case MEMCLOCK:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Memory Clock value in MHz expected");
- devp->MemClk = (int)(val.realnum * 1000.0 + 0.5);
- OFLG_SET(XCONFIG_MEMCLOCK,&(devp->xconfigFlag));
- break;
-
- case LCDCLOCK:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("LCD Clock value in MHz expected");
- devp->LCDClk = (int)(val.realnum * 1000.0 + 0.5);
- OFLG_SET(XCONFIG_LCDCLOCK,&(devp->xconfigFlag));
- break;
-
- case CHIPID:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("ChipID expected");
- devp->chipID = val.num;
- break;
-
- case CHIPREV:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("ChipRev expected");
- devp->chipRev = val.num;
- break;
-
- case VGABASEADDR:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("VGA aperature base address expected");
- devp->VGAbase = val.num;
- OFLG_SET(XCONFIG_VGABASE, &(devp->xconfigFlag));
- break;
-
- case S3REFCLK:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("RefCLK value in MHz expected");
- devp->s3RefClk = (int)(val.realnum * 1000.0 + 0.5);
- break;
-
- case S3BLANKDELAY:
- if (xf86GetToken(NULL) != NUMBER || val.num>7)
- xf86ConfigError("number(s) 0..7 expected");
- devp->s3BlankDelay = val.num;
- if ((token=xf86GetToken(NULL)) == NUMBER) {
- if (val.num>7) xf86ConfigError("number2 0..7 expected");
- devp->s3BlankDelay |= val.num<<4;
- }
- else pushToken = token;
- break;
-
- case TEXTCLOCKFRQ:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Text clock expected");
- devp->textClockValue = (int)(val.realnum * 1000.0 + 0.5);
- break;
-
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
- default:
- if(DCerr)
- xf86ConfigError("Device section keyword expected");
- break;
+ xf86Msg(X_ERROR, "No core keyboard device specified\n");
+ return FALSE;
}
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
+ return TRUE;
}
-static CONFIG_RETURN_TYPE
-configMonitorSection()
+/*
+ * figure out which layout is active, which screens are used in that layout,
+ * which drivers and monitors are used in these screens
+ */
+static Bool
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
{
- int token;
- int i;
- MonPtr monp;
- float multiplier;
-
- /* Allocate one more monitor */
- if ( monitor_list == NULL ) {
- monitor_list = (MonPtr) xalloc(sizeof(MonRec));
- } else {
- monitor_list = (MonPtr) xrealloc(monitor_list,
- (n_monitors+1) * sizeof(MonRec));
- }
- monp = &(monitor_list[n_monitors]); /* Point to the new monitor */
- monp->Modes = 0;
- monp->Last = 0;
- monp->n_hsync = 0;
- monp->n_vrefresh = 0;
- n_monitors++;
-
- while ((token = xf86GetToken(MonitorTab)) != ENDSECTION) {
- switch (token) {
- case IDENTIFIER:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("identifier name expected");
- monp->id = val.str;
- break;
- case VENDOR:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("vendor name expected");
- monp->vendor = val.str;
- break;
- case MODEL:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("model name expected");
- monp->model = val.str;
- break;
- case MODE:
- readVerboseMode(monp);
- break;
- case MODELINE:
- token = xf86GetToken(NULL);
- pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec));
-
- if (monp->Last)
- monp->Last->next = pNew;
- else
- monp->Modes = pNew;
-
- if (token == STRING)
- {
- pNew->name = val.str;
- if ((token = xf86GetToken(NULL)) != NUMBER)
- FatalError("Dotclock expected");
- }
- else if (monp->Last)
- {
-#if defined(MACH) || defined(AMOEBA)
- pNew->name = (char *) xalloc (strlen (monp->Last->name) + 1);
- strcpy (pNew->name, monp->Last->name);
-#else
- pNew->name = (char *)strdup(monp->Last->name);
-#endif
- }
- else
- xf86ConfigError("Mode name expected");
-
- pNew->next = NULL;
- pNew->prev = NULL;
- pNew->Flags = 0;
- pNew->Clock = (int)(val.realnum * 1000.0 + 0.5);
- pNew->CrtcHAdjusted = FALSE;
- pNew->CrtcVAdjusted = FALSE;
- pNew->CrtcHSkew = pNew->HSkew = 0;
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHDisplay = pNew->HDisplay = val.num;
- else xf86ConfigError("Horizontal display expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHSyncStart = pNew->HSyncStart = val.num;
- else xf86ConfigError("Horizontal sync start expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHSyncEnd = pNew->HSyncEnd = val.num;
- else xf86ConfigError("Horizontal sync end expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHTotal = pNew->HTotal = val.num;
- else xf86ConfigError("Horizontal total expected");
-
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVDisplay = pNew->VDisplay = val.num;
- else xf86ConfigError("Vertical display expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVSyncStart = pNew->VSyncStart = val.num;
- else xf86ConfigError("Vertical sync start expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVSyncEnd = pNew->VSyncEnd = val.num;
- else xf86ConfigError("Vertical sync end expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVTotal = pNew->VTotal = val.num;
- else xf86ConfigError("Vertical total expected");
-
- token = xf86GetToken(TimingTab);
- while ( (token == TT_INTERLACE) || (token == TT_PHSYNC) ||
- (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
- (token == TT_NVSYNC) || (token == TT_CSYNC) ||
- (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
- (token == TT_DBLSCAN) || (token == TT_HSKEW) )
- {
- switch(token) {
-
- case TT_INTERLACE: pNew->Flags |= V_INTERLACE; break;
- case TT_PHSYNC: pNew->Flags |= V_PHSYNC; break;
- case TT_NHSYNC: pNew->Flags |= V_NHSYNC; break;
- case TT_PVSYNC: pNew->Flags |= V_PVSYNC; break;
- case TT_NVSYNC: pNew->Flags |= V_NVSYNC; break;
- case TT_CSYNC: pNew->Flags |= V_CSYNC; break;
- case TT_PCSYNC: pNew->Flags |= V_PCSYNC; break;
- case TT_NCSYNC: pNew->Flags |= V_NCSYNC; break;
- case TT_DBLSCAN: pNew->Flags |= V_DBLSCAN; break;
- case TT_HSKEW:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Horizontal skew expected");
- pNew->CrtcHSkew = pNew->HSkew = val.num;
- pNew->Flags |= V_HSKEW;
- break;
- default:
- xf86ConfigError("bug found in config reader"); break;
- }
- token = xf86GetToken(TimingTab);
- }
- pushToken = token;
- monp->Last = pNew; /* GJA */
- break;
- case BANDWIDTH:
- /* This should be completely removed at some point */
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Bandwidth number expected");
-#if 0
- monp->bandwidth = val.realnum;
- /* Handle optional scaler */
- token = xf86GetToken(UnitTab);
- switch ( token ) {
- case HRZ: multiplier = 1.0e-6; break;
- case KHZ: multiplier = 1.0e-3; break;
- case MHZ: multiplier = 1.0; break;
- default: multiplier = 1.0; pushToken = token;
- }
- monp->bandwidth *= multiplier;
-#endif
- break;
- case HORIZSYNC:
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Horizontal sync value expected");
- monp->hsync[monp->n_hsync].lo = val.realnum;
- if ((token = xf86GetToken(NULL)) == DASH) {
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Upperbound for horizontal sync value expected");
- monp->hsync[monp->n_hsync].hi = val.realnum;
- } else {
- pushToken = token;
- monp->hsync[monp->n_hsync].hi = monp->hsync[monp->n_hsync].lo;
- }
- monp->n_hsync++;
- while ( (token = xf86GetToken(NULL)) == COMMA ) {
- if ( monp->n_hsync == MAX_HSYNC )
- xf86ConfigError("Sorry. Too many horizontal sync intervals.");
-
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Horizontal sync value expected");
- monp->hsync[monp->n_hsync].lo = val.realnum;
- if ((token = xf86GetToken(NULL)) == DASH) {
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Upperbound for horizontal sync value expected");
- monp->hsync[monp->n_hsync].hi = val.realnum;
- } else {
- pushToken = token;
- monp->hsync[monp->n_hsync].hi = monp->hsync[monp->n_hsync].lo;
- }
- monp->n_hsync++;
- }
- pushToken = token;
- /* Handle optional scaler */
- token = xf86GetToken(UnitTab);
- switch ( token ) {
- case HRZ: multiplier = 1.0e-3; break;
- case KHZ: multiplier = 1.0; break;
- case MHZ: multiplier = 1.0e3; break;
- default: multiplier = 1.0; pushToken = token;
- }
- for ( i = 0 ; i < monp->n_hsync ; i++ ) {
- monp->hsync[i].hi *= multiplier;
- monp->hsync[i].lo *= multiplier;
- }
- break;
- case VERTREFRESH:
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Vertical refresh value expected");
- monp->vrefresh[monp->n_vrefresh].lo = val.realnum;
- if ((token = xf86GetToken(NULL)) == DASH) {
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Upperbound for vertical refresh value expected");
- monp->vrefresh[monp->n_vrefresh].hi = val.realnum;
- } else {
- monp->vrefresh[monp->n_vrefresh].hi =
- monp->vrefresh[monp->n_vrefresh].lo;
- pushToken = token;
- }
- monp->n_vrefresh++;
- while ( (token = xf86GetToken(NULL)) == COMMA ) {
- if ( monp->n_vrefresh == MAX_HSYNC )
- xf86ConfigError("Sorry. Too many vertical refresh intervals.");
-
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Vertical refresh value expected");
- monp->vrefresh[monp->n_vrefresh].lo = val.realnum;
- if ((token = xf86GetToken(NULL)) == DASH) {
- if ((token = xf86GetToken(NULL)) != NUMBER)
- xf86ConfigError("Upperbound for vertical refresh value expected");
- monp->vrefresh[monp->n_vrefresh].hi = val.realnum;
- } else {
- monp->vrefresh[monp->n_vrefresh].hi =
- monp->vrefresh[monp->n_vrefresh].lo;
- pushToken = token;
- }
- monp->n_vrefresh++;
- }
- pushToken = token;
- /* Handle optional scaler */
- token = xf86GetToken(UnitTab);
- switch ( token ) {
- case HRZ: multiplier = 1.0; break;
- case KHZ: multiplier = 1.0e3; break;
- case MHZ: multiplier = 1.0e6; break;
- default: multiplier = 1.0; pushToken = token;
- }
- for ( i = 0 ; i < monp->n_vrefresh ; i++ ) {
- monp->vrefresh[i].hi *= multiplier;
- monp->vrefresh[i].lo *= multiplier;
- }
- break;
- case GAMMA: {
- char *msg = "gamma correction value(s) expected\n either one value or three r/g/b values with 0.1 <= gamma <= 10";
- if ((token = xf86GetToken(NULL)) != NUMBER || val.realnum<0.1 || val.realnum>10)
- xf86ConfigError(msg);
- else {
- xf86rGamma = xf86gGamma = xf86bGamma = 1.0 / val.realnum;
- if ((token = xf86GetToken(NULL)) == NUMBER) {
- if (val.realnum<0.1 || val.realnum>10) xf86ConfigError(msg);
- else {
- xf86gGamma = 1.0 / val.realnum;
- if ((token = xf86GetToken(NULL)) != NUMBER || val.realnum<0.1 || val.realnum>10)
- xf86ConfigError(msg);
- else {
- xf86bGamma = 1.0 / val.realnum;
- }
- }
- }
- else pushToken = token;
- }
- break;
+ XF86ConfAdjacencyPtr adjp;
+ XF86ConfInactivePtr idp;
+ XF86ConfInputrefPtr irp;
+ int count = 0;
+ int scrnum;
+ XF86ConfLayoutPtr l;
+ MessageType from;
+ screenLayoutPtr slp;
+ GDevPtr gdp;
+ IDevPtr indp;
+ int i = 0, j;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ /*
+ * which layout section is the active one?
+ *
+ * If there is a -layout command line option, use that one, otherwise
+ * pick the first one.
+ */
+ from = X_DEFAULT;
+ if (xf86LayoutName != NULL)
+ from = X_CMDLINE;
+ else if (default_layout) {
+ xf86LayoutName = default_layout;
+ from = X_CONFIG;
+ }
+ if (xf86LayoutName != NULL) {
+ if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
+ xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
+ xf86LayoutName);
+ return FALSE;
+ }
+ conf_layout = l;
}
- case EOF:
- FatalError("Unexpected EOF. Missing EndSection?");
- break; /* :-) */
+ xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
+ adjp = conf_layout->lay_adjacency_lst;
- default:
- xf86ConfigError("Monitor section keyword expected");
- break;
+ /*
+ * we know that each screen is referenced exactly once on the left side
+ * of a layout statement in the Layout section. So to allocate the right
+ * size for the array we do a quick walk of the list to figure out how
+ * many sections we have
+ */
+ while (adjp) {
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
}
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
+#ifdef DEBUG
+ ErrorF("Found %d screens in the layout section %s",
+ count, conf_layout->lay_identifier);
#endif
-}
+ slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+ slp[count].screen = NULL;
+ /*
+ * now that we have storage, loop over the list again and fill in our
+ * data structure; at this point we do not fill in the adjacency
+ * information as it is not clear if we need it at all
+ */
+ adjp = conf_layout->lay_adjacency_lst;
+ count = 0;
+ while (adjp) {
+ slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
+ if (adjp->adj_scrnum < 0)
+ scrnum = count;
+ else
+ scrnum = adjp->adj_scrnum;
+ if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
+ X_CONFIG))
+ return FALSE;
+ slp[count].x = adjp->adj_x;
+ slp[count].y = adjp->adj_y;
+ slp[count].refname = adjp->adj_refscreen;
+ switch (adjp->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ slp[count].where = PosObsolete;
+ slp[count].topname = adjp->adj_top_str;
+ slp[count].bottomname = adjp->adj_bottom_str;
+ slp[count].leftname = adjp->adj_left_str;
+ slp[count].rightname = adjp->adj_right_str;
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ slp[count].where = PosAbsolute;
+ break;
+ case CONF_ADJ_RIGHTOF:
+ slp[count].where = PosRightOf;
+ break;
+ case CONF_ADJ_LEFTOF:
+ slp[count].where = PosLeftOf;
+ break;
+ case CONF_ADJ_ABOVE:
+ slp[count].where = PosAbove;
+ break;
+ case CONF_ADJ_BELOW:
+ slp[count].where = PosBelow;
+ break;
+ case CONF_ADJ_RELATIVE:
+ slp[count].where = PosRelative;
+ break;
+ }
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ }
-static CONFIG_RETURN_TYPE
-configDynamicModuleSection()
-{
- int token;
-
- while ((token = xf86GetToken(ModuleTab)) != ENDSECTION) {
- switch (token) {
- case LOAD:
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("Dynamic module expected");
- else {
-#ifdef DYNAMIC_MODULE
- if (!modulePath) {
- static Bool firstTime = TRUE;
-
- modulePath = (char*)Xcalloc(strlen(DEFAULT_MODULE_PATH)+1);
- strcpy(modulePath, DEFAULT_MODULE_PATH);
-
- if (xf86Verbose && firstTime) {
- ErrorF("%s no ModulePath specified using default: %s\n",
- XCONFIG_PROBED, DEFAULT_MODULE_PATH);
- firstTime = FALSE;
- }
- }
- xf86LoadModule(val.str, modulePath);
-#else
- ErrorF("Dynamic modules not supported. \"%s\" not loaded\n",
- val.str);
-#endif
+ /* XXX Need to tie down the upper left screen. */
+
+ /* Fill in the refscreen and top/bottom/left/right values */
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < count; j++) {
+ if (slp[i].refname &&
+ strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+ slp[i].refscreen = slp[j].screen;
}
- break;
+ if (slp[i].topname &&
+ strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+ slp[i].top = slp[j].screen;
+ }
+ if (slp[i].bottomname &&
+ strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+ slp[i].bottom = slp[j].screen;
+ }
+ if (slp[i].leftname &&
+ strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+ slp[i].left = slp[j].screen;
+ }
+ if (slp[i].rightname &&
+ strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+ slp[i].right = slp[j].screen;
+ }
+ }
+ if (slp[i].where != PosObsolete
+ && slp[i].where != PosAbsolute
+ && !slp[i].refscreen) {
+ xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
+ slp[i].refname);
+ slp[i].where = PosAbsolute;
+ slp[i].x = 0;
+ slp[i].y = 0;
+ }
+ }
- case EOF:
- FatalError("Unexpected EOF. Missing EndSection?");
- break; /* :-) */
-
- default:
- xf86ConfigError("Module section keyword expected");
+#ifdef LAYOUT_DEBUG
+ ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier);
+ for (i = 0; i < count; i++) {
+ ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id,
+ slp[i].screen->screennum);
+ switch (slp[i].where) {
+ case PosObsolete:
+ ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n",
+ slp[i].top, slp[i].bottom, slp[i].left, slp[i].right);
+ break;
+ case PosAbsolute:
+ if (slp[i].x == -1)
+ if (slp[i].screen->screennum == 0)
+ ErrorF("\tImplicitly left-most\n");
+ else
+ ErrorF("\tImplicitly right of screen %d\n",
+ slp[i].screen->screennum - 1);
+ else
+ ErrorF("\t%d %d\n", slp[i].x, slp[i].y);
+ break;
+ case PosRightOf:
+ ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosLeftOf:
+ ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id);
break;
- }
+ case PosAbove:
+ ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosBelow:
+ ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosRelative:
+ ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y,
+ slp[i].refscreen->id);
+ break;
+ }
}
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
#endif
+ /*
+ * Count the number of inactive devices.
+ */
+ count = 0;
+ idp = conf_layout->lay_inactive_lst;
+ while (idp) {
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+#ifdef DEBUG
+ ErrorF("Found %d inactive devices in the layout section %s",
+ count, conf_layout->lay_identifier);
+#endif
+ gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+ gdp[count].identifier = NULL;
+ idp = conf_layout->lay_inactive_lst;
+ count = 0;
+ while (idp) {
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ return FALSE;
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+ /*
+ * Count the number of input devices.
+ */
+ count = 0;
+ irp = conf_layout->lay_input_lst;
+ while (irp) {
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+#ifdef DEBUG
+ ErrorF("Found %d input devices in the layout section %s",
+ count, conf_layout->lay_identifier);
+#endif
+ indp = xnfalloc((count + 1) * sizeof(IDevRec));
+ indp[count].identifier = NULL;
+ irp = conf_layout->lay_input_lst;
+ count = 0;
+ while (irp) {
+ if (!configInput(&indp[count], irp->iref_inputdev, X_CONFIG))
+ return FALSE;
+ indp[count].extraOptions = irp->iref_option_lst;
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ servlayoutp->id = conf_layout->lay_identifier;
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = gdp;
+ servlayoutp->inputs = indp;
+ servlayoutp->options = conf_layout->lay_option_lst;
+ from = X_DEFAULT;
+
+ if (!checkCoreInputDevices(servlayoutp, FALSE))
+ return FALSE;
+ return TRUE;
}
-static CONFIG_RETURN_TYPE
-readVerboseMode(monp)
-MonPtr monp;
+/*
+ * No layout section, so find the first Screen section and set that up as
+ * the only active screen.
+ */
+static Bool
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
{
- int token, token2;
- int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
-
- pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec));
- pNew->next = NULL;
- pNew->prev = NULL;
- pNew->Flags = 0;
- pNew->HDisplay = pNew->VDisplay = 0; /* Uninitialized */
- pNew->CrtcHAdjusted = pNew->CrtcVAdjusted = FALSE;
- pNew->CrtcHSkew = pNew->HSkew = 0;
-
- if (monp->Last)
- monp->Last->next = pNew;
- else
- monp->Modes = pNew;
- monp->Last = pNew;
-
- if ( xf86GetToken(NULL) != STRING ) {
- FatalError("Mode name expected");
- }
- pNew->name = val.str;
- while ((token = xf86GetToken(ModeTab)) != ENDMODE) {
- switch (token) {
- case DOTCLOCK:
- if ((token = xf86GetToken(NULL)) != NUMBER) {
- FatalError("Dotclock expected");
- }
- pNew->Clock = (int)(val.realnum * 1000.0 + 0.5);
- had_dotclock = 1;
- break;
- case HTIMINGS:
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHDisplay = pNew->HDisplay = val.num;
- else xf86ConfigError("Horizontal display expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHSyncStart = pNew->HSyncStart = val.num;
- else xf86ConfigError("Horizontal sync start expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHSyncEnd = pNew->HSyncEnd = val.num;
- else xf86ConfigError("Horizontal sync end expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcHTotal = pNew->HTotal = val.num;
- else xf86ConfigError("Horizontal total expected");
- had_htimings = 1;
- break;
- case VTIMINGS:
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVDisplay = pNew->VDisplay = val.num;
- else xf86ConfigError("Vertical display expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVSyncStart = pNew->VSyncStart = val.num;
- else xf86ConfigError("Vertical sync start expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVSyncEnd = pNew->VSyncEnd = val.num;
- else xf86ConfigError("Vertical sync end expected");
-
- if (xf86GetToken(NULL) == NUMBER)
- pNew->CrtcVTotal = pNew->VTotal = val.num;
- else xf86ConfigError("Vertical total expected");
- had_vtimings = 1;
- break;
- case FLAGS:
- token = xf86GetToken(NULL);
- if (token != STRING)
- xf86ConfigError("Flag string expected. Note: flags must be in \"\"");
- while ( token == STRING ) {
- token2 = getStringToken(TimingTab);
- switch(token2) {
- case TT_INTERLACE: pNew->Flags |= V_INTERLACE; break;
- case TT_PHSYNC: pNew->Flags |= V_PHSYNC; break;
- case TT_NHSYNC: pNew->Flags |= V_NHSYNC; break;
- case TT_PVSYNC: pNew->Flags |= V_PVSYNC; break;
- case TT_NVSYNC: pNew->Flags |= V_NVSYNC; break;
- case TT_CSYNC: pNew->Flags |= V_CSYNC; break;
- case TT_PCSYNC: pNew->Flags |= V_PCSYNC; break;
- case TT_NCSYNC: pNew->Flags |= V_NCSYNC; break;
- case TT_DBLSCAN: pNew->Flags |= V_DBLSCAN; break;
- default:
- xf86ConfigError("Unknown flag string"); break;
- }
- token = xf86GetToken(NULL);
- }
- pushToken = token;
- break;
- case HSKEW:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Horizontal skew expected");
- pNew->Flags |= V_HSKEW;
- pNew->CrtcHSkew = pNew->HSkew = val.num;
- break;
+ MessageType from;
+ XF86ConfScreenPtr s;
+ screenLayoutPtr slp;
+ IDevPtr indp;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ if (conf_screen == NULL) {
+ xf86ConfigError("No Screen sections present\n");
+ return FALSE;
}
- }
- if ( !had_dotclock ) xf86ConfigError("the dotclock is missing");
- if ( !had_htimings ) xf86ConfigError("the horizontal timings are missing");
- if ( !had_vtimings ) xf86ConfigError("the vertical timings are missing");
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
-}
-static Bool dummy;
+ /*
+ * which screen section is the active one?
+ *
+ * If there is a -screen option, use that one, otherwise use the first
+ * one.
+ */
-#ifdef XF86SETUP
-int xf86setup_scrn_ndisps[8];
-DispPtr xf86setup_scrn_displays[8];
-#endif
+ from = X_CONFIG;
+ if (xf86ScreenName != NULL) {
+ if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
+ xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
+ xf86ScreenName);
+ return FALSE;
+ }
+ conf_screen = s;
+ from = X_CMDLINE;
+ }
+
+ /* We have exactly one screen */
+
+ slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
+ slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
+ slp[1].screen = NULL;
+ if (!configScreen(slp[0].screen, conf_screen, 0, from))
+ return FALSE;
+ servlayoutp->id = "(implicit)";
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
+ servlayoutp->options = NULL;
+ /* Set up an empty input device list, then look for some core devices. */
+ indp = xnfalloc(sizeof(IDevRec));
+ indp->identifier = NULL;
+ servlayoutp->inputs = indp;
+ if (!checkCoreInputDevices(servlayoutp, TRUE))
+ return FALSE;
+
+ return TRUE;
+}
-static CONFIG_RETURN_TYPE
-configScreenSection()
+static Bool
+configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
{
- int i, j;
- int driverno;
- int had_monitor = 0, had_device = 0;
- int dispIndex = 0;
- int numDisps = 0;
- DispPtr dispList = NULL;
- DispPtr dispp;
-
- int token;
- ScrnInfoPtr screen = NULL;
- int textClockValue = -1;
-
- token = xf86GetToken(ScreenTab);
- if ( token != DRIVER )
- xf86ConfigError("The screen section must begin with the 'driver' line");
-
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Driver name expected");
- driverno = getStringToken(DriverTab);
- switch ( driverno ) {
- case SVGA:
- case VGA2:
- case MONO:
- case VGA16:
- case ACCEL:
- case FBDEV:
- break;
- default:
- xf86ConfigError("Not a recognized driver name");
- }
- scr_index = getScreenIndex(driverno);
+ int count = 0;
+ XF86ConfVideoPortPtr conf_port;
+
+ xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
+ conf_adaptor->va_identifier);
+ adaptor->identifier = conf_adaptor->va_identifier;
+ adaptor->options = conf_adaptor->va_option_lst;
+ if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
+ xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
+ return FALSE;
+ }
- dummy = scr_index < 0 || !xf86Screens[scr_index];
- if (dummy)
- screen = (ScrnInfoPtr)xalloc(sizeof(ScrnInfoRec));
- else
- {
- screen = xf86Screens[scr_index];
- screen->configured = TRUE;
- screen->tmpIndex = screenno++;
- screen->scrnIndex = scr_index; /* scrnIndex must not be changed */
- screen->frameX0 = -1;
- screen->frameY0 = -1;
- screen->virtualX = -1;
- screen->virtualY = -1;
- screen->defaultVisual = -1;
- screen->modes = NULL;
- screen->width = 240;
- screen->height = 180;
- screen->bankedMono = FALSE;
- screen->textclock = -1;
- screen->blackColour.red = 0;
- screen->blackColour.green = 0;
- screen->blackColour.blue = 0;
- screen->whiteColour.red = 0x3F;
- screen->whiteColour.green = 0x3F;
- screen->whiteColour.blue = 0x3F;
- }
- screen->clocks = 0;
+ /*
+ * figure out how many videoport subsections there are and fill them in
+ */
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
+ adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+ adaptor->numports = count;
+ count = 0;
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ adaptor->ports[count].identifier = conf_port->vp_identifier;
+ adaptor->ports[count].options = conf_port->vp_option_lst;
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
- while ((token = xf86GetToken(ScreenTab)) != ENDSECTION) {
- switch (token) {
+ return TRUE;
+}
+
+static Bool
+configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
+ MessageType from)
+{
+ int count = 0;
+ XF86ConfDisplayPtr dispptr;
+ XF86ConfAdaptorLinkPtr conf_adaptor;
- case DEFBPP:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Default color depth expected");
- screen->depth = val.num;
- break;
+ xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
+ scrnum);
+ /*
+ * now we fill in the elements of the screen
+ */
+ screenp->id = conf_screen->scrn_identifier;
+ screenp->screennum = scrnum;
+ screenp->defaultdepth = conf_screen->scrn_defaultdepth;
+ screenp->defaultbpp = conf_screen->scrn_defaultbpp;
+ screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
+ screenp->monitor = xnfcalloc(1, sizeof(MonRec));
+ if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
+ return FALSE;
+ screenp->device = xnfcalloc(1, sizeof(GDevRec));
+ configDevice(screenp->device,conf_screen->scrn_device, TRUE);
+ screenp->device->myScreenSection = screenp;
+ screenp->options = conf_screen->scrn_option_lst;
+
+ /*
+ * figure out how many display subsections there are and fill them in
+ */
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
+ screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->numdisplays = count;
+ count = 0;
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ configDisplay(&(screenp->displays[count]),dispptr);
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
- case SCREENNO:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Screen number expected");
- screen->tmpIndex = val.num;
- break;
+ /*
+ * figure out how many videoadaptor references there are and fill them in
+ */
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ count++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
+ screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+ screenp->numxvadaptors = 0;
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
+ conf_adaptor->al_adaptor))
+ screenp->numxvadaptors++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
- case SUBSECTION:
- if ((xf86GetToken(NULL) != STRING) || (StrCaseCmp(val.str, "display") != 0)) {
- xf86ConfigError("You must say \"Display\" here");
- }
- if (dispList == NULL) {
- dispList = (DispPtr)xalloc(sizeof(DispRec));
- } else {
- dispList = (DispPtr)xrealloc(dispList,
- (numDisps + 1) * sizeof(DispRec));
- }
- dispp = dispList + numDisps;
- numDisps++;
- dispp->depth = -1;
- dispp->weight.red = dispp->weight.green = dispp->weight.blue = 0;
- dispp->frameX0 = -1;
- dispp->frameY0 = -1;
- dispp->virtualX = -1;
- dispp->virtualY = -1;
- dispp->modes = NULL;
- dispp->whiteColour.red = dispp->whiteColour.green =
- dispp->whiteColour.blue = 0x3F;
- dispp->blackColour.red = dispp->blackColour.green =
- dispp->blackColour.blue = 0;
- dispp->defaultVisual = -1;
- OFLG_ZERO(&(dispp->options));
- OFLG_ZERO(&(dispp->xconfigFlag));
- dispp->DCOptions = NULL;
-
- configDisplaySubsection(dispp);
- break;
-
- case EOF:
- FatalError("Unexpected EOF (missing EndSection?)");
- break; /* :-) */
-
- case MDEVICE:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Device name expected");
- for ( i = 0 ; i < n_devices ; i++ ) {
- if ( strcmp(device_list[i].identifier,val.str) == 0 ) {
- /* Copy back */
- if (!dummy && xf86Verbose) {
- ErrorF("%s %s: Graphics device ID: \"%s\"\n",
- XCONFIG_GIVEN, screen->name, device_list[i].identifier);
- }
- screen->clocks = device_list[i].clocks;
- for ( j = 0 ; j < MAXCLOCKS ; j++ ) {
- screen->clock[j] = device_list[i].clock[j];
- }
- screen->chipset = device_list[i].chipset;
- screen->ramdac = device_list[i].ramdac;
- for (j=0; j<MAXDACSPEEDS; j++)
- screen->dacSpeeds[j] = device_list[i].dacSpeeds[j];
- screen->dacSpeedBpp = 0;
- screen->options = device_list[i].options;
- screen->clockOptions = device_list[i].clockOptions;
- screen->xconfigFlag = device_list[i].xconfigFlag;
- screen->videoRam = device_list[i].videoRam;
- screen->speedup = device_list[i].speedup;
- screen->clockprog = device_list[i].clockprog;
- textClockValue = device_list[i].textClockValue;
- if (OFLG_ISSET(XCONFIG_BIOSBASE, &screen->xconfigFlag))
- screen->BIOSbase = device_list[i].BIOSbase;
- if (OFLG_ISSET(XCONFIG_MEMBASE, &screen->xconfigFlag))
- screen->MemBase = device_list[i].MemBase;
- if (OFLG_ISSET(XCONFIG_IOBASE, &screen->xconfigFlag))
- screen->IObase = device_list[i].IObase;
- if (OFLG_ISSET(XCONFIG_DACBASE, &screen->xconfigFlag))
- screen->DACbase = device_list[i].DACbase;
- if (OFLG_ISSET(XCONFIG_COPBASE, &screen->xconfigFlag))
- screen->COPbase = device_list[i].COPbase;
- if (OFLG_ISSET(XCONFIG_POSBASE, &screen->xconfigFlag))
- screen->POSbase = device_list[i].POSbase;
- if (OFLG_ISSET(XCONFIG_INSTANCE, &screen->xconfigFlag))
- screen->instance = device_list[i].instance;
- screen->s3Madjust = device_list[i].s3Madjust;
- screen->s3Nadjust = device_list[i].s3Nadjust;
- screen->s3MClk = device_list[i].s3MClk;
- screen->MemClk = device_list[i].MemClk;
- screen->LCDClk = device_list[i].LCDClk;
- screen->chipID = device_list[i].chipID;
- screen->chipRev = device_list[i].chipRev;
- screen->s3RefClk = device_list[i].s3RefClk;
- screen->s3BlankDelay = device_list[i].s3BlankDelay;
- screen->textClockFreq = device_list[i].textClockValue;
- if (OFLG_ISSET(XCONFIG_VGABASE, &screen->xconfigFlag))
- screen->VGAbase = device_list[i].VGAbase;
- screen->DCConfig = device_list[i].DCConfig;
- screen->DCOptions = device_list[i].DCOptions;
-#ifdef XF86SETUP
- screen->device = (void *) &device_list[i];
-#endif
- break;
- }
- }
- if ( i == n_devices ) { /* Exhausted the device list */
- xf86ConfigError("Not a declared device");
- }
- had_device = 1;
- break;
-
- case MONITOR:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Monitor name expected");
- for ( i = 0 ; i < n_monitors ; i++ ) {
- if ( strcmp(monitor_list[i].id,val.str) == 0 ) {
- if (!dummy && xf86Verbose) {
- ErrorF("%s %s: Monitor ID: \"%s\"\n",
- XCONFIG_GIVEN, screen->name, monitor_list[i].id);
- }
- if (!dummy) {
- monitor_list[i].Modes = xf86PruneModes(&monitor_list[i],
- monitor_list[i].Modes,
- screen, FALSE);
- screen->monitor = (MonPtr)xalloc(sizeof(MonRec));
- memcpy(screen->monitor, &monitor_list[i], sizeof(MonRec));
- }
- break;
- }
- }
- if ( i == n_monitors ) { /* Exhausted the monitor list */
- xf86ConfigError("Not a declared monitor");
- }
- had_monitor = 1;
- break;
-
- case BLANKTIME:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Screensaver blank time expected");
- if (!dummy && !xf86sFlag)
- defaultScreenSaverTime = ScreenSaverTime = val.num * MILLI_PER_MIN;
- break;
-
- case STANDBYTIME:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Screensaver standby time expected");
-#ifdef DPMSExtension
- if (!dummy)
- DPMSStandbyTime = val.num * MILLI_PER_MIN;
-#endif
- break;
+ return TRUE;
+}
- case SUSPENDTIME:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Screensaver suspend time expected");
-#ifdef DPMSExtension
- if (!dummy)
- DPMSSuspendTime = val.num * MILLI_PER_MIN;
-#endif
- break;
+static Bool
+configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
+{
+ int count;
+ DisplayModePtr mode,last = NULL;
+ XF86ConfModeLinePtr cmodep;
+ XF86ConfModesPtr modes;
+ XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
+ Gamma zeros = {0.0, 0.0, 0.0};
+ float badgamma = 0.0;
+
+ xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n",
+ conf_monitor->mon_identifier);
+ monitorp->id = conf_monitor->mon_identifier;
+ monitorp->vendor = conf_monitor->mon_vendor;
+ monitorp->model = conf_monitor->mon_modelname;
+ monitorp->Modes = NULL;
+ monitorp->Last = NULL;
+ monitorp->gamma = zeros;
+ monitorp->widthmm = conf_monitor->mon_width;
+ monitorp->heightmm = conf_monitor->mon_height;
+ monitorp->options = conf_monitor->mon_option_lst;
- case OFFTIME:
- if (xf86GetToken(NULL) != NUMBER)
- xf86ConfigError("Screensaver off time expected");
-#ifdef DPMSExtension
- if (!dummy)
- DPMSOffTime = val.num * MILLI_PER_MIN;
-#endif
- break;
+ /*
+ * fill in the monitor structure
+ */
+ for( count = 0 ; count < conf_monitor->mon_n_hsync; count++) {
+ monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
+ monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
+ }
+ monitorp->nHsync = conf_monitor->mon_n_hsync;
+ for( count = 0 ; count < conf_monitor->mon_n_vrefresh; count++) {
+ monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
+ monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
+ }
+ monitorp->nVrefresh = conf_monitor->mon_n_vrefresh;
- default:
- if (!dummy && !validateGraphicsToken(screen->validTokens, token))
- {
- xf86ConfigError("Screen section keyword expected");
- }
- break;
+ /*
+ * first we collect the mode lines from the UseModes directive
+ */
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str,
+ xf86configptr->conf_modes_lst);
+ modeslnk->ml_modes = modes;
+
+
+ /* now add the modes found in the modes
+ section to the list of modes for this
+ monitor unless it has been added before
+ because we are reusing the same section
+ for another screen */
+ if (xf86itemNotSublist(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst)) {
+ conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
+ xf86addListItem(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst);
+ }
+ modeslnk = modeslnk->list.next;
}
- }
- if (!dummy) {
- if (dispList == NULL) {
- FatalError(
- "A \"Display\" subsection is required in each \"Screen\" section\n");
- } else {
- /* Work out which if any Display subsection to use based on depth */
- if (xf86bpp < 0) {
- /*
- * no -bpp option given, so take depth if only one Display subsection
- * Don't do this for VGA2 and VGA16 where it makes no sense, and only
- * causes problems
- */
- if (numDisps == 1) {
-#ifndef XF86SETUP
- if (dispList[0].depth > 0
- && !(driverno >= VGA2 && driverno <= VGA16)) {
- xf86bpp = dispList[0].depth;
- }
-#endif
- dispIndex = 0;
- } else {
- xf86bpp = screen->depth;
- /* Look for a section which matches the driver's default depth */
- for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
- if (dispList[dispIndex].depth == screen->depth)
- break;
- }
- if (dispIndex == numDisps) {
- /* No match. This time, allow 15/16 and 24/32 to match */
- for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
- if ((screen->depth == 15 && dispList[dispIndex].depth == 16) ||
- (screen->depth == 16 && dispList[dispIndex].depth == 15) ||
- (screen->depth == 24 && dispList[dispIndex].depth == 32) ||
- (screen->depth == 32 && dispList[dispIndex].depth == 24))
- break;
- }
- }
- if (dispIndex == numDisps) {
- /* Still no match, so exit */
- FatalError("No \"Display\" subsection for default depth %d\n",
- screen->depth);
- }
+ /*
+ * we need to hook in the mode lines now
+ * here both data structures use lists, only our internal one
+ * is double linked
+ */
+ cmodep = conf_monitor->mon_modeline_lst;
+ while( cmodep ) {
+ mode = xnfalloc(sizeof(DisplayModeRec));
+ memset(mode,'\0',sizeof(DisplayModeRec));
+ mode->type = 0;
+ mode->Clock = cmodep->ml_clock;
+ mode->HDisplay = cmodep->ml_hdisplay;
+ mode->HSyncStart = cmodep->ml_hsyncstart;
+ mode->HSyncEnd = cmodep->ml_hsyncend;
+ mode->HTotal = cmodep->ml_htotal;
+ mode->VDisplay = cmodep->ml_vdisplay;
+ mode->VSyncStart = cmodep->ml_vsyncstart;
+ mode->VSyncEnd = cmodep->ml_vsyncend;
+ mode->VTotal = cmodep->ml_vtotal;
+ mode->Flags = cmodep->ml_flags;
+ mode->HSkew = cmodep->ml_hskew;
+ mode->VScan = cmodep->ml_vscan;
+ mode->name = xnfstrdup(cmodep->ml_identifier);
+ if( last ) {
+ mode->prev = last;
+ last->next = mode;
}
- } else {
- /* xf86bpp is set */
- if (numDisps == 1 && dispList[0].depth < 0) {
- /* one Display subsection, no depth set, so use it */
- /* XXXX Maybe should only do this when xf86bpp == default depth?? */
- dispIndex = 0;
- } else {
- /* find Display subsection matching xf86bpp */
- for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
- if (dispList[dispIndex].depth == xf86bpp)
- break;
- }
- if (dispIndex == numDisps) {
-#if 0
- /* No match. This time, allow 15/16 and 24/32 to match */
- for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
- if ((xf86bpp == 15 && dispList[dispIndex].depth == 16) ||
- (xf86bpp == 16 && dispList[dispIndex].depth == 15) ||
- (xf86bpp == 24 && dispList[dispIndex].depth == 32) ||
- (xf86bpp == 32 && dispList[dispIndex].depth == 24))
- break;
-#else
- /* No match. This time, allow 15/16 to match */
- for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
- if ((xf86bpp == 15 && dispList[dispIndex].depth == 16) ||
- (xf86bpp == 16 && dispList[dispIndex].depth == 15))
- break;
-#endif
- }
- }
- if (dispIndex == numDisps) {
- if (!(driverno >= VGA2 && driverno <= VGA16)) {
- /* Still no match, so exit */
- FatalError("No \"Display\" subsection for -bpp depth %d\n",
- xf86bpp);
- }
- else
- dispIndex = 0;
- }
+ else {
+ /*
+ * this is the first mode
+ */
+ monitorp->Modes = mode;
+ mode->prev = NULL;
}
- }
- /* Now copy the info across to the screen rec */
- dispp = dispList + dispIndex;
- if (xf86bpp > 0) screen->depth = xf86bpp;
- else if (dispp->depth > 0) screen->depth = dispp->depth;
- if (xf86weight.red || xf86weight.green || xf86weight.blue)
- screen->weight = xf86weight;
- else if (dispp->weight.red > 0) {
- screen->weight = dispp->weight;
- xf86weight = dispp->weight;
- }
- screen->frameX0 = dispp->frameX0;
- screen->frameY0 = dispp->frameY0;
- screen->virtualX = dispp->virtualX;
- screen->virtualY = dispp->virtualY;
- screen->modes = dispp->modes;
- screen->whiteColour = dispp->whiteColour;
- screen->blackColour = dispp->blackColour;
- screen->defaultVisual = dispp->defaultVisual;
- /* Add any new options that might be set */
- for (i = 0; i < MAX_OFLAGS; i++) {
- if (OFLG_ISSET(i, &(dispp->options)))
- OFLG_SET(i, &(screen->options));
- if (OFLG_ISSET(i, &(dispp->xconfigFlag)))
- OFLG_SET(i, &(screen->xconfigFlag));
- }
- screen->DCOptions = xf86DCConcatOption(screen->DCOptions,dispp->DCOptions);
-#ifdef XF86SETUP
- xf86setup_scrn_ndisps[driverno-SVGA] = numDisps;
- xf86setup_scrn_displays[driverno-SVGA] = dispList;
-#else
- /* Don't need them any more */
- xfree(dispList);
-#endif
+ last = mode;
+ cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
}
-
- /* Maybe these should be FatalError() instead? */
- if ( !had_monitor ) {
- xf86ConfigError("A screen must specify a monitor");
+ if(last){
+ last->next = NULL;
}
- if ( !had_device ) {
- xf86ConfigError("A screen must specify a device");
+ monitorp->Last = last;
+
+ /* add the (VESA) default modes */
+ if (! addDefaultModes(monitorp) )
+ return FALSE;
+
+ if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
+ monitorp->gamma.red = conf_monitor->mon_gamma_red;
+ if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
+ monitorp->gamma.green = conf_monitor->mon_gamma_green;
+ if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
+ monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
+
+ /* Check that the gamma values are within range */
+ if (monitorp->gamma.red > GAMMA_ZERO &&
+ (monitorp->gamma.red < GAMMA_MIN ||
+ monitorp->gamma.red > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.red;
+ } else if (monitorp->gamma.green > GAMMA_ZERO &&
+ (monitorp->gamma.green < GAMMA_MIN ||
+ monitorp->gamma.green > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.green;
+ } else if (monitorp->gamma.blue > GAMMA_ZERO &&
+ (monitorp->gamma.blue < GAMMA_MIN ||
+ monitorp->gamma.blue > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.blue;
+ }
+ if (badgamma > GAMMA_ZERO) {
+ xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
+ badgamma, GAMMA_MIN, GAMMA_MAX);
+ return FALSE;
}
- }
- /* Check for information that must be specified in XF86Config */
- if (scr_index >= 0 && xf86Screens[scr_index])
- {
- ScrnInfoPtr driver = xf86Screens[scr_index];
+ return TRUE;
+}
- graphFound = TRUE;
+static int
+lookupVisual(const char *visname)
+{
+ int i;
- if (driver->clockprog && !driver->clocks)
- {
- if (!OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions))){
- ErrorF("%s: No clock line specified: assuming programmable clocks\n");
- OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions));}
- driver->textclock = textClockValue;
- }
+ if (!visname || !*visname)
+ return -1;
- /* Find the Index of the Text Clock for the ClockProg */
- if (driver->clockprog && textClockValue > 0
- && !OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions)))
- {
- driver->textclock = xf86GetNearestClock(driver, textClockValue);
- if (abs(textClockValue - driver->clock[driver->textclock]) >
- CLOCK_TOLERANCE)
- FatalError(
- "There is no defined dot-clock matching the text clock\n");
- if (xf86Verbose)
- ErrorF("%s %s: text clock = %7.3f, clock used = %7.3f\n",
- XCONFIG_GIVEN,
- driver->name, textClockValue / 1000.0,
- driver->clock[driver->textclock] / 1000.0);
- }
- if (xf86Verbose && driver->defaultVisual > 0) {
- char *visualname;
- switch (driver->defaultVisual) {
- case StaticGray:
- case GrayScale:
- case StaticColor:
- case PseudoColor:
- case TrueColor:
- case DirectColor:
- visualname = xf86VisualNames[driver->defaultVisual];
- break;
- default:
- xf86ConfigError("unknown visual type");
- }
- ErrorF("%s %s: Default visual: %s\n", XCONFIG_GIVEN, driver->name,
- visualname);
+ for (i = 0; i <= DirectColor; i++) {
+ if (!xf86nameCompare(visname, xf86VisualNames[i]))
+ break;
}
- if (defaultColorVisualClass < 0)
- defaultColorVisualClass = driver->defaultVisual;
- /* GJA --Moved these from the device code. Had to reorganize it
- * a bit.
- */
- if (xf86Verbose) {
- if (OFLG_ISSET(XCONFIG_IOBASE, &driver->xconfigFlag))
- ErrorF("%s %s: Direct Access Register I/O Base Address: %x\n",
- XCONFIG_GIVEN, driver->name, driver->IObase);
-
- if (OFLG_ISSET(XCONFIG_DACBASE, &driver->xconfigFlag))
- ErrorF("%s %s: DAC Base I/O Address: %x\n",
- XCONFIG_GIVEN, driver->name, driver->DACbase);
-
- if (OFLG_ISSET(XCONFIG_COPBASE, &driver->xconfigFlag))
- ErrorF("%s %s: Coprocessor Base Memory Address: %x\n",
- XCONFIG_GIVEN, driver->name, driver->COPbase);
-
- if (OFLG_ISSET(XCONFIG_POSBASE, &driver->xconfigFlag))
- ErrorF("%s %s: POS Base Address: %x\n", XCONFIG_GIVEN, driver->name,
- driver->POSbase);
-
- if (OFLG_ISSET(XCONFIG_BIOSBASE, &driver->xconfigFlag))
- ErrorF("%s %s: BIOS Base Address: %x\n", XCONFIG_GIVEN, driver->name,
- driver->BIOSbase);
-
- if (OFLG_ISSET(XCONFIG_MEMBASE, &driver->xconfigFlag))
- ErrorF("%s %s: Memory Base Address: %x\n", XCONFIG_GIVEN,
- driver->name, driver->MemBase);
-
- if (OFLG_ISSET(XCONFIG_VGABASE, &driver->xconfigFlag))
- ErrorF("%s %s: VGA Aperture Base Address: %x\n", XCONFIG_GIVEN,
- driver->name, driver->VGAbase);
-
- /* Print clock program */
- if ( driver->clockprog ) {
- ErrorF("%s %s: ClockProg: \"%s\"", XCONFIG_GIVEN, driver->name,
- driver->clockprog);
- if ( textClockValue )
- ErrorF(", Text Clock: %7.3f\n", textClockValue / 1000.0);
- ErrorF("\n");
- }
- }
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
+ if (i <= DirectColor)
+ return i;
+
+ return -1;
}
-static CONFIG_RETURN_TYPE
-configDisplaySubsection(disp)
-DispPtr disp;
+
+static Bool
+configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
{
- int token;
- int i;
-
- while ((token = xf86GetToken(DisplayTab)) != ENDSUBSECTION) {
- switch (token) {
- case DEPTH:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display depth expected");
- disp->depth = val.num;
- break;
-
- case WEIGHT:
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected");
- if (val.num > 9) {
- disp->weight.red = (val.num / 100) % 10;
- disp->weight.green = (val.num / 10) % 10;
- disp->weight.blue = val.num % 10;
- } else {
- disp->weight.red = val.num;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected");
- disp->weight.green = val.num;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected");
- disp->weight.blue = val.num;
- }
- break;
-
- case VIEWPORT:
- OFLG_SET(XCONFIG_VIEWPORT,&(disp->xconfigFlag));
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Viewport X expected");
- disp->frameX0 = val.num;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Viewport Y expected");
- disp->frameY0 = val.num;
- break;
-
- case VIRTUAL:
- OFLG_SET(XCONFIG_VIRTUAL,&(disp->xconfigFlag));
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Virtual X expected");
- disp->virtualX = val.num;
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Virtual Y expected");
- disp->virtualY = val.num;
- break;
-
- case MODES:
- for (pLast=NULL; (token = xf86GetToken(NULL)) == STRING; pLast = pNew)
- {
- pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec));
- pNew->name = val.str;
- pNew->PrivSize = 0;
- pNew->Private = NULL;
-
- if (pLast)
- {
- pLast->next = pNew;
- pNew->prev = pLast;
- }
- else
- disp->modes = pNew;
- }
- /* Make sure at least one mode was present */
- if (!pLast)
- xf86ConfigError("Mode name expected");
- pNew->next = disp->modes;
- disp->modes->prev = pLast;
- pushToken = token;
- break;
-
- case BLACK:
- case WHITE:
- {
- unsigned char rgb[3];
- int ii;
-
- for (ii = 0; ii < 3; ii++)
- {
- if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("RGB value expected");
- rgb[ii] = val.num & 0x3F;
- }
- if (token == BLACK)
- {
- disp->blackColour.red = rgb[0];
- disp->blackColour.green = rgb[1];
- disp->blackColour.blue = rgb[2];
- }
- else
- {
- disp->whiteColour.red = rgb[0];
- disp->whiteColour.green = rgb[1];
- disp->whiteColour.blue = rgb[2];
- }
- }
- break;
-
- case VISUAL:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Visual name expected");
- token = getStringToken(VisualTab);
- if (!dummy && disp->defaultVisual >= 0)
- xf86ConfigError("Only one default visual may be specified");
- disp->defaultVisual = token - STATICGRAY;
- break;
-
- case OPTION:
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected");
- i = 0;
- while (xf86_OptionTab[i].token != -1)
- {
- if (StrCaseCmp(val.str, xf86_OptionTab[i].name) == 0)
- {
- OFLG_SET(xf86_OptionTab[i].token, &(disp->options));
- break;
- }
- i++;
- }
- if (xf86_OptionTab[i].token == -1)
- disp->DCOptions = xf86DCOption(disp->DCOptions,val);
- break;
-
- /* The following should really go in the S3 server */
- case INVERTVCLK:
- case BLANKDELAY:
- case EARLYSC:
- {
- DisplayModePtr p = disp->modes;
- if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mode name expected");
- if (disp->modes == NULL)
- xf86ConfigError("This must be after the Modes line");
- {
- Bool found = FALSE;
- int opt;
- INT32 value;
- char *mode_string = (char *)xalloc(strlen(val.str)+1);
- strcpy(mode_string,val.str);
-
- switch (token) {
- default: /* pacify compiler (uninitialized opt, value) */
- case INVERTVCLK:
- if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 1)
- xf86ConfigError("0 or 1 expected");
- opt = S3_INVERT_VCLK;
- value = val.num;
- break;
-
- case BLANKDELAY:
- if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 7)
- xf86ConfigError("number(s) 0..7 expected");
- opt = S3_BLANK_DELAY;
- value = val.num;
- if ((token=xf86GetToken(NULL)) == NUMBER) {
- if (val.num < 0 || val.num > 7)
- xf86ConfigError("number2 0..7 expected");
- value |= val.num << 4;
- }
- else pushToken = token;
- break;
-
- case EARLYSC:
- if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 1)
- xf86ConfigError("0 or 1 expected");
- opt = S3_EARLY_SC;
- value = val.num;
- break;
- }
-
- do {
- if (strcmp(p->name, mode_string) == 0
- || strcmp("*", mode_string) == 0) {
- found = TRUE;
- if (!p->PrivSize || !p->Private) {
- p->PrivSize = S3_MODEPRIV_SIZE;
- p->Private = (INT32 *)Xcalloc(sizeof(INT32) * S3_MODEPRIV_SIZE);
- p->Private[0] = 0;
- }
- p->Private[0] |= (1 << opt);
- p->Private[opt] = value;
- }
- p = p->next;
- } while (p != disp->modes);
- if (!found) xf86ConfigError("No mode of that name in the Modes line");
- xfree(mode_string);
- }
- }
- break;
+ int count = 0;
+ XF86ModePtr modep;
+ displayp->frameX0 = conf_display->disp_frameX0;
+ displayp->frameY0 = conf_display->disp_frameY0;
+ displayp->virtualX = conf_display->disp_virtualX;
+ displayp->virtualY = conf_display->disp_virtualY;
+ displayp->depth = conf_display->disp_depth;
+ displayp->fbbpp = conf_display->disp_bpp;
+ displayp->weight.red = conf_display->disp_weight.red;
+ displayp->weight.green = conf_display->disp_weight.green;
+ displayp->weight.blue = conf_display->disp_weight.blue;
+ displayp->blackColour.red = conf_display->disp_black.red;
+ displayp->blackColour.green = conf_display->disp_black.green;
+ displayp->blackColour.blue = conf_display->disp_black.blue;
+ displayp->whiteColour.red = conf_display->disp_white.red;
+ displayp->whiteColour.green = conf_display->disp_white.green;
+ displayp->whiteColour.blue = conf_display->disp_white.blue;
+ displayp->options = conf_display->disp_option_lst;
+ if (conf_display->disp_visual) {
+ displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
+ if (displayp->defaultVisual == -1) {
+ xf86ConfigError("Invalid visual name: \"%s\"",
+ conf_display->disp_visual);
+ return FALSE;
+ }
+ } else {
+ displayp->defaultVisual = -1;
+ }
+
+ /*
+ * now hook in the modes
+ */
+ modep = conf_display->disp_mode_lst;
+ while(modep) {
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes = xnfalloc((count+1) * sizeof(char*));
+ modep = conf_display->disp_mode_lst;
+ count = 0;
+ while(modep) {
+ displayp->modes[count] = modep->mode_name;
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes[count] = NULL;
- case EOF:
- FatalError("Unexpected EOF (missing EndSubSection)");
- break; /* :-) */
+ return TRUE;
+}
- default:
- xf86ConfigError("Display subsection keyword expected");
- break;
+static Bool
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+{
+ int i;
+
+ if (active)
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
+ else
+ xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
+ conf_device->dev_identifier);
+
+ devicep->identifier = conf_device->dev_identifier;
+ devicep->vendor = conf_device->dev_vendor;
+ devicep->board = conf_device->dev_board;
+ devicep->chipset = conf_device->dev_chipset;
+ devicep->ramdac = conf_device->dev_ramdac;
+ devicep->driver = conf_device->dev_driver;
+ devicep->active = active;
+ devicep->videoRam = conf_device->dev_videoram;
+ devicep->BiosBase = conf_device->dev_bios_base;
+ devicep->MemBase = conf_device->dev_mem_base;
+ devicep->IOBase = conf_device->dev_io_base;
+ devicep->clockchip = conf_device->dev_clockchip;
+ devicep->busID = conf_device->dev_busid;
+ devicep->textClockFreq = conf_device->dev_textclockfreq;
+ devicep->chipID = conf_device->dev_chipid;
+ devicep->chipRev = conf_device->dev_chiprev;
+ devicep->options = conf_device->dev_option_lst;
+ devicep->irq = conf_device->dev_irq;
+ devicep->screen = conf_device->dev_screen;
+
+ for (i = 0; i < MAXDACSPEEDS; i++) {
+ if (i < CONF_MAXDACSPEEDS)
+ devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
+ else
+ devicep->dacSpeeds[i] = 0;
}
- }
-#ifdef NEED_RETURN_VALUE
- return RET_OKAY;
-#endif
+ devicep->numclocks = conf_device->dev_clocks;
+ if (devicep->numclocks > MAXCLOCKS)
+ devicep->numclocks = MAXCLOCKS;
+ for (i = 0; i < devicep->numclocks; i++) {
+ devicep->clock[i] = conf_device->dev_clock[i];
+ }
+ devicep->claimed = FALSE;
+
+ return TRUE;
}
-Bool
-xf86LookupMode(target, driver, flags)
- DisplayModePtr target;
- ScrnInfoPtr driver;
- int flags;
+#ifdef XF86DRI
+static Bool
+configDRI(XF86ConfDRIPtr drip)
{
- DisplayModePtr p;
- DisplayModePtr best_mode = NULL;
- int i, j, k, Gap;
- int Minimum_Gap = CLOCK_TOLERANCE + 1;
- Bool found_mode = FALSE;
- Bool clock_too_high = FALSE;
- static Bool first_time = TRUE;
- double refresh, bestRefresh = 0.0;
-
- if (first_time)
- {
- ErrorF("%s %s: Maximum allowed dot-clock: %1.3f MHz\n", XCONFIG_PROBED,
- driver->name, driver->maxClock / 1000.0);
- first_time = FALSE;
- /*
- * First time through, cull modes which are not valid for the
- * card/driver.
- */
- driver->monitor->Modes = xf86PruneModes(NULL, driver->monitor->Modes,
- driver, TRUE);
- }
-
- if (xf86BestRefresh && !(flags & LOOKUP_FORCE_DEFAULT))
- flags |= LOOKUP_BEST_REFRESH;
+ int count = 0;
+ XF86ConfBuffersPtr bufs;
+ int i;
+ struct group *grp;
+
+ xf86ConfigDRI.group = -1;
+ xf86ConfigDRI.mode = 0;
+ xf86ConfigDRI.bufs_count = 0;
+ xf86ConfigDRI.bufs = NULL;
+
+ if (drip) {
+ if (drip->dri_group_name) {
+ if ((grp = getgrnam(drip->dri_group_name)))
+ xf86ConfigDRI.group = grp->gr_gid;
+ } else {
+ if (drip->dri_group >= 0)
+ xf86ConfigDRI.group = drip->dri_group;
+ }
+ xf86ConfigDRI.mode = drip->dri_mode;
+ for (bufs = drip->dri_buffers_lst; bufs; bufs = bufs->list.next)
+ ++count;
+
+ xf86ConfigDRI.bufs_count = count;
+ xf86ConfigDRI.bufs = xnfalloc(count * sizeof(*xf86ConfigDRI.bufs));
+
+ for (i = 0, bufs = drip->dri_buffers_lst;
+ i < count;
+ i++, bufs = bufs->list.next) {
+
+ xf86ConfigDRI.bufs[i].count = bufs->buf_count;
+ xf86ConfigDRI.bufs[i].size = bufs->buf_size;
+ /* FIXME: Flags not implemented. These
+ could be used, for example, to specify a
+ contiguous block and/or write-combining
+ cache policy. */
+ xf86ConfigDRI.bufs[i].flags = 0;
+ }
+ }
- for (p = driver->monitor->Modes; p != NULL; p = p->next) /* scan list */
- {
- if (!strcmp(p->name, target->name)) /* names equal ? */
- {
- /* First check if the driver objects to the mode */
- if ((driver->ValidMode)(p, xf86Verbose, MODE_USED) != MODE_OK)
- {
- ErrorF("%s %s: Mode \"%s\" rejected by driver. Deleted.\n",
- XCONFIG_PROBED,driver->name, target->name );
- break;
- }
+ return TRUE;
+}
+#endif
- if ((flags & LOOKUP_NO_INTERLACED) && (p->Flags & V_INTERLACE))
- {
- continue;
- }
+static Bool
+configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
+{
+ xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
+ inputp->identifier = conf_input->inp_identifier;
+ inputp->driver = conf_input->inp_driver;
+ inputp->commonOptions = conf_input->inp_option_lst;
+ inputp->extraOptions = NULL;
- if ((OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(driver->clockOptions))) &&
- !OFLG_ISSET(OPTION_NO_PROGRAM_CLOCKS, &(driver->options)))
- {
- if (driver->clocks == 0)
- {
- /* this we know */
- driver->clock[0] = 25175; /* 25.175Mhz */
- driver->clock[1] = 28322; /* 28.322MHz */
- driver->clocks = 2;
- }
+ /* XXX This is required until the keyboard driver is converted */
+ if (!xf86NameCmp(inputp->driver, "keyboard"))
+ return configInputKbd(inputp);
- if ((p->Clock / 1000) > (driver->maxClock / 1000))
- clock_too_high = TRUE;
- else
- {
- /* We fill in the the programmable clocks as we go */
- for (i=0; i < driver->clocks; i++)
- if (driver->clock[i] == p->Clock)
- break;
-
- if (i >= MAXCLOCKS)
- {
- ErrorF("%s %s: Too many programmable clocks used (limit %d)!\n",
- XCONFIG_PROBED, driver->name, MAXCLOCKS);
- return FALSE;
- }
-
- if (i == driver->clocks)
- {
- driver->clock[i] = p->Clock;
- driver->clocks++;
- }
-
-
- if (flags & LOOKUP_BEST_REFRESH)
- {
- refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal;
- if (p->Flags & V_INTERLACE)
- {
- refresh *= 2;
- refresh /= INTERLACE_REFRESH_WEIGHT;
- }
- else if (p->Flags & V_DBLSCAN)
- {
- refresh /= 2;
- }
- if (refresh > bestRefresh)
- {
- best_mode = p;
- bestRefresh = refresh;
- target->Clock = i;
- }
- }
- else
- {
- target->Clock = i;
- best_mode = p;
- }
- }
- }
- else
- {
- /*
- * go look if any of the clocks in the list matches the one in
- * the mode (j=1), or if a better match exists when the clocks
- * in the list are divided by 2 (j=2)
- */
- if (OFLG_ISSET(OPTION_CLKDIV2, &(driver->options)))
- k=2;
- else
- k=1;
- for (j=1 ; j<=k ; j++)
- {
- i = xf86GetNearestClock(driver, p->Clock*j);
- if (flags & LOOKUP_BEST_REFRESH)
- {
- if ( ((driver->clock[i]/j) / 1000) > (driver->maxClock / 1000) )
- clock_too_high = TRUE;
- else
- {
- refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal;
- if (p->Flags & V_INTERLACE)
- {
- refresh *= 2;
- refresh /= INTERLACE_REFRESH_WEIGHT;
- }
- else if (p->Flags & V_DBLSCAN)
- {
- refresh /= 2;
- }
- if (refresh > bestRefresh)
- {
- target->Clock = i;
- if (j==2) p->Flags |= V_CLKDIV2;
- best_mode = p;
- bestRefresh = refresh;
- }
- }
- }
- else
- {
- Gap = abs( p->Clock - (driver->clock[i]/j) );
- if (Gap < Minimum_Gap)
- {
- if ( ((driver->clock[i]/j) / 1000) > (driver->maxClock / 1000) )
- clock_too_high = TRUE;
- else
- {
- target->Clock = i;
- if (j==2) p->Flags |= V_CLKDIV2;
- best_mode = p;
- Minimum_Gap = Gap;
- }
- }
- }
- }
- }
- found_mode = TRUE;
- }
- }
+ return TRUE;
+}
+
+static Bool
+modeIsPresent(char * modename,MonPtr monitorp)
+{
+ DisplayModePtr knownmodes = monitorp->Modes;
- if (best_mode != NULL)
- {
- target->HDisplay = best_mode->HDisplay;
- target->HSyncStart = best_mode->HSyncStart;
- target->HSyncEnd = best_mode->HSyncEnd;
- target->HTotal = best_mode->HTotal;
- target->HSkew = best_mode->HSkew;
- target->VDisplay = best_mode->VDisplay;
- target->VSyncStart = best_mode->VSyncStart;
- target->VSyncEnd = best_mode->VSyncEnd;
- target->VTotal = best_mode->VTotal;
- target->Flags = best_mode->Flags;
- target->CrtcHDisplay = best_mode->CrtcHDisplay;
- target->CrtcHSyncStart = best_mode->CrtcHSyncStart;
- target->CrtcHSyncEnd = best_mode->CrtcHSyncEnd;
- target->CrtcHTotal = best_mode->CrtcHTotal;
- target->CrtcHSkew = best_mode->CrtcHSkew;
- target->CrtcVDisplay = best_mode->CrtcVDisplay;
- target->CrtcVSyncStart = best_mode->CrtcVSyncStart;
- target->CrtcVSyncEnd = best_mode->CrtcVSyncEnd;
- target->CrtcVTotal = best_mode->CrtcVTotal;
- target->CrtcHAdjusted = best_mode->CrtcHAdjusted;
- target->CrtcVAdjusted = best_mode->CrtcVAdjusted;
- if (target->Flags & V_DBLSCAN)
+ /* all I can think of is a linear search... */
+ while(knownmodes != NULL)
{
- target->CrtcVDisplay *= 2;
- target->CrtcVSyncStart *= 2;
- target->CrtcVSyncEnd *= 2;
- target->CrtcVTotal *= 2;
- target->CrtcVAdjusted = TRUE;
+ if(!strcmp(modename,knownmodes->name) &&
+ !(knownmodes->type & M_T_DEFAULT))
+ return TRUE;
+ knownmodes = knownmodes->next;
}
+ return FALSE;
+}
-#if 0
- /* I'm not sure if this is the best place for this in the
- * new XF86Config organization. - SRA
- */
- if (found_mode)
- if ((driver->ValidMode)(target, xf86Verbose, MODE_USED) != MODE_OK)
- {
- ErrorF("%s %s: Unable to support mode \"%s\"\n",
- XCONFIG_GIVEN,driver->name, target->name );
- return(FALSE);
- }
-#endif
+static Bool
+addDefaultModes(MonPtr monitorp)
+{
+ DisplayModePtr mode;
+ DisplayModePtr last = monitorp->Last;
+ int i = 0;
- if (xf86Verbose)
+ while (xf86DefaultModes[i].name != NULL)
{
- ErrorF("%s %s: Mode \"%s\": mode clock = %7.3f",
- XCONFIG_GIVEN, driver->name, target->name,
- best_mode->Clock / 1000.0);
- if (!OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(driver->clockOptions)) ||
- OFLG_ISSET(OPTION_NO_PROGRAM_CLOCKS, &(driver->options))) {
- ErrorF(", clock used = %7.3f", driver->clock[target->Clock] / 1000.0);
- if (target->Flags & V_CLKDIV2)
- ErrorF("/2");
- }
- ErrorF("\n");
+ if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
+ do
+ {
+ mode = xnfalloc(sizeof(DisplayModeRec));
+ memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
+ if (xf86DefaultModes[i].name)
+ mode->name = xnfstrdup(xf86DefaultModes[i].name);
+ if( last ) {
+ mode->prev = last;
+ last->next = mode;
+ }
+ else {
+ /* this is the first mode */
+ monitorp->Modes = mode;
+ mode->prev = NULL;
+ }
+ last = mode;
+ i++;
+ }
+ while((xf86DefaultModes[i].name != NULL) &&
+ (!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
+ else
+ i++;
}
- }
- else if (!found_mode)
- ErrorF("%s %s: There is no mode definition named \"%s\"\n",
- XCONFIG_PROBED, driver->name, target->name);
- else if (clock_too_high)
- ErrorF("%s %s: Clock for mode \"%s\" %s\n\tLimit is %7.3f MHz\n",
- XCONFIG_PROBED, driver->name, target->name,
- "is too high for the configured hardware.",
- driver->maxClock / 1000.0);
- else
- ErrorF("%s %s: There is no defined dot-clock matching mode \"%s\"\n",
- XCONFIG_PROBED, driver->name, target->name);
-
- return (best_mode != NULL);
-}
+ monitorp->Last = last;
-void
-xf86VerifyOptions(allowedOptions, driver)
- OFlagSet *allowedOptions;
- ScrnInfoPtr driver;
-{
- int j;
-
- for (j=0; xf86_OptionTab[j].token >= 0; j++)
- if ((OFLG_ISSET(xf86_OptionTab[j].token, &driver->options)))
- if (OFLG_ISSET(xf86_OptionTab[j].token, allowedOptions))
- {
- if (xf86Verbose)
- ErrorF("%s %s: Option \"%s\"\n", XCONFIG_GIVEN,
- driver->name, xf86_OptionTab[j].name);
- }
- else
- ErrorF("%s %s: Option flag \"%s\" is not defined for this driver\n",
- XCONFIG_GIVEN, driver->name, xf86_OptionTab[j].name);
+ return TRUE;
}
-/* Note: (To keep me [GJA] from getting confused)
- * We have two mode-related datastructures:
- * 1. A doubly linked mode name list, with ends marked by self-pointers.
- * 2. A doubly linked mode structure list.
- * We are operating here on the second structure.
- * Initially this is just singly linked.
+/*
+ * load the config file and fill the global data structure
*/
-static DisplayModePtr
-xf86PruneModes(monp, allmodes, scrp, card)
- MonPtr monp; /* Monitor specification */
- DisplayModePtr allmodes; /* List to be pruned */
- ScrnInfoPtr scrp;
- Bool card; /* TRUE => do driver validity check */
+Bool
+xf86HandleConfigFile(void)
{
- DisplayModePtr dispmp; /* To walk the list */
- DisplayModePtr olddispmp; /* The one being freed. */
- DisplayModePtr remainder; /* The first one retained. */
+ const char *filename;
+ char *searchpath;
+ MessageType from = X_DEFAULT;
- dispmp = allmodes;
+ if (getuid() == 0)
+ searchpath = ROOT_CONFIGPATH;
+ else
+ searchpath = USER_CONFIGPATH;
- /* The first modes to be deleted require that the pointer to the
- * mode list is updated. Also, they have no predecessor in the list.
- */
- while (dispmp &&
- (card ?
- ((scrp->ValidMode)(dispmp, xf86Verbose, MODE_SUGGESTED)
- != MODE_OK) :
- (xf86CheckMode(scrp, dispmp, monp, xf86Verbose) != MODE_OK))) {
- olddispmp = dispmp;
- dispmp = dispmp->next;
- xfree(olddispmp->name);
- xfree(olddispmp);
- }
- /* Now we either have a mode that fits, or no mode at all */
- if ( ! dispmp ) { /* No mode at all */
- return NULL;
- }
- remainder = dispmp;
- while ( dispmp->next ) {
- if (card ?
- ((scrp->ValidMode)(dispmp->next,xf86Verbose,MODE_SUGGESTED)
- != MODE_OK) :
- (xf86CheckMode(scrp, dispmp->next, monp, xf86Verbose) !=
- MODE_OK)) {
- olddispmp = dispmp->next;
- dispmp->next = dispmp->next->next;
- xfree(olddispmp->name);
- xfree(olddispmp);
- } else {
- dispmp = dispmp->next;
- }
- }
- return remainder; /* Return pointer to {the first / the list } */
-}
+ if (xf86ConfigFile)
+ from = X_CMDLINE;
-/*
- * Return MODE_OK if the mode pointed to by dispmp agrees with all constraints
- * we can make up for the monitor pointed to by monp.
- */
-int
-xf86CheckMode(scrp, dispmp, monp, verbose)
- ScrnInfoPtr scrp;
- DisplayModePtr dispmp;
- MonPtr monp;
- Bool verbose;
-{
- int i;
- float dotclock, hsyncfreq, vrefreshrate;
- char *scrname = scrp->name;
-
- /* Sanity checks */
- if ((0 >= dispmp->HDisplay) ||
- (dispmp->HDisplay > dispmp->HSyncStart) ||
- (dispmp->HSyncStart >= dispmp->HSyncEnd) ||
- (dispmp->HSyncEnd >= dispmp->HTotal))
- {
- ErrorF(
- "%s %s: Invalid horizontal timing for mode \"%s\". Deleted.\n",
- XCONFIG_PROBED, scrname, dispmp->name);
- return MODE_HSYNC;
- }
+ filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT);
+ if (filename) {
+ xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename);
+ xf86ConfigFile = xnfstrdup(filename);
+ } else {
+ xf86Msg(X_ERROR, "Unable to locate/open config file");
+ if (xf86ConfigFile)
+ xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile);
+ xf86ErrorFVerb(0, "\n");
+ return FALSE;
+ }
+ if ((xf86configptr = xf86readConfigFile ()) == NULL) {
+ xf86Msg(X_ERROR, "Problem parsing the config file\n");
+ return FALSE;
+ }
+ xf86closeConfigFile ();
- if ((0 >= dispmp->VDisplay) ||
- (dispmp->VDisplay > dispmp->VSyncStart) ||
- (dispmp->VSyncStart >= dispmp->VSyncEnd) ||
- (dispmp->VSyncEnd >= dispmp->VTotal))
- {
- ErrorF(
- "%s %s: Invalid vertical timing for mode \"%s\". Deleted.\n",
- XCONFIG_PROBED, scrname, dispmp->name);
- return MODE_VSYNC;
- }
+ /* Initialise a few things. */
- /* Deal with the dispmp->Clock being a frequency or index */
- if (dispmp->Clock > MAXCLOCKS) {
- dotclock = (float)dispmp->Clock;
- } else {
- dotclock = (float)scrp->clock[dispmp->Clock];
+ /*
+ * now we convert part of the information contained in the parser
+ * structures into our own structures.
+ * The important part here is to figure out which Screen Sections
+ * in the XF86Config file are active so that we can piece together
+ * the modes that we need later down the road.
+ * And while we are at it, we'll decode the rest of the stuff as well
+ */
+
+ /* First check if a layout section is present, and if it is valid. */
+
+ if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
+ if (xf86ScreenName == NULL) {
+ xf86Msg(X_WARNING,
+ "No Layout section. Using the first Screen section.\n");
}
- hsyncfreq = dotclock / (float)(dispmp->HTotal);
- for ( i = 0 ; i < monp->n_hsync ; i++ )
- if ( (hsyncfreq > 0.999 * monp->hsync[i].lo) &&
- (hsyncfreq < 1.001 * monp->hsync[i].hi) )
- break; /* In range. */
-
- /* Now see whether we ran out of sync frequencies */
- if ( i == monp->n_hsync ) {
- if (verbose) {
- ErrorF(
- "%s %s: Mode \"%s\" needs hsync freq of %.2f kHz. Deleted.\n",
- XCONFIG_PROBED, scrname, dispmp->name, hsyncfreq);
- }
- return MODE_HSYNC;
+ if (!configImpliedLayout(&xf86ConfigLayout,
+ xf86configptr->conf_screen_lst)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
}
-
- vrefreshrate = dotclock * 1000.0 /
- ((float)(dispmp->HTotal) * (float)(dispmp->VTotal)) ;
- if ( dispmp->Flags & V_INTERLACE ) vrefreshrate *= 2.0;
- if ( dispmp->Flags & V_DBLSCAN ) vrefreshrate /= 2.0;
- for ( i = 0 ; i < monp->n_vrefresh ; i++ )
- if ( (vrefreshrate > 0.999 * monp->vrefresh[i].lo) &&
- (vrefreshrate < 1.001 * monp->vrefresh[i].hi) )
- break; /* In range. */
-
- /* Now see whether we ran out of refresh rates */
- if ( i == monp->n_vrefresh ) {
- if (verbose) {
- ErrorF(
- "%s %s: Mode \"%s\" needs vert refresh rate of %.2f Hz. Deleted.\n",
- XCONFIG_PROBED, scrname, dispmp->name, vrefreshrate);
- }
- return MODE_VSYNC;
+ } else {
+ if (xf86configptr->conf_flags != NULL) {
+ char *dfltlayout = NULL;
+ pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+ dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ dfltlayout)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ } else {
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ NULL)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
+ }
}
+ }
- /* Interlaced modes should have an odd VTotal */
- if (dispmp->Flags & V_INTERLACE)
- dispmp->CrtcVTotal = dispmp->VTotal |= 1;
+ /* Now process everything else */
- /* Passed every test. */
- return MODE_OK;
-}
+ if (!configFiles(xf86configptr->conf_files) ||
+ !configServerFlags(xf86configptr->conf_flags,
+ xf86ConfigLayout.options)
+#ifdef XF86DRI
+ || !configDRI(xf86configptr->conf_dri)
+#endif
+ ) {
+ ErrorF ("Problem when converting the config data structures\n");
+ return FALSE;
+ }
-/*
- * Save entire line from config file in memory area, if memory area
- * does not exist allocate it. Set DCerr according to value of token.
- * Return address of memory area.
- */
-static char *xf86DCSaveLine(DCPointer,token)
- char *DCPointer;
- int token;
-{
- static int len = 0; /* length of memory area where to store strings */
- static int pos = 0; /* current position */
- char *currpointer; /* pointer to current position in memory area */
- static int currline; /* lineno of line currently interpreted */
- int addlen; /* len to add to pos */
-
- if(DCPointer == NULL){ /* initialize */
- DCPointer = (char *)xalloc(4096); /* initial size 4kB */
- len = 4096;
- strcpy(DCPointer,configPath);
- pos = strlen(DCPointer) + 1;
- currline = -1; /* no line yet */
- }
+ /*
+ * Handle some command line options that can override some of the
+ * ServerFlags settings.
+ */
+#ifdef XF86VIDMODE
+ if (xf86VidModeDisabled)
+ xf86Info.vidModeEnabled = FALSE;
+ if (xf86VidModeAllowNonLocal)
+ xf86Info.vidModeAllowNonLocal = TRUE;
+#endif
- if(configLineNo != currline) /* new line */
- {
- currline = configLineNo;
- addlen = strlen(configBuf) + 1 + sizeof(int); /* string + lineno */
- while ( (pos + addlen) >= len ){ /* not enough space? */
- DCPointer = (char *)xrealloc(DCPointer, (len + 4096));
- len += 4096;
- }
- currpointer = DCPointer + pos; /* find current position */
- memcpy(currpointer, &currline, sizeof(int)); /* Grrr unaligned ints.. */
- strcpy((currpointer + sizeof(int)),configBuf); /* store complete line*/
- pos += addlen; /* goto end */
- currpointer += addlen;
- *(currpointer) = EOF; /* mark end */
- }
- switch(token){
- case STRING:
- case DASH:
- case NUMBER:
- case COMMA:
- break;
- case ERROR_TOKEN: /* if unknown token unset DCerr to ignore it */
- DCerr = 0; /* and subsequent STRING, DASH, NUMBER, COMMA */
- break;
- default: /* set to complain if a valid token is */
- DCerr = 1; /* followed by an unwanted STRING etc. */
- }
- return(DCPointer);
+#ifdef XF86MISC
+ if (xf86MiscModInDevDisabled)
+ xf86Info.miscModInDevEnabled = FALSE;
+ if (xf86MiscModInDevAllowNonLocal)
+ xf86Info.miscModInDevAllowNonLocal = TRUE;
+#endif
+
+ if (xf86AllowMouseOpenFail)
+ xf86Info.allowMouseOpenFail = TRUE;
+
+ return TRUE;
}
-/*
- * Store any unknown Option strings (contained in val.str)
- * in a memory are pointed to by pointer. If it doesn't
- * exist allocate it and return a pointer pointing to it
- */
-static char *
-xf86DCOption(DCPointer, val)
- char *DCPointer;
- LexRec val;
+/* These make the equivalent parser functions visible to the common layer. */
+Bool
+xf86PathIsAbsolute(const char *path)
{
- static int len = 0;
- static int pos = 0;
- int addlen;
- char *currpointer; /* current position */
-
- if (DCPointer == NULL){ /* First time: initialize */
- DCPointer = (char *)xalloc(4096); /* allocate enough space */
- strcpy(DCPointer,configPath);
- pos = strlen(DCPointer) + 1;
- len = 4096; /* and total length */
- }
-
- addlen = sizeof(int) + strlen(val.str) + 1; /* token, lineno */
- while( (pos + addlen) >= len ){ /* reallocate if not enough */
- DCPointer = (char *)xrealloc(DCPointer, (len + 4096));
- len += 4096;
- }
- currpointer = DCPointer + pos;
- *(int *)currpointer=configLineNo;
- strcpy(currpointer + sizeof(int),val.str); /* store string */
- pos += addlen;
- *(currpointer + addlen) = EOF; /* mark end */
- return(DCPointer);
+ return (xf86pathIsAbsolute(path) != 0);
}
-static char
-* xf86DCConcatOption(Pointer1, Pointer2)
-char *Pointer1;
-char *Pointer2;
+Bool
+xf86PathIsSafe(const char *path)
{
- int s1 = 0;
- int s2 = 0;
- int s3;
- char *ptmp;
-
- if(Pointer1)
- while(*(Pointer1 + s1) != EOF){s1++;}
- else if (Pointer2)
- return Pointer2;
- else return NULL;
- if(Pointer2)
- while(*(Pointer2 + s2) != EOF){s2++;}
- else if (Pointer1)
- return Pointer1;
- else return NULL;
- s3 = strlen(Pointer2) + 1;
- s2 -= s3;
-
- Pointer1 = (char *)xrealloc(Pointer1,s1+s2+1);
- ptmp = Pointer1 + s1;
- Pointer2 += s3;
- do{
- *ptmp = *Pointer2;
- *ptmp++;
- *Pointer2++;
- } while(s2--);
- return Pointer1;
+ return (xf86pathIsSafe(path) != 0);
}
-
+
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 6c0943b41..1a214c4ad 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -1,27 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.13 1996/12/23 06:43:22 dawes Exp $ */
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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
- * 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.
- *
- * THOMAS ROELL 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
- * 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: xf86Cursor.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.35 2003/02/13 10:49:38 eich Exp $ */
+/* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
#define NEED_EVENTS
#include "X.h"
@@ -30,73 +8,72 @@
#include "cursor.h"
#include "mipointer.h"
#include "scrnintstr.h"
+#include "globals.h"
#include "compiler.h"
#include "xf86.h"
-#include "xf86Procs.h"
-#ifdef XFreeXDGA
-#include "Xproto.h"
-#include "extnsionst.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-
-#define _XF86DGA_SERVER_
-#include "extensions/xf86dgastr.h"
-#endif
+#include "xf86Priv.h"
+#include "xf86_OSproc.h"
#ifdef XINPUT
-#include "xf86_Config.h"
#include "XIproto.h"
#include "xf86Xinput.h"
#endif
-/* #include "atKeynames.h" -hv- dont need that include here */
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+typedef struct _xf86EdgeRec {
+ short screen;
+ short start;
+ short end;
+ DDXPointRec offset;
+ struct _xf86EdgeRec *next;
+} xf86EdgeRec, *xf86EdgePtr;
-static Bool xf86CursorOffScreen(
-#if NeedFunctionPrototypes
- ScreenPtr *pScreen,
- int *x,
- int *y
-#endif
-);
-static void xf86CrossScreen(
-#if NeedFunctionPrototypes
- ScreenPtr pScreen,
- Bool entering
-#endif
-);
-static void xf86WrapCursor(
-#if NeedFunctionPrototypes
- ScreenPtr pScreen,
- int x,
- int y
-#endif
-);
+typedef struct {
+ xf86EdgePtr left, right, up, down;
+} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
+
+static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
+static void xf86CrossScreen(ScreenPtr pScreen, Bool entering);
+static void xf86WarpCursor(ScreenPtr pScreen, int x, int y);
+
+static void xf86PointerMoved(int scrnIndex, int x, int y);
-miPointerScreenFuncRec xf86PointerScreenFuncs = {
+static miPointerScreenFuncRec xf86PointerScreenFuncs = {
xf86CursorOffScreen,
xf86CrossScreen,
- xf86WrapCursor,
+ xf86WarpCursor,
#ifdef XINPUT
xf86eqEnqueue,
+ xf86eqSwitchScreen
+#else
+ /* let miPointerInitialize take care of these */
+ NULL,
+ NULL
#endif
};
+static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
+static Bool HardEdges;
/*
* xf86InitViewport --
* Initialize paning & zooming parameters, so that a driver must only
* check what resolutions are possible and whether the virtual area
- * is valid if specifyed.
+ * is valid if specified.
*/
void
-xf86InitViewport(pScr)
- ScrnInfoPtr pScr;
+xf86InitViewport(ScrnInfoPtr pScr)
{
+
+ pScr->PointerMoved = xf86PointerMoved;
+
/*
* Compute the initial Viewport if necessary
*/
@@ -131,163 +108,269 @@ xf86InitViewport(pScr)
*/
void
-xf86SetViewport(pScreen, x, y)
- ScreenPtr pScreen;
- int x, y;
+xf86SetViewport(ScreenPtr pScreen, int x, int y)
{
- Bool frameChanged = FALSE;
ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ (*pScr->PointerMoved)(pScreen->myNum, x, y);
+}
+
+
+static void
+xf86PointerMoved(int scrnIndex, int x, int y)
+{
+ Bool frameChanged = FALSE;
+ ScrnInfoPtr pScr = xf86Screens[scrnIndex];
+
/*
* check wether (x,y) belongs to the visual part of the screen
* if not, change the base of the displayed frame accoring
*/
if ( pScr->frameX0 > x) {
pScr->frameX0 = x;
- pScr->frameX1 = x + pScr->modes->HDisplay - 1;
+ pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
frameChanged = TRUE ;
}
if ( pScr->frameX1 < x) {
pScr->frameX1 = x + 1;
- pScr->frameX0 = x - pScr->modes->HDisplay + 1;
+ pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
frameChanged = TRUE ;
}
if ( pScr->frameY0 > y) {
pScr->frameY0 = y;
- pScr->frameY1 = y + pScr->modes->VDisplay - 1;
+ pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
frameChanged = TRUE;
}
if ( pScr->frameY1 < y) {
pScr->frameY1 = y;
- pScr->frameY0 = y - pScr->modes->VDisplay + 1;
+ pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
frameChanged = TRUE;
}
- if (frameChanged) (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0);
+ if (frameChanged && pScr->AdjustFrame != NULL)
+ pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
}
-
-static Bool xf86ZoomLocked = FALSE;
-
/*
* xf86LockZoom --
* Enable/disable ZoomViewport
*/
void
-xf86LockZoom (pScreen, lock)
- ScreenPtr pScreen;
- Bool lock;
+xf86LockZoom(ScreenPtr pScreen, Bool lock)
{
- /*
- * pScreen is currently ignored, but may be used later to enable locking
- * of individual screens.
- */
-
- xf86ZoomLocked = lock;
+ XF86SCRNINFO(pScreen)->zoomLocked = lock;
}
/*
- * xf86ZoomViewport --
- * Reinitialize the visual part of the screen for another modes->
+ * xf86SwitchMode --
+ * This is called by both keyboard processing and the VidMode extension to
+ * set a new mode.
*/
-void
-xf86ZoomViewport (pScreen, zoom)
- ScreenPtr pScreen;
- int zoom;
+Bool
+xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScreenPtr pCursorScreen;
+ Bool Switched;
+ int px, py;
- if (xf86ZoomLocked)
- return;
+ if (!pScr->vtSema || !mode || !pScr->SwitchMode)
+ return FALSE;
#ifdef XFreeXDGA
- /*
- * We should really send the mode change request to the DGA client and let
- * it decide what to do. For now just bin the request
- */
- if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics)
- return;
+ if (DGAActive(pScr->scrnIndex))
+ return FALSE;
#endif
- if (pScr->modes != pScr->modes->next)
- {
- pScr->modes = zoom > 0 ? pScr->modes->next : pScr->modes->prev;
+ if (mode == pScr->currentMode)
+ return TRUE;
+
+ if (mode->HDisplay > pScreen->width || mode->VDisplay > pScreen->height)
+ return FALSE;
+
+ pCursorScreen = miPointerCurrentScreen();
+ if (pScreen == pCursorScreen)
+ miPointerPosition(&px, &py);
+
+ xf86EnterServerState(SETUP);
+ Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
+ xf86EnterServerState(OPERATING);
+ if (Switched) {
+ pScr->currentMode = mode;
+
+ /*
+ * Adjust frame for new display size.
+ */
+ if (pScreen == pCursorScreen)
+ pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
+ else
+ pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
+
+ if (pScr->frameX0 < 0)
+ pScr->frameX0 = 0;
+
+ pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
+ if (pScr->frameX1 >= pScr->virtualX) {
+ pScr->frameX0 = pScr->virtualX - mode->HDisplay;
+ pScr->frameX1 = pScr->virtualX - 1;
+ }
- if ((pScr->SwitchMode)(pScr->modes))
- {
- /*
- * adjust new frame for the displaysize
- */
- pScr->frameX0 = (pScr->frameX1 + pScr->frameX0 -pScr->modes->HDisplay)/2;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
-
- if (pScr->frameX0 < 0)
- {
- pScr->frameX0 = 0;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- }
- else if (pScr->frameX1 >= pScr->virtualX)
- {
- pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- }
-
- pScr->frameY0 = (pScr->frameY1 + pScr->frameY0 - pScr->modes->VDisplay)/2;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
-
- if (pScr->frameY0 < 0)
- {
- pScr->frameY0 = 0;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
- }
- else if (pScr->frameY1 >= pScr->virtualY)
- {
- pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
- }
+ if (pScreen == pCursorScreen)
+ pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
+ else
+ pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
+
+ if (pScr->frameY0 < 0)
+ pScr->frameY0 = 0;
+
+ pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
+ if (pScr->frameY1 >= pScr->virtualY) {
+ pScr->frameY0 = pScr->virtualY - mode->VDisplay;
+ pScr->frameY1 = pScr->virtualY - 1;
}
- else /* switch failed, so go back to old mode */
- pScr->modes = zoom > 0 ? pScr->modes->prev : pScr->modes->next;
}
- (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0);
+ if (pScr->AdjustFrame)
+ (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+
+ if (pScreen == pCursorScreen)
+ xf86WarpCursor(pScreen, px, py);
+
+ return Switched;
}
+
+/*
+ * xf86ZoomViewport --
+ * Reinitialize the visual part of the screen for another mode.
+ */
+void
+xf86ZoomViewport(ScreenPtr pScreen, int zoom)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
+
+ if (pScr->zoomLocked || !(mode = pScr->currentMode))
+ return;
+
+ do {
+ if (zoom > 0)
+ mode = mode->next;
+ else
+ mode = mode->prev;
+ } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
+
+ (void)xf86SwitchMode(pScreen, mode);
+}
+
+
+static xf86EdgePtr
+FindEdge(xf86EdgePtr edge, int val)
+{
+ while(edge && (edge->end <= val))
+ edge = edge->next;
+ if(edge && (edge->start <= val))
+ return edge;
+
+ return NULL;
+}
/*
* xf86CursorOffScreen --
* Check whether it is necessary to switch to another screen
*/
-/* ARGSUSED */
static Bool
-xf86CursorOffScreen (pScreen, x, y)
- ScreenPtr *pScreen;
- int *x, *y;
+xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
{
- int i;
-
- if ((screenInfo.numScreens > 1) && ((*x < 0) || ((*pScreen)->width <= *x))) {
- i = (*pScreen)->myNum;
- if (*x < 0) {
- i = (i ? i : screenInfo.numScreens) -1;
- *pScreen = screenInfo.screens[i];
- *x += (*pScreen)->width;
+ xf86EdgePtr edge;
+ int tmp;
+
+ if(screenInfo.numScreens == 1)
+ return FALSE;
+
+ if(*x < 0) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*x >= (*pScreen)->width) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = (*pScreen)->width - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- else {
- *x -= (*pScreen)->width;
- i = (i+1) % screenInfo.numScreens;
- *pScreen = screenInfo.screens[i];
+
+ if(*y < 0) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- return(TRUE);
- }
- return(FALSE);
+
+ if(*y >= (*pScreen)->height) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = (*pScreen)->height - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ (*pScreen) = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+
+#if 0
+ /* This presents problems for overlapping screens when
+ HardEdges is used. Have to think about the logic more */
+ if((*x < 0) || (*x >= (*pScreen)->width) ||
+ (*y < 0) || (*y >= (*pScreen)->height)) {
+ /* We may have crossed more than one screen */
+ xf86CursorOffScreen(pScreen, x, y);
+ }
+#endif
+
+ return TRUE;
}
@@ -297,30 +380,373 @@ xf86CursorOffScreen (pScreen, x, y)
* Switch to another screen
*/
+/* NEED TO CHECK THIS */
/* ARGSUSED */
static void
-xf86CrossScreen (pScreen, entering)
- ScreenPtr pScreen;
- Bool entering;
+xf86CrossScreen (ScreenPtr pScreen, Bool entering)
{
+#if 0
if (xf86Info.sharedMonitor)
(XF86SCRNINFO(pScreen)->EnterLeaveMonitor)(entering);
(XF86SCRNINFO(pScreen)->EnterLeaveCursor)(entering);
+#endif
}
/*
- * xf86WrapCursor --
- * Wrap possible to another screen
+ * xf86WarpCursor --
+ * Warp possible to another screen
*/
/* ARGSUSED */
static void
-xf86WrapCursor (pScreen, x, y)
- ScreenPtr pScreen;
- int x,y;
+xf86WarpCursor (ScreenPtr pScreen, int x, int y)
{
+ int sigstate;
+ sigstate = xf86BlockSIGIO ();
miPointerWarpCursor(pScreen,x,y);
xf86Info.currentScreen = pScreen;
+ xf86UnblockSIGIO (sigstate);
+}
+
+
+void *
+xf86GetPointerScreenFuncs(void)
+{
+ return (void *)&xf86PointerScreenFuncs;
+}
+
+
+static xf86EdgePtr
+AddEdge(
+ xf86EdgePtr edge,
+ short min,
+ short max,
+ short dx,
+ short dy,
+ short screen
+){
+ xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
+
+ while(1) {
+ while(pEdge && (min >= pEdge->end)) {
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+ }
+
+ if(!pEdge) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->end = max;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = NULL;
+
+ if(pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ break;
+ } else if (min < pEdge->start) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = pEdge;
+
+ if(pPrev) pPrev->next = pNew;
+ else edge = pNew;
+
+ if(max <= pEdge->start) {
+ pNew->end = max;
+ break;
+ } else {
+ pNew->end = pEdge->start;
+ min = pEdge->end;
+ }
+ } else
+ min = pEdge->end;
+
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+
+ if(max <= min) break;
+ }
+
+ return edge;
+}
+
+static void
+FillOutEdge(xf86EdgePtr pEdge, int limit)
+{
+ xf86EdgePtr pNext;
+ int diff;
+
+ if(pEdge->start > 0) pEdge->start = 0;
+
+ while((pNext = pEdge->next)) {
+ diff = pNext->start - pEdge->end;
+ if(diff > 0) {
+ pEdge->end += diff >> 1;
+ pNext->start -= diff - (diff >> 1);
+ }
+ pEdge = pNext;
+ }
+
+ if(pEdge->end < limit)
+ pEdge->end = limit;
+}
+
+/*
+ * xf86InitOrigins() can deal with a maximum of 32 screens
+ * on 32 bit architectures, 64 on 64 bit architectures.
+ */
+
+void
+xf86InitOrigins(void)
+{
+ unsigned long screensLeft, prevScreensLeft, mask;
+ screenLayoutPtr screen;
+ ScreenPtr pScreen;
+ int x1, x2, y1, y2, left, right, top, bottom;
+ int i, j, ref, minX, minY, min, max;
+ xf86ScreenLayoutPtr pLayout;
+ Bool OldStyleConfig = FALSE;
+
+ /* need to have this set up with a config file option */
+ HardEdges = FALSE;
+
+ bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+
+ screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
+
+ while(1) {
+ for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
+ if(!(mask & 1L)) continue;
+
+ screen = &xf86ConfigLayout.screens[i];
+
+ switch(screen->where) {
+ case PosObsolete:
+ OldStyleConfig = TRUE;
+ pLayout = &xf86ScreenLayout[i];
+ /* force edge lists */
+ if(screen->left) {
+ ref = screen->left->screennum;
+ pLayout->left = AddEdge(pLayout->left,
+ 0, xf86Screens[i]->pScreen->height,
+ xf86Screens[ref]->pScreen->width, 0, ref);
+ }
+ if(screen->right) {
+ ref = screen->right->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->right = AddEdge(pLayout->right,
+ 0, pScreen->height, -pScreen->width, 0, ref);
+ }
+ if(screen->top) {
+ ref = screen->top->screennum;
+ pLayout->up = AddEdge(pLayout->up,
+ 0, xf86Screens[i]->pScreen->width,
+ 0, xf86Screens[ref]->pScreen->height, ref);
+ }
+ if(screen->bottom) {
+ ref = screen->bottom->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->down = AddEdge(pLayout->down,
+ 0, pScreen->width, 0, -pScreen->height, ref);
+ }
+ /* we could also try to place it based on those
+ relative locations if we wanted to */
+ screen->x = screen->y = 0;
+ /* FALLTHROUGH */
+ case PosAbsolute:
+ dixScreenOrigins[i].x = screen->x;
+ dixScreenOrigins[i].y = screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRelative:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRightOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x + pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosLeftOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x - pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosBelow:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y + pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosAbove:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y - pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ default:
+ ErrorF("Illegal placement keyword in Layout!\n");
+ break;
+ }
+
+ }
+
+ if(!screensLeft) break;
+
+ if(screensLeft == prevScreensLeft) {
+ /* All the remaining screens are referencing each other.
+ Assign a value to one of them and go through again */
+ i = 0;
+ while(!((1 << i) & screensLeft)){ i++; }
+
+ ref = xf86ConfigLayout.screens[i].refscreen->screennum;
+ dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ screensLeft &= ~(1 << ref);
+ }
+
+ prevScreensLeft = screensLeft;
+ }
+
+ /* justify the topmost and leftmost to (0,0) */
+ minX = dixScreenOrigins[0].x;
+ minY = dixScreenOrigins[0].y;
+
+ for(i = 1; i < xf86NumScreens; i++) {
+ if(dixScreenOrigins[i].x < minX)
+ minX = dixScreenOrigins[i].x;
+ if(dixScreenOrigins[i].y < minY)
+ minY = dixScreenOrigins[i].y;
+ }
+
+ if (minX || minY) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ dixScreenOrigins[i].x -= minX;
+ dixScreenOrigins[i].y -= minY;
+ }
+ }
+
+
+ /* Create the edge lists */
+
+ if(!OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+
+ pScreen = xf86Screens[i]->pScreen;
+
+ left = dixScreenOrigins[i].x;
+ right = left + pScreen->width;
+ top = dixScreenOrigins[i].y;
+ bottom = top + pScreen->height;
+
+ for(j = 0; j < xf86NumScreens; j++) {
+ if(i == j) continue;
+
+ x1 = dixScreenOrigins[j].x;
+ x2 = x1 + xf86Screens[j]->pScreen->width;
+ y1 = dixScreenOrigins[j].y;
+ y2 = y1 + xf86Screens[j]->pScreen->height;
+
+ if((bottom > y1) && (top < y2)) {
+ min = y1 - top;
+ if(min < 0) min = 0;
+ max = pScreen->height - (bottom - y2);
+ if(max > pScreen->height) max = pScreen->height;
+
+ if(((left - 1) >= x1) && ((left - 1) < x2))
+ pLayout->left = AddEdge(pLayout->left, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((right >= x1) && (right < x2))
+ pLayout->right = AddEdge(pLayout->right, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+
+
+ if((left < x2) && (right > x1)) {
+ min = x1 - left;
+ if(min < 0) min = 0;
+ max = pScreen->width - (right - x2);
+ if(max > pScreen->width) max = pScreen->width;
+
+ if(((top - 1) >= y1) && ((top - 1) < y2))
+ pLayout->up = AddEdge(pLayout->up, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((bottom >= y1) && (bottom < y2))
+ pLayout->down = AddEdge(pLayout->down, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+ }
+ }
+ }
+
+ if(!HardEdges && !OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+ pScreen = xf86Screens[i]->pScreen;
+ if(pLayout->left)
+ FillOutEdge(pLayout->left, pScreen->height);
+ if(pLayout->right)
+ FillOutEdge(pLayout->right, pScreen->height);
+ if(pLayout->up)
+ FillOutEdge(pLayout->up, pScreen->width);
+ if(pLayout->down)
+ FillOutEdge(pLayout->down, pScreen->width);
+ }
+ }
}
+
+void
+xf86ReconfigureLayout(void)
+{
+ int i;
+
+ for (i = 0; i < MAXSCREENS; i++) {
+ xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
+ /* we don't have to zero these, xf86InitOrigins() takes care of that */
+ if (sl->left) xfree(sl->left);
+ if (sl->right) xfree(sl->right);
+ if (sl->up) xfree(sl->up);
+ if (sl->down) xfree(sl->down);
+ }
+
+ xf86InitOrigins();
+}
+
+
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index aa0983111..4d0efbcb9 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.42.2.4 1998/02/07 09:23:28 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.146 2003/02/20 04:20:52 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,48 +21,42 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86Events.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */
+/* $XConsortium: xf86Events.c /main/46 1996/10/25 11:36:30 kaleb $ */
/* [JCH-96/01/21] Extended std reverse map to four buttons. */
-#define NEED_EVENTS
#include "X.h"
+#include "Xpoll.h"
#include "Xproto.h"
#include "misc.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
#include "compiler.h"
-#include "Xpoll.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
#include "atKeynames.h"
#ifdef XFreeXDGA
-#include "XIproto.h"
-#include "extnsionst.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-
-#include "exevents.h"
-
-#define _XF86DGA_SERVER_
-#include "extensions/xf86dgastr.h"
+#include "dgaproc.h"
#endif
#ifdef XINPUT
#include "XI.h"
#include "XIproto.h"
-#include "xf86Xinput.h"
+#else
+#include "inputstr.h"
#endif
+#include "xf86Xinput.h"
+#include "mi.h"
#include "mipointer.h"
-#include "opaque.h"
-#ifdef DPMSExtension
-#include "extensions/dpms.h"
+
+#ifdef XF86BIGFONT
+#define _XF86BIGFONT_SERVER_
+#include "xf86bigfont.h"
#endif
#ifdef XKB
@@ -72,6 +66,18 @@ extern Bool noXkbExtension;
#define XE_POINTER 1
#define XE_KEYBOARD 2
+#ifdef XINPUT
+#define __EqEnqueue(ev) xf86eqEnqueue(ev)
+#else
+#define __EqEnqueue(ev) mieqEnqueue(ev)
+#endif
+
+#define EqEnqueue(ev) { \
+ int __sigstate = xf86BlockSIGIO (); \
+ __EqEnqueue (ev); \
+ xf86UnblockSIGIO(__sigstate); \
+}
+
#ifdef XTESTEXT1
#define XTestSERVER_SIDE
@@ -81,62 +87,30 @@ extern short xtest_mousey;
extern int on_steal_input;
extern Bool XTestStealKeyData();
extern void XTestStealMotionData();
-
-#ifdef XINPUT
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- if (!on_steal_input || \
- XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
- xtest_mousex, xtest_mousey)) \
- xf86eqEnqueue((ev))
-#else
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
if (!on_steal_input || \
XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
xtest_mousex, xtest_mousey)) \
- mieqEnqueue((ev))
-#endif
-
-#define MOVEPOINTER(dx, dy, time) \
- if (on_steal_input) \
- XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \
- miPointerDeltaCursor (dx, dy, time)
-
+ EqEnqueue((ev))
#else /* ! XTESTEXT1 */
-#ifdef XINPUT
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
- xf86eqEnqueue((ev))
-#else
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- mieqEnqueue((ev))
-#endif
-#define MOVEPOINTER(dx, dy, time) \
- miPointerDeltaCursor (dx, dy, time)
+ EqEnqueue((ev))
#endif
-Bool xf86VTSema = TRUE;
-
-#ifdef XINPUT
-extern InputInfo inputInfo;
-#endif /* XINPUT */
-
/*
- * The first of many hack's to get VT switching to work under
+ * The first of many hacks to get VT switching to work under
* Solaris 2.1 for x86. The basic problem is that Solaris is supposed
* to be SVR4. It is for the most part, except where the video interface
* is concerned. These hacks work around those problems.
- * See the comments for Linux, and SCO.
+ * See the comments for Linux, and SCO.
*
- * This is a toggleling variable:
+ * This is a toggling variable:
* FALSE = No VT switching keys have been pressed last time around
* TRUE = Possible VT switch Pending
* (DWH - 12/2/93)
@@ -145,167 +119,40 @@ extern InputInfo inputInfo;
*/
#ifdef USE_VT_SYSREQ
-static Bool VTSysreqToggle = FALSE;
+Bool VTSysreqToggle = FALSE;
#endif /* !USE_VT_SYSREQ */
-static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for *BSD */
+Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
extern fd_set EnabledDevices;
-#if defined(CODRV_SUPPORT)
-extern unsigned char xf86CodrvMap[];
-#endif
-
-#if defined(XQUEUE) && !defined(XQUEUE_ASYNC)
-extern void xf86XqueRequest(
-#if NeedFunctionPrototypes
- void
-#endif
- );
+#if defined(XQUEUE)
+extern void xf86XqueRequest(void);
#endif
+extern void (*xf86OSPMClose)(void);
-#ifdef DPMSExtension
-extern BOOL DPMSEnabled;
-extern void DPMSSet(CARD16);
-#endif
-
-static void xf86VTSwitch(
-#if NeedFunctionPrototypes
- void
-#endif
- );
-#ifdef XFreeXDGA
-static void XF86DirectVideoMoveMouse(
-#if NeedFunctionPrototypes
- int x,
- int y,
- CARD32 mtime
-#endif
- );
-static void XF86DirectVideoKeyEvent(
-#if NeedFunctionPrototypes
- xEvent *xE,
- int keycode,
- int etype
-#endif
- );
-#endif
-static CARD32 buttonTimer(
-#if NeedFunctionPrototypes
- OsTimerPtr timer,
- CARD32 now,
- pointer arg
-#endif
- );
+static void xf86VTSwitch(void);
/*
- * Lets create a simple finite-state machine:
- *
- * state[?][0]: action1
- * state[?][1]: action2
- * state[?][2]: next state
- *
- * action > 0: ButtonPress
- * action = 0: nothing
- * action < 0: ButtonRelease
- *
- * Why this stuff ??? Normally you cannot press both mousebuttons together, so
- * the mouse reports both pressed at the same time ...
+ * Allow arbitrary drivers or other XFree86 code to register with our main
+ * Wakeup handler.
*/
+typedef struct x_IHRec {
+ int fd;
+ InputHandlerProc ihproc;
+ pointer data;
+ Bool enabled;
+ struct x_IHRec * next;
+} IHRec, *IHPtr;
-static char stateTab[48][3] = {
-
-/* nothing pressed */
- { 0, 0, 0 },
- { 0, 0, 8 }, /* 1 right -> delayed right */
- { 0, 0, 0 }, /* 2 nothing */
- { 0, 0, 8 }, /* 3 right -> delayed right */
- { 0, 0, 16 }, /* 4 left -> delayed left */
- { 2, 0, 24 }, /* 5 left & right (middle press) -> middle pressed */
- { 0, 0, 16 }, /* 6 left -> delayed left */
- { 2, 0, 24 }, /* 7 left & right (middle press) -> middle pressed */
-
-/* delayed right */
- { 1, -1, 0 }, /* 8 nothing (right event) -> init */
- { 1, 0, 32 }, /* 9 right (right press) -> right pressed */
- { 1, -1, 0 }, /* 10 nothing (right event) -> init */
- { 1, 0, 32 }, /* 11 right (right press) -> right pressed */
- { 1, -1, 16 }, /* 12 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 13 left & right (middle press) -> middle pressed */
- { 1, -1, 16 }, /* 14 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 15 left & right (middle press) -> middle pressed */
-
-/* delayed left */
- { 3, -3, 0 }, /* 16 nothing (left event) -> init */
- { 3, -3, 8 }, /* 17 right (left event) -> delayed right */
- { 3, -3, 0 }, /* 18 nothing (left event) -> init */
- { 3, -3, 8 }, /* 19 right (left event) -> delayed right */
- { 3, 0, 40 }, /* 20 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 21 left & right (middle press) -> pressed middle */
- { 3, 0, 40 }, /* 22 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 23 left & right (middle press) -> pressed middle */
-
-/* pressed middle */
- { -2, 0, 0 }, /* 24 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 25 right (middle release) -> init */
- { -2, 0, 0 }, /* 26 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 27 right (middle release) -> init */
- { -2, 0, 0 }, /* 28 left (middle release) -> init */
- { 0, 0, 24 }, /* 29 left & right -> pressed middle */
- { -2, 0, 0 }, /* 30 left (middle release) -> init */
- { 0, 0, 24 }, /* 31 left & right -> pressed middle */
-
-/* pressed right */
- { -1, 0, 0 }, /* 32 nothing (right release) -> init */
- { 0, 0, 32 }, /* 33 right -> pressed right */
- { -1, 0, 0 }, /* 34 nothing (right release) -> init */
- { 0, 0, 32 }, /* 35 right -> pressed right */
- { -1, 0, 16 }, /* 36 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 37 left & right (r rel, m prs) -> middle pressed */
- { -1, 0, 16 }, /* 38 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 39 left & right (r rel, m prs) -> middle pressed */
-
-/* pressed left */
- { -3, 0, 0 }, /* 40 nothing (left release) -> init */
- { -3, 0, 8 }, /* 41 right (left release) -> delayed right */
- { -3, 0, 0 }, /* 42 nothing (left release) -> init */
- { -3, 0, 8 }, /* 43 right (left release) -> delayed right */
- { 0, 0, 40 }, /* 44 left -> left pressed */
- { -3, 2, 24 }, /* 45 left & right (l rel, mprs) -> middle pressed */
- { 0, 0, 40 }, /* 46 left -> left pressed */
- { -3, 2, 24 }, /* 47 left & right (l rel, mprs) -> middle pressed */
-};
-
-
-/*
- * Table to allow quick reversal of natural button mapping to correct mapping
- */
-
-/*
- * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
- * with a fourth button activated by tapping the PAD.
- * The 2nd line corresponds to 4th button on; the drv sends
- * the buttons in the following map (MSBit described first) :
- * 0 | 4th | 1st | 2nd | 3rd
- * And we remap them (MSBit described first) :
- * 0 | 4th | 3rd | 2nd | 1st
- */
-static char reverseMap[32] = { 0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15,
- 16, 20, 18, 22, 17, 21, 19, 23,
- 24, 28, 26, 30, 25, 29, 27, 31};
-
-
-static char hitachMap[16] = { 0, 2, 1, 3,
- 8, 10, 9, 11,
- 4, 6, 5, 7,
- 12, 14, 13, 15 };
-
-#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
+static IHPtr InputHandlers = NULL;
/*
* TimeSinceLastInputEvent --
- * Function used for screensaver purposes by the os module. Retruns the
+ * Function used for screensaver purposes by the os module. Returns the
* time in milliseconds since there last was any input.
*/
@@ -348,20 +195,6 @@ ProcessInputEvents ()
static int generation = 0;
#endif
-#ifdef AMOEBA
-#define MAXEVENTS 32
-#define BUTTON_PRESS 0x1000
-#define MAP_BUTTON(ev,but) (((ev) == EV_ButtonPress) ? \
- ((but) | BUTTON_PRESS) : ((but) & ~BUTTON_PRESS))
-#define KEY_RELEASE 0x80
-#define MAP_KEY(ev, key) (((ev) == EV_KeyReleaseEvent) ? \
- ((key) | KEY_RELEASE) : ((key) & ~KEY_RELEASE))
-
- register IOPEvent *e, *elast;
- IOPEvent events[MAXEVENTS];
- int dx, dy, nevents;
-#endif
-
/*
* With INHERIT_LOCK_STATE defined, the initial state of CapsLock, NumLock
* and ScrollLock will be set to match that of the VT the server is
@@ -398,37 +231,6 @@ ProcessInputEvents ()
}
#endif
-#ifdef AMOEBA
- /*
- * Get all events from the IOP server
- */
- while ((nevents = AmoebaGetEvents(events, MAXEVENTS)) > 0) {
- for (e = &events[0], elast = &events[nevents]; e < elast; e++) {
- xf86Info.lastEventTime = e->time;
- switch (e->type) {
- case EV_PointerDelta:
- if (e->x != 0 || e->y != 0) {
- xf86PostMseEvent(&xf86Info.pMouse, 0, e->x, e->y);
- }
- break;
- case EV_ButtonPress:
- case EV_ButtonRelease:
- xf86PostMseEvent(&xf86Info.pMouse, MAP_BUTTON(e->type, e->keyorbut), 0, 0);
- break;
- case EV_KeyPressEvent:
- case EV_KeyReleaseEvent:
- xf86PostKbdEvent(MAP_KEY(e->type, e->keyorbut));
- break;
- default:
- /* this shouldn't happen */
- ErrorF("stray event %d (%d,%d) %x\n",
- e->type, e->x, e->y, e->keyorbut);
- break;
- }
- }
- }
-#endif
-
xf86Info.inputPending = FALSE;
#ifdef XINPUT
@@ -442,7 +244,111 @@ ProcessInputEvents ()
xf86SetViewport(xf86Info.currentScreen, x, y);
}
+void
+xf86GrabServerCallback(CallbackListPtr *callbacks, pointer data, pointer args)
+{
+ ServerGrabInfoRec *grab = (ServerGrabInfoRec*)args;
+
+ xf86Info.grabInfo.server.client = grab->client;
+ xf86Info.grabInfo.server.grabstate = grab->grabstate;
+}
+/*
+ * Handle keyboard events that cause some kind of "action"
+ * (i.e., server termination, video mode changes, VT switches, etc.)
+ */
+void
+xf86ProcessActionEvent(ActionEvent action, void *arg)
+{
+#ifdef DEBUG
+ ErrorF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
+#endif
+ switch (action) {
+ case ACTION_TERMINATE:
+ if (!xf86Info.dontZap) {
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+ GiveUp(0);
+ }
+ break;
+ case ACTION_NEXT_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ break;
+ case ACTION_PREV_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ break;
+ case ACTION_DISABLEGRAB:
+ if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowDeactivate) {
+ if (inputInfo.pointer && inputInfo.pointer->grab != NULL &&
+ inputInfo.pointer->DeactivateGrab)
+ inputInfo.pointer->DeactivateGrab(inputInfo.pointer);
+ if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL &&
+ inputInfo.keyboard->DeactivateGrab)
+ inputInfo.keyboard->DeactivateGrab(inputInfo.keyboard);
+ }
+ break;
+ case ACTION_CLOSECLIENT:
+ if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowClosedown) {
+ ClientPtr pointer, keyboard, server;
+
+ pointer = keyboard = server = NULL;
+ if (inputInfo.pointer && inputInfo.pointer->grab != NULL)
+ pointer = clients[CLIENT_ID(inputInfo.pointer->grab->resource)];
+ if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL) {
+ keyboard = clients[CLIENT_ID(inputInfo.keyboard->grab->resource)];
+ if (keyboard == pointer)
+ keyboard = NULL;
+ }
+ if ((xf86Info.grabInfo.server.grabstate == SERVER_GRABBED) &&
+ (((server = xf86Info.grabInfo.server.client) == pointer) ||
+ (server == keyboard)))
+ server = NULL;
+
+ if (pointer)
+ CloseDownClient(pointer);
+ if (keyboard)
+ CloseDownClient(keyboard);
+ if (server)
+ CloseDownClient(server);
+ }
+ break;
+#if !defined(__SOL8__) && (!defined(sun) || defined(i386))
+ case ACTION_SWITCHSCREEN:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
+ int vtno = *((int *) arg);
+#if defined(QNX4)
+ xf86Info.vtRequestsPending = vtno;
+#else
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0)
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+#endif
+ }
+ break;
+ case ACTION_SWITCHSCREEN_NEXT:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0)
+#if defined(SCO) || (defined(sun) && defined (i386) && defined (SVR4))
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0)
+#else
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) < 0)
+#endif
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ }
+ break;
+ case ACTION_SWITCHSCREEN_PREV:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1) < 0)
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ }
+ break;
+#endif
+ default:
+ break;
+ }
+}
/*
* xf86PostKbdEvent --
@@ -454,17 +360,18 @@ ProcessInputEvents ()
* ifdefs further (hv).
*/
-#ifdef ASSUME_CUSTOM_KEYCODES
+#ifdef __linux__
extern u_char SpecialServerMap[];
-#endif /* ASSUME_CUSTOM_KEYCODES */
+#endif
-#if !defined(__EMX__)
+#if !defined(__UNIXOS2__) && \
+ !defined(__SOL8__) && \
+ (!defined(sun) || defined(i386))
void
-xf86PostKbdEvent(key)
- unsigned key;
+xf86PostKbdEvent(unsigned key)
{
int scanCode = (key & 0x7f);
- int specialkey;
+ int specialkey = 0;
Bool down = (key & 0x80 ? FALSE : TRUE);
KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
Bool updateLeds = FALSE;
@@ -474,16 +381,17 @@ xf86PostKbdEvent(key)
KeySym *keysym;
int keycode;
static int lockkeys = 0;
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
static Bool first_time = TRUE;
#endif
-
-#if defined(CODRV_SUPPORT)
- if (xf86Info.consType == CODRV011 || xf86Info.consType == CODRV01X)
- scanCode = xf86CodrvMap[scanCode];
+#if defined(__sparc__)
+ static int kbdSun = -1;
#endif
+ /* Disable any keyboard processing while in suspend */
+ if (xf86inSuspend)
+ return;
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
if (first_time)
{
first_time = FALSE;
@@ -492,102 +400,78 @@ xf86PostKbdEvent(key)
}
#endif
-#if defined (i386) && defined (SVR4) && !defined (PC98)
+#if defined (__sparc__)
+ if (kbdSun == -1) {
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
+ kbdSun = 1;
+ else
+ kbdSun = 0;
+ }
+ if (kbdSun)
+ goto special;
+#endif /* __sparc__ */
+
+#if defined (i386) && defined (SVR4)
/*
* PANIX returns DICOP standards based keycodes in using 106jp
* keyboard. We need to remap some keys.
*/
-#define KEY_P_UP 0x5A
-#define KEY_P_PGUP 0x5B
-#define KEY_P_LEFT 0x5C
-#define KEY_P_BKSL 0x73
-#define KEY_P_YEN 0x7D
-#define KEY_P_NFER 0x7B
-#define KEY_P_XFER 0x79
-
if(xf86Info.panix106 == TRUE){
switch (scanCode) {
- /* case 0x78: scanCode = KEY_P_UP; break; not needed*/
- case 0x56: scanCode = KEY_P_BKSL; break; /* Backslash */
- case 0x5A: scanCode = KEY_P_NFER; break; /* No Kanji Transfer*/
- case 0x5B: scanCode = KEY_P_XFER; break; /* Kanji Tranfer */
- case 0x5C: scanCode = KEY_P_YEN; break; /* Yen curs pgup */
- case 0x6B: scanCode = KEY_P_LEFT; break; /* Cur Left */
- case 0x6F: scanCode = KEY_P_PGUP; break; /* Cur PageUp */
+ case 0x56: scanCode = KEY_BSlash2; break; /* Backslash */
+ case 0x5A: scanCode = KEY_NFER; break; /* No Kanji Transfer*/
+ case 0x5B: scanCode = KEY_XFER; break; /* Kanji Tranfer */
+ case 0x5C: scanCode = KEY_Yen; break; /* Yen curs pgup */
+ case 0x6B: scanCode = KEY_Left; break; /* Cur Left */
+ case 0x6F: scanCode = KEY_PgUp; break; /* Cur PageUp */
case 0x72: scanCode = KEY_AltLang; break; /* AltLang(right) */
case 0x73: scanCode = KEY_RCtrl; break; /* not needed */
}
}
#endif /* i386 && SVR4 */
-#ifndef ASSUME_CUSTOM_KEYCODES
+#ifdef __linux__
+ if (xf86Info.kbdCustomKeycodes) {
+ specialkey = SpecialServerMap[scanCode];
+ goto customkeycodes;
+ }
+#endif
+
/*
* First do some special scancode remapping ...
*/
if (xf86Info.scanPrefix == 0) {
switch (scanCode) {
-
-#ifndef PC98
case KEY_Prefix0:
case KEY_Prefix1:
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
- || xf86Info.consType == PCVT) {
+ || xf86Info.consType == PCVT
+#ifdef WSCONS_SUPPORT
+ || (xf86Info.consType == WSCONS && xf86Info.kbdEvents != xf86WSKbdEvents)
+#endif
+ ) {
#endif
xf86Info.scanPrefix = scanCode; /* special prefixes */
return;
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
}
break;
#endif
-#endif /* not PC98 */
- }
-#ifndef PC98
- if (xf86Info.serverNumLock) {
- if ((!xf86Info.numLock && ModifierDown(ShiftMask)) ||
- (xf86Info.numLock && !ModifierDown(ShiftMask))) {
- /*
- * Hardwired numlock handling ... (Some applications break if they have
- * these keys double defined, like twm)
- */
- switch (scanCode) {
- case KEY_KP_7: scanCode = KEY_SN_KP_7; break; /* curs 7 */
- case KEY_KP_8: scanCode = KEY_SN_KP_8; break; /* curs 8 */
- case KEY_KP_9: scanCode = KEY_SN_KP_9; break; /* curs 9 */
- case KEY_KP_4: scanCode = KEY_SN_KP_4; break; /* curs 4 */
- case KEY_KP_5: scanCode = KEY_SN_KP_5; break; /* curs 5 */
- case KEY_KP_6: scanCode = KEY_SN_KP_6; break; /* curs 6 */
- case KEY_KP_1: scanCode = KEY_SN_KP_1; break; /* curs 1 */
- case KEY_KP_2: scanCode = KEY_SN_KP_2; break; /* curs 2 */
- case KEY_KP_3: scanCode = KEY_SN_KP_3; break; /* curs 3 */
- case KEY_KP_0: scanCode = KEY_SN_KP_0; break; /* curs 0 */
- case KEY_KP_Decimal: scanCode = KEY_SN_KP_Dec; break; /* curs decimal */
- }
- } else {
- switch (scanCode) {
- case KEY_KP_7: scanCode = KEY_SN_KP_Home; break; /* curs home */
- case KEY_KP_8: scanCode = KEY_SN_KP_Up ; break; /* curs up */
- case KEY_KP_9: scanCode = KEY_SN_KP_Prior; break; /* curs pgup */
- case KEY_KP_4: scanCode = KEY_SN_KP_Left; break; /* curs left */
- case KEY_KP_5: scanCode = KEY_SN_KP_Begin; break; /* curs begin */
- case KEY_KP_6: scanCode = KEY_SN_KP_Right; break; /* curs right */
- case KEY_KP_1: scanCode = KEY_SN_KP_End; break; /* curs end */
- case KEY_KP_2: scanCode = KEY_SN_KP_Down; break; /* curs down */
- case KEY_KP_3: scanCode = KEY_SN_KP_Next; break; /* curs pgdn */
- case KEY_KP_0: scanCode = KEY_SN_KP_Ins; break; /* curs ins */
- case KEY_KP_Decimal: scanCode = KEY_SN_KP_Del; break; /* curs del */
- }
- }
}
-#endif /* not PC98 */
}
-#ifndef PC98
else if (
#ifdef CSRG_BASED
(xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
- || xf86Info.consType == PCVT) &&
+ || xf86Info.consType == PCVT
+#ifdef WSCONS_SUPPORT
+ || (xf86Info.consType == WSCONS && xf86Info.kbdEvents !=
+ xf86WSKbdEvents)
+#endif
+ ) &&
#endif
(xf86Info.scanPrefix == KEY_Prefix0)) {
xf86Info.scanPrefix = 0;
@@ -622,8 +506,18 @@ xf86PostKbdEvent(key)
/*
* Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
*/
+ case 0x2A:
+ case 0x36:
+ return;
default:
- return; /* skip illegal */
+ xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
+ scanCode);
+ /*
+ * "Internet" keyboards are generating lots of new codes. Let them
+ * pass. There is little consistency between them, so don't bother
+ * with symbolic names at this level.
+ */
+ scanCode += 0x78;
}
}
@@ -639,55 +533,140 @@ xf86PostKbdEvent(key)
if (scanCode != KEY_NumLock) return;
scanCode = KEY_Pause; /* pause */
}
-#endif /* not PC98 */
-#endif /* !ASSUME_CUSTOM_KEYCODES */
/*
* and now get some special keysequences
*/
-#ifdef ASSUME_CUSTOM_KEYCODES
- specialkey = SpecialServerMap[scanCode];
-#else /* ASSUME_CUSTOM_KEYCODES */
specialkey = scanCode;
-#endif /* ASSUME_CUSTOM_KEYCODES */
- if ((ModifierDown(ControlMask | AltMask)) ||
- (ModifierDown(ControlMask | AltLangMask)))
+#ifdef __linux__
+customkeycodes:
+#endif
+#if defined(i386) || defined(__i386__)
+ if (xf86IsPc98()) {
+ switch (scanCode) {
+ case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */
+ case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus */
+ case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus */
+
+ /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+
+ case 0x62: specialkey = 0x3b; break; /* KEY_F1 */
+ case 0x63: specialkey = 0x3c; break; /* KEY_F2 */
+ case 0x64: specialkey = 0x3d; break; /* KEY_F3 */
+ case 0x65: specialkey = 0x3e; break; /* KEY_F4 */
+ case 0x66: specialkey = 0x3f; break; /* KEY_F5 */
+ case 0x67: specialkey = 0x40; break; /* KEY_F6 */
+ case 0x68: specialkey = 0x41; break; /* KEY_F7 */
+ case 0x69: specialkey = 0x42; break; /* KEY_F8 */
+ case 0x6a: specialkey = 0x43; break; /* KEY_F9 */
+ case 0x6b: specialkey = 0x44; break; /* KEY_F10 */
+ /* case 0x73: specialkey = 0x38; break; KEY_Alt */
+ /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl */
+ default: specialkey = 0x00; break;
+ }
+ }
+#endif
+#if defined (__sparc__)
+special:
+ if (kbdSun) {
+ switch (scanCode) {
+ case 0x2b: specialkey = KEY_BackSpace; break;
+ case 0x47: specialkey = KEY_KP_Minus; break;
+ case 0x7d: specialkey = KEY_KP_Plus; break;
+
+ /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+
+ case 0x05: specialkey = KEY_F1; break;
+ case 0x06: specialkey = KEY_F2; break;
+ case 0x08: specialkey = KEY_F3; break;
+ case 0x0a: specialkey = KEY_F4; break;
+ case 0x0c: specialkey = KEY_F5; break;
+ case 0x0e: specialkey = KEY_F6; break;
+ case 0x10: specialkey = KEY_F7; break;
+ case 0x11: specialkey = KEY_F8; break;
+ case 0x12: specialkey = KEY_F9; break;
+ case 0x07: specialkey = KEY_F10; break;
+ case 0x09: specialkey = KEY_F11; break;
+ case 0x0b: specialkey = KEY_F12; break;
+ default: specialkey = 0; break;
+ }
+ /*
+ * XXX XXX XXX:
+ *
+ * I really don't know what's wrong here, but passing the real
+ * scanCode offsets by one from XKB's point of view.
+ *
+ * (ecd@skynet.be, 980405)
+ */
+ scanCode--;
+ }
+#endif /* defined (__sparc__) */
+
+#ifdef XKB
+ if ((xf86Info.ddxSpecialKeys == SKWhenNeeded &&
+ !xf86Info.ActionKeyBindingsSet) ||
+ noXkbExtension || xf86Info.ddxSpecialKeys == SKAlways) {
+#endif
+ if (!(ModifierDown(ShiftMask)) &&
+ ((ModifierDown(ControlMask | AltMask)) ||
+ (ModifierDown(ControlMask | AltLangMask))))
{
-
switch (specialkey) {
case KEY_BackSpace:
- if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
- if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics)
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
break;
-#endif
- GiveUp(0);
- }
+
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
break;
-
- /*
- * The idea here is to pass the scancode down to a list of
- * registered routines. There should be some standard conventions
- * for processing certain keys.
- */
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * Video mode switches
+ */
case KEY_KP_Minus: /* Keypad - */
- if (!xf86Info.dontZoom) {
- if (down) xf86ZoomViewport(xf86Info.currentScreen, -1);
- return;
- }
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
break;
case KEY_KP_Plus: /* Keypad + */
- if (!xf86Info.dontZoom) {
- if (down) xf86ZoomViewport(xf86Info.currentScreen, 1);
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+
+ /* Under QNX4, we set the vtPending flag for VT switching and
+ * let the VT switch function do the rest...
+ * This is a little different from the other OS'es.
+ */
+#if defined(QNX4)
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (down) {
+ int vtno = specialkey - KEY_1 + 1;
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
+ }
return;
}
break;
+#endif
-#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) || defined(SCO)
+#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT))) || defined(SCO)
/*
* Under Linux, the raw keycodes are consumed before the kernel
* does any processing on them, so we must emulate the vt switching
@@ -703,37 +682,23 @@ xf86PostKbdEvent(key)
case KEY_F8:
case KEY_F9:
case KEY_F10:
- if (VTSwitchEnabled && !xf86Info.vtSysreq
-#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)))
- && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
-#endif
- )
- {
- if (down)
-#ifdef SCO325
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F1);
-#else
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F1 + 1);
-#endif
- return;
- }
- break;
case KEY_F11:
case KEY_F12:
- if (VTSwitchEnabled && !xf86Info.vtSysreq
-#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)))
+ if ((VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
+#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)))
&& (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
#endif
- )
- {
- if (down)
+ ) {
+ int vtno = specialkey - KEY_F1 + 1;
+ if (specialkey == KEY_F11 || specialkey == KEY_F12)
+ vtno = specialkey - KEY_F11 + 11;
#ifdef SCO325
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F11 + 10);
-#else
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F11 + 11);
+ vtno--;
#endif
- return;
- }
+ if (down)
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
+ return;
+ }
break;
#endif /* linux || BSD with VTs */
@@ -753,7 +718,7 @@ xf86PostKbdEvent(key)
*/
#ifdef USE_VT_SYSREQ
- if (VTSwitchEnabled && xf86Info.vtSysreq)
+ if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
{
switch (specialkey)
{
@@ -765,7 +730,7 @@ xf86PostKbdEvent(key)
case KEY_H:
if (VTSysreqToggle && down)
{
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0);
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, NULL);
VTSysreqToggle = 0;
return;
}
@@ -780,8 +745,7 @@ xf86PostKbdEvent(key)
case KEY_N:
if (VTSysreqToggle && down)
{
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1 ) < 0)
- ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
VTSysreqToggle = FALSE;
return;
}
@@ -790,9 +754,7 @@ xf86PostKbdEvent(key)
case KEY_P:
if (VTSysreqToggle && down)
{
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1 ) < 0)
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0)
- ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
VTSysreqToggle = FALSE;
return;
}
@@ -809,21 +771,13 @@ xf86PostKbdEvent(key)
case KEY_F8:
case KEY_F9:
case KEY_F10:
- if (VTSysreqToggle && down)
- {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F1 + 1) < 0)
- ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
- VTSysreqToggle = FALSE;
- return;
- }
- break;
-
case KEY_F11:
case KEY_F12:
if (VTSysreqToggle && down)
- {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F11 + 11) < 0)
- ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ { int vtno = specialkey - KEY_F1 + 1;
+ if (specialkey == KEY_F11 || specialkey == KEY_F12)
+ vtno = specialkey - KEY_F11 + 11;
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
VTSysreqToggle = FALSE;
return;
}
@@ -831,17 +785,13 @@ xf86PostKbdEvent(key)
/* Ignore these keys -- ie don't let them cancel an alt-sysreq */
case KEY_Alt:
-#ifndef PC98
case KEY_AltLang:
-#endif /* not PC98 */
break;
-#ifndef PC98
case KEY_SysReqest:
if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask)))
VTSysreqToggle = TRUE;
break;
-#endif /* not PC98 */
default:
if (VTSysreqToggle)
@@ -870,14 +820,26 @@ xf86PostKbdEvent(key)
*/
if (specialkey == KEY_Print && ModifierDown(ControlMask)) {
if (down)
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0)
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0)
- ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
return;
}
#endif /* SCO */
+#ifdef XKB
+ }
+#endif
/*
+ * PC keyboards generate separate key codes for
+ * Alt+Print and Control+Pause but in the X keyboard model
+ * they need to get the same key code as the base key on the same
+ * physical keyboard key.
+ */
+ if (scanCode == KEY_SysReqest)
+ scanCode = KEY_Print;
+ else if (scanCode == KEY_Break)
+ scanCode = KEY_Pause;
+
+ /*
* Now map the scancodes to real X-keycodes ...
*/
keycode = scanCode + MIN_KEYCODE;
@@ -949,7 +911,6 @@ xf86PostKbdEvent(key)
* ignore releases, toggle on & off on presses.
* Don't deal with the Caps_Lock keysym directly, but check the lock modifier
*/
-#ifndef PC98
if (keyc->modifierMap[keycode] & LockMask ||
keysym[0] == XK_Scroll_Lock ||
keysym[1] == XF86XK_ModeLock ||
@@ -971,28 +932,29 @@ xf86PostKbdEvent(key)
if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag;
updateLeds = TRUE;
}
-#endif /* not PC98 */
-#ifndef ASSUME_CUSTOM_KEYCODES
- /*
- * normal, non-keypad keys
- */
- if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
-#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__)
+ if (!xf86Info.kbdCustomKeycodes) {
/*
- * magic ALT_L key on AT84 keyboards for multilingual support
+ * normal, non-keypad keys
*/
- if (xf86Info.kbdType == KB_84 &&
- ModifierDown(AltMask) &&
- keysym[2] != NoSymbol)
- {
- UsePrefix = TRUE;
- Direction = TRUE;
- }
-#endif /* !CSRG_BASED && !MACH386 && !MINIX && !__OSF__ */
+ if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
+#if !defined(CSRG_BASED) && \
+ !defined(__GNU__) && \
+ defined(KB_84)
+ /*
+ * magic ALT_L key on AT84 keyboards for multilingual support
+ */
+ if (xf86Info.kbdType == KB_84 &&
+ ModifierDown(AltMask) &&
+ keysym[2] != NoSymbol)
+ {
+ UsePrefix = TRUE;
+ Direction = TRUE;
+ }
+#endif /* !CSRG_BASED && ... */
+ }
}
-#endif /* !ASSUME_CUSTOM_KEYCODES */
- if (updateLeds) xf86KbdLeds();
+ if (updateLeds) xf86UpdateKbdLeds();
#ifdef XKB
}
#endif
@@ -1000,9 +962,14 @@ xf86PostKbdEvent(key)
/*
* check for an autorepeat-event
*/
- if ((down && KeyPressed(keycode)) &&
- (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
- return;
+ if (down && KeyPressed(keycode)) {
+ KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed;
+ if ((xf86Info.autoRepeat != AutoRepeatModeOn) ||
+ keyc->modifierMap[keycode] ||
+ (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) ))))
+ return;
+ }
+
xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
/*
@@ -1023,383 +990,220 @@ xf86PostKbdEvent(key)
}
else
{
-#ifdef XFreeXDGA
- if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectKeyb) {
- XF86DirectVideoKeyEvent(&kevent, keycode, (down ? KeyPress : KeyRelease));
- } else
-#endif
- {
- ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
-
- }
+ ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
}
}
-#endif /* !__EMX__ */
+#endif /* !__UNIXOS2__ */
+#define ModifierIsSet(k) ((modifiers & (k)) == (k))
-static CARD32
-buttonTimer(timer, now, arg)
- OsTimerPtr timer;
- CARD32 now;
- pointer arg;
+Bool
+xf86CommonSpecialKey(int key, Bool down, int modifiers)
{
- MouseDevPtr priv = MOUSE_DEV((DeviceIntPtr) arg);
+ if ((ModifierIsSet(ControlMask | AltMask)) ||
+ (ModifierIsSet(ControlMask | AltLangMask))) {
+ switch (key) {
+
+ case KEY_BackSpace:
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+ break;
- xf86PostMseEvent(((DeviceIntPtr) arg), priv->truebuttons, 0, 0);
- return(0);
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ break;
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * The idea here is to pass the scancode down to a list of
+ * registered routines. There should be some standard conventions
+ * for processing certain keys.
+ */
+ case KEY_KP_Minus: /* Keypad - */
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return TRUE;
+ break;
+
+ case KEY_KP_Plus: /* Keypad + */
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) return TRUE;
+ break;
+ }
+ }
+ return FALSE;
}
-
-/*
- * xf86PostMseEvent --
- * Translate the raw hardware MseEvent into an XEvent(s), and tell DIX
- * about it. Perform a 3Button emulation if required.
+/*
+ * xf86Wakeup --
+ * Os wakeup handler.
*/
+/* ARGSUSED */
void
-xf86PostMseEvent(device, buttons, dx, dy)
- DeviceIntPtr device;
- int buttons, dx, dy;
+xf86Wakeup(pointer blockData, int err, pointer pReadmask)
{
- static OsTimerPtr timer = NULL;
- MouseDevPtr private = MOUSE_DEV(device);
- int id, change;
- int truebuttons;
- xEvent mevent[2];
-#ifdef XINPUT
- deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) mevent;
- deviceValuator *xv = (deviceValuator *) (xev+1);
- int is_pointer; /* the mouse is the pointer ? */
-#endif
-
-#ifdef AMOEBA
- int pressed;
-
- pressed = ((buttons & BUTTON_PRESS) != 0);
- buttons &= ~BUTTON_PRESS;
-#endif
-
-#ifdef XINPUT
- is_pointer = xf86IsCorePointer(device);
-
- if (!is_pointer) {
- xev->time = xf86Info.lastEventTime = GetTimeInMillis();
- }
- else
-#endif
- xf86Info.lastEventTime = mevent->u.keyButtonPointer.time = GetTimeInMillis();
-
- truebuttons = buttons;
- if (private->mseType == P_MMHIT)
- buttons = reverseBits(hitachMap, buttons);
- else
- buttons = reverseBits(reverseMap, buttons);
-
- if (dx || dy) {
-
- /*
- * accelerate the baby now if sqrt(dx*dx + dy*dy) > threshold !
- * but do some simpler arithmetic here...
- */
- if ((abs(dx) + abs(dy)) >= private->threshold) {
- dx = (dx * private->num) / private->den;
- dy = (dy * private->num)/ private->den;
- }
-
-#ifdef XINPUT
- if (is_pointer) {
-#endif
-#ifdef XFreeXDGA
- if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectMouse) {
- XF86DirectVideoMoveMouse(dx, dy, mevent->u.keyButtonPointer.time);
- } else
-#endif
- {
- MOVEPOINTER(dx, dy, mevent->u.keyButtonPointer.time);
+#if !defined(__UNIXOS2__) && !defined(__QNX__)
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesWithInput;
+ InputInfoPtr pInfo;
+
+ if (err >= 0) {
+
+ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesWithInput)) {
+ if (xf86Info.kbdEvents)
+ (xf86Info.kbdEvents)();
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0 &&
+ (FD_ISSET(pInfo->fd, ((fd_set *)pReadmask)) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ /*
+ * Must break here because more than one device may share
+ * the same file descriptor.
+ */
+ break;
+ }
+ pInfo = pInfo->next;
+ }
}
-#ifdef XINPUT
}
- else {
- xev->type = DeviceMotionNotify;
- xev->deviceid = device->id | MORE_EVENTS;
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->num_valuators = 2;
- xv->first_valuator = 0;
- xv->device_state = 0;
- xv->valuator0 = dx;
- xv->valuator1 = dy;
- xf86eqEnqueue(mevent);
+#else /* __UNIXOS2__ and __QNX__ */
+
+ InputInfoPtr pInfo;
+
+ (xf86Info.kbdEvents)(); /* Under OS/2 and QNX, always call */
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0) {
+ int sigstate = xf86BlockSIGIO();
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ /*
+ * Must break here because more than one device may share
+ * the same file descriptor.
+ */
+ break;
+ }
+ pInfo = pInfo->next;
}
-#endif
- }
-
- if (private->emulate3Buttons)
- {
- /*
- * Hack to operate the middle button even with Emulate3Buttons set.
- * Modifying the state table to keep track of the middle button state
- * would nearly double its size, so I'll stick with this fix. - TJW
- */
- if (private->mseType == P_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- if (change & 02)
- {
-#ifdef XINPUT
- if (xf86CheckButton(2, (buttons & 02))) {
-#endif
- ENQUEUE(mevent,
- 2, (buttons & 02) ? ButtonPress : ButtonRelease,
- XE_POINTER);
-#ifdef XINPUT
- }
-#endif
- }
-
- /*
- * emulate the third button by the other two
- */
- if ((id = stateTab[buttons + private->emulateState][0]) != 0)
- {
-#ifdef XINPUT
- if (is_pointer) {
- if (xf86CheckButton(abs(id), (id >= 0))) {
-#endif
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#ifdef XINPUT
- }
- }
- else {
- xev->type = (id < 0 ? DeviceButtonRelease : DeviceButtonPress);
- xev->deviceid = device->id | MORE_EVENTS;
- xev->detail = abs(id);
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->num_valuators = 0;
- xv->device_state = 0;
- xf86eqEnqueue(mevent);
- }
-#endif
- }
+#endif /* __UNIXOS2__ and __QNX__ */
- if ((id = stateTab[buttons + private->emulateState][1]) != 0)
- {
-#ifdef XINPUT
- if (is_pointer) {
- if (xf86CheckButton(abs(id), (id >= 0))) {
-#endif
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#ifdef XINPUT
- }
- }
- else {
- xev->type = (id < 0 ? DeviceButtonRelease : DeviceButtonPress);
- xev->deviceid = device->id | MORE_EVENTS;
- xev->detail = abs(id);
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->num_valuators = 0;
- xv->device_state = 0;
- xf86eqEnqueue(mevent);
- }
-#endif
- }
-
- private->emulateState = stateTab[buttons + private->emulateState][2];
- if (stateTab[buttons + private->emulateState][0] ||
- stateTab[buttons + private->emulateState][1])
- {
- private->truebuttons = truebuttons;
- timer = TimerSet(timer, 0, private->emulate3Timeout, buttonTimer,
- (pointer)device);
- }
- else
- {
- if (timer)
- {
- TimerFree(timer);
- timer = NULL;
- }
- }
- }
- else
- {
-#ifdef AMOEBA
- if (truebuttons != 0) {
-#ifdef XINPUT
- if (is_pointer) {
- if (xf86CheckButton(truebuttons)) {
-#endif
- ENQUEUE(mevent,
- truebuttons, (pressed ? ButtonPress : ButtonRelease),
- XE_POINTER);
-#ifdef XINPUT
- }
- }
- else {
- xev->type = pressed ? DeviceButtonPress : DeviceButtonRelease;
- xev->deviceid = device->id | MORE_EVENTS;
- xev->detail = truebuttons;
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->num_valuators = 0;
- xv->device_state = 0;
- xf86eqEnqueue(mevent);
- }
-#endif
- }
-#else
- /*
- * real three button event
- * Note that xf86Info.lastButtons has the hardware button mapping which
- * is the reverse of the button mapping reported to the server.
- */
- if (private->mseType == P_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- while (change)
- {
- id = ffs(change);
- change &= ~(1 << (id-1));
-#ifdef XINPUT
- if (is_pointer) {
- if (xf86CheckButton(id, (buttons&(1<<(id-1))))) {
-#endif
- ENQUEUE(mevent,
- id, (buttons&(1<<(id-1)))? ButtonPress : ButtonRelease,
- XE_POINTER);
-#ifdef XINPUT
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
+ for (ih = InputHandlers; ih; ih = ih->next) {
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
+ (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
+ ih->ihproc(ih->fd, ih->data);
}
- }
- else {
- xev->type = (buttons&(1<<(id-1)))? DeviceButtonPress : DeviceButtonRelease;
- xev->deviceid = device->id | MORE_EVENTS;
- xev->detail = id;
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->num_valuators = 0;
- xv->device_state = 0;
- xf86eqEnqueue(mevent);
- }
-#endif
}
-#endif
}
- private->lastButtons = truebuttons;
-}
+
+ if (xf86VTSwitchPending()) xf86VTSwitch();
+ if (xf86Info.inputPending) ProcessInputEvents();
+}
/*
- * xf86Block --
- * Os block handler.
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
*/
-
-/* ARGSUSED */
-void
-xf86Block(blockData, pTimeout, pReadmask)
- pointer blockData;
- OSTimePtr pTimeout;
- pointer pReadmask;
+static void
+xf86SigioReadInput(int fd,
+ void *closure)
{
-}
+ int sigstate = xf86BlockSIGIO();
+ InputInfoPtr pInfo = (InputInfoPtr) closure;
+ pInfo->read_input(pInfo);
-#ifndef AMOEBA
+ xf86UnblockSIGIO(sigstate);
+}
/*
- * xf86Wakeup --
- * Os wakeup handler.
+ * xf86AddEnabledDevice --
+ *
*/
-
-/* ARGSUSED */
void
-xf86Wakeup(blockData, err, pReadmask)
- pointer blockData;
- int err;
- pointer pReadmask;
+xf86AddEnabledDevice(InputInfoPtr pInfo)
{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
-#ifndef __EMX__
-#ifdef __OSF__
- fd_set kbdDevices;
- fd_set mseDevices;
-#endif /* __OSF__ */
- fd_set* LastSelectMask = (fd_set*)pReadmask;
- fd_set devicesWithInput;
-
- if ((int)err >= 0) {
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
-#ifdef __OSF__
- /*
- * Until the two devices are made nonblock on read, we have to do this.
- */
-
- MASKANDSETBITS(devicesWithInput, pReadmask, EnabledDevices);
-
- CLEARBITS(kbdDevices);
- BITSET(kbdDevices, xf86Info.consoleFd);
- MASKANDSETBITS(kbdDevices, kbdDevices, devicesWithInput);
-
- CLEARBITS(mseDevices);
- BITSET(mseDevices, xf86Info.mouseDev->mseFd);
- MASKANDSETBITS(mseDevices, mseDevices, devicesWithInput);
-
- if (ANYSET(kbdDevices) || xf86Info.kbdRate)
- (xf86Info.kbdEvents)(ANYSET(kbdDevices));
- if (ANYSET(mseDevices))
- (xf86Info.mouseDev->mseEvents)(1);
-
-#else
- if (XFD_ANYSET(&devicesWithInput))
- {
- (xf86Info.kbdEvents)();
- (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
- }
-#endif /* __OSF__ */
- }
-#else /* __EMX__ */
-
- (xf86Info.kbdEvents)(); /* Under OS/2, always call */
- (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
-
-#endif /* __EMX__ */
-
-#if defined(XQUEUE) && !defined(XQUEUE_ASYNC)
- /* This could be done more cleanly */
- if (xf86Info.mouseDev->xqueSema && xf86Info.mouseDev->xquePending)
- xf86XqueRequest();
-#endif
-
- if (xf86VTSwitchPending()) xf86VTSwitch();
-
- if (xf86Info.inputPending) ProcessInputEvents();
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
}
-#endif /* AMOEBA */
+static int *xf86SignalIntercept = NULL;
+void
+xf86InterceptSignals(int *signo)
+{
+ if ((xf86SignalIntercept = signo))
+ *signo = -1;
+}
/*
* xf86SigHandler --
- * Catch unexpected signals and exit cleanly.
+ * Catch unexpected signals and exit or continue cleanly.
*/
void
-xf86SigHandler(signo)
- int signo;
+xf86SigHandler(int signo)
{
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ /* Re-arm handler just in case */
+ (void) signal(signo, xf86SigHandler);
+ *xf86SignalIntercept = signo;
+ return;
+ }
+
signal(signo,SIG_IGN);
xf86Info.caughtSignal = TRUE;
+#ifdef XF86BIGFONT
+ XF86BigfontCleanup();
+#endif
+#if defined(XFree86LOADER)
+ if (xf86Initialising)
+ LoaderCheckUnresolved(LD_RESOLV_IFDONE);
+ ErrorF("\n"
+ " *** If unresolved symbols were reported above, they might not\n"
+ " *** be the reason for the server aborting.\n");
+#endif
FatalError("Caught signal %d. Server aborting\n", signo);
}
+#ifdef MEMDEBUG
+void
+xf86SigMemDebug(int signo)
+{
+ CheckMemory();
+ (void) signal(signo, xf86SigMemDebug);
+ return;
+}
+#endif
+
/*
* xf86VTSwitch --
* Handle requests for switching the vt.
@@ -1407,76 +1211,261 @@ xf86SigHandler(signo)
static void
xf86VTSwitch()
{
- int j;
+ int i, prevSIGIO;
+ InputInfoPtr pInfo;
+ IHPtr ih;
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch()\n");
+#endif
+
#ifdef XFreeXDGA
+ if(!DGAVTSwitch())
+ return;
+#endif
+
/*
- * Not ideal, but until someone adds DGA events to the DGA client we
- * should protect the machine
+ * Since all screens are currently all in the same state it is sufficient
+ * check the first. This might change in future.
*/
- if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics) {
- xf86Info.vtRequestsPending = FALSE;
- return;
- }
+ if (xf86Screens[0]->vtSema) {
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
#endif
- if (xf86VTSema) {
- for (j = 0; j < screenInfo.numScreens; j++)
- (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(LEAVE, j);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
+#if !defined(__UNIXOS2__)
-#ifndef __EMX__
+ /*
+ * Keep the order: Disable Device > LeaveVT
+ * EnterVT > EnableDevice
+ */
DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
- DisableDevice((DeviceIntPtr)xf86Info.pMouse);
-#endif
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ DisableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->LeaveVT(i, 0);
+ }
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86DisableInputHandler(ih);
+ xf86AccessLeave(); /* We need this here, otherwise */
+ xf86AccessLeaveState(); /* console won't be restored */
if (!xf86VTSwitchAway()) {
/*
* switch failed
*/
- for (j = 0; j < screenInfo.numScreens; j++)
- (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(ENTER, j);
- SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
-#ifdef DPMSExtension
- if (DPMSEnabled)
- DPMSSet(DPMSModeOn);
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Leave failed\n");
#endif
+ prevSIGIO = xf86BlockSIGIO();
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ xf86EnterServerState(OPERATING);
+ if (!(dispatchException & DE_TERMINATE)) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ }
+ SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
-#ifndef __EMX__
+#if !defined(__UNIXOS2__)
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#endif
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
} else {
- xf86VTSema = FALSE;
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ xf86Screens[i]->access = NULL;
+ xf86Screens[i]->busAccess = NULL;
+ }
+ xf86DisableIO();
}
} else {
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Entering\n");
+#endif
if (!xf86VTSwitchTo()) return;
-
- xf86VTSema = TRUE;
- for (j = 0; j < screenInfo.numScreens; j++)
- (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(ENTER, j);
-
+
+ prevSIGIO = xf86BlockSIGIO();
+ xf86OSPMClose = xf86OSPMOpen();
+
+ xf86EnableIO();
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->vtSema = TRUE;
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ xf86EnterServerState(OPERATING);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
+ }
+
/* Turn screen saver off when switching back */
SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
-#ifdef DPMSExtension
- if (DPMSEnabled)
- DPMSSet(DPMSModeOn);
-#endif
-#ifndef __EMX__
+#if !defined(__UNIXOS2__)
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#endif
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+ xf86UnblockSIGIO(prevSIGIO);
}
}
+
+/* Input handler registration */
+
+pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih;
+
+ if (fd < 0 || !proc)
+ return NULL;
+
+ ih = xcalloc(sizeof(*ih), 1);
+ if (!ih)
+ return NULL;
+
+ ih->fd = fd;
+ ih->ihproc = proc;
+ ih->data = data;
+ ih->enabled = TRUE;
+
+ ih->next = InputHandlers;
+ InputHandlers = ih;
+
+ AddEnabledDevice(fd);
+
+ return ih;
+}
+
+int
+xf86RemoveInputHandler(pointer handler)
+{
+ IHPtr ih, p;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+
+ if (ih == InputHandlers)
+ InputHandlers = ih->next;
+ else {
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
+ }
+ xfree(ih);
+ return fd;
+}
+
+void
+xf86DisableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+}
+
+void
+xf86EnableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddEnabledDevice(ih->fd);
+}
+
+/*
+ * As used currently by the DRI, the return value is ignored.
+ */
+Bool
+xf86EnableVTSwitch(Bool new)
+{
+ static Bool def = TRUE;
+ Bool old;
+
+ old = VTSwitchEnabled;
+ if (!new) {
+ /* Disable VT switching */
+ def = VTSwitchEnabled;
+ VTSwitchEnabled = FALSE;
+ } else {
+ /* Restore VT switching to default */
+ VTSwitchEnabled = def;
+ }
+ return old;
+}
+
#ifdef XTESTEXT1
void
-XTestGetPointerPos(fmousex, fmousey)
- short *fmousex;
- short *fmousey;
+XTestGetPointerPos(short *fmousex, short *fmousey)
{
int x,y;
@@ -1488,23 +1477,14 @@ XTestGetPointerPos(fmousex, fmousey)
void
-XTestJumpPointer(jx, jy, dev_type)
- int jx;
- int jy;
- int dev_type;
+XTestJumpPointer(int jx, int jy, int dev_type)
{
miPointerAbsoluteCursor(jx, jy, GetTimeInMillis() );
}
-
-
void
-XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
- int dev_type;
- int keycode;
- int keystate;
- int mousex;
- int mousey;
+XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
+ int mousey)
{
xEvent tevent;
@@ -1525,51 +1505,30 @@ XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
#endif /* XTESTEXT1 */
+#ifdef WSCONS_SUPPORT
-#ifdef XFreeXDGA
-static void
-XF86DirectVideoMoveMouse(x, y, mtime)
- int x;
- int y;
- CARD32 mtime;
-{
- xEvent xE;
-
- xE.u.u.type = MotionNotify;
- xE.u.keyButtonPointer.time = xf86Info.lastEventTime = mtime;
- xf86Info.lastEventTime = mtime;
-
-
- xE.u.keyButtonPointer.eventY = x;
- xE.u.keyButtonPointer.eventY = y;
- xE.u.keyButtonPointer.rootX = x;
- xE.u.keyButtonPointer.rootY = y;
+/* XXX Currently XKB is mandatory. */
- if (((DeviceIntPtr)(xf86Info.pMouse))->grab)
- DeliverGrabbedEvent(&xE, (xf86Info.pMouse), FALSE, 1);
- else
- DeliverDeviceEvents(GetSpriteWindow(), &xE, NullGrab, NullWindow,
- (xf86Info.pMouse), 1);
-}
+extern int WSKbdToKeycode(int);
-static void
-XF86DirectVideoKeyEvent(xE, keycode, etype)
-xEvent *xE;
-int keycode;
-int etype;
+void
+xf86PostWSKbdEvent(struct wscons_event *event)
{
- DeviceIntPtr keybd = (DeviceIntPtr)xf86Info.pKeyboard;
- KeyClassPtr keyc = keybd->key;
- BYTE *kptr;
-
- kptr = &keyc->down[keycode >> 3];
- xE->u.u.type = etype;
- xE->u.u.detail = keycode;
-
- /* clear the keypress state */
- if (etype == KeyPress) {
- *kptr &= ~(1 << (keycode & 7));
+ int type = event->type;
+ int value = event->value;
+ unsigned int keycode;
+ int blocked;
+
+ if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
+ Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
+
+ /* map the scancodes to standard XFree86 scancode */
+ keycode = WSKbdToKeycode(value);
+ if (!down) keycode |= 0x80;
+ /* It seems better to block SIGIO there */
+ blocked = xf86BlockSIGIO();
+ xf86PostKbdEvent(keycode);
+ xf86UnblockSIGIO(blocked);
}
- keybd->public.processInputProc(xE, keybd, 1);
}
-#endif
+#endif /* WSCONS_SUPPORT */
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 864933a84..7c65ce888 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1,138 +1,199 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.198 2003/02/26 09:21:38 dawes Exp $ */
+
/*
- * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.66.2.2 1997/06/29 08:43:36 dawes Exp $
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright 1991-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
- * 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.
+ * Loosely based on code bearing the following copyright:
*
- * THOMAS ROELL 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
- * 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.
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*/
-/* $Xorg: xf86Init.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#else
-extern int atoi();
-#endif
#define NEED_EVENTS
#include "X.h"
#include "Xmd.h"
#include "Xproto.h"
+#include "Xatom.h"
#include "input.h"
#include "servermd.h"
+#include "windowstr.h"
#include "scrnintstr.h"
#include "site.h"
+#include "mi.h"
#include "compiler.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#define XF86_OS_PRIVS
#include "xf86.h"
-#include "xf86Procs.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
#include "xf86_OSlib.h"
#include "xf86Version.h"
+#include "xf86Date.h"
+#include "xf86Build.h"
#include "mipointer.h"
-
#ifdef XINPUT
#include "XI.h"
#include "XIproto.h"
-#include "xf86_Config.h"
-#include "xf86Xinput.h"
#else
#include "inputstr.h"
#endif
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
-#include "opaque.h"
+#include "globals.h"
#ifdef XTESTEXT1
#include "atKeynames.h"
extern int xtest_command_key;
#endif /* XTESTEXT1 */
-#ifdef __EMX__
-#define seteuid(x) /*nothing*/
-#define setruid(x) /*nothing*/
-#endif
-/* xf86Exiting is set while the screen is shutting down (even on a reset) */
-Bool xf86Exiting = FALSE;
-Bool xf86Resetting = FALSE;
-Bool xf86ProbeFailed = TRUE;
-Bool xf86FlipPixels = FALSE;
-#ifdef XF86VIDMODE
-Bool xf86VidModeEnabled = TRUE;
-Bool xf86VidModeAllowNonLocal = FALSE;
-#endif
-#ifdef XF86MISC
-Bool xf86MiscModInDevEnabled = TRUE;
-Bool xf86MiscModInDevAllowNonLocal = FALSE;
-#endif
-Bool xf86AllowMouseOpenFail = FALSE;
-PciProbeType xf86PCIFlags = PCIProbe1;
-Bool xf86ScreensOpen = FALSE;
-int xf86Verbose = 1;
-Bool xf86fpFlag = FALSE;
-Bool xf86coFlag = FALSE;
-Bool xf86sFlag = FALSE;
-Bool xf86ProbeOnly = FALSE;
-char xf86ConfigFile[PATH_MAX] = "";
-int xf86bpp = -1;
-xrgb xf86weight = { 0, 0, 0 } ; /* RGB weighting at 16 bpp */
-double xf86rGamma=1.0, xf86gGamma=1.0, xf86bGamma=1.0;
-unsigned char xf86rGammaMap[256], xf86gGammaMap[256], xf86bGammaMap[256];
-char *xf86ServerName = NULL;
-Bool xf86BestRefresh = FALSE;
-
-int vgaIOBase = 0x3d0;
-int vgaCRIndex = 0x3d4;
-int vgaCRReg = 0x3d5;
-
-static void xf86PrintBanner(
-#if NeedFunctionPrototypes
- void
-#endif
- );
-static void xf86PrintConfig(
-#if NeedFunctionPrototypes
- void
-#endif
- );
+/* forward declarations */
+
+static void xf86PrintBanner(void);
+static void xf86PrintMarkers(void);
+static void xf86RunVtInit(void);
+
#ifdef DO_CHECK_BETA
-void xf86CheckBeta(
-#if NeedFunctionPrototypes
- int,
- char *
-#endif
- );
static int extraDays = 0;
static char *expKey = NULL;
#endif
-extern ScrnInfoPtr xf86Screens[];
-extern int xf86MaxScreens;
-extern double pow();
-#ifdef USE_XF86_SERVERLOCK
-extern void xf86UnlockServer();
-#endif
-#ifdef __EMX__
+#ifdef __UNIXOS2__
extern void os2ServerVideoAccess();
#endif
-xf86InfoRec xf86Info;
-int xf86ScreenIndex;
+void (*xf86OSPMClose)(void) = NULL;
+
+#ifdef XFree86LOADER
+static char *baseModules[] = {
+ "bitmap",
+ "pcidata",
+ NULL
+};
+#endif
+
+/* Common pixmap formats */
+
+static PixmapFormatRec formats[MAXFORMATS] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+#ifdef RENDER
+ { 32, 32, BITMAP_SCANLINE_PAD },
+#endif
+};
+#ifdef RENDER
+static int numFormats = 7;
+#else
+static int numFormats = 6;
+#endif
+static Bool formatsDone = FALSE;
+
+InputDriverRec xf86KEYBOARD = {
+ 1,
+ "keyboard",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PropertyPtr pRegProp, pOldRegProp;
+ CreateWindowProcPtr CreateWindow =
+ (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+
+#ifdef DEBUG
+ ErrorF("xf86CreateRootWindow(%p)\n", pWin);
+#endif
+
+ if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ xf86CreateRootWindow, pScreen->CreateWindow );
+ }
+
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL!=pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow)(pWin);
+ }
+
+ /* Now do our stuff */
+
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pRegProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pRegProp != NULL && err==Success;
+ pRegProp = pRegProp->next )
+ {
+ Atom oldNameAtom = pRegProp->propertyName;
+ char *nameString;
+ /* propertyName was created before the screen existed,
+ * so the atom does not belong to any screen;
+ * we need to create a new atom with the same name.
+ */
+ nameString = NameForAtom(oldNameAtom);
+ pRegProp->propertyName = MakeAtom(nameString, strlen(nameString), TRUE);
+ err = ChangeWindowProperty(pWin,
+ pRegProp->propertyName, pRegProp->type,
+ pRegProp->format, PropModeReplace,
+ pRegProp->size, pRegProp->data,
+ FALSE
+ );
+ }
+
+ /* Look at err */
+ ret &= (err==Success);
+
+ /* free memory */
+ pOldRegProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ while (pOldRegProp!=NULL) {
+ pRegProp = pOldRegProp->next;
+ xfree(pOldRegProp);
+ pOldRegProp = pRegProp;
+ }
+ xf86RegisteredPropertiesTable[pScreen->myNum] = NULL;
+ } else {
+ xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+ "non-root window %p (parent %p)\n", pWin, pWin->parent);
+ ret = FALSE;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("xf86CreateRootWindow() returns %d\n", ret);
+#endif
+ return (ret);
+}
+
/*
* InitOutput --
@@ -142,23 +203,38 @@ int xf86ScreenIndex;
*/
void
-InitOutput(pScreenInfo, argc, argv)
- ScreenInfo *pScreenInfo;
- int argc;
- char **argv;
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
- int i, j, scr_index;
- static int numFormats = 0;
- static PixmapFormatRec formats[MAXFORMATS];
+ int i, j, k, scr_index;
static unsigned long generation = 0;
- int any_screens = 0;
-
-#ifdef __EMX__
+#ifdef XFree86LOADER
+ char **modulelist;
+ pointer *optionlist;
+#endif
+ screenLayoutPtr layout;
+ Pix24Flags screenpix24, pix24;
+ MessageType pix24From = X_DEFAULT;
+ Bool pix24Fail = FALSE;
+
+#ifdef __UNIXOS2__
os2ServerVideoAccess(); /* See if we have access to the screen before doing anything */
#endif
+ xf86Initialising = TRUE;
+
+ /* Do this early? */
+ if (generation != serverGeneration) {
+ xf86ScreenIndex = AllocateScreenPrivateIndex();
+ xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
+ xf86PixmapIndex = AllocatePixmapPrivateIndex();
+ xf86RegisteredPropertiesTable=NULL;
+ generation = serverGeneration;
+ }
+
if (serverGeneration == 1) {
+ pScreenInfo->numScreens = 0;
+
if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
xf86ServerName++;
else
@@ -169,119 +245,517 @@ InitOutput(pScreenInfo, argc, argv)
#endif
xf86PrintBanner();
+ xf86PrintMarkers();
+ if (xf86LogFile) {
+ time_t t;
+ const char *ct;
+ t = time(NULL);
+ ct = ctime(&t);
+ xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+ xf86LogFile, ct);
+ }
+
+ /* Read and parse the config file */
+ if (!xf86DoProbe && !xf86DoConfigure) {
+ if (!xf86HandleConfigFile()) {
+ xf86Msg(X_ERROR, "Error from xf86HandleConfigFile()\n");
+ return;
+ }
+ }
- xf86PrintConfig();
+ /*
+ * Install signal handler for unexpected signals
+ */
+ xf86Info.caughtSignal=FALSE;
+ if (!xf86Info.notrapSignals) {
+ signal(SIGSEGV,xf86SigHandler);
+ signal(SIGILL,xf86SigHandler);
+#ifdef SIGEMT
+ signal(SIGEMT,xf86SigHandler);
+#endif
+ signal(SIGFPE,xf86SigHandler);
+#ifdef SIGBUS
+ signal(SIGBUS,xf86SigHandler);
+#endif
+#ifdef SIGSYS
+ signal(SIGSYS,xf86SigHandler);
+#endif
+#ifdef SIGXCPU
+ signal(SIGXCPU,xf86SigHandler);
+#endif
+#ifdef SIGXFSZ
+ signal(SIGXFSZ,xf86SigHandler);
+#endif
+#ifdef MEMDEBUG
+ signal(SIGUSR2,xf86SigMemDebug);
+#endif
+ }
xf86OpenConsole();
+ xf86OSPMClose = xf86OSPMOpen();
+
+ /* Run an external VT Init program if specified in the config file */
+ xf86RunVtInit();
+
+ /* Do this after XF86Config is read (it's normally in OsInit()) */
+ OsInitColors();
+
+ /* Enable full I/O access */
+ xf86EnableIO();
+
+#ifdef XFree86LOADER
+ /* Initialise the loader */
+ LoaderInit();
+
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
+
+#ifdef TESTING
+ {
+ char **list, **l;
+ const char *subdirs[] = {
+ "drivers",
+ NULL
+ };
+ const char *patlist[] = {
+ "(.*)_drv\\.so",
+ "(.*)_drv\\.o",
+ NULL
+ };
+ ErrorF("Getting module listing...\n");
+ list = LoaderListDirs(NULL, NULL);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("module: %s\n", *l);
+ LoaderFreeDirList(list);
+ ErrorF("Getting video driver listing...\n");
+ list = LoaderListDirs(subdirs, NULL);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("video driver: %s\n", *l);
+ LoaderFreeDirList(list);
+ ErrorF("Getting driver listing...\n");
+ list = LoaderListDirs(NULL, patlist);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("video driver: %s\n", *l);
+ LoaderFreeDirList(list);
+ }
+#endif
+
+ /* Force load mandatory base modules */
+ if (!xf86LoadModules(baseModules, NULL))
+ FatalError("Unable to load required base modules, Exiting...\n");
+
+#endif
+
+ /* Do a general bus probe. This will be a PCI probe for x86 platforms */
+ xf86BusProbe();
+
+ if (xf86DoProbe)
+ DoProbe();
+
+ if (xf86DoConfigure)
+ DoConfigure();
+
+ /* Initialise the resource broker */
+ xf86ResourceBrokerInit();
+
+#ifdef XFree86LOADER
+ /* Load all modules specified explicitly in the config file */
+ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+ xf86LoadModules(modulelist, optionlist);
+ xfree(modulelist);
+ xfree(optionlist);
+ }
+
+ /* Load all driver modules specified in the config file */
+ if ((modulelist = xf86DriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ xfree(modulelist);
+ }
+
+ /* Setup the builtin input drivers */
+ xf86AddInputDriver(&xf86KEYBOARD, NULL, 0);
+ /* Load all input driver modules specified in the config file. */
+ if ((modulelist = xf86InputDriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ xfree(modulelist);
+ }
-#if !defined(AMOEBA) && !defined(MINIX)
/*
- * If VTInit was set, run that program with consoleFd as stdin and stdout
+ * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+ * called for each driver as it is loaded. Those functions save the
+ * module pointers for drivers.
+ * XXX Nothing keeps track of them for other modules.
*/
+ /* XXX What do we do if not all of these could be loaded? */
+#endif
- if (xf86Info.vtinit) {
- switch(fork()) {
- case -1:
- FatalError("Fork failed for VTInit (%s)\n", strerror(errno));
- break;
- case 0: /* child */
- setuid(getuid());
- /* set stdin, stdout to the consoleFd */
- for (i = 0; i < 2; i++) {
- if (xf86Info.consoleFd != i) {
- close(i);
- dup(xf86Info.consoleFd);
- }
- }
- execl("/bin/sh", "sh", "-c", xf86Info.vtinit, NULL);
- ErrorF("Warning: exec of /bin/sh failed for VTInit (%s)\n",
- strerror(errno));
- exit(255);
- break;
- default: /* parent */
- wait(NULL);
+ /*
+ * At this point, xf86DriverList[] is all filled in with entries for
+ * each of the drivers to try and xf86NumDrivers has the number of
+ * drivers. If there are none, return now.
+ */
+
+ if (xf86NumDrivers == 0) {
+ xf86Msg(X_ERROR, "No drivers available.\n");
+ return;
+ }
+
+ /*
+ * Call each of the Identify functions. The Identify functions print
+ * out some identifying information, and anything else that might be
+ * needed at this early stage.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++)
+ /* The Identify function is mandatory, but if it isn't there continue */
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
+ else {
+ xf86Msg(X_WARNING, "Driver `%s' has no Identify function\n",
+ xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
+ : "noname");
}
+
+ /*
+ * Locate bus slot that had register IO enabled at server startup
+ */
+
+ xf86AccessInit();
+ xf86FindPrimaryDevice();
+
+ /*
+ * Now call each of the Probe functions. Each successful probe will
+ * result in an extra entry added to the xf86Screens[] list for each
+ * instance of the hardware found.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->Probe != NULL)
+ xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
+ else {
+ xf86MsgVerb(X_WARNING, 0,
+ "Driver `%s' has no Probe function (ignoring)\n",
+ xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
+ : "noname");
+ }
+ xf86SetPciVideo(NULL,NONE);
}
-#endif /* !AMOEBA && !MINIX */
- /* Do this after XF86Config is read (it's normally in OsInit()) */
- OsInitColors();
+ /*
+ * If nothing was detected, return now.
+ */
- for (i=0; i<256; i++) {
- xf86rGammaMap[i] = (int)(pow(i/255.0,xf86rGamma)*255.0+0.5);
- xf86gGammaMap[i] = (int)(pow(i/255.0,xf86gGamma)*255.0+0.5);
- xf86bGammaMap[i] = (int)(pow(i/255.0,xf86bGamma)*255.0+0.5);
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "No devices detected.\n");
+ return;
}
- xf86Config(TRUE); /* Probe displays, and resolve modes */
+ /*
+ * Match up the screens found by the probes against those specified
+ * in the config file. Remove the ones that won't be used. Sort
+ * them in the order specified.
+ */
-#ifdef XKB
- xf86InitXkb();
-#endif
+ /*
+ * What is the best way to do this?
+ *
+ * For now, go through the screens allocated by the probes, and
+ * look for screen config entry which refers to the same device
+ * section as picked out by the probe.
+ *
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+ layout++) {
+ Bool found = FALSE;
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+
+ GDevPtr dev =
+ xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
+ xf86Screens[i]->entityInstanceList[j]);
+
+ if (dev == layout->screen->device) {
+ /* A match has been found */
+ xf86Screens[i]->confScreen = layout->screen;
+ found = TRUE;
+ break;
+ }
+ }
+ if (found) break;
+ }
+ if (layout->screen == NULL) {
+ /* No match found */
+ xf86Msg(X_ERROR,
+ "Screen %d deleted because of no matching config section.\n", i);
+ xf86DeleteScreen(i--, 0);
+ }
+ }
/*
- * collect all possible formats
+ * If no screens left, return now.
*/
- formats[0].depth = 1;
- formats[0].bitsPerPixel = 1;
- formats[0].scanlinePad = BITMAP_SCANLINE_PAD;
- numFormats++;
-
- for ( i=0;
- i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured;
- i++ )
- {
- /*
- * At least one probe function succeeded.
- */
- any_screens = 1;
- /*
- * add new pixmap format
- */
- for ( j=0; j < numFormats; j++ ) {
-
- if (formats[j].depth == xf86Screens[i]->depth &&
- formats[j].bitsPerPixel == xf86Screens[i]->bitsPerPixel)
- break; /* found */
- }
-
- if (j == numFormats) { /* not already there */
- formats[j].depth = xf86Screens[i]->depth;
- formats[j].bitsPerPixel = xf86Screens[i]->bitsPerPixel;
- formats[j].scanlinePad = BITMAP_SCANLINE_PAD;
- numFormats++;
- if ( numFormats > MAXFORMATS )
- FatalError( "Too many pixmap formats! Exiting\n" );
- }
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Device(s) detected, but none match those in the config file.\n");
+ return;
+ }
+
+ xf86PostProbe();
+ xf86EntityInit();
+
+ /*
+ * Sort the drivers to match the requested ording. Using a slow
+ * bubble sort.
+ */
+ for (j = 0; j < xf86NumScreens - 1; j++) {
+ for (i = 0; i < xf86NumScreens - j - 1; i++) {
+ if (xf86Screens[i + 1]->confScreen->screennum <
+ xf86Screens[i]->confScreen->screennum) {
+ ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+ xf86Screens[i + 1] = xf86Screens[i];
+ xf86Screens[i] = tmpScrn;
+ }
+ }
+ }
+ /* Fix up the indexes */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->scrnIndex = i;
+ }
+
+ /*
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->PreInit &&
+ xf86Screens[i]->PreInit(xf86Screens[i], 0))
+ xf86Screens[i]->configured = TRUE;
+ }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86Screens[i]->configured)
+ xf86DeleteScreen(i--, 0);
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Screen(s) found, but none have a usable configuration.\n");
+ return;
+ }
+
+ /* This could be moved into a separate function */
+
+ /*
+ * Check that all screens have initialised the mandatory function
+ * entry points. Delete those which have not.
+ */
+
+#define WARN_SCREEN(func) \
+ xf86Msg(X_ERROR, "Driver `%s' has no %s function, deleting.\n", \
+ xf86Screens[i]->name, (warned++, func))
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ int warned = 0;
+ if (xf86Screens[i]->name == NULL) {
+ xf86Screens[i]->name = xnfalloc(strlen("screen") + 1 + 1);
+ if (i < 10)
+ sprintf(xf86Screens[i]->name, "screen%c", i + '0');
+ else
+ sprintf(xf86Screens[i]->name, "screen%c", i - 10 + 'A');
+ xf86MsgVerb(X_WARNING, 0,
+ "Screen driver %d has no name set, using `%s'.\n",
+ i, xf86Screens[i]->name);
}
- if (!any_screens)
- if (xf86ProbeFailed)
- ErrorF("\n *** None of the configured devices were detected.***\n\n");
- else
- ErrorF(
- "\n *** A configured device found, but display modes could not be resolved.***\n\n");
+ if (xf86Screens[i]->ScreenInit == NULL)
+ WARN_SCREEN("ScreenInit");
+ if (xf86Screens[i]->EnterVT == NULL)
+ WARN_SCREEN("EnterVT");
+ if (xf86Screens[i]->LeaveVT == NULL)
+ WARN_SCREEN("LeaveVT");
+ if (warned)
+ xf86DeleteScreen(i--, 0);
+ }
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "Screen(s) found, but drivers were unusable.\n");
+ return;
+ }
+
+ /* XXX Should this be before or after loading dependent modules? */
if (xf86ProbeOnly)
{
- xf86VTSema = FALSE;
+ OsCleanup();
AbortDDX();
fflush(stderr);
exit(0);
}
- }
- else {
+
+#ifdef XFree86LOADER
+ /* Remove (unload) drivers that are not required */
+ for (i = 0; i < xf86NumDrivers; i++)
+ if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+ xf86DeleteDriver(i);
+#endif
+
+ /*
+ * At this stage we know how many screens there are.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86InitViewport(xf86Screens[i]);
+
+ /*
+ * Collect all pixmap formats and check for conflicts at the display
+ * level. Should we die here? Or just delete the offending screens?
+ * Also, should this be done for -probeonly?
+ */
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->imageByteOrder !=
+ xf86Screens[0]->imageByteOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlinePad !=
+ xf86Screens[0]->bitmapScanlinePad)
+ FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlineUnit !=
+ xf86Screens[0]->bitmapScanlineUnit)
+ FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
+ if (xf86Screens[i]->bitmapBitOrder !=
+ xf86Screens[0]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ /* Determine the depth 24 pixmap format the screens would like */
+ if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86Screens[i]->pixmap24;
+ else if (screenpix24 != xf86Screens[i]->pixmap24)
+ FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ /* check if screenpix24 is consistent with the config/cmdline */
+ if (xf86Info.pixmap24 != Pix24DontCare) {
+ pix24 = xf86Info.pixmap24;
+ pix24From = xf86Info.pix24From;
+ if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
+ pix24Fail = TRUE;
+ } else if (screenpix24 != Pix24DontCare) {
+ pix24 = screenpix24;
+ pix24From = X_PROBED;
+ } else
+ pix24 = Pix24Use32;
+
+ if (pix24Fail)
+ FatalError("Screen(s) can't use the required depth 24 pixmap format"
+ " (%d). Exiting\n", PIX24TOBPP(pix24));
+
+ /* Initialise the depth 24 format */
+ for (j = 0; j < numFormats && formats[j].depth != 24; j++)
+ ;
+ formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+
+ /* Collect additional formats */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+ for (k = 0; ; k++) {
+ if (k >= numFormats) {
+ if (k >= MAXFORMATS)
+ FatalError("Too many pixmap formats! Exiting\n");
+ formats[k] = xf86Screens[i]->formats[j];
+ numFormats++;
+ break;
+ }
+ if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+ if ((formats[k].bitsPerPixel ==
+ xf86Screens[i]->formats[j].bitsPerPixel) &&
+ (formats[k].scanlinePad ==
+ xf86Screens[i]->formats[j].scanlinePad))
+ break;
+ FatalError("Inconsistent pixmap format for depth %d."
+ " Exiting\n", formats[k].depth);
+ }
+ }
+ }
+ }
+ formatsDone = TRUE;
+
+ /* If a screen uses depth 24, show what the pixmap format is */
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->depth == 24) {
+ xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+ PIX24TOBPP(pix24));
+ break;
+ }
+ }
+
+#if BITMAP_SCANLINE_UNIT == 64
+ /*
+ * cfb24 doesn't currently work on architectures with a 64 bit
+ * BITMAP_SCANLINE_UNIT, so check for 24 bit pixel size for pixmaps
+ * or framebuffers.
+ */
+ {
+ Bool usesCfb24 = FALSE;
+
+ if (PIX24TOBPP(pix24) == 24)
+ usesCfb24 = TRUE;
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->bitsPerPixel == 24)
+ usesCfb24 = TRUE;
+ if (usesCfb24) {
+ FatalError("24-bit pixel size is not supported on systems with"
+ " 64-bit scanlines.\n");
+ }
+ }
+#endif
+
+#ifdef XKB
+ xf86InitXkb();
+#endif
+ /* set up the proper access funcs */
+ xf86PostPreInit();
+
+ AddCallback(&ServerGrabCallback, xf86GrabServerCallback, NULL);
+
+ } else {
/*
* serverGeneration != 1; some OSs have to do things here, too.
*/
xf86OpenConsole();
+
+ /*
+ should we reopen it here? We need to deal with an already opened
+ device. We could leave this to the OS layer. For now we simply
+ close it here
+ */
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+ xf86MsgVerb(3,X_INFO,"APM registered successfully\n");
+
+ /* Make sure full I/O access is enabled */
+ xf86EnableIO();
}
+#if 0
/*
* Install signal handler for unexpected signals
*/
+ xf86Info.caughtSignal=FALSE;
if (!xf86Info.notrapSignals)
{
- xf86Info.caughtSignal=FALSE;
signal(SIGSEGV,xf86SigHandler);
signal(SIGILL,xf86SigHandler);
#ifdef SIGEMT
@@ -301,85 +775,146 @@ InitOutput(pScreenInfo, argc, argv)
signal(SIGXFSZ,xf86SigHandler);
#endif
}
-
+#endif
/*
- * Use the previous collected parts to setup pScreenInfo
+ * Use the previously collected parts to setup pScreenInfo
*/
- pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
- pScreenInfo->numPixmapFormats = numFormats;
- for ( i=0; i < numFormats; i++ ) pScreenInfo->formats[i] = formats[i];
-
- if (generation != serverGeneration)
- {
- xf86ScreenIndex = AllocateScreenPrivateIndex();
- generation = serverGeneration;
- }
-
- for ( i=0;
- i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured;
- i++ )
- {
- /*
- * On a server-reset, we have explicitely to remap all stuff ...
- * (At startuptime this is implicitely done by probing the device
- */
- if (serverGeneration != 1)
- {
- xf86Resetting = TRUE;
- xf86Exiting = FALSE;
+ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+ pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+ pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+ pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+ pScreenInfo->numPixmapFormats = numFormats;
+ for (i = 0; i < numFormats; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ /* Make sure the server's VT is active */
+
+ if (serverGeneration != 1) {
+ xf86Resetting = TRUE;
+ /* All screens are in the same state, so just check the first */
+ if (!xf86Screens[0]->vtSema) {
#ifdef HAS_USL_VTS
- if (!xf86VTSema)
- ioctl(xf86Info.consoleFd,VT_RELDISP,VT_ACKACQ);
+ ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
#endif
- xf86VTSema = TRUE;
- (xf86Screens[i]->EnterLeaveVT)(ENTER, i);
- xf86Resetting = FALSE;
- }
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ }
+ }
#ifdef SCO
- else {
- /*
- * Under SCO we must ack that we got the console at startup,
- * I think this is the safest way to assure it
- */
- static int once = 1;
- if (once) {
- once = 0;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- ErrorF("VT_ACKACQ failed");
- }
- }
+ else {
+ /*
+ * Under SCO we must ack that we got the console at startup,
+ * I think this is the safest way to assure it.
+ */
+ static int once = 1;
+ if (once) {
+ once = 0;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+ xf86Msg(X_WARNING, "VT_ACKACQ failed");
+ }
+ }
#endif /* SCO */
- scr_index = AddScreen(xf86Screens[i]->Init, argc, argv);
- if (scr_index > -1)
- {
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ /*
+ * Almost everything uses these defaults, and many of those that
+ * don't, will wrap them.
+ */
+ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+ xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+ scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+ if (scr_index == i) {
+ /*
+ * Hook in our ScrnInfoRec, and initialise some other pScreen
+ * fields.
+ */
screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
= (pointer)xf86Screens[i];
+ xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+ /* The driver should set this, but make sure it is set anyway */
+ xf86Screens[i]->vtSema = TRUE;
+ } else {
+ /* This shouldn't normally happen */
+ FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
}
+#ifdef DEBUG
+ ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+#endif
+
+ screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
+ = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+#ifdef RENDER
+ if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
+ {
+ xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
+ PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
+ DDC ?
+ (DDC->features.input_type ?
+ SubPixelHorizontalRGB : SubPixelNone) :
+ SubPixelUnknown);
+ }
+#endif
+#ifdef RANDR
+ if (!xf86Info.disableRandR)
+ xf86RandRInit (screenInfo.screens[scr_index]);
+ xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+ xf86Info.disableRandR ? "disabled" : "enabled");
+#endif
+#ifdef NOT_USED
/*
* Here we have to let the driver getting access of the VT. Note that
* this doesn't mean that the graphics board may access automatically
* the monitor. If the monitor is shared this is done in xf86CrossScreen!
*/
if (!xf86Info.sharedMonitor) (xf86Screens[i]->EnterLeaveMonitor)(ENTER);
- }
+#endif
+ }
-#ifndef AMOEBA
- RegisterBlockAndWakeupHandlers(xf86Block, xf86Wakeup, (void *)0);
+#ifdef XFree86LOADER
+ if ((serverGeneration == 1) && LoaderCheckUnresolved(LD_RESOLV_IFDONE)) {
+ /* For now, just a warning */
+ xf86Msg(X_WARNING, "Some symbols could not be resolved!\n");
+ }
#endif
+
+ xf86PostScreenInit();
+
+ xf86InitOrigins();
+
+ xf86Resetting = FALSE;
+ xf86Initialising = FALSE;
+
+ RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
+ NULL);
+}
+
+
+static InputDriverPtr
+MatchInput(IDevPtr pDev)
+{
+ int i;
+
+ for (i = 0; i < xf86NumInputDrivers; i++) {
+ if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+ xf86NameCmp(pDev->driver, xf86InputDriverList[i]->driverName) == 0)
+ return xf86InputDriverList[i];
+ }
+ return NULL;
}
/*
* InitInput --
- * Initialize all supported input devices...what else is there
- * besides pointer and keyboard? Two DeviceRec's are allocated and
- * registered as the system pointer and keyboard devices.
+ * Initialize all supported input devices.
*/
void
@@ -387,129 +922,175 @@ InitInput(argc, argv)
int argc;
char **argv;
{
- xf86Info.vtRequestsPending = FALSE;
- xf86Info.inputPending = FALSE;
+ IDevPtr pDev;
+ InputDriverPtr pDrv;
+ InputInfoPtr pInfo;
+ static InputInfoPtr coreKeyboard = NULL, corePointer = NULL;
+
+ xf86Info.vtRequestsPending = FALSE;
+ xf86Info.inputPending = FALSE;
#ifdef XTESTEXT1
- xtest_command_key = KEY_Begin + MIN_KEYCODE;
+ xtest_command_key = KEY_Begin + MIN_KEYCODE;
#endif /* XTESTEXT1 */
- xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
- xf86Info.pMouse = AddInputDevice(xf86Info.mouseDev->mseProc, TRUE);
- RegisterKeyboardDevice((DevicePtr)xf86Info.pKeyboard);
- RegisterPointerDevice((DevicePtr)xf86Info.pMouse);
-
-#ifdef XINPUT
- (xf86Info.pMouse)->public.devicePrivate = xf86Info.mouseLocal;
-#if 0 /* Is this needed?? */
- ((LocalDevicePtr) xf86Info.mouseLocal)->dev = xf86Info.pMouse;
-#endif
-#else
- (xf86Info.pMouse)->public.devicePrivate = (pointer) xf86Info.mouseDev;
-#endif
-
-#ifdef XINPUT
- InitExtInput();
+ if (serverGeneration == 1) {
+ /* Call the PreInit function for each input device instance. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+ /* XXX The keyboard driver is a special case for now. */
+ if (!xf86NameCmp(pDev->driver, "keyboard")) {
+ xf86Msg(X_INFO, "Keyboard \"%s\" handled by legacy driver\n",
+ pDev->identifier);
+ continue;
+ }
+ if ((pDrv = MatchInput(pDev)) == NULL) {
+ xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
+ /* XXX For now, just continue. */
+ continue;
+ }
+ if (!pDrv->PreInit) {
+ xf86MsgVerb(X_WARNING, 0,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ pDrv->driverName);
+ continue;
+ }
+ pInfo = pDrv->PreInit(pDrv, pDev, 0);
+ if (!pInfo) {
+ xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
+ pDev->identifier);
+ continue;
+ } else if (!(pInfo->flags & XI86_CONFIGURED)) {
+ xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+ pDev->identifier);
+ xf86DeleteInput(pInfo, 0);
+ continue;
+ }
+ if (pInfo->flags & XI86_CORE_KEYBOARD) {
+ if (coreKeyboard) {
+ xf86Msg(X_ERROR,
+ "Attempt to register more than one core keyboard (%s)\n",
+ pInfo->name);
+ pInfo->flags &= ~XI86_CORE_KEYBOARD;
+ } else {
+ if (!(pInfo->flags & XI86_KEYBOARD_CAPABLE)) {
+ /* XXX just a warning for now */
+ xf86Msg(X_WARNING,
+ "%s: does not have core keyboard capabilities\n",
+ pInfo->name);
+ }
+ coreKeyboard = pInfo;
+ }
+ }
+ if (pInfo->flags & XI86_CORE_POINTER) {
+ if (corePointer) {
+ xf86Msg(X_ERROR,
+ "Attempt to register more than one core pointer (%s)\n",
+ pInfo->name);
+ pInfo->flags &= ~XI86_CORE_POINTER;
+ } else {
+ if (!(pInfo->flags & XI86_POINTER_CAPABLE)) {
+ /* XXX just a warning for now */
+ xf86Msg(X_WARNING,
+ "%s: does not have core pointer capabilities\n",
+ pInfo->name);
+ }
+ corePointer = pInfo;
+ }
+ }
+ }
+ if (!corePointer) {
+ xf86Msg(X_WARNING, "No core pointer registered\n");
+ /* XXX register a dummy core pointer */
+ }
+#ifdef NEW_KBD
+ if (!coreKeyboard) {
+ xf86Msg(X_WARNING, "No core keyboard registered\n");
+ /* XXX register a dummy core keyboard */
+ }
#endif
+ }
+
+ /* Initialise all input devices. */
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ xf86ActivateDevice(pInfo);
+ pInfo = pInfo->next;
+ }
- miRegisterPointerDevice(screenInfo.screens[0], (DevicePtr) xf86Info.pMouse);
+ if (coreKeyboard) {
+ xf86Info.pKeyboard = coreKeyboard->dev;
+ xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/
+ }
+ else {
+ xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
+ }
+ if (corePointer)
+ xf86Info.pMouse = corePointer->dev;
+ RegisterKeyboardDevice(xf86Info.pKeyboard);
+
+ miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
#ifdef XINPUT
- xf86XinputFinalizeInit(xf86Info.pMouse);
xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
#else
- mieqInit (xf86Info.pKeyboard, xf86Info.pMouse);
+ mieqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
#endif
}
+#ifndef SET_STDERR_NONBLOCKING
+#define SET_STDERR_NONBLOCKING 1
+#endif
+
/*
* OsVendorInit --
* OS/Vendor-specific initialisations. Called from OsInit(), which
* is called by dix before establishing the well known sockets.
*/
-extern Bool OsDelayInitColors;
-
void
OsVendorInit()
{
+ static Bool beenHere = FALSE;
+
+ /* xf86WrapperInit() is called directly from OsInit() */
#ifdef SIGCHLD
signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
#endif
-#ifdef USE_XF86_SERVERLOCK
- extern void xf86LockServer();
- static Bool been_here = FALSE;
-
- if (!been_here) {
- xf86LockServer();
- been_here = TRUE;
- }
-#endif
OsDelayInitColors = TRUE;
-}
-
-#ifdef DPMSExtension
-extern CARD16 DPMSPowerLevel;
-
-/*
- * DPMSSet --
- * Device dependent DPMS mode setting hook. This is called whenever
- * the DPMS mode is to be changed.
- */
-void
-DPMSSet(CARD16 level)
-{
- int i;
+#ifdef XFree86LOADER
+ loadableFonts = TRUE;
+#endif
- /* For each screen, set the power saver level */
- for (i = 0; i < screenInfo.numScreens; i++) {
- (XF86SCRNINFO(screenInfo.screens[i])->DPMSSet)(level);
- }
+ if (!beenHere)
+ xf86LogInit();
- DPMSPowerLevel = level;
-}
+#if SET_STDERR_NONBLOCKING
+ /* Set stderr to non-blocking. */
+#ifndef O_NONBLOCK
+#if defined(FNDELAY)
+#define O_NONBLOCK FNDELAY
+#elif defined(O_NDELAY)
+#define O_NONBLOCK O_NDELAY
+#endif
+#endif
-#if 0
-/*
- * DPMSGet --
- * Device dependent DPMS mode getting hook. This returns the current
- * DPMS mode, or -1 if DPMS is not supported.
- *
- * This should hook in to the appropriate driver-level function, which
- * will be added to the ScrnInfoRec.
- *
- * NOTES:
- * 1. the calling interface should be changed to specify which
- * screen to check.
- * 2. It isn't clear that this function is ever used.
- */
-CARD16
-DPMSGet(CARD16 *level)
-{
- int i;
+#ifdef O_NONBLOCK
+ if (!beenHere) {
+#if !defined(__EMX__)
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ int status;
- /* For each screen, set the power saver level */
- for (i = 0; i < screenInfo.numScreens; i++) {
- ;
+ status = fcntl(fileno(stderr), F_GETFL, 0);
+ if (status != -1) {
+ fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+ }
}
-}
+ }
+#endif
#endif
-/*
- * DPMSSupported --
- * Return TRUE if any screen supports DPMS.
- */
-Bool
-DPMSSupported(void)
-{
- int i;
-
- /* For each screen, check if DPMS is supported */
- for (i = 0; i < screenInfo.numScreens; i++) {
- if (XF86SCRNINFO(screenInfo.screens[i])->DPMSSet != (void (*)())NoopDDA)
- return TRUE;
- }
- return FALSE;
+ beenHere = TRUE;
}
-#endif /* DPMSExtension */
/*
* ddxGiveUp --
@@ -521,15 +1102,38 @@ DPMSSupported(void)
void
ddxGiveUp()
{
+ int i;
+
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+
+ xf86AccessLeaveState();
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ xf86Screens[i]->access = NULL;
+ xf86Screens[i]->busAccess = NULL;
+ }
+
#ifdef USE_XF86_SERVERLOCK
- xf86UnlockServer();
+ xf86UnlockServer();
#endif
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+
+ xf86CloseConsole();
- xf86CloseConsole();
+ xf86CloseLog();
- /* If an unexpected signal was caught, dump a core for debugging */
- if (xf86Info.caughtSignal)
- abort();
+ /* If an unexpected signal was caught, dump a core for debugging */
+ if (xf86Info.caughtSignal)
+ abort();
}
@@ -546,18 +1150,11 @@ AbortDDX()
{
int i;
-#if 0
- if (xf86Exiting)
- return;
-#endif
-
- xf86Exiting = TRUE;
-
/*
* try to deinitialize all input devices
*/
- if (xf86Info.pMouse) (xf86Info.mouseDev->mseProc)(xf86Info.pMouse, DEVICE_CLOSE);
- if (xf86Info.pKeyboard) (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
+ if (xf86Info.pKeyboard)
+ (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
/*
* try to restore the original video state
@@ -566,14 +1163,25 @@ AbortDDX()
/* Need the sleep when starting X from within another X session */
sleep(1);
#endif
- if (xf86VTSema && xf86ScreensOpen)
- for ( i=0;
- i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured;
- i++ )
- (xf86Screens[i]->EnterLeaveVT)(LEAVE, i);
-
+ if (xf86Screens) {
+ if (xf86Screens[0]->vtSema)
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->vtSema) {
+ /*
+ * if we are aborting before ScreenInit() has finished
+ * we might not have been wrapped yet. Therefore enable
+ * screen explicitely.
+ */
+ xf86EnableAccess(xf86Screens[i]);
+ (xf86Screens[i]->LeaveVT)(i, 0);
+ }
+ }
+
+ xf86AccessLeave();
+
/*
- * This is needed for a abnormal server exit, since the normal exit stuff
+ * This is needed for an abnormal server exit, since the normal exit stuff
* MUST also be performed (i.e. the vt must be left in a defined state)
*/
ddxGiveUp();
@@ -583,7 +1191,11 @@ void
OsVendorFatalError()
{
ErrorF("\nWhen reporting a problem related to a server crash, please send\n"
- "the full server output, not just the last messages\n\n");
+ "the full server output, not just the last messages.\n");
+ if (xf86LogFile && xf86LogFileWasOpened)
+ ErrorF("This can be found in the log file \"%s\".\n", xf86LogFile);
+ ErrorF("Please report problems to %s.\n", BUILDERADDR);
+ ErrorF("\n");
}
/*
@@ -591,24 +1203,81 @@ OsVendorFatalError()
* Process device-dependent command line args. Returns 0 if argument is
* not device dependent, otherwise Count of number of elements of argv
* that are part of a device dependent commandline option.
+ *
*/
+
+
/* ARGSUSED */
int
-ddxProcessArgument (argc, argv, i)
- int argc;
- char *argv[];
- int i;
+ddxProcessArgument(int argc, char **argv, int i)
{
- if (getuid() == 0 && !strcmp(argv[i], "-xf86config"))
+ /*
+ * Note: can't use xalloc/xfree here because OsInit() hasn't been called
+ * yet. Use malloc/free instead.
+ */
+
+#ifdef DDXOSVERRORF
+ static Bool beenHere = FALSE;
+
+ if (!beenHere) {
+ /*
+ * This initialises our hook into VErrorF() for catching log messages
+ * that are generated before OsInit() is called.
+ */
+ OsVendorVErrorFProc = OsVendorVErrorF;
+ beenHere = TRUE;
+ }
+#endif
+
+ /* First the options that are only allowed for root */
+ if (getuid() == 0)
+ {
+ if (!strcmp(argv[i], "-modulepath"))
+ {
+ char *mp;
+ if (!argv[i + 1])
+ return 0;
+ mp = malloc(strlen(argv[i + 1]) + 1);
+ if (!mp)
+ FatalError("Can't allocate memory for ModulePath\n");
+ strcpy(mp, argv[i + 1]);
+ xf86ModulePath = mp;
+ xf86ModPathFrom = X_CMDLINE;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-logfile"))
+ {
+ char *lf;
+ if (!argv[i + 1])
+ return 0;
+ lf = malloc(strlen(argv[i + 1]) + 1);
+ if (!lf)
+ FatalError("Can't allocate memory for LogFile\n");
+ strcpy(lf, argv[i + 1]);
+ xf86LogFile = lf;
+ xf86LogFileFrom = X_CMDLINE;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-xf86config"))
{
- if (!argv[i+1])
+ if (!argv[i + 1])
return 0;
- if (strlen(argv[i+1]) >= PATH_MAX)
- FatalError("XF86Config path name too long\n");
- strcpy(xf86ConfigFile, argv[i+1]);
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for -xf86config\n"
+ "\tFor non-root users, the file specified with -xf86config must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default XF86Config search path.\n\n");
+ }
+ xf86ConfigFile = argv[i + 1];
return 2;
}
+ if (!strcmp(argv[i],"-showunresolved"))
+ {
+ xf86ShowUnresolved = TRUE;
+ return 1;
+ }
if (!strcmp(argv[i],"-probeonly"))
{
xf86ProbeOnly = TRUE;
@@ -622,7 +1291,7 @@ ddxProcessArgument (argc, argv, i)
#ifdef XF86VIDMODE
if (!strcmp(argv[i],"-disableVidMode"))
{
- xf86VidModeEnabled = FALSE;
+ xf86VidModeDisabled = TRUE;
return 1;
}
if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
@@ -634,7 +1303,7 @@ ddxProcessArgument (argc, argv, i)
#ifdef XF86MISC
if (!strcmp(argv[i],"-disableModInDev"))
{
- xf86MiscModInDevEnabled = FALSE;
+ xf86MiscModInDevDisabled = TRUE;
return 1;
}
if (!strcmp(argv[i],"-allowNonLocalModInDev"))
@@ -642,17 +1311,24 @@ ddxProcessArgument (argc, argv, i)
xf86MiscModInDevAllowNonLocal = TRUE;
return 1;
}
+#endif
if (!strcmp(argv[i],"-allowMouseOpenFail"))
{
xf86AllowMouseOpenFail = TRUE;
return 1;
}
-#endif
if (!strcmp(argv[i],"-bestRefresh"))
{
xf86BestRefresh = TRUE;
return 1;
}
+ if (!strcmp(argv[i],"-ignoreABI"))
+ {
+#ifdef XFree86LOADER
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+#endif
+ return 1;
+ }
#ifdef DO_CHECK_BETA
if (!strcmp(argv[i],"-extendExpiry"))
{
@@ -663,8 +1339,34 @@ ddxProcessArgument (argc, argv, i)
#endif
if (!strcmp(argv[i],"-verbose"))
{
- if (!xf86Verbose++)
- xf86Verbose = 2;
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86Verbose = val;
+ return 2;
+ }
+ }
+ xf86Verbose++;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-logverbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86LogVerbose = val;
+ return 2;
+ }
+ }
+ xf86LogVerbose++;
return 1;
}
if (!strcmp(argv[i],"-quiet"))
@@ -675,7 +1377,6 @@ ddxProcessArgument (argc, argv, i)
if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
{
xf86PrintBanner();
- xf86PrintConfig();
exit(0);
}
/* Notice the -fp flag, but allow it to pass to the dix layer */
@@ -690,26 +1391,72 @@ ddxProcessArgument (argc, argv, i)
xf86coFlag = TRUE;
return 0;
}
+ /* Notice the -bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-bs"))
+ {
+ xf86bsDisableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the +bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "+bs"))
+ {
+ xf86bsEnableFlag = TRUE;
+ return 0;
+ }
/* Notice the -s flag, but allow it to pass to the dix layer */
if (!strcmp(argv[i], "-s"))
{
xf86sFlag = TRUE;
return 0;
}
-#ifndef XF86MONOVGA
if (!strcmp(argv[i], "-bpp"))
{
+ if (++i >= argc)
+ return 0;
+ ErrorF("The -bpp option is no longer supported.\n"
+ "\tUse -depth to set the color depth, and use -fbbpp if you really\n"
+ "\tneed to force a non-default framebuffer (hardware) pixel format.\n");
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pixmap24"))
+ {
+ xf86Pix24 = Pix24Use24;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-pixmap32"))
+ {
+ xf86Pix24 = Pix24Use32;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-fbbpp"))
+ {
int bpp;
if (++i >= argc)
return 0;
if (sscanf(argv[i], "%d", &bpp) == 1)
{
- xf86bpp = bpp;
+ xf86FbBpp = bpp;
return 2;
}
else
{
- ErrorF("Invalid bpp\n");
+ ErrorF("Invalid fbbpp\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-depth"))
+ {
+ int depth;
+ if (++i >= argc)
+ return 0;
+ if (sscanf(argv[i], "%d", &depth) == 1)
+ {
+ xf86Depth = depth;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid depth\n");
return 0;
}
}
@@ -720,9 +1467,9 @@ ddxProcessArgument (argc, argv, i)
return 0;
if (sscanf(argv[i], "%1d%1d%1d", &red, &green, &blue) == 3)
{
- xf86weight.red = red;
- xf86weight.green = green;
- xf86weight.blue = blue;
+ xf86Weight.red = red;
+ xf86Weight.green = green;
+ xf86Weight.blue = blue;
return 2;
}
else
@@ -738,23 +1485,78 @@ ddxProcessArgument (argc, argv, i)
if (++i >= argc)
return 0;
if (sscanf(argv[i], "%lf", &gamma) == 1) {
- if (gamma < 0.1 || gamma > 10) {
- ErrorF("gamma out of range, only 0.1 < gamma_value < 10 is valid\n");
+ if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+ ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
+ " is valid\n", GAMMA_MIN, GAMMA_MAX);
return 0;
}
- if (!strcmp(argv[i-1], "-gamma"))
- xf86rGamma = xf86gGamma = xf86bGamma = 1.0 / gamma;
- else if (!strcmp(argv[i-1], "-rgamma")) xf86rGamma = 1.0 / gamma;
- else if (!strcmp(argv[i-1], "-ggamma")) xf86gGamma = 1.0 / gamma;
- else if (!strcmp(argv[i-1], "-bgamma")) xf86bGamma = 1.0 / gamma;
+ if (!strcmp(argv[i-1], "-gamma"))
+ xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+ else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
+ else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
+ else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
return 2;
}
}
-#endif /* XF86MONOVGA */
+ if (!strcmp(argv[i], "-layout"))
+ {
+ if (++i >= argc)
+ return 0;
+ xf86LayoutName = argv[i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-screen"))
+ {
+ if (++i >= argc)
+ return 0;
+ xf86ScreenName = argv[i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pointer"))
+ {
+ if (++i >= argc)
+ return 0;
+ xf86PointerName = argv[i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-keyboard"))
+ {
+ if (++i >= argc)
+ return 0;
+ xf86KeyboardName = argv[i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-nosilk"))
+ {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-scanpci"))
+ {
+ DoScanPci(argc, argv, i);
+ }
+ if (!strcmp(argv[i], "-probe"))
+ {
+ xf86DoProbe = TRUE;
+#if 0
+ DoProbe(argc, argv, i);
+#endif
+ return 1;
+ }
+ if (!strcmp(argv[i], "-configure"))
+ {
+ if (getuid() != 0) {
+ ErrorF("The '-configure' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoConfigure = TRUE;
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ /* OS-specific processing */
return xf86ProcessArgument(argc, argv, i);
}
-
/*
* ddxUseMsg --
* Print out correct use of device dependent commandline options.
@@ -768,18 +1570,36 @@ ddxUseMsg()
ErrorF("\n");
ErrorF("Device Dependent Usage\n");
if (getuid() == 0)
+ {
ErrorF("-xf86config file specify a configuration file\n");
+ ErrorF("-modulepath paths specify the module search path\n");
+ ErrorF("-logfile file specify a log file name\n");
+ ErrorF("-configure probe for devices and write an XF86Config\n");
+ }
+ else
+ {
+ ErrorF("-xf86config file specify a configuration file, relative to the\n");
+ ErrorF(" XF86Config search path, only root can use absolute\n");
+ }
ErrorF("-probeonly probe for devices, then exit\n");
- ErrorF("-verbose verbose startup messages\n");
+ ErrorF("-scanpci execute the scanpci module and exit\n");
+ ErrorF("-verbose [n] verbose startup messages\n");
+ ErrorF("-logverbose [n] verbose log messages\n");
ErrorF("-quiet minimal startup messages\n");
-#ifndef XF86MONOVGA
- ErrorF("-bpp n set number of bits per pixel. Default: 8\n");
+ ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
+ ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
+ ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
+ ErrorF("-depth n set colour depth. Default: 8\n");
ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
ErrorF("-rgamma f set gamma value for red phase\n");
ErrorF("-ggamma f set gamma value for green phase\n");
ErrorF("-bgamma f set gamma value for blue phase\n");
ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
-#endif /* XF86MONOVGA */
+ ErrorF("-layout name specify the ServerLayout section name\n");
+ ErrorF("-screen name specify the Screen section name\n");
+ ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
+ ErrorF("-pointer name specify the core pointer InputDevice name\n");
+ ErrorF("-nosilk disable Silken Mouse\n");
ErrorF("-flipPixels swap default black/white Pixel values\n");
#ifdef XF86VIDMODE
ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
@@ -791,44 +1611,230 @@ ddxUseMsg()
ErrorF(" from non-local clients\n");
ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
#endif
- ErrorF("-bestRefresh Chose modes with the best refresh rate\n");
- ErrorF(
- "-showconfig show which drivers are included in the server\n");
+ ErrorF("-bestRefresh choose modes with the best refresh rate\n");
+ ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+ ErrorF("-version show the server version\n");
+ /* OS-specific usage */
xf86UseMsg();
ErrorF("\n");
}
#ifndef OSNAME
-#define OSNAME "unknown"
+#define OSNAME " unknown"
#endif
#ifndef OSVENDOR
#define OSVENDOR ""
#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XF86_VERSION_SNAP
+#endif
static void
xf86PrintBanner()
{
- ErrorF("\nXFree86 Version%s/ X Window System\n",XF86_VERSION);
- ErrorF("(protocol Version %d, revision %d, vendor release %d)\n",
- X_PROTOCOL, X_PROTOCOL_REVISION, VENDOR_RELEASE );
- ErrorF("Release Date: %s\n", XF86_DATE);
- ErrorF("\tIf the server is older than 6-12 months, or if your card is "
- "newer\n"
- "\tthan the above date, look for a newer version before "
- "reporting\n"
- "\tproblems. (see http://www.XFree86.Org/FAQ)\n");
- ErrorF("Operating System: %s %s\n", OSNAME, OSVENDOR);
+#if PRE_RELEASE
+ ErrorF("\n"
+ "This is a pre-release version of XFree86, and is not supported in any\n"
+ "way. Bugs may be reported to XFree86@XFree86.Org and patches submitted\n"
+ "to fixes@XFree86.Org. Before reporting bugs in pre-release versions,\n"
+ "please check the latest version in the XFree86 CVS repository\n"
+ "(http://www.XFree86.Org/cvs).\n");
+#endif
+ ErrorF("\nXFree86 Version %d.%d.%d", XF86_VERSION_MAJOR, XF86_VERSION_MINOR,
+ XF86_VERSION_PATCH);
+#if XF86_VERSION_SNAP > 0
+ ErrorF(".%d", XF86_VERSION_SNAP);
+#endif
+
+#if XF86_VERSION_SNAP >= 900
+ ErrorF(" (%d.%d.0 RC %d)", XF86_VERSION_MAJOR, XF86_VERSION_MINOR + 1,
+ XF86_VERSION_SNAP - 900);
+#endif
+
+#ifdef XF86_CUSTOM_VERSION
+ ErrorF(" (%s)", XF86_CUSTOM_VERSION);
+#endif
+ ErrorF("\nRelease Date: %s\n", XF86_DATE);
+ ErrorF("X Protocol Version %d, Revision %d, %s\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+ ErrorF("Build Operating System:%s%s\n", OSNAME, OSVENDOR);
+#ifdef BUILD_DATE
+ {
+ struct tm t;
+ char buf[100];
+
+ bzero(&t, sizeof(t));
+ bzero(buf, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ ErrorF("Build Date: %s\n", buf);
+ }
+#endif
+#if defined(BUILDERSTRING)
+ ErrorF("%s \n",BUILDERSTRING);
+#endif
+ ErrorF("\tBefore reporting problems, check http://www.XFree86.Org/\n"
+ "\tto make sure that you have the latest version.\n");
+#ifdef XFree86LOADER
+ ErrorF("Module Loader present\n");
+#endif
}
static void
-xf86PrintConfig()
+xf86PrintMarkers()
{
- int i;
+ /* Show what the marker symbols mean */
+ ErrorF("Markers: " X_PROBE_STRING " probed, "
+ X_CONFIG_STRING " from config file, "
+ X_DEFAULT_STRING " default setting,\n"
+ " " X_CMDLINE_STRING " from command line, "
+ X_NOTICE_STRING " notice, "
+ X_INFO_STRING " informational,\n"
+ " " X_WARNING_STRING " warning, "
+ X_ERROR_STRING " error, "
+ X_NOT_IMPLEMENTED_STRING " not implemented, "
+ X_UNKNOWN_STRING " unknown.\n");
+}
+
+static void
+xf86RunVtInit(void)
+{
+ int i;
+
+ /*
+ * If VTInit was set, run that program with consoleFd as stdin and stdout
+ */
+
+ if (xf86Info.vtinit) {
+ switch(fork()) {
+ case -1:
+ FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
+ break;
+ case 0: /* child */
+ setuid(getuid());
+ /* set stdin, stdout to the consoleFd */
+ for (i = 0; i < 2; i++) {
+ if (xf86Info.consoleFd != i) {
+ close(i);
+ dup(xf86Info.consoleFd);
+ }
+ }
+ execl("/bin/sh", "sh", "-c", xf86Info.vtinit, (void *)NULL);
+ xf86Msg(X_WARNING, "exec of /bin/sh failed for VTInit (%s)\n",
+ strerror(errno));
+ exit(255);
+ break;
+ default: /* parent */
+ wait(NULL);
+ }
+ }
+}
+
+#ifdef XFree86LOADER
+/*
+ * xf86LoadModules iterates over a list that is being passed in.
+ */
+Bool
+xf86LoadModules(char **list, pointer *optlist)
+{
+ int errmaj, errmin;
+ pointer opt;
+ int i;
+ char *name;
+ Bool failed = FALSE;
+
+ if (!list)
+ return TRUE;
+
+ for (i = 0; list[i] != NULL; i++) {
+
+#ifndef NORMALISE_MODULE_NAME
+ name = xstrdup(list[i]);
+#else
+ /* Normalise the module name */
+ name = xf86NormalizeName(list[i]);
+#endif
+
+ /* Skip empty names */
+ if (name == NULL || *name == '\0')
+ continue;
+
+ if (optlist)
+ opt = optlist[i];
+ else
+ opt = NULL;
+
+ if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ failed = TRUE;
+ }
+ xfree(name);
+ }
+ return !failed;
+}
+
+#endif
+
+/* Pixmap format stuff */
- ErrorF("Configured drivers:\n");
- for (i = 0; i < xf86MaxScreens; i++)
- if (xf86Screens[i])
- (xf86Screens[i]->PrintIdent)();
+PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
+{
+ int i;
+ static PixmapFormatRec format; /* XXX not reentrant */
+
+ /*
+ * When the formats[] list initialisation isn't complete, check the
+ * depth 24 pixmap config/cmdline options and screen-specified formats.
+ */
+
+ if (!formatsDone) {
+ if (depth == 24) {
+ Pix24Flags pix24 = Pix24DontCare;
+
+ format.depth = 24;
+ format.scanlinePad = BITMAP_SCANLINE_PAD;
+ if (xf86Info.pixmap24 != Pix24DontCare)
+ pix24 = xf86Info.pixmap24;
+ else if (pScrn->pixmap24 != Pix24DontCare)
+ pix24 = pScrn->pixmap24;
+ if (pix24 == Pix24Use24)
+ format.bitsPerPixel = 24;
+ else
+ format.bitsPerPixel = 32;
+ return &format;
+ }
+ }
+
+ for (i = 0; i < numFormats; i++)
+ if (formats[i].depth == depth)
+ break;
+ if (i != numFormats)
+ return &formats[i];
+ else if (!formatsDone) {
+ /* Check for screen-specified formats */
+ for (i = 0; i < pScrn->numFormats; i++)
+ if (pScrn->formats[i].depth == depth)
+ break;
+ if (i != pScrn->numFormats)
+ return &pScrn->formats[i];
+ }
+ return NULL;
+}
+
+int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
+{
+ PixmapFormatPtr format;
+
+
+ format = xf86GetPixFormat(pScrn, depth);
+ if (format)
+ return format->bitsPerPixel;
+ else
+ return 0;
}
diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c
index 6fddb5e89..06819bccf 100644
--- a/hw/xfree86/common/xf86Io.c
+++ b/hw/xfree86/common/xf86Io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.28.2.5 1998/02/24 19:05:55 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.53 2003/01/15 03:29:05 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,8 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86Io.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */
-/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */
+/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
#define NEED_EVENTS
#include "X.h"
@@ -32,12 +31,16 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
+#include "mipointer.h"
#ifdef XINPUT
#include "xf86Xinput.h"
+#include "XIproto.h"
+#include "exevents.h"
#endif
#ifdef XKB
@@ -46,18 +49,12 @@
#include <X11/extensions/XKBsrv.h>
#endif
-extern KeybdCtrl defaultKeyboardControl;
-
unsigned int xf86InitialCaps = 0;
unsigned int xf86InitialNum = 0;
unsigned int xf86InitialScroll = 0;
#include "atKeynames.h"
-extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
- unsigned long start, unsigned long stop,
- ScreenPtr pScreen);
-
/*
* xf86KbdBell --
* Ring the terminal/keyboard bell for an amount of time proportional to
@@ -74,50 +71,58 @@ xf86KbdBell(percent, pKeyboard, ctrl, unused)
xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
}
-#ifdef AMOEBA
-#define LED_CAP IOP_LED_CAP
-#define LED_NUM IOP_LED_NUM
-#define LED_SCR IOP_LED_SCROLL
-#endif
-
-#ifdef MINIX
-#define LED_CAP KBD_LEDS_CAPS
-#define LED_NUM KBD_LEDS_NUM
-#define LED_SCR KBD_LEDS_SCROLL
-#endif
+void
+xf86UpdateKbdLeds()
+{
+ int leds = 0;
+ if (xf86Info.capsLock) leds |= XLED1;
+ if (xf86Info.numLock) leds |= XLED2;
+ if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3;
+ if (xf86Info.composeLock) leds |= XLED4;
+ xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds);
+ xf86KbdLeds();
+}
void
xf86KbdLeds ()
{
- int leds = 0;
-#ifdef XKB
- if (!noXkbExtension) {
- XkbEventCauseRec cause;
- XkbSetCauseUnknown(&cause);
- XkbUpdateIndicators((DeviceIntPtr)xf86Info.pKeyboard,
- XkbAllIndicatorsMask, False, NULL, &cause);
- return;
+ int leds, real_leds = 0;
+
+#if defined (__sparc__)
+ static int kbdSun = -1;
+ if (kbdSun == -1) {
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) ||
+ (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
+ kbdSun = 1;
+ else
+ kbdSun = 0;
}
-#endif
-#ifdef LED_CAP
- if (xf86Info.capsLock && !(xf86Info.xleds & XLED1))
- leds |= LED_CAP;
-
- if (xf86Info.numLock && !(xf86Info.xleds & XLED2))
- leds |= LED_NUM;
-
- if ((xf86Info.scrollLock ||
- xf86Info.modeSwitchLock ||
- xf86Info.composeLock) &&
- !(xf86Info.xleds & XLED3))
- leds |= LED_SCR;
-
- if ((xf86Info.leds & xf86Info.xleds) & XLED1) leds |= LED_CAP;
- if ((xf86Info.leds & xf86Info.xleds) & XLED2) leds |= LED_NUM;
- if ((xf86Info.leds & xf86Info.xleds) & XLED3) leds |= LED_SCR;
+ if (kbdSun) {
+ if (xf86Info.leds & 0x08) real_leds |= XLED1;
+ if (xf86Info.leds & 0x04) real_leds |= XLED3;
+ if (xf86Info.leds & 0x02) real_leds |= XLED4;
+ if (xf86Info.leds & 0x01) real_leds |= XLED2;
+ leds = real_leds;
+ real_leds = 0;
+ } else {
+ leds = xf86Info.leds;
+ }
+#else
+ leds = xf86Info.leds;
+#endif /* defined (__sparc__) */
- xf86SetKbdLeds(leds);
-#endif /* LED_CAP */
+#ifdef LED_CAP
+ if (leds & XLED1) real_leds |= LED_CAP;
+ if (leds & XLED2) real_leds |= LED_NUM;
+ if (leds & XLED3) real_leds |= LED_SCR;
+#ifdef LED_COMP
+ if (leds & XLED4) real_leds |= LED_COMP;
+#else
+ if (leds & XLED4) real_leds |= LED_SCR;
+#endif
+#endif
+ xf86SetKbdLeds(real_leds);
+ return;
}
/*
@@ -131,19 +136,30 @@ xf86KbdCtrl (pKeyboard, ctrl)
DevicePtr pKeyboard; /* Keyboard to alter */
KeybdCtrl *ctrl;
{
+ int leds;
xf86Info.bell_pitch = ctrl->bell_pitch;
xf86Info.bell_duration = ctrl->bell_duration;
xf86Info.autoRepeat = ctrl->autoRepeat;
- xf86Info.leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
xf86Info.composeLock = (ctrl->leds & XCOMP) ? TRUE : FALSE;
+ leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds);
+#ifdef XKB
+ } else {
+ xf86Info.leds = leds;
+ }
+#endif
+
xf86KbdLeds();
}
/*
* xf86InitKBD --
- * Reinitialize the keyboard. Only set Lockkeys accrding to ours leds.
+ * Reinitialize the keyboard. Only set Lockkeys according to ours leds.
* Depress all other keys.
*/
@@ -158,7 +174,6 @@ Bool init;
KeyClassRec *keyc = xf86Info.pKeyboard->key;
KeySym *map = keyc->curKeySyms.map;
-#ifndef MACH386
kevent.u.keyButtonPointer.time = GetTimeInMillis();
kevent.u.keyButtonPointer.rootX = 0;
kevent.u.keyButtonPointer.rootY = 0;
@@ -192,7 +207,6 @@ Bool init;
(* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
}
}
-#endif /* MACH386 */
xf86Info.scanPrefix = 0;
@@ -314,7 +328,10 @@ xf86KbdProc (pKeyboard, what)
(KbdCtrlProcPtr)xf86KbdCtrl);
#ifdef XKB
} else {
- XkbComponentNamesRec names;
+ XkbComponentNamesRec names;
+ XkbDescPtr desc;
+ Bool foundTerminate = FALSE;
+ int keyc;
if (XkbInitialMap) {
if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
xf86Info.xkbkeymap++;
@@ -343,12 +360,30 @@ xf86KbdProc (pKeyboard, what)
XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
xf86Info.xkblayout, xf86Info.xkbvariant,
xf86Info.xkboptions);
+
XkbInitKeyboardDeviceStruct(pKeyboard,
&names,
&keySyms,
modMap,
xf86KbdBell,
(KbdCtrlProcPtr)xf86KbdCtrl);
+
+ /* Search keymap for Terminate action */
+ desc = pKeyboard->key->xkbInfo->desc;
+ for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) {
+ int i;
+ for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) {
+ if (XkbKeyAction(desc, keyc, i)
+ && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) {
+ foundTerminate = TRUE;
+ goto searchdone;
+ }
+ }
+ }
+searchdone:
+ xf86Info.ActionKeyBindingsSet = foundTerminate;
+ if (!foundTerminate)
+ xf86Msg(X_INFO, "Server_Terminate keybinding not found\n");
}
#endif
@@ -367,15 +402,21 @@ xf86KbdProc (pKeyboard, what)
* passing on parts of the VT switch sequence.
*/
sleep(1);
- if (kbdFd != -1) {
- char buf[16];
- read(kbdFd, buf, 16);
+#if defined(WSCONS_SUPPORT)
+ if (xf86Info.consType != WSCONS) {
+#endif
+ if (kbdFd != -1) {
+ char buf[16];
+ read(kbdFd, buf, 16);
+ }
+#if defined(WSCONS_SUPPORT)
}
+#endif
-#ifndef __EMX__ /* Under EMX, keyboard cannot be select()'ed */
+#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
if (kbdFd != -1)
AddEnabledDevice(kbdFd);
-#endif /* __EMX__ */
+#endif /* __UNIXOS2__ */
pKeyboard->public.on = TRUE;
xf86InitKBD(FALSE);
@@ -399,144 +440,31 @@ xf86KbdProc (pKeyboard, what)
return (Success);
}
-/*
- * xf86MseCtrl --
- * Alter the control parameters for the mouse. Note that all special
- * protocol values are handled by dix.
- */
-
-void
-xf86MseCtrl(pPointer, ctrl)
- DevicePtr pPointer;
- PtrCtrl *ctrl;
-{
- MouseDevPtr mouse = MOUSE_DEV((DeviceIntPtr) pPointer);
-
- mouse->num = ctrl->num;
- mouse->den = ctrl->den;
- mouse->threshold = ctrl->threshold;
-}
-
-/*
- * xf86MseProc --
- * Handle the initialization, etc. of a mouse
- */
-
-int
-xf86MseProc(pPointer, what)
- DeviceIntPtr pPointer;
- int what;
-{
- MouseDevPtr mouse = MOUSE_DEV(pPointer);
-
- mouse->device = pPointer;
-
- return xf86MseProcAux(pPointer, what, mouse, NULL,
- (PtrCtrlProcPtr)xf86MseCtrl);
-}
-
-int
-xf86MseProcAux(pPointer, what, mouse, fd, ctrl)
- DeviceIntPtr pPointer;
- int what;
- MouseDevPtr mouse;
- int *fd;
- PtrCtrlProcPtr ctrl;
-{
- unsigned char map[MSE_MAXBUTTONS + 1];
- int nbuttons;
- int mousefd;
-
- switch (what)
- {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- /*
- * [KAZU-241097] We don't know exactly how many buttons the
- * device has...
- */
- for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
- map[nbuttons + 1] = nbuttons + 1;
-
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- min(mouse->buttons, MSE_MAXBUTTONS),
- miPointerGetMotionEvents,
- ctrl,
- miPointerGetMotionBufferSize());
-
- xf86MouseInit(mouse);
-
- break;
-
- case DEVICE_ON:
-
- mousefd = xf86MouseOn(mouse);
-
- if (fd)
- *fd = mousefd;
-
- if (mousefd != -1) {
- if (mousefd == -2) {
- if (fd)
- *fd = -1;
- } else {
- if (mouse->mseType == P_PS2)
- write(mousefd, "\364", 1);
-
- AddEnabledDevice(mousefd);
- }
- mouse->lastButtons = 0;
- mouse->emulateState = 0;
- pPointer->public.on = TRUE;
- } else {
- return !Success;
- }
-
- break;
-
- case DEVICE_OFF:
- case DEVICE_CLOSE:
-
- mousefd = xf86MouseOff(mouse, what == DEVICE_CLOSE);
-
- if (mousefd != -1)
- RemoveEnabledDevice(mousefd);
-
- pPointer->public.on = FALSE;
- usleep(300000);
- break;
- }
- return Success;
-}
-
-/*
- * xf86MseEvents --
- * Read the new events from the device, and pass them to the eventhandler.
- * This should is not used if there is only an OS_MOUSE driver.
- */
-#ifndef OSMOUSE_ONLY
-void
-xf86MseEvents(mouse)
- MouseDevPtr mouse;
-{
- xf86MouseEvents(mouse);
-}
-#endif
-
-#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__)
+#if defined(DDXTIME) && !defined(QNX4)
/*
* These are getting tossed in here until I can think of where
* they really belong
*/
+#define HALFMONTH ((unsigned long) 1<<31)
CARD32
GetTimeInMillis()
{
struct timeval tp;
+ register CARD32 val;
+ register INT32 diff;
+ static CARD32 oldval = 0;
+ static CARD32 time = 0;
gettimeofday(&tp, 0);
- return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ val = (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ if (oldval) {
+ diff = val - oldval;
+ if (diff > 0)
+ time += diff;
+ }
+ oldval = val;
+
+ return time;
}
-#endif /* !AMOEBA && !(sun || SVR4) && !MINIX */
+#endif /* DDXTIME && !QNX4 */
diff --git a/hw/xfree86/common/xf86Kbd.c b/hw/xfree86/common/xf86Kbd.c
index f263937a2..c1ad79778 100644
--- a/hw/xfree86/common/xf86Kbd.c
+++ b/hw/xfree86/common/xf86Kbd.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.14 1997/01/05 11:58:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.24 2002/05/31 18:45:58 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,7 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86Kbd.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
+/* $XConsortium: xf86Kbd.c /main/10 1996/02/21 17:38:32 kaleb $ */
#include "X.h"
#include "Xmd.h"
@@ -30,13 +30,27 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "atKeynames.h"
-#include "xf86_Config.h"
+#include "xf86Config.h"
#include "xf86Keymap.h"
+#if defined(KDGKBTYPE) && \
+ !defined(Lynx) && \
+ !defined(__UNIXOS2__) && !defined(__mips__) && \
+ !defined(__arm32__) && !defined(__GNU__) && !defined(__QNX__)
+#define HAS_GETKBTYPE
+#endif
+#if defined(GIO_KEYMAP) && \
+ !defined(Lynx) && \
+ !defined(__UNIXOS2__) && !defined(__mips__) && \
+ !defined(__arm32__) && !defined(__GNU__) && !defined(DGUX) && \
+ !defined(__QNX__)
+#define HAS_GETKEYMAP
+
#define KD_GET_ENTRY(i,n) \
eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
@@ -208,6 +222,7 @@ static KeySym eascii_to_x[512] = {
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
};
+#endif /* HAS_GETKEYMAP */
/*
* LegalModifier --
@@ -238,14 +253,15 @@ xf86KbdGetMapping (pKeySyms, pModMap)
CARD8 *pModMap;
{
KeySym *k;
-#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__)
+#ifdef HAS_GETKEYMAP
keymap_t keymap;
-#endif /* !Lynx && !AMOEBA && !MINIX && !__OSF__ && !__EMX__ */
- char type;
- int i, j;
+#endif
+ int i;
KeySym *pMap;
+
+#ifdef HAS_GETKBTYPE
+ char type;
-#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__)
xf86Info.kbdType =
ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
if (xf86Info.kbdType == KB_84)
@@ -253,11 +269,14 @@ xf86KbdGetMapping (pKeySyms, pModMap)
else
pMap = map;
#else
+/* OS/2 sets the keyboard type during xf86OpenKbd */
+#ifndef __UNIXOS2__
xf86Info.kbdType = 0;
+#endif
pMap = map;
#endif
-#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__)
+#ifdef HAS_GETKEYMAP
/*
* use the keymap, which can be gotten from our oringinal vt??.
* ( ttymap(1) !!!! )
@@ -280,59 +299,7 @@ xf86KbdGetMapping (pKeySyms, pModMap)
if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
}
}
-#endif /* !Lynx && !AMOEBA && !MINIX && !__OSF__ && !__EMX__ */
-
- /*
- * Apply the special key mapping specified in XF86Config
- */
- for (k = pMap, i = MIN_KEYCODE;
- i < (NUM_KEYCODES + MIN_KEYCODE);
- i++, k += 4) {
- switch (k[0]) {
- case XK_Alt_L:
- j = K_INDEX_LEFTALT;
- break;
- case XK_Alt_R:
- j = K_INDEX_RIGHTALT;
- break;
- case XK_Scroll_Lock:
- j = K_INDEX_SCROLLLOCK;
- break;
- case XK_Control_R:
- j = K_INDEX_RIGHTCTL;
- break;
- default:
- j = -1;
- }
- if (j >= 0)
- switch (xf86Info.specialKeyMap[j]) {
- case KM_META:
- if (k[0] == XK_Alt_R)
- k[1] = XK_Meta_R;
- else {
- k[0] = XK_Alt_L;
- k[1] = XK_Meta_L;
- }
- break;
- case KM_COMPOSE:
- k[0] = XK_Multi_key;
- break;
- case KM_MODESHIFT:
- k[0] = XK_Mode_switch;
- k[1] = NoSymbol;
- break;
- case KM_MODELOCK:
- k[0] = XK_Mode_switch;
- k[1] = XF86XK_ModeLock;
- break;
- case KM_SCROLLLOCK:
- k[0] = XK_Scroll_Lock;
- break;
- case KM_CONTROL:
- k[0] = XK_Control_R;
- break;
- }
- }
+#endif
/*
* compute the modifier map
@@ -366,7 +333,7 @@ xf86KbdGetMapping (pKeySyms, pModMap)
break;
case XK_Num_Lock:
- if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ pModMap[i] = NumLockMask;
break;
case XK_Scroll_Lock:
@@ -386,22 +353,8 @@ xf86KbdGetMapping (pKeySyms, pModMap)
}
-#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__)
- xf86Info.kbdType =
- ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-#else
-/* OS/2 sets the keyboard type during xf86OpenKbd */
-#ifndef __EMX__
- xf86Info.kbdType = 0;
-#endif
-#endif
-
-
pKeySyms->map = pMap;
pKeySyms->mapWidth = GLYPHS_PER_KEY;
pKeySyms->minKeyCode = MIN_KEYCODE;
- if (xf86Info.serverNumLock)
- pKeySyms->maxKeyCode = MAX_KEYCODE;
- else
- pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
}
diff --git a/hw/xfree86/common/xf86KbdBSD.c b/hw/xfree86/common/xf86KbdBSD.c
index bf880dd68..a606b14fb 100644
--- a/hw/xfree86/common/xf86KbdBSD.c
+++ b/hw/xfree86/common/xf86KbdBSD.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.10 1996/12/23 06:43:30 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.20 2002/05/22 21:38:27 herrb Exp $ */
/*
* Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
* which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
@@ -22,7 +22,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Xorg: xf86KbdBSD.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
+/* $XConsortium: xf86KbdBSD.c /main/6 1996/10/23 13:12:27 kaleb $ */
#include "X.h"
#include "Xmd.h"
@@ -31,22 +31,17 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "atKeynames.h"
-#include "xf86_Config.h"
-#include "coKeynames.h"
#include "xf86Keymap.h"
+#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
#define KD_GET_ENTRY(i,n) \
eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-#ifndef __bsdi__
-static KeySym coGetKeysym();
-#endif
-
-#ifndef PC98
-static unsigned char remap[128] = {
+static unsigned char remap[NUM_KEYCODES] = {
0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
@@ -64,27 +59,6 @@ static unsigned char remap[128] = {
0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
};
-#else /* PC98 */
-static unsigned char remap[128] = {
- 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0, 0, 0, /* 0x30 - 0x37 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x38 - 0x3f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x47 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
- 0, 0, 0x52, 0x53, 0x54, 0x55, 0x56, 0, /* 0x50 - 0x57 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 - 0x67 */
- 0x68, 0x69, 0x6a, 0x6b, 0, 0, 0, 0, /* 0x68 - 0x6f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0, 0, 0, /* 0x70 - 0x77 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
-};
-#endif /* PC98 */
-
/* This table assumes the ibm code page 437 coding for characters
* > 0x80. They are returned in this form by PCVT */
@@ -158,6 +132,74 @@ static KeySym eascii_to_x[512] = {
* special marked entries (256 + x)
*/
+#if 1
+ /* This has been checked against what syscons actually does */
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ XK_ISO_Left_Tab,XK_Control_L, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Control_R, XK_Alt_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol
+#else
+ /* The old table, supposedly for pcvt. */
NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
@@ -221,6 +263,8 @@ static KeySym eascii_to_x[512] = {
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol
+#endif
};
#ifdef __OpenBSD__
@@ -314,6 +358,7 @@ static KeySym latin1_to_x[256] = {
XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
};
#endif
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
/*
* LegalModifier --
* determine whether a key is a legal modifier key, i.e send a
@@ -341,8 +386,7 @@ xf86KbdGetMapping (pKeySyms, pModMap)
CARD8 *pModMap;
{
KeySym *k;
- char type;
- int i, j;
+ int i;
#ifndef __bsdi__
switch (xf86Info.consType) {
@@ -453,7 +497,10 @@ xf86KbdGetMapping (pKeySyms, pModMap)
break;
#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+/*
+ * XXX wscons has no GIO_KEYMAP
+ */
+#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
case SYSCONS:
case PCVT:
{
@@ -461,11 +508,7 @@ xf86KbdGetMapping (pKeySyms, pModMap)
if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-#ifdef PC98
- if (remap[i] || i == 0) {
-#else
if (remap[i]) {
-#endif
k = map + (remap[i] << 2);
k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
k[1] = KD_GET_ENTRY(i,1); /* shifted */
@@ -482,102 +525,10 @@ xf86KbdGetMapping (pKeySyms, pModMap)
break;
#endif /* SYSCONS || PCVT */
-#ifdef CODRV_SUPPORT
- case CODRV011:
- case CODRV01X:
- for (i=1; i<= 128; i++) {
- struct kbd_ovlkey cokeymap;
- struct oldkbd_ovlkey ocokeymap;
- KeySym coGetKeysym();
-
- if (xf86Info.consType == CODRV011) {
- ocokeymap.keynum = i;
- if (ioctl(xf86Info.consoleFd, OLDKBDGCKEY, &ocokeymap) < 0)
- break; /* Don't try again if it fails once */
- if ((ocokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
- k = map + (xf86CodrvMap[i] << 2);
- k[0] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.unshift,k[0]);
- k[1] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.shift,k[1]);
- k[2] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.altgr,k[2]);
- k[3] = NoSymbol;
- }
- } else {
- cokeymap.keynum = i;
- if (ioctl(xf86Info.consoleFd, KBDGCKEY, &cokeymap) < 0)
- break; /* Don't try again if it fails once */
- if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
- k = map + (xf86CodrvMap[i] << 2);
- k[0] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.unshift,k[0]);
- k[1] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shift,k[1]);
- k[2] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.altgr,k[2]);
- k[3] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shiftaltgr,k[3]);
- }
- }
- if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
- if (k[3] == k[2]) k[3] = NoSymbol;
- if (k[2] == k[1]) k[2] = NoSymbol;
- if (k[1] == k[0]) k[1] = NoSymbol;
- if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
- }
- }
- break;
-#endif /* CODRV */
}
#endif /* !bsdi */
/*
- * Apply the special key mapping specified in XF86Config
- */
- for (k = map, i = MIN_KEYCODE;
- i < (NUM_KEYCODES + MIN_KEYCODE);
- i++, k += 4) {
- switch (k[0]) {
- case XK_Alt_L:
- j = K_INDEX_LEFTALT;
- break;
- case XK_Alt_R:
- j = K_INDEX_RIGHTALT;
- break;
- case XK_Scroll_Lock:
- j = K_INDEX_SCROLLLOCK;
- break;
- case XK_Control_R:
- j = K_INDEX_RIGHTCTL;
- break;
- default:
- j = -1;
- }
- if (j >= 0)
- switch (xf86Info.specialKeyMap[j]) {
- case KM_META:
- if (k[0] == XK_Alt_R)
- k[1] = XK_Meta_R;
- else {
- k[0] = XK_Alt_L;
- k[1] = XK_Meta_L;
- }
- break;
- case KM_COMPOSE:
- k[0] = XK_Multi_key;
- break;
- case KM_MODESHIFT:
- k[0] = XK_Mode_switch;
- k[1] = NoSymbol;
- break;
- case KM_MODELOCK:
- k[0] = XK_Mode_switch;
- k[1] = XF86XK_ModeLock;
- break;
- case KM_SCROLLLOCK:
- k[0] = XK_Scroll_Lock;
- break;
- case KM_CONTROL:
- k[0] = XK_Control_R;
- break;
- }
- }
-
- /*
* compute the modifier map
*/
for (i = 0; i < MAP_LENGTH; i++)
@@ -609,7 +560,7 @@ xf86KbdGetMapping (pKeySyms, pModMap)
break;
case XK_Num_Lock:
- if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ pModMap[i] = NumLockMask;
break;
case XK_Scroll_Lock:
@@ -634,54 +585,649 @@ xf86KbdGetMapping (pKeySyms, pModMap)
pKeySyms->map = map;
pKeySyms->mapWidth = GLYPHS_PER_KEY;
pKeySyms->minKeyCode = MIN_KEYCODE;
- if (xf86Info.serverNumLock)
- pKeySyms->maxKeyCode = MAX_KEYCODE;
- else
- pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
}
-#ifdef CODRV_SUPPORT
-/* Converts a CoDriver ASCII+Special combination into a KeySym
+#ifdef WSCONS_SUPPORT
+#include "atKeynames.h"
+
+static CARD8 wsUsbMap[] = {
+ /* 0 */ KEY_NOTUSED,
+ /* 1 */ KEY_NOTUSED,
+ /* 2 */ KEY_NOTUSED,
+ /* 3 */ KEY_NOTUSED,
+ /* 4 */ KEY_A,
+ /* 5 */ KEY_B,
+ /* 6 */ KEY_C,
+ /* 7 */ KEY_D,
+ /* 8 */ KEY_E,
+ /* 9 */ KEY_F,
+ /* 10 */ KEY_G,
+ /* 11 */ KEY_H,
+ /* 12 */ KEY_I,
+ /* 13 */ KEY_J,
+ /* 14 */ KEY_K,
+ /* 15 */ KEY_L,
+ /* 16 */ KEY_M,
+ /* 17 */ KEY_N,
+ /* 18 */ KEY_O,
+ /* 19 */ KEY_P,
+ /* 20 */ KEY_Q,
+ /* 21 */ KEY_R,
+ /* 22 */ KEY_S,
+ /* 23 */ KEY_T,
+ /* 24 */ KEY_U,
+ /* 25 */ KEY_V,
+ /* 26 */ KEY_W,
+ /* 27 */ KEY_X,
+ /* 28 */ KEY_Y,
+ /* 29 */ KEY_Z,
+ /* 30 */ KEY_1, /* 1 !*/
+ /* 31 */ KEY_2, /* 2 @ */
+ /* 32 */ KEY_3, /* 3 # */
+ /* 33 */ KEY_4, /* 4 $ */
+ /* 34 */ KEY_5, /* 5 % */
+ /* 35 */ KEY_6, /* 6 ^ */
+ /* 36 */ KEY_7, /* 7 & */
+ /* 37 */ KEY_8, /* 8 * */
+ /* 38 */ KEY_9, /* 9 ( */
+ /* 39 */ KEY_0, /* 0 ) */
+ /* 40 */ KEY_Enter, /* Return */
+ /* 41 */ KEY_Escape, /* Escape */
+ /* 42 */ KEY_BackSpace, /* Backspace Delete */
+ /* 43 */ KEY_Tab, /* Tab */
+ /* 44 */ KEY_Space, /* Space */
+ /* 45 */ KEY_Minus, /* - _ */
+ /* 46 */ KEY_Equal, /* = + */
+ /* 47 */ KEY_LBrace, /* [ { */
+ /* 48 */ KEY_RBrace, /* ] } */
+ /* 49 */ KEY_BSlash, /* \ | */
+ /* 50 */ KEY_BSlash2, /* \ _ # ~ on some keyboards */
+ /* 51 */ KEY_SemiColon, /* ; : */
+ /* 52 */ KEY_Quote, /* ' " */
+ /* 53 */ KEY_Tilde, /* ` ~ */
+ /* 54 */ KEY_Comma, /* , < */
+ /* 55 */ KEY_Period, /* . > */
+ /* 56 */ KEY_Slash, /* / ? */
+ /* 57 */ KEY_CapsLock, /* Caps Lock */
+ /* 58 */ KEY_F1, /* F1 */
+ /* 59 */ KEY_F2, /* F2 */
+ /* 60 */ KEY_F3, /* F3 */
+ /* 61 */ KEY_F4, /* F4 */
+ /* 62 */ KEY_F5, /* F5 */
+ /* 63 */ KEY_F6, /* F6 */
+ /* 64 */ KEY_F7, /* F7 */
+ /* 65 */ KEY_F8, /* F8 */
+ /* 66 */ KEY_F9, /* F9 */
+ /* 67 */ KEY_F10, /* F10 */
+ /* 68 */ KEY_F11, /* F11 */
+ /* 69 */ KEY_F12, /* F12 */
+ /* 70 */ KEY_Print, /* PrintScrn SysReq */
+ /* 71 */ KEY_ScrollLock, /* Scroll Lock */
+ /* 72 */ KEY_Pause, /* Pause Break */
+ /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */
+ /* 74 */ KEY_Home, /* Home */
+ /* 75 */ KEY_PgUp, /* Page Up */
+ /* 76 */ KEY_Delete, /* Delete */
+ /* 77 */ KEY_End, /* End */
+ /* 78 */ KEY_PgDown, /* Page Down */
+ /* 79 */ KEY_Right, /* Right Arrow */
+ /* 80 */ KEY_Left, /* Left Arrow */
+ /* 81 */ KEY_Down, /* Down Arrow */
+ /* 82 */ KEY_Up, /* Up Arrow */
+ /* 83 */ KEY_NumLock, /* Num Lock */
+ /* 84 */ KEY_KP_Divide, /* Keypad / */
+ /* 85 */ KEY_KP_Multiply, /* Keypad * */
+ /* 86 */ KEY_KP_Minus, /* Keypad - */
+ /* 87 */ KEY_KP_Plus, /* Keypad + */
+ /* 88 */ KEY_KP_Enter, /* Keypad Enter */
+ /* 89 */ KEY_KP_1, /* Keypad 1 End */
+ /* 90 */ KEY_KP_2, /* Keypad 2 Down */
+ /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */
+ /* 92 */ KEY_KP_4, /* Keypad 4 Left */
+ /* 93 */ KEY_KP_5, /* Keypad 5 */
+ /* 94 */ KEY_KP_6, /* Keypad 6 */
+ /* 95 */ KEY_KP_7, /* Keypad 7 Home */
+ /* 96 */ KEY_KP_8, /* Keypad 8 Up */
+ /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */
+ /* 98 */ KEY_KP_0, /* Keypad 0 Ins */
+ /* 99 */ KEY_KP_Decimal, /* Keypad . Del */
+ /* 100 */ KEY_Less, /* < > on some keyboards */
+ /* 101 */ KEY_Menu, /* Menu */
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_NOTUSED,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_NOTUSED,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_NOTUSED,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_NOTUSED,
+ /* 116 */ KEY_NOTUSED,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_NOTUSED,
+ /* 119 */ KEY_NOTUSED,
+ /* 120 */ KEY_NOTUSED,
+ /* 121 */ KEY_NOTUSED,
+ /* 122 */ KEY_NOTUSED,
+ /* 123 */ KEY_NOTUSED,
+ /* 124 */ KEY_NOTUSED,
+ /* 125 */ KEY_NOTUSED,
+ /* 126 */ KEY_NOTUSED,
+ /* 127 */ KEY_NOTUSED,
+ /* 128 */ KEY_NOTUSED,
+ /* 129 */ KEY_NOTUSED,
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_NOTUSED,
+ /* 136 */ KEY_NOTUSED,
+ /* 137 */ KEY_NOTUSED,
+ /* 138 */ KEY_NOTUSED,
+ /* 139 */ KEY_NOTUSED,
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+ /* 224 */ KEY_LCtrl, /* Left Control */
+ /* 225 */ KEY_ShiftL, /* Left Shift */
+ /* 226 */ KEY_Alt, /* Left Alt */
+ /* 227 */ KEY_LMeta, /* Left Meta */
+ /* 228 */ KEY_RCtrl, /* Right Control */
+ /* 229 */ KEY_ShiftR, /* Right Shift */
+ /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */
+ /* 231 */ KEY_LMeta, /* Right Meta XXX */
+};
+
+#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
+
+/* Map for adb keyboards */
+static CARD8 wsAdbMap[] = {
+ /* 0 */ KEY_A,
+ /* 1 */ KEY_S,
+ /* 2 */ KEY_D,
+ /* 3 */ KEY_F,
+ /* 4 */ KEY_H,
+ /* 5 */ KEY_G,
+ /* 6 */ KEY_Z,
+ /* 7 */ KEY_X,
+ /* 8 */ KEY_C,
+ /* 9 */ KEY_V,
+ /* 10 */ KEY_UNKNOWN, /* @ # on french keyboards */
+ /* 11 */ KEY_B,
+ /* 12 */ KEY_Q,
+ /* 13 */ KEY_W,
+ /* 14 */ KEY_E,
+ /* 15 */ KEY_R,
+ /* 16 */ KEY_Y,
+ /* 17 */ KEY_T,
+ /* 18 */ KEY_1,
+ /* 19 */ KEY_2,
+ /* 20 */ KEY_3,
+ /* 21 */ KEY_4,
+ /* 22 */ KEY_6,
+ /* 23 */ KEY_5,
+ /* 24 */ KEY_Equal,
+ /* 25 */ KEY_9,
+ /* 26 */ KEY_7,
+ /* 27 */ KEY_Minus,
+ /* 28 */ KEY_8,
+ /* 29 */ KEY_0,
+ /* 30 */ KEY_RBrace,
+ /* 31 */ KEY_O,
+ /* 32 */ KEY_U,
+ /* 33 */ KEY_LBrace,
+ /* 34 */ KEY_I,
+ /* 35 */ KEY_P,
+ /* 36 */ KEY_Enter,
+ /* 37 */ KEY_L,
+ /* 38 */ KEY_J,
+ /* 39 */ KEY_Quote,
+ /* 40 */ KEY_K,
+ /* 41 */ KEY_SemiColon,
+ /* 42 */ KEY_BSlash,
+ /* 43 */ KEY_Comma,
+ /* 44 */ KEY_Slash,
+ /* 45 */ KEY_N,
+ /* 46 */ KEY_M,
+ /* 47 */ KEY_Period,
+ /* 48 */ KEY_Tab,
+ /* 49 */ KEY_Space,
+ /* 50 */ KEY_Tilde,
+ /* 51 */ KEY_Delete,
+ /* 52 */ KEY_AltLang,
+ /* 53 */ KEY_Escape,
+ /* 54 */ KEY_LCtrl,
+ /* 55 */ KEY_Alt,
+ /* 56 */ KEY_ShiftL,
+ /* 57 */ KEY_CapsLock,
+ /* 58 */ KEY_LMeta,
+ /* 59 */ KEY_Left,
+ /* 60 */ KEY_Right,
+ /* 61 */ KEY_Down,
+ /* 62 */ KEY_Up,
+ /* 63 */ KEY_UNKNOWN, /* Fn */
+ /* 64 */ KEY_NOTUSED,
+ /* 65 */ KEY_KP_Decimal,
+ /* 66 */ KEY_NOTUSED,
+ /* 67 */ KEY_KP_Multiply,
+ /* 68 */ KEY_NOTUSED,
+ /* 69 */ KEY_KP_Plus,
+ /* 70 */ KEY_NOTUSED,
+ /* 71 */ KEY_UNKNOWN, /* Clear */
+ /* 72 */ KEY_NOTUSED,
+ /* 73 */ KEY_NOTUSED,
+ /* 74 */ KEY_NOTUSED,
+ /* 75 */ KEY_KP_Divide,
+ /* 76 */ KEY_KP_Enter,
+ /* 77 */ KEY_NOTUSED,
+ /* 78 */ KEY_KP_Minus,
+ /* 79 */ KEY_NOTUSED,
+ /* 80 */ KEY_NOTUSED,
+ /* 81 */ KEY_KP_Equal, /* Keypad = */
+ /* 82 */ KEY_KP_0,
+ /* 83 */ KEY_KP_1,
+ /* 84 */ KEY_KP_2,
+ /* 85 */ KEY_KP_3,
+ /* 86 */ KEY_KP_4,
+ /* 87 */ KEY_KP_5,
+ /* 88 */ KEY_KP_6,
+ /* 89 */ KEY_KP_7,
+ /* 90 */ KEY_NOTUSED,
+ /* 91 */ KEY_KP_8,
+ /* 92 */ KEY_KP_9,
+ /* 93 */ KEY_NOTUSED,
+ /* 94 */ KEY_NOTUSED,
+ /* 95 */ KEY_UNKNOWN, /* Keypad , */
+ /* 96 */ KEY_F5,
+ /* 97 */ KEY_F6,
+ /* 98 */ KEY_F7,
+ /* 99 */ KEY_F3,
+ /* 100 */ KEY_F8,
+ /* 101 */ KEY_F9,
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_F11,
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_KP_Enter,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_F10,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_F12,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_Home,
+ /* 116 */ KEY_PgUp,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_F4,
+ /* 119 */ KEY_End,
+ /* 120 */ KEY_F2,
+ /* 121 */ KEY_PgDown,
+ /* 122 */ KEY_F1,
+ /* 123 */ KEY_NOTUSED,
+ /* 124 */ KEY_NOTUSED,
+ /* 125 */ KEY_NOTUSED,
+ /* 126 */ KEY_NOTUSED,
+ /* 127 */ KEY_NOTUSED,
+ /* 128 */ KEY_NOTUSED,
+ /* 129 */ KEY_NOTUSED,
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_NOTUSED,
+ /* 136 */ KEY_NOTUSED,
+ /* 137 */ KEY_NOTUSED,
+ /* 138 */ KEY_NOTUSED,
+ /* 139 */ KEY_NOTUSED,
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+};
+
+static CARD8 wsSunMap[] = {
+ /* 0x00 */ KEY_NOTUSED,
+ /* 0x01 */ KEY_NOTUSED, /* stop */
+ /* 0x02 */ KEY_NOTUSED, /* BrightnessDown / S-VolumeDown */
+ /* 0x03 */ KEY_NOTUSED, /* again */
+ /* 0x04 */ KEY_NOTUSED, /* BridgtnessUp / S-VolumeUp */
+ /* 0x05 */ KEY_F1,
+ /* 0x06 */ KEY_F2,
+ /* 0x07 */ KEY_F10,
+ /* 0x08 */ KEY_F3,
+ /* 0x09 */ KEY_F11,
+ /* 0x0a */ KEY_F4,
+ /* 0x0b */ KEY_F12,
+ /* 0x0c */ KEY_F5,
+ /* 0x0d */ KEY_AltLang,
+ /* 0x0e */ KEY_F6,
+ /* 0x0f */ KEY_NOTUSED,
+ /* 0x10 */ KEY_F7,
+ /* 0x11 */ KEY_F8,
+ /* 0x12 */ KEY_F9,
+ /* 0x13 */ KEY_Alt,
+ /* 0x14 */ KEY_Up,
+ /* 0x15 */ KEY_Pause,
+ /* 0x16 */ KEY_Print,
+ /* 0x17 */ KEY_NOTUSED, /* props */
+ /* 0x18 */ KEY_Left,
+ /* 0x19 */ KEY_ScrollLock,
+ /* 0x1a */ KEY_NOTUSED, /* undo */
+ /* 0x1b */ KEY_Down,
+ /* 0x1c */ KEY_Right,
+ /* 0x1d */ KEY_Escape,
+ /* 0x1e */ KEY_1,
+ /* 0x1f */ KEY_2,
+ /* 0x20 */ KEY_3,
+ /* 0x21 */ KEY_4,
+ /* 0x22 */ KEY_5,
+ /* 0x23 */ KEY_6,
+ /* 0x24 */ KEY_7,
+ /* 0x25 */ KEY_8,
+ /* 0x26 */ KEY_9,
+ /* 0x27 */ KEY_0,
+ /* 0x28 */ KEY_Minus,
+ /* 0x29 */ KEY_Equal,
+ /* 0x2a */ KEY_Tilde,
+ /* 0x2b */ KEY_BackSpace,
+ /* 0x2c */ KEY_Insert,
+ /* 0x2d */ KEY_KP_Equal,
+ /* 0x2e */ KEY_KP_Divide,
+ /* 0x2f */ KEY_KP_Multiply,
+ /* 0x30 */ KEY_NOTUSED,
+ /* 0x31 */ KEY_NOTUSED, /* front */
+ /* 0x32 */ KEY_KP_Decimal,
+ /* 0x33 */ KEY_NOTUSED, /* copy */
+ /* 0x34 */ KEY_Home,
+ /* 0x35 */ KEY_Tab,
+ /* 0x36 */ KEY_Q,
+ /* 0x37 */ KEY_W,
+ /* 0x38 */ KEY_E,
+ /* 0x39 */ KEY_R,
+ /* 0x3a */ KEY_T,
+ /* 0x3b */ KEY_Y,
+ /* 0x3c */ KEY_U,
+ /* 0x3d */ KEY_I,
+ /* 0x3e */ KEY_O,
+ /* 0x3f */ KEY_P,
+ /* 0x40 */ KEY_LBrace,
+ /* 0x41 */ KEY_RBrace,
+ /* 0x42 */ KEY_Delete,
+ /* 0x43 */ KEY_NOTUSED, /* compose */
+ /* 0x44 */ KEY_KP_7,
+ /* 0x45 */ KEY_KP_8,
+ /* 0x46 */ KEY_KP_9,
+ /* 0x47 */ KEY_KP_Minus,
+ /* 0x48 */ KEY_NOTUSED, /* open */
+ /* 0x49 */ KEY_NOTUSED, /* paste */
+ /* 0x4a */ KEY_End,
+ /* 0x4b */ KEY_NOTUSED,
+ /* 0x4c */ KEY_LCtrl,
+ /* 0x4d */ KEY_A,
+ /* 0x4e */ KEY_S,
+ /* 0x4f */ KEY_D,
+ /* 0x50 */ KEY_F,
+ /* 0x51 */ KEY_G,
+ /* 0x52 */ KEY_H,
+ /* 0x53 */ KEY_J,
+ /* 0x54 */ KEY_K,
+ /* 0x55 */ KEY_L,
+ /* 0x56 */ KEY_SemiColon,
+ /* 0x57 */ KEY_Quote,
+ /* 0x58 */ KEY_BSlash,
+ /* 0x59 */ KEY_Enter,
+ /* 0x5a */ KEY_KP_Enter,
+ /* 0x5b */ KEY_KP_4,
+ /* 0x5c */ KEY_KP_5,
+ /* 0x5d */ KEY_KP_6,
+ /* 0x5e */ KEY_KP_0,
+ /* 0x5f */ KEY_NOTUSED, /* find */
+ /* 0x60 */ KEY_PgUp,
+ /* 0x61 */ KEY_NOTUSED, /* cut */
+ /* 0x62 */ KEY_NumLock,
+ /* 0x63 */ KEY_ShiftL,
+ /* 0x64 */ KEY_Z,
+ /* 0x65 */ KEY_X,
+ /* 0x66 */ KEY_C,
+ /* 0x67 */ KEY_V,
+ /* 0x68 */ KEY_B,
+ /* 0x69 */ KEY_N,
+ /* 0x6a */ KEY_M,
+ /* 0x6b */ KEY_Comma,
+ /* 0x6c */ KEY_Period,
+ /* 0x6d */ KEY_Slash,
+ /* 0x6e */ KEY_ShiftR,
+ /* 0x6f */ KEY_NOTUSED, /* linefeed */
+ /* 0x70 */ KEY_KP_1,
+ /* 0x71 */ KEY_KP_2,
+ /* 0x72 */ KEY_KP_3,
+ /* 0x73 */ KEY_NOTUSED,
+ /* 0x74 */ KEY_NOTUSED,
+ /* 0x75 */ KEY_NOTUSED,
+ /* 0x76 */ KEY_NOTUSED, /* help */
+ /* 0x77 */ KEY_CapsLock,
+ /* 0x78 */ KEY_LMeta,
+ /* 0x79 */ KEY_Space,
+ /* 0x7a */ KEY_RMeta,
+ /* 0x7b */ KEY_PgDown,
+ /* 0x7c */ KEY_NOTUSED,
+ /* 0x7d */ KEY_KP_Plus,
+ /* 0x7e */ KEY_NOTUSED,
+ /* 0x7f */ KEY_NOTUSED
+};
+
+#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
+
+
+#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
+
+/*
+ * Translate raw wskbd keyboard event values to XFree86 standard keycodes
+ * (based on the AT keyboard scan codes using the tables above
*/
-static KeySym
-coGetKeysym(typ,str,old)
- int typ;
- CARD8 *str;
- KeySym old;
+int
+WSKbdToKeycode(int keycode)
{
- if (strlen((char *)str) > 1) return old;
- switch (typ & KBD_MASK) {
- case KBD_NONE:
- return NoSymbol;
- case KBD_SHIFT:
- if (old==XK_Shift_L || old==XK_Shift_R) return old;
- else return XK_Shift_L;
- case KBD_NUM:
- return XK_Num_Lock;
- case KBD_CTL:
- if (old==XK_Control_L || old==XK_Control_R) return old;
- else return XK_Control_L;
- case KBD_ALTGR:
- return XK_Mode_switch;
- case KBD_META:
- if (old==XK_Alt_L || old==XK_Alt_R) return old;
- else return XK_Alt_L;
- case KBD_SHFTLOCK:
- case KBD_CAPS:
- return XK_Caps_Lock;
- case KBD_SCROLL:
- return XK_Scroll_Lock;
- case KBD_BREAK:
- return XK_Break;
+ switch (xf86Info.wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ case WSKBD_TYPE_PC_AT:
+ /* No translation needed */
+ return keycode;
+ case WSKBD_TYPE_USB:
+ if (keycode < 0 || keycode >= WS_USB_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsUsbMap[keycode];
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ if (keycode < 0 || keycode >= WS_ADB_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsAdbMap[keycode];
+#endif
+#ifdef WSKBD_TYPE_SUN
+ case WSKBD_TYPE_SUN:
+ if (keycode < 0 || keycode >= WS_SUN_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsSunMap[keycode];
+#endif
default:
- case KBD_KP: /* there are few good reasons to overload
- * F Keys and KP Keys, so we ignore any attempt
- * at all
- */
- return old;
- case KBD_ASCII:
- return *str;
+ ErrorF("Unknown wskbd type %d\n", xf86Info.wsKbdType);
+ return KEY_UNKNOWN;
}
}
-#endif
+
+#endif /* WSCONS_SUPPORT */
diff --git a/hw/xfree86/common/xf86KbdLnx.c b/hw/xfree86/common/xf86KbdLnx.c
index 094044b30..1f97c0b15 100644
--- a/hw/xfree86/common/xf86KbdLnx.c
+++ b/hw/xfree86/common/xf86KbdLnx.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.12 1996/12/23 06:43:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.16 2001/03/05 20:18:20 dawes Exp $ */
/*
* Linux version of keymapping setup. The kernel (since 0.99.14) has support
* for fully remapping the keyboard, but there are some differences between
@@ -28,7 +28,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86KbdLnx.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
+/* $XConsortium: xf86KbdLnx.c /main/7 1996/10/19 17:59:00 kaleb $ */
#include "X.h"
#include "Xmd.h"
@@ -37,10 +37,10 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "atKeynames.h"
-#include "xf86_Config.h"
#include "xf86Keymap.h"
#include "DECkeysym.h"
@@ -71,63 +71,11 @@ xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
{
KeySym *k;
char type;
- int i, j;
+ int i;
readKernelMapping(pKeySyms, pModMap);
/*
- * Apply the special key mapping specified in XF86Config
- */
- for (k = map, i = MIN_KEYCODE;
- i < (NUM_KEYCODES + MIN_KEYCODE);
- i++, k += 4) {
- switch (k[0]) {
- case XK_Alt_L:
- j = K_INDEX_LEFTALT;
- break;
- case XK_Alt_R:
- j = K_INDEX_RIGHTALT;
- break;
- case XK_Scroll_Lock:
- j = K_INDEX_SCROLLLOCK;
- break;
- case XK_Control_R:
- j = K_INDEX_RIGHTCTL;
- break;
- default:
- j = -1;
- }
- if (j >= 0)
- switch (xf86Info.specialKeyMap[j]) {
- case KM_META:
- if (k[0] == XK_Alt_R)
- k[1] = XK_Meta_R;
- else {
- k[0] = XK_Alt_L;
- k[1] = XK_Meta_L;
- }
- break;
- case KM_COMPOSE:
- k[0] = XK_Multi_key;
- break;
- case KM_MODESHIFT:
- k[0] = XK_Mode_switch;
- k[1] = NoSymbol;
- break;
- case KM_MODELOCK:
- k[0] = XK_Mode_switch;
- k[1] = XF86XK_ModeLock;
- break;
- case KM_SCROLLLOCK:
- k[0] = XK_Scroll_Lock;
- break;
- case KM_CONTROL:
- k[0] = XK_Control_R;
- break;
- }
- }
-
- /*
* compute the modifier map
*/
for (i = 0; i < MAP_LENGTH; i++)
@@ -159,7 +107,7 @@ xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
break;
case XK_Num_Lock:
- if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ pModMap[i] = NumLockMask;
break;
case XK_Scroll_Lock:
@@ -185,11 +133,7 @@ xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
pKeySyms->map = map;
pKeySyms->mapWidth = GLYPHS_PER_KEY;
pKeySyms->minKeyCode = MIN_KEYCODE;
- if (xf86Info.serverNumLock)
- pKeySyms->maxKeyCode = MAX_KEYCODE;
- else
- pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
-
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
}
#include <linux/keyboard.h>
@@ -226,7 +170,7 @@ static KeySym linux_to_x[256] = {
XK_p, XK_q, XK_r, XK_s,
XK_t, XK_u, XK_v, XK_w,
XK_x, XK_y, XK_z, XK_braceleft,
- XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
@@ -261,12 +205,10 @@ static KeySym linux_to_x[256] = {
XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
};
-#ifndef ASSUME_CUSTOM_KEYCODES
-
/*
* Maps the AT keycodes to Linux keycodes
*/
-static unsigned char at2lnx[] =
+static unsigned char at2lnx[NUM_KEYCODES] =
{
0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
0x03, /* KEY_2 */ 0x04, /* KEY_3 */
@@ -332,34 +274,19 @@ static unsigned char at2lnx[] =
0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
0x00, /* 0x7f */
- /* the following are for ServerNumLock handling */
- 0x47, /* KEY_SN_KP_7 */ 0x48, /* KEY_SN_KP_8 */
- 0x49, /* KEY_SN_KP_9 */ 0x4b, /* KEY_SN_KP_4 */
- 0x4c, /* KEY_SN_KP_5 */ 0x4d, /* KEY_SN_KP_6 */
- 0x4f, /* KEY_SN_KP_1 */ 0x50, /* KEY_SN_KP_2 */
- 0x51, /* KEY_SN_KP_3 */ 0x52, /* KEY_SN_KP_0 */
- 0x53, /* KEY_SN_KP_Decimal */ 0x66, /* KEY_SN_Home */
- 0x67, /* KEY_SN_Up */ 0x68, /* KEY_SN_Prior */
- 0x69, /* KEY_SN_Left */ 0x5d, /* KEY_SN_Begin */
- 0x6a, /* KEY_SN_Right */ 0x6b, /* KEY_SN_End */
- 0x6c, /* KEY_SN_Down */ 0x6d, /* KEY_SN_Next */
- 0x6e, /* KEY_SN_Ins */ 0x6f /* KEY_SN_Del */
};
#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
-#else /* !ASSUME_CUSTOM_KEYCODES */
-
-#define NUM_AT2LNX NR_KEYS
+#define NUM_CUSTOMKEYS NR_KEYS
-u_char SpecialServerMap[NR_KEYS];
-
-#endif /* !ASSUME_CUSTOM_KEYCODES */
+u_char SpecialServerMap[NUM_CUSTOMKEYS];
static void
readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
{
KeySym *k;
int i;
+ int maxkey;
static unsigned char tbl[GLYPHS_PER_KEY] =
{
0, /* unshifted */
@@ -377,30 +304,27 @@ readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
* First, figure out which tables to use for the modeswitch columns
* above, from the XF86Config fields.
*/
- if (xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODESHIFT ||
- xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODELOCK)
- tbl[2] = 4; /* control */
- else if (xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODESHIFT ||
- xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODELOCK)
- tbl[2] = 2; /* AltGr */
- else
- tbl[2] = 8; /* alt */
+ tbl[2] = 8; /* alt */
tbl[3] = tbl[2] | 1;
-#ifndef ASSUME_CUSTOM_KEYCODES
- for (i = 0, k = map+GLYPHS_PER_KEY; i < NUM_AT2LNX; ++i)
-#else /* !ASSUME_CUSTOM_KEYCODES */
- for (i = 0, k = map; i < NUM_AT2LNX; ++i)
-#endif /* !ASSUME_CUSTOM_KEYCODES */
+ if (xf86Info.kbdCustomKeycodes) {
+ k = map;
+ maxkey = NUM_CUSTOMKEYS;
+ }
+ else {
+ k = map+GLYPHS_PER_KEY;
+ maxkey = NUM_AT2LNX;
+ }
+
+ for (i = 0; i < maxkey; ++i)
{
struct kbentry kbe;
int j;
-#ifndef ASSUME_CUSTOM_KEYCODES
- kbe.kb_index = at2lnx[i];
-#else /* !ASSUME_CUSTOM_KEYCODES */
- kbe.kb_index = i;
-#endif /* !ASSUME_CUSTOM_KEYCODES */
+ if (xf86Info.kbdCustomKeycodes)
+ kbe.kb_index = i;
+ else
+ kbe.kb_index = at2lnx[i];
for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
{
@@ -410,9 +334,7 @@ readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
kbe.kb_table = tbl[j];
if (
-#ifndef ASSUME_CUSTOM_KEYCODES
- kbe.kb_index == 0 ||
-#endif /* !ASSUME_CUSTOM_KEYCODES */
+ (!xf86Info.kbdCustomKeycodes && kbe.kb_index == 0) ||
ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
continue;
@@ -624,11 +546,14 @@ readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
}
-#ifdef ASSUME_CUSTOM_KEYCODES
+
+ if (!xf86Info.kbdCustomKeycodes)
+ return;
+
/*
* Find the Mapping for the special server functions
*/
- for (i = 0; i < NR_KEYS; ++i) {
+ for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
struct kbentry kbe;
int special = 0;
@@ -693,5 +618,4 @@ readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
}
SpecialServerMap[i] = special;
}
-#endif /* ASSUME_CUSTOM_KEYCODES */
}
diff --git a/hw/xfree86/common/xf86KbdMach.c b/hw/xfree86/common/xf86KbdMach.c
index cc23ee8e0..fbbafd8af 100644
--- a/hw/xfree86/common/xf86KbdMach.c
+++ b/hw/xfree86/common/xf86KbdMach.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdMach.c,v 3.7 1996/12/23 06:43:32 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdMach.c,v 3.8 1998/07/25 16:55:09 dawes Exp $ */
/*
*****************************************************************************
* HISTORY
@@ -35,7 +35,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86KbdMach.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
+/* $XConsortium: xf86KbdMach.c /main/9 1996/02/21 17:38:43 kaleb $ */
#include "X.h"
#include "Xmd.h"
@@ -44,10 +44,11 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "atKeynames.h"
-#include "xf86_Config.h"
+#include "xf86Config.h"
#include "xf86Keymap.h"
diff --git a/hw/xfree86/common/xf86Keymap.h b/hw/xfree86/common/xf86Keymap.h
index 2b9debff4..45f4dd104 100644
--- a/hw/xfree86/common/xf86Keymap.h
+++ b/hw/xfree86/common/xf86Keymap.h
@@ -1,13 +1,15 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.9 1996/12/23 06:43:35 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.19 2002/05/31 18:45:58 dawes Exp $ */
/*
*
* For Scancodes see notes in atKeynames.h !!!!
*
*/
-/* $Xorg: xf86Keymap.h,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
+/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+
+#if !defined(__SOL8__) && (!defined(sun) || defined(i386))
-static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
-#ifndef PC98
/* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
/* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
@@ -23,7 +25,7 @@ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
/* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
/* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
- /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_Tab, XK_ISO_Left_Tab,NoSymbol, NoSymbol,
/* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
/* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
/* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
@@ -84,7 +86,7 @@ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
/* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
/* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
- /* 0x4c */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_KP_Begin, XK_KP_5, NoSymbol, NoSymbol,
/* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
/* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
/* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
@@ -97,7 +99,6 @@ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
/* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
/* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
-
/* 0x59 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
/* 0x5a */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
/* 0x5b */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
@@ -119,180 +120,178 @@ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol,
/* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol,
/* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_F13, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ XK_F14, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ XK_F15, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ XK_F16, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ XK_F17, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ XK_backslash, XK_underscore, NoSymbol, NoSymbol,
/* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ XK_Henkan, XK_Mode_switch, NoSymbol, NoSymbol,
/* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol,
/* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
/* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-#else /* PC98 */
- /* 0x00 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
- /* 0x01 */ XK_1, XK_exclam, XK_kana_NU, NoSymbol,
- /* 0x02 */ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol,
- /* 0x03 */ XK_3, XK_numbersign, XK_kana_A, XK_kana_a,
- /* 0x04 */ XK_4, XK_dollar, XK_kana_U, XK_kana_u,
- /* 0x05 */ XK_5, XK_percent, XK_kana_E, XK_kana_e,
- /* 0x06 */ XK_6, XK_ampersand, XK_kana_O, XK_kana_o,
- /* 0x07 */ XK_7, XK_quoteright, XK_kana_YA, XK_kana_ya,
- /* 0x08 */ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu,
- /* 0x09 */ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo,
- /* 0x0a */ XK_0, NoSymbol, XK_kana_WA, XK_kana_WO,
- /* 0x0b */ XK_minus, XK_equal, XK_kana_HO, NoSymbol,
- /* 0x0c */ XK_asciicircum, XK_quoteleft, XK_kana_HE, NoSymbol,
- /* 0x0d */ XK_backslash, XK_bar, XK_prolongedsound, NoSymbol,
- /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
- /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10 */ XK_Q, NoSymbol, XK_kana_TA, NoSymbol,
- /* 0x11 */ XK_W, NoSymbol, XK_kana_TE, NoSymbol,
- /* 0x12 */ XK_E, NoSymbol, XK_kana_I, XK_kana_i,
- /* 0x13 */ XK_R, NoSymbol, XK_kana_SU, NoSymbol,
- /* 0x14 */ XK_T, NoSymbol, XK_kana_KA, NoSymbol,
- /* 0x15 */ XK_Y, NoSymbol, XK_kana_N, NoSymbol,
- /* 0x16 */ XK_U, NoSymbol, XK_kana_NA, NoSymbol,
- /* 0x17 */ XK_I, NoSymbol, XK_kana_NI, NoSymbol,
- /* 0x18 */ XK_O, NoSymbol, XK_kana_RA, NoSymbol,
- /* 0x19 */ XK_P, NoSymbol, XK_kana_SE, NoSymbol,
- /* 0x1a */ XK_at, XK_asciitilde, XK_voicedsound, NoSymbol,
- /* 0x1b */ XK_bracketleft, XK_braceleft, XK_semivoicedsound, XK_kana_openingbracket,
- /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
- /* 0x1d */ XK_A, NoSymbol, XK_kana_CHI, NoSymbol,
- /* 0x1e */ XK_S, NoSymbol, XK_kana_TO, NoSymbol,
- /* 0x1f */ XK_D, NoSymbol, XK_kana_SHI, NoSymbol,
- /* 0x20 */ XK_F, NoSymbol, XK_kana_HA, NoSymbol,
- /* 0x21 */ XK_G, NoSymbol, XK_kana_KI, NoSymbol,
- /* 0x22 */ XK_H, NoSymbol, XK_kana_KU, NoSymbol,
- /* 0x23 */ XK_J, NoSymbol, XK_kana_MA, NoSymbol,
- /* 0x24 */ XK_K, NoSymbol, XK_kana_NO, NoSymbol,
- /* 0x25 */ XK_L, NoSymbol, XK_kana_RI, NoSymbol,
- /* 0x26 */ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol,
- /* 0x27 */ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol,
- /* 0x28 */ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket,
- /* 0x29 */ XK_Z, NoSymbol, XK_kana_TSU, NoSymbol,
- /* 0x2a */ XK_X, NoSymbol, XK_kana_SA, NoSymbol,
- /* 0x2b */ XK_C, NoSymbol, XK_kana_SO, NoSymbol,
- /* 0x2c */ XK_V, NoSymbol, XK_kana_HI, NoSymbol,
- /* 0x2d */ XK_B, NoSymbol, XK_kana_KO, NoSymbol,
- /* 0x2e */ XK_N, NoSymbol, XK_kana_MI, NoSymbol,
- /* 0x2f */ XK_M, NoSymbol, XK_kana_MO, NoSymbol,
- /* 0x30 */ XK_comma, XK_less, XK_kana_NE, XK_kana_comma,
- /* 0x31 */ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop,
- /* 0x32 */ XK_slash, XK_question, XK_kana_ME, XK_kana_middledot,
- /* 0x33 */ XK_underscore, XK_underscore, XK_kana_RO, NoSymbol,
- /* 0x34 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
- /* 0x35 */ XK_Henkan, XK_Kanji, NoSymbol, NoSymbol,
- /* 0x36 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
- /* 0x37 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
- /* 0x38 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
- /* 0x39 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3a */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3b */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3c */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3d */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3e */ XK_Clear, XK_Home, NoSymbol, NoSymbol,
- /* 0x3f */ XK_Help, NoSymbol, NoSymbol, NoSymbol,
- /* 0x40 */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
- /* 0x41 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
- /* 0x42 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x43 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x44 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x45 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
- /* 0x46 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x47 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x48 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x49 */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4a */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4b */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4c */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4d */ XK_KP_Equal, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4e */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4f */ XK_KP_Separator,NoSymbol, NoSymbol, NoSymbol,
- /* 0x50 */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol,
- /* 0x51 */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol,
- /* 0x52 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
- /* 0x53 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
- /* 0x54 */ XK_F13, NoSymbol, NoSymbol, NoSymbol,
- /* 0x55 */ XK_F14, NoSymbol, NoSymbol, NoSymbol,
- /* 0x56 */ XK_F15, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+
+#else /* SunOS */
+
+/* Assumes a US English keyboard as default - sorry 'bout that
+ *
+ * Hopefully it'll be enough someone can have a sorta working
+ * keyboard, if they're not using XKB
+ *
+ * DWH 9/12/99
+ */
+
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x2a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x38 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x3f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x48 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x49 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_End, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x52 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
/* 0x57 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x58 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x5c */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x5d */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
/* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x60 */ XK_Break, NoSymbol, NoSymbol, NoSymbol,
- /* 0x61 */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
- /* 0x62 */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x63 */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x64 */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x65 */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x66 */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x67 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x68 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x69 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6a */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6b */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x61 */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x62 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x63 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
/* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x70 */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
- /* 0x71 */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
- /* 0x72 */ XK_kana_switch, NoSymbol, XK_kana_switch, NoSymbol,
- /* 0x73 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
- /* 0x74 */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
- /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-#endif /* PC98 */
+ /* 0x70 */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x74 */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7a */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7e */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
/* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* These are for ServerNumLock handling */
- /* 0x80 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x81 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x82 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x83 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x84 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x85 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x86 */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x87 */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x88 */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x89 */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8a */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8b */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8c */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8d */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8e */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8f */ XK_Begin, NoSymbol, NoSymbol, NoSymbol,
- /* 0x90 */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
- /* 0x91 */ XK_End, NoSymbol, NoSymbol, NoSymbol,
- /* 0x92 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x93 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
- /* 0x94 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
- /* 0x95 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+#endif /* SunOS */
+
};
-static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+#if !defined(Lynx) && \
+ !defined(__UNIXOS2__) && \
+ !defined(__mips__) && \
+ !defined(linux) && \
+ !defined(CSRG_BASED) && \
+ !defined(__CYGWIN__) && \
+ !defined(__SOL8__) && \
+ (!defined(sun) || defined(i386))
+
+static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
/* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
@@ -382,7 +381,6 @@ static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
/* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
/* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
-
/* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
@@ -421,29 +419,5 @@ static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
/* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
/* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* These are for ServerNumLock handling */
- /* 0x80 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x81 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x82 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x83 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x84 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x85 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x86 */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x87 */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x88 */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x89 */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8a */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8b */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8c */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8d */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8e */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8f */ XK_Begin, NoSymbol, NoSymbol, NoSymbol,
- /* 0x90 */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
- /* 0x91 */ XK_End, NoSymbol, NoSymbol, NoSymbol,
- /* 0x92 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x93 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
- /* 0x94 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
- /* 0x95 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
};
+#endif
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 3c73f6e56..308e7a72c 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -1,175 +1,202 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.24.2.1 1998/02/01 16:04:47 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.80 2002/12/12 18:29:10 eich Exp $ */
+
/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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
- * 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.
- *
- * THOMAS ROELL 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
- * 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.
+ * Copyright (c) 1997 by The XFree86 Project, Inc.
+ */
+
+/*
+ * This file contains declarations for private XFree86 functions and variables,
+ * and definitions of private macros.
*
+ * "private" means not available to video drivers.
*/
-/* $Xorg: xf86Priv.h,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */
#ifndef _XF86PRIV_H
#define _XF86PRIV_H
-#ifndef _XF86VIDMODE_SERVER_
-#include "Xproto.h"
-#include "xf86_OSproc.h"
+#include "xf86Privstr.h"
+#include "propertyst.h"
+
+/*
+ * Parameters set ONLY from the command line options
+ * The global state of these things is held in xf86InfoRec (when appropriate).
+ */
+extern const char *xf86ConfigFile;
+extern Bool xf86AllowMouseOpenFail;
+#ifdef XF86VIDMODE
+extern Bool xf86VidModeDisabled;
+extern Bool xf86VidModeAllowNonLocal;
+#endif
+#ifdef XF86MISC
+extern Bool xf86MiscModInDevDisabled;
+extern Bool xf86MiscModInDevAllowNonLocal;
+#endif
+extern Bool xf86fpFlag;
+extern Bool xf86coFlag;
+extern Bool xf86sFlag;
+extern Bool xf86bsEnableFlag;
+extern Bool xf86bsDisableFlag;
+extern Bool xf86silkenMouseDisableFlag;
+extern char *xf86LayoutName;
+extern char *xf86ScreenName;
+extern char *xf86PointerName;
+extern char *xf86KeyboardName;
+#ifdef KEEPBPP
+extern int xf86Bpp;
#endif
+extern int xf86FbBpp;
+extern int xf86Depth;
+extern Pix24Flags xf86Pix24;
+extern rgb xf86Weight;
+extern Bool xf86FlipPixels;
+extern Bool xf86BestRefresh;
+extern Gamma xf86Gamma;
+extern char *xf86ServerName;
+extern Bool xf86ShowUnresolved;
-typedef struct {
+/* Other parameters */
- /* keyboard part */
- DeviceIntPtr pKeyboard;
- DeviceProc kbdProc; /* procedure for initializing */
- void (* kbdEvents)( /* proc for processing events */
-#if NeedNestedPrototypes && !defined(__OSF__)
- void
-#endif
- );
-#ifndef MINIX
- int consoleFd;
+extern xf86InfoRec xf86Info;
+extern const char *xf86InputDeviceList;
+extern const char *xf86ModulePath;
+extern MessageType xf86ModPathFrom;
+extern const char *xf86LogFile;
+extern MessageType xf86LogFileFrom;
+extern Bool xf86LogFileWasOpened;
+extern serverLayoutRec xf86ConfigLayout;
+extern Pix24Flags xf86ConfigPix24;
+
+extern unsigned short xf86MouseCflags[];
+extern Bool xf86SupportedMouseTypes[];
+extern int xf86NumMouseTypes;
+
+#ifdef XFree86LOADER
+extern DriverPtr *xf86DriverList;
+extern ModuleInfoPtr *xf86ModuleInfoList;
+extern int xf86NumModuleInfos;
#else
- int kbdFd;
-#endif /* MINIX */
-#if defined(MACH386) || defined(__OSF__)
- int kbdFd;
-#endif /* MACH386 || __OSF__ */
- int vtno;
- int kbdType; /* AT84 / AT101 */
- int kbdRate;
- int kbdDelay;
- int bell_pitch;
- int bell_duration;
- Bool autoRepeat;
- unsigned long leds;
- unsigned long xleds;
- char *vtinit;
- int *specialKeyMap;
- int scanPrefix; /* scancode-state */
- Bool capsLock;
- Bool numLock;
- Bool scrollLock;
- Bool modeSwitchLock;
- Bool serverNumLock;
- Bool composeLock;
- Bool vtSysreq;
-#if defined(SVR4) && defined(i386)
- Bool panix106;
-#endif /* SVR4 && i386 */
-
- /* mouse part */
- DeviceIntPtr pMouse;
-#ifdef XINPUT
- pointer mouseLocal;
+extern DriverPtr xf86DriverList[];
#endif
- MouseDevPtr mouseDev;
-
- /* event handler part */
- int lastEventTime;
- Bool vtRequestsPending;
- Bool inputPending;
- Bool dontZap;
- Bool dontZoom;
- Bool notrapSignals; /* don't exit cleanly - die at fault */
- Bool caughtSignal;
-
- /* graphics part */
- Bool sharedMonitor;
- ScreenPtr currentScreen;
-#ifdef CSRG_BASED
- int screenFd; /* fd for memory mapped access to vga card */
- int consType; /* Which console driver? */
+extern int xf86NumDrivers;
+extern Bool xf86Resetting;
+extern Bool xf86Initialising;
+extern Bool xf86ProbeFailed;
+extern int xf86NumScreens;
+extern pciVideoPtr *xf86PciVideoInfo;
+extern xf86CurrentAccessRec xf86CurrentAccess;
+extern const char *xf86VisualNames[];
+extern int xf86Verbose; /* verbosity level */
+extern int xf86LogVerbose; /* log file verbosity level */
+extern Bool xf86ProbeOnly;
+extern Bool xf86DoProbe;
+
+#ifndef DEFAULT_VERBOSE
+#define DEFAULT_VERBOSE 0
#endif
-#if defined(AMOEBA)
- void *screenPtr;
+#ifndef DEFAULT_LOG_VERBOSE
+#define DEFAULT_LOG_VERBOSE 3
#endif
-
-#ifdef XKB
-/*
- * would like to use an XkbComponentNamesRec here but can't without
- * pulling in a bunch of header files. :-(
- */
- char *xkbkeymap;
- char *xkbkeycodes;
- char *xkbtypes;
- char *xkbcompat;
- char *xkbsymbols;
- char *xkbgeometry;
- Bool xkbcomponents_specified;
- char *xkbrules;
- char *xkbmodel;
- char *xkblayout;
- char *xkbvariant;
- char *xkboptions;
+#ifndef DEFAULT_DPI
+#define DEFAULT_DPI 75
#endif
-} xf86InfoRec, *xf86InfoPtr;
+#define DEFAULT_UNRESOLVED TRUE
+#define DEFAULT_BEST_REFRESH FALSE
-extern xf86InfoRec xf86Info;
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Beta.c */
+extern void xf86CheckBeta(int extraDays, char *key);
+
+/* xf86Bus.c */
-/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */
-#define XLED1 ((unsigned long) 0x00000001)
-#define XLED2 ((unsigned long) 0x00000002)
-#define XLED3 ((unsigned long) 0x00000004)
-#define XCAPS ((unsigned long) 0x20000000)
-#define XNUM ((unsigned long) 0x40000000)
-#define XSCR ((unsigned long) 0x80000000)
-#define XCOMP ((unsigned long) 0x00008000)
-
-/* 386BSD console driver types (consType) */
-#ifdef CSRG_BASED
-#define PCCONS 0
-#define CODRV011 1
-#define CODRV01X 2
-#define SYSCONS 8
-#define PCVT 16
+void xf86BusProbe(void);
+void xf86ChangeBusIndex(int oldIndex, int newIndex);
+void xf86AccessInit(void);
+void xf86AccessEnter(void);
+void xf86AccessLeave(void);
+void xf86EntityInit(void);
+void xf86EntityEnter(void);
+void xf86EntityLeave(void);
+void xf86AccessLeaveState(void);
+
+void xf86FindPrimaryDevice(void);
+/* new RAC */
+void xf86ResourceBrokerInit(void);
+void xf86PostProbe(void);
+void xf86ClearEntityListForScreen(int scrnIndex);
+void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+extern void xf86PostPreInit(void);
+extern void xf86PostScreenInit(void);
+extern memType getValidBIOSBase(PCITAG tag, int num);
+extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag);
+
+/* xf86Config.c */
+
+Bool xf86PathIsAbsolute(const char *path);
+Bool xf86PathIsSafe(const char *path);
+
+/* xf86DefaultModes */
+
+extern DisplayModeRec xf86DefaultModes [];
+
+/* xf86DoScanPci.c */
+
+void DoScanPci(int argc, char **argv, int i);
+
+/* xf86DoProbe.c */
+void DoProbeArgs(int argc, char **argv, int i);
+void DoProbe(void);
+void DoConfigure(void);
+
+/* xf86Events.c */
+
+void xf86PostKbdEvent(unsigned key);
+void xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy);
+void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
+void xf86SigHandler(int signo);
+#ifdef MEMDEBUG
+void xf86SigMemDebug(int signo);
#endif
+void xf86HandlePMEvents(int fd, pointer data);
+extern int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
+extern pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
+void xf86GrabServerCallback(CallbackListPtr *, pointer, pointer);
-/* Values of xf86Info.mouseFlags */
-#define MF_CLEAR_DTR 1
-#define MF_CLEAR_RTS 2
+/* xf86Helper.c */
+void xf86LogInit(void);
+void xf86CloseLog(void);
+void OsVendorVErrorF(const char *f, va_list args);
-extern int xf86ScreenIndex;
+/* xf86Init.c */
+Bool xf86LoadModules(char **list, pointer *optlist);
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
+/* xf86Io.c */
-extern int xf86MaxScreens;
-extern ScrnInfoPtr xf86Screens[];
-extern int xf86ScreenNames[];
+void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl,
+ int unused);
+void xf86KbdLeds(void);
+void xf86UpdateKbdLeds(void);
+void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl);
+void xf86InitKBD(Bool init);
+int xf86KbdProc(DeviceIntPtr pKeyboard, int what);
-extern char xf86ConfigFile[];
-extern int xf86Verbose;
-extern Bool xf86ProbeOnly, xf86ProbeFailed;
-extern unsigned short xf86MouseCflags[];
-extern Bool xf86SupportedMouseTypes[];
-extern int xf86NumMouseTypes;
-extern int xf86bpp;
-extern xrgb xf86weight;
-extern Bool xf86AllowMouseOpenFail;
-extern Bool xf86BestRefresh;
+/* xf86Kbd.c */
-extern Bool xf86FlipPixels;
-#define XF86FLIP_PIXELS() \
- if (xf86FlipPixels) { \
- pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
- pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
- }
+void xf86KbdGetMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
-#endif /* _XF86PRIV_H */
+/* xf86Lock.c */
+#ifdef USE_XF86_SERVERLOCK
+void xf86UnlockServer(void);
+#endif
+/* xf86XKB.c */
+
+void xf86InitXkb(void);
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+
+#endif /* _XF86PRIV_H */
diff --git a/hw/xfree86/common/xf86Version.h b/hw/xfree86/common/xf86Version.h
index f403c31f5..e548b0437 100644
--- a/hw/xfree86/common/xf86Version.h
+++ b/hw/xfree86/common/xf86Version.h
@@ -1,23 +1,33 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.236.2.50 1998/03/02 09:58:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.543.2.1 2003/05/10 01:10:10 dawes Exp $ */
-#define XF86_VERSION " 3.3.2 "
+#ifndef XF86_VERSION_CURRENT
-/* The finer points in versions... */
-#define XF86_VERSION_MAJOR 3
+#define XF86_VERSION_MAJOR 4
#define XF86_VERSION_MINOR 3
-#define XF86_VERSION_SUBMINOR 2
-#define XF86_VERSION_BETA 0 /* 0="", 1="A", 2="B", etc... */
-#define XF86_VERSION_ALPHA 0 /* 0="", 1="a", 2="b", etc... */
+#define XF86_VERSION_PATCH 0
+#define XF86_VERSION_SNAP 1
+
+/* This has five arguments for compatibilty reasons */
+#define XF86_VERSION_NUMERIC(major,minor,patch,snap,dummy) \
+ (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap)
+
+#define XF86_GET_MAJOR_VERSION(vers) ((vers) / 10000000)
+#define XF86_GET_MINOR_VERSION(vers) (((vers) % 10000000) / 100000)
+#define XF86_GET_PATCH_VERSION(vers) (((vers) % 100000) / 1000)
+#define XF86_GET_SNAP_VERSION(vers) ((vers) % 1000)
+
+/* Define these for compatibility. They'll be removed at some point. */
+#define XF86_VERSION_SUBMINOR XF86_VERSION_PATCH
+#define XF86_VERSION_BETA 0
+#define XF86_VERSION_ALPHA XF86_VERSION_SNAP
-#define XF86_VERSION_NUMERIC(major,minor,subminor,beta,alpha) \
- ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
#define XF86_VERSION_CURRENT \
XF86_VERSION_NUMERIC(XF86_VERSION_MAJOR, \
XF86_VERSION_MINOR, \
- XF86_VERSION_SUBMINOR, \
- XF86_VERSION_BETA, \
- XF86_VERSION_ALPHA)
+ XF86_VERSION_PATCH, \
+ XF86_VERSION_SNAP, \
+ 0)
-#define XF86_DATE "March 2 1998"
+#endif
-/* $Xorg: xf86Version.h,v 1.3 2000/08/17 19:48:48 cpqbld Exp $ */
+/* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */
diff --git a/hw/xfree86/common/xf86XKB.c b/hw/xfree86/common/xf86XKB.c
index c5ac740fd..ddd3055ab 100644
--- a/hw/xfree86/common/xf86XKB.c
+++ b/hw/xfree86/common/xf86XKB.c
@@ -1,4 +1,4 @@
-/* $Xorg: xf86XKB.c,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */
+/* $XConsortium: xf86XKB.c /main/4 1996/02/04 09:28:04 kaleb $ */
/************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.6 1996/12/28 11:14:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.11 2002/10/11 01:40:31 dawes Exp $ */
#include <stdio.h>
#define NEED_EVENTS 1
@@ -38,81 +38,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
#include "XKBsrv.h"
-#ifdef AMOEBA
-#define LED_CAP IOP_LED_CAP
-#define LED_NUM IOP_LED_NUM
-#define LED_SCR IOP_LED_SCROLL
-#endif
-
-#ifdef MINIX
-#define LED_CAP KBD_LEDS_CAPS
-#define LED_NUM KBD_LEDS_NUM
-#define LED_SCR KBD_LEDS_SCROLL
-#endif
-
-void
-xf86InitXkb()
-{
-}
-
-void
-#if NeedFunctionPrototypes
-XkbDDXUpdateIndicators(DeviceIntPtr pXDev,CARD32 new)
-#else
-XkbDDXUpdateIndicators(pXDev,new)
- DeviceIntPtr pXDev;
- CARD32 new;
-#endif
-{
- CARD32 old;
-#ifdef DEBUG
-/* if (xkbDebugFlags)*/
- ErrorF("XkbDDXUpdateIndicators(...,0x%x) -- XFree86 version\n",new);
-#endif
-#ifdef LED_CAP
- old= new;
- new= 0;
- if (old&XLED1) new|= LED_CAP;
- if (old&XLED2) new|= LED_NUM;
- if (old&XLED3) new|= LED_SCR;
-#endif
- xf86SetKbdLeds(new);
- return;
-}
-
void
-#if NeedFunctionPrototypes
-XkbDDXUpdateDeviceIndicators( DeviceIntPtr dev,
- XkbSrvLedInfoPtr sli,
- CARD32 new)
-#else
-XkbDDXUpdateDeviceIndicators(dev,sli,new)
- DeviceIntPtr dev;
- XkbSrvLedInfoPtr sli;
- CARD32 new;
-#endif
+xf86InitXkb(void)
{
- if (sli->fb.kf==dev->kbdfeed)
- XkbDDXUpdateIndicators(dev,new);
- else if (sli->class==KbdFeedbackClass) {
- KbdFeedbackPtr kf;
- kf= sli->fb.kf;
- if (kf && kf->CtrlProc) {
- (*kf->CtrlProc)(dev,&kf->ctrl);
- }
- }
- else if (sli->class==LedFeedbackClass) {
- LedFeedbackPtr lf;
- lf= sli->fb.lf;
- if (lf && lf->CtrlProc) {
- (*lf->CtrlProc)(dev,&lf->ctrl);
- }
- }
- return;
}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7659deb3f..53fa1b3ff 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1,6 +1,6 @@
-/* $Xorg: xf86Xinput.c,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */
+/* $XConsortium: xf86Xinput.c /main/14 1996/10/27 11:05:25 kaleb $ */
/*
- * Copyright 1995,1996 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
+ * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@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
@@ -22,25 +22,37 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.22.2.7 1998/02/07 10:05:22 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.68 2002/10/11 01:40:31 dawes Exp $ */
+#include "Xfuncproto.h"
#include "Xmd.h"
+#ifdef XINPUT
#include "XI.h"
#include "XIproto.h"
+#endif
#include "xf86.h"
-#include "Xpoll.h"
#include "xf86Priv.h"
-#include "xf86_Config.h"
#include "xf86Xinput.h"
-#include "xf86Procs.h"
+#ifdef XINPUT
+#include "XIstubs.h"
+#endif
#include "mipointer.h"
+#include "xf86InPriv.h"
#ifdef DPMSExtension
+#define DPMS_SERVER
#include "extensions/dpms.h"
+#include "dpmsproc.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
#endif
#include "exevents.h" /* AddInputDevice */
+#include "exglobals.h"
+#define EXTENSION_PROC_ARGS void *
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
@@ -48,40 +60,34 @@
#include <stdarg.h>
-extern InputInfo inputInfo;
+#include "osdep.h" /* EnabledDevices */
+#include "Xpoll.h"
+#include "xf86_OSproc.h" /* sigio stuff */
-#ifndef DYNAMIC_MODULE
-#ifdef JOYSTICK_SUPPORT
-extern DeviceAssocRec joystick_assoc;
-#endif
-#ifdef WACOM_SUPPORT
-extern DeviceAssocRec wacom_stylus_assoc;
-extern DeviceAssocRec wacom_cursor_assoc;
-extern DeviceAssocRec wacom_eraser_assoc;
-#endif
-#ifdef ELOGRAPHICS_SUPPORT
-extern DeviceAssocRec elographics_assoc;
-#endif
-#ifdef SUMMASKETCH_SUPPORT
-extern DeviceAssocRec summasketch_assoc;
+/******************************************************************************
+ * debugging macro
+ *****************************************************************************/
+#ifdef DBG
+#undef DBG
#endif
+#ifdef DEBUG
+#undef DEBUG
#endif
-extern DeviceAssocRec mouse_assoc;
+#define DEBUG 0
-static int num_devices;
-static LocalDevicePtr *localDevices;
-static int max_devices;
+#if DEBUG
+static int debug_level = 0;
-static DeviceAssocPtr *deviceAssoc = NULL;
-static int numAssoc = 0;
-static int maxAssoc = 0;
+#define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
+#else
+#define DBG(lvl, f)
+#endif
-static SymTabRec XinputTab[] = {
- { ENDSECTION, "endsection"},
- { SUBSECTION, "subsection" },
- { -1, "" },
-};
+/******************************************************************************
+ * macros
+ *****************************************************************************/
+#define ENQUEUE(e) xf86eqEnqueue((e))
/***********************************************************************
*
@@ -110,20 +116,27 @@ xf86AlwaysCoreControl(DeviceIntPtr device,
int
xf86IsCorePointer(DeviceIntPtr device)
{
+ return(device == inputInfo.pointer);
+}
+
+static int
+xf86ShareCorePointer(DeviceIntPtr device)
+{
LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
return((local->always_core_feedback &&
- local->always_core_feedback->ctrl.integer_displayed) ||
- (device == inputInfo.pointer));
+ local->always_core_feedback->ctrl.integer_displayed));
}
-static int
-xf86IsAlwaysCore(DeviceIntPtr device)
+static Bool
+xf86SendDragEvents(DeviceIntPtr device)
{
- LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
- return(local->always_core_feedback &&
- local->always_core_feedback->ctrl.integer_displayed);
+ if (inputInfo.pointer->button->buttonsDown > 0)
+ return (local->flags & XI86_SEND_DRAG_EVENTS);
+ else
+ return (TRUE);
}
int
@@ -136,8 +149,7 @@ xf86IsCoreKeyboard(DeviceIntPtr device)
}
void
-xf86AlwaysCore(LocalDevicePtr local,
- Bool always)
+xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always)
{
if (always) {
local->flags |= XI86_ALWAYS_CORE;
@@ -146,6 +158,8 @@ xf86AlwaysCore(LocalDevicePtr local,
}
}
+static int xf86CoreButtonState;
+
/***********************************************************************
*
* xf86CheckButton --
@@ -159,153 +173,64 @@ Bool
xf86CheckButton(int button,
int down)
{
- /* The device may have up to MSE_MAXBUTTONS (12) buttons. */
- int state = (inputInfo.pointer->button->state & 0x0fff00) >> 8;
- int check = (state & (1 << (button - 1)));
+ int check;
+ int bit = (1 << (button - 1));
+
+ check = xf86CoreButtonState & bit;
- if ((check && down) && (!check && !down)) {
+ DBG(5, ErrorF("xf86CheckButton "
+ "button=%d down=%d state=%d check=%d returns ",
+ button, down, state, check));
+ if ((check && down) || (!check && !down)) {
+ DBG(5, ErrorF("FALSE\n"));
return FALSE;
}
+ xf86CoreButtonState ^= bit;
+ DBG(5, ErrorF("TRUE\n"));
return TRUE;
}
/***********************************************************************
*
- * ReadInput --
- * Wakeup handler to catch input and dispatch it to our
- * input routines if necessary.
+ * xf86ProcessCommonOptions --
+ *
+ * Process global options.
*
***********************************************************************
*/
-static void
-ReadInput(pointer block_data,
- int select_status,
- pointer read_mask)
+void
+xf86ProcessCommonOptions(LocalDevicePtr local,
+ pointer list)
{
- int i;
- LocalDevicePtr local_dev;
- fd_set* LastSelectMask = (fd_set*) read_mask;
- fd_set devices_with_input;
- extern fd_set EnabledDevices;
-
- if (select_status < 1)
- return;
-
- XFD_ANDSET(&devices_with_input, LastSelectMask, &EnabledDevices);
- if (!XFD_ANYSET(&devices_with_input))
- return;
-
- for (i = 0; i < num_devices; i++) {
- local_dev = localDevices[i];
- if (local_dev->read_input &&
- (local_dev->fd >= 0) &&
- (FD_ISSET(local_dev->fd, ((fd_set *) read_mask)) != 0)) {
- (*local_dev->read_input)(local_dev);
- break;
+ if (xf86SetBoolOption(list, "AlwaysCore", 0) ||
+ xf86SetBoolOption(list, "SendCoreEvents", 0)) {
+ local->flags |= XI86_ALWAYS_CORE;
+ xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
}
- }
-}
-/***********************************************************************
- *
- * configExtendedInputSection --
- *
- ***********************************************************************
- */
-
-void
-xf86ConfigExtendedInputSection(LexPtr val)
-{
- int i;
- int token;
-
-#ifndef DYNAMIC_MODULE
-# ifdef JOYSTICK_SUPPORT
- xf86AddDeviceAssoc(&joystick_assoc);
-# endif
-# ifdef WACOM_SUPPORT
- xf86AddDeviceAssoc(&wacom_stylus_assoc);
- xf86AddDeviceAssoc(&wacom_cursor_assoc);
- xf86AddDeviceAssoc(&wacom_eraser_assoc);
-# endif
-# ifdef ELOGRAPHICS_SUPPORT
- xf86AddDeviceAssoc(&elographics_assoc);
-# endif
-# ifdef SUMMASKETCH_SUPPORT
- xf86AddDeviceAssoc(&summasketch_assoc);
-# endif
-#endif
+ if (xf86SetBoolOption(list, "CorePointer", 0)) {
+ local->flags |= XI86_CORE_POINTER;
+ xf86Msg(X_CONFIG, "%s: Core Pointer\n", local->name);
+ }
- xf86AddDeviceAssoc(&mouse_assoc);
-
- num_devices = 0;
- max_devices = 3;
- localDevices = (LocalDevicePtr*) xalloc(sizeof(LocalDevicePtr)*max_devices);
-
- while ((token = xf86GetToken(XinputTab)) != ENDSECTION)
- {
- if (token == SUBSECTION)
- {
- int found = 0;
-
- if (xf86GetToken(NULL) != STRING)
- xf86ConfigError("SubSection name expected");
-
- for(i=0; !found && i<numAssoc; i++)
- {
- if (StrCaseCmp(val->str, deviceAssoc[i]->config_section_name) == 0)
- {
- if (num_devices == max_devices) {
- max_devices *= 2;
- localDevices = (LocalDevicePtr*) xrealloc(localDevices,
- sizeof(LocalDevicePtr)*max_devices);
- }
- localDevices[num_devices] = deviceAssoc[i]->device_allocate();
-
- if (localDevices[num_devices] && localDevices[num_devices]->device_config)
- {
- (*localDevices[num_devices]->device_config)(localDevices,
- num_devices,
- num_devices+1,
- val);
- localDevices[num_devices]->flags |= XI86_CONFIGURED;
- num_devices++;
- }
- found = 1;
- }
- }
- if (!found)
- xf86ConfigError("Invalid SubSection name");
- }
- else
- xf86ConfigError("XInput keyword section expected");
+ if (xf86SetBoolOption(list, "CoreKeyboard", 0)) {
+ local->flags |= XI86_CORE_KEYBOARD;
+ xf86Msg(X_CONFIG, "%s: Core Keyboard\n", local->name);
}
-}
-/***********************************************************************
- *
- * xf86AddDeviceAssoc --
- *
- * Add an association to the array deviceAssoc. This is needed to
- * allow dynamic loading of devices to register themself.
- *
- ***********************************************************************
- */
-void
-xf86AddDeviceAssoc(DeviceAssocPtr assoc)
-{
- if (!deviceAssoc) {
- maxAssoc = 10;
- deviceAssoc = (DeviceAssocPtr*) xalloc(sizeof(DeviceAssocPtr)*maxAssoc);
+ if (xf86SetBoolOption(list, "SendDragEvents", 1)) {
+ local->flags |= XI86_SEND_DRAG_EVENTS;
} else {
- if (maxAssoc == numAssoc) {
- maxAssoc *= 2;
- deviceAssoc = (DeviceAssocPtr*) xrealloc(deviceAssoc, sizeof(DeviceAssocPtr)*maxAssoc);
- }
+ xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
+ }
+
+ local->history_size = xf86SetIntOption(list, "HistorySize", 0);
+
+ if (local->history_size > 0) {
+ xf86Msg(X_CONFIG, "%s: has a history of %d motions\n", local->name,
+ local->history_size);
}
- deviceAssoc[numAssoc] = assoc;
- numAssoc++;
}
/***********************************************************************
@@ -321,6 +246,9 @@ void
xf86XinputFinalizeInit(DeviceIntPtr dev)
{
LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+
+ local->dxremaind = 0.0;
+ local->dyremaind = 0.0;
if (InitIntegerFeedbackClassDeviceStruct(dev, xf86AlwaysCoreControl) == FALSE) {
ErrorF("Unable to init integer feedback for always core feature\n");
@@ -330,57 +258,61 @@ xf86XinputFinalizeInit(DeviceIntPtr dev)
}
}
-
/***********************************************************************
*
- * InitExtInput --
+ * xf86ActivateDevice --
*
- * Initialize any extended devices we might have. It is called from
- * ddx InitInput.
+ * Initialize an input device.
*
***********************************************************************
*/
-
void
-InitExtInput()
+xf86ActivateDevice(LocalDevicePtr local)
{
DeviceIntPtr dev;
- int i;
- /* Register a Wakeup handler to handle input when generated */
- RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr) NoopDDA, ReadInput,
- NULL);
-
- /* Add each device */
- for (i = 0; i < num_devices; i++) {
- if (localDevices[i]->flags & XI86_CONFIGURED) {
- int open_on_init;
-
- open_on_init = !(localDevices[i]->flags & XI86_NO_OPEN_ON_INIT) ||
- (localDevices[i]->flags & XI86_ALWAYS_CORE);
-
- dev = AddInputDevice(localDevices[i]->device_control,
- open_on_init);
- if (dev == NULL)
- FatalError("Too many input devices");
-
- localDevices[i]->atom = MakeAtom(localDevices[i]->name,
- strlen(localDevices[i]->name),
- TRUE);
- dev->public.devicePrivate = (pointer) localDevices[i];
- localDevices[i]->dev = dev;
+ if (local->flags & XI86_CONFIGURED) {
+ int open_on_init;
+
+ open_on_init = local->flags &
+ (XI86_OPEN_ON_INIT |
+ XI86_ALWAYS_CORE | XI86_CORE_POINTER | XI86_CORE_KEYBOARD);
+
+ dev = AddInputDevice(local->device_control,
+ open_on_init);
+ if (dev == NULL)
+ FatalError("Too many input devices");
+
+ local->atom = MakeAtom(local->name,
+ strlen(local->name),
+ TRUE);
+ AssignTypeAndName (dev, local->atom, local->name);
+ dev->public.devicePrivate = (pointer) local;
+ local->dev = dev;
+
+ xf86XinputFinalizeInit(dev);
- xf86XinputFinalizeInit(dev);
-
+ /*
+ * XXX Can a single device instance be both core keyboard and
+ * core pointer? If so, this should be changed.
+ */
+ if (local->flags & XI86_CORE_POINTER)
+ RegisterPointerDevice(dev);
+ else if (local->flags & XI86_CORE_KEYBOARD)
+ RegisterKeyboardDevice(dev);
+#ifdef XINPUT
+ else
RegisterOtherDevice(dev);
- if (serverGeneration == 1)
- ErrorF("%s Adding extended device \"%s\" (type: %s)\n", XCONFIG_GIVEN,
- localDevices[i]->name, localDevices[i]->type_name);
- }
+#endif
+
+ if (serverGeneration == 1)
+ xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
+ local->name, local->type_name);
}
}
+#ifdef XINPUT
/***********************************************************************
*
* Caller: ProcXOpenDevice
@@ -405,13 +337,10 @@ InitExtInput()
*/
void
-OpenInputDevice (dev, client, status)
- DeviceIntPtr dev;
- ClientPtr client;
- int *status;
+OpenInputDevice(DeviceIntPtr dev,
+ ClientPtr client,
+ int *status)
{
- extern int BadDevice;
-
if (!dev->inited) {
*status = BadDevice;
} else {
@@ -453,9 +382,7 @@ OpenInputDevice (dev, client, status)
*/
int
-ChangeKeyboardDevice (old_dev, new_dev)
- DeviceIntPtr old_dev;
- DeviceIntPtr new_dev;
+ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev)
{
/**********************************************************************
* DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
@@ -496,17 +423,11 @@ ChangeKeyboardDevice (old_dev, new_dev)
*/
int
-#ifdef NeedFunctionPrototypes
ChangePointerDevice (
DeviceIntPtr old_dev,
DeviceIntPtr new_dev,
unsigned char x,
unsigned char y)
-#else
-ChangePointerDevice (old_dev, new_dev, x, y)
- DeviceIntPtr old_dev, new_dev;
- unsigned char x, y;
-#endif /* NeedFunctionPrototypes */
{
/************************************************************************
InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
@@ -518,6 +439,7 @@ ChangePointerDevice (old_dev, new_dev, x, y)
else
axes_changed = FALSE;
*************************************************************************/
+
/*
* We don't allow axis swap or other exotic features.
*/
@@ -561,9 +483,7 @@ ChangePointerDevice (old_dev, new_dev, x, y)
*/
void
-CloseInputDevice (d, client)
- DeviceIntPtr d;
- ClientPtr client;
+CloseInputDevice (DeviceIntPtr d, ClientPtr client)
{
ErrorF("ProcXCloseDevice to close or not ?\n");
}
@@ -616,10 +536,7 @@ AddOtherInputDevices ()
*/
int
-SetDeviceMode (client, dev, mode)
- register ClientPtr client;
- DeviceIntPtr dev;
- int mode;
+SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
{
LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
@@ -645,12 +562,8 @@ SetDeviceMode (client, dev, mode)
*/
int
-SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
- register ClientPtr client;
- DeviceIntPtr dev;
- int *valuators;
- int first_valuator;
- int num_valuators;
+SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
+ int first_valuator, int num_valuators)
{
return BadMatch;
}
@@ -666,10 +579,7 @@ SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
*/
int
-ChangeDeviceControl (client, dev, control)
- register ClientPtr client;
- DeviceIntPtr dev;
- xDeviceCtl *control;
+ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
{
LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
@@ -680,13 +590,12 @@ ChangeDeviceControl (client, dev, control)
return (*local->control_proc)(local, control);
}
}
+#endif
/*
* adapted from mieq.c to support extended events
*
*/
-extern InputInfo inputInfo;
-
#define QUEUE_SIZE 256
typedef struct _Event {
@@ -710,8 +619,7 @@ typedef struct _EventQueue {
static EventQueueRec xf86EventQueue;
Bool
-xf86eqInit (pKbd, pPtr)
- DevicePtr pKbd, pPtr;
+xf86eqInit (DevicePtr pKbd, DevicePtr pPtr)
{
xf86EventQueue.head = xf86EventQueue.tail = 0;
xf86EventQueue.lastEventTime = GetTimeInMillis ();
@@ -732,46 +640,56 @@ xf86eqInit (pKbd, pPtr)
*/
void
-xf86eqEnqueue (e)
- xEvent *e;
+xf86eqEnqueue (xEvent *e)
{
- int oldtail, newtail;
- Bool isMotion;
+ int oldtail, newtail;
+ Bool isMotion;
#ifdef XINPUT
- int count;
-
- switch (e->u.u.type)
- {
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
+ int count;
+
+ xf86AssertBlockedSIGIO ("xf86eqEnqueue");
+ switch (e->u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+#ifdef XFreeXDGA
+ /* we do this here, because nobody seems to be calling
+ xf86PostKeyEvent(). We can't steal MotionNotify events here
+ because the motion-relative information has been lost already. */
+ if(DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, e))
+ return;
+#endif
+ /* fall through */
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
count = 1;
break;
- default:
- if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS)
- {
+ default:
+#ifdef XFreeXDGA
+ if (DGAIsDgaEvent (e))
+ {
+ count = 1;
+ break;
+ }
+#endif
+ if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS) {
count = 1;
- }
- else
- {
- count = 2;
- }
+ }
+ else {
+ count = 2;
+ }
break;
- }
+ }
#endif
oldtail = xf86EventQueue.tail;
isMotion = e->u.u.type == MotionNotify;
- if (isMotion && xf86EventQueue.lastMotion && oldtail != xf86EventQueue.head)
- {
+ if (isMotion && xf86EventQueue.lastMotion && oldtail != xf86EventQueue.head) {
if (oldtail == 0)
oldtail = QUEUE_SIZE;
oldtail = oldtail - 1;
}
- else
- {
+ else {
newtail = oldtail + 1;
if (newtail == QUEUE_SIZE)
newtail = 0;
@@ -784,9 +702,8 @@ xf86eqEnqueue (e)
xf86EventQueue.lastMotion = isMotion;
xf86EventQueue.events[oldtail].event = *e;
#ifdef XINPUT
- if (count == 2)
- {
- xf86EventQueue.events[oldtail].val = *((deviceValuator *) (((deviceKeyButtonPointer *) e)+1));
+ if (count == 2) {
+ xf86EventQueue.events[oldtail].val = *((deviceValuator *) (((deviceKeyButtonPointer *) e)+1));
}
#endif
/*
@@ -794,8 +711,8 @@ xf86eqEnqueue (e)
* is "unnecessary", but very useful
*/
if (e->u.keyButtonPointer.time < xf86EventQueue.lastEventTime &&
- xf86EventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
- {
+ xf86EventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) {
+
xf86EventQueue.events[oldtail].event.u.keyButtonPointer.time =
xf86EventQueue.lastEventTime;
}
@@ -810,28 +727,31 @@ xf86eqProcessInputEvents ()
{
EventRec *e;
int x, y;
- xEvent xe;
+ struct {
+ xEvent event;
+#ifdef XINPUT
+ deviceValuator val;
+#endif
+ } xe;
#ifdef XINPUT
DeviceIntPtr dev;
int id, count;
deviceKeyButtonPointer *dev_xe;
#endif
- while (xf86EventQueue.head != xf86EventQueue.tail)
- {
+ while (xf86EventQueue.head != xf86EventQueue.tail) {
if (screenIsSaved == SCREEN_SAVER_ON)
SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
#ifdef DPMSExtension
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(DPMSModeOn);
#endif
e = &xf86EventQueue.events[xf86EventQueue.head];
/*
* Assumption - screen switching can only occur on motion events
*/
- if (e->pScreen != xf86EventQueue.pDequeueScreen)
- {
+ if (e->pScreen != xf86EventQueue.pDequeueScreen) {
xf86EventQueue.pDequeueScreen = e->pScreen;
x = e->event.u.keyButtonPointer.rootX;
y = e->event.u.keyButtonPointer.rootY;
@@ -841,54 +761,56 @@ xf86eqProcessInputEvents ()
++xf86EventQueue.head;
NewCurrentScreen (xf86EventQueue.pDequeueScreen, x, y);
}
- else
- {
- xe = e->event;
+ else {
+ xe.event = e->event;
+ xe.val = e->val;
if (xf86EventQueue.head == QUEUE_SIZE - 1)
xf86EventQueue.head = 0;
else
++xf86EventQueue.head;
- switch (xe.u.u.type)
- {
+ switch (xe.event.u.u.type) {
case KeyPress:
case KeyRelease:
(*xf86EventQueue.pKbd->processInputProc)
- (&xe, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
break;
#ifdef XINPUT
case ButtonPress:
case ButtonRelease:
case MotionNotify:
(*(inputInfo.pointer->public.processInputProc))
- (&xe, (DeviceIntPtr)inputInfo.pointer, 1);
- break;
+ (&xe.event, (DeviceIntPtr)inputInfo.pointer, 1);
+ break;
default:
- dev_xe = (deviceKeyButtonPointer *) e;
- id = dev_xe->deviceid & DEVICE_BITS;
- if (!(dev_xe->deviceid & MORE_EVENTS)) {
- count = 1;
- } else {
- count = 2;
- }
- dev = LookupDeviceIntRec(id);
- if (dev == NULL)
- {
- ErrorF("LookupDeviceIntRec id=0x%x not found\n", id);
+#ifdef XFreeXDGA
+ if (DGADeliverEvent (xf86EventQueue.pDequeueScreen, &xe.event))
+ break;
+#endif
+ dev_xe = (deviceKeyButtonPointer *) &xe.event;
+ id = dev_xe->deviceid & DEVICE_BITS;
+ if (!(dev_xe->deviceid & MORE_EVENTS)) {
+ count = 1;
+ }
+ else {
+ count = 2;
+ }
+ dev = LookupDeviceIntRec(id);
+ if (dev == NULL) {
+ ErrorF("LookupDeviceIntRec id=0x%x not found\n", id);
/* FatalError("xf86eqProcessInputEvents : device not found.\n");
*/
- break;
- }
- if (!dev->public.processInputProc)
- {
- FatalError("xf86eqProcessInputEvents : device has no input proc.\n");
- break;
- }
- (*dev->public.processInputProc)(&e->event, dev, count);
+ break;
+ }
+ if (!dev->public.processInputProc) {
+ FatalError("xf86eqProcessInputEvents : device has no input proc.\n");
+ break;
+ }
+ (*dev->public.processInputProc)(&xe.event, dev, count);
#else
default:
(*xf86EventQueue.pPtr->processInputProc)
- (&xe, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
#endif
break;
}
@@ -896,6 +818,16 @@ xf86eqProcessInputEvents ()
}
}
+void
+xf86eqSwitchScreen(ScreenPtr pScreen,
+ Bool fromDIX)
+{
+ xf86EventQueue.pEnqueueScreen = pScreen;
+
+ if (fromDIX)
+ xf86EventQueue.pDequeueScreen = pScreen;
+}
+
/*
* convenient functions to post events
*/
@@ -912,87 +844,206 @@ xf86PostMotionEvent(DeviceIntPtr device,
xEvent xE[2];
deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
deviceValuator *xv = (deviceValuator*) xev+1;
- LocalDevicePtr local = (LocalDevicePtr)device->public.devicePrivate;
- char *buff;
- Time current = GetTimeInMillis();
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+ char *buff = 0;
+ Time current;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_shared = xf86ShareCorePointer(device);
+ Bool drag = xf86SendDragEvents(device);
+ ValuatorClassPtr val = device->valuator;
+ int valuator[6];
+ int oldaxis[6];
+ int *axisvals;
+ AxisInfoPtr axes;
+ int dx = 0, dy = 0;
+ float mult;
+ int x, y;
+ int loop_start;
+ int i;
+ int num;
- if (HAS_MOTION_HISTORY(local)) {
+ DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) is_core=%s is_shared=%s is_absolute=%s\n",
+ device, device->name,
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+ xf86Info.lastEventTime = xev->time = current = GetTimeInMillis();
+
+ if (!is_core) {
+ if (HAS_MOTION_HISTORY(local)) {
buff = ((char *)local->motion_history +
(sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last);
- } else
- buff = 0;
+ }
+ }
+
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
+
+ axisvals = val->axisVal;
+ axes = val->axes;
va_start(var, num_valuators);
+ loop_start = first_valuator;
for(loop=0; loop<num_valuators; loop++) {
- switch (loop % 6) {
- case 0:
- xv->valuator0 = va_arg(var, int);
- break;
- case 1:
- xv->valuator1 = va_arg(var, int);
- break;
- case 2:
- xv->valuator2 = va_arg(var, int);
- break;
- case 3:
- xv->valuator3 = va_arg(var, int);
- break;
- case 4:
- xv->valuator4 = va_arg(var, int);
- break;
- case 5:
- xv->valuator5 = va_arg(var, int);
- break;
- }
- if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
- if (!xf86IsCorePointer(device)) {
+
+ valuator[loop%6] = va_arg(var,int);
+
+ if (loop % 6 == 5 || loop == num_valuators - 1) {
+ num = loop % 6 + 1;
+ /*
+ * Adjust first two relative valuators
+ */
+ if (!is_absolute && num_valuators >= 2 && loop_start == 0) {
+
+ dx = valuator[0];
+ dy = valuator[1];
+
+ /*
+ * Accelerate
+ */
+ if (device->ptrfeed && device->ptrfeed->ctrl.num) {
+ /* modeled from xf86Events.c */
+ if (device->ptrfeed->ctrl.threshold) {
+ if ((abs(dx) + abs(dy)) >= device->ptrfeed->ctrl.threshold) {
+ valuator[0] = (dx * device->ptrfeed->ctrl.num) /
+ device->ptrfeed->ctrl.den;
+ valuator[1] = (dy * device->ptrfeed->ctrl.num) /
+ device->ptrfeed->ctrl.den;
+ }
+ }
+ else if (dx || dy) {
+ mult = pow((float)(dx*dx+dy*dy),
+ ((float)(device->ptrfeed->ctrl.num) /
+ (float)(device->ptrfeed->ctrl.den) - 1.0) /
+ 2.0) / 2.0;
+ if (dx) {
+ local->dxremaind = mult * (float)dx + local->dxremaind;
+ valuator[0] = (int)local->dxremaind;
+ local->dxremaind = local->dxremaind - (float)valuator[0];
+ }
+ if (dy) {
+ local->dyremaind = mult * (float)dy + local->dyremaind;
+ valuator[1] = (int)local->dyremaind;
+ local->dyremaind = local->dyremaind - (float)valuator[1];
+ }
+ }
+ DBG(6, ErrorF("xf86PostMotionEvent acceleration v0=%d v1=%d\n",
+ valuator[0], valuator[1]));
+ }
+
+ /*
+ * Map current position back to device space in case
+ * the cursor was warped
+ */
+ if (is_core || is_shared)
+ {
+ miPointerPosition (&x, &y);
+ if (local->reverse_conversion_proc)
+ (*local->reverse_conversion_proc)(local, x, y, axisvals);
+ else
+ {
+ axisvals[0] = x;
+ axisvals[1] = y;
+ }
+ }
+ }
+
+ /*
+ * Update axes
+ */
+ for (i = 0; i < num; i++)
+ {
+ oldaxis[i] = axisvals[loop_start + i];
+ if (is_absolute)
+ axisvals[loop_start + i] = valuator[i];
+ else
+ axisvals[loop_start + i] += valuator[i];
+ }
+
+ /*
+ * Deliver extension event
+ */
+ if (!is_core) {
xev->type = DeviceMotionNotify;
xev->detail = 0;
- xf86Info.lastEventTime = xev->time = current;
xev->deviceid = device->id | MORE_EVENTS;
xv->type = DeviceValuator;
xv->deviceid = device->id;
- xv->num_valuators = (loop % 6) + 1;
- xv->first_valuator = first_valuator + (loop / 6) * 6;
xv->device_state = 0;
+ xv->num_valuators = num;
+ xv->first_valuator = loop_start;
+ memcpy (&xv->valuator0, &axisvals[loop_start],
+ sizeof(INT32)*xv->num_valuators);
if (HAS_MOTION_HISTORY(local)) {
*(Time*)buff = current;
- memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator, &xv->valuator0,
+ memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator,
+ &axisvals[loop_start],
sizeof(INT32)*xv->num_valuators);
}
-
- xf86eqEnqueue(xE);
- } else {
- xf86Info.lastEventTime = current;
+ ENQUEUE(xE);
+ }
- if (num_valuators >= 2) {
- if (is_absolute) {
- miPointerAbsoluteCursor(xv->valuator0, xv->valuator1, xf86Info.lastEventTime);
- } else {
- if (device->ptrfeed) {
- /* modeled from xf86Events.c */
- if ((abs(xv->valuator0) + abs(xv->valuator1)) >= device->ptrfeed->ctrl.threshold) {
- xv->valuator0 = (xv->valuator0 * device->ptrfeed->ctrl.num) / device->ptrfeed->ctrl.den;
- xv->valuator1 = (xv->valuator1 * device->ptrfeed->ctrl.num) / device->ptrfeed->ctrl.den;
- }
- }
- miPointerDeltaCursor(xv->valuator0, xv->valuator1, xf86Info.lastEventTime);
- }
+ /*
+ * Deliver core event
+ */
+ if (is_core ||
+ (is_shared && num_valuators >= 2 && loop_start == 0)) {
+#ifdef XFreeXDGA
+ /*
+ * Let DGA peek at the event and steal it
+ */
+ xev->type = MotionNotify;
+ xev->detail = 0;
+ if (is_absolute)
+ {
+ dx = axisvals[0] - oldaxis[0];
+ dy = axisvals[1] - oldaxis[1];
+ }
+ if (DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum,
+ xE, dx, dy))
+ continue;
+#endif
+ if (!(*local->conversion_proc)(local, loop_start, num,
+ axisvals[0], axisvals[1],
+ axisvals[2], axisvals[3],
+ axisvals[4], axisvals[5],
+ &x, &y))
+ continue;
+
+ if (drag)
+ miPointerAbsoluteCursor (x, y, current);
+ /*
+ * Retrieve the position
+ */
+ miPointerPosition (&x, &y);
+ if (local->reverse_conversion_proc)
+ (*local->reverse_conversion_proc)(local, x, y, axisvals);
+ else
+ {
+ axisvals[0] = x;
+ axisvals[1] = y;
}
- break;
}
+ loop_start += 6;
}
- va_end(var);
}
+ va_end(var);
if (HAS_MOTION_HISTORY(local)) {
local->last = (local->last + 1) % device->valuator->numMotionEvents;
if (local->last == local->first)
local->first = (local->first + 1) % device->valuator->numMotionEvents;
}
+ DBG(5, ErrorF("xf86PostMotionEvent END 0x%x(%s) is_core=%s is_shared=%s\n",
+ device, device->name,
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False"));
}
void
@@ -1007,47 +1058,85 @@ xf86PostProximityEvent(DeviceIntPtr device,
xEvent xE[2];
deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
deviceValuator *xv = (deviceValuator*) xev+1;
+ ValuatorClassPtr val = device->valuator;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_absolute = val && ((val->mode & 1) == Relative);
+
+ DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
+ device, device->name, is_in ? "true" : "false",
+ is_core ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+ if (is_core) {
+ return;
+ }
+
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
- va_start(var, num_valuators);
-
- for(loop=0; loop<num_valuators; loop++) {
- switch (loop % 6) {
- case 0:
- xv->valuator0 = va_arg(var, int);
- break;
- case 1:
- xv->valuator1 = va_arg(var, int);
- break;
- case 2:
- xv->valuator2 = va_arg(var, int);
- break;
- case 3:
- xv->valuator3 = va_arg(var, int);
- break;
- case 4:
- xv->valuator4 = va_arg(var, int);
- break;
- case 5:
- xv->valuator5 = va_arg(var, int);
- break;
- }
- if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
- xev->type = is_in ? ProximityIn : ProximityOut;
- xev->detail = 0;
- xf86Info.lastEventTime = xev->time = GetTimeInMillis();
- xev->deviceid = device->id | MORE_EVENTS;
-
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
-
- xv->num_valuators = (loop % 6) + 1;
- xv->first_valuator = first_valuator + (loop / 6) * 6;
- xv->device_state = 0;
+ xev->type = is_in ? ProximityIn : ProximityOut;
+ xev->detail = 0;
+ xev->deviceid = device->id | MORE_EVENTS;
- xf86eqEnqueue(xE);
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+ xv->device_state = 0;
+
+ if ((device->valuator->mode & 1) == Relative) {
+ num_valuators = 0;
+ }
+
+ if (num_valuators != 0) {
+ int *axisvals = val->axisVal;
+
+ va_start(var, num_valuators);
+
+ for(loop=0; loop<num_valuators; loop++) {
+ switch (loop % 6) {
+ case 0:
+ xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 1:
+ xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 2:
+ xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 3:
+ xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 4:
+ xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 5:
+ xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ }
+ if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+ xv->num_valuators = (loop % 6) + 1;
+ xv->first_valuator = first_valuator + (loop / 6) * 6;
+ ENQUEUE(xE);
+ }
}
+ va_end(var);
}
- va_end(var);
+ else {
+ /* no valuator */
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+ xv->num_valuators = 0;
+ xv->first_valuator = 0;
+ ENQUEUE(xE);
+ }
+ DBG(5, ErrorF("xf86PostProximityEvent END 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
+ device, device->name, is_in ? "true" : "false",
+ is_core ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
}
void
@@ -1064,89 +1153,97 @@ xf86PostButtonEvent(DeviceIntPtr device,
xEvent xE[2];
deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
deviceValuator *xv = (deviceValuator*) xev+1;
- int is_core_pointer = xf86IsCorePointer(device);
-
+ ValuatorClassPtr val = device->valuator;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_shared = xf86ShareCorePointer(device);
+
+ DBG(5, ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_core=%s is_shared=%s is_absolute=%s\n",
+ device, device->name, button,
+ is_down ? "True" : "False",
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
/* Check the core pointer button state not to send an inconsistent
* event. This can happen with the AlwaysCore feature.
*/
- if (is_core_pointer && !xf86CheckButton(button, is_down)) {
+ if ((is_core || is_shared) &&
+ !xf86CheckButton(device->button->map[button], is_down))
+ {
return;
}
- va_start(var, num_valuators);
-
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
- for(loop=0; loop<num_valuators; loop++) {
- switch (loop % 6) {
- case 0:
- xv->valuator0 = va_arg(var, int);
- break;
- case 1:
- xv->valuator1 = va_arg(var, int);
- break;
- case 2:
- xv->valuator2 = va_arg(var, int);
- break;
- case 3:
- xv->valuator3 = va_arg(var, int);
- break;
- case 4:
- xv->valuator4 = va_arg(var, int);
- break;
- case 5:
- xv->valuator5 = va_arg(var, int);
- break;
- }
- if (((loop % 6 == 5) || (loop == num_valuators - 1)) &&
- !is_core_pointer) {
- xev->type = is_down ? DeviceButtonPress : DeviceButtonRelease;
- xev->detail = button;
-
- xf86Info.lastEventTime = xev->time = GetTimeInMillis();
- xev->deviceid = device->id | MORE_EVENTS;
-
- xv->type = DeviceValuator;
- xv->deviceid = device->id;
- xv->device_state = 0;
- /* if the device is in the relative mode we don't have to send valuators */
- xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0;
- xv->first_valuator = first_valuator + (loop / 6) * 6;
- xf86eqEnqueue(xE);
- /* if the device is in the relative mode only one event is needed */
- if (!is_absolute) break;
- }
- if (is_core_pointer && loop == 1) {
- int cx, cy;
+ if (!is_core) {
+ xev->type = is_down ? DeviceButtonPress : DeviceButtonRelease;
+ xev->detail = button;
+ xev->deviceid = device->id | MORE_EVENTS;
- GetSpritePosition(&cx, &cy);
-
- /* Try to find the index in the core buttons map
- * which corresponds to the extended button for
- * an AlwaysCore device.
- */
- if (xf86IsAlwaysCore(device)) {
- int loop;
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+ xv->device_state = 0;
- button = device->button->map[button];
-
- for(loop=1; loop<=inputInfo.pointer->button->numButtons; loop++) {
- if (inputInfo.pointer->button->map[loop] == button) {
- button = loop;
- break;
- }
+ if (num_valuators != 0) {
+ int *axisvals = val->axisVal;
+
+ va_start(var, num_valuators);
+
+ for(loop=0; loop<num_valuators; loop++) {
+ switch (loop % 6) {
+ case 0:
+ xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 1:
+ xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 2:
+ xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 3:
+ xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 4:
+ xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 5:
+ xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ }
+ if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+ xv->num_valuators = (loop % 6) + 1;
+ xv->first_valuator = first_valuator + (loop / 6) * 6;
+ ENQUEUE(xE);
+
}
}
-
- xE->u.u.type = is_down ? ButtonPress : ButtonRelease;
- xE->u.u.detail = button;
- xE->u.keyButtonPointer.rootY = cx;
- xE->u.keyButtonPointer.rootX = cy;
- xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis();
- xf86eqEnqueue(xE);
- break;
+ va_end(var);
+ }
+ else {
+ /* no valuator */
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+ xv->num_valuators = 0;
+ xv->first_valuator = 0;
+ ENQUEUE(xE);
}
}
- va_end(var);
+
+ /* removed rootX/rootY as DIX sets these fields */
+ if (is_core || is_shared) {
+ xE->u.u.type = is_down ? ButtonPress : ButtonRelease;
+ xE->u.u.detail = device->button->map[button];
+ xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis();
+
+#ifdef XFreeXDGA
+ if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, 0, 0))
+#endif
+ ENQUEUE(xE);
+ }
+ DBG(5, ErrorF("xf86PostButtonEvent END\n"));
}
void
@@ -1166,7 +1263,6 @@ xf86PostKeyEvent(DeviceIntPtr device,
va_start(var, num_valuators);
-
for(loop=0; loop<num_valuators; loop++) {
switch (loop % 6) {
case 0:
@@ -1202,7 +1298,7 @@ xf86PostKeyEvent(DeviceIntPtr device,
xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0;
xv->first_valuator = first_valuator + (loop / 6) * 6;
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
/* if the device is in the relative mode only one event is needed */
if (!is_absolute) break;
}
@@ -1210,6 +1306,28 @@ xf86PostKeyEvent(DeviceIntPtr device,
va_end(var);
}
+void
+xf86PostKeyboardEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down)
+{
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+
+ if (xf86IsCoreKeyboard(device)) {
+ xev->type = is_down ? KeyPress : KeyRelease;
+ } else {
+ xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease;
+ }
+ xev->detail = key_code;
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+#ifdef XFreeXDGA
+ /* if(!DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, xE)) */
+#endif
+ ENQUEUE(xE);
+}
+
/*
* Motion history management.
*/
@@ -1221,7 +1339,7 @@ xf86MotionHistoryAllocate(LocalDevicePtr local)
if (!HAS_MOTION_HISTORY(local))
return;
-
+ if (local->motion_history) xfree(local->motion_history);
local->motion_history = xalloc((sizeof(INT32) * valuator->numAxes + sizeof(Time))
* valuator->numMotionEvents);
local->first = 0;
@@ -1261,4 +1379,102 @@ xf86GetMotionEvents(DeviceIntPtr dev,
return num;
}
+LocalDevicePtr
+xf86FirstLocalDevice()
+{
+ return xf86InputDevs;
+}
+
+/*
+ * Cx - raw data from touch screen
+ * Sxhigh - scaled highest dimension
+ * (remember, this is of rows - 1 because of 0 origin)
+ * Sxlow - scaled lowest dimension
+ * Rxhigh - highest raw value from touch screen calibration
+ * Rxlow - lowest raw value from touch screen calibration
+ *
+ * This function is the same for X or Y coordinates.
+ * You may have to reverse the high and low values to compensate for
+ * different orgins on the touch screen vs X.
+ */
+
+int
+xf86ScaleAxis(int Cx,
+ int Sxhigh,
+ int Sxlow,
+ int Rxhigh,
+ int Rxlow )
+{
+ int X;
+ int dSx = Sxhigh - Sxlow;
+ int dRx = Rxhigh - Rxlow;
+
+ dSx = Sxhigh - Sxlow;
+ if (dRx) {
+ X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow;
+ }
+ else {
+ X = 0;
+ ErrorF ("Divide by Zero in xf86ScaleAxis");
+ }
+
+ if (X > Sxlow)
+ X = Sxlow;
+ if (X < Sxhigh)
+ X = Sxhigh;
+
+ return (X);
+}
+
+/*
+ * This function checks the given screen against the current screen and
+ * makes changes if appropriate. It should be called from an XInput driver's
+ * ReadInput function before any events are posted, if the device is screen
+ * specific like a touch screen.
+ */
+void
+xf86XInputSetScreen(LocalDevicePtr local,
+ int screen_number,
+ int x,
+ int y)
+{
+ if ((xf86IsCorePointer(local->dev) || xf86ShareCorePointer(local->dev)) &&
+ (miPointerCurrentScreen() != screenInfo.screens[screen_number])) {
+ miPointerSetNewScreen (screen_number, x, y);
+ }
+}
+
+
+void
+xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
+ int resolution, int min_res, int max_res)
+{
+#ifdef XINPUT
+ if (maxval == -1) {
+ if (axnum == 0)
+ maxval = screenInfo.screens[0]->width - 1;
+ else if (axnum == 1)
+ maxval = screenInfo.screens[0]->height - 1;
+ /* else? */
+ }
+ InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution, min_res,
+ max_res);
+#endif
+}
+
+/*
+ * Set the valuator values to be in synch with dix/event.c
+ * DefineInitialRootWindow().
+ */
+void
+xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
+{
+#ifdef XINPUT
+ if (axnum == 0)
+ dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+ else if (axnum == 1)
+ dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+#endif
+}
+
/* end of xf86Xinput.c */
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index b2bb8832f..1e9694402 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -1,6 +1,6 @@
-/* $Xorg: xf86Xinput.h,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */
+/* $XConsortium: xf86Xinput.h /main/11 1996/10/27 11:05:29 kaleb $ */
/*
- * Copyright 1995,1996 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
+ * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@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
@@ -22,7 +22,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.14.2.1 1997/05/12 12:52:29 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.35 2002/10/11 01:40:31 dawes Exp $ */
#ifndef _xf86Xinput_h
#define _xf86Xinput_h
@@ -30,251 +30,164 @@
#ifndef NEED_EVENTS
#define NEED_EVENTS
#endif
-#include "X.h"
-#include "Xproto.h"
+#include "xf86str.h"
#include "inputstr.h"
-#include "XI.h"
-#include "XIproto.h"
+#ifdef XINPUT
+#include "extensions/XI.h"
+#include "extensions/XIproto.h"
#include "XIstubs.h"
+#endif
+
+/* Input device flags */
+#define XI86_OPEN_ON_INIT 0x01 /* open the device at startup time */
+#define XI86_CONFIGURED 0x02 /* the device has been configured */
+#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */
+/* the device sends Xinput and core pointer events */
+#define XI86_SEND_CORE_EVENTS XI86_ALWAYS_CORE
+/* if the device is the core pointer or is sending core events, and
+ * SEND_DRAG_EVENTS is false, and a buttons is done, then no motion events
+ * (mouse drag action) are sent. This is mainly to allow a touch screen to be
+ * used with netscape and other browsers which do strange things if the mouse
+ * moves between button down and button up. With a touch screen, this motion
+ * is common due to the user's finger moving slightly.
+ */
+#define XI86_SEND_DRAG_EVENTS 0x08
+#define XI86_CORE_POINTER 0x10 /* device is the core pointer */
+#define XI86_CORE_KEYBOARD 0x20 /* device is the core keyboard */
+#define XI86_POINTER_CAPABLE 0x40 /* capable of being a core pointer */
+#define XI86_KEYBOARD_CAPABLE 0x80 /* capable of being a core keyboard */
-#define XI86_NO_OPEN_ON_INIT 1 /* open the device only when needed */
-#define XI86_CONFIGURED 2 /* the device has been configured */
-#define XI86_ALWAYS_CORE 4 /* the device always controls the pointer */
+#define XI_PRIVATE(dev) \
+ (((LocalDevicePtr)((dev)->public.devicePrivate))->private)
-#ifdef PRIVATE
-#undef PRIVATE
+#ifdef DBG
+#undef DBG
#endif
-#define PRIVATE(dev) (((LocalDevicePtr)((dev)->public.devicePrivate))->private)
+#define DBG(lvl, f) {if ((lvl) <= xf86GetVerbosity()) f;}
#ifdef HAS_MOTION_HISTORY
#undef HAS_MOTION_HISTORY
#endif
#define HAS_MOTION_HISTORY(local) ((local)->dev->valuator && (local)->dev->valuator->numMotionEvents)
-typedef struct _LocalDeviceRec {
- char *name;
- int flags;
- Bool (*device_config)(
-#if NeedNestedPrototypes
- struct _LocalDeviceRec** /*array*/,
- int /*index*/,
- int /*max*/,
- LexPtr /*val*/
-#endif
- );
- Bool (*device_control)(
-#if NeedNestedPrototypes
- DeviceIntPtr /*device*/,
- int /*what*/
-#endif
- );
- void (*read_input)(
-#if NeedNestedPrototypes
- struct _LocalDeviceRec* /*local*/
-#endif
- );
- int (*control_proc)(
-#if NeedNestedPrototypes
- struct _LocalDeviceRec* /*local*/,
- xDeviceCtl* /* control */
-#endif
- );
- void (*close_proc)(
-#if NeedNestedPrototypes
- struct _LocalDeviceRec* /*local*/
-#endif
- );
- int (*switch_mode)(
-#if NeedNestedPrototypes
- ClientPtr /*client*/,
- DeviceIntPtr /*dev*/,
- int /*mode*/
-#endif
- );
- int fd;
- Atom atom;
- DeviceIntPtr dev;
- pointer private;
- int private_flags;
- pointer motion_history;
- ValuatorMotionProcPtr motion_history_proc;
- unsigned int history_size; /* only for configuration purpose */
- unsigned int first;
- unsigned int last;
- char *type_name;
- IntegerFeedbackPtr always_core_feedback;
-} LocalDeviceRec, *LocalDevicePtr;
+#ifdef XINPUT
+/* This holds the input driver entry and module information. */
+typedef struct _InputDriverRec {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ struct _LocalDeviceRec *(*PreInit)(struct _InputDriverRec *drv,
+ IDevPtr dev, int flags);
+ void (*UnInit)(struct _InputDriverRec *drv,
+ struct _LocalDeviceRec *pInfo,
+ int flags);
+ pointer module;
+ int refCount;
+} InputDriverRec, *InputDriverPtr;
+#endif
+
+/* This is to input devices what the ScrnInfoRec is to screens. */
+
+typedef struct _LocalDeviceRec {
+ struct _LocalDeviceRec *next;
+ char * name;
+ int flags;
+
+ Bool (*device_control)(DeviceIntPtr device, int what);
+ void (*read_input)(struct _LocalDeviceRec *local);
+ int (*control_proc)(struct _LocalDeviceRec *local,
+ xDeviceCtl *control);
+ void (*close_proc)(struct _LocalDeviceRec *local);
+ int (*switch_mode)(ClientPtr client, DeviceIntPtr dev,
+ int mode);
+ Bool (*conversion_proc)(struct _LocalDeviceRec *local,
+ int first, int num, int v0,
+ int v1, int v2, int v3, int v4,
+ int v5, int *x, int *y);
+ Bool (*reverse_conversion_proc)(
+ struct _LocalDeviceRec *local,
+ int x, int y, int *valuators);
+
+ int fd;
+ Atom atom;
+ DeviceIntPtr dev;
+ pointer private;
+ int private_flags;
+ pointer motion_history;
+ ValuatorMotionProcPtr motion_history_proc;
+ unsigned int history_size; /* only for configuration purpose */
+ unsigned int first;
+ unsigned int last;
+ int old_x;
+ int old_y;
+ float dxremaind;
+ float dyremaind;
+ char * type_name;
+ IntegerFeedbackPtr always_core_feedback;
+ IDevPtr conf_idev;
+ InputDriverPtr drv;
+ pointer module;
+ pointer options;
+} LocalDeviceRec, *LocalDevicePtr, InputInfoRec, *InputInfoPtr;
typedef struct _DeviceAssocRec
{
- char *config_section_name;
- LocalDevicePtr (*device_allocate)(
-#if NeedNestedPrototypes
- void
-#endif
-);
+ char * config_section_name;
+ LocalDevicePtr (*device_allocate)(void);
} DeviceAssocRec, *DeviceAssocPtr;
-extern int DeviceKeyPress;
-extern int DeviceKeyRelease;
-extern int DeviceButtonPress;
-extern int DeviceButtonRelease;
-extern int DeviceMotionNotify;
-extern int DeviceValuator;
-extern int ProximityIn;
-extern int ProximityOut;
-
-extern int
-xf86IsCorePointer(
-#if NeedFunctionPrototypes
- DeviceIntPtr /*dev*/
-#endif
-);
-
-extern int
-xf86IsCoreKeyboard(
-#if NeedFunctionPrototypes
- DeviceIntPtr /*dev*/
-#endif
-);
-
-extern void
-xf86AlwaysCore(
-#if NeedFunctionPrototypes
- LocalDevicePtr /*local*/,
- Bool /*always*/
-#endif
-);
-
-void
-xf86configExtendedInputSection(
-#ifdef NeedFunctionPrototypes
- LexPtr /* val */
-#endif
-);
-
-void
-xf86AddDeviceAssoc(
-#ifdef NeedFunctionPrototypes
- DeviceAssocPtr /* assoc */
-#endif
-);
-
-void
-InitExtInput(
-#ifdef NeedFunctionPrototypes
- void
-#endif
-);
-
-Bool
-xf86eqInit (
-#ifdef NeedFunctionPrototypes
- DevicePtr /* pKbd */,
- DevicePtr /* pPtr */
-#endif
-);
-
-void
-xf86eqEnqueue (
-#ifdef NeedFunctionPrototypes
- struct _xEvent * /*event */
-#endif
-);
-
-void
-xf86eqProcessInputEvents (
-#ifdef NeedFunctionPrototypes
- void
-#endif
-);
-
-void
-xf86PostMotionEvent(
-#if NeedVarargsPrototypes
- DeviceIntPtr /*device*/,
- int /*is_absolute*/,
- int /*first_valuator*/,
- int /*num_valuators*/,
- ...
-#endif
-);
-
-void
-xf86PostProximityEvent(
-#if NeedVarargsPrototypes
- DeviceIntPtr /*device*/,
- int /*is_in*/,
- int /*first_valuator*/,
- int /*num_valuators*/,
- ...
-#endif
-);
-
-void
-xf86PostButtonEvent(
-#if NeedVarargsPrototypes
- DeviceIntPtr /*device*/,
- int /*is_absolute*/,
- int /*button*/,
- int /*is_down*/,
- int /*first_valuator*/,
- int /*num_valuators*/,
- ...
-#endif
-);
-
-void
-xf86PostKeyEvent(
-#if NeedVarargsPrototypes
- DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- ...
-#endif
-);
-
-void
-xf86AddDeviceAssoc(
-#if NeedFunctionPrototypes
- DeviceAssocPtr /*assoc*/
-#endif
-);
-
-void
-xf86MotionHistoryAllocate(
-#if NeedFunctionPrototypes
- LocalDevicePtr local
-#endif
-);
-
-int
-xf86GetMotionEvents(
-#if NeedFunctionPrototypes
- DeviceIntPtr dev,
- xTimecoord *buff,
- unsigned long start,
- unsigned long stop,
- ScreenPtr pScreen
-#endif
-);
-
-void
-xf86XinputFinalizeInit(
-#if NeedFunctionPrototypes
- DeviceIntPtr dev
-#endif
-);
-
-Bool
-xf86CheckButton(
-#if NeedFunctionPrototypes
- int button,
- int down
-#endif
-);
+/* xf86Globals.c */
+extern InputInfoPtr xf86InputDevs;
+
+/* xf86Xinput.c */
+int xf86IsCorePointer(DeviceIntPtr dev);
+int xf86IsCoreKeyboard(DeviceIntPtr dev);
+void xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always);
+#define xf86AlwaysCore(a,b) xf86XInputSetSendCoreEvents(a,b)
+
+void InitExtInput(void);
+Bool xf86eqInit(DevicePtr pKbd, DevicePtr pPtr);
+void xf86eqEnqueue(struct _xEvent *event);
+void xf86eqProcessInputEvents (void);
+void xf86eqSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
+ int first_valuator, int num_valuators, ...);
+void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
+ int first_valuator, int num_valuators, ...);
+void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button,
+ int is_down, int first_valuator, int num_valuators,
+ ...);
+void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
+ int is_absolute, int first_valuator, int num_valuators,
+ ...);
+void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
+ int is_down);
+void xf86MotionHistoryAllocate(LocalDevicePtr local);
+int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
+ unsigned long start, unsigned long stop,
+ ScreenPtr pScreen);
+void xf86XinputFinalizeInit(DeviceIntPtr dev);
+Bool xf86CheckButton(int button, int down);
+void xf86SwitchCoreDevice(LocalDevicePtr device, DeviceIntPtr core);
+LocalDevicePtr xf86FirstLocalDevice(void);
+int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
+void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);
+void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options);
+void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval,
+ int maxval, int resolution, int min_res,
+ int max_res);
+void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
+void xf86AddEnabledDevice(InputInfoPtr pInfo);
+void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
+
+/* xf86Helper.c */
+void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
+void xf86DeleteInputDriver(int drvIndex);
+InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
+void xf86DeleteInput(InputInfoPtr pInp, int flags);
+
+/* xf86Option.c */
+void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
+ pointer extraOpts);
#endif /* _xf86Xinput_h */
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 8abab86a5..f9882f2f1 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/xf86vmode.c,v 3.25 1996/10/16 14:37:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/xf86vmode.c,v 3.54 2002/12/22 00:46:51 dawes Exp $ */
/*
@@ -43,27 +43,25 @@ from Kaleb S. KEITHLEY
#include "servermd.h"
#define _XF86VIDMODE_SERVER_
#include "xf86vmstr.h"
-#include "Xfuncproto.h"
-#include "../hw/xfree86/common/xf86.h"
-#include "../hw/xfree86/common/xf86Priv.h"
+#include "swaprep.h"
+#include "xf86.h"
+#include "vidmodeproc.h"
-extern int xf86ScreenIndex;
-extern Bool xf86VidModeEnabled;
-extern Bool xf86VidModeAllowNonLocal;
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
-static int vidmodeErrorBase;
+static int VidModeErrorBase;
+static int VidModeGeneration = 0;
+static int VidModeClientPrivateIndex;
-static int ProcXF86VidModeDispatch(
-#if NeedFunctionPrototypes
- ClientPtr /* client */
-#endif
-);
+/* This holds the client's version information */
+typedef struct {
+ int major;
+ int minor;
+} VidModePrivRec, *VidModePrivPtr;
-static int SProcXF86VidModeDispatch(
-#if NeedFunctionPrototypes
- ClientPtr /* client */
-#endif
-);
+#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr)
static void XF86VidModeResetProc(
#if NeedFunctionPrototypes
@@ -71,20 +69,60 @@ static void XF86VidModeResetProc(
#endif
);
-extern void Swap32Write(); /* XXX should be in header file */
+static DISPATCH_PROC(ProcXF86VidModeDispatch);
+static DISPATCH_PROC(ProcXF86VidModeGetAllModeLines);
+static DISPATCH_PROC(ProcXF86VidModeGetModeLine);
+static DISPATCH_PROC(ProcXF86VidModeGetMonitor);
+static DISPATCH_PROC(ProcXF86VidModeLockModeSwitch);
+static DISPATCH_PROC(ProcXF86VidModeAddModeLine);
+static DISPATCH_PROC(ProcXF86VidModeDeleteModeLine);
+static DISPATCH_PROC(ProcXF86VidModeModModeLine);
+static DISPATCH_PROC(ProcXF86VidModeValidateModeLine);
+static DISPATCH_PROC(ProcXF86VidModeQueryVersion);
+static DISPATCH_PROC(ProcXF86VidModeSwitchMode);
+static DISPATCH_PROC(ProcXF86VidModeSwitchToMode);
+static DISPATCH_PROC(ProcXF86VidModeGetViewPort);
+static DISPATCH_PROC(ProcXF86VidModeSetViewPort);
+static DISPATCH_PROC(ProcXF86VidModeGetDotClocks);
+static DISPATCH_PROC(ProcXF86VidModeSetGamma);
+static DISPATCH_PROC(ProcXF86VidModeGetGamma);
+static DISPATCH_PROC(ProcXF86VidModeSetClientVersion);
+static DISPATCH_PROC(ProcXF86VidModeGetGammaRamp);
+static DISPATCH_PROC(ProcXF86VidModeSetGammaRamp);
+static DISPATCH_PROC(ProcXF86VidModeGetGammaRampSize);
+static DISPATCH_PROC(SProcXF86VidModeDispatch);
+static DISPATCH_PROC(SProcXF86VidModeGetAllModeLines);
+static DISPATCH_PROC(SProcXF86VidModeGetModeLine);
+static DISPATCH_PROC(SProcXF86VidModeGetMonitor);
+static DISPATCH_PROC(SProcXF86VidModeLockModeSwitch);
+static DISPATCH_PROC(SProcXF86VidModeAddModeLine);
+static DISPATCH_PROC(SProcXF86VidModeDeleteModeLine);
+static DISPATCH_PROC(SProcXF86VidModeModModeLine);
+static DISPATCH_PROC(SProcXF86VidModeValidateModeLine);
+static DISPATCH_PROC(SProcXF86VidModeQueryVersion);
+static DISPATCH_PROC(SProcXF86VidModeSwitchMode);
+static DISPATCH_PROC(SProcXF86VidModeSwitchToMode);
+static DISPATCH_PROC(SProcXF86VidModeGetViewPort);
+static DISPATCH_PROC(SProcXF86VidModeSetViewPort);
+static DISPATCH_PROC(SProcXF86VidModeGetDotClocks);
+static DISPATCH_PROC(SProcXF86VidModeSetGamma);
+static DISPATCH_PROC(SProcXF86VidModeGetGamma);
+static DISPATCH_PROC(SProcXF86VidModeSetClientVersion);
+static DISPATCH_PROC(SProcXF86VidModeGetGammaRamp);
+static DISPATCH_PROC(SProcXF86VidModeSetGammaRamp);
+static DISPATCH_PROC(SProcXF86VidModeGetGammaRampSize);
static unsigned char XF86VidModeReqCode = 0;
+
/* The XF86VIDMODE_EVENTS code is far from complete */
#ifdef XF86VIDMODE_EVENTS
static int XF86VidModeEventBase = 0;
static void SXF86VidModeNotifyEvent();
-#if NeedFunctionPrototypes
xXF86VidModeNotifyEvent * /* from */,
xXF86VidModeNotifyEvent * /* to */
-#endif
);
extern WindowPtr *WindowTable;
@@ -114,25 +152,59 @@ static int ScreenPrivateIndex;
#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
-#define New(t) ((t *) xalloc (sizeof (t)))
+#define New(t) (xalloc (sizeof (t)))
+#endif
+
+#ifdef DEBUG
+# define DEBUG_P(x) ErrorF(x"\n");
+#else
+# define DEBUG_P(x) /**/
#endif
void
-XFree86VidModeExtensionInit()
+XFree86VidModeExtensionInit(void)
{
ExtensionEntry* extEntry;
-#ifdef XF86VIDMODE_EVENTS
+ ScreenPtr pScreen;
int i;
- ScreenPtr pScreen;
+ Bool enabled = FALSE;
+
+ DEBUG_P("XFree86VidModeExtensionInit");
+#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents);
ScreenPrivateIndex = AllocateScreenPrivateIndex ();
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pScreen = screenInfo.screens[i];
+#endif
+
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ if (VidModeExtensionInit(pScreen))
+ enabled = TRUE;
+#ifdef XF86VIDMODE_EVENTS
SetScreenPrivate (pScreen, NULL);
- }
#endif
+ }
+ /* This means that the DDX doesn't want the vidmode extension enabled */
+ if (!enabled)
+ return;
+
+ /*
+ * Allocate a client private index to hold the client's version
+ * information.
+ */
+ if (VidModeGeneration != serverGeneration) {
+ VidModeClientPrivateIndex = AllocateClientPrivateIndex();
+ /*
+ * Allocate 0 length, and use the private to hold a pointer to our
+ * VidModePrivRec.
+ */
+ if (!AllocateClientPrivate(VidModeClientPrivateIndex, 0)) {
+ ErrorF("XFree86VidModeExtensionInit: "
+ "AllocateClientPrivate failed\n");
+ return;
+ }
+ VidModeGeneration = serverGeneration;
+ }
if (
#ifdef XF86VIDMODE_EVENTS
@@ -146,10 +218,10 @@ XFree86VidModeExtensionInit()
XF86VidModeResetProc,
StandardMinorOpcode))) {
XF86VidModeReqCode = (unsigned char)extEntry->base;
- vidmodeErrorBase = extEntry->errorBase;
+ VidModeErrorBase = extEntry->errorBase;
#ifdef XF86VIDMODE_EVENTS
XF86VidModeEventBase = extEntry->eventBase;
- EventSwapVector[XF86VidModeEventBase] = SXF86VidModeNotifyEvent;
+ EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent;
#endif
}
}
@@ -161,6 +233,18 @@ XF86VidModeResetProc (extEntry)
{
}
+static int
+ClientMajorVersion(ClientPtr client)
+{
+ VidModePrivPtr pPriv;
+
+ pPriv = VMPRIV(client);
+ if (!pPriv)
+ return 0;
+ else
+ return pPriv->major;
+}
+
#ifdef XF86VIDMODE_EVENTS
static void
CheckScreenPrivate (pScreen)
@@ -194,9 +278,7 @@ MakeScreenPrivate (pScreen)
}
static unsigned long
-getEventMask (pScreen, client)
- ScreenPtr pScreen;
- ClientPtr client;
+getEventMask (ScreenPtr pScreen, ClientPtr client)
{
SetupScreen(pScreen);
XF86VidModeEventPtr pEv;
@@ -210,10 +292,7 @@ getEventMask (pScreen, client)
}
static Bool
-setEventMask (pScreen, client, mask)
- ScreenPtr pScreen;
- ClientPtr client;
- unsigned long mask;
+setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask)
{
SetupScreen(pScreen);
XF86VidModeEventPtr pEv, *pPrev;
@@ -251,9 +330,7 @@ setEventMask (pScreen, client, mask)
}
static int
-XF86VidModeFreeEvents (value, id)
- pointer value;
- XID id;
+XF86VidModeFreeEvents(pointer value, XID id)
{
XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value;
ScreenPtr pScreen = pOld->screen;
@@ -274,10 +351,7 @@ XF86VidModeFreeEvents (value, id)
}
static void
-SendXF86VidModeNotify (pScreen, state, forced)
- ScreenPtr pScreen;
- int state;
- Bool forced;
+SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
{
XF86VidModeScreenPrivatePtr pPriv;
XF86VidModeEventPtr pEv;
@@ -312,8 +386,8 @@ SendXF86VidModeNotify (pScreen, state, forced)
}
static void
-SXF86VidModeNotifyEvent (from, to)
- xXF86VidModeNotifyEvent *from, *to;
+SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent *from,
+ xXF86VidModeNotifyEvent *to)
{
to->type = from->type;
to->state = from->state;
@@ -326,12 +400,13 @@ SXF86VidModeNotifyEvent (from, to)
#endif
static int
-ProcXF86VidModeQueryVersion(client)
- register ClientPtr client;
+ProcXF86VidModeQueryVersion(ClientPtr client)
{
xXF86VidModeQueryVersionReply rep;
register int n;
+ DEBUG_P("XF86VidModeQueryVersion");
+
REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
@@ -349,43 +424,66 @@ ProcXF86VidModeQueryVersion(client)
}
static int
-ProcXF86VidModeGetModeLine(client)
- register ClientPtr client;
+ProcXF86VidModeGetModeLine(ClientPtr client)
{
REQUEST(xXF86VidModeGetModeLineReq);
xXF86VidModeGetModeLineReply rep;
+ xXF86OldVidModeGetModeLineReply oldrep;
+ pointer mode;
register int n;
- ScrnInfoPtr vptr;
- DisplayModePtr mptr;
- int privsize;
-
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
-
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->modes;
+ int dotClock;
+ int ver;
- if (!mptr->Private)
- privsize = 0;
- else
- privsize = mptr->PrivSize;
+ DEBUG_P("XF86VidModeGetModeline");
+ ver = ClientMajorVersion(client);
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
rep.type = X_Reply;
- rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xGenericReply) +
- privsize * sizeof(INT32)) >> 2;
+ if (ver < 2) {
+ rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) -
+ SIZEOF(xGenericReply)) >> 2;
+ } else {
+ rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) -
+ SIZEOF(xGenericReply)) >> 2;
+ }
rep.sequenceNumber = client->sequence;
- rep.dotclock = vptr->clock[mptr->Clock];
- rep.hdisplay = mptr->HDisplay;
- rep.hsyncstart = mptr->HSyncStart;
- rep.hsyncend = mptr->HSyncEnd;
- rep.htotal = mptr->HTotal;
- rep.vdisplay = mptr->VDisplay;
- rep.vsyncstart = mptr->VSyncStart;
- rep.vsyncend = mptr->VSyncEnd;
- rep.vtotal = mptr->VTotal;
- rep.flags = mptr->Flags;
- rep.privsize = privsize;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ rep.dotclock = dotClock;
+ rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
+ rep.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
+ rep.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
+ rep.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
+ rep.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
+ rep.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
+ rep.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
+ rep.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
+ rep.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
+ rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
+
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("GetModeLine - scrn: %d clock: %d\n",
+ stuff->screen, rep.dotclock);
+ ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ rep.hdisplay, rep.hsyncstart,
+ rep.hsyncend, rep.htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ rep.vdisplay, rep.vsyncstart, rep.vsyncend,
+ rep.vtotal, rep.flags);
+ }
+
+ /*
+ * Older servers sometimes had server privates that the VidMode
+ * extention made available. So to be compatiable pretend that
+ * there are no server privates to pass to the client
+ */
+ rep.privsize = 0;
+
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
@@ -394,6 +492,7 @@ ProcXF86VidModeGetModeLine(client)
swaps(&rep.hsyncstart, n);
swaps(&rep.hsyncend, n);
swaps(&rep.htotal, n);
+ swaps(&rep.hskew, n);
swaps(&rep.vdisplay, n);
swaps(&rep.vsyncstart, n);
swaps(&rep.vsyncend, n);
@@ -401,42 +500,66 @@ ProcXF86VidModeGetModeLine(client)
swapl(&rep.flags, n);
swapl(&rep.privsize, n);
}
- WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), (char *)&rep);
- if (privsize) {
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, privsize * sizeof(INT32),
- mptr->Private);
+ if (ver < 2) {
+ oldrep.type = rep.type;
+ oldrep.sequenceNumber = rep.sequenceNumber;
+ oldrep.length = rep.length;
+ oldrep.dotclock = rep.dotclock;
+ oldrep.hdisplay = rep.hdisplay;
+ oldrep.hsyncstart = rep.hsyncstart;
+ oldrep.hsyncend = rep.hsyncend;
+ oldrep.htotal = rep.htotal;
+ oldrep.vdisplay = rep.vdisplay;
+ oldrep.vsyncstart = rep.vsyncstart;
+ oldrep.vsyncend = rep.vsyncend;
+ oldrep.vtotal = rep.vtotal;
+ oldrep.flags = rep.flags;
+ oldrep.privsize = rep.privsize;
+ WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply),
+ (char *)&oldrep);
+ } else {
+ WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply),
+ (char *)&rep);
}
return (client->noClientException);
}
static int
-ProcXF86VidModeGetAllModeLines(client)
- register ClientPtr client;
+ProcXF86VidModeGetAllModeLines(ClientPtr client)
{
REQUEST(xXF86VidModeGetAllModeLinesReq);
xXF86VidModeGetAllModeLinesReply rep;
xXF86VidModeModeInfo mdinf;
+ xXF86OldVidModeModeInfo oldmdinf;
+ pointer mode;
+ int modecount, dotClock;
register int n;
- ScrnInfoPtr vptr;
- DisplayModePtr mptr, curmptr;
- int privsize, modecount=1;
+ int ver;
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
+ DEBUG_P("XF86VidModeGetAllModelines");
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- curmptr = mptr = vptr->modes;
+ REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
- while (mptr->next != curmptr) {
- ++modecount;
- mptr = mptr->next;
- }
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
+ ver = ClientMajorVersion(client);
+
+ modecount = VidModeGetNumOfModes(stuff->screen);
+ if (modecount < 1)
+ return (VidModeErrorBase + XF86VidModeExtensionDisabled);
+
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
rep.type = X_Reply;
- rep.length = (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xGenericReply) +
- modecount * sizeof(xXF86VidModeModeInfo)) >> 2;
+ rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
+ SIZEOF(xGenericReply);
+ if (ver < 2)
+ rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
+ else
+ rep.length += modecount * sizeof(xXF86VidModeModeInfo);
+ rep.length >>= 2;
rep.sequenceNumber = client->sequence;
rep.modecount = modecount;
if (client->swapped) {
@@ -445,67 +568,113 @@ ProcXF86VidModeGetAllModeLines(client)
swapl(&rep.modecount, n);
}
WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep);
- mptr = curmptr;
+
do {
- if (!mptr->Private)
- privsize = 0;
- else
- privsize = mptr->PrivSize;
-
- mdinf.dotclock = vptr->clock[mptr->Clock];
- mdinf.hdisplay = mptr->HDisplay;
- mdinf.hsyncstart = mptr->HSyncStart;
- mdinf.hsyncend = mptr->HSyncEnd;
- mdinf.htotal = mptr->HTotal;
- mdinf.vdisplay = mptr->VDisplay;
- mdinf.vsyncstart = mptr->VSyncStart;
- mdinf.vsyncend = mptr->VSyncEnd;
- mdinf.vtotal = mptr->VTotal;
- mdinf.flags = mptr->Flags;
- mdinf.privsize = privsize;
+ mdinf.dotclock = dotClock;
+ mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
+ mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
+ mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
+ mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
+ mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
+ mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
+ mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
+ mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
+ mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
+ mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
+ mdinf.privsize = 0;
if (client->swapped) {
swapl(&mdinf.dotclock, n);
swaps(&mdinf.hdisplay, n);
swaps(&mdinf.hsyncstart, n);
swaps(&mdinf.hsyncend, n);
swaps(&mdinf.htotal, n);
+ swaps(&mdinf.hskew, n);
swaps(&mdinf.vdisplay, n);
swaps(&mdinf.vsyncstart, n);
swaps(&mdinf.vsyncend, n);
swaps(&mdinf.vtotal, n);
swapl(&mdinf.flags, n);
swapl(&mdinf.privsize, n);
- }
- WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf);
- mptr = mptr->next;
- } while (mptr != curmptr);
+ }
+ if (ver < 2) {
+ oldmdinf.dotclock = mdinf.dotclock;
+ oldmdinf.hdisplay = mdinf.hdisplay;
+ oldmdinf.hsyncstart = mdinf.hsyncstart;
+ oldmdinf.hsyncend = mdinf.hsyncend;
+ oldmdinf.htotal = mdinf.htotal;
+ oldmdinf.vdisplay = mdinf.vdisplay;
+ oldmdinf.vsyncstart = mdinf.vsyncstart;
+ oldmdinf.vsyncend = mdinf.vsyncend;
+ oldmdinf.vtotal = mdinf.vtotal;
+ oldmdinf.flags = mdinf.flags;
+ oldmdinf.privsize = mdinf.privsize;
+ WriteToClient(client, sizeof(xXF86OldVidModeModeInfo),
+ (char *)&oldmdinf);
+ } else {
+ WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf);
+ }
+
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
return (client->noClientException);
}
-#define CLOCKSPD(clk,scrp) ((clk>MAXCLOCKS)? clk: scrp->clock[clk])
-#define MODEMATCH(mptr,stuff,scrp) \
- (CLOCKSPD(mptr->Clock,scrp) == CLOCKSPD(stuff->dotclock,scrp) \
- && mptr->HDisplay == stuff->hdisplay \
- && mptr->HSyncStart== stuff->hsyncstart \
- && mptr->HSyncEnd == stuff->hsyncend \
- && mptr->HTotal == stuff->htotal \
- && mptr->VDisplay == stuff->vdisplay \
- && mptr->VSyncStart== stuff->vsyncstart \
- && mptr->VSyncEnd == stuff->vsyncend \
- && mptr->VTotal == stuff->vtotal \
- && mptr->Flags == stuff->flags )
+#define MODEMATCH(mode,stuff) \
+ (VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \
+ && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \
+ && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \
+ && VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \
+ && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \
+ && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \
+ && VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \
+ && VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \
+ && VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
static int
-ProcXF86VidModeAddModeLine(client)
- register ClientPtr client;
+ProcXF86VidModeAddModeLine(ClientPtr client)
{
REQUEST(xXF86VidModeAddModeLineReq);
- ScrnInfoPtr vptr;
- DisplayModePtr curmptr, mptr, newmptr;
- DisplayModeRec modetmp;
+ xXF86OldVidModeAddModeLineReq *oldstuff =
+ (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ xXF86VidModeAddModeLineReq newstuff;
+ pointer mode;
int len;
-
- if (xf86Verbose) {
+ int dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeAddModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ stuff->after_dotclock = oldstuff->after_dotclock;
+ stuff->after_hdisplay = oldstuff->after_hdisplay;
+ stuff->after_hsyncstart = oldstuff->after_hsyncstart;
+ stuff->after_hsyncend = oldstuff->after_hsyncend;
+ stuff->after_htotal = oldstuff->after_htotal;
+ stuff->after_hskew = 0;
+ stuff->after_vdisplay = oldstuff->after_vdisplay;
+ stuff->after_vsyncstart = oldstuff->after_vsyncstart;
+ stuff->after_vsyncend = oldstuff->after_vsyncend;
+ stuff->after_vtotal = oldstuff->after_vtotal;
+ stuff->after_flags = oldstuff->after_flags;
+ }
+ if (xf86GetVerbosity() > 1) {
ErrorF("AddModeLine - scrn: %d clock: %d\n",
stuff->screen, stuff->dotclock);
ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -523,17 +692,20 @@ ProcXF86VidModeAddModeLine(client)
stuff->after_vdisplay, stuff->after_vsyncstart,
stuff->after_vsyncend, stuff->after_vtotal, stuff->after_flags);
}
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
-
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- curmptr = mptr = vptr->modes;
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2);
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2);
+ }
if (len != stuff->privsize)
return BadLength;
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
if (stuff->hsyncstart < stuff->hdisplay ||
stuff->hsyncend < stuff->hsyncstart ||
stuff->htotal < stuff->hsyncend ||
@@ -552,96 +724,103 @@ ProcXF86VidModeAddModeLine(client)
if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
Bool found = FALSE;
- do {
- if (MODEMATCH(mptr, stuff, vptr)) {
- found = TRUE;
- break;
- }
- } while ((mptr = mptr->next) != curmptr);
+ if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
+ do {
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
+ == dotClock) && MODEMATCH(mode, stuff)) {
+ found = TRUE;
+ break;
+ }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+ }
if (!found)
return BadValue;
}
- newmptr = (DisplayModePtr) xalloc(sizeof(DisplayModeRec));
-
- newmptr->Clock = stuff->dotclock;
- newmptr->CrtcHDisplay = newmptr->HDisplay = stuff->hdisplay;
- newmptr->CrtcHSyncStart= newmptr->HSyncStart = stuff->hsyncstart;
- newmptr->CrtcHSyncEnd = newmptr->HSyncEnd = stuff->hsyncend;
- newmptr->CrtcHTotal = newmptr->HTotal = stuff->htotal;
- newmptr->CrtcVDisplay = newmptr->VDisplay = stuff->vdisplay;
- newmptr->CrtcVSyncStart= newmptr->VSyncStart = stuff->vsyncstart;
- newmptr->CrtcVSyncEnd = newmptr->VSyncEnd = stuff->vsyncend;
- newmptr->CrtcVTotal = newmptr->VTotal = stuff->vtotal;
- newmptr->Flags = stuff->flags;
-#if 0
- newmptr->CrtcHSkew = newmptr->HSkew = stuff->hskew;
-#endif
- newmptr->CrtcHAdjusted = FALSE;
- newmptr->CrtcVAdjusted = FALSE;
- newmptr->name = "";
- newmptr->Private = NULL;
- if (stuff->privsize) {
- if (xf86Verbose)
- ErrorF("AddModeLine - Request includes privates\n");
- newmptr->Private =
- (INT32 *) ALLOCATE_LOCAL(stuff->privsize * sizeof(INT32));
- memcpy(newmptr->Private, &stuff[1], stuff->privsize*sizeof(INT32));
- }
+
+ mode = VidModeCreateMode();
+ if (mode == NULL)
+ return BadValue;
+
+ VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
+
+ if (stuff->privsize)
+ ErrorF("AddModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
- switch (xf86CheckMode(vptr, newmptr, vptr->monitor, FALSE)) {
+ switch (VidModeCheckModeForMonitor(stuff->screen, mode)) {
+ case MODE_OK:
+ break;
case MODE_HSYNC:
- xfree(newmptr->Private);
- xfree(newmptr);
- return vidmodeErrorBase + XF86VidModeBadHTimings;
+ case MODE_H_ILLEGAL:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeBadHTimings;
case MODE_VSYNC:
- xfree(newmptr->Private);
- xfree(newmptr);
- return vidmodeErrorBase + XF86VidModeBadVTimings;
+ case MODE_V_ILLEGAL:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
/* Check that the driver is happy with the mode */
- if (vptr->ValidMode(newmptr, xf86Verbose, MODE_VID) != MODE_OK) {
- xfree(newmptr->Private);
- xfree(newmptr);
- return vidmodeErrorBase + XF86VidModeModeUnsuitable;
- }
-
- if (newmptr->Flags & V_DBLSCAN)
- {
- newmptr->CrtcVDisplay *= 2;
- newmptr->CrtcVSyncStart *= 2;
- newmptr->CrtcVSyncEnd *= 2;
- newmptr->CrtcVTotal *= 2;
- newmptr->CrtcVAdjusted = TRUE;
+ if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) {
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
- newmptr->next = mptr->next;
- newmptr->prev = mptr;
- mptr->next = newmptr;
- newmptr->next->prev = newmptr;
-
-#if 0 /* Do we want this? */
- (vptr->SwitchMode)(newmptr);
-#endif
-
- if (xf86Verbose)
+ VidModeSetCrtcForMode(stuff->screen, mode);
+
+ VidModeAddModeline(stuff->screen, mode);
+
+ if (xf86GetVerbosity() > 1)
ErrorF("AddModeLine - Succeeded\n");
- return(client->noClientException);
+ return client->noClientException;
}
static int
-ProcXF86VidModeDeleteModeLine(client)
- register ClientPtr client;
+ProcXF86VidModeDeleteModeLine(ClientPtr client)
{
REQUEST(xXF86VidModeDeleteModeLineReq);
- ScrnInfoPtr vptr;
- DisplayModePtr curmptr, mptr;
- DisplayModeRec modetmp;
- int len;
-
- if (xf86Verbose) {
+ xXF86OldVidModeDeleteModeLineReq *oldstuff =
+ (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ xXF86VidModeDeleteModeLineReq newstuff;
+ pointer mode;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeDeleteModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > 1) {
ErrorF("DeleteModeLine - scrn: %d clock: %d\n",
stuff->screen, stuff->dotclock, stuff->dotclock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -651,65 +830,110 @@ ProcXF86VidModeDeleteModeLine(client)
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- curmptr = mptr = vptr->modes;
-
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2);
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2);
+ }
if (len != stuff->privsize) {
- ErrorF("req_len = %d, sizeof(Req) = %d, privsize = %d, len = %d, length = %d\n",
- client->req_len, sizeof(xXF86VidModeDeleteModeLineReq)>>2, stuff->privsize, len, stuff->length);
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("req_len = %d, sizeof(Req) = %d, privsize = %d, len = %d, length = %d\n",
+ client->req_len, sizeof(xXF86VidModeDeleteModeLineReq)>>2, stuff->privsize, len, stuff->length);
+ }
return BadLength;
}
- ErrorF("Checking against clock: %d (%d)\n",
- mptr->Clock, CLOCKSPD(mptr->Clock, vptr));
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- mptr->HDisplay, mptr->HSyncStart,
- mptr->HSyncEnd, mptr->HTotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd,
- mptr->VTotal, mptr->Flags);
- if (MODEMATCH(mptr, stuff, vptr))
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
return BadValue;
- while ((mptr = mptr->next) != curmptr) {
+ if (xf86GetVerbosity() > 1) {
ErrorF("Checking against clock: %d (%d)\n",
- mptr->Clock, CLOCKSPD(mptr->Clock, vptr));
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- mptr->HDisplay, mptr->HSyncStart,
- mptr->HSyncEnd, mptr->HTotal);
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd,
- mptr->VTotal, mptr->Flags);
- if (MODEMATCH(mptr, stuff, vptr)) {
- mptr->prev->next = mptr->next;
- mptr->next->prev = mptr->prev;
- xfree(mptr->name);
- xfree(mptr->Private);
- xfree(mptr);
- if (xf86Verbose)
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff))
+ return BadValue;
+
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ do {
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
+ VidModeDeleteModeline(stuff->screen, mode);
+ if (xf86GetVerbosity())
ErrorF("DeleteModeLine - Succeeded\n");
return(client->noClientException);
}
- }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
return BadValue;
}
static int
-ProcXF86VidModeModModeLine(client)
- register ClientPtr client;
+ProcXF86VidModeModModeLine(ClientPtr client)
{
REQUEST(xXF86VidModeModModeLineReq);
- ScrnInfoPtr vptr;
- DisplayModePtr mptr;
- DisplayModeRec modetmp;
- int len;
-
- if (xf86Verbose) {
+ xXF86OldVidModeModModeLineReq *oldstuff =
+ (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ xXF86VidModeModModeLineReq newstuff;
+ pointer mode, modetmp;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeModModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2 ) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > 1) {
ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->screen, stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
@@ -717,14 +941,14 @@ ProcXF86VidModeModModeLine(client)
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
-
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->modes;
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2);
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeModModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2);
+ }
if (len != stuff->privsize)
return BadLength;
@@ -736,104 +960,103 @@ ProcXF86VidModeModModeLine(client)
stuff->vtotal < stuff->vsyncend)
return BadValue;
- memcpy(&modetmp, mptr, sizeof(DisplayModeRec));
-
- modetmp.HDisplay = stuff->hdisplay;
- modetmp.HSyncStart = stuff->hsyncstart;
- modetmp.HSyncEnd = stuff->hsyncend;
- modetmp.HTotal = stuff->htotal;
- modetmp.VDisplay = stuff->vdisplay;
- modetmp.VSyncStart = stuff->vsyncstart;
- modetmp.VSyncEnd = stuff->vsyncend;
- modetmp.VTotal = stuff->vtotal;
- modetmp.Flags = stuff->flags;
- if (mptr->PrivSize && stuff->privsize) {
- if (mptr->PrivSize != stuff->privsize)
- return BadValue;
- }
- if (mptr->PrivSize && mptr->Private) {
- modetmp.Private =
- (INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32));
- if (stuff->privsize) {
- if (xf86Verbose)
- ErrorF("ModModeLine - Request includes privates\n");
- memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
- } else
- memcpy(modetmp.Private, mptr->Private,
- mptr->PrivSize * sizeof(INT32));
- }
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ modetmp = VidModeCreateMode();
+ VidModeCopyMode(mode, modetmp);
+
+ VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
+
+ if (stuff->privsize)
+ ErrorF("ModModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
- switch (xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) {
+ switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) {
+ case MODE_OK:
+ break;
case MODE_HSYNC:
- DEALLOCATE_LOCAL(modetmp.Private);
- return vidmodeErrorBase + XF86VidModeBadHTimings;
+ case MODE_H_ILLEGAL:
+ return VidModeErrorBase + XF86VidModeBadHTimings;
case MODE_VSYNC:
- DEALLOCATE_LOCAL(modetmp.Private);
- return vidmodeErrorBase + XF86VidModeBadVTimings;
+ case MODE_V_ILLEGAL:
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
/* Check that the driver is happy with the mode */
- if (vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID) != MODE_OK) {
- DEALLOCATE_LOCAL(modetmp.Private);
- return vidmodeErrorBase + XF86VidModeModeUnsuitable;
- }
-
- DEALLOCATE_LOCAL(modetmp.Private);
-
- mptr->HDisplay = stuff->hdisplay;
- mptr->HSyncStart = stuff->hsyncstart;
- mptr->HSyncEnd = stuff->hsyncend;
- mptr->HTotal = stuff->htotal;
- mptr->VDisplay = stuff->vdisplay;
- mptr->VSyncStart = stuff->vsyncstart;
- mptr->VSyncEnd = stuff->vsyncend;
- mptr->VTotal = stuff->vtotal;
- mptr->Flags = stuff->flags;
- mptr->CrtcHDisplay = stuff->hdisplay;
- mptr->CrtcHSyncStart = stuff->hsyncstart;
- mptr->CrtcHSyncEnd = stuff->hsyncend;
- mptr->CrtcHTotal = stuff->htotal;
- mptr->CrtcVDisplay = stuff->vdisplay;
- mptr->CrtcVSyncStart = stuff->vsyncstart;
- mptr->CrtcVSyncEnd = stuff->vsyncend;
- mptr->CrtcVTotal = stuff->vtotal;
- mptr->CrtcVAdjusted = FALSE;
- mptr->CrtcHAdjusted = FALSE;
- if (mptr->Flags & V_DBLSCAN)
- {
- mptr->CrtcVDisplay *= 2;
- mptr->CrtcVSyncStart *= 2;
- mptr->CrtcVSyncEnd *= 2;
- mptr->CrtcVTotal *= 2;
- mptr->CrtcVAdjusted = TRUE;
- }
- if (mptr->PrivSize && stuff->privsize) {
- memcpy(mptr->Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
+ if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) {
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
- (vptr->SwitchMode)(mptr);
- (vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0);
-
- if (xf86Verbose)
+ VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
+
+ VidModeSetCrtcForMode(stuff->screen, mode);
+ VidModeSwitchMode(stuff->screen, mode);
+
+ if (xf86GetVerbosity() > 1)
ErrorF("ModModeLine - Succeeded\n");
return(client->noClientException);
}
static int
-ProcXF86VidModeValidateModeLine(client)
- register ClientPtr client;
+ProcXF86VidModeValidateModeLine(ClientPtr client)
{
REQUEST(xXF86VidModeValidateModeLineReq);
+ xXF86OldVidModeValidateModeLineReq *oldstuff =
+ (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ xXF86VidModeValidateModeLineReq newstuff;
xXF86VidModeValidateModeLineReply rep;
- ScrnInfoPtr vptr;
- DisplayModePtr mptr;
- DisplayModeRec modetmp;
- int len, status;
-
- if (xf86Verbose) {
+ pointer mode, modetmp;
+ int len, status, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeValidateModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > 1) {
ErrorF("ValidateModeLine - scrn: %d clock: %d\n",
- stuff->screen, stuff->dotclock, stuff->dotclock);
+ stuff->screen, stuff->dotclock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
@@ -841,19 +1064,22 @@ ProcXF86VidModeValidateModeLine(client)
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
-
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->modes;
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2);
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ len = client->req_len -
+ (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2);
+ }
if (len != stuff->privsize)
return BadLength;
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
status = MODE_OK;
- modetmp.Private = NULL;
if (stuff->hsyncstart < stuff->hdisplay ||
stuff->hsyncend < stuff->hsyncstart ||
@@ -866,46 +1092,33 @@ ProcXF86VidModeValidateModeLine(client)
goto status_reply;
}
- memcpy(&modetmp, mptr, sizeof(DisplayModeRec));
-
- modetmp.HDisplay = stuff->hdisplay;
- modetmp.HSyncStart = stuff->hsyncstart;
- modetmp.HSyncEnd = stuff->hsyncend;
- modetmp.HTotal = stuff->htotal;
- modetmp.VDisplay = stuff->vdisplay;
- modetmp.VSyncStart = stuff->vsyncstart;
- modetmp.VSyncEnd = stuff->vsyncend;
- modetmp.VTotal = stuff->vtotal;
- modetmp.Flags = stuff->flags;
- modetmp.Private = NULL;
- if (mptr->PrivSize && stuff->privsize) {
- if (mptr->PrivSize != stuff->privsize) {
- status = MODE_BAD;
- goto status_reply;
- }
- }
- if (mptr->PrivSize && mptr->Private) {
- modetmp.Private =
- (INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32));
- if (stuff->privsize) {
- if (xf86Verbose)
- ErrorF("ValidateModeLine - Request includes privates\n");
- memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
- } else
- memcpy(modetmp.Private, mptr->Private,
- mptr->PrivSize * sizeof(INT32));
- }
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ modetmp = VidModeCreateMode();
+ VidModeCopyMode(mode, modetmp);
+
+ VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
+ if (stuff->privsize)
+ ErrorF("ValidateModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
- if ((status = xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) != MODE_OK)
+ if ((status = VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
goto status_reply;
/* Check that the driver is happy with the mode */
- status = vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID);
+ status = VidModeCheckModeForDriver(stuff->screen, modetmp);
status_reply:
- if (modetmp.Private)
- DEALLOCATE_LOCAL(modetmp.Private);
rep.type = X_Reply;
rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply)
- SIZEOF(xGenericReply)) >> 2;
@@ -918,227 +1131,555 @@ status_reply:
swapl(&rep.status, n);
}
WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep);
- if (xf86Verbose)
- ErrorF("ValidateModeLine - Succeeded\n");
+ if (xf86GetVerbosity() > 1)
+ ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
return(client->noClientException);
}
static int
-ProcXF86VidModeSwitchMode(client)
- register ClientPtr client;
+ProcXF86VidModeSwitchMode(ClientPtr client)
{
REQUEST(xXF86VidModeSwitchModeReq);
- ScreenPtr vptr;
-
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
- vptr = screenInfo.screens[stuff->screen];
- if (xf86Info.dontZoom)
- return vidmodeErrorBase + XF86VidModeZoomLocked;
+ DEBUG_P("XF86VidModeSwitchMode");
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
- xf86ZoomViewport(vptr, (short)stuff->zoom);
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ VidModeZoomViewport(stuff->screen, (short)stuff->zoom);
+
return (client->noClientException);
}
static int
-ProcXF86VidModeSwitchToMode(client)
- register ClientPtr client;
+ProcXF86VidModeSwitchToMode(ClientPtr client)
{
REQUEST(xXF86VidModeSwitchToModeReq);
- ScrnInfoPtr vptr;
- DisplayModePtr curmptr, mptr;
- DisplayModeRec modetmp;
+ xXF86OldVidModeSwitchToModeReq *oldstuff =
+ (xXF86OldVidModeSwitchToModeReq *)client->requestBuffer;
+ xXF86VidModeSwitchToModeReq newstuff;
+ pointer mode;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeSwitchToMode");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("SwitchToMode - scrn: %d clock: %d\n",
+ stuff->screen, stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, stuff->flags);
+ }
- if (stuff->screen > screenInfo.numScreens)
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
+ len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2);
+ }
+ if (len != stuff->privsize)
+ return BadLength;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
return BadValue;
- if (xf86Info.dontZoom)
- return vidmodeErrorBase + XF86VidModeZoomLocked;
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock)
+ && MODEMATCH(mode, stuff))
+ return (client->noClientException);
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- curmptr = mptr = vptr->modes;
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
+ do {
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
- if (MODEMATCH(mptr, stuff, vptr))
- return (client->noClientException);
+ if (!VidModeSwitchMode(stuff->screen, mode))
+ return BadValue;
- while ((mptr = mptr->next) != curmptr) {
- if (MODEMATCH(mptr, stuff, vptr)) {
- if ((vptr->SwitchMode)(mptr)) {
- vptr->modes = mptr;
- vptr->frameX0 = (vptr->frameX1 +vptr->frameX0 -mptr->HDisplay)/2;
- vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1;
- if (vptr->frameX0 < 0) {
- vptr->frameX0 = 0;
- vptr->frameX1 = mptr->HDisplay -1;
- } else if (vptr->frameX1 >= vptr->virtualX) {
- vptr->frameX0 = vptr->virtualX - mptr->HDisplay;
- vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1;
- }
- vptr->frameY0 = (vptr->frameY1 +vptr->frameY0 -mptr->VDisplay)/2;
- vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1;
- if (vptr->frameY0 < 0) {
- vptr->frameY0 = 0;
- vptr->frameY1 = mptr->VDisplay -1;
- } else if (vptr->frameY1 >= vptr->virtualY) {
- vptr->frameY0 = vptr->virtualY - mptr->VDisplay;
- vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1;
- }
- }
- (vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0);
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SwitchToMode - Succeeded\n");
return(client->noClientException);
}
- }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
return BadValue;
}
static int
-ProcXF86VidModeLockModeSwitch(client)
- register ClientPtr client;
+ProcXF86VidModeLockModeSwitch(ClientPtr client)
{
REQUEST(xXF86VidModeLockModeSwitchReq);
- ScreenPtr vptr;
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
+ REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
- vptr = screenInfo.screens[stuff->screen];
- if (xf86Info.dontZoom)
- return vidmodeErrorBase + XF86VidModeZoomLocked;
+ DEBUG_P("XF86VidModeLockModeSwitch");
- REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeLockZoom(stuff->screen, (short)stuff->lock))
+ return VidModeErrorBase + XF86VidModeZoomLocked;
- xf86LockZoom(vptr, (short)stuff->lock);
return (client->noClientException);
}
static int
-ProcXF86VidModeGetMonitor(client)
- register ClientPtr client;
+ProcXF86VidModeGetMonitor(ClientPtr client)
{
REQUEST(xXF86VidModeGetMonitorReq);
xXF86VidModeGetMonitorReply rep;
register int n;
- ScrnInfoPtr vptr;
- MonPtr mptr;
CARD32 *hsyncdata, *vsyncdata;
- int i;
+ int i, nHsync, nVrefresh;
+ pointer monitor;
+
+ DEBUG_P("XF86VidModeGetMonitor");
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
+ REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->monitor;
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+ if (!VidModeGetMonitor(stuff->screen, &monitor))
+ return BadValue;
+
+ nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
+ nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+
rep.type = X_Reply;
- if (mptr->vendor)
- rep.vendorLength = strlen(mptr->vendor);
+ if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
+ rep.vendorLength = strlen((char *)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VENDOR, 0)).ptr);
else
rep.vendorLength = 0;
- if (mptr->model)
- rep.modelLength = strlen(mptr->model);
+ if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
+ rep.modelLength = strlen((char *)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_MODEL, 0)).ptr);
else
rep.modelLength = 0;
rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
- (mptr->n_hsync + mptr->n_vrefresh) * sizeof(CARD32) +
+ (nHsync + nVrefresh) * sizeof(CARD32) +
((rep.vendorLength + 3) & ~3) +
((rep.modelLength + 3) & ~3)) >> 2;
rep.sequenceNumber = client->sequence;
- rep.nhsync = mptr->n_hsync;
- rep.nvsync = mptr->n_vrefresh;
-#if 0
- rep.bandwidth = (unsigned long)(mptr->bandwidth * 1e6);
-#endif
- hsyncdata = ALLOCATE_LOCAL(mptr->n_hsync * sizeof(CARD32));
+ rep.nhsync = nHsync;
+ rep.nvsync = nVrefresh;
+ hsyncdata = ALLOCATE_LOCAL(nHsync * sizeof(CARD32));
if (!hsyncdata) {
return BadAlloc;
}
- vsyncdata = ALLOCATE_LOCAL(mptr->n_vrefresh * sizeof(CARD32));
+
+ vsyncdata = ALLOCATE_LOCAL(nVrefresh * sizeof(CARD32));
if (!vsyncdata) {
DEALLOCATE_LOCAL(hsyncdata);
return BadAlloc;
}
- for (i = 0; i < mptr->n_hsync; i++) {
- hsyncdata[i] = (unsigned short)(mptr->hsync[i].lo * 100.0) |
- (unsigned short)(mptr->hsync[i].hi * 100.0) << 16;
+
+ for (i = 0; i < nHsync; i++) {
+ hsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_HSYNC_LO, i)).f |
+ (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_HSYNC_HI, i)).f << 16;
}
- for (i = 0; i < mptr->n_vrefresh; i++) {
- vsyncdata[i] = (unsigned short)(mptr->vrefresh[i].lo * 100.0) |
- (unsigned short)(mptr->vrefresh[i].hi * 100.0) << 16;
+ for (i = 0; i < nVrefresh; i++) {
+ vsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_LO, i)).f |
+ (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_HI, i)).f << 16;
}
+
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
- swapl(&rep.bandwidth, n);
}
WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep);
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, mptr->n_hsync * sizeof(CARD32),
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, nHsync * sizeof(CARD32),
hsyncdata);
- WriteSwappedDataToClient(client, mptr->n_vrefresh * sizeof(CARD32),
+ WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32),
vsyncdata);
if (rep.vendorLength)
- WriteToClient(client, rep.vendorLength, mptr->vendor);
+ WriteToClient(client, rep.vendorLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr);
if (rep.modelLength)
- WriteToClient(client, rep.modelLength, mptr->model);
+ WriteToClient(client, rep.modelLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr);
+
DEALLOCATE_LOCAL(hsyncdata);
DEALLOCATE_LOCAL(vsyncdata);
+
return (client->noClientException);
}
static int
-ProcXF86VidModeGetViewPort(client)
- register ClientPtr client;
+ProcXF86VidModeGetViewPort(ClientPtr client)
{
REQUEST(xXF86VidModeGetViewPortReq);
xXF86VidModeGetViewPortReply rep;
- register int n;
- ScrnInfoPtr vptr;
- MonPtr mptr;
- CARD32 *hsyncdata, *vsyncdata;
- int i;
+ int x, y, n;
- if (stuff->screen > screenInfo.numScreens)
- return BadValue;
-
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->monitor;
+ DEBUG_P("XF86VidModeGetViewPort");
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ VidModeGetViewPort(stuff->screen, &x, &y);
+ rep.x = x;
+ rep.y = y;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.x, n);
+ swapl(&rep.y, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *)&rep);
return (client->noClientException);
}
static int
-ProcXF86VidModeSetViewPort(client)
- register ClientPtr client;
+ProcXF86VidModeSetViewPort(ClientPtr client)
{
REQUEST(xXF86VidModeSetViewPortReq);
+
+ DEBUG_P("XF86VidModeSetViewPort");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y))
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetDotClocks(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetDotClocksReq);
+ xXF86VidModeGetDotClocksReply rep;
register int n;
- ScrnInfoPtr vptr;
- MonPtr mptr;
- CARD32 *hsyncdata, *vsyncdata;
- int i;
+ int numClocks;
+ CARD32 dotclock;
+ int *Clocks = NULL;
+ Bool ClockProg;
+
+ DEBUG_P("XF86VidModeGetDotClocks");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
+
+ rep.type = X_Reply;
+ rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply)
+ - SIZEOF(xGenericReply) + numClocks) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.clocks = numClocks;
+ rep.maxclocks = MAXCLOCKS;
+ rep.flags = 0;
+
+ if (!ClockProg) {
+ Clocks = ALLOCATE_LOCAL(numClocks * sizeof(int));
+ if (!Clocks)
+ return BadValue;
+ if (!VidModeGetClocks(stuff->screen, Clocks)) {
+ DEALLOCATE_LOCAL(Clocks);
+ return BadValue;
+ }
+ }
+
+ if (ClockProg) {
+ rep.flags |= CLKFLAG_PROGRAMABLE;
+ }
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.clocks, n);
+ swapl(&rep.maxclocks, n);
+ swapl(&rep.flags, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *)&rep);
+ if (!ClockProg) {
+ for (n = 0; n < numClocks; n++) {
+ dotclock = *Clocks++;
+ if (client->swapped) {
+ WriteSwappedDataToClient(client, 4, (char *)&dotclock);
+ } else {
+ WriteToClient(client, 4, (char *)&dotclock);
+ }
+ }
+ }
+
+ DEALLOCATE_LOCAL(Clocks);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSetGamma(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSetGammaReq);
+
+ DEBUG_P("XF86VidModeSetGamma");
- if (stuff->screen > screenInfo.numScreens)
+ REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeSetGamma(stuff->screen, ((float)stuff->red)/10000.,
+ ((float)stuff->green)/10000., ((float)stuff->blue)/10000.))
return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
- mptr = vptr->monitor;
+ return (client->noClientException);
+}
- REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
+static int
+ProcXF86VidModeGetGamma(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetGammaReq);
+ xXF86VidModeGetGammaReply rep;
+ register int n;
+ float red, green, blue;
+
+ DEBUG_P("XF86VidModeGetGamma");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
+ return BadValue;
+ rep.red = (CARD32)(red * 10000.);
+ rep.green = (CARD32)(green * 10000.);
+ rep.blue = (CARD32)(blue * 10000.);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.red, n);
+ swapl(&rep.green, n);
+ swapl(&rep.blue, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
+ CARD16 *r, *g, *b;
+ int length;
+ REQUEST(xXF86VidModeSetGammaRampReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
+
+ length = (stuff->size + 1) & ~1;
+
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
+
+ r = (CARD16*)&stuff[1];
+ g = r + length;
+ b = g + length;
+
+ if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
+ CARD16 *ramp = NULL;
+ int n, length, i;
+ xXF86VidModeGetGammaRampReply rep;
+ REQUEST(xXF86VidModeGetGammaRampReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+
+ length = (stuff->size + 1) & ~1;
+
+ if(stuff->size) {
+ if(!(ramp = xalloc(length * 3 * sizeof(CARD16))))
+ return BadAlloc;
+
+ if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
+ ramp, ramp + length, ramp + (length * 2)))
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = (length >> 1) * 3;
+ rep.sequenceNumber = client->sequence;
+ rep.size = stuff->size;
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.size, n);
+ for(i = 0; i < length * 3; i++)
+ swaps(&ramp[i],n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep);
+
+ if(stuff->size) {
+ WriteToClient(client, rep.length << 2, (char*)ramp);
+ xfree(ramp);
+ }
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
+ xXF86VidModeGetGammaRampSizeReply rep;
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampSizeReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.size = VidModeGetGammaRampSize(stuff->screen);
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.size, n);
+ }
+ WriteToClient(client,sizeof(xXF86VidModeGetGammaRampSizeReply),(char*)&rep);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetPermissions(ClientPtr client)
+{
+ xXF86VidModeGetPermissionsReply rep;
+ int n;
+ REQUEST(xXF86VidModeGetPermissionsReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.permissions = XF86VM_READ_PERMISSION;
+ if (xf86GetVidModeEnabled() &&
+ (xf86GetVidModeAllowNonLocal() || LocalClient (client))) {
+ rep.permissions |= XF86VM_WRITE_PERMISSION;
+ }
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.permissions, n);
+ }
+ WriteToClient(client,sizeof(xXF86VidModeGetPermissionsReply),(char*)&rep);
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86VidModeSetClientVersion(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSetClientVersionReq);
+
+ VidModePrivPtr pPriv;
+
+ DEBUG_P("XF86VidModeSetClientVersion");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+
+ if ((pPriv = VMPRIV(client)) == NULL) {
+ pPriv = xalloc(sizeof(VidModePrivRec));
+ if (!pPriv)
+ return BadAlloc;
+ VMPRIV(client) = pPriv;
+ }
+ pPriv->major = stuff->major;
+ pPriv->minor = stuff->minor;
+
return (client->noClientException);
}
static int
-ProcXF86VidModeDispatch (client)
- register ClientPtr client;
+ProcXF86VidModeDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data)
@@ -1147,18 +1688,30 @@ ProcXF86VidModeDispatch (client)
return ProcXF86VidModeQueryVersion(client);
case X_XF86VidModeGetModeLine:
return ProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetAllModeLines:
- return ProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeGetMonitor:
return ProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:
+ return ProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeValidateModeLine:
return ProcXF86VidModeValidateModeLine(client);
case X_XF86VidModeGetViewPort:
return ProcXF86VidModeGetViewPort(client);
+ case X_XF86VidModeGetDotClocks:
+ return ProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:
+ return ProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:
+ return ProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:
+ return ProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:
+ return ProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:
+ return ProcXF86VidModeGetPermissions(client);
default:
- if (!xf86VidModeEnabled)
- return vidmodeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86VidModeAllowNonLocal || LocalClient (client)) {
+ if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient (client)) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return ProcXF86VidModeAddModeLine(client);
@@ -1174,17 +1727,20 @@ ProcXF86VidModeDispatch (client)
return ProcXF86VidModeLockModeSwitch(client);
case X_XF86VidModeSetViewPort:
return ProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:
+ return ProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:
+ return ProcXF86VidModeSetGammaRamp(client);
default:
return BadRequest;
}
} else
- return vidmodeErrorBase + XF86VidModeClientNotLocal;
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
static int
-SProcXF86VidModeQueryVersion(client)
- register ClientPtr client;
+SProcXF86VidModeQueryVersion(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeQueryVersionReq);
@@ -1193,8 +1749,7 @@ SProcXF86VidModeQueryVersion(client)
}
static int
-SProcXF86VidModeGetModeLine(client)
- ClientPtr client;
+SProcXF86VidModeGetModeLine(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeGetModeLineReq);
@@ -1205,8 +1760,7 @@ SProcXF86VidModeGetModeLine(client)
}
static int
-SProcXF86VidModeGetAllModeLines(client)
- ClientPtr client;
+SProcXF86VidModeGetAllModeLines(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeGetAllModeLinesReq);
@@ -1217,100 +1771,187 @@ SProcXF86VidModeGetAllModeLines(client)
}
static int
-SProcXF86VidModeAddModeLine(client)
- ClientPtr client;
+SProcXF86VidModeAddModeLine(ClientPtr client)
{
+ xXF86OldVidModeAddModeLineReq *oldstuff =
+ (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ int ver;
register int n;
+
REQUEST(xXF86VidModeAddModeLineReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- swapl(&stuff->screen, n);
- swaps(&stuff->hdisplay, n);
- swaps(&stuff->hsyncstart, n);
- swaps(&stuff->hsyncend, n);
- swaps(&stuff->htotal, n);
- swaps(&stuff->vdisplay, n);
- swaps(&stuff->vsyncstart, n);
- swaps(&stuff->vsyncend, n);
- swaps(&stuff->vtotal, n);
- swapl(&stuff->flags, n);
- swapl(&stuff->privsize, n);
- SwapRestL(stuff);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
return ProcXF86VidModeAddModeLine(client);
}
static int
-SProcXF86VidModeDeleteModeLine(client)
- ClientPtr client;
+SProcXF86VidModeDeleteModeLine(ClientPtr client)
{
+ xXF86OldVidModeDeleteModeLineReq *oldstuff =
+ (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ int ver;
register int n;
+
REQUEST(xXF86VidModeDeleteModeLineReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- swapl(&stuff->screen, n);
- swaps(&stuff->hdisplay, n);
- swaps(&stuff->hsyncstart, n);
- swaps(&stuff->hsyncend, n);
- swaps(&stuff->htotal, n);
- swaps(&stuff->vdisplay, n);
- swaps(&stuff->vsyncstart, n);
- swaps(&stuff->vsyncend, n);
- swaps(&stuff->vtotal, n);
- swapl(&stuff->flags, n);
- swapl(&stuff->privsize, n);
- SwapRestL(stuff);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
return ProcXF86VidModeDeleteModeLine(client);
}
static int
-SProcXF86VidModeModModeLine(client)
- ClientPtr client;
+SProcXF86VidModeModModeLine(ClientPtr client)
{
+ xXF86OldVidModeModModeLineReq *oldstuff =
+ (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ int ver;
register int n;
+
REQUEST(xXF86VidModeModModeLineReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- swapl(&stuff->screen, n);
- swaps(&stuff->hdisplay, n);
- swaps(&stuff->hsyncstart, n);
- swaps(&stuff->hsyncend, n);
- swaps(&stuff->htotal, n);
- swaps(&stuff->vdisplay, n);
- swaps(&stuff->vsyncstart, n);
- swaps(&stuff->vsyncend, n);
- swaps(&stuff->vtotal, n);
- swapl(&stuff->flags, n);
- swapl(&stuff->privsize, n);
- SwapRestL(stuff);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
return ProcXF86VidModeModModeLine(client);
}
static int
-SProcXF86VidModeValidateModeLine(client)
- ClientPtr client;
+SProcXF86VidModeValidateModeLine(ClientPtr client)
{
+ xXF86OldVidModeValidateModeLineReq *oldstuff =
+ (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ int ver;
register int n;
+
REQUEST(xXF86VidModeValidateModeLineReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- swapl(&stuff->screen, n);
- swaps(&stuff->hdisplay, n);
- swaps(&stuff->hsyncstart, n);
- swaps(&stuff->hsyncend, n);
- swaps(&stuff->htotal, n);
- swaps(&stuff->vdisplay, n);
- swaps(&stuff->vsyncstart, n);
- swaps(&stuff->vsyncend, n);
- swaps(&stuff->vtotal, n);
- swapl(&stuff->flags, n);
- swapl(&stuff->privsize, n);
- SwapRestL(stuff);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
return ProcXF86VidModeValidateModeLine(client);
}
static int
-SProcXF86VidModeSwitchMode(client)
- ClientPtr client;
+SProcXF86VidModeSwitchMode(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeSwitchModeReq);
@@ -1322,8 +1963,7 @@ SProcXF86VidModeSwitchMode(client)
}
static int
-SProcXF86VidModeSwitchToMode(client)
- ClientPtr client;
+SProcXF86VidModeSwitchToMode(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeSwitchToModeReq);
@@ -1334,8 +1974,7 @@ SProcXF86VidModeSwitchToMode(client)
}
static int
-SProcXF86VidModeLockModeSwitch(client)
- ClientPtr client;
+SProcXF86VidModeLockModeSwitch(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeLockModeSwitchReq);
@@ -1347,8 +1986,7 @@ SProcXF86VidModeLockModeSwitch(client)
}
static int
-SProcXF86VidModeGetMonitor(client)
- ClientPtr client;
+SProcXF86VidModeGetMonitor(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeGetMonitorReq);
@@ -1359,8 +1997,7 @@ SProcXF86VidModeGetMonitor(client)
}
static int
-SProcXF86VidModeGetViewPort(client)
- ClientPtr client;
+SProcXF86VidModeGetViewPort(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeGetViewPortReq);
@@ -1371,20 +2008,123 @@ SProcXF86VidModeGetViewPort(client)
}
static int
-SProcXF86VidModeSetViewPort(client)
- ClientPtr client;
+SProcXF86VidModeSetViewPort(ClientPtr client)
{
register int n;
REQUEST(xXF86VidModeSetViewPortReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
swaps(&stuff->screen, n);
+ swapl(&stuff->x, n);
+ swapl(&stuff->y, n);
return ProcXF86VidModeSetViewPort(client);
}
static int
-SProcXF86VidModeDispatch (client)
- register ClientPtr client;
+SProcXF86VidModeGetDotClocks(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetDotClocksReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetDotClocks(client);
+}
+
+static int
+SProcXF86VidModeSetClientVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSetClientVersionReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+ swaps(&stuff->major, n);
+ swaps(&stuff->minor, n);
+ return ProcXF86VidModeSetClientVersion(client);
+}
+
+static int
+SProcXF86VidModeSetGamma(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSetGammaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
+ swaps(&stuff->screen, n);
+ swapl(&stuff->red, n);
+ swapl(&stuff->green, n);
+ swapl(&stuff->blue, n);
+ return ProcXF86VidModeSetGamma(client);
+}
+
+static int
+SProcXF86VidModeGetGamma(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetGammaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGamma(client);
+}
+
+static int
+SProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
+ CARD16 *ramp;
+ int length, n;
+ REQUEST(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->size, n);
+ swaps(&stuff->screen, n);
+ length = ((stuff->size + 1) & ~1) * 6;
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
+ ramp = (CARD16*)&stuff[1];
+ while(length--) {
+ swaps(ramp, n);
+ ramp++;
+ }
+ return ProcXF86VidModeSetGammaRamp(client);
+}
+
+static int
+SProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+ swaps(&stuff->size, n);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGammaRamp(client);
+}
+
+static int
+SProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampSizeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGammaRampSize(client);
+}
+
+static int
+SProcXF86VidModeGetPermissions(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetPermissionsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetPermissions(client);
+}
+
+
+static int
+SProcXF86VidModeDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data)
@@ -1393,18 +2133,30 @@ SProcXF86VidModeDispatch (client)
return SProcXF86VidModeQueryVersion(client);
case X_XF86VidModeGetModeLine:
return SProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetAllModeLines:
- return SProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeGetMonitor:
return SProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:
+ return SProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeGetViewPort:
return SProcXF86VidModeGetViewPort(client);
case X_XF86VidModeValidateModeLine:
return SProcXF86VidModeValidateModeLine(client);
+ case X_XF86VidModeGetDotClocks:
+ return SProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:
+ return SProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:
+ return SProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:
+ return SProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:
+ return SProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:
+ return SProcXF86VidModeGetPermissions(client);
default:
- if (!xf86VidModeEnabled)
- return vidmodeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86VidModeAllowNonLocal || LocalClient(client)) {
+ if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return SProcXF86VidModeAddModeLine(client);
@@ -1420,10 +2172,14 @@ SProcXF86VidModeDispatch (client)
return SProcXF86VidModeLockModeSwitch(client);
case X_XF86VidModeSetViewPort:
return SProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:
+ return SProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:
+ return SProcXF86VidModeSetGammaRamp(client);
default:
return BadRequest;
}
} else
- return vidmodeErrorBase + XF86VidModeClientNotLocal;
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
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 */
diff --git a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c
index 37c23cfea..f7d07eb79 100644
--- a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c
+++ b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c
@@ -1,10 +1,10 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.c,v 3.5 1996/12/23 06:47:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.c,v 3.6 1998/07/26 09:56:17 dawes Exp $ */
/* Keyboard mode control program for 386BSD */
-/* $Xorg: kbd_mode.c,v 1.3 2000/08/17 19:51:09 cpqbld Exp $ */
+/* $XConsortium: kbd_mode.c /main/7 1996/03/11 10:46:12 kaleb $ */
#include <sys/types.h>
#include <fcntl.h>
@@ -20,6 +20,7 @@
#include "scrnintstr.h"
#include "xf86.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
static int fd;
diff --git a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre
index c959d2332..677663d7e 100644
--- a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre
+++ b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre
@@ -1,5 +1,5 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.man,v 3.2 1996/12/23 06:47:14 dawes Exp $
-.TH KBD_MODE 1 "Release 6.3 (XFree86 3.2)" "X Version 11"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.man,v 3.5 2001/01/27 18:20:56 dawes Exp $
+.TH KBD_MODE 1 __vendorversion__
.SH NAME
kbd_mode \- recover the PC console keyboard
.SH SYNOPSIS
@@ -33,4 +33,4 @@ reset it typing:
kbd_mode -u
.sp
-.\" $Xorg: kbd_mode.man,v 1.3 2000/08/17 19:51:10 cpqbld Exp $
+.\" $TOG: kbd_mode.man /main/6 1997/07/19 10:37:14 kaleb $
diff --git a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c
index 294787354..6e81fd247 100644
--- a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c
+++ b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c
@@ -27,10 +27,11 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.c,v 3.11 2002/10/23 16:23:36 tsi Exp $ */
-#ifndef lint
+/*
static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
-#endif
+ */
/*
* Copyright 1986 by Sun Microsystems, Inc.
@@ -41,7 +42,7 @@ static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
-#if defined(SVR4) || defined(__bsdi_)
+#if defined(SVR4) || defined(__bsdi__)
#include <fcntl.h>
#ifndef __bsdi__
#include <sys/kbio.h>
@@ -61,15 +62,18 @@ static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
#endif
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
static void die(), usage();
static int kbd_fd;
+int
main(argc, argv)
int argc;
char** argv;
{
- int code, translate, direct = -1;
+ int code = 0, translate, direct = -1;
char led;
int click;
diff --git a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre
index 88c4a89b4..528ed12f0 100644
--- a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre
+++ b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre
@@ -23,7 +23,10 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
-.TH KBD_MODE 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.man,v 1.7 2001/12/14 19:59:42 dawes Exp $
+.\"
+.TH KBD_MODE 1 __xorgversion__
.SH NAME
kbd_mode \- recover the Sun console keyboard
.SH SYNOPSIS
diff --git a/hw/xfree86/utils/scanpci/scanpci.c b/hw/xfree86/utils/scanpci/scanpci.c
index f3a142fba..6093bd31a 100644
--- a/hw/xfree86/utils/scanpci/scanpci.c
+++ b/hw/xfree86/utils/scanpci/scanpci.c
@@ -1,30 +1,7 @@
-/* $Xorg: scanpci.c,v 1.3 2000/08/17 19:51:10 cpqbld Exp $ */
-/*
- * name: scanpci.c
- *
- * purpose: This program will scan for and print details of
- * devices on the PCI bus.
-
- * author: Robin Cutshaw (robin@xfree86.org)
- *
- * supported O/S's: SVR4, UnixWare, SCO, Solaris,
- * FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
- * Linux, Mach/386, ISC
- * DOS (WATCOM 9.5 compiler)
- *
- * compiling: [g]cc scanpci.c -o scanpci
- * for SVR4 (not Solaris), UnixWare use:
- * [g]cc -DSVR4 scanpci.c -o scanpci
- * for DOS, watcom 9.5:
- * wcc386p -zq -omaxet -7 -4s -s -w3 -d2 name.c
- * and link with PharLap or other dos extender for exe
- *
- */
-
-/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.10 1998/02/27 17:13:22 robin Exp $ */
-
/*
+ * Copyright 2000 by Egbert Eich
* Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ * Copyright 2002 by David Dawes
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -46,1510 +23,505 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.92 2003/02/13 12:17:14 tsi Exp $ */
+
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSproc.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xf86ScanPci.h"
+#include "dummylib.h"
+
+#include <stdarg.h>
+#include <stdlib.h>
+#ifdef __linux__
+/* to get getopt on Linux */
+#ifndef __USE_POSIX2
+#define __USE_POSIX2
+#endif
+#endif
+#include <unistd.h>
+
+#if defined(ISC) || defined(Lynx)
+extern char *optarg;
+extern int optind, opterr;
+#endif
+
+pciVideoPtr *xf86PciVideoInfo = NULL;
+
+static void usage(void);
+static void identify_card(pciConfigPtr pcr, int verbose);
+static void print_default_class(pciConfigPtr pcr);
+static void print_bridge_pci_class(pciConfigPtr pcr);
+static void print_mach64(pciConfigPtr pcr);
+static void print_i128(pciConfigPtr pcr);
+static void print_dc21050(pciConfigPtr pcr);
+static void print_simba(pciConfigPtr pcr);
+static void print_460gx_sac(pciConfigPtr pcr);
+static void print_460gx_pxb(pciConfigPtr pcr);
+static void print_460gx_gxb(pciConfigPtr pcr);
+
+#define MAX_DEV_PER_VENDOR 40
+
+typedef struct {
+ unsigned int Vendor;
+ struct {
+ int DeviceID;
+ void(*func)(pciConfigPtr);
+ } Device[MAX_DEV_PER_VENDOR];
+} pciVendorDevFuncInfo;
+
+static pciVendorDevFuncInfo vendorDeviceFuncInfo[] = {
+ { PCI_VENDOR_ATI, {
+ { PCI_CHIP_MACH64CT, print_mach64 },
+ { PCI_CHIP_MACH64CX, print_mach64 },
+ { PCI_CHIP_MACH64ET, print_mach64 },
+ { PCI_CHIP_MACH64GB, print_mach64 },
+ { PCI_CHIP_MACH64GD, print_mach64 },
+ { PCI_CHIP_MACH64GI, print_mach64 },
+ { PCI_CHIP_MACH64GL, print_mach64 },
+ { PCI_CHIP_MACH64GM, print_mach64 },
+ { PCI_CHIP_MACH64GN, print_mach64 },
+ { PCI_CHIP_MACH64GO, print_mach64 },
+ { PCI_CHIP_MACH64GP, print_mach64 },
+ { PCI_CHIP_MACH64GQ, print_mach64 },
+ { PCI_CHIP_MACH64GR, print_mach64 },
+ { PCI_CHIP_MACH64GS, print_mach64 },
+ { PCI_CHIP_MACH64GT, print_mach64 },
+ { PCI_CHIP_MACH64GU, print_mach64 },
+ { PCI_CHIP_MACH64GV, print_mach64 },
+ { PCI_CHIP_MACH64GW, print_mach64 },
+ { PCI_CHIP_MACH64GX, print_mach64 },
+ { PCI_CHIP_MACH64GY, print_mach64 },
+ { PCI_CHIP_MACH64GZ, print_mach64 },
+ { PCI_CHIP_MACH64LB, print_mach64 },
+ { PCI_CHIP_MACH64LD, print_mach64 },
+ { PCI_CHIP_MACH64LG, print_mach64 },
+ { PCI_CHIP_MACH64LI, print_mach64 },
+ { PCI_CHIP_MACH64LM, print_mach64 },
+ { PCI_CHIP_MACH64LN, print_mach64 },
+ { PCI_CHIP_MACH64LP, print_mach64 },
+ { PCI_CHIP_MACH64LQ, print_mach64 },
+ { PCI_CHIP_MACH64LR, print_mach64 },
+ { PCI_CHIP_MACH64LS, print_mach64 },
+ { PCI_CHIP_MACH64VT, print_mach64 },
+ { PCI_CHIP_MACH64VU, print_mach64 },
+ { PCI_CHIP_MACH64VV, print_mach64 },
+ { 0x0000, NULL } } },
+ { PCI_VENDOR_DIGITAL, {
+ { PCI_CHIP_DC21050, print_dc21050},
+ { 0x0000, NULL } } },
+ { PCI_VENDOR_NUMNINE, {
+ { PCI_CHIP_I128, print_i128 },
+ { PCI_CHIP_I128_2, print_i128 },
+ { PCI_CHIP_I128_T2R, print_i128 },
+ { PCI_CHIP_I128_T2R4, print_i128 },
+ { 0x0000, NULL } } },
+ { PCI_VENDOR_SUN, {
+ { PCI_CHIP_SIMBA, print_simba },
+ { 0x0000, NULL } } },
+ { PCI_VENDOR_INTEL, {
+ { PCI_CHIP_460GX_SAC, print_460gx_sac },
+ { PCI_CHIP_460GX_PXB, print_460gx_pxb },
+ { PCI_CHIP_460GX_GXB_1, print_460gx_gxb },
+ { PCI_CHIP_460GX_WXB, print_460gx_pxb }, /* Uncertain */
+ { 0x0000, NULL } } },
+ { 0x0000, {
+ { 0x0000, NULL } } }
+};
-#if defined(__SVR4)
-#if !defined(SVR4)
-#define SVR4
-#endif
-#endif
+static void
+usage(void)
+{
+ printf("Usage: scanpci [-v12OfV]\n");
+ printf(" -v print config space\n");
+ printf(" -1 config type 1\n");
+ printf(" -2 config type 2\n");
+ printf(" -O use OS config support\n");
+ printf(" -f force config type\n");
+ printf(" -V set message verbosity level\n");
+}
-#ifdef __EMX__
-#define INCL_DOSFILEMGR
-#include <os2.h>
-#endif
+int
+main(int argc, char *argv[])
+{
+ pciConfigPtr *pcrpp = NULL;
+ int Verbose = 0;
+ int i = 0;
+ int force = 0;
+ int c;
-#include <stdio.h>
-#include <sys/types.h>
-#if defined(SVR4)
-#if defined(sun)
-#define __EXTENSIONS__
-#endif
-#include <sys/proc.h>
-#include <sys/tss.h>
-#if defined(NCR)
-#define __STDC
-#include <sys/sysi86.h>
-#undef __STDC
-#else
-#include <sys/sysi86.h>
-#endif
-#if defined(__SUNPRO_C) || defined(sun) || defined(__sun)
-#include <sys/psw.h>
-#else
-#include <sys/seg.h>
-#endif
-#include <sys/v86.h>
-#endif
-#if defined(__FreeBSD__) || defined(__386BSD__)
-#include <sys/file.h>
-#include <machine/console.h>
-#ifndef GCCUSESGAS
-#define GCCUSESGAS
-#endif
-#endif
-#if defined(__NetBSD__)
-#include <sys/param.h>
-#include <sys/file.h>
-#include <machine/sysarch.h>
-#ifndef GCCUSESGAS
-#define GCCUSESGAS
-#endif
-#endif
-#if defined(__bsdi__)
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <i386/isa/pcconsioctl.h>
-#ifndef GCCUSESGAS
-#define GCCUSESGAS
-#endif
-#endif
-#if defined(SCO) || defined(ISC)
-#ifndef ISC
-#include <sys/console.h>
-#endif
-#include <sys/param.h>
-#include <sys/immu.h>
-#include <sys/region.h>
-#include <sys/proc.h>
-#include <sys/tss.h>
-#include <sys/sysi86.h>
-#include <sys/v86.h>
-#endif
-#if defined(Lynx_22)
-#ifndef GCCUSESGAS
-#define GCCUSESGAS
-#endif
-#endif
+ xf86Info.pciFlags = PCIProbe1;
+ while ((c = getopt(argc, argv, "?v12OfV:")) != -1)
+ switch(c) {
+ case 'v':
+ Verbose = 1;
+ break;
+ case '1':
+ xf86Info.pciFlags = PCIProbe1;
+ break;
+ case '2':
+ xf86Info.pciFlags = PCIProbe2;
+ break;
+ case 'O':
+ xf86Info.pciFlags = PCIOsConfig;
+ break;
+ case 'f':
+ force = 1;
+ break;
+ case 'V':
+ xf86Verbose = atoi(optarg);
+ break;
+ case '?':
+ default:
+ usage();
+ exit (1);
+ break;
+ }
-#if defined(__WATCOMC__)
+ if (force)
+ switch (xf86Info.pciFlags) {
+ case PCIProbe1:
+ xf86Info.pciFlags = PCIForceConfig1;
+ break;
+ case PCIProbe2:
+ xf86Info.pciFlags = PCIForceConfig2;
+ break;
+ default:
+ break;
+ }
-#include <stdlib.h>
-void outl(unsigned port, unsigned data);
-#pragma aux outl = "out dx, eax" parm [dx] [eax];
-void outb(unsigned port, unsigned data);
-#pragma aux outb = "out dx, al" parm [dx] [eax];
-unsigned inl(unsigned port);
-#pragma aux inl = "in eax, dx" parm [dx];
-unsigned inb(unsigned port);
-#pragma aux inb = "xor eax,eax" "in al, dx" parm [dx];
+ xf86EnableIO();
+ pcrpp = xf86scanpci(0);
-#else /* __WATCOMC__ */
+ if (!pcrpp) {
+ printf("No PCI devices found\n");
+ xf86DisableIO();
+ exit (1);
+ }
-#if defined(__GNUC__)
+ while (pcrpp[i])
+ identify_card(pcrpp[i++],Verbose);
-#if !defined(__alpha__) && !defined(__powerpc__)
-#if defined(GCCUSESGAS)
-#define OUTB_GCC "outb %0,%1"
-#define OUTL_GCC "outl %0,%1"
-#define INB_GCC "inb %1,%0"
-#define INL_GCC "inl %1,%0"
-#else
-#define OUTB_GCC "out%B0 (%1)"
-#define OUTL_GCC "out%L0 (%1)"
-#define INB_GCC "in%B0 (%1)"
-#define INL_GCC "in%L0 (%1)"
-#endif /* GCCUSESGAS */
+ xf86DisableIO();
+ exit(0);
+}
-static void outb(unsigned short port, unsigned char val) {
- __asm__ __volatile__(OUTB_GCC : :"a" (val), "d" (port)); }
-static void outl(unsigned short port, unsigned long val) {
- __asm__ __volatile__(OUTL_GCC : :"a" (val), "d" (port)); }
-static unsigned char inb(unsigned short port) { unsigned char ret;
- __asm__ __volatile__(INB_GCC : "=a" (ret) : "d" (port)); return ret; }
-static unsigned long inl(unsigned short port) { unsigned long ret;
- __asm__ __volatile__(INL_GCC : "=a" (ret) : "d" (port)); return ret; }
+static void
+identify_card(pciConfigPtr pcr, int verbose)
+{
+ int i, j;
+ int foundit = 0;
+ int foundvendor = 0;
+ const char *vname, *dname, *svname, *sname;
-#endif /* !defined(__alpha__) && !defined(__powerpc__) */
-#else /* __GNUC__ */
+ pciVendorDevFuncInfo *vdf = vendorDeviceFuncInfo;
-#if defined(__STDC__) && (__STDC__ == 1)
-# if !defined(NCR)
-# define asm __asm
-# endif
-#endif
+ if (!ScanPciSetupPciIds()) {
+ fprintf(stderr, "xf86SetupPciIds() failed\n");
+ exit(1);
+ }
-#if defined(__SUNPRO_C)
-/*
- * This section is a gross hack in if you tell anyone that I wrote it,
- * I'll deny it. :-)
- * The leave/ret instructions are the big hack to leave %eax alone on return.
- */
- unsigned char inb(int port) {
- asm(" movl 8(%esp),%edx");
- asm(" subl %eax,%eax");
- asm(" inb (%dx)");
- asm(" leave");
- asm(" ret");
- }
+ printf("\npci bus 0x%04x cardnum 0x%02x function 0x%02x:"
+ " vendor 0x%04x device 0x%04x\n",
+ pcr->busnum, pcr->devnum, pcr->funcnum,
+ pcr->pci_vendor, pcr->pci_device);
- unsigned short inw(int port) {
- asm(" movl 8(%esp),%edx");
- asm(" subl %eax,%eax");
- asm(" inw (%dx)");
- asm(" leave");
- asm(" ret");
- }
+ ScanPciFindPciNamesByDevice(pcr->pci_vendor, pcr->pci_device,
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card,
+ &vname, &dname, &svname, &sname);
- unsigned long inl(int port) {
- asm(" movl 8(%esp),%edx");
- asm(" inl (%dx)");
- asm(" leave");
- asm(" ret");
+ if (vname) {
+ printf(" %s ", vname);
+ if (dname) {
+ printf("%s", dname);
+ foundit = 1;
}
+ }
- void outb(int port, unsigned char value) {
- asm(" movl 8(%esp),%edx");
- asm(" movl 12(%esp),%eax");
- asm(" outb (%dx)");
+ if (!foundit)
+ printf(" Device unknown\n");
+ else {
+ printf("\n");
+ if (verbose) {
+ for (i = 0; vdf[i].Vendor; i++) {
+ if (vdf[i].Vendor == pcr->pci_vendor) {
+ for (j = 0; vdf[i].Device[j].DeviceID; j++) {
+ if (vdf[i].Device[j].DeviceID == pcr->pci_device) {
+ (*vdf[i].Device[j].func)(pcr);
+ return;
+ }
+ }
+ break;
+ }
+ }
}
+ }
- void outw(int port, unsigned short value) {
- asm(" movl 8(%esp),%edx");
- asm(" movl 12(%esp),%eax");
- asm(" outw (%dx)");
+ if (verbose && !(pcr->pci_header_type & 0x7f) &&
+ (pcr->pci_subsys_vendor != 0 || pcr->pci_subsys_card != 0) &&
+ (pcr->pci_vendor != pcr->pci_subsys_vendor ||
+ pcr->pci_device != pcr->pci_subsys_card)) {
+ foundit = 0;
+ foundvendor = 0;
+ printf(" CardVendor 0x%04x card 0x%04x",
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card);
+ if (svname) {
+ printf(" (%s", svname);
+ foundvendor = 1;
+ if (sname) {
+ printf(" %s)", sname);
+ foundit = 1;
+ }
}
- void outl(int port, unsigned long value) {
- asm(" movl 8(%esp),%edx");
- asm(" movl 12(%esp),%eax");
- asm(" outl (%dx)");
+ if (!foundit) {
+ if (!foundvendor)
+ printf(" (");
+ else
+ printf(", ");
+ printf("Card unknown)");
}
-#else
-
-#if defined(SVR4)
-# if !defined(__USLC__)
-# define __USLC__
-# endif
-#endif
-
-#ifndef SCO325
-# include <sys/inline.h>
-#else
-# include "scoasm.h"
-#endif
-
-#endif /* SUNPRO_C */
-
-#endif /* __GNUC__ */
-#endif /* __WATCOMC__ */
-
-
-#if defined(__alpha__)
-#if defined(linux)
-#include <asm/unistd.h>
-#define BUS(tag) (((tag)>>16)&0xff)
-#define DFN(tag) (((tag)>>8)&0xff)
-int pciconfig_read(
- unsigned char bus,
- unsigned char dfn,
- unsigned char off,
- unsigned char len,
- void * buf)
-{
- return __syscall(__NR_pciconfig_read, bus, dfn, off, len, buf);
-}
-int pciconfig_write(
- unsigned char bus,
- unsigned char dfn,
- unsigned char off,
- unsigned char len,
- void * buf)
-{
- return __syscall(__NR_pciconfig_write, bus, dfn, off, len, buf);
-}
-#else
-Generate compiler error - scanpci unsupported on non-linux alpha platforms
-#endif /* linux */
-#endif /* __alpha__ */
-#if defined(Lynx) && defined(__powerpc__)
-/* let's mimick the Linux Alpha stuff for LynxOS so we don't have
- * to change too much code
- */
-#include <smem.h>
-
-unsigned char *pciConfBase;
+ printf("\n");
+ }
-static __inline__ unsigned long
-swapl(unsigned long val)
-{
- unsigned char *p = (unsigned char *)&val;
- return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0));
+ if (verbose) {
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+ if ((pcr->pci_base_class == PCI_CLASS_BRIDGE) &&
+ (pcr->pci_sub_class == PCI_SUBCLASS_BRIDGE_PCI))
+ print_bridge_pci_class(pcr);
+ else
+ print_default_class(pcr);
+ }
}
-
-#define BUS(tag) (((tag)>>16)&0xff)
-#define DFN(tag) (((tag)>>8)&0xff)
-
-#define PCIBIOS_DEVICE_NOT_FOUND 0x86
-#define PCIBIOS_SUCCESSFUL 0x00
-
-int pciconfig_read(
- unsigned char bus,
- unsigned char dev,
- unsigned char offset,
- int len, /* unused, alway 4 */
- unsigned long *val)
+static void
+print_default_class(pciConfigPtr pcr)
{
- unsigned long _val;
- unsigned long *ptr;
-
- dev >>= 3;
- if (bus || dev >= 16) {
- *val = 0xFFFFFFFF;
- return PCIBIOS_DEVICE_NOT_FOUND;
+ printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
+ pcr->pci_bist, pcr->pci_header_type, pcr->pci_latency_timer,
+ pcr->pci_cache_line_size);
+ if (pcr->pci_base0) {
+ if ((pcr->pci_base0 & 0x7) == 0x4) {
+ printf(" BASE0 0x%08x%08x addr 0x%08x%08x MEM%s 64BIT\n",
+ (int)pcr->pci_base1, (int)pcr->pci_base0,
+ (int)pcr->pci_base1,
+ (int)(pcr->pci_base0 &
+ (pcr->pci_base0 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base0 & 0x8) ? " PREFETCHABLE" :"");
} else {
- ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
- _val = swapl(*ptr);
+ printf(" BASE0 0x%08x addr 0x%08x %s%s\n",
+ (int)pcr->pci_base0,
+ (int)(pcr->pci_base0 &
+ (pcr->pci_base0 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base0 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base0 & 0x9) == 0x8) ? " PREFETCHABLE" :"");
}
- *val = _val;
- return PCIBIOS_SUCCESSFUL;
-}
-
-int pciconfig_write(
- unsigned char bus,
- unsigned char dev,
- unsigned char offset,
- int len, /* unused, alway 4 */
- unsigned long val)
-{
- unsigned long _val;
- unsigned long *ptr;
-
- dev >>= 3;
- _val = swapl(val);
- if (bus || dev >= 16) {
- return PCIBIOS_DEVICE_NOT_FOUND;
+ }
+ if ((pcr->pci_base1) && ((pcr->pci_base0 & 0x7) != 0x4)) {
+ if ((pcr->pci_base1 & 0x7) == 0x4) {
+ printf(" BASE1 0x%08x%08x addr 0x%08x%08x MEM%s 64BIT\n",
+ (int)pcr->pci_base2, (int)pcr->pci_base1,
+ (int)pcr->pci_base2,
+ (int)(pcr->pci_base1 &
+ (pcr->pci_base1 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base1 & 0x8) ? " PREFETCHABLE" :"");
} else {
- ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
- *ptr = _val;
+ printf(" BASE1 0x%08x addr 0x%08x %s%s\n",
+ (int)pcr->pci_base1,
+ (int)(pcr->pci_base1 &
+ (pcr->pci_base1 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base1 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base1 & 0x9) == 0x8) ? " PREFETCHABLE" :"");
}
- return PCIBIOS_SUCCESSFUL;
-}
-#endif
-
-#if !defined(__powerpc__)
-struct pci_config_reg {
- /* start of official PCI config space header */
- union {
- unsigned long device_vendor;
- struct {
- unsigned short vendor;
- unsigned short device;
- } dv;
- } dv_id;
-#define _device_vendor dv_id.device_vendor
-#define _vendor dv_id.dv.vendor
-#define _device dv_id.dv.device
- union {
- unsigned long status_command;
- struct {
- unsigned short command;
- unsigned short status;
- } sc;
- } stat_cmd;
-#define _status_command stat_cmd.status_command
-#define _command stat_cmd.sc.command
-#define _status stat_cmd.sc.status
- union {
- unsigned long class_revision;
- struct {
- unsigned char rev_id;
- unsigned char prog_if;
- unsigned char sub_class;
- unsigned char base_class;
- } cr;
- } class_rev;
-#define _class_revision class_rev.class_revision
-#define _rev_id class_rev.cr.rev_id
-#define _prog_if class_rev.cr.prog_if
-#define _sub_class class_rev.cr.sub_class
-#define _base_class class_rev.cr.base_class
- union {
- unsigned long bist_header_latency_cache;
- struct {
- unsigned char cache_line_size;
- unsigned char latency_timer;
- unsigned char header_type;
- unsigned char bist;
- } bhlc;
- } bhlc;
-#define _bist_header_latency_cache bhlc.bist_header_latency_cache
-#define _cache_line_size bhlc.bhlc.cache_line_size
-#define _latency_timer bhlc.bhlc.latency_timer
-#define _header_type bhlc.bhlc.header_type
-#define _bist bhlc.bhlc.bist
- union {
- struct {
- unsigned long dv_base0;
- unsigned long dv_base1;
- unsigned long dv_base2;
- unsigned long dv_base3;
- unsigned long dv_base4;
- unsigned long dv_base5;
- } dv;
- struct {
- unsigned long bg_rsrvd[2];
- unsigned char primary_bus_number;
- unsigned char secondary_bus_number;
- unsigned char subordinate_bus_number;
- unsigned char secondary_latency_timer;
- unsigned char io_base;
- unsigned char io_limit;
- unsigned short secondary_status;
- unsigned short mem_base;
- unsigned short mem_limit;
- unsigned short prefetch_mem_base;
- unsigned short prefetch_mem_limit;
- } bg;
- } bc;
-#define _base0 bc.dv.dv_base0
-#define _base1 bc.dv.dv_base1
-#define _base2 bc.dv.dv_base2
-#define _base3 bc.dv.dv_base3
-#define _base4 bc.dv.dv_base4
-#define _base5 bc.dv.dv_base5
-#define _primary_bus_number bc.bg.primary_bus_number
-#define _secondary_bus_number bc.bg.secondary_bus_number
-#define _subordinate_bus_number bc.bg.subordinate_bus_number
-#define _secondary_latency_timer bc.bg.secondary_latency_timer
-#define _io_base bc.bg.io_base
-#define _io_limit bc.bg.io_limit
-#define _secondary_status bc.bg.secondary_status
-#define _mem_base bc.bg.mem_base
-#define _mem_limit bc.bg.mem_limit
-#define _prefetch_mem_base bc.bg.prefetch_mem_base
-#define _prefetch_mem_limit bc.bg.prefetch_mem_limit
- unsigned long rsvd1;
- unsigned long rsvd2;
- unsigned long _baserom;
- unsigned long rsvd3;
- unsigned long rsvd4;
- union {
- unsigned long max_min_ipin_iline;
- struct {
- unsigned char int_line;
- unsigned char int_pin;
- unsigned char min_gnt;
- unsigned char max_lat;
- } mmii;
- } mmii;
-#define _max_min_ipin_iline mmii.max_min_ipin_iline
-#define _int_line mmii.mmii.int_line
-#define _int_pin mmii.mmii.int_pin
-#define _min_gnt mmii.mmii.min_gnt
-#define _max_lat mmii.mmii.max_lat
- /* I don't know how accurate or standard this is (DHD) */
- union {
- unsigned long user_config;
- struct {
- unsigned char user_config_0;
- unsigned char user_config_1;
- unsigned char user_config_2;
- unsigned char user_config_3;
- } uc;
- } uc;
-#define _user_config uc.user_config
-#define _user_config_0 uc.uc.user_config_0
-#define _user_config_1 uc.uc.user_config_1
-#define _user_config_2 uc.uc.user_config_2
-#define _user_config_3 uc.uc.user_config_3
- /* end of official PCI config space header */
- unsigned long _pcibusidx;
- unsigned long _pcinumbus;
- unsigned long _pcibuses[16];
- unsigned short _configtype; /* config type found */
- unsigned short _ioaddr; /* config type 1 - private I/O addr */
- unsigned long _cardnum; /* config type 2 - private card number */
-};
-#else
-/* ppc is big endian, swapping bytes is not quite enough
- * to interpret the PCI config registers...
- */
-struct pci_config_reg {
- /* start of official PCI config space header */
- union {
- unsigned long device_vendor;
- struct {
- unsigned short device;
- unsigned short vendor;
- } dv;
- } dv_id;
-#define _device_vendor dv_id.device_vendor
-#define _vendor dv_id.dv.vendor
-#define _device dv_id.dv.device
- union {
- unsigned long status_command;
- struct {
- unsigned short status;
- unsigned short command;
- } sc;
- } stat_cmd;
-#define _status_command stat_cmd.status_command
-#define _command stat_cmd.sc.command
-#define _status stat_cmd.sc.status
- union {
- unsigned long class_revision;
- struct {
- unsigned char base_class;
- unsigned char sub_class;
- unsigned char prog_if;
- unsigned char rev_id;
- } cr;
- } class_rev;
-#define _class_revision class_rev.class_revision
-#define _rev_id class_rev.cr.rev_id
-#define _prog_if class_rev.cr.prog_if
-#define _sub_class class_rev.cr.sub_class
-#define _base_class class_rev.cr.base_class
- union {
- unsigned long bist_header_latency_cache;
- struct {
- unsigned char bist;
- unsigned char header_type;
- unsigned char latency_timer;
- unsigned char cache_line_size;
- } bhlc;
- } bhlc;
-#define _bist_header_latency_cache bhlc.bist_header_latency_cache
-#define _cache_line_size bhlc.bhlc.cache_line_size
-#define _latency_timer bhlc.bhlc.latency_timer
-#define _header_type bhlc.bhlc.header_type
-#define _bist bhlc.bhlc.bist
- union {
- struct {
- unsigned long dv_base0;
- unsigned long dv_base1;
- unsigned long dv_base2;
- unsigned long dv_base3;
- unsigned long dv_base4;
- unsigned long dv_base5;
- } dv;
-/* ?? */
- struct {
- unsigned long bg_rsrvd[2];
-
- unsigned char secondary_latency_timer;
- unsigned char subordinate_bus_number;
- unsigned char secondary_bus_number;
- unsigned char primary_bus_number;
-
- unsigned short secondary_status;
- unsigned char io_limit;
- unsigned char io_base;
-
- unsigned short mem_limit;
- unsigned short mem_base;
-
- unsigned short prefetch_mem_limit;
- unsigned short prefetch_mem_base;
- } bg;
- } bc;
-#define _base0 bc.dv.dv_base0
-#define _base1 bc.dv.dv_base1
-#define _base2 bc.dv.dv_base2
-#define _base3 bc.dv.dv_base3
-#define _base4 bc.dv.dv_base4
-#define _base5 bc.dv.dv_base5
-#define _primary_bus_number bc.bg.primary_bus_number
-#define _secondary_bus_number bc.bg.secondary_bus_number
-#define _subordinate_bus_number bc.bg.subordinate_bus_number
-#define _secondary_latency_timer bc.bg.secondary_latency_timer
-#define _io_base bc.bg.io_base
-#define _io_limit bc.bg.io_limit
-#define _secondary_status bc.bg.secondary_status
-#define _mem_base bc.bg.mem_base
-#define _mem_limit bc.bg.mem_limit
-#define _prefetch_mem_base bc.bg.prefetch_mem_base
-#define _prefetch_mem_limit bc.bg.prefetch_mem_limit
- unsigned long rsvd1;
- unsigned long rsvd2;
- unsigned long _baserom;
- unsigned long rsvd3;
- unsigned long rsvd4;
- union {
- unsigned long max_min_ipin_iline;
- struct {
- unsigned char max_lat;
- unsigned char min_gnt;
- unsigned char int_pin;
- unsigned char int_line;
- } mmii;
- } mmii;
-#define _max_min_ipin_iline mmii.max_min_ipin_iline
-#define _int_line mmii.mmii.int_line
-#define _int_pin mmii.mmii.int_pin
-#define _min_gnt mmii.mmii.min_gnt
-#define _max_lat mmii.mmii.max_lat
- /* I don't know how accurate or standard this is (DHD) */
- union {
- unsigned long user_config;
- struct {
- unsigned char user_config_3;
- unsigned char user_config_2;
- unsigned char user_config_1;
- unsigned char user_config_0;
- } uc;
- } uc;
-#define _user_config uc.user_config
-#define _user_config_0 uc.uc.user_config_0
-#define _user_config_1 uc.uc.user_config_1
-#define _user_config_2 uc.uc.user_config_2
-#define _user_config_3 uc.uc.user_config_3
- /* end of official PCI config space header */
- unsigned long _pcibusidx;
- unsigned long _pcinumbus;
- unsigned long _pcibuses[16];
- unsigned short _ioaddr; /* config type 1 - private I/O addr */
- unsigned short _configtype; /* config type found */
- unsigned long _cardnum; /* config type 2 - private card number */
-};
-#endif
-
-extern void identify_card(struct pci_config_reg *, int);
-extern void print_i128(struct pci_config_reg *);
-extern void print_mach64(struct pci_config_reg *);
-extern void print_pcibridge(struct pci_config_reg *);
-extern void enable_os_io();
-extern void disable_os_io();
-
-#define MAX_DEV_PER_VENDOR_CFG1 32
-#define MAX_DEV_PER_VENDOR_CFG2 16
-#define MAX_PCI_DEVICES 64
-#define NF ((void (*)())NULL)
-#define PCI_MULTIFUNC_DEV 0x80
-#if defined(__alpha__) || defined(__powerpc__)
-#define PCI_ID_REG 0x00
-#define PCI_CMD_STAT_REG 0x04
-#define PCI_CLASS_REG 0x08
-#define PCI_HEADER_MISC 0x0C
-#define PCI_MAP_REG_START 0x10
-#define PCI_MAP_ROM_REG 0x30
-#define PCI_INTERRUPT_REG 0x3C
-#define PCI_REG_USERCONFIG 0x40
-#endif
-
-struct pci_vendor_device {
- unsigned short vendor_id;
- char *vendorname;
- struct pci_device {
- unsigned short device_id;
- char *devicename;
- void (*print_func)(struct pci_config_reg *);
- } device[MAX_DEV_PER_VENDOR_CFG1];
-} pvd[] = {
- { 0x0e11, "Compaq", {
- { 0x3033, "QVision 1280/p", NF },
- { 0xae10, "Smart-2/P RAID Controller", NF },
- { 0xae32, "Netellignet 10/100", NF },
- { 0xae34, "Netellignet 10", NF },
- { 0xae35, "NetFlex 3", NF },
- { 0xae40, "Netellignet 10/100 Dual", NF },
- { 0xae43, "Netellignet 10/100 ProLiant", NF },
- { 0xb011, "Netellignet 10/100 Integrated", NF },
- { 0xf130, "ThunderLAN", NF },
- { 0xf150, "NetFlex 3 BNC", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1000, "NCR", {
- { 0x0001, "53C810", NF },
- { 0x0002, "53C820", NF },
- { 0x0003, "53C825", NF },
- { 0x0004, "53C815", NF },
- { 0x0005, "53C810AP", NF },
- { 0x0006, "53C860", NF },
- { 0x000B, "53C896", NF },
- { 0x000C, "53C895", NF },
- { 0x000D, "53C885", NF },
- { 0x000F, "53C875", NF },
- { 0x008F, "53C875J", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1002, "ATI", {
- { 0x4158, "Mach32", NF },
- { 0x4354, "Mach64 CT", print_mach64 },
- { 0x4358, "Mach64 CX", print_mach64 },
- { 0x4554, "Mach64 ET", print_mach64 },
- { 0x4742, "Mach64 GB", print_mach64 },
- { 0x4744, "Mach64 GD", print_mach64 },
- { 0x4750, "Mach64 GP", print_mach64 },
- { 0x4754, "Mach64 GT", print_mach64 },
- { 0x4755, "Mach64 GT", print_mach64 },
- { 0x4758, "Mach64 GX", print_mach64 },
- { 0x4C47, "Mach64 LT", print_mach64 },
- { 0x5654, "Mach64 VT", print_mach64 },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1004, "VLSI", {
- { 0x0005, "82C592-FC1", NF },
- { 0x0006, "82C593-FC1", NF },
- { 0x0007, "82C594-AFC2", NF },
- { 0x0009, "82C597-AFC2", NF },
- { 0x000C, "82C541 Lynx", NF },
- { 0x000D, "82C543 Lynx ISA", NF },
- { 0x0702, "VAS96011", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1005, "Avance Logic", {
- { 0x2301, "ALG2301", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x100B, "NS", {
- { 0x0002, "87415", NF },
- { 0xD001, "87410", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x100C, "Tseng Labs", {
- { 0x3202, "ET4000w32p rev A", NF },
- { 0x3205, "ET4000w32p rev B", NF },
- { 0x3206, "ET4000w32p rev D", NF },
- { 0x3207, "ET4000w32p rev C", NF },
- { 0x3208, "ET6000/6100", NF },
- { 0x4702, "ET6300", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x100E, "Weitek", {
- { 0x9001, "P9000", NF },
- { 0x9100, "P9100", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1011, "Digital Equipment Corporation", {
- { 0x0001, "DC21050 PCI-PCI Bridge",print_pcibridge},
- { 0x0002, "DC21040 10Mb/s Ethernet", NF },
- { 0x0004, "TGA", NF },
- { 0x0009, "DC21140 10/100 Mb/s Ethernet", NF },
- { 0x000D, "TGA2", NF },
- { 0x000F, "DEFPA (FDDI PCI)", NF },
- { 0x0014, "DC21041 10Mb/s Ethernet Plus", NF },
- { 0x0019, "DC21142 10/100 Mb/s Ethernet", NF },
- { 0x0021, "DC21052", NF },
- { 0x0024, "DC21152", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1013, "Cirrus Logic", {
- { 0x0038, "GD 7548", NF },
- { 0x00A0, "GD 5430", NF },
- { 0x00A4, "GD 5434-4", NF },
- { 0x00A8, "GD 5434-8", NF },
- { 0x00AC, "GD 5436", NF },
- { 0x00B8, "GD 5446", NF },
- { 0x00BC, "GD 5480", NF },
- { 0x00D0, "GD 5462", NF },
- { 0x00D4, "GD 5464", NF },
- { 0x1100, "CL 6729", NF },
- { 0x1110, "CL 6832", NF },
- { 0x1200, "GD 7542", NF },
- { 0x1202, "GD 7543", NF },
- { 0x1204, "GD 7541", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1014, "IBM", {
- { 0x000A, "Fire Coral", NF },
- { 0x0018, "Token Ring", NF },
- { 0x001D, "82G2675", NF },
- { 0x0022, "82351 pci-pci bridge", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x101A, "NCR", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x101C, "WD*", {
- { 0x3296, "WD 7197", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1022, "AMD", {
- { 0x2000, "79C970 Lance", NF },
- { 0x2020, "53C974 SCSI", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1023, "Trident", {
- { 0x9320, "TGUI 9320", NF },
- { 0x9420, "TGUI 9420", NF },
- { 0x9440, "TGUI 9440", NF },
- { 0x9660, "TGUI 9660/9680/9682", NF },
-#if 0
- { 0x9680, "TGUI 9680", NF },
- { 0x9682, "TGUI 9682", NF },
-#endif
- { 0x9750, "TGUI 9750", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1025, "ALI", {
- { 0x1435, "M1435", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x102B, "Matrox", {
- { 0x0518, "MGA-2 Atlas PX2085", NF },
- { 0x0519, "MGA Millennium", NF },
- { 0x051a, "MGA Mystique", NF },
- { 0x051b, "MGA Millennium II", NF },
- { 0x0D10, "MGA Impression", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x102C, "CT", {
- { 0x00D8, "65545", NF },
- { 0x00DC, "65548", NF },
- { 0x00E0, "65550", NF },
- { 0x00E4, "65554", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1031, "Miro", {
- { 0x5601, "ZR36050", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1033, "NEC", {
- { 0x0046, "PowerVR PCX2", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1036, "FD", {
- { 0x0000, "TMC-18C30 (36C70)", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1039, "SIS", {
- { 0x0001, "86C201", NF },
- { 0x0002, "86C202", NF },
- { 0x0008, "85C503", NF },
- { 0x0205, "86C205", NF },
- { 0x0406, "85C501", NF },
- { 0x0496, "85C496", NF },
- { 0x0601, "85C601", NF },
- { 0x5107, "5107", NF },
- { 0x5511, "85C5511", NF },
- { 0x5513, "85C5513", NF },
- { 0x5571, "5571", NF },
- { 0x5597, "5597", NF },
- { 0x7001, "7001", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x103C, "HP", {
- { 0x1030, "J2585A", NF },
- { 0x1031, "J2585B", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1042, "SMC/PCTECH", {
- { 0x1000, "FDC 37C665/RZ1000", NF },
- { 0x1001, "FDC /RZ1001", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1044, "DPT", {
- { 0xA400, "SmartCache/Raid", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1045, "Opti", {
- { 0xC178, "92C178", NF },
- { 0xC557, "82C557 Viper-M", NF },
- { 0xC558, "82C558 Viper-M ISA+IDE", NF },
- { 0xC621, "82C621", NF },
- { 0xC700, "82C700", NF },
- { 0xC701, "82C701 FireStar Plus", NF },
- { 0xC814, "82C814 Firebridge 1", NF },
- { 0xC822, "82C822", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x104A, "SGS Thomson", {
- { 0x0008, "STG2000", NF },
- { 0x0009, "STG1764", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x104B, "BusLogic", {
- { 0x0140, "946C 01", NF },
- { 0x1040, "946C 10", NF },
- { 0x8130, "FlashPoint", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x104C, "Texas Instruments", {
- { 0x3d04, "3DLabs Permedia", NF },
- { 0x3d07, "3DLabs Permedia 2", NF },
- { 0xAC12, "PCI1130", NF },
- { 0xAC15, "PCI1131", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x104E, "Oak", {
- { 0x0107, "OTI107", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1050, "Windbond", {
- { 0x0940, "89C940 NE2000-PCI", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1057, "Motorola", {
- { 0x0001, "MPC105 Eagle", NF },
- { 0x0002, "MPC105 Grackle", NF },
- { 0x4801, "Raven", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x105A, "Promise", {
- { 0x4D33, "IDE UltraDMA/33", NF },
- { 0x5300, "DC5030", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x105D, "Number Nine", {
- { 0x2309, "Imagine-128", print_i128 },
- { 0x2339, "Imagine-128-II", print_i128 },
- { 0x493D, "Imagine-128-T2R", print_i128 },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1060, "UMC", {
- { 0x0101, "UM8673F", NF },
- { 0x673A, "UM8886BF", NF },
- { 0x886A, "UM8886A", NF },
- { 0x8881, "UM8881F", NF },
- { 0x8886, "UM8886F", NF },
- { 0x8891, "UM8891A", NF },
- { 0x9017, "UM9017F", NF },
- { 0xE886, "UM8886N", NF },
- { 0xE891, "UM8891N", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1061, "X", {
- { 0x0001, "ITT AGX016", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1066, "PICOP", {
- { 0x0001, "PT86C52x Vesuvius", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x106B, "Apple", {
- { 0x0001, "Bandit", NF },
- { 0x0002, "Grand Central", NF },
- { 0x000E, "Hydra", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1074, "Nexgen", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x1077, "QLogic", {
- { 0x1020, "ISP1020", NF },
- { 0x1022, "ISP1022", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1078, "Cyrix", {
- { 0x0000, "5510", NF },
- { 0x0001, "PCI Master", NF },
- { 0x0002, "5520", NF },
- { 0x0100, "5530 Kahlua Legacy", NF },
- { 0x0101, "5530 Kahlua SMI", NF },
- { 0x0102, "5530 Kahlua IDE", NF },
- { 0x0103, "5530 Kahlua Audio", NF },
- { 0x0104, "5530 Kahlua Video", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x107D, "Leadtek", {
- { 0x0000, "S3 805", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1080, "Contaq", {
- { 0x0600, "82C599", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1083, "FOREX", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x108D, "Olicom", {
- { 0x0001, "OC-3136", NF },
- { 0x0011, "OC-2315", NF },
- { 0x0012, "OC-2325", NF },
- { 0x0013, "OC-2183", NF },
- { 0x0014, "OC-2326", NF },
- { 0x0021, "OC-6151", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x108E, "Sun", {
- { 0x1000, "EBUS", NF },
- { 0x1001, "Happy Meal", NF },
- { 0x8000, "PCI Bus Module", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1095, "CMD", {
- { 0x0640, "640A", NF },
- { 0x0643, "643", NF },
- { 0x0646, "646", NF },
- { 0x0670, "670", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1098, "Vision", {
- { 0x0001, "QD 8500", NF },
- { 0x0002, "QD 8580", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x109E, "Brooktree", {
- { 0x0350, "Bt848", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10A8, "Sierra", {
- { 0x0000, "STB Horizon 64", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10AA, "ACC", {
- { 0x0000, "2056", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10AD, "Winbond", {
- { 0x0001, "W83769F", NF },
- { 0x0105, "SL82C105", NF },
- { 0x0565, "W83C553", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10B3, "Databook", {
- { 0xB106, "DB87144", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10B7, "3COM", {
- { 0x5900, "3C590 10bT", NF },
- { 0x5950, "3C595 100bTX", NF },
- { 0x5951, "3C595 100bT4", NF },
- { 0x5952, "3C595 10b-MII", NF },
- { 0x9000, "3C900 10bTPO", NF },
- { 0x9001, "3C900 10b Combo", NF },
- { 0x9050, "3C905 100bTX", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10B8, "SMC", {
- { 0x0005, "9432 TX", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10B9, "ALI", {
- { 0x1445, "M1445", NF },
- { 0x1449, "M1449", NF },
- { 0x1451, "M1451", NF },
- { 0x1461, "M1461", NF },
- { 0x1489, "M1489", NF },
- { 0x1511, "M1511", NF },
- { 0x1513, "M1513", NF },
- { 0x1521, "M1521", NF },
- { 0x1523, "M1523", NF },
- { 0x1531, "M1531 Aladdin IV", NF },
- { 0x1533, "M1533 Aladdin IV", NF },
- { 0x5215, "M4803", NF },
- { 0x5219, "M5219", NF },
- { 0x5229, "M5229 TXpro", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10BA, "Mitsubishi", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x10BD, "Surecom", {
- { 0x0E34, "NE-34PCI Lan", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10C8, "Neomagic", {
- { 0x0001, "Magicgraph NM2070", NF },
- { 0x0002, "Magicgraph 128V", NF },
- { 0x0003, "Magicgraph 128ZV", NF },
- { 0x0004, "Magicgraph NM2160", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10CD, "Advanced System Products", {
- { 0x1200, "ABP940", NF },
- { 0x1300, "ABP940U", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10DC, "CERN", {
- { 0x0001, "STAR/RD24 SCI-PCI (PMC)", NF },
- { 0x0002, "STAR/RD24 SCI-PCI (PMC)", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10DE, "NVidia", {
- { 0x0008, "NV1", NF },
- { 0x0009, "DAC64", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10E0, "IMS", {
- { 0x8849, "8849", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10E1, "Tekram", {
- { 0x690C, "DC690C", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10E3, "Tundra", {
- { 0x0000, "CA91C042 Universe", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10E8, "AMCC", {
- { 0x8043, "Myrinet PCI (M2-PCI-32)", NF },
- { 0x807D, "S5933 PCI44", NF },
- { 0x809C, "S5933 Traquair HEPC3", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10EA, "Intergraphics", {
- { 0x1680, "IGA-1680", NF },
- { 0x1682, "IGA-1682", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10EC, "Realtek", {
- { 0x8029, "8029", NF },
- { 0x8129, "8129", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x10FA, "Truevision", {
- { 0x000C, "Targa 1000", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1101, "Initio Corp", {
- { 0x9100, "320 P", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1106, "VIA", {
- { 0x0505, "VT 82C505", NF },
- { 0x0561, "VT 82C505", NF },
- { 0x0576, "VT 82C576 3V", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1119, "Vortex", {
- { 0x0001, "GDT 6000b", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x111A, "EF", {
- { 0x0000, "155P-MF1", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1127, "Fore Systems", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x112F, "Imaging Technology", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x113C, "PLX", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x1142, "Alliance", {
- { 0x3210, "ProMotion 6410", NF },
- { 0x6422, "ProMotion 6422", NF },
- { 0x6424, "ProMotion AT24", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x114A, "VMIC", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x114F, "DIGI*", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x1159, "Mutech", {
- { 0x0001, "MV1000", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1163, "Rendition", {
- { 0x0001, "V1000", NF },
- { 0x2000, "V2100", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1179, "Toshiba", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x1193, "Zeinet", {
- { 0x0001, "1221", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x11CB, "Specialix", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x11FE, "Control", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x120E, "Cyclades", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x121A, "3Dfx Interactive", {
- { 0x0001, "Voodoo Graphics", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1236, "Sigma Designs", {
- { 0x6401, "REALmagic64/GX (SD 6425)", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1281, "YOKOGAWA", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x1292, "TriTech Microelectronics", {
- { 0xfc02, "Pyramid3D TR25202", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x12D2, "NVidia/SGS-Thomson", {
- { 0x0018, "Riva128", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1C1C, "Symphony", {
- { 0x0001, "82C101", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x1DE1, "Tekram", {
- { 0xDC29, "DC290", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x3D3D, "3Dlabs", {
- { 0x0001, "GLINT 300SX", NF },
- { 0x0002, "GLINT 500TX", NF },
- { 0x0003, "GLINT Delta", NF },
- { 0x0004, "GLINT Permedia", NF },
- { 0x0006, "GLINT MX", NF },
- { 0x0007, "GLINT Permedia 2", NF },
- { 0x0000, (char *)NULL, NF } } } ,
- { 0x4005, "Avance", {
- { 0x0000, (char *)NULL, NF } } },
- { 0x5333, "S3", {
- { 0x0551, "Plato/PX", NF },
- { 0x5631, "ViRGE", NF },
- { 0x8811, "Trio32/64", NF },
- { 0x8812, "Aurora64V+", NF },
- { 0x8814, "Trio64UV+", NF },
- { 0x883D, "ViRGE/VX", NF },
- { 0x8880, "868", NF },
- { 0x88B0, "928", NF },
- { 0x88C0, "864-0", NF },
- { 0x88C1, "864-1", NF },
- { 0x88D0, "964-0", NF },
- { 0x88D1, "964-1", NF },
- { 0x88F0, "968", NF },
- { 0x8901, "Trio64V2/DX or /GX", NF },
- { 0x8902, "PLATO/PX", NF },
- { 0x8A01, "ViRGE/DX or /GX", NF },
- { 0x8A10, "ViRGE/GX2", NF },
- { 0x8C01, "ViRGE/MX", NF },
- { 0x8C02, "ViRGE/MX+", NF },
- { 0x8C03, "ViRGE/MX+MV", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x8086, "Intel", {
- { 0x0482, "82375EB pci-eisa bridge", NF },
- { 0x0483, "82424ZX cache dram controller", NF },
- { 0x0484, "82378IB/ZB pci-isa bridge", NF },
- { 0x0486, "82430ZX Aries", NF },
- { 0x04A3, "82434LX/NX pci cache mem controller", NF },
- { 0x1230, "82371 bus-master IDE controller", NF },
- { 0x1223, "SAA7116", NF },
- { 0x1229, "82557 10/100MBit network controller",NF},
- { 0x122D, "82437 Triton", NF },
- { 0x122E, "82471 Triton", NF },
- { 0x1230, "82438", NF },
- { 0x1250, "82439", NF },
- { 0x7000, "82371 pci-isa bridge", NF },
- { 0x7010, "82371 bus-master IDE controller", NF },
- { 0x7100, "82439 TX", NF },
- { 0x7110, "82371AB PIIX4 ISA", NF },
- { 0x7111, "82371AB PIIX4 IDE", NF },
- { 0x7112, "82371AB PIIX4 USB", NF },
- { 0x7113, "82371AB PIIX4 ACPI", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x9004, "Adaptec", {
- { 0x5078, "7850", NF },
- { 0x5578, "7855", NF },
- { 0x6078, "7860", NF },
- { 0x7078, "294x", NF },
- { 0x7178, "2940", NF },
- { 0x7278, "7872", NF },
- { 0x7478, "2944", NF },
- { 0x8178, "2940U", NF },
- { 0x8278, "3940U", NF },
- { 0x8478, "2944U", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x907F, "Atronics", {
- { 0x2015, "IDE-2015PL", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0xEDD8, "ARK Logic", {
- { 0xA091, "1000PV", NF },
- { 0xA099, "2000PV", NF },
- { 0xA0A1, "2000MT", NF },
- { 0xA0A9, "2000MI", NF },
- { 0x0000, (char *)NULL, NF } } },
- { 0x0000, (char *)NULL, {
- { 0x0000, (char *)NULL, NF } } }
-};
-
-#if defined(__alpha__)
-#define PCI_EN 0x00000000
-#else
-#define PCI_EN 0x80000000
-#endif
-
-#define PCI_MODE1_ADDRESS_REG 0xCF8
-#define PCI_MODE1_DATA_REG 0xCFC
-
-#define PCI_MODE2_ENABLE_REG 0xCF8
-#ifdef PC98
-#define PCI_MODE2_FORWARD_REG 0xCF9
-#else
-#define PCI_MODE2_FORWARD_REG 0xCFA
-#endif
-
-
-main(int argc, unsigned char *argv[])
-{
- unsigned long tmplong1, tmplong2, config_cmd;
- unsigned char tmp1, tmp2;
- unsigned int idx;
- struct pci_config_reg pcr;
- int ch, verbose = 0, do_mode1_scan = 0, do_mode2_scan = 0;
- int func;
-
- while((ch = getopt(argc, argv, "v12")) != EOF) {
- switch((char)ch) {
- case '1':
- do_mode1_scan = 1;
- break;
- case '2':
- do_mode2_scan = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- default :
- printf("Usage: %s [-v12] \n", argv[0]);
- exit(1);
- }
}
-#if !defined(MSDOS)
- if (getuid()) {
- printf("This program must be run as root\n");
- exit(1);
- }
-#endif
-
- enable_os_io();
-
-#if !defined(__alpha__) && !defined(__powerpc__)
- pcr._configtype = 0;
-
- outb(PCI_MODE2_ENABLE_REG, 0x00);
- outb(PCI_MODE2_FORWARD_REG, 0x00);
- tmp1 = inb(PCI_MODE2_ENABLE_REG);
- tmp2 = inb(PCI_MODE2_FORWARD_REG);
- if ((tmp1 == 0x00) && (tmp2 == 0x00)) {
- pcr._configtype = 2;
- printf("PCI says configuration type 2\n");
- } else {
- tmplong1 = inl(PCI_MODE1_ADDRESS_REG);
- outl(PCI_MODE1_ADDRESS_REG, PCI_EN);
- tmplong2 = inl(PCI_MODE1_ADDRESS_REG);
- outl(PCI_MODE1_ADDRESS_REG, tmplong1);
- if (tmplong2 == PCI_EN) {
- pcr._configtype = 1;
- printf("PCI says configuration type 1\n");
+ if ((pcr->pci_base2) && ((pcr->pci_base1 & 0x7) != 0x4)) {
+ if ((pcr->pci_base2 & 0x7) == 0x4) {
+ printf(" BASE2 0x%08x%08x addr 0x%08x%08x MEM%s 64BIT\n",
+ (int)pcr->pci_base3, (int)pcr->pci_base2,
+ (int)pcr->pci_base3,
+ (int)(pcr->pci_base2 &
+ (pcr->pci_base2 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base2 & 0x8) ? " PREFETCHABLE" :"");
} else {
- printf("No PCI !\n");
- disable_os_io();
- exit(1);
+ printf(" BASE2 0x%08x addr 0x%08x %s%s\n",
+ (int)pcr->pci_base2,
+ (int)(pcr->pci_base2 &
+ (pcr->pci_base2 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base2 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base2 & 0x9) == 0x8) ? " PREFETCHABLE" :"");
}
}
-#else
- pcr._configtype = 1;
-#endif
-
- /* Try pci config 1 probe first */
-
- if ((pcr._configtype == 1) || do_mode1_scan) {
- printf("\nPCI probing configuration type 1\n");
-
- pcr._ioaddr = 0xFFFF;
-
- pcr._pcibuses[0] = 0;
- pcr._pcinumbus = 1;
- pcr._pcibusidx = 0;
- idx = 0;
-
- do {
- printf("Probing for devices on PCI bus %d:\n\n", pcr._pcibusidx);
-
- for (pcr._cardnum = 0x0; pcr._cardnum < MAX_DEV_PER_VENDOR_CFG1;
- pcr._cardnum += 0x1) {
- func = 0;
- do { /* loop over the different functions, if present */
-#if !defined(__alpha__) && !defined(__powerpc__)
- config_cmd = PCI_EN | (pcr._pcibuses[pcr._pcibusidx]<<16) |
- (pcr._cardnum<<11) | (func<<8);
-
- outl(PCI_MODE1_ADDRESS_REG, config_cmd); /* ioreg 0 */
- pcr._device_vendor = inl(PCI_MODE1_DATA_REG);
-#else
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_ID_REG, 4, &pcr._device_vendor);
-#endif
-
- if ((pcr._vendor == 0xFFFF) || (pcr._device == 0xFFFF))
- break; /* nothing there */
-
- printf("\npci bus 0x%x cardnum 0x%02x function 0x%04x: vendor 0x%04x device 0x%04x\n",
- pcr._pcibuses[pcr._pcibusidx], pcr._cardnum, func,
- pcr._vendor, pcr._device);
-
-#if !defined(__alpha__) && !defined(__powerpc__)
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x04);
- pcr._status_command = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x08);
- pcr._class_revision = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x0C);
- pcr._bist_header_latency_cache = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x10);
- pcr._base0 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x14);
- pcr._base1 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x18);
- pcr._base2 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x1C);
- pcr._base3 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x20);
- pcr._base4 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x24);
- pcr._base5 = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x30);
- pcr._baserom = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x3C);
- pcr._max_min_ipin_iline = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x40);
- pcr._user_config = inl(PCI_MODE1_DATA_REG);
-#else
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_CMD_STAT_REG, 4, &pcr._status_command);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_CLASS_REG, 4, &pcr._class_revision);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_HEADER_MISC, 4, &pcr._bist_header_latency_cache);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START, 4, &pcr._base0);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START + 0x04, 4, &pcr._base1);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START + 0x08, 4, &pcr._base2);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START + 0x0C, 4, &pcr._base3);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START + 0x10, 4, &pcr._base4);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_REG_START + 0x14, 4, &pcr._base5);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_MAP_ROM_REG, 4, &pcr._baserom);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_INTERRUPT_REG, 4, &pcr._max_min_ipin_iline);
- pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3,
- PCI_REG_USERCONFIG, 4, &pcr._user_config);
-#endif
-
- /* check for pci-pci bridges */
-#define PCI_CLASS_MASK 0xff000000
-#define PCI_SUBCLASS_MASK 0x00ff0000
-#define PCI_CLASS_BRIDGE 0x06000000
-#define PCI_SUBCLASS_BRIDGE_PCI 0x00040000
- switch(pcr._class_revision & (PCI_CLASS_MASK|PCI_SUBCLASS_MASK)) {
- case PCI_CLASS_BRIDGE|PCI_SUBCLASS_BRIDGE_PCI:
- if (pcr._secondary_bus_number > 0) {
- pcr._pcibuses[pcr._pcinumbus++] = pcr._secondary_bus_number;
- }
- break;
- default:
- break;
- }
- if((func==0) && ((pcr._header_type & PCI_MULTIFUNC_DEV) == 0)) {
- /* not a multi function device */
- func = 8;
- } else {
- func++;
- }
-
- if (idx++ >= MAX_PCI_DEVICES)
- continue;
-
- identify_card(&pcr, verbose);
- } while( func < 8 );
- }
- } while (++pcr._pcibusidx < pcr._pcinumbus);
+ if ((pcr->pci_base3) && ((pcr->pci_base2 & 0x7) != 0x4)) {
+ if ((pcr->pci_base3 & 0x7) == 0x4) {
+ printf(" BASE3 0x%08x%08x addr 0x%08x%08x MEM%s 64BIT\n",
+ (int)pcr->pci_base4, (int)pcr->pci_base3,
+ (int)pcr->pci_base4,
+ (int)(pcr->pci_base3 &
+ (pcr->pci_base3 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base3 & 0x8) ? " PREFETCHABLE" :"");
+ } else {
+ printf(" BASE3 0x%08x addr 0x%08x %s%s\n",
+ (int)pcr->pci_base3,
+ (int)(pcr->pci_base3 &
+ (pcr->pci_base3 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base3 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base3 & 0x9) == 0x8) ? " PREFETCHABLE" :"");
+ }
}
-
-#if !defined(__alpha__) && !defined(__powerpc__)
- /* Now try pci config 2 probe (deprecated) */
-
- if ((pcr._configtype == 2) || do_mode2_scan) {
- outb(PCI_MODE2_ENABLE_REG, 0xF1);
- outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */
-
- printf("\nPCI probing configuration type 2\n");
-
- pcr._pcibuses[0] = 0;
- pcr._pcinumbus = 1;
- pcr._pcibusidx = 0;
- idx = 0;
-
- do {
- for (pcr._ioaddr = 0xC000; pcr._ioaddr < 0xD000; pcr._ioaddr += 0x0100){
- outb(PCI_MODE2_FORWARD_REG, pcr._pcibuses[pcr._pcibusidx]); /* bus 0 for now */
- pcr._device_vendor = inl(pcr._ioaddr);
- outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */
-
- if ((pcr._vendor == 0xFFFF) || (pcr._device == 0xFFFF))
- continue;
- if ((pcr._vendor == 0xF0F0) || (pcr._device == 0xF0F0))
- continue; /* catch ASUS P55TP4XE motherboards */
-
- printf("\npci bus 0x%x slot at 0x%04x, vendor 0x%04x device 0x%04x\n",
- pcr._pcibuses[pcr._pcibusidx], pcr._ioaddr, pcr._vendor,
- pcr._device);
-
- outb(PCI_MODE2_FORWARD_REG, pcr._pcibuses[pcr._pcibusidx]); /* bus 0 for now */
- pcr._status_command = inl(pcr._ioaddr + 0x04);
- pcr._class_revision = inl(pcr._ioaddr + 0x08);
- pcr._bist_header_latency_cache = inl(pcr._ioaddr + 0x0C);
- pcr._base0 = inl(pcr._ioaddr + 0x10);
- pcr._base1 = inl(pcr._ioaddr + 0x14);
- pcr._base2 = inl(pcr._ioaddr + 0x18);
- pcr._base3 = inl(pcr._ioaddr + 0x1C);
- pcr._base4 = inl(pcr._ioaddr + 0x20);
- pcr._base5 = inl(pcr._ioaddr + 0x24);
- pcr._baserom = inl(pcr._ioaddr + 0x30);
- pcr._max_min_ipin_iline = inl(pcr._ioaddr + 0x3C);
- pcr._user_config = inl(pcr._ioaddr + 0x40);
- outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */
-
- /* check for pci-pci bridges (currently we only know Digital) */
- if ((pcr._vendor == 0x1011) && (pcr._device == 0x0001))
- if (pcr._secondary_bus_number > 0)
- pcr._pcibuses[pcr._pcinumbus++] = pcr._secondary_bus_number;
-
- if (idx++ >= MAX_PCI_DEVICES)
- continue;
-
- identify_card(&pcr, verbose);
+ if ((pcr->pci_base4) && ((pcr->pci_base3 & 0x7) != 0x4)) {
+ if ((pcr->pci_base4 & 0x7) == 0x4) {
+ printf(" BASE4 0x%08x%08x addr 0x%08x%08x MEM%s 64BIT\n",
+ (int)pcr->pci_base5, (int)pcr->pci_base4,
+ (int)pcr->pci_base5,
+ (int)(pcr->pci_base4 &
+ (pcr->pci_base4 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base4 & 0x8) ? " PREFETCHABLE" :"");
+ } else {
+ printf(" BASE4 0x%08x addr 0x%08x %s%s\n",
+ (int)pcr->pci_base4,
+ (int)(pcr->pci_base4 &
+ (pcr->pci_base4 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base4 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base4 & 0x9) == 0x8) ? " PREFETCHABLE" :"");
}
- } while (++pcr._pcibusidx < pcr._pcinumbus);
-
- outb(PCI_MODE2_ENABLE_REG, 0x00);
}
-
-#endif /* __alpha__ */
-
- disable_os_io();
+ if ((pcr->pci_base5) && ((pcr->pci_base4 & 0x7) != 0x4)) {
+ printf(" BASE5 0x%08x addr 0x%08x %s%s%s\n",
+ (int)pcr->pci_base5,
+ (int)(pcr->pci_base5 &
+ (pcr->pci_base5 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)),
+ (pcr->pci_base5 & 0x1) ? "I/O" : "MEM",
+ ((pcr->pci_base5 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base5 & 0x7) == 0x4) ? " 64BIT" : "");
+ }
+ if (pcr->pci_baserom)
+ printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n",
+ (int)pcr->pci_baserom, (int)(pcr->pci_baserom & 0xFFFF8000),
+ pcr->pci_baserom & 0x1 ? "" : "not-");
+ if (pcr->pci_max_min_ipin_iline)
+ printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x"
+ " INT_PIN 0x%02x INT_LINE 0x%02x\n",
+ pcr->pci_max_lat, pcr->pci_min_gnt,
+ pcr->pci_int_pin, pcr->pci_int_line);
+ if (pcr->pci_user_config)
+ printf(" BYTE_0 0x%02x BYTE_1 0x%02x"
+ " BYTE_2 0x%02x BYTE_3 0x%02x\n",
+ (int)pcr->pci_user_config_0, (int)pcr->pci_user_config_1,
+ (int)pcr->pci_user_config_2, (int)pcr->pci_user_config_3);
}
+#define PCI_B_FAST_B_B 0x80
+#define PCI_B_SB_RESET 0x40
+#define PCI_B_M_ABORT 0x20
+#define PCI_B_VGA_EN 0x08
+#define PCI_B_ISA_EN 0x04
+#define PCI_B_SERR_EN 0x02
+#define PCI_B_P_ERR 0x01
-void
-identify_card(struct pci_config_reg *pcr, int verbose)
+static void
+print_bridge_pci_class(pciConfigPtr pcr)
{
-
- int i = 0, j, foundit = 0;
-
- while (pvd[i].vendorname != (char *)NULL) {
- if (pvd[i].vendor_id == pcr->_vendor) {
- j = 0;
- printf(" %s ", pvd[i].vendorname);
- while (pvd[i].device[j].devicename != (char *)NULL) {
- if (pvd[i].device[j].device_id == pcr->_device) {
- printf("%s", pvd[i].device[j].devicename);
- foundit = 1;
- break;
- }
- j++;
- }
- }
- if (foundit)
- break;
- i++;
+ printf(" HEADER 0x%02x LATENCY 0x%02x\n",
+ pcr->pci_header_type, pcr->pci_latency_timer);
+ printf(" PRIBUS 0x%02x SECBUS 0x%02x SUBBUS 0x%02x\n",
+ pcr->pci_primary_bus_number, pcr->pci_secondary_bus_number,
+ pcr->pci_subordinate_bus_number);
+ printf(" SECLT 0x%02x SECSTATUS 0x%04x\n",
+ pcr->pci_secondary_latency_timer, pcr->pci_secondary_status);
+
+ if (pcr->pci_io_base || pcr->pci_io_limit ||
+ pcr->pci_upper_io_base || pcr->pci_upper_io_limit) {
+ if (((pcr->pci_io_base & 0x0f) == 0x01) ||
+ ((pcr->pci_io_limit & 0x0f) == 0x01)) {
+ printf(" IOBASE 0x%04x%04x IOLIM 0x%04x%04x\n",
+ pcr->pci_upper_io_base, (pcr->pci_io_base & 0x00f0) << 8,
+ pcr->pci_upper_io_limit, (pcr->pci_io_limit << 8) | 0x0fff);
+ } else {
+ printf(" IOBASE 0x%04x IOLIM 0x%04x\n",
+ (pcr->pci_io_base & 0x00f0) << 8,
+ (pcr->pci_io_limit << 8) | 0x0fff);
}
+ }
- if (!foundit)
- printf(" Device unknown\n");
- else {
- printf("\n");
- if (verbose) {
- if (pvd[i].device[j].print_func != (void (*)())NULL) {
- pvd[i].device[j].print_func(pcr);
- return;
- }
- }
+ if (pcr->pci_mem_base || pcr->pci_mem_limit)
+ printf(" NOPREFETCH_MEMBASE 0x%08x MEMLIM 0x%08x\n",
+ (pcr->pci_mem_base & 0x00fff0) << 16,
+ (pcr->pci_mem_limit << 16) | 0x0fffff);
+
+ if (pcr->pci_prefetch_mem_base || pcr->pci_prefetch_mem_limit ||
+ pcr->pci_prefetch_upper_mem_base ||
+ pcr->pci_prefetch_upper_mem_limit) {
+ if (((pcr->pci_prefetch_mem_base & 0x0f) == 0x01) ||
+ ((pcr->pci_prefetch_mem_limit & 0x0f) == 0x01)) {
+ printf(" PREFETCH_MEMBASE 0x%08x%08x MEMLIM 0x%08x%08x\n",
+ (int)pcr->pci_prefetch_upper_mem_base,
+ (pcr->pci_prefetch_mem_base & 0x00fff0) << 16,
+ (int)pcr->pci_prefetch_upper_mem_limit,
+ (pcr->pci_prefetch_mem_limit << 16) | 0x0fffff);
+ } else {
+ printf(" PREFETCH_MEMBASE 0x%08x MEMLIM 0x%08x\n",
+ (pcr->pci_prefetch_mem_base & 0x00fff0) << 16,
+ (pcr->pci_prefetch_mem_limit << 16) | 0x0fffff);
}
+ }
- if (verbose) {
- if (pcr->_status_command)
- printf(" STATUS 0x%04x COMMAND 0x%04x\n",
- pcr->_status, pcr->_command);
- if (pcr->_class_revision)
- printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
- pcr->_base_class, pcr->_sub_class, pcr->_prog_if,
- pcr->_rev_id);
- if (pcr->_bist_header_latency_cache)
- printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
- pcr->_bist, pcr->_header_type, pcr->_latency_timer,
- pcr->_cache_line_size);
- if (pcr->_base0)
- printf(" BASE0 0x%08x addr 0x%08x %s\n",
- pcr->_base0, pcr->_base0 & (pcr->_base0 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base0 & 0x1 ? "I/O" : "MEM");
- if (pcr->_base1)
- printf(" BASE1 0x%08x addr 0x%08x %s\n",
- pcr->_base1, pcr->_base1 & (pcr->_base1 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base1 & 0x1 ? "I/O" : "MEM");
- if (pcr->_base2)
- printf(" BASE2 0x%08x addr 0x%08x %s\n",
- pcr->_base2, pcr->_base2 & (pcr->_base2 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base2 & 0x1 ? "I/O" : "MEM");
- if (pcr->_base3)
- printf(" BASE3 0x%08x addr 0x%08x %s\n",
- pcr->_base3, pcr->_base3 & (pcr->_base3 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base3 & 0x1 ? "I/O" : "MEM");
- if (pcr->_base4)
- printf(" BASE4 0x%08x addr 0x%08x %s\n",
- pcr->_base4, pcr->_base4 & (pcr->_base4 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base4 & 0x1 ? "I/O" : "MEM");
- if (pcr->_base5)
- printf(" BASE5 0x%08x addr 0x%08x %s\n",
- pcr->_base5, pcr->_base5 & (pcr->_base5 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0),
- pcr->_base5 & 0x1 ? "I/O" : "MEM");
- if (pcr->_baserom)
- printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n",
- pcr->_baserom, pcr->_baserom & 0xFFFF8000,
- pcr->_baserom & 0x1 ? "" : "not-");
- if (pcr->_max_min_ipin_iline)
- printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n",
- pcr->_max_lat, pcr->_min_gnt,
- pcr->_int_pin, pcr->_int_line);
- if (pcr->_user_config)
- printf(" BYTE_0 0x%02x BYTE_1 0x%02x BYTE_2 0x%02x BYTE_3 0x%02x\n",
- pcr->_user_config_0, pcr->_user_config_1,
- pcr->_user_config_2, pcr->_user_config_3);
- }
+ printf(" %sFAST_B2B %sSEC_BUS_RST %sM_ABRT %sVGA_EN %sISA_EN"
+ " %sSERR_EN %sPERR_EN\n",
+ (pcr->pci_bridge_control & PCI_B_FAST_B_B) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_SB_RESET) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_M_ABORT) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_VGA_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_ISA_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_SERR_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_P_ERR) ? "" : "NO_");
}
-
-void
-print_mach64(struct pci_config_reg *pcr)
+static void
+print_mach64(pciConfigPtr pcr)
{
- unsigned long sparse_io = 0;
-
- if (pcr->_status_command)
- printf(" STATUS 0x%04x COMMAND 0x%04x\n",
- pcr->_status, pcr->_command);
- if (pcr->_class_revision)
- printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
- pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id);
- if (pcr->_bist_header_latency_cache)
- printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
- pcr->_bist, pcr->_header_type, pcr->_latency_timer,
- pcr->_cache_line_size);
- if (pcr->_base0)
- printf(" APBASE 0x%08x addr 0x%08x\n",
- pcr->_base0, pcr->_base0 & (pcr->_base0 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0));
- if (pcr->_base1)
- printf(" BLOCKIO 0x%08x addr 0x%08x\n",
- pcr->_base1, pcr->_base1 & (pcr->_base1 & 0x1 ?
- 0xFFFFFFFC : 0xFFFFFFF0));
- if (pcr->_baserom)
- printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n",
- pcr->_baserom, pcr->_baserom & 0xFFFF8000,
- pcr->_baserom & 0x1 ? "" : "not-");
- if (pcr->_max_min_ipin_iline)
- printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n",
- pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line);
- switch (pcr->_user_config_0 & 0x03) {
+ CARD32 sparse_io = 0;
+
+ printf(" CardVendor 0x%04x card 0x%04x\n",
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card);
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class,
+ pcr->pci_prog_if, pcr->pci_rev_id);
+ printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
+ pcr->pci_bist, pcr->pci_header_type, pcr->pci_latency_timer,
+ pcr->pci_cache_line_size);
+ if (pcr->pci_base0)
+ printf(" APBASE 0x%08x addr 0x%08x\n",
+ (int)pcr->pci_base0, (int)(pcr->pci_base0 &
+ (pcr->pci_base0 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)));
+ if (pcr->pci_base1)
+ printf(" BLOCKIO 0x%08x addr 0x%08x\n",
+ (int)pcr->pci_base1, (int)(pcr->pci_base1 &
+ (pcr->pci_base1 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)));
+ if (pcr->pci_base2)
+ printf(" REGBASE 0x%08x addr 0x%08x\n",
+ (int)pcr->pci_base2, (int)(pcr->pci_base2 &
+ (pcr->pci_base2 & 0x1 ? 0xFFFFFFFC : 0xFFFFFFF0)));
+ if (pcr->pci_baserom)
+ printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n",
+ (int)pcr->pci_baserom, (int)(pcr->pci_baserom & 0xFFFF8000),
+ pcr->pci_baserom & 0x1 ? "" : "not-");
+ if (pcr->pci_max_min_ipin_iline)
+ printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x"
+ " INT_PIN 0x%02x INT_LINE 0x%02x\n",
+ pcr->pci_max_lat, pcr->pci_min_gnt,
+ pcr->pci_int_pin, pcr->pci_int_line);
+ switch (pcr->pci_user_config_0 & 0x03) {
case 0:
sparse_io = 0x2ec;
break;
@@ -1560,231 +532,248 @@ print_mach64(struct pci_config_reg *pcr)
sparse_io = 0x1c8;
break;
}
- printf(" SPARSEIO 0x%03x %s %s\n",
- sparse_io, pcr->_user_config_0 & 0x04 ? "Block IO enabled" :
- "Sparse IO enabled",
- pcr->_user_config_0 & 0x08 ? "Disable 0x46E8" : "Enable 0x46E8");
+ printf(" SPARSEIO 0x%03x %s IO enabled %sable 0x46E8\n",
+ (int)sparse_io, pcr->pci_user_config_0 & 0x04 ? "Block" : "Sparse",
+ pcr->pci_user_config_0 & 0x08 ? "Dis" : "En");
}
-void
-print_i128(struct pci_config_reg *pcr)
+static void
+print_i128(pciConfigPtr pcr)
{
- if (pcr->_status_command)
- printf(" STATUS 0x%04x COMMAND 0x%04x\n",
- pcr->_status, pcr->_command);
- if (pcr->_class_revision)
- printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
- pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id);
- if (pcr->_bist_header_latency_cache)
- printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
- pcr->_bist, pcr->_header_type, pcr->_latency_timer,
- pcr->_cache_line_size);
+ printf(" CardVendor 0x%04x card 0x%04x\n",
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card);
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+ printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
+ pcr->pci_bist, pcr->pci_header_type, pcr->pci_latency_timer,
+ pcr->pci_cache_line_size);
printf(" MW0_AD 0x%08x addr 0x%08x %spre-fetchable\n",
- pcr->_base0, pcr->_base0 & 0xFFC00000,
- pcr->_base0 & 0x8 ? "" : "not-");
+ (int)pcr->pci_base0, (int)(pcr->pci_base0 & 0xFFC00000),
+ pcr->pci_base0 & 0x8 ? "" : "not-");
printf(" MW1_AD 0x%08x addr 0x%08x %spre-fetchable\n",
- pcr->_base1, pcr->_base1 & 0xFFC00000,
- pcr->_base1 & 0x8 ? "" : "not-");
+ (int)pcr->pci_base1, (int)(pcr->pci_base1 & 0xFFC00000),
+ pcr->pci_base1 & 0x8 ? "" : "not-");
printf(" XYW_AD(A) 0x%08x addr 0x%08x\n",
- pcr->_base2, pcr->_base2 & 0xFFC00000);
+ (int)pcr->pci_base2, (int)(pcr->pci_base2 & 0xFFC00000));
printf(" XYW_AD(B) 0x%08x addr 0x%08x\n",
- pcr->_base3, pcr->_base3 & 0xFFC00000);
+ (int)pcr->pci_base3, (int)(pcr->pci_base3 & 0xFFC00000));
printf(" RBASE_G 0x%08x addr 0x%08x\n",
- pcr->_base4, pcr->_base4 & 0xFFFF0000);
+ (int)pcr->pci_base4, (int)(pcr->pci_base4 & 0xFFFF0000));
printf(" IO 0x%08x addr 0x%08x\n",
- pcr->_base5, pcr->_base5 & 0xFFFFFF00);
+ (int)pcr->pci_base5, (int)(pcr->pci_base5 & 0xFFFFFF00));
printf(" RBASE_E 0x%08x addr 0x%08x %sdecode-enabled\n",
- pcr->_baserom, pcr->_baserom & 0xFFFF8000,
- pcr->_baserom & 0x1 ? "" : "not-");
- if (pcr->_max_min_ipin_iline)
- printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n",
- pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line);
+ (int)pcr->pci_baserom, (int)(pcr->pci_baserom & 0xFFFF8000),
+ pcr->pci_baserom & 0x1 ? "" : "not-");
+ if (pcr->pci_max_min_ipin_iline)
+ printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x"
+ " INT_PIN 0x%02x INT_LINE 0x%02x\n",
+ pcr->pci_max_lat, pcr->pci_min_gnt,
+ pcr->pci_int_pin, pcr->pci_int_line);
}
-void
-print_pcibridge(struct pci_config_reg *pcr)
+static void
+print_dc21050(pciConfigPtr pcr)
{
- if (pcr->_status_command)
- printf(" STATUS 0x%04x COMMAND 0x%04x\n",
- pcr->_status, pcr->_command);
- if (pcr->_class_revision)
- printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
- pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id);
- if (pcr->_bist_header_latency_cache)
- printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
- pcr->_bist, pcr->_header_type, pcr->_latency_timer,
- pcr->_cache_line_size);
- printf(" PRIBUS 0x%02x SECBUS 0x%02x SUBBUS 0x%02x SECLT 0x%02x\n",
- pcr->_primary_bus_number, pcr->_secondary_bus_number,
- pcr->_subordinate_bus_number, pcr->_secondary_latency_timer);
- printf(" IOBASE: 0x%02x00 IOLIM 0x%02x00 SECSTATUS 0x%04x\n",
- pcr->_io_base, pcr->_io_limit, pcr->_secondary_status);
- printf(" NOPREFETCH MEMBASE: 0x%08x MEMLIM 0x%08x\n",
- pcr->_mem_base, pcr->_mem_limit);
- printf(" PREFETCH MEMBASE: 0x%08x MEMLIM 0x%08x\n",
- pcr->_prefetch_mem_base, pcr->_prefetch_mem_limit);
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+ printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
+ pcr->pci_bist, pcr->pci_header_type, pcr->pci_latency_timer,
+ pcr->pci_cache_line_size);
+ printf(" PRIBUS 0x%02x SECBUS 0x%02x SUBBUS 0x%02x SECLT 0x%02x\n",
+ pcr->pci_primary_bus_number, pcr->pci_secondary_bus_number,
+ pcr->pci_subordinate_bus_number, pcr->pci_secondary_latency_timer);
+ printf(" IOBASE 0x%02x IOLIM 0x%02x SECSTATUS 0x%04x\n",
+ pcr->pci_io_base << 8, (pcr->pci_io_limit << 8) | 0xfff,
+ pcr->pci_secondary_status);
+ printf(" NOPREFETCH_MEMBASE 0x%08x MEMLIM 0x%08x\n",
+ pcr->pci_mem_base << 16, (pcr->pci_mem_limit << 16) | 0xfffff);
+ printf(" PREFETCH_MEMBASE 0x%08x MEMLIM 0x%08x\n",
+ pcr->pci_prefetch_mem_base << 16,
+ (pcr->pci_prefetch_mem_limit << 16) | 0xfffff);
printf(" RBASE_E 0x%08x addr 0x%08x %sdecode-enabled\n",
- pcr->_baserom, pcr->_baserom & 0xFFFF8000,
- pcr->_baserom & 0x1 ? "" : "not-");
- if (pcr->_max_min_ipin_iline)
- printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n",
- pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line);
+ (int)pcr->pci_baserom, (int)(pcr->pci_baserom & 0xFFFF8000),
+ pcr->pci_baserom & 0x1 ? "" : "not-");
+ if (pcr->pci_max_min_ipin_iline)
+ printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x"
+ " INT_PIN 0x%02x INT_LINE 0x%02x\n",
+ pcr->pci_max_lat, pcr->pci_min_gnt,
+ pcr->pci_int_pin, pcr->pci_int_line);
}
-static int io_fd;
-#ifdef __EMX__
-USHORT callgate[3] = {0,0,0};
-#endif
-
-void
-enable_os_io()
+static void
+print_simba(pciConfigPtr pcr)
{
-#if defined(SVR4) || defined(SCO) || defined(ISC)
-#if defined(SI86IOPL)
- sysi86(SI86IOPL, 3);
-#else
- sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
-#endif
-#endif
-#if defined(linux)
- iopl(3);
-#endif
-#if defined(__FreeBSD__) || defined(__386BSD__) || defined(__bsdi__)
- if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) {
- perror("/dev/console");
- exit(1);
- }
-#if defined(__FreeBSD__) || defined(__386BSD__)
- if (ioctl(io_fd, KDENABIO, 0) < 0) {
- perror("ioctl(KDENABIO)");
- exit(1);
- }
-#endif
-#if defined(__bsdi__)
- if (ioctl(io_fd, PCCONENABIOPL, 0) < 0) {
- perror("ioctl(PCCONENABIOPL)");
- exit(1);
- }
-#endif
-#endif
-#if defined(__NetBSD__)
-#if !defined(USE_I386_IOPL)
- if ((io_fd = open("/dev/io", O_RDWR, 0)) < 0) {
- perror("/dev/io");
- exit(1);
- }
-#else
- if (i386_iopl(1) < 0) {
- perror("i386_iopl");
- exit(1);
- }
-#endif /* USE_I386_IOPL */
-#endif /* __NetBSD__ */
-#if defined(__OpenBSD__)
- if (i386_iopl(1) < 0) {
- perror("i386_iopl");
- exit(1);
- }
-#endif /* __OpenBSD__ */
-#if defined(MACH386)
- if ((io_fd = open("/dev/iopl", O_RDWR, 0)) < 0) {
- perror("/dev/iopl");
- exit(1);
- }
-#endif
-#ifdef __EMX__
- {
- HFILE hfd;
- ULONG dlen,action;
- APIRET rc;
- static char *ioDrvPath = "/dev/fastio$";
-
- if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
- (ULONG)0, FILE_SYSTEM, FILE_OPEN,
- OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
- (ULONG)0) != 0) {
- fprintf(stderr,"Error opening fastio$ driver...\n");
- fprintf(stderr,"Please install xf86sup.sys in config.sys!\n");
- exit(42);
- }
- callgate[0] = callgate[1] = 0;
-
-/* Get callgate from driver for fast io to ports and other stuff */
+ int i;
+ CARD8 io, mem;
+
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+ printf(" HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n",
+ pcr->pci_header_type, pcr->pci_latency_timer,
+ pcr->pci_cache_line_size);
+ printf(" PRIBUS 0x%02x SECBUS 0x%02x SUBBUS 0x%02x SECLT 0x%02x\n",
+ pcr->pci_primary_bus_number, pcr->pci_secondary_bus_number,
+ pcr->pci_subordinate_bus_number, pcr->pci_secondary_latency_timer);
+ printf(" SECSTATUS 0x%04x\n",
+ pcr->pci_secondary_status);
+ printf(" %sFAST_B2B %sSEC_BUS_RST %sM_ABRT %sVGA_EN %sISA_EN"
+ " %sSERR_EN %sPERR_EN\n",
+ (pcr->pci_bridge_control & PCI_B_FAST_B_B) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_SB_RESET) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_M_ABORT) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_VGA_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_ISA_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_SERR_EN) ? "" : "NO_",
+ (pcr->pci_bridge_control & PCI_B_P_ERR) ? "" : "NO_");
+ printf(" TICK 0x%08lx SECCNTL 0x%02x\n", (long)
+ pciReadLong(pcr->tag, 0x00b0), pciReadByte(pcr->tag, 0x00dd));
+ printf(" MASTER RETRIES: PRIMARY 0x%02x, SECONDARY 0x%02x\n",
+ pciReadByte(pcr->tag, 0x00c0), pciReadByte(pcr->tag, 0x00dc));
+ printf(" TARGET RETRIES: PIO 0x%02x, DMA 0x%02x\n",
+ pciReadByte(pcr->tag, 0x00d8), pciReadByte(pcr->tag, 0x00da));
+ printf(" TARGET LATENCY: PIO 0x%02x, DMA 0x%02x\n",
+ pciReadByte(pcr->tag, 0x00d9), pciReadByte(pcr->tag, 0x00db));
+ printf(" DMA AFSR 0x%08lx%08lx AFAR 0x%08lx%08lx\n",
+ (long)pciReadLong(pcr->tag, 0x00cc),
+ (long)pciReadLong(pcr->tag, 0x00c8),
+ (long)pciReadLong(pcr->tag, 0x00d4),
+ (long)pciReadLong(pcr->tag, 0x00d0));
+ printf(" PIO AFSR 0x%08lx%08lx AFAR 0x%08lx%08lx\n",
+ (long)pciReadLong(pcr->tag, 0x00ec),
+ (long)pciReadLong(pcr->tag, 0x00e8),
+ (long)pciReadLong(pcr->tag, 0x00f4),
+ (long)pciReadLong(pcr->tag, 0x00f0));
+ printf(" PCI CNTL 0x%08lx%08lx DIAG 0x%08lx%08lx\n",
+ (long)pciReadLong(pcr->tag, 0x00e4),
+ (long)pciReadLong(pcr->tag, 0x00e0),
+ (long)pciReadLong(pcr->tag, 0x00fc),
+ (long)pciReadLong(pcr->tag, 0x00f8));
+ printf(" MAPS: I/O 0x%02x, MEM 0x%02x\n",
+ (io = pciReadByte(pcr->tag, 0x00de)),
+ (mem = pciReadByte(pcr->tag, 0x00df)));
+ for (i = 0; i < 8; i++)
+ if (io & (1 << i))
+ printf(" BUS I/O 0x%06x-0x%06x\n", i << 21, ((i + 1) << 21) - 1);
+ for (i = 0; i < 8; i++)
+ if (mem & (1 << i))
+ printf(" BUS MEM 0x%08x-0x%08x\n", i << 29, ((i + 1) << 29) - 1);
+}
- rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
- NULL, 0, NULL,
- (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
- if (rc) {
- fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n",
- rc,dlen);
- DosClose(hfd);
- exit(42);
- }
+static int cbn_460gx = -1;
-/* Calling callgate with function 13 sets IOPL for the program */
+static void
+print_460gx_sac(pciConfigPtr pcr)
+{
+ CARD32 tmp;
+
+ /* Print generalities */
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+
+ tmp = pcr->pci_user_config;
+ pcr->pci_user_config = 0;
+ print_default_class(pcr);
+ pcr->pci_user_config = tmp;
+
+ /* Only print what XFree86 might be interested in */
+ if (pcr->busnum == 0) {
+ if ((pcr->devnum != 0x10) || (pcr->funcnum != 0))
+ return;
+
+ /* Get Chipset Bus Number */
+ cbn_460gx = (unsigned int)pciReadByte(pcr->tag, 0x0040);
+ printf(" CBN 0x%02x CBUSES 0x%02x\n",
+ cbn_460gx, pciReadByte(pcr->tag, 0x0044));
+
+ return;
+ }
- asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate"
- : /*no outputs */
- : /*no inputs */
- : "eax","ebx","ecx","edx","cc");
+ if ((pcr->busnum != cbn_460gx) || (pcr->funcnum != 0))
+ return;
- DosClose(hfd);
- }
-#endif
-#if defined(Lynx) && defined(__powerpc__)
- pciConfBase = (unsigned char *) smem_create("PCI-CONF",
- (char *)0x80800000, 64*1024, SM_READ|SM_WRITE);
- if (pciConfBase == (void *) -1)
- exit(1);
-#endif
+ switch (pcr->devnum) {
+ case 0:
+ printf(" F16NUM 0x%02x F16CPL 0x%02x DEVNPRES 0x%08lx\n",
+ pciReadByte(pcr->tag, 0x0060), pciReadByte(pcr->tag, 0x0078),
+ (long)pciReadLong(pcr->tag, 0x0070));
+
+ return;
+
+ case 0x10:
+ printf(" TOM 0x%04x IORD 0x%04x\n",
+ pciReadWord(pcr->tag, 0x0050), pciReadWord(pcr->tag, 0x008E));
+ /* Fall through */
+
+ case 0x11: case 0x12: case 0x13:
+ case 0x14: case 0x15: case 0x16: case 0x17:
+ printf(" BUSNO 0x%02x SUBNO 0x%02x\n",
+ pciReadByte(pcr->tag, 0x0048), pciReadByte(pcr->tag, 0x0049));
+ printf(" VGASE 0x%02x PCIS 0x%02x IOR 0x%02x\n",
+ pciReadByte(pcr->tag, 0x0080), pciReadByte(pcr->tag, 0x0084),
+ pciReadByte(pcr->tag, 0x008C));
+ /* Fall through */
+
+ default:
+ return;
+ }
}
+static void
+print_460gx_pxb(pciConfigPtr pcr)
+{
+ CARD32 tmp;
+
+ /* Print generalities */
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+
+ tmp = pcr->pci_user_config;
+ pcr->pci_user_config = 0;
+ print_default_class(pcr);
+ pcr->pci_user_config = tmp;
+
+ /* Only print what XFree86 might be interested in */
+ printf(" ERRCMD 0x%02x GAPEN 0x%02x\n",
+ pciReadByte(pcr->tag, 0x0046), pciReadByte(pcr->tag, 0x0060));
+}
-void
-disable_os_io()
+static void
+print_460gx_gxb(pciConfigPtr pcr)
{
-#if defined(SVR4) || defined(SCO) || defined(ISC)
-#if defined(SI86IOPL)
- sysi86(SI86IOPL, 0);
-#else
- sysi86(SI86V86, V86SC_IOPL, 0);
-#endif
-#endif
-#if defined(linux)
- iopl(0);
-#endif
-#if defined(__FreeBSD__) || defined(__386BSD__)
- if (ioctl(io_fd, KDDISABIO, 0) < 0) {
- perror("ioctl(KDDISABIO)");
- close(io_fd);
- exit(1);
- }
- close(io_fd);
-#endif
-#if defined(__NetBSD__)
-#if !defined(USE_I386_IOPL)
- close(io_fd);
-#else
- if (i386_iopl(0) < 0) {
- perror("i386_iopl");
- exit(1);
- }
-#endif /* NetBSD1_1 */
-#endif /* __NetBSD__ */
-#if defined(__bsdi__)
- if (ioctl(io_fd, PCCONDISABIOPL, 0) < 0) {
- perror("ioctl(PCCONDISABIOPL)");
- close(io_fd);
- exit(1);
- }
- close(io_fd);
-#endif
-#if defined(MACH386)
- close(io_fd);
-#endif
-#if defined(Lynx) && defined(__powerpc__)
- smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH);
- smem_remove("PCI-CONF");
- pciConfBase = NULL;
-#endif
+ CARD32 tmp;
+
+ /* Print generalities */
+ printf(" STATUS 0x%04x COMMAND 0x%04x\n",
+ pcr->pci_status, pcr->pci_command);
+ printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n",
+ pcr->pci_base_class, pcr->pci_sub_class, pcr->pci_prog_if,
+ pcr->pci_rev_id);
+
+ tmp = pcr->pci_user_config;
+ pcr->pci_user_config = 0;
+ print_default_class(pcr);
+ pcr->pci_user_config = tmp;
+
+ /* Only print what XFree86 might be interested in */
+ printf(" BAPBASE 0x%08lx%08lx AGPSIZ 0x%02x VGAGE 0x%02x\n",
+ (long)pciReadLong(pcr->tag, 0x009C),
+ (long)pciReadLong(pcr->tag, 0x0098),
+ pciReadByte(pcr->tag, 0x00A2), pciReadByte(pcr->tag, 0x0060));
}
+
+#include "xf86getpagesize.c"
diff --git a/hw/xfree86/utils/xorgconfig/Cards b/hw/xfree86/utils/xorgconfig/Cards
index 0412fdd61..83d8840ea 100644
--- a/hw/xfree86/utils/xorgconfig/Cards
+++ b/hw/xfree86/utils/xorgconfig/Cards
@@ -1,4 +1,4 @@
-# $Xorg: Cards,v 1.3 2000/08/17 19:53:04 cpqbld Exp $
+# $XConsortium: Cards /main/27 1996/10/28 05:43:53 kaleb $
# This is the database of card definitions used by xf86config.
# Each definition should have a NAME entry, CHIPSET (descriptive) and
# SERVER (one of Mono, VGA16, SVGA, S3, 8514, Mach8, Mach32, Mach64, AGX,
@@ -18,7 +18,228 @@
# The majority of entries are just a binding of a model name to a
# chipset/server and untested.
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.51.2.15 1998/02/27 15:28:57 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.80 2002/11/18 05:24:19 paulo Exp $
+
+# VGA
+
+NAME * Generic VGA compatible
+SERVER VGA16
+DRIVER vga
+
+NAME * Generic VESA compatible
+SERVER VGA16
+DRIVER vesa
+
+NAME * Unsupported VGA compatible
+SERVER VGA16
+DRIVER vga
+UNSUPPORTED
+
+
+# #
+# generic #
+# #
+
+NAME ** Alliance Pro Motion (generic) [apm]
+#CHIPSET apm
+SERVER SVGA
+DRIVER apm
+LINE #Option "no_accel"
+
+NAME ** Ark Logic (generic) [ark]
+#CHIPSET ark
+SERVER SVGA
+DRIVER ark
+
+NAME ** ATI (generic) [ati]
+#CHIPSET ati
+SERVER SVGA
+DRIVER ati
+
+NAME ** ATI Rage 128 based (generic) [r128]
+#CHIPSET r128
+SERVER SVGA
+DRIVER r128
+
+NAME ** ATI Radeon (generic) [radeon]
+#CHIPSET radeon
+SERVER SVGA
+DRIVER radeon
+
+NAME ** Chips and Technologies (generic) [chips]
+#CHIPSET chips
+SERVER SVGA
+DRIVER chips
+LINE # Option "suspend_hack"
+LINE # Option "STN"
+LINE # Option "no_stretch"
+LINE # Option "no_center"
+LINE # Option "use_modeline"
+LINE # Option "fix_panel_size"
+LINE # videoram 512
+LINE # Option "noaccel"
+LINE # Option "no_bitblt"
+LINE # Option "xaa_no_color_exp"
+LINE # Option "xaa_benchmark"
+LINE # Option "hw_cursor"
+LINE # Option "nolinear"
+LINE # MemBase 0x03b00000
+LINE # Option "hw_clocks"
+LINE # Textclockfreq 25.175
+
+NAME ** Cirrus Logic (generic) [cirrus]
+#CHIPSET cirrus
+SERVER SVGA
+DRIVER cirrus
+LINE # MemBase 0x00e00000 # ISA card that maps to 14Mb
+LINE # MemBase 0x04000000 # VLB card that maps to 64Mb
+LINE # MemBase 0x80000000 # VLB card that maps to 2048Mb
+LINE # MemBase 0x02000000 # VLB card that maps to 32Mb
+LINE # Option "linear"
+LINE # Option "fifo_conservative"
+
+NAME ** Cyrix MediaGX (generic) [cyrix]
+#CHIPSET cyrix
+SERVER SVGA
+DRIVER cyrix
+
+NAME ** Linux framebuffer (generic) [fbdev]
+#CHIPSET fbdev
+SERVER SVGA
+DRIVER fbdev
+
+NAME ** 3DLabs, TI (generic) [glint]
+#CHIPSET glint
+SERVER SVGA
+DRIVER glint
+LINE #Option "no_accel"
+
+NAME ** Number Nine I128 (generic) [i128]
+#CHIPSET i128
+SERVER SVGA
+DRIVER i128
+
+NAME ** Intel i740 (generic) [i740]
+#CHIPSET i740
+SERVER SVGA
+DRIVER i740
+
+NAME ** Intel i810 (generic) [i810]
+#CHIPSET i810
+SERVER SVGA
+DRIVER i810
+
+NAME ** Matrox Graphics (generic) [mga]
+#CHIPSET mga
+SERVER SVGA
+DRIVER mga
+LINE # Option "mga_sdram"
+
+NAME ** NeoMagic (generic) [neomagic]
+#CHIPSET neomagic
+SERVER SVGA
+DRIVER neomagic
+LINE # Chipset "NM2160"
+LINE # IOBase 0xfea00000
+LINE # MemBase 0xfd000000
+LINE # VideoRam 2048
+LINE # DacSpeed 90
+LINE # Option "linear"
+LINE # Option "nolinear"
+LINE # Option "sw_cursor"
+LINE # Option "hw_cursor"
+LINE # Option "no_accel"
+LINE # Option "intern_disp"
+LINE # Option "extern_disp"
+LINE # Option "mmio"
+LINE # Option "no_mmio"
+LINE # Option "lcd_center"
+LINE # Option "no_stretch"
+
+NAME ** NVIDIA (generic) [nv]
+#CHIPSET nv
+SERVER SVGA
+DRIVER nv
+
+NAME ** Rendition (generic) [rendition]
+#CHIPSET rendition
+SERVER SVGA
+DRIVER rendition
+LINE # Option "sw_cursor"
+
+NAME ** S3 (not ViRGE or Savage) (generic) [s3]
+#CHIPSET s3
+SERVER SVGA
+DRIVER s3
+
+NAME ** S3 ViRGE (generic) [s3virge]
+#CHIPSET s3virge
+SERVER SVGA
+DRIVER s3virge
+LINE # Option "xaa_benchmark"
+LINE # Option "fifo_moderate"
+LINE # Option "pci_burst_on"
+LINE # Option "pci_retry"
+LINE # Option "lcd_center"
+LINE # Set_LCDClk <pixel_clock_for_LCD>
+
+NAME ** S3 Savage (generic) [savage]
+#CHIPSET savage
+SERVER SVGA
+DRIVER savage
+
+NAME ** Silicon Motion (generic) [siliconmotion]
+#CHIPSET siliconmotion
+SERVER SVGA
+DRIVER siliconmotion
+
+NAME ** SiS (generic) [sis]
+#CHIPSET sis
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel"
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+LINE # Option "no_BitBlt"
+LINE # Option "fast_vram"
+LINE # Option "pci_burst_on"
+LINE # Option "xaa_benchmark"
+LINE # Option "ext_eng_queue"
+
+NAME ** 3Dfx (generic) [tdfx]
+#CHIPSET tdfx
+SERVER SVGA
+DRIVER tdfx
+
+NAME ** DEC TGA (generic) [tga]
+#CHIPSET tga
+SERVER SVGA
+DRIVER tga
+
+NAME ** Trident (generic) [trident]
+#CHIPSET trident
+SERVER SVGA
+DRIVER trident
+
+NAME ** Tseng Labs (generic) [tseng]
+#CHIPSET tseng
+SERVER SVGA
+DRIVER tseng
+LINE # Option "linear"
+LINE # Option "noaccel"
+LINE # Option "power_saver"
+LINE # Option "fast_dram"
+LINE # Option "pci_retry"
+LINE # Option "hibit_high"
+LINE # Option "hibit_low"
+LINE # MemBase 0x3C00000
+
+NAME ** VMWare guest OS (generic) [vmware]
+#CHIPSET vmware
+SERVER SVGA
+DRIVER vmware
+
#Chips & Technologies
@@ -26,6 +247,7 @@
NAME Chips & Technologies CT65520
CHIPSET ct65520
SERVER SVGA
+DRIVER chips
LINE # Device section for C&T cards.
LINE # Option "suspend_hack"
LINE # Option "STN"
@@ -65,7 +287,7 @@ LINE # Option "noaccel"
LINE # Option "no_bitblt"
LINE # Option "xaa_no_color_exp"
LINE # Option "xaa_benchmark"
-LINE # Option "sw_cursor"
+LINE # Option "hw_cursor"
LINE # Option "mmio"
SEE Chips & Technologies CT65540
@@ -84,7 +306,7 @@ LINE # Option "noaccel"
LINE # Option "no_bitblt"
LINE # Option "xaa_no_color_exp"
LINE # Option "xaa_benchmark"
-LINE # Option "sw_cursor"
+LINE # Option "hw_cursor"
LINE # Option "sync_on_green"
LINE # Option "fast_dram"
LINE # Option "use_vclk1"
@@ -103,20 +325,30 @@ NAME Chips & Technologies CT68554
CHIPSET ct68554
SEE Chips & Technologies CT65550
+NAME Chips & Technologies CT69000
+CHIPSET ct69000
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT69030
+CHIPSET ct69030
+SEE Chips & Technologies CT65550
+
NAME Chips & Technologies CT64200
CHIPSET ct64200
SERVER SVGA
+DRIVER chips
LINE # Device section for C&T cards.
LINE # videoram 1024
NAME Chips & Technologies CT64300
CHIPSET ct64300
SERVER SVGA
+DRIVER chips
LINE # Option "noaccel"
LINE # Option "no_bitblt"
LINE # Option "xaa_no_color_exp"
LINE # Option "xaa_benchmark"
-LINE # Option "sw_cursor"
+LINE # Option "hw_cursor"
LINE # Option "nolinear"
LINE # MemBase 0x03b00000
LINE # Option "hw_clocks"
@@ -127,8 +359,9 @@ SEE Chips & Technologies CT64200
#tested
NAME Cirrus Logic GD542x
-CHIPSET CL-GD5420/2/4/6/8/9
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
LINE # Device section for Cirrus Logic GD5420/2/4/6/8/9-based cards.
LINE #MemBase 0x00e00000
@@ -137,8 +370,9 @@ LINE #Option "linear"
#tested
NAME Cirrus Logic GD543x
-CHIPSET CL-GD5430/5434
+CHIPSET CL-GD5430/5434/5436
SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
LINE # Device section for Cirrus Logic GD5430/34-based cards.
LINE #MemBase 0x00e00000 # ISA card that maps to 14Mb
@@ -150,6 +384,7 @@ LINE #Option "linear"
NAME Cirrus Logic GD544x
CHIPSET CL-GD544x
SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
NAME Creative Labs Graphics Blaster MA201
@@ -162,13 +397,25 @@ SEE Cirrus Logic GD544x
NAME Cirrus Logic GD5462
CHIPSET CL-GD5462
SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
+LINE #Option "fifo_conservative"
#tested
NAME Cirrus Logic GD5464
CHIPSET CL-GD5464
SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE #Option "fifo_conservative"
+
+#tested
+NAME Cirrus Logic GD5465
+CHIPSET CL-GD5465
+SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
+LINE #Option "fifo_conservative"
NAME Creative Labs Graphics Blaster MA302
CHIPSET CL-GD5462
@@ -183,6 +430,13 @@ CHIPSET CL-GD5464
SEE Cirrus Logic GD5464
#tested
+NAME Cirrus Logic GD5480
+CHIPSET CL-GD5480
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+
+#tested
NAME Diamond SpeedStar 64
CHIPSET CL-GD5434
SEE Cirrus Logic GD543x
@@ -200,6 +454,7 @@ SEE Cirrus Logic GD542x
NAME Orchid Kelvin 64 VLB Rev A
CHIPSET CL-GD5434
SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
LINE # Device section for Orchid Kelvin 64 VLB Rev A
LINE # Linear framebuffer maps at 2048Mb. Some motherboards make linear addressing
@@ -212,6 +467,7 @@ LINE #Option "linear"
NAME Orchid Kelvin 64 VLB Rev B
CHIPSET CL-GD5434
SERVER SVGA
+DRIVER cirrus
NOCLOCKPROBE
LINE # Device section for Orchid Kelvin 64 VLB Rev B
LINE # Linear framebuffer maps at 32Mb. Some motherboards make linear addressing
@@ -283,22 +539,90 @@ SEE Cirrus Logic GD543x
NAME Cirrus Logic GD62xx (laptop)
CHIPSET CL-GD6205/15/25/35
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME Cirrus Logic GD64xx (laptop)
CHIPSET CL-GD6420/6440
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Cirrus Logic GD754x (laptop)
CHIPSET CL-GD7541/42/43/48
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Techworks Ultimate 3D
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME VideoLogic GrafixStar 550
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME Jaton Video-70P
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME PixelView Combo TV Pro (Prolink)
+CHIPSET CL-GD5480, 4MB
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # COMMENT on card TV Tuner
+NOCLOCKPROBE
+
+NAME PixelView Combo TV 3D AGP (Prolink)
+CHIPSET CL-GD5465, 4MB
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # COMMENT on card TV+FM Tuner
+NOCLOCKPROBE
+
+NAME Creative Labs Graphics Blaster Eclipse (OEM Model CT6510)
+SEE Cirrus Logic GD5465
+
+NAME VideoLogic GrafixStar 560 (PCI/AGP)
+SEE Cirrus Logic GD5465
+
+NAME Cirrus Logic GD5446 (noname card)
+CHIPSET CL-GD5446, 1MB (upgradable to 2MB).
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
+NAME Octek VL-VGA-26
+CHIPSET CL-GD5426
+SEE Cirrus Logic GD542x
+
+NAME Octek VL-VGA-28
+CHIPSET CL-GD5428
+SEE Cirrus Logic GD542x
+
+NAME Octek Combo-26
+CHIPSET CL-GD5426
+SEE Cirrus Logic GD542x
+
+NAME Octek Combo-28
+CHIPSET CL-GD5428
+SEE Cirrus Logic GD542x
+
+NAME Octek AVGA-20
+SEE Cirrus Logic GD542x
+
# S3 801/805
NAME S3 801/805 (generic)
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME S3 86C801 (generic)
SEE S3 801/805 (generic)
@@ -310,28 +634,38 @@ SEE S3 801/805 (generic)
NAME S3 801/805 with ATT20c490 RAMDAC
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
LINE #Option "dac_8_bit" # Not supported by some 20c490 clones
NAME S3 801/805 with SC1148{2,3,4} RAMDAC
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC sc11482
NAME S3 801/805 with SC1148{5,7,9} RAMDAC
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC sc11485
NAME S3 801/805 with S3 GenDAC
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC s3gendac
CLOCKCHIP s3gendac
NAME S3 801/805 with ATT20c490 RAMDAC and ICD2061A
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
CLOCKCHIP icd2061a
LINE #Option "dac_8_bit" # Not supported by some 20c490 clones
@@ -339,6 +673,8 @@ LINE #Option "dac_8_bit" # Not supported by some 20c490 clones
NAME S3 801/805 with Chrontel 8391
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
CLOCKCHIP ch8391
LINE Option "dac_8_bit"
@@ -347,21 +683,29 @@ LINE Option "dac_8_bit"
NAME Actix GE32+ 2MB
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
LINE #Option "dac_8_bit"
NAME Actix GE32i
CHIPSET S3 805i
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME Orchid Fahrenheit VA
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
NAME Orchid Fahrenheit 1280
CHIPSET S3 801
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Probable clocks:
LINE #Clocks 25.20 28.32 32.50 0.00 40.00 44.90 50.40 65.00
LINE #Clocks 78.00 56.70 63.10 75.10 80.00 89.90 100.90 31.50
@@ -369,6 +713,8 @@ LINE #Clocks 78.00 56.70 63.10 75.10 80.00 89.90 100.90 31.50
NAME Orchid Fahrenheit-1280+
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20C490
LINE Dacspeed 110
LINE Option "dac_8_bit"
@@ -380,6 +726,8 @@ LINE #Clocks 130.0 120.20 80.0 31.50 110.30 65.0 75.0 94.60
NAME Diamond Stealth 24
CHIPSET S3 801/805
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
LINE #Option "nolinear"
LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp
@@ -408,8 +756,9 @@ SEE S3 801/805 with Chrontel 8391
# S3 864/Trio64/Trio32/868
NAME S3 864 (generic)
-CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME S3 86C864 (generic)
SEE S3 864 (generic)
@@ -420,6 +769,8 @@ SEE S3 864 (generic)
NAME S3 864 with SDAC (86C716)
CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC s3_sdac
CLOCKCHIP s3_sdac
NOCLOCKPROBE
@@ -427,17 +778,23 @@ NOCLOCKPROBE
NAME S3 864 with ATT 20C498 or 21C498
CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c498
NAME S3 864 with STG1703
CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC stg1703
NOCLOCKPROBE
NAME S3 868 (generic)
CHIPSET S3 868
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME S3 86C868 (generic)
SEE S3 868 (generic)
@@ -448,16 +805,22 @@ SEE S3 868 (generic)
NAME S3 868 with SDAC (86C716)
CHIPSET S3 868
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 868 with ATT 20C498 or 21C498
CHIPSET S3 868
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c498
NAME S3 868 with ATT 20C409
CHIPSET S3 868
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c409
NOCLOCKPROBE
@@ -466,16 +829,18 @@ CLOCKCHIP icd2061a
SEE S3 868 with ATT 20C498 or 21C498
NAME S3 Trio64 (generic)
-CHIPSET S3 Trio64
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 86C764 (generic)
SEE S3 Trio64 (generic)
NAME S3 Trio64V+ (generic)
-CHIPSET S3 Trio64V+
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 86C765 (generic)
@@ -484,6 +849,8 @@ SEE S3 Trio64V+ (generic)
NAME S3 Trio32 (generic)
CHIPSET S3 Trio32
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME Genoa Phantom 64i with S3 SDAC
@@ -493,6 +860,8 @@ SEE S3 864 with SDAC (86C716)
NAME Number Nine GXE64
CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
LINE Option "number_nine"
@@ -529,6 +898,8 @@ SEE S3 864 with SDAC (86C716)
NAME ELSA Winner 1000PRO with STG1700 or AT&T RAMDAC
CHIPSET S3 864
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
NAME ELSA Winner 1000PRO/X
@@ -537,6 +908,8 @@ SEE S3 868 with SDAC (86C716)
NAME ELSA Winner 1000ISA
CHIPSET S3 805i
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
LINE Option "dac_8_bit"
LINE # the following settings should be detected and set automatically by XF86_S3
@@ -626,8 +999,9 @@ SEE S3 Trio64V+ (generic)
# S3 Trio64V2
NAME S3 Trio64V2 (generic)
-CHIPSET S3 Trio64V2
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 Trio64V2/DX (generic)
@@ -651,6 +1025,8 @@ SEE S3 Trio64V2/DX (generic)
NAME S3 Aurora64V+ (generic)
CHIPSET S3 Aurora64V+
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
LINE # Option "lcd_center"
LINE # Set_LCDClk <pixel_clock_for_LCD>
@@ -676,6 +1052,8 @@ SEE S3 Aurora64V+ (generic)
NAME S3 964 (generic)
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 86C964 (generic)
@@ -687,6 +1065,8 @@ SEE S3 964 (generic)
NAME S3 968 (generic)
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME S3 86C968 (generic)
@@ -698,6 +1078,8 @@ SEE S3 968 (generic)
NAME Number Nine GXE64 Pro
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC ti3025
LINE Option "number_nine"
@@ -781,21 +1163,29 @@ SEE S3 964 (generic)
NAME Miro Crystal 20SV
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
NAME Miro Crystal 40SV
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP ti3025
NAME Miro Crystal 80SV
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME Miro Video 20SV
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c505
LINE #DacSpeed 150
CLOCKCHIP ics9161a
@@ -803,65 +1193,87 @@ CLOCKCHIP ics9161a
NAME SPEA Mercury 64
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP ics9161a
LINE #Option "spea_mercury"
NAME ELSA Winner 2000PRO-2
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "ELSA_w2000pro"
NOCLOCKPROBE
NAME ELSA Winner 2000PRO-4
CHIPSET S3 964
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "ELSA_w2000pro"
NOCLOCKPROBE
NAME ELSA Winner 2000PRO/X-2
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME ELSA Winner 2000PRO/X-4
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME ELSA Winner 2000PRO/X-8
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME ELSA Winner 2000AVI
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME ELSA Gloria-4
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME ELSA Gloria-8
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Option "sync_on_green"
NOCLOCKPROBE
NAME VideoLogic GrafixStar 700
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME LeadTek WinFast S430
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME WinFast S430
@@ -870,6 +1282,8 @@ SEE LeadTek WinFast S430
NAME LeadTek WinFast S510
CHIPSET S3 968
SERVER S3
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME WinFast S510
@@ -880,6 +1294,8 @@ SEE LeadTek WinFast S510
NAME S3 928 (generic)
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME S3 86C928 (generic)
SEE S3 928 (generic)
@@ -887,12 +1303,16 @@ SEE S3 928 (generic)
NAME Actix Ultra
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
LINE #Option "dac_8_bit"
NAME Diamond Stealth Pro
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp
LINE #Option "no_linear" # Some VLB machines may require this
@@ -900,6 +1320,8 @@ LINE #Option "no_linear" # Some VLB machines may require this
NAME ELSA Winner 1000VL
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE # the following settings should be detected and set automatically by XF86_S3
LINE # if the serial number of the ELSA card is printed correctly:
LINE #ClockChip "icd2061a"
@@ -917,12 +1339,16 @@ SEE S3 928 (generic)
NAME SPEA/V7 Mercury
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP sc11412
LINE Option "spea_mercury"
NAME STB Pegasus
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
RAMDAC bt485
CLOCKCHIP icd2061a
LINE Option "stb_pegasus"
@@ -931,6 +1357,8 @@ LINE #Option "sync_on_green"
NAME Number Nine GXE Level 14/16
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
DACSPEED 200
CLOCKCHIP icd2061a
LINE Option "number_nine"
@@ -940,12 +1368,16 @@ LINE #Option "nomemaccess"
NAME Number Nine GXE Level 10/11/12
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
LINE Option "number_nine"
NAME 928Movie
CHIPSET S3 928
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2595
RAMDAC bt485
LINE # pixel multiplexing not supported
@@ -955,6 +1387,8 @@ LINE # pixel multiplexing not supported
NAME S3 911/924 (generic)
CHIPSET S3 911/924
SERVER S3
+DRIVER vga
+UNSUPPORTED
NAME S3 86C911 (generic)
SEE S3 911/924 (generic)
@@ -965,6 +1399,8 @@ SEE S3 911/924 (generic)
NAME Diamond Stealth VRAM
CHIPSET S3 911/924
SERVER S3
+DRIVER vga
+UNSUPPORTED
CLOCKCHIP icd2061a
#NAME Orchid Fahrenheit 1280
@@ -973,6 +1409,8 @@ CLOCKCHIP icd2061a
NAME S3 924 with SC1148 DAC
CHIPSET S3 924
SERVER S3
+DRIVER vga
+UNSUPPORTED
LINE #Probable clocks:
LINE #Clocks 25.2 28.3 39.7 1.7 49.9 76.7 35.7 44
LINE #Clocks 130.2 119.5 79.4 31.2 110.0 65.2 74.9 71.3
@@ -982,11 +1420,13 @@ LINE #Clocks 130.2 119.5 79.4 31.2 110.0 65.2 74.9 71.3
NAME S3 ViRGE (old S3V server)
CHIPSET S3 ViRGE
SERVER S3V
+DRIVER s3virge
NOCLOCKPROBE
NAME S3 ViRGE (generic)
CHIPSET S3 ViRGE
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "xaa_benchmark"
LINE #Option "fifo_moderate"
@@ -996,6 +1436,7 @@ LINE #Option "pci_retry"
NAME S3 ViRGE/DX (generic)
CHIPSET S3 ViRGE/DX
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "xaa_benchmark"
LINE #Option "fifo_moderate"
@@ -1005,6 +1446,7 @@ LINE #Option "pci_retry"
NAME S3 ViRGE/GX (generic)
CHIPSET S3 ViRGE/GX
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "xaa_benchmark"
LINE #Option "fifo_moderate"
@@ -1015,6 +1457,7 @@ LINE #Option "pci_retry"
NAME S3 ViRGE/GX2 (generic)
CHIPSET S3 ViRGE/GX2
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "xaa_benchmark"
LINE #Option "fifo_moderate"
@@ -1024,6 +1467,7 @@ LINE #Option "pci_retry"
NAME S3 ViRGE/MX (generic)
CHIPSET S3 ViRGE/MX
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "lcd_center"
LINE #Set_LCDClk <pixel_clock_for_LCD>
@@ -1032,6 +1476,9 @@ LINE #Option "fifo_moderate"
LINE #Option "pci_burst_on"
LINE #Option "pci_retry"
+NAME S3 ViRGE/MX+ (generic)
+SEE S3 ViRGE/MX (generic)
+
@@ -1050,6 +1497,9 @@ SEE S3 ViRGE/GX2 (generic)
NAME S3 86C260 (generic)
SEE S3 ViRGE/MX (generic)
+NAME S3 86C280 (generic)
+SEE S3 ViRGE/MX+ (generic)
+
NAME ELSA Victory 3D
SEE S3 ViRGE (generic)
@@ -1105,10 +1555,7 @@ SEE LeadTek WinFast 3D S600
NAME LeadTek WinFast 3D S680
SEE S3 ViRGE/GX2 (generic)
-NAME WinFast 3D S600
-SEE LeadTek WinFast 3D S680
-
-NAME miro miroMedia 3D
+NAME Miro MiroMedia 3D
SEE S3 ViRGE (generic)
NAME Orchid Technology Fahrenheit Video 3D
@@ -1131,6 +1578,7 @@ SEE S3 ViRGE (generic)
NAME S3 ViRGE/VX (generic)
CHIPSET S3 ViRGE/VX
SERVER SVGA
+DRIVER s3virge
NOCLOCKPROBE
LINE #Option "xaa_benchmark"
LINE #Option "fifo_moderate"
@@ -1162,6 +1610,8 @@ SEE S3 ViRGE/VX (generic)
NAME MELCO WGP-VX8
SEE S3 ViRGE/VX (generic)
+NAME Diamond Stealth 3D 4000
+SEE S3 ViRGE/GX2 (generic)
NAME Toshiba Tecra 750CDT
SEE S3 ViRGE/MX (generic)
@@ -1175,15 +1625,31 @@ SEE S3 ViRGE/MX (generic)
NAME Toshiba Tecra 550CDT
SEE S3 ViRGE/MX (generic)
+# currently unsupported S3
+NAME S3 86C365 (Trio3D)
+SEE * Unsupported VGA compatible
+NAME S3 86C391 (Savage3D)
+SEE * Unsupported VGA compatible
+NAME S3 Trio3D
+SEE * Unsupported VGA compatible
+
+NAME S3 Savage3D
+SEE * Unsupported VGA compatible
+
+NAME S3 Savage4
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
# ET4000/ET6000
NAME ET3000 (generic)
CHIPSET ET3000
SERVER SVGA
+DRIVER tseng
NAME Genoa 5400
SEE ET3000 (generic)
@@ -1191,14 +1657,17 @@ SEE ET3000 (generic)
NAME ET4000 (generic)
CHIPSET ET4000
SERVER SVGA
+DRIVER tseng
NAME ET4000/W32 (generic)
CHIPSET ET4000/W32
SERVER W32
+DRIVER tseng
NAME ET4000 W32i, W32p (generic)
CHIPSET ET4000/W32(i/p)
SERVER SVGA
+DRIVER tseng
LINE #Option "linear" # for linear mode at 8bpp
LINE #Option "noaccel" # when problems with accelerator
LINE #Option "power_saver" # enable VESA DPMS
@@ -1212,6 +1681,7 @@ LINE # -- see README.tseng for more (important) information on MemBase
NAME ET6000 (generic)
CHIPSET ET6000
SERVER SVGA
+DRIVER tseng
NOCLOCKPROBE
LINE #videoram 2304 # 2.25 MB, when memory probe is incorrect
LINE #Option "linear" # for linear mode at 8bpp
@@ -1223,8 +1693,7 @@ LINE #Option "xaa_no_color_exp" # When text (or bitmap) is not rendered cor
NAME ET6100 (generic)
CHIPSET ET6100
-SERVER XSuSE_Tseng
-NOCLOCKPROBE
+SEE ET6000 (generic)
NAME Diamond Stealth 32
CLOCKCHIP icd2061a
@@ -1358,184 +1827,174 @@ SEE ET6000 (generic)
NAME Interay PMC Viper
SEE ET6000 (generic)
-2-the-Max MAXColor 6000
+NAME 2-the-Max MAXColor 6000
SEE ET6000 (generic)
-Gainward Challenger EV
+NAME Gainward Challenger EV
SEE ET6000 (generic)
-MachSpeed VGA ET6000
+NAME MachSpeed VGA ET6000
SEE ET6000 (generic)
-KouTech KeyVision 128 EV
+NAME KouTech KeyVision 128 EV
SEE ET6000 (generic)
+NAME Jaton Video-58P
+SEE ET6000 (generic)
# ATI
+NAME ATI Rage 128
+CHIPSET ati
+SERVER SVGA
+DRIVER ati
+
NAME ATI 8514 Ultra (no VGA)
-CHIPSET ATI-Mach8
+CHIPSET ati
SERVER Mach8
+DRIVER vga
+UNSUPPORTED
NAME ATI Graphics Ultra
-CHIPSET ATI-Mach8
+CHIPSET ati
SERVER Mach8
-LINE #Probable clocks:
-LINE #Clocks 43 49 80 36 50 56 0 45 30 32 110 79 40 45 75 65
-LINE #Clocks 22 25 46 18 25 28 0 22 15 16 55 40 20 22 38 32
+DRIVER ati
NAME ATI Graphics Ultra Pro
-CHIPSET ATI-Mach32
+CHIPSET ati
SERVER Mach32
-LINE #Probable clocks:
-LINE #Clocks 100 126 92 36 51 57 0 44 135 32 110 80 39
-LINE #Clocks 45 75 65 50 63 46 18 25 28 0 22 67 16 55 40 19 23 37 33
-LINE #Option "dac_8_bit"
+DRIVER ati
NAME ATI Wonder SVGA
-CHIPSET ATI vgawonder
+CHIPSET ati
SERVER SVGA
-LINE #probable clocks:
-LINE #Clocks 30 32 11 80 42 48 92 36 40 45 75 65 50 56 0 0
-LINE #Clocks 15 16 55 0 21 24 46 18 20 22 37 32 25 28 0 0
+DRIVER ati
NAME ATI Ultra Plus
-CHIPSET ATI-Mach32
+CHIPSET ati
SERVER Mach32
+DRIVER ati
NAME ATI Mach32
-CHIPSET ATI-Mach32
+CHIPSET ati
SERVER Mach32
+DRIVER ati
NAME ATI Mach64
-CHIPSET ATI-Mach64
+CHIPSET ati
SERVER Mach64
+DRIVER ati
NOCLOCKPROBE
-NAME ATI Mach64 with AT&T 20C408 RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-LINE #Ramdac "att20c408"
-NOCLOCKPROBE
+NAME ATI Mach64 CT (264CT)
+SEE ATI Mach64
-NAME ATI Mach64 with CH8398 RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-LINE #Ramdac "ch8398"
-NOCLOCKPROBE
+NAME ATI Mach64 VT (264VT)
+SEE ATI Mach64
-NAME ATI Mach64 with IBM RGB514 RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-LINE #Ramdac "ibm_rgb514"
-NOCLOCKPROBE
+NAME ATI Mach64 GT (264GT), aka 3D RAGE
+SEE ATI Mach64
-NAME ATI Mach64 CT (264CT), Internal RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI Mach64 3D RAGE II
+SEE ATI Mach64
-NAME ATI Mach64 VT (264VT), Internal RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI Mach64 3D RAGE II+DVD
+SEE ATI Mach64
-NAME ATI Mach64 GT (264GT), aka 3D RAGE, Internal RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI Mach64 3D Rage IIC
+SEE ATI Mach64
-NAME ATI Mach64 3D RAGE II, Internal RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI Mach64 3D Rage Pro
+SEE ATI Mach64
-NAME ATI Mach64 3D RAGE II+, Internal RAMDAC
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI 3D Pro Turbo
+SEE ATI Mach64
-NAME ATI Xpert@Play PCI and AGP, 3D Rage Pro
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI 3D Pro Turbo PC2TV
+SEE ATI Mach64
-NAME ATI Xpert@Work, 3D Rage Pro
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI 3D Xpression
+SEE ATI Mach64
-NAME ATI Pro Turbo+PC2TV, 3D Rage II+DVD
-CHIPSET ATI-Mach64
-SERVER Mach64
-NOCLOCKPROBE
+NAME ATI 3D Xpression+
+SEE ATI Mach64
-NAME ATI Graphics Xpression with STG1702 RAMDAC
+NAME ATI 3D Xpression+ PC2TV
SEE ATI Mach64
-NAME ATI Graphics Xpression with 68875 RAMDAC
+NAME ATI All-in-Wonder
SEE ATI Mach64
-NAME ATI Graphics Xpression with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
+NAME ATI All-in-Wonder Pro
+SEE ATI Mach64
-NAME ATI Graphics Xpression with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
+NAME ATI Graphics Pro Turbo
+SEE ATI Mach64
-NAME ATI Graphics Xpression with Mach64 CT (264CT)
-SEE ATI Mach64 CT (264CT), Internal RAMDAC
+NAME ATI Graphics Pro Turbo 1600
+SEE ATI Mach64
-NAME ATI Video Xpression
-SEE ATI Mach64 VT (264VT), Internal RAMDAC
+NAME ATI Graphics Xpression
+SEE ATI Mach64
-NAME ATI 3D Xpression
-SEE ATI Mach64 GT (264GT), aka 3D RAGE, Internal RAMDAC
+NAME ATI Video Boost
+SEE ATI Mach64
-NAME ATI 3D Xpression+ PC2TV
-SEE ATI Mach64 3D RAGE II, Internal RAMDAC
+NAME ATI Video Charger
+SEE ATI Mach64
-NAME ATI 3D Pro Turbo
-SEE ATI Mach64 3D RAGE II, Internal RAMDAC
+NAME ATI Video Xpression
+SEE ATI Mach64
-NAME ATI All-in-Wonder
-SEE ATI Mach64 3D RAGE II+, Internal RAMDAC
+NAME ATI Video Xpression+
+SEE ATI Mach64
+
+NAME ATI WinBoost
+SEE ATI Mach64
-NAME ATI Win Boost with STG1702 RAMDAC
+NAME ATI WinCharger
SEE ATI Mach64
-NAME ATI Win Boost with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
+NAME ATI WinTurbo
+SEE ATI Mach64
-NAME ATI Win Boost with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
+NAME ATI Xpert 98
+SEE ATI Mach64
-NAME ATI Win Boost with Mach64 CT (264CT)
-SEE ATI Mach64 CT (264CT), Internal RAMDAC
+NAME ATI Xpert XL
+SEE ATI Mach64
-NAME ATI Graphics Pro Turbo
+NAME ATI Xpert@Play
SEE ATI Mach64
-NAME ATI Graphics Pro Turbo 1600
-SEE ATI Mach64 with IBM RGB514 RAMDAC
+NAME ATI Xpert@Play 98
+SEE ATI Mach64
+
+NAME ATI Xpert@Work
+SEE ATI Mach64
-NAME ATI Win Turbo
+NAME ATI integrated on Intel Maui MU440EX motherboard
SEE ATI Mach64
NAME ASUS PCI-V264CT
-SEE ATI Mach64 CT (264CT), Internal RAMDAC
+SEE ATI Mach64
NAME ASUS PCI-AV264CT
-SEE ATI Mach64 CT (264CT), Internal RAMDAC
+SEE ATI Mach64
# AGX
NAME AGX (generic)
CHIPSET AGX-014/15/16
SERVER AGX
+DRIVER vga
+UNSUPPORTED
NAME Boca Vortex (Sierra RAMDAC)
CHIPSET AGX-015
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC sc15025
LINE Option "dac_8_bit"
LINE Option "no_wait_state"
@@ -1547,6 +2006,8 @@ SEE AGX (generic)
NAME Orchid Celsius (AT&T RAMDAC)
CHIPSET AGX-015
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC att20c490
LINE Option "dac_8_bit"
LINE Option "no_wait_state"
@@ -1555,6 +2016,8 @@ LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels
NAME Orchid Celsius (Sierra RAMDAC)
CHIPSET AGX-015
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC sc15025
LINE Option "dac_8_bit"
LINE Option "no_wait_state"
@@ -1564,6 +2027,8 @@ LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels
NAME Spider Black Widow
CHIPSET AGX-015
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC sc15025
LINE Option "dac_8_bit"
LINE Option "no_wait_state"
@@ -1573,6 +2038,8 @@ LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels
NAME Spider Black Widow Plus
CHIPSET AGX-016
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC sc15025
LINE Option "dac_8_bit"
LINE Option "no_wait_state"
@@ -1585,6 +2052,8 @@ LINE #Clocks 89.0 119.8 79.9 31.5 110.0 64.9 74.9 94.9
NAME Hercules Graphite HG210
CHIPSET AGX-014
SERVER AGX
+DRIVER vga
+UNSUPPORTED
RAMDAC bt482
DACSPEED 85
LINE Chipset "AGX-014"
@@ -1597,6 +2066,8 @@ LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0
NAME Hercules Graphite Pro
CHIPSET AGX-015
SERVER AGX
+DRIVER vga
+UNSUPPORTED
# Card specific DAC, doesn't appear in ramdac menu
LINE Ramdac "herc_dual_dac"
LINE Chipset "AGX-015"
@@ -1610,6 +2081,8 @@ LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0
NAME Hercules Graphite Power
CHIPSET AGX-016
SERVER AGX
+DRIVER vga
+UNSUPPORTED
# Card specific DAC, doesn't appear in ramdac menu
# The glue logic state machine for RAMDAC switching doesn't work as
# documented, for now we're stuck with the small RAMDAC
@@ -1626,6 +2099,8 @@ LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0
NAME XGA-2 (ISA bus)
CHIPSET XGA-2
SERVER AGX
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
LINE #Instance 7 # XGA instance 0-7
LINE #COPbase 0xC8F00 # XGA memory-mapped register address
@@ -1634,6 +2109,8 @@ LINE #POSbase 0 # Disable probing if above are specified
NAME XGA-1 (ISA bus)
CHIPSET XGA-1
SERVER AGX
+DRIVER vga
+UNSUPPORTED
LINE #Instance 7 # XGA instance 0-7
LINE #COPbase 0xC8F00 # XGA memory-mapped register address
LINE #POSbase 0 # Disable probing if above are specified
@@ -1643,18 +2120,26 @@ LINE #POSbase 0 # Disable probing if above are specified
NAME Paradise/WD 90CXX
CHIPSET WD90CXX
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME DFI-WG6000
CHIPSET WD90C33
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Diamond SpeedStar 24X (not fully supported)
CHIPSET WD90C31
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME WD 90C24 (laptop)
CHIPSET WD90C24
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
LINE #Chipset "wd90c24"
LINE #Option "noaccel" # Use this if acceleration is causing problems
LINE #Clocks 25.175 28.322 65 36 # These are not programmable
@@ -1667,6 +2152,8 @@ LINE #Clocks 44.297 # Must match Mclk
NAME WD 90C24A or 90C24A2 (laptop)
CHIPSET WD90C24A
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
LINE #Chipset "wd90c24"
LINE #Clocks 25.175 28.322 65 36 # These are not programmable
LINE #Clocks 29.979 77.408 62.195 59.957 # These are programmable
@@ -1680,61 +2167,85 @@ NAME Avance Logic 2101
CHIPSET Avance Logic
LINE #chipset "al2101"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Avance Logic 2228
CHIPSET Avance Logic
LINE #chipset "ali2228"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Avance Logic 2301
CHIPSET Avance Logic
LINE #chipset "ali2301"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Avance Logic 2302
CHIPSET Avance Logic
LINE #chipset "ali2302"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Avance Logic 2308
CHIPSET Avance Logic
LINE #chipset "ali2308"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Avance Logic 2401
CHIPSET Avance Logic
LINE #chipset "ali2401"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Hercules Stingray
CHIPSET ALG-2228/2301/2302
LINE #chipset "ali2228"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME SPEA/V7 Mirage VEGA Plus
CHIPSET ALG-2228
LINE #chipset "ali2228"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
# ARK Logic
NAME Ark Logic ARK1000PV (generic)
CHIPSET ARK1000PV
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
# For now, treat the VL as a PV. This may be changed later
NAME Ark Logic ARK1000VL (generic)
CHIPSET ARK1000VL
LINE Chipset "ark1000pv"
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Ark Logic ARK2000PV (generic)
CHIPSET ARK1000PV
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Ark Logic ARK2000MT (generic)
CHIPSET ARK1000MT
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Hercules Stingray Pro
SEE Ark Logic ARK1000PV (generic)
@@ -1753,27 +2264,51 @@ NAME Hercules Stingray 64/V with ICS5342
CHIPSET ARK2000MT
RAMDAC ics5342
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Diamond Stealth64 Graphics 2001 series
CHIPSET ARK2000PV
RAMDAC ics5342
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
# Oak
-NAME Oak (generic)
-CHIPSET Oak-067/77/87
+NAME Oak ISA Card (generic)
+CHIPSET Oak OTI-067/77
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
-NAME Paradise Accelerator Value
+NAME Oak 87 VLB (generic)
CHIPSET Oak OTI-087
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE Option "fifo_aggressive" # Comment this if you experience streaks.
+LINE Option "no_wait" # Comment this if you find problems.
+LINE #Option "enable_bitblt" # You may enable this and see if it works (see README.Oak file)
+
+NAME Oak 87 ISA (generic)
+CHIPSET Oak OTI-087
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE Option "noaccel" # ISA cards seem to have Color Expansion support broken
+LINE #Option "enable_bitblt" # This should work on ISA, but lets not make it default just in case.
+
+NAME Paradise Accelerator Value
+SEE Oak 87 ISA (generic)
# P9000
NAME Diamond Viper VLB 2Mb
CHIPSET Weitek 9000
SERVER P9000
+DRIVER vga
+UNSUPPORTED
LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server)
LINE #Versions later than 3.1 do not require a clocks line
LINE Chipset "vipervlb" # Required for some cards which autodetect as PCI
@@ -1784,6 +2319,8 @@ NOCLOCKPROBE
NAME Diamond Viper PCI 2Mb
CHIPSET Weitek 9000
SERVER P9000
+DRIVER vga
+UNSUPPORTED
LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server)
LINE #Versions later than 3.1 do not require a clocks line
LINE Videoram 2048 # Required
@@ -1793,170 +2330,671 @@ NOCLOCKPROBE
NAME Orchid P9000 VLB
CHIPSET Weitek 9000
SERVER P9000
+DRIVER vga
+UNSUPPORTED
LINE Chipset "orchid_p9000"
LINE Membase 0xE0000000
NOCLOCKPROBE
+# P9100
+
+NAME Weitek P9100 (generic)
+CHIPSET Weitek P9100
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Diamond Viper Pro Video
+SEE Weitek P9100 (generic)
+
# Trident
NAME Trident 8900/9000 (generic)
CHIPSET TVGA8900/9000
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Trident 8900D (generic)
-CHIPSET TVGA8900D
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Trident TVGA9200CXr (generic)
CHIPSET TVGA9200CXr
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NAME Trident TGUI9400CXi (generic)
CHIPSET TGUI9400CXi
SERVER SVGA
+DRIVER trident
NAME Trident TGUI9420DGi (generic)
CHIPSET TGUI9420DGi
SERVER SVGA
+DRIVER trident
NAME Trident TGUI9430DGi (generic)
CHIPSET TGUI9430DGi
SERVER SVGA
+DRIVER trident
+
+NAME Trident TGUI9420 (generic)
+CHIPSET TGUI9420
+DRIVER trident
+NOCLOCKPROBE
NAME Trident TGUI9440 (generic)
CHIPSET TGUI9440
-SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident TGUI9660 (generic)
CHIPSET TGUI9660
-SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident TGUI9680 (generic)
CHIPSET TGUI9680
-SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident TGUI9682 (generic)
CHIPSET TGUI9682
SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident TGUI9685 (generic)
CHIPSET TGUI9685
SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9320 (generic)
+CHIPSET Cyber9320
+DRIVER trident
NOCLOCKPROBE
NAME Trident Cyber 9382 (generic)
CHIPSET Cyber9382
SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident Cyber 9385 (generic)
CHIPSET Cyber9385
SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
NAME Trident Cyber 9388 (generic)
CHIPSET Cyber9388
SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 939a (generic)
+CHIPSET Cyber939a
+DRIVER trident
NOCLOCKPROBE
NAME Trident Cyber 9397 (generic)
CHIPSET Cyber9397
SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9520 (generic)
+CHIPSET Cyber9520
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage975 (generic)
+CHIPSET 3dimage975
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage975 AGP (generic)
+CHIPSET 3dimage975
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage985 (generic)
+CHIPSET 3dimage985
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Providia 9682 (generic)
+CHIPSET Providia9682
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Providia 9685 (generic)
+CHIPSET Providia9685
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TVGA 8800BR
+SEE * Generic VGA compatible
+
+NAME Trident TVGA 8800CS
+SEE * Generic VGA compatible
+
+NAME Trident CyberBlade (generic)
+CHIPSET CyberBlade
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Blade3D (generic)
+CHIPSET Blade3D
+SERVER SVGA
+DRIVER trident
NOCLOCKPROBE
# SiS
+NAME SiS 530
+CHIPSET SIS530
+SERVER SVGA
+DRIVER sis
+
+NAME SiS 620
+CHIPSET SIS620
+SERVER SVGA
+DRIVER sis
+
NAME SiS SG86C201
CHIPSET SIS86C201
SERVER SVGA
+DRIVER sis
-# Alliance ProMotion
+NAME SiS SG86C205
+CHIPSET SIS86C205
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+NOCLOCKPROBE
-NAME Alliance ProMotion 6422
-CHIPSET AP6422
+NAME SiS SG86C215
+CHIPSET SIS86C215
SERVER SVGA
+DRIVER sis
+LINE # This is a cheap version of 86c205. I am not sure if acceleration works
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "no_BitBlt" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+NOCLOCKPROBE
-# VGA
+NAME SiS SG86C225
+CHIPSET SIS86C225
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+NOCLOCKPROBE
-NAME Generic VGA compatible
-CHIPSET Generic VGA
-SERVER VGA16
+NAME SiS 5597
+CHIPSET SiS5597
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+LINE # Option "fast_vram"
+LINE # Option "pci_burst_on"
+LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing
+LINE # errors, but gives some accel
+NOCLOCKPROBE
-NAME Unsupported VGA compatible
-CHIPSET Generic VGA
-SERVER VGA16
+NAME SiS 5598
+CHIPSET SIS5598
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+LINE # Option "fast_vram"
+LINE # Option "pci_burst_on"
+LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing
+LINE # errors, but gives some accel
+NOCLOCKPROBE
+
+NAME SiS 6326
+CHIPSET SiS6326
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel" # Use this if acceleration is causing problems
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+LINE # Option "fast_vram"
+LINE # Option "pci_burst_on"
+LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing
+LINE # errors, but gives some accel
+NOCLOCKPROBE
+
+NAME MSI MS-4417
+SEE SiS 6326
+
+NAME SiS 3D PRO AGP
+SEE SiS 6326
+
+NAME Miro Crystal DVD
+SEE SiS 6326
+
+NAME PC-Chips M567 Mainboard
+SEE SiS 5597
+
+NAME Diamond SpeedStar A50
+SEE SiS 6326
+
+# Cyrix
+
+NAME MediaGX
+CHIPSET mediagx
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+# Alliance ProMotion
+
+NAME Alliance ProMotion 6422
+CHIPSET AP6422
+SERVER SVGA
+DRIVER vga
UNSUPPORTED
# Number 9 I128
-NAME Number Nine Imagine I-128 (2-8MB)
+NAME Number Nine Imagine I-128
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+NAME Number Nine Imagine I-128 Series 2
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+NAME Number Nine Revolution 3D (T2R)
CHIPSET I128
SERVER I128
+DRIVER i128
+NOCLOCKPROBE
-NAME Number Nine Imagine I-128 Series 2 (2-4MB)
+NAME Number Nine Imagine-128 Revolution IV (T2R4)
CHIPSET I128
SERVER I128
+DRIVER i128
+NOCLOCKPROBE
# Matrox
-NAME Matrox Millennium (MGA)
+NAME Matrox Millennium 2MB
+CHIPSET mga2064w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 2048
+NOCLOCKPROBE
+
+NAME Matrox Millennium 4MB
CHIPSET mga2064w
SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
NOCLOCKPROBE
-NAME Matrox Millennium II
+NAME Matrox Millennium 8MB
+CHIPSET mga2064w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium II 4MB
CHIPSET mga2164w
SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
NOCLOCKPROBE
-NAME Matrox Millennium II AGP
-CHIPSET mga2164w AGP
+NAME Matrox Millennium II 8MB
+CHIPSET mga2164w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium II 16MB
+CHIPSET mga2164w
SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+LINE # Option "mga_sdram"
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+LINE # Option "mga_sdram"
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+LINE # Option "mga_sdram"
NOCLOCKPROBE
NAME Matrox Mystique
CHIPSET mga1064sg
SERVER SVGA
+DRIVER mga
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium G400
+CHIPSET mgag400
+SERVER SVGA
+DRIVER mga
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Productiva G100 4MB
+CHIPSET mgag100
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Productiva G100 8MB
+CHIPSET mgag100
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
NOCLOCKPROBE
-# NV1
+# NVIDIA
NAME Diamond Edge 3D
CHIPSET nv1
SERVER SVGA
+DRIVER vga
+UNSUPPORTED
NOCLOCKPROBE
NAME RIVA128
CHIPSET RIVA128
SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME RIVA TNT
+CHIPSET RIVATNT
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME RIVA TNT2
+CHIPSET RIVATNT2
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME NVIDIA GeForce
+CHIPSET GeForce
+SERVER SVGA
+DRIVER nv
NOCLOCKPROBE
NAME ELSA VICTORY ERAZOR
SEE RIVA128
+NAME ELSA Winner 1000 R3D
+SEE RIVA128
+
+NAME ELSA ERAZOR II
+SEE RIVA TNT
+
NAME Diamond Viper 330
SEE RIVA128
+NAME Diamond Viper 550
+SEE RIVA TNT
+
+NAME Diamond Viper 770
+SEE RIVA TNT2
+
NAME STB Velocity 128
SEE RIVA128
+NAME STB nvidia 128
+SEE RIVA128
+
+NAME STB Velocity 4400
+SEE RIVA TNT
+
NAME ASUS 3Dexplorer
SEE RIVA128
+NAME Guillemot Maxi Gamer Xentor
+SEE RIVA TNT2
+
+NAME Guillemot Maxi Gamer Xentor 32
+SEE RIVA TNT2
+
+NAME Creative Graphics Blaster TNT
+SEE RIVA TNT
+
+NAME Creative Graphics Blaster TNT2
+SEE RIVA TNT2
+
+# 3Dfx
+NAME Voodoo Banshee (generic)
+SERVER SVGA
+CHIPSET Voodo Banshee
+DRIVER tdfx
+
+NAME Voodoo3 (generic)
+SERVER SVGA
+CHIPSET Voodoo3
+DRIVER tdfx
+
+NAME Elsa Victory II
+SEE Voodoo Banshee (generic)
+
+NAME Diamond Monster Fusion
+SEE Voodoo Banshee (generic)
+
+NAME AOpen PA2010
+SEE Voodoo Banshee (generic)
+
+NAME Chaintech Desperado 3F10
+SEE Voodoo Banshee (generic)
+
+# 3DLabs
+
+NAME ELSA GLoria-L/MX
+CHIPSET GLINT MX
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME ELSA GLoria-L
+CHIPSET GLINT 500TX
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME ELSA GLoria-XL
+CHIPSET GLINT MX
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 3000
+CHIPSET GLINT 500TX
+SERVER 3DLabs
+DRIVER glint
+LINE Option "firegl_3000"
+NOCLOCKPROBE
+
+NAME ELSA GLoria-S
+CHIPSET PERMEDIA
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+LINE #VideoRam 8192
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 1000
+CHIPSET PERMEDIA
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+LINE #VideoRam 8192
+NOCLOCKPROBE
+
+NAME ELSA GLoria Synergy
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000/Office
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 1000 PRO
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Creative Blaster Exxtreme
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME AccelStar Permedia II AGP
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Leadtek WinFast 2300
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME 3DLabs Oxygen GMX
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Appian Jeronimo 2000
+CHIPSET PERMEDIA 3
+SERVER XFree86
+DRIVER glint
+NOCLOCKPROBE
+
# Alliance Semiconductor
NAME Diamond Stealth Video 2500
CHIPSET Alliance AT24
SERVER SVGA
+DRIVER apm
NOCLOCKPROBE
NAME AT3D
CHIPSET Alliance AT3D
SERVER SVGA
+DRIVER apm
NOCLOCKPROBE
LINE #Option "no_accel"
@@ -1966,26 +3004,68 @@ SEE AT3D
NAME Hercules Stingray 128 3D
SEE AT3D
-# Misc
+# NeoMagic
-NAME Techworks Ultimate 3D
-CHIPSET CL-GD5464
-SEE Cirrus Logic GD5464
+NAME NeoMagic (laptop/notebook)
+CHIPSET MagicGraph 128 series
+SERVER SVGA
+DRIVER neomagic
+LINE # Chipset "NM2160"
+LINE # IOBase 0xfea00000
+LINE # MemBase 0xfd000000
+LINE # VideoRam 2048
+LINE # DacSpeed 90
+LINE # Option "linear"
+LINE # Option "nolinear"
+LINE # Option "sw_cursor"
+LINE # Option "hw_cursor"
+LINE # Option "no_accel"
+LINE # Option "intern_disp"
+LINE # Option "extern_disp"
+LINE # Option "mmio"
+LINE # Option "no_mmio"
+LINE # Option "lcd_center"
+LINE # Option "no_stretch"
+
+# Epson SPC8110
+
+NAME EPSON SPC8110 (CardPC)
+CHIPSET SPC8110
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # Chipset "spc8110"
+LINE # MemBase 0x03e00000
+LINE # VideoRam 1024
+LINE # Option "nolinear"
+LINE # Option "sw_cursor"
+LINE # Option "noaccel"
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conservative"
-NAME VideoLogic GrafixStar 550
-CHIPSET CL-GD5464
-SEE Cirrus Logic GD5464
+# Silicon Motion, Inc.
-NAME Jaton Video-70P
-CHIPSET CL-GD5464
-SEE Cirrus Logic GD5464
+NAME Silicon Motion Lynx family
+CHIPSET Lynx
+SERVER SVGA
+DRIVER siliconmotion
+NOCLOCKPROBE
-NAME Jaton Video-58P
-SEE ET6000 (generic)
+# Rendition
NAME Rendition Verite 1000
CHIPSET Verite 1000
-SEE Unsupported VGA compatible
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # Option "sw_cursor"
+
+NAME Rendition Verite 2x00
+CHIPSET Verite 2x00
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # Option "sw_cursor"
NAME Creative Labs 3D Blaster PCI (Verite 1000)
SEE Rendition Verite 1000
@@ -1996,8 +3076,55 @@ SEE Rendition Verite 1000
NAME Sierra Screaming 3D
SEE Rendition Verite 1000
-NAME NeoMagic (laptop/notebook)
-CHIPSET NeoMagic 128/V/ZV
-SEE Unsupported VGA compatible
+NAME Miro CRYSTAL VRX
+SEE Rendition Verite 1000
+
+NAME Diamond Stealth II S220
+CHIPSET Verite 2100
+SEE Rendition Verite 2x00
+
+NAME Hercules Thriller3D
+CHIPSET Verite 2200
+SEE Rendition Verite 2x00
+
+# Digital
+
+NAME Digital 8-plane TGA (UDB/Multia)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt485
+
+NAME Digital 8-plane TGA (ZLXp-E1)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt485
+
+NAME Digital 24-plane TGA (ZLXp-E2)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt463
+
+NAME Digital 24-plane+3D TGA (ZLXp-E3)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt463
+
+# i810
+
+NAME Intel 810
+SERVER SVGA
+DRIVER i810
+
+# i740
+
+NAME Intel 740 (generic)
+SERVER SVGA
+DRIVER i740
+
+# Misc
END
diff --git a/hw/xfree86/utils/xorgconfig/cards.c b/hw/xfree86/utils/xorgconfig/cards.c
index a714d04ca..8aac06606 100644
--- a/hw/xfree86/utils/xorgconfig/cards.c
+++ b/hw/xfree86/utils/xorgconfig/cards.c
@@ -1,10 +1,10 @@
-/* $Xorg: cards.c,v 1.3 2000/08/17 19:53:05 cpqbld Exp $ */
+/* $XConsortium: cards.c /main/9 1996/10/19 18:15:32 kaleb $ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.c,v 3.11.2.1 1998/01/18 10:35:45 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.c,v 3.17 2002/05/31 18:46:04 dawes Exp $ */
/*
* Functions to manipulate card database.
@@ -22,6 +22,7 @@
* NAME <name of card>
* CHIPSET <chipset description>
* SERVER <server name>
+ * DRIVER <driver name>
*
* Optional keywords:
* RAMDAC <ramdac identifier>
@@ -47,16 +48,13 @@ int lastcard;
Card card[MAX_CARDS];
-void sort_database();
-
-static int getline(f, l)
-FILE *f;
-char *l;
+static int
+getnextline(FILE *f, char *l)
{
if (fgets(l, 128, f) == NULL)
return -1;
-#ifdef __EMX__
+#ifdef __UNIXOS2__
{
char *p = strchr(l,'\r');
if (p) {
@@ -68,9 +66,8 @@ char *l;
return 0;
}
-static void appendstring(destp, src)
- char **destp;
- char *src;
+static void
+appendstring(char **destp, char *src)
{
char *newstr;
newstr = malloc(strlen(*destp) + strlen(src) + 1);
@@ -81,7 +78,8 @@ static void appendstring(destp, src)
*destp = newstr;
}
-int lookupcard( char *name ) {
+int
+lookupcard(char *name) {
int i;
for (i = 0; i <= lastcard; i++)
if (strcmp(name, card[i].name) == 0)
@@ -109,7 +107,7 @@ int parse_database() {
int i, lineno;
char filename[128];
-#ifndef __EMX__
+#ifndef __UNIXOS2__
strcpy(filename, CARD_DATABASE_FILE);
#else
strcpy(filename, (char*)__XOS2RedirRoot(CARD_DATABASE_FILE));
@@ -122,7 +120,7 @@ int parse_database() {
lineno = 0;
for (;;) {
- if (getline(f, buf))
+ if (getnextline(f, buf))
break;
lineno++;
if (buf[0] == '#')
@@ -133,7 +131,6 @@ int parse_database() {
break;
if (strncmp(buf, "LINE", 4) == 0 && lastcard>=0) {
/* Line of Device comment. */
- char *lines;
/* Append to existing lines. */
appendstring(&card[lastcard].lines, buf + 5);
continue;
@@ -158,7 +155,9 @@ int parse_database() {
card[lastcard].name = malloc(strlen(buf + 5) + 1);
strcpy(card[lastcard].name, buf + 5);
card[lastcard].chipset = NULL;
- card[lastcard].ramdac = NULL;
+ card[lastcard].server = NULL;
+ card[lastcard].driver = NULL;
+ card[lastcard].ramdac = NULL;
card[lastcard].clockchip = NULL;
card[lastcard].dacspeed = NULL;
card[lastcard].flags = 0;
@@ -182,6 +181,8 @@ int parse_database() {
card[lastcard].chipset = card[i].chipset;
if (card[lastcard].server == NULL)
card[lastcard].server = card[i].server;
+ if (card[lastcard].driver == NULL)
+ card[lastcard].driver = card[i].driver;
if (card[lastcard].ramdac == NULL)
card[lastcard].ramdac = card[i].ramdac;
if (card[lastcard].clockchip == NULL)
@@ -204,6 +205,12 @@ int parse_database() {
strcpy(card[lastcard].server, buf + 7);
continue;
}
+ if (strncmp(buf, "DRIVER", 6) == 0) {
+ /* Driver identifier. */
+ card[lastcard].driver = malloc(strlen(buf + 7) + 1);
+ strcpy(card[lastcard].driver, buf + 7);
+ continue;
+ }
if (strncmp(buf, "RAMDAC", 6) == 0) {
/* Ramdac indentifier. */
card[lastcard].ramdac = malloc(strlen(buf + 7) + 1);
@@ -232,12 +239,12 @@ int parse_database() {
continue;
}
/* test for missing required fields */
- if (card[lastcard].server == NULL) {
- fprintf(stderr, "Warning SERVER specification missing "
+ if (card[lastcard].driver == NULL) {
+ fprintf(stderr, "Warning DRIVER specification missing "
"in Card database entry %s (line %d).\n",
card[lastcard].name, lineno);
keypress();
- card[lastcard].server = "unknown";
+ card[lastcard].driver = "unknown";
}
if (card[lastcard].chipset == NULL) {
fprintf(stderr, "Warning CHIPSET specification missing "
@@ -266,20 +273,14 @@ int parse_database() {
return 0;
}
-#ifdef __STDC__
-#define CONST const
-#else
-#define CONST
-#endif
-
-static int compare_card(e1, e2)
- CONST void *e1;
- CONST void *e2;
+static int
+compare_card(const void *e1, const void *e2)
{
return strcmp(((Card *)e1)->name, ((Card *)e2)->name);
}
-void sort_database() {
+void
+sort_database() {
/* Each element is a bunch of words, but nothing too bad. */
qsort(card, lastcard + 1, sizeof(Card), compare_card);
}
diff --git a/hw/xfree86/utils/xorgconfig/cards.h b/hw/xfree86/utils/xorgconfig/cards.h
index 11976d978..c5299e899 100644
--- a/hw/xfree86/utils/xorgconfig/cards.h
+++ b/hw/xfree86/utils/xorgconfig/cards.h
@@ -1,10 +1,10 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.h,v 3.3 1996/12/23 07:04:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.h,v 3.5 1999/07/05 12:12:06 dawes Exp $ */
-/* $Xorg: cards.h,v 1.3 2000/08/17 19:53:05 cpqbld Exp $ */
+/* $XConsortium: cards.h /main/3 1996/02/21 18:12:53 kaleb $ */
#ifndef CARD_DATABASE_FILE
#define CARD_DATABASE_FILE "Cards"
@@ -16,7 +16,8 @@ typedef struct {
char *name; /* Name of the card. */
char *chipset; /* Chipset (decriptive). */
char *server; /* Server identifier. */
- char *ramdac; /* Ramdac identifier. */
+ char *driver; /* Driver identifier. */
+ char *ramdac; /* Ramdac identifier. */
char *clockchip; /* Clockchip identifier. */
char *dacspeed; /* DAC speed rating. */
int flags;
@@ -31,6 +32,7 @@ extern int lastcard;
extern Card card[MAX_CARDS];
-
-int parse_database();
-
+extern int lookupcard ( char *name );
+extern int parse_database ( void );
+extern void sort_database ( void );
+extern void keypress ( void );
diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c
index 76e71aeee..61b560800 100644
--- a/hw/xnest/Color.c
+++ b/hw/xnest/Color.c
@@ -30,8 +30,6 @@ is" without express or implied warranty.
#include "XNWindow.h"
#include "Args.h"
-#define lowbit(x) ((x) & (~(x) + 1))
-
static ColormapPtr InstalledMaps[MAXSCREENS];
Bool xnestCreateColormap(pCmap)
diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index 6915df7a2..c20ec940a 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Cursor.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "screenint.h"
@@ -26,7 +28,7 @@ is" without express or implied warranty.
#include "Display.h"
#include "Screen.h"
-#include "Cursor.h"
+#include "XNCursor.h"
#include "Visual.h"
#include "Keyboard.h"
#include "Args.h"
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index 5f3bdb9a5..d8cefcc6f 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -12,10 +12,11 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.c,v 3.4 2001/10/28 03:34:10 tsi Exp $ */
-#include "X.h"
-#include "Xproto.h"
+#include <X11/X.h>
+#include <X11/Xproto.h>
#include "screenint.h"
#include "input.h"
#include "misc.h"
@@ -89,7 +90,7 @@ void xnestOpenDisplay(argc, argv)
break;
}
if (xnestDefaultVisualIndex == UNDEFINED)
- FatalError("Uable to find desird default visual.\n");
+ FatalError("Unable to find desired default visual.\n");
}
else {
vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay,
@@ -184,8 +185,6 @@ void xnestOpenDisplay(argc, argv)
void xnestCloseDisplay()
{
- int i;
-
if (!xnestDoFullGeneration || !xnestDisplay) return;
/*
diff --git a/hw/xnest/Display.h b/hw/xnest/Display.h
index 3699d18d5..14ed0bb0a 100644
--- a/hw/xnest/Display.h
+++ b/hw/xnest/Display.h
@@ -12,6 +12,7 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.6 2001/01/17 22:36:55 dawes Exp $ */
#ifndef XNESTCOMMON_H
#define XNESTCOMMON_H
@@ -19,7 +20,7 @@ is" without express or implied warranty.
#define UNDEFINED -1
#define MAXDEPTH 32
-#define MAXVISUALSPERDEPTH 6
+#define MAXVISUALSPERDEPTH 256
extern Display *xnestDisplay;
extern XVisualInfo *xnestVisuals;
diff --git a/hw/xnest/Drawable.h b/hw/xnest/Drawable.h
index 47b723731..6f52b286b 100644
--- a/hw/xnest/Drawable.h
+++ b/hw/xnest/Drawable.h
@@ -12,12 +12,13 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Drawable.h,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
#ifndef XNESTDRAWABLE_H
#define XNESTDRAWABLE_H
#include "XNWindow.h"
-#include "Pixmap.h"
+#include "XNPixmap.h"
#define xnestDrawable(pDrawable) \
((pDrawable)->type == DRAWABLE_WINDOW ? \
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 760f1962a..729296f22 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Events.c,v 1.2 2001/08/01 00:44:57 tsi Exp $ */
+
#include "X.h"
#define NEED_EVENTS
#include "Xproto.h"
@@ -22,8 +24,11 @@ is" without express or implied warranty.
#include "windowstr.h"
#include "servermd.h"
+#include "mi.h"
+
#include "Xnest.h"
+#include "Color.h"
#include "Display.h"
#include "Screen.h"
#include "XNWindow.h"
diff --git a/hw/xnest/Font.c b/hw/xnest/Font.c
index 562db362d..b30cf45bf 100644
--- a/hw/xnest/Font.c
+++ b/hw/xnest/Font.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Font.c,v 3.5 2001/01/17 22:36:55 dawes Exp $ */
+
#include "X.h"
#include "Xatom.h"
#include "Xproto.h"
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index 3e16c95c2..0816957de 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/GC.c,v 3.6 2001/10/28 03:34:11 tsi Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "gcstruct.h"
@@ -130,11 +132,12 @@ void xnestChangeGC(pGC, mask)
if (mask & GCFillRule)
values.fill_rule = pGC->fillRule;
- if (mask & GCTile)
+ if (mask & GCTile) {
if (pGC->tileIsPixel)
mask &= ~GCTile;
else
values.tile = xnestPixmap(pGC->tile.pixmap);
+ }
if (mask & GCStipple)
values.stipple = xnestPixmap(pGC->stipple);
@@ -279,9 +282,8 @@ void xnestChangeClip(pGC, type, pValue, nRects)
* other parts of server can only deal with CT_NONE,
* CT_PIXMAP and CT_REGION client clips.
*/
- pGC->clientClip = (pointer) (*pGC->pScreen->RectsToRegion)(nRects,
- (xRectangle *)pValue,
- type);
+ pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nRects,
+ (xRectangle *)pValue, type);
xfree(pValue);
pValue = pGC->clientClip;
type = CT_REGION;
@@ -326,8 +328,6 @@ void xnestCopyClip(pGCDst, pGCSrc)
GCPtr pGCDst;
{
RegionPtr pRgn;
- int nRects, size;
- xRectangle *pRects;
switch (pGCSrc->clientClipType)
{
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
index 745fd602f..3af24c35a 100644
--- a/hw/xnest/GCOps.c
+++ b/hw/xnest/GCOps.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/GCOps.c,v 3.4 2001/01/17 22:36:55 dawes Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "miscstruct.h"
diff --git a/hw/xnest/Handlers.c b/hw/xnest/Handlers.c
index 6feddebd7..d65116b0d 100644
--- a/hw/xnest/Handlers.c
+++ b/hw/xnest/Handlers.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Handlers.c,v 1.2 2001/08/01 00:44:57 tsi Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "screenint.h"
@@ -24,6 +26,7 @@ is" without express or implied warranty.
#include "Xnest.h"
#include "Display.h"
+#include "Events.h"
#include "Handlers.h"
void xnestBlockHandler(blockData, pTimeout, pReadMask)
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 00cd4f9ac..665aec182 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Init.c,v 3.24 2003/01/15 02:34:14 torrey Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "screenint.h"
@@ -20,6 +22,8 @@ is" without express or implied warranty.
#include "scrnintstr.h"
#include "windowstr.h"
#include "servermd.h"
+#include "mi.h"
+#include "fontstruct.h"
#include "Xnest.h"
@@ -53,7 +57,8 @@ void InitOutput(screenInfo, argc, argv)
screenInfo->numPixmapFormats = 0;
for (i = 0; i < xnestNumPixmapFormats; i++)
for (j = 0; j < xnestNumDepths; j++)
- if (xnestPixmapFormats[i].depth == xnestDepths[j]) {
+ if ((xnestPixmapFormats[i].depth == 1) ||
+ (xnestPixmapFormats[i].depth == xnestDepths[j])) {
screenInfo->formats[screenInfo->numPixmapFormats].depth =
xnestPixmapFormats[i].depth;
screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
@@ -61,6 +66,7 @@ void InitOutput(screenInfo, argc, argv)
screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
xnestPixmapFormats[i].scanline_pad;
screenInfo->numPixmapFormats++;
+ break;
}
xnestWindowPrivateIndex = AllocateWindowPrivateIndex();
@@ -81,8 +87,8 @@ void InitInput(argc, argv)
int argc;
char *argv[];
{
- DevicePtr ptr, kbd;
-
+ pointer ptr, kbd;
+
ptr = AddInputDevice(xnestPointerProc, TRUE);
kbd = AddInputDevice(xnestKeyboardProc, TRUE);
@@ -111,11 +117,39 @@ void ddxGiveUp()
AbortDDX();
}
+#ifdef __DARWIN__
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+
+void GlxExtensionInit();
+void GlxWrapInitVisuals(void *procPtr);
+
+void
+DarwinGlxExtensionInit()
+{
+ GlxExtensionInit();
+}
+
+void
+DarwinGlxWrapInitVisuals(
+ void *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+#endif
+
void OsVendorInit()
{
return;
}
+void OsVendorFatalError()
+{
+ return;
+}
+
/* this is just to get the server to link on AIX */
#ifdef AIXV3
int SelectWaitTime = 10000; /* usec */
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index ce5d57f5d..107caee90 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Keyboard.c,v 1.8 2001/10/28 03:34:11 tsi Exp $ */
+
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
@@ -29,6 +31,63 @@ is" without express or implied warranty.
#include "Keyboard.h"
#include "Args.h"
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBconfig.h>
+
+extern Bool XkbQueryExtension(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ int * /* opcodeReturn */,
+ int * /* eventBaseReturn */,
+ int * /* errorBaseReturn */,
+ int * /* majorRtrn */,
+ int * /* minorRtrn */
+#endif
+);
+
+extern XkbDescPtr XkbGetKeyboard(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+#endif
+);
+
+extern Status XkbGetControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+#ifndef XKB_BASE_DIRECTORY
+#define XKB_BASE_DIRECTORY "/usr/X11R6/lib/X11/xkb/"
+#endif
+#ifndef XKB_CONFIG_FILE
+#define XKB_CONFIG_FILE "X0-config.keyboard"
+#endif
+#ifndef XKB_DFLT_RULES_FILE
+#define XKB_DFLT_RULES_FILE "xfree86"
+#endif
+#ifndef XKB_DFLT_KB_LAYOUT
+#define XKB_DFLT_KB_LAYOUT "us"
+#endif
+#ifndef XKB_DFLT_KB_MODEL
+#define XKB_DFLT_KB_MODEL "pc101"
+#endif
+#ifndef XKB_DFLT_KB_VARIANT
+#define XKB_DFLT_KB_VARIANT NULL
+#endif
+#ifndef XKB_DFLT_KB_OPTIONS
+#define XKB_DFLT_KB_OPTIONS NULL
+#endif
+
+extern Bool noXkbExtension;
+#endif
+
void xnestBell(volume, pDev, ctrl, cls)
int volume;
DeviceIntPtr pDev;
@@ -42,6 +101,7 @@ void xnestChangeKeyboardControl(pDev, ctrl)
DeviceIntPtr pDev;
KeybdCtrl *ctrl;
{
+#if 0
unsigned long value_mask;
XKeyboardControl values;
int i;
@@ -73,6 +133,7 @@ void xnestChangeKeyboardControl(pDev, ctrl)
values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff;
XChangeKeyboardControl(xnestDisplay, value_mask, &values);
}
+#endif
}
int xnestKeyboardProc(pDev, onoff, argc, argv)
@@ -120,9 +181,9 @@ int xnestKeyboardProc(pDev, onoff, argc, argv)
for (j = 0; j < 8; j++)
for(i = 0; i < modifier_keymap->max_keypermod; i++) {
CARD8 keycode;
- if (keycode =
+ if ((keycode =
modifier_keymap->
- modifiermap[j * modifier_keymap->max_keypermod + i])
+ modifiermap[j * modifier_keymap->max_keypermod + i]))
modmap[keycode] |= 1<<j;
}
XFreeModifiermap(modifier_keymap);
@@ -132,6 +193,10 @@ int xnestKeyboardProc(pDev, onoff, argc, argv)
keySyms.mapWidth = mapWidth;
keySyms.map = keymap;
+#ifdef XKB
+ if (noXkbExtension) {
+XkbError:
+#endif
XGetKeyboardControl(xnestDisplay, &values);
memmove((char *) defaultKeyboardControl.autoRepeats,
@@ -139,7 +204,73 @@ int xnestKeyboardProc(pDev, onoff, argc, argv)
InitKeyboardDeviceStruct(pDev, &keySyms, modmap,
xnestBell, xnestChangeKeyboardControl);
+#ifdef XKB
+ } else {
+ FILE *file;
+ XkbConfigRtrnRec config;
+
+ XkbComponentNamesRec names;
+ char *rules, *model, *layout, *variants, *options;
+
+ XkbDescPtr xkb;
+ int op, event, error, major, minor;
+
+ if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) == 0) {
+ ErrorF("Unable to initialize XKEYBOARD extension.\n");
+ goto XkbError;
+ }
+ xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ if (xkb == NULL || xkb->geom == NULL) {
+ ErrorF("Couldn't get keyboard.\n");
+ goto XkbError;
+ }
+ XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
+
+ memset(&names, 0, sizeof(XkbComponentNamesRec));
+ rules = XKB_DFLT_RULES_FILE;
+ model = XKB_DFLT_KB_MODEL;
+ layout = XKB_DFLT_KB_LAYOUT;
+ variants = XKB_DFLT_KB_VARIANT;
+ options = XKB_DFLT_KB_OPTIONS;
+ if (XkbInitialMap) {
+ if ((names.keymap = strchr(XkbInitialMap, '/')) != NULL)
+ ++names.keymap;
+ else
+ names.keymap = XkbInitialMap;
+ }
+
+ if ((file = fopen(XKB_BASE_DIRECTORY XKB_CONFIG_FILE, "r")) != NULL) {
+ if (XkbCFParse(file, XkbCFDflts, xkb, &config) == 0) {
+ ErrorF("Error parsing config file.\n");
+ fclose(file);
+ goto XkbError;
+ }
+ if (config.rules_file)
+ rules = config.rules_file;
+ if (config.model)
+ model = config.model;
+ if (config.layout)
+ layout = config.layout;
+ if (config.variant)
+ variants = config.variant;
+ if (config.options)
+ options = config.options;
+
+ fclose(file);
+ }
+
+ XkbSetRulesDflts(rules, model, layout, variants, options);
+ XkbInitKeyboardDeviceStruct((pointer)pDev, &names, &keySyms, modmap,
+ xnestBell, xnestChangeKeyboardControl);
+ XkbDDXChangeControls((pointer)pDev, xkb->ctrls, xkb->ctrls);
+ XkbFreeKeyboard(xkb, 0, False);
+ }
+#endif
+#ifdef _XSERVER64
+ xfree(keymap);
+#else
XFree(keymap);
+#endif
break;
case DEVICE_ON:
xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 51180a4f5..f93dcac52 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Pixmap.c,v 3.6 2003/01/10 13:29:40 eich Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "miscstruct.h"
@@ -26,7 +28,11 @@ is" without express or implied warranty.
#include "Display.h"
#include "Screen.h"
-#include "Pixmap.h"
+#include "XNPixmap.h"
+
+#ifdef PIXPRIV
+int xnestPixmapPrivateIndex;
+#endif
PixmapPtr xnestCreatePixmap(pScreen, width, height, depth)
ScreenPtr pScreen;
@@ -36,7 +42,7 @@ PixmapPtr xnestCreatePixmap(pScreen, width, height, depth)
{
PixmapPtr pPixmap;
- pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + sizeof(xnestPrivPixmap));
+ pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
if (!pPixmap)
return NullPixmap;
pPixmap->drawable.type = DRAWABLE_PIXMAP;
@@ -52,7 +58,12 @@ PixmapPtr xnestCreatePixmap(pScreen, width, height, depth)
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
+#ifdef PIXPRIV
+ pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
+#else
pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
@@ -82,7 +93,6 @@ RegionPtr xnestPixmapToRegion(pPixmap)
register int x, y;
unsigned long previousPixel, currentPixel;
BoxRec Box;
- int nWidth;
Bool overlap;
ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index 4d718cb5d..bef6a75dd 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Screen.c,v 3.11 2003/01/10 13:29:40 eich Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "scrnintstr.h"
@@ -25,27 +27,27 @@ is" without express or implied warranty.
#include "Display.h"
#include "Screen.h"
-#include "Args.h"
#include "XNGC.h"
#include "GCOps.h"
#include "Drawable.h"
#include "XNFont.h"
#include "Color.h"
-#include "Cursor.h"
+#include "XNCursor.h"
#include "Visual.h"
#include "Events.h"
#include "Init.h"
+#include "mipointer.h"
#include "Args.h"
-extern Bool miModifyPixmapHeader();
-extern Bool miCreateScreenResources();
-extern Bool miCloseScreen();
-extern Bool miScreenInit();
extern Window xnestParentWindow;
Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS];
+#ifdef PIXPRIV
+int xnestScreenGeneration = -1;
+#endif
+
ScreenPtr xnestScreen(window)
Window window;
{
@@ -102,6 +104,28 @@ static Bool xnestSaveScreen(pScreen, what)
}
}
+static Bool
+xnestCursorOffScreen (ppScreen, x, y)
+ ScreenPtr *ppScreen;
+ int *x, *y;
+{
+ return FALSE;
+}
+
+static void
+xnestCrossScreen (pScreen, entering)
+ ScreenPtr pScreen;
+ Bool entering;
+{
+}
+
+static miPointerScreenFuncRec xnestPointerCursorFuncs =
+{
+ xnestCursorOffScreen,
+ xnestCrossScreen,
+ miPointerWarpCursor
+};
+
Bool xnestOpenScreen(index, pScreen, argc, argv)
int index;
register ScreenPtr pScreen;
@@ -123,6 +147,17 @@ Bool xnestOpenScreen(index, pScreen, argc, argv)
sizeof(xnestPrivGC))))
return False;
+#ifdef PIXPRIV
+ if (xnestScreenGeneration != serverGeneration) {
+ if ((xnestPixmapPrivateIndex = AllocatePixmapPrivateIndex()) < 0)
+ return False;
+ xnestScreenGeneration = serverGeneration;
+ }
+
+ if (!AllocatePixmapPrivate(pScreen,xnestPixmapPrivateIndex,
+ sizeof (xnestPrivPixmap)))
+ return False;
+#endif
visuals = (VisualPtr)xalloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0;
@@ -160,6 +195,9 @@ Bool xnestOpenScreen(index, pScreen, argc, argv)
(VisualID *)xalloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
numDepths++;
}
+ if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) {
+ FatalError("Visual table overflow");
+ }
depths[depthIndex].vids[depths[depthIndex].numVids] =
visuals[numVisuals].vid;
depths[depthIndex].numVids++;
@@ -179,7 +217,11 @@ Bool xnestOpenScreen(index, pScreen, argc, argv)
visuals[xnestDefaultVisualIndex].nplanes, /* rootDepth */
numDepths, depths,
visuals[xnestDefaultVisualIndex].vid, /* root visual */
- numVisuals, visuals, NULL);
+ numVisuals, visuals);
+
+ miInitializeBackingStore(pScreen);
+
+ miDCInitialize(pScreen, &xnestPointerCursorFuncs);
pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay,
DefaultScreen(xnestDisplay)) /
diff --git a/hw/xnest/TestExt.c b/hw/xnest/TestExt.c
index 7898bcd14..7f5a5907d 100644
--- a/hw/xnest/TestExt.c
+++ b/hw/xnest/TestExt.c
@@ -12,13 +12,18 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
-#include "X.h"
-#include "Xproto.h"
+/* $XFree86: xc/programs/Xserver/hw/xnest/TestExt.c,v 3.5 2001/08/27 17:41:00 dawes Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xlib.h>
+#undef Bool
#include "screenint.h"
#include "input.h"
#include "misc.h"
#include "scrnintstr.h"
#include "servermd.h"
+#include "mipointer.h"
#define XTestSERVER_SIDE
#include "xtestext1.h"
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index e345b49d1..a5dfc2de1 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -12,6 +12,8 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Window.c,v 3.7 2001/10/28 03:34:11 tsi Exp $ */
+
#include "X.h"
#include "Xproto.h"
#include "gcstruct.h"
@@ -22,6 +24,8 @@ is" without express or implied warranty.
#include "scrnintstr.h"
#include "region.h"
+#include "mi.h"
+
#include "Xnest.h"
#include "Display.h"
@@ -288,23 +292,26 @@ Bool xnestChangeWindowAttributes(pWin, mask)
break;
}
- if (mask & CWBackPixel)
+ if (mask & CWBackPixel) {
if (pWin->backgroundState == BackgroundPixel)
attributes.background_pixel = xnestPixel(pWin->background.pixel);
else
mask &= ~CWBackPixel;
+ }
- if (mask & CWBorderPixmap)
+ if (mask & CWBorderPixmap) {
if (pWin->borderIsPixel)
mask &= ~CWBorderPixmap;
else
attributes.border_pixmap = xnestPixmap(pWin->border.pixmap);
+ }
- if (mask & CWBorderPixel)
+ if (mask & CWBorderPixel) {
if (pWin->borderIsPixel)
attributes.border_pixel = xnestPixel(pWin->border.pixel);
else
mask &= ~CWBorderPixel;
+ }
if (mask & CWBitGravity)
attributes.bit_gravity = pWin->bitGravity;
@@ -488,7 +495,6 @@ void xnestShapeWindow(pWin)
BoxPtr pBox;
XRectangle rect;
int i;
- Bool overlap;
if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape,
wBoundingShape(pWin))) {
diff --git a/hw/xnest/Xnest.h b/hw/xnest/Xnest.h
index 5ced40e28..64b09de7e 100644
--- a/hw/xnest/Xnest.h
+++ b/hw/xnest/Xnest.h
@@ -28,6 +28,7 @@ other dealings in this Software without prior written authorization
from the X Consortium.
*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Xnest.h,v 1.3 2001/08/28 16:48:08 tsi Exp $ */
/*
** Machines with a 64 bit library interface and a 32 bit server require
@@ -65,8 +66,8 @@ typedef XID KeySym64;
#endif /*_XSERVER64*/
#define GC XlibGC
-#include "Xlib.h"
-#include "Xutil.h"
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#undef GC
diff --git a/hw/xnest/Xnest.man.pre b/hw/xnest/Xnest.man.pre
index 608c30dd1..474569a47 100644
--- a/hw/xnest/Xnest.man.pre
+++ b/hw/xnest/Xnest.man.pre
@@ -24,7 +24,10 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XNEST 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/xnest/Xnest.man,v 1.6 2001/01/27 18:21:00 dawes Exp $
+.\"
+.TH XNEST 1 __xorgversion__
.SH NAME
Xnest \- a nested X server
.SH SYNOPSIS