summaryrefslogtreecommitdiff
path: root/hw/xfree86
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:29:01 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:29:01 +0000
commit90f1536dd315cd265bfc7ef35058761a65a01734 (patch)
treece1f7aed9444ad2577d62a6e5a2dd36008771c6c /hw/xfree86
parentd461855a73d8c9f51a18673aef7ce88f94a71629 (diff)
Initial revisionXORG-STABLE
Diffstat (limited to 'hw/xfree86')
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c354
-rw-r--r--hw/xfree86/common/xf86Versions.c77
-rw-r--r--hw/xfree86/common/xf86xvpriv.h86
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.h144
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dgaext.h8
-rw-r--r--hw/xfree86/dummylib/logvwrite.c18
-rw-r--r--hw/xfree86/getconfig/cfg.man.pre138
-rw-r--r--hw/xfree86/getconfig/cfg.sample111
-rw-r--r--hw/xfree86/getconfig/getconfig45
-rw-r--r--hw/xfree86/getconfig/getconfig.man.pre98
-rw-r--r--hw/xfree86/getconfig/getconfig.pl429
11 files changed, 1508 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
new file mode 100644
index 000000000..7c773fee6
--- /dev/null
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -0,0 +1,354 @@
+/* $DHD: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.15 2003/09/24 19:39:36 dawes Exp $ */
+
+/*
+ * Copyright 2003 by David H. Dawes.
+ * Copyright 2003 by X-Oz Technologies.
+ * All rights reserved.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+ * and author(s) 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 copyright holder(s) and author(s).
+ *
+ * Author: David Dawes <dawes@XFree86.Org>.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.2 2003/11/03 05:11:01 tsi Exp $ */
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Sections for the default built-in configuration.
+ */
+
+#define BUILTIN_MODULE_SECTION \
+ "Section \"Module\"\n" \
+ "\tLoad\t\"extmod\"\n" \
+ "\tLoad\t\"dbe\"\n" \
+ "\tLoad\t\"glx\"\n" \
+ "\tLoad\t\"freetype\"\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_DEVICE_NAME \
+ "\"Builtin Default %s Device %d\""
+
+#define BUILTIN_DEVICE_SECTION_PRE \
+ "Section \"Device\"\n" \
+ "\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \
+ "\tDriver\t\"%s\"\n"
+
+#define BUILTIN_DEVICE_SECTION_POST \
+ "EndSection\n\n"
+
+#define BUILTIN_DEVICE_SECTION \
+ BUILTIN_DEVICE_SECTION_PRE \
+ BUILTIN_DEVICE_SECTION_POST
+
+#define BUILTIN_MONITOR_NAME \
+ "\"Builtin Default Monitor\""
+
+#define BUILTIN_MONITOR_SECTION \
+ "Section \"Monitor\"\n" \
+ "\tIdentifier\t" BUILTIN_MONITOR_NAME "\n" \
+ "\tOption\t\"TargetRefresh\"\t\"75.0\"\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_SCREEN_NAME \
+ "\"Builtin Default %s Screen %d\""
+
+#define BUILTIN_SCREEN_SECTION \
+ "Section \"Screen\"\n" \
+ "\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
+ "\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
+ "\tMonitor\t" BUILTIN_MONITOR_NAME "\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_LAYOUT_SECTION_PRE \
+ "Section \"ServerLayout\"\n" \
+ "\tIdentifier\t\"Builtin Default Layout\"\n"
+
+#define BUILTIN_LAYOUT_SCREEN_LINE \
+ "\tScreen\t" BUILTIN_SCREEN_NAME "\n"
+
+#define BUILTIN_LAYOUT_SECTION_POST \
+ "EndSection\n\n"
+
+
+#ifndef GET_CONFIG_CMD
+#define GET_CONFIG_CMD "getconfig"
+#endif
+
+#ifndef GETCONFIG_DIR
+#define GETCONFIG_DIR PROJECTROOT "/lib/X11/getconfig"
+#endif
+
+#define GETCONFIG_WHITESPACE " \t\n"
+
+static const char **builtinConfig = NULL;
+static int builtinLines = 0;
+static const char *deviceList[] = {
+ "fbdev",
+ "vesa",
+ "vga",
+ NULL
+};
+
+/*
+ * A built-in config file is stored as an array of strings, with each string
+ * representing a single line. AppendToConfig() breaks up the string "s"
+ * into lines, and appends those lines it to builtinConfig.
+ */
+
+static void
+AppendToList(const char *s, const char ***list, int *lines)
+{
+ char *str, *newstr, *p;
+
+ str = xnfstrdup(s);
+ for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
+ (*lines)++;
+ *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+ newstr = xnfalloc(strlen(p) + 2);
+ strcpy(newstr, p);
+ strcat(newstr, "\n");
+ (*list)[*lines - 1] = newstr;
+ (*list)[*lines] = NULL;
+ }
+ xfree(str);
+}
+
+static void
+FreeList(const char ***list, int *lines)
+{
+ int i;
+
+ for (i = 0; i < *lines; i++) {
+ if ((*list)[i])
+ xfree((*list)[i]);
+ }
+ xfree(*list);
+ *list = NULL;
+ *lines = 0;
+}
+
+static void
+FreeConfig(void)
+{
+ FreeList(&builtinConfig, &builtinLines);
+}
+
+static void
+AppendToConfig(const char *s)
+{
+ AppendToList(s, &builtinConfig, &builtinLines);
+}
+
+Bool
+xf86AutoConfig(void)
+{
+ const char **p;
+ char buf[1024];
+ pciVideoPtr *pciptr, info = NULL;
+ char *driver = NULL;
+ FILE *gp = NULL;
+ ConfigStatus ret;
+
+ /* Find the primary device, and get some information about it. */
+ if (xf86PciVideoInfo) {
+ for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) {
+ if (xf86IsPrimaryPci(info)) {
+ break;
+ }
+ }
+ if (!info) {
+ ErrorF("Primary device is not PCI\n");
+ }
+ } else {
+ ErrorF("xf86PciVideoInfo is not set\n");
+ }
+
+ if (info) {
+ char *tmp;
+ char *path = NULL, *a, *b;
+ char *searchPath = NULL;
+
+ /*
+ * Look for the getconfig program first in the xf86ModulePath
+ * directories, then in BINDIR. If it isn't found in any of those
+ * locations, just use the normal search path.
+ */
+
+ if (xf86ModulePath) {
+ a = xnfstrdup(xf86ModulePath);
+ b = strtok(a, ",");
+ while (b) {
+ path = xnfrealloc(path,
+ strlen(b) + 1 + strlen(GET_CONFIG_CMD) + 1);
+ sprintf(path, "%s/%s", b, GET_CONFIG_CMD);
+ if (access(path, X_OK) == 0)
+ break;
+ b = strtok(NULL, ",");
+ }
+ if (!b) {
+ xfree(path);
+ path = NULL;
+ }
+ xfree(a);
+ }
+
+#ifdef BINDIR
+ if (!path) {
+ path = xnfstrdup(BINDIR "/" GET_CONFIG_CMD);
+ if (access(path, X_OK) != 0) {
+ xfree(path);
+ path = NULL;
+ }
+ }
+#endif
+
+ if (!path)
+ path = xnfstrdup(GET_CONFIG_CMD);
+
+ /*
+ * Build up the config file directory search path:
+ *
+ * /etc/X11
+ * PROJECTROOT/etc/X11
+ * xf86ModulePath
+ * PROJECTROOT/lib/X11/getconfig (GETCONFIG_DIR)
+ */
+
+ searchPath = xnfalloc(strlen("/etc/X11") + 1 +
+ strlen(PROJECTROOT "/etc/X11") + 1 +
+ (xf86ModulePath ? strlen(xf86ModulePath) : 0)
+ + 1 +
+ strlen(GETCONFIG_DIR) + 1);
+ strcpy(searchPath, "/etc/X11," PROJECTROOT "/etc/X11,");
+ if (xf86ModulePath && *xf86ModulePath) {
+ strcat(searchPath, xf86ModulePath);
+ strcat(searchPath, ",");
+ }
+ strcat(searchPath, GETCONFIG_DIR);
+
+ ErrorF("xf86AutoConfig: Primary PCI is %d:%d:%d\n",
+ info->bus, info->device, info->func);
+
+ snprintf(buf, sizeof(buf), "%s"
+#ifdef DEBUG
+ " -D"
+#endif
+ " -X %d"
+ " -I %s"
+ " -v 0x%04x -d 0x%04x -r 0x%02x -s 0x%04x"
+ " -b 0x%04x -c 0x%04x",
+ path,
+ (unsigned int)xf86GetVersion(),
+ searchPath,
+ info->vendor, info->chipType, info->chipRev,
+ info->subsysVendor, info->subsysCard,
+ info->class << 8 | info->subclass);
+ ErrorF("Running \"%s\"\n", buf);
+ gp = Popen(buf, "r");
+ if (gp) {
+ if (fgets(buf, sizeof(buf) - 1, gp)) {
+ buf[strlen(buf) - 1] = '\0';
+ tmp = strtok(buf, GETCONFIG_WHITESPACE);
+ if (tmp)
+ driver = xnfstrdup(tmp);
+ }
+ }
+ xfree(path);
+ xfree(searchPath);
+ }
+
+ AppendToConfig(BUILTIN_MODULE_SECTION);
+ AppendToConfig(BUILTIN_MONITOR_SECTION);
+
+ if (driver) {
+ snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE,
+ driver, 0, driver);
+ AppendToConfig(buf);
+ ErrorF("New driver is \"%s\"\n", driver);
+ buf[0] = '\t';
+ while (fgets(buf + 1, sizeof(buf) - 2, gp)) {
+ AppendToConfig(buf);
+ ErrorF("Extra line: %s", buf);
+ }
+ AppendToConfig(BUILTIN_DEVICE_SECTION_POST);
+ snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION,
+ driver, 0, driver, 0);
+ AppendToConfig(buf);
+ }
+
+ if (gp)
+ Pclose(gp);
+
+ for (p = deviceList; *p; p++) {
+ snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
+ AppendToConfig(buf);
+ snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
+ AppendToConfig(buf);
+ }
+
+ AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE);
+ if (driver) {
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0);
+ AppendToConfig(buf);
+ }
+ for (p = deviceList; *p; p++) {
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
+ AppendToConfig(buf);
+ }
+ AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
+
+#ifdef BUILTIN_EXTRA
+ AppendToConfig(BUILTIN_EXTRA);
+#endif
+
+ if (driver)
+ xfree(driver);
+
+ xf86MsgVerb(X_DEFAULT, 0,
+ "Using default built-in configuration (%d lines)\n",
+ builtinLines);
+
+ xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
+ for (p = builtinConfig; *p; p++)
+ xf86ErrorFVerb(3, "\t%s", *p);
+ xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
+
+ xf86setBuiltinConfig(builtinConfig);
+ ret = xf86HandleConfigFile(TRUE);
+ FreeConfig();
+ switch(ret) {
+ case CONFIG_OK:
+ return TRUE;
+ default:
+ xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
+ return FALSE;
+ }
+}
+
diff --git a/hw/xfree86/common/xf86Versions.c b/hw/xfree86/common/xf86Versions.c
new file mode 100644
index 000000000..7b20ef9ab
--- /dev/null
+++ b/hw/xfree86/common/xf86Versions.c
@@ -0,0 +1,77 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Versions.c,v 1.2 2003/08/24 20:01:19 dawes Exp $ */
+/*
+ * Copyright (c) 2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+ * and author(s) 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 copyright holder(s) and author(s).
+ */
+
+#include "xf86.h"
+#include "xf86OSmouse.h"
+#include "xf86OSKbd.h"
+
+static CARD32 registeredVersions[NUM_BUILTIN_IFS];
+
+CARD32
+xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flags)
+{
+ if (iface < 0 || iface >= NUM_BUILTIN_IFS) {
+ xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: Unexpected interface"
+ "query: %d\n", iface);
+ return 0;
+ }
+
+ if (registeredVersions[iface])
+ return registeredVersions[iface];
+
+ /* Most built-in interfaces are handled this way. */
+ switch (iface) {
+ case BUILTIN_IF_OSMOUSE:
+ return OS_MOUSE_VERSION_CURRENT;
+ case BUILTIN_IF_OSKBD:
+ return OS_KBD_VERSION_CURRENT;
+ default:
+ xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: internal error: "
+ "interface %d not handled\n", iface);
+ return 0;
+ }
+}
+
+Bool
+xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface, CARD32 version,
+ int flags)
+{
+ if (iface < 0 || iface >= NUM_BUILTIN_IFS) {
+ xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: "
+ "unexpected interface number: %d\n", iface);
+ return FALSE;
+ }
+ if (version == 0) {
+ xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: "
+ "versions must be greater than zero\n");
+ return FALSE;
+ }
+ registeredVersions[iface] = version;
+ return TRUE;
+}
+
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
new file mode 100644
index 000000000..0d1efdafb
--- /dev/null
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -0,0 +1,86 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h,v 1.2 2003/08/24 17:36:56 dawes Exp $ */
+
+/*
+ * Copyright (c) 2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+ * and author(s) 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 copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86XVPRIV_H_
+#define _XF86XVPRIV_H_
+
+#include "xf86xv.h"
+
+/*** These are DDX layer privates ***/
+
+extern int XF86XvScreenIndex;
+
+typedef struct {
+ DestroyWindowProcPtr DestroyWindow;
+ ClipNotifyProcPtr ClipNotify;
+ WindowExposuresProcPtr WindowExposures;
+ void (*AdjustFrame)(int, int, int, int);
+ Bool (*EnterVT)(int, int);
+ void (*LeaveVT)(int, int);
+ GCPtr videoGC;
+} XF86XVScreenRec, *XF86XVScreenPtr;
+
+typedef struct {
+ int flags;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ DrawablePtr pDraw;
+ unsigned char type;
+ unsigned int subWindowMode;
+ DDXPointRec clipOrg;
+ RegionPtr clientClip;
+ RegionPtr pCompositeClip;
+ Bool FreeCompositeClip;
+ XvAdaptorRecPrivatePtr AdaptorRec;
+ XvStatus isOn;
+ Bool moved;
+ int vid_x, vid_y, vid_w, vid_h;
+ int drw_x, drw_y, drw_w, drw_h;
+ DevUnion DevPriv;
+} XvPortRecPrivate, *XvPortRecPrivatePtr;
+
+typedef struct _XF86XVWindowRec{
+ XvPortRecPrivatePtr PortRec;
+ struct _XF86XVWindowRec *next;
+} XF86XVWindowRec, *XF86XVWindowPtr;
+
+#endif /* _XF86XVPRIV_H_ */
diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
new file mode 100644
index 000000000..cc717c31b
--- /dev/null
+++ b/hw/xfree86/dixmods/extmod/modinit.h
@@ -0,0 +1,144 @@
+/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.2 2003/09/13 21:33:04 dawes Exp $ */
+
+#ifndef INITARGS
+#define INITARGS void
+#endif
+
+#ifdef SHAPE
+extern void ShapeExtensionInit(INITARGS);
+#define _SHAPE_SERVER_ /* don't want Xlib structures */
+#include "shapestr.h"
+#endif
+
+#ifdef MULTIBUFFER
+extern void MultibufferExtensionInit(INITARGS);
+#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
+#include "multibufst.h"
+#endif
+
+#ifdef MITMISC
+extern void MITMiscExtensionInit(INITARGS);
+#define _MITMISC_SERVER_
+#include "mitmiscstr.h"
+#endif
+
+#ifdef XTEST
+extern void XTestExtensionInit(INITARGS);
+#define _XTEST_SERVER_
+#include "XTest.h"
+#include "xteststr.h"
+#endif
+
+#if 1
+extern void XTestExtension1Init(INITARGS);
+#endif
+
+#ifdef BIGREQS
+extern void BigReqExtensionInit(INITARGS);
+#include "bigreqstr.h"
+#endif
+
+#ifdef XSYNC
+extern void SyncExtensionInit(INITARGS);
+#define _SYNC_SERVER
+#include "sync.h"
+#include "syncstr.h"
+#endif
+
+#ifdef SCREENSAVER
+extern void ScreenSaverExtensionInit (INITARGS);
+#include "saver.h"
+#endif
+
+#ifdef XCMISC
+extern void XCMiscExtensionInit(INITARGS);
+#include "xcmiscstr.h"
+#endif
+
+#ifdef XF86VIDMODE
+extern void XFree86VidModeExtensionInit(INITARGS);
+#define _XF86VIDMODE_SERVER_
+#include "xf86vmstr.h"
+#endif
+
+#ifdef XF86MISC
+extern void XFree86MiscExtensionInit(INITARGS);
+#define _XF86MISC_SERVER_
+#define _XF86MISC_SAVER_COMPAT_
+#include "xf86mscstr.h"
+#endif
+
+#ifdef XFreeXDGA
+extern void XFree86DGAExtensionInit(INITARGS);
+extern void XFree86DGARegister(INITARGS);
+#define _XF86DGA_SERVER_
+#include "xf86dgastr.h"
+#endif
+
+#ifdef DPMSExtension
+extern void DPMSExtensionInit(INITARGS);
+#include "dpmsstr.h"
+#endif
+
+#ifdef FONTCACHE
+extern void FontCacheExtensionInit(INITARGS);
+#define _FONTCACHE_SERVER_
+#include "fontcacheP.h"
+#include "fontcachstr.h"
+#endif
+
+#ifdef TOGCUP
+extern void XcupExtensionInit(INITARGS);
+#define _XCUP_SERVER_
+#include "Xcupstr.h"
+#endif
+
+#ifdef EVI
+extern void EVIExtensionInit(INITARGS);
+#define _XEVI_SERVER_
+#include "XEVIstr.h"
+#endif
+
+#ifdef XV
+extern void XvExtensionInit(INITARGS);
+extern void XvMCExtensionInit(INITARGS);
+extern void XvRegister(INITARGS);
+#include "Xv.h"
+#include "XvMC.h"
+#endif
+
+#ifdef RES
+extern void ResExtensionInit(INITARGS);
+#include "XResproto.h"
+#endif
+
+#ifdef SHM
+extern void ShmExtensionInit(INITARGS);
+#include "shmstr.h"
+extern void ShmSetPixmapFormat(
+ ScreenPtr pScreen,
+ int format);
+extern void ShmRegisterFuncs(
+ ScreenPtr pScreen,
+ ShmFuncsPtr funcs);
+#endif
+
+#if 1
+extern void SecurityExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void XagExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void XpExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void PanoramiXExtensionInit(int argc, char *argv[]);
+#endif
+
+#if 1
+extern void XkbExtensionInit(INITARGS);
+#endif
diff --git a/hw/xfree86/dixmods/extmod/xf86dgaext.h b/hw/xfree86/dixmods/extmod/xf86dgaext.h
new file mode 100644
index 000000000..831108399
--- /dev/null
+++ b/hw/xfree86/dixmods/extmod/xf86dgaext.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86dgaext.h,v 1.1 2003/07/16 01:38:30 dawes Exp $ */
+
+#ifndef _XF86DGAEXT_H_
+#define _XF86DGAEXT_H_
+
+extern DISPATCH_PROC(ProcXF86DGADispatch);
+
+#endif /* _XF86DGAEXT_H_ */
diff --git a/hw/xfree86/dummylib/logvwrite.c b/hw/xfree86/dummylib/logvwrite.c
new file mode 100644
index 000000000..75634d7f3
--- /dev/null
+++ b/hw/xfree86/dummylib/logvwrite.c
@@ -0,0 +1,18 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/logvwrite.c,v 1.1 2003/09/09 03:20:38 dawes Exp $ */
+
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+/*
+ * Utility functions required by libxf86_os.
+ */
+
+void
+LogVWrite(int verb, const char *format, va_list ap)
+{
+ if (xf86Verbose >= verb)
+ vfprintf(stderr, format, ap);
+}
+
diff --git a/hw/xfree86/getconfig/cfg.man.pre b/hw/xfree86/getconfig/cfg.man.pre
new file mode 100644
index 000000000..fcf1a6161
--- /dev/null
+++ b/hw/xfree86/getconfig/cfg.man.pre
@@ -0,0 +1,138 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/getconfig/cfg.man,v 1.1 2003/11/12 04:52:15 dawes Exp $
+.TH getconfig __filemansuffix__ __vendorversion__
+.SH NAME
+getconfig - meta configuration files for getconfig(1)
+.SH SYNOPSIS
+.B \(**.cfg
+.SH DESCRIPTION
+.B getconfig
+is a programatic interface that is used by the
+.B XFree86
+server to get configuration information about video hardware when
+operating without an
+.B XF86Config
+file.
+.PP
+This implementation of
+.B getconfig
+is written in perl. It processes rules from meta-configuration files.
+All meta-configuration files have a
+.I .cfg
+suffix.
+.PP
+Lines starting with a pound-sign (#) are comments, and are ignored.
+Blank lines that consist only of white space are also treated as comments
+and ignored.
+.PP
+The first non-comment line must be a signature string followed by
+the file format version number. The signature string is
+.PP
+.RS 4
+.nf
+"XFree86 Project getconfig rules file.\ \ Version: "
+.fi
+.RE
+.PP
+The currently defined version is "1.0". Files that do not have the
+correct signature string are ignored.
+.PP
+The remaining non-comment lines define rules. The start of a new rule
+is indicated by a line with no leading white space. Subsequent lines
+making up a rule must be indented with white space. Logical lines within
+a rule may be split over multiple physical lines by using the usual
+continuation convention ('\e' at the end of the line). The first logical
+line of each rule is a perl expression. It may be any valid perl
+expression whose evaluated (with 'eval') result may be used as the
+argument to a perl 'if' statement. The second logical line should be
+the name of the XFree86 video driver to use when the rule is true, and
+subsequent logical lines of each rule, if present, are additional
+configuration output for the video device's
+.B XF86Config
+.B Device
+section. The driver name and additional lines of configuration information
+are written to standard output when the rule is chosen as the successful
+rule.
+.PP
+Pseudo rules consisting of perl expressions may be present in the file
+for the purpose of defining custom perl variables or setting the weight
+to use for the following rules. Pseudo rules are rules that consist of
+a single logical line only, and the are never candidates themselves for the
+successful rule.
+.PP
+Several perl variables are pre-defined, and may be used within rules.
+They include:
+.PP
+.RS 4
+.nf
+.BR "$vendor " "PCI vendor ID"
+.BR "$device " "PCI device ID"
+.BR "$revision " "PCI revision ID"
+.BR "$subsys " "PCI subsystem ID"
+.BR "$subsysVendor " "PCI subsystem vendor ID"
+.BR "$class " "PCI class"
+.BR "$XFree86Version " "XFree86 version, as a 'v' string"
+.BR "$XFree86VersionNumeric " "XFree86 numeric version"
+.BR "$XFree86VersionMajor " "XFree86 major version"
+.BR "$XFree86VersionMinor " "XFree86 minor version"
+.BR "$XFree86VersionPatch " "XFree86 patch version"
+.BR "$XFree86VersionSnap " "XFree86 snap version"
+.BR "$weight " "current rule weight"
+.fi
+.RE
+.PP
+The
+.B $weight
+variable deterines the weight of the rules as they are processed. The
+weight for subsequent rules may be set with a pseudo rule that sets or
+changes the value of
+.BR $weight .
+The default weight, and the weight used for built-in rules is 500. The
+meta-configuration files are processed in an unpredictable order. The
+weighting of the rules is used to determine their relative priority
+.PP
+After processing all of the rules, both built-in and those read from
+the meta-configration files, the
+.B getconfig
+program chooses as the successful rule the last and highest weighted
+rule that evaluates to true.
+.SH FILES
+.I .cfg
+files located in the search path. The search path typically specified
+by the
+.B XFree86
+server is:
+.PP
+.RS 4
+.nf
+.I /etc/X11
+.I __projectroot__/etc/X11
+.I <modulepath>
+.I __projectroot__/lib/X11/getconfig
+.fi
+.RE
+.PP
+where
+.I <modulepath>
+is the
+.B XFree86
+server's module search path.
+.PP
+.TP 30
+.I __projectroot__/lib/X11/getconfig/xfree86.cfg
+Default rules file that gets installed. This file doesn't contain any
+rules by default.
+.TP 30
+.I __projectroot__/lib/X11/getconfig/cfg.sample
+A sample rules file that gives some examples of what types of rules can
+appear in rules files.
+
+.SH "SEE ALSO"
+getconfig(1),
+XFree86(1),
+XF86Config(__filemansuffix__).
+
+.SH AUTHORS
+The XFree86 automatic configuration support and the
+.B getconfig
+interface was written by David H. Dawes, with the support of X-Oz
+Technologies.
diff --git a/hw/xfree86/getconfig/cfg.sample b/hw/xfree86/getconfig/cfg.sample
new file mode 100644
index 000000000..acf262d1a
--- /dev/null
+++ b/hw/xfree86/getconfig/cfg.sample
@@ -0,0 +1,111 @@
+# $DHD: xc/programs/Xserver/hw/xfree86/getconfig/cfg.sample,v 1.2 2003/09/23 05:12:07 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/getconfig/cfg.sample,v 1.2 2003/11/12 04:52:15 dawes Exp $
+
+# Some sample XFree86 getconfig rules file.
+
+#
+# The line below is the getconfig rules file signature, and must be the
+# first non-blank, non-comment line.
+#
+
+XFree86 Project getconfig rules file. Version: 1.0
+
+#
+# Set the weight for the following rules. This should be set, otherwise
+# the previously set weight will get used, and you have no idea of knowing
+# what that might be.
+#
+
+$weight = 1000
+
+#
+# Rules. Rules consist of a condition (in perl code) followed by
+# a driver name and optionally some additional strings. The start of a
+# rule is indicated by a line with no leading white space. Subsequent
+# lines making up a rule must be indented. Logical lines may be split
+# over multiple physical lines by using the usual continuation '\'.
+#
+# Rules that are not followed by a driver name may be used to do other
+# things, like setting the weight as above.
+#
+
+#
+# Pre-defined variables include:
+#
+# $vendor PCI vendor ID
+# $device PCI device ID
+# $revision PCI revision ID
+# $subsys PCI subsystem ID
+# $subsysVendor PCI subsystem vendor ID
+# $class PCI class
+# $XFree86Version XFree86 version, as a 'v' string.
+#
+# The XFree86 version information is also available as the following:
+#
+# $XFree86VersionNumeric
+# $XFree86VersionMajor
+# $XFree86VersionMinor
+# $XFree86VersionPatch
+# $XFree86VersionSnap
+#
+
+# Define a fake vendor ID for some sample rules.
+
+$novendor = 0x10000
+$nodevice = 0x10000
+
+$vendor == $novendor
+ nodriver
+ Option "xx"
+ Videoram 1000
+
+# A rule with continued lines.
+
+$vendor == $novendor && \
+$device == $nodevice
+ nodriver2
+ Option \
+ "yy"
+
+# Increase the weight of the following rules if the XFree86 version is 4.3 or
+# higher.
+
+$weight++ if ($XFree86Version ge v4.3)
+
+$vendor == $novendor
+ nodriver
+ Option "yy"
+
+#
+# The weight can be changed at any times, and applies to rules that follow
+# until changed again.
+#
+
+$weight = 100
+
+$vendor == $novendor && $XFree86Version eq v4.3.2.1
+ nodriver3
+
+$weight = 600
+
+#
+# The following two examples use some real values.
+#
+
+# Example: make the default depth 24 for Radeon R200 and RV200 cards.
+
+$vendor == 0x1002 && \
+ ($device >= 0x5148 && $device <= 0x514F || \
+ $device >= 0x5168 && $device <= 0x516C || \
+ $device == 0x4242 || \
+ $device >= 0x5157 && device <= 0x5158)
+ ati
+ Option "DefaultDepth" "24"
+
+
+# Example: enable DRI for MGA G400
+
+$vendor == 0x102b && $device == 0x0525
+ mga
+ Option "dri"
+
diff --git a/hw/xfree86/getconfig/getconfig b/hw/xfree86/getconfig/getconfig
new file mode 100644
index 000000000..d2acc9bb8
--- /dev/null
+++ b/hw/xfree86/getconfig/getconfig
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# $DHD: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.sh,v 1.2 2003/09/20 01:45:57 dawes Exp $
+
+#
+# Copyright 2003 by David H. Dawes.
+# Copyright 2003 by X-Oz Technologies.
+# All rights reserved.
+#
+# 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+# and author(s) 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 copyright holder(s) and author(s).
+#
+# Author: David Dawes <dawes@XFree86.Org>.
+#
+
+# $XFree86: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.sh,v 1.1 2003/10/08 14:58:29 dawes Exp $
+
+# A simple wrapper to execute the real getconfig program. So long as perl
+# is in $PATH, we don't need to know where it is this way.
+
+if echo $0 | grep / >/dev/null 2>&1; then
+ DIR=`dirname $0`/
+fi
+
+exec perl ${DIR}getconfig.pl "$@"
diff --git a/hw/xfree86/getconfig/getconfig.man.pre b/hw/xfree86/getconfig/getconfig.man.pre
new file mode 100644
index 000000000..16c472fc5
--- /dev/null
+++ b/hw/xfree86/getconfig/getconfig.man.pre
@@ -0,0 +1,98 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.man,v 1.1 2003/11/12 04:52:15 dawes Exp $
+.TH getconfig 1 __vendorversion__
+.SH NAME
+getconfig - get configuration information for the XFree86 server
+.SH SYNOPSIS
+.B getconfig
+.RI [ option
+.IR ... ]
+.SH DESCRIPTION
+.B getconfig
+is a programatic interface that is used by the
+.B XFree86
+server to get configuration information about video hardware when
+operating without an
+.B XF86Config
+file.
+.PP
+This implementation of
+.B getconfig
+is written in perl. It processes a prioritized and ordered list of
+rules supplied internally and from meta-configuration files. The rules
+are in the form of perl expressions.
+.B getconfig
+writes to standard output the XF86Config-style configuration data
+specified by the last highest priority rule that evaluates to true.
+Information about the format of the meta-configuration files can be
+found in the getconfig(__filemansuffix__) manual page.
+.SH OPTIONS
+.TP 8
+.BI \-I " search-path"
+Specify the search path to use for meta-config files.
+.I search-path
+is a comma-separated list of directories to search. Each directory in
+the search path is searched for files with a
+.I .cfg
+suffix. Each such file is opened and checked for a valid signature
+string. Rules are read from files with a valid signature string and
+appended to the list of rules to evaluate. If no search path is specified,
+only the internally supplied configuration rules will be used.
+.TP 8
+.B \-D
+Enable debugging output.
+.TP 8
+.B \-V
+Print out the version information and exit.
+.TP 8
+.BI \-X " XFree86-version"
+Specify the XFree86 version in numeric (integer) form.
+.TP 8
+.BI \-b " subsys-id"
+Specify the PCI subsystem ID of the video device.
+.TP 8
+.BI \-c " class"
+Specify the PCI class of the video device.
+.TP 8
+.BI \-d " device-id"
+Specify the PCI devide ID of the video device.
+.TP 8
+.BI \-r " revision"
+Specify the PCI revision of the video device.
+.TP 8
+.BI \-s " subsysvendor-id"
+Specify the PCI subsystem vendor ID of the video device.
+.TP 8
+.BI \-v " vendor-id"
+Specify the PCI vendor ID of the video device.
+.SH FILES
+.I .cfg
+files located in the search path. The search path typically specified
+by the
+.B XFree86
+server is:
+.PP
+.RS 4
+.nf
+.I /etc/X11
+.I __projectroot__/etc/X11
+.I <modulepath>
+.I __projectroot__/lib/X11/getconfig
+.fi
+.RE
+.PP
+where
+.I <modulepath>
+is the
+.B XFree86
+server's module search path.
+
+.SH "SEE ALSO"
+getconfig(__filemansuffix__),
+XFree86(1),
+XF86Config(__filemansuffix__).
+
+.SH AUTHORS
+The XFree86 automatic configuration support and the
+.B getconfig
+interface was written by David H. Dawes, with the support of X-Oz
+Technologies.
diff --git a/hw/xfree86/getconfig/getconfig.pl b/hw/xfree86/getconfig/getconfig.pl
new file mode 100644
index 000000000..fcfd7d057
--- /dev/null
+++ b/hw/xfree86/getconfig/getconfig.pl
@@ -0,0 +1,429 @@
+#!/usr/bin/perl
+
+# $DHD: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.pl,v 1.13 2003/09/23 05:12:07 dawes Exp $
+
+#
+# Copyright 2003 by David H. Dawes.
+# Copyright 2003 by X-Oz Technologies.
+# All rights reserved.
+#
+# 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+# and author(s) 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 copyright holder(s) and author(s).
+#
+# Author: David Dawes <dawes@XFree86.Org>.
+#
+
+# $XFree86: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.pl,v 1.1 2003/10/08 14:58:29 dawes Exp $
+
+#
+# This script takes PCI id information, compares it against an ordered list
+# of rules, and prints out the configuration information specified by the
+# last matching rule.
+#
+# This script is called by xf86AutoConfig().
+#
+
+# Command line processing.
+
+$GetconfigVersion = v1.0;
+
+$debug = 0;
+
+$myname = $0;
+$myname =~ s/.*\///;
+
+$signature = "XFree86 Project getconfig rules file. Version: ";
+
+while (@ARGV[0] =~ /^-[A-Za-z]$/) {
+ $f = shift;
+ SWITCH: {
+ if ($f eq "-D") {
+ $debug = 1;
+ last SWITCH;
+ }
+ if ($f eq "-I") {
+ push(@searchPaths, split(/,/, shift));
+ last SWITCH;
+ }
+ if ($f eq "-V") {
+ printf STDERR "$myname: Version %vd.\n", $GetconfigVersion;
+ exit 0;
+ }
+ if ($f eq "-X") {
+ $XFree86VersionNumeric = shift;
+ if (!defined($XFree86VersionNumeric)) {
+ print STDERR "$myname: -X requires the XFree86 version.\n";
+ exit 1;
+ }
+ }
+ if ($f eq "-b") {
+ $subsys = oct(shift);
+ if (!defined($subsys)) {
+ print STDERR "$myname: -b requires the subsys id.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ if ($f eq "-c") {
+ $class = oct(shift);
+ if (!defined($class)) {
+ print STDERR "$myname: -c requires the class value.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ if ($f eq "-d") {
+ $device = oct(shift);
+ if (!defined($device)) {
+ print STDERR "$myname: -d requires the device id.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ if ($f eq "-r") {
+ $revision = oct(shift);
+ if (!defined($revision)) {
+ print STDERR "$myname: -r requires the device revision.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ if ($f eq "-s") {
+ $subsysVendor = oct(shift);
+ if (!defined($subsysVendor)) {
+ print STDERR "$myname: -s requires the subsysVendor id.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ if ($f eq "-v") {
+ $vendor = oct(shift);
+ if (!defined($vendor)) {
+ print STDERR "$myname: -v requires the vendor id.\n";
+ exit 1;
+ }
+ last SWITCH;
+ }
+ }
+}
+
+printf STDERR "$myname: Version %vd.\n", $GetconfigVersion;
+
+if (defined($XFree86VersionNumeric)) {
+ $XFree86VersionMajor = $XFree86VersionNumeric / 10000000;
+ $XFree86VersionMinor = ($XFree86VersionNumeric % 10000000) / 100000;
+ $XFree86VersionPatch = ($XFree86VersionNumeric % 100000) / 1000;
+ $XFree86VersionSnapshot = $XFree86VersionNumeric % 1000;
+ $XFree86Version = chr($XFree86VersionMajor) . chr($XFree86VersionMinor) .
+ chr($XFree86VersionPatch) . chr($XFree86VersionSnapshot);
+}
+
+if ($debug) {
+ printf STDERR "$myname: XFree86 Version: %d, %d.%d.%d.%d, %vd.\n",
+ $XFree86VersionNumeric, $XFree86VersionMajor, $XFree86VersionMinor,
+ $XFree86VersionPatch, $XFree86VersionSnapshot, $XFree86Version;
+} else {
+ printf STDERR "$myname: XFree86 Version: %vd.\n", $XFree86Version;
+}
+
+
+# The rules here are just basic vendor ID to driver mappings.
+# Ideally this is all that would be required. More complicated configuration
+# rules will be provided in external files.
+
+# XXX This set of basic rules isn't complete yet.
+
+@rules = (
+
+# Set the weight for the built-in rules.
+['$weight = 500'],
+
+# APM
+['$vendor == 0x1142',
+ 'apm'],
+
+# ARK
+['$vendor == 0xedd8',
+ 'apm'],
+
+# ATI
+['$vendor == 0x1002',
+ 'ati'],
+
+# Chips & Technologies
+['$vendor == 0x102c',
+ 'chips'],
+
+# Cirrus
+['$vendor == 0x1013',
+ 'cirrus'],
+
+# Intel
+['$vendor == 0x8086',
+ 'i810'],
+['$vendor == 0x8086 && ($chipType == 0x00d1 || $chipType == 0x7800)',
+ 'i740'],
+
+# Matrox
+['$vendor == 0x102b',
+ 'mga'],
+
+# Neomagic
+['$vendor == 0x10c8',
+ 'neomagic'],
+
+# Number Nine
+['$vendor == 0x105d',
+ 'i128'],
+
+# NVIDIA
+['$vendor == 0x10de || $vendor == 0x12d2',
+ 'nv'],
+
+# S3
+['$vendor == 0x5333 && ($device == 0x88d0 ||' .
+ '$device == 0x88d1 ||' .
+ '$device == 0x88f0 ||' .
+ '$device == 0x8811 ||' .
+ '$device == 0x8812 ||' .
+ '$device == 0x8814 ||' .
+ '$device == 0x8901)',
+ 's3'],
+
+# S3 virge
+['$vendor == 0x5333 && ($device == 0x5631 ||' .
+ '$device == 0x883d ||' .
+ '$device == 0x8a01 ||' .
+ '$device == 0x8a10 ||' .
+ '$device == 0x8c01 ||' .
+ '$device == 0x8c03 ||' .
+ '$device == 0x8904 ||' .
+ '$device == 0x8a13)',
+ 's3virge'],
+
+# S3 Savage
+['$vendor == 0x5333 && ($device >= 0x8a20 && $device <= 0x8a22 ||' .
+ '$device == 0x9102 ||' .
+ '$device >= 0x8c10 && $device <= 0x8c13 ||' .
+ '$device == 0x8a25 ||' .
+ '$device == 0x8a26 ||' .
+ '$device >= 0x8d01 && $device <= 0x8d04 ||' .
+ '$device >= 0x8c2a && $device <= 0x8c2f ||' .
+ '$device == 0x8c22 ||' .
+ '$device == 0x8c24 ||' .
+ '$device == 0x8c26)',
+ 'savage'],
+
+# SIS
+['$vendor == 0x1039',
+ 'sis'],
+
+# SMI
+['$vendor == 0x126f',
+ 'siliconmotion'],
+
+# 3Dfx
+['$vendor == 0x121a',
+ 'tdfx'],
+
+# 3Dlabs
+['$vendor == 0x3d3d',
+ 'glint'],
+
+# Trident
+['$vendor == 0x1023',
+ 'trident'],
+
+# Tseng Labs
+['$vendor == 0x100c',
+ 'tseng'],
+
+# VIA
+['$vendor == 0x1106',
+ 'via'],
+
+# VMware
+['$vendor == 0x15ad',
+ 'vmware'],
+
+);
+
+# Reverse the search path list, since the later rules have higher priority
+# than earlier ones (weighting being equal).
+
+@searchPaths = reverse(@searchPaths);
+
+if ($debug) {
+ $i = 0;
+ for $path (@searchPaths) {
+ print STDERR "$myname: Search path $i is: \"$path\".\n";
+ $i++;
+ }
+}
+
+print STDERR "$myname: ", $#rules + 1, " built-in rule", plural($#rules + 1),
+ ".\n";
+
+for $path (@searchPaths) {
+ while (<$path/*.cfg>) {
+ @tmp = readRulesFile($_);
+ if (defined(@tmp[0])) {
+ push @rules, @tmp;
+ }
+ }
+}
+
+if ($debug) {
+ $i = 0;
+ for $r (@rules) {
+ print STDERR "$myname: rule $i is: \'@$r\'.\n";
+ $i++
+ }
+}
+
+$i = 0;
+$e = 0;
+$weight = 0;
+$w = 0;
+for $r (@rules) {
+ ($cond, $d, @o) = @$r;
+ $result = eval $cond;
+ if ($@) {
+ print STDERR "$myname: Error evaluating rule $i \'$cond\': $@";
+ $e++;
+ }
+ if ($debug) {
+ print STDERR "$myname: rule $i \'$cond\' evaluates to \'$result\'.\n";
+ }
+ if ($result && defined($d) && $weight >= $w) {
+ $driver = $d;
+ @opts = @o;
+ $w = $weight;
+ }
+ $i++;
+}
+
+print STDERR "$myname: Evaluated $i rule", plural($i),
+ " with $e error", plural($e), ".\n";
+
+print STDERR "$myname: Weight of result is $w.\n";
+
+if ($debug) {
+ if (defined($driver)) {
+ print STDERR "$myname: Driver is \'$driver\'.\n";
+ } else {
+ print STDERR "$myname: No driver.\n";
+ }
+ if (defined(@opts)) {
+ print STDERR "$myname: options are:\n";
+ for $opt (@opts) {
+ print STDERR "\t$opt\n";
+ }
+ } else {
+ print STDERR "$myname: No options.\n";
+ }
+}
+
+print "$driver\n";
+for $opt (@opts) {
+ print "$opt\n";
+}
+
+exit 0;
+
+# Subroutines.
+
+sub readRulesFile {
+ my ($file) = @_;
+ my $signatureOK = 0;
+ my @r, @tmp;
+ my $line, $cont, $prevcont, $fileversion;
+
+ undef @tmp;
+ undef @r;
+
+ if (open(RF, "<$file")) {
+ $prevcont = 0;
+ while (<RF>) {
+ chop;
+ $line = $_;
+ next if ($line =~ /^#/);
+ next if ($line =~ /^\s*$/);
+ if (!$signatureOK) {
+ if ($line =~ /^$signature(.*)$/) {
+ $fileversion = $1;
+ $signatureOK = 1;
+ print STDERR
+ "$myname: rules file \'$file\' has version $fileversion.\n";
+ next;
+ }
+ }
+ if (!$signatureOK) {
+ print STDERR "$myname: file \'$file\' has bad signature.\n";
+ close(RF);
+ last;
+ }
+ $cont = 0;
+ if ($line =~ s/\\\s*$//) {
+ $cont = 1;
+ }
+ if (!$prevcont && $line =~ /^\S+/) {
+ if (defined(@tmp[0])) {
+ push(@r,[@tmp]);
+ }
+ undef @tmp;
+ }
+ if ($prevcont) {
+ push(@tmp, pop(@tmp) . $line);
+ } else {
+ push(@tmp, $line);
+ }
+ $prevcont = $cont;
+ }
+ if (defined(@tmp[0])) {
+ push(@r,[@tmp]);
+ }
+ if (!defined(@r[0])) {
+ print STDERR "$myname: no rules in file \'$file\'.\n";
+ } else {
+ print STDERR "$myname: ", $#r + 1,
+ " rule", plural($#r + 1),
+ " added from file \'$file\'.\n";
+ }
+ } else {
+ print STDERR "$myname: cannot open file \'$file\'.\n";
+ }
+
+ return @r;
+}
+
+sub plural {
+ my ($count) = @_;
+
+ if ($count != 1) {
+ return "s";
+ } else {
+ return "";
+ }
+}
+