aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
committermarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
commit9f986778bd4393c5a9108426969d45aa7f10f334 (patch)
tree27d7bd08dac54a54a923e76dccf2b8e388be2a03 /xorg-server/hw/xfree86
parentafbd3947071a33f59dda122f1ac396442a02c128 (diff)
downloadvcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.gz
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.bz2
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.zip
libX11 libXext libXft mesa libxcb mkfontscale pixman xserver
xkeyboard-config git update 19 oct 2011
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r--xorg-server/hw/xfree86/common/Makefile.am9
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h16
-rw-r--r--xorg-server/hw/xfree86/common/xf86AutoConfig.c806
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c19
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.h149
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c4
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86DPMS.c395
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c90
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c7
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h2
-rw-r--r--xorg-server/hw/xfree86/common/xf86VGAarbiter.c2239
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbBus.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.c2723
-rw-r--r--xorg-server/hw/xfree86/common/xf86str.h8
-rw-r--r--xorg-server/hw/xfree86/dixmods/Makefile.am136
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/Makefile.am60
-rw-r--r--xorg-server/hw/xfree86/exa/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/fbdevhw.h2
-rw-r--r--xorg-server/hw/xfree86/int10/generic.c72
-rw-r--r--xorg-server/hw/xfree86/int10/helper_exec.c52
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.c61
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.h2
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c2
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.h2
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Cursors.c1
-rw-r--r--xorg-server/hw/xfree86/os-support/Makefile.am5
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/i386_video.c2
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Makefile.am49
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Pci.c286
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Pci.h306
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/bsd_pci.c16
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/linuxPci.c450
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/nobus.c1
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/xf86Pci.h10
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/Makefile.am4
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/int10/linux.c1085
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/bios_devmem.c75
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/ia64Pci.c188
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/vidmem.c586
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/Makefile.am19
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/stub_bell.c10
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/stub_bios.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/stub_init.c26
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/stub_video.c13
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86_OSproc.h10
-rw-r--r--xorg-server/hw/xfree86/sdksyms.sh12
-rw-r--r--xorg-server/hw/xfree86/shadowfb/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/utils/cvt/cvt.c593
-rw-r--r--xorg-server/hw/xfree86/vbe/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaHW.c4074
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaHW.h468
-rw-r--r--xorg-server/hw/xfree86/xaa/Makefile.am148
54 files changed, 7298 insertions, 8023 deletions
diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am
index 23ddb5c34..a27372103 100644
--- a/xorg-server/hw/xfree86/common/Makefile.am
+++ b/xorg-server/hw/xfree86/common/Makefile.am
@@ -1,5 +1,10 @@
noinst_LTLIBRARIES = libcommon.la
+if XORG_BUS_PCI
+PCI_SOURCES = xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \
+ xf86VGAarbiterPriv.h
+endif
+
if XORG_BUS_SPARC
SBUS_SOURCES = xf86sbusBus.c
endif
@@ -19,7 +24,7 @@ endif
RANDRSOURCES = xf86RandR.c
-BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
+BUSSOURCES = xf86fbBus.c xf86noBus.c $(PCI_SOURCES) $(SBUS_SOURCES)
MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
@@ -33,7 +38,7 @@ AM_LDFLAGS = -r
libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
xf86Events.c xf86Globals.c xf86AutoConfig.c \
- xf86Option.c xf86Init.c xf86VGAarbiter.c \
+ xf86Option.c xf86Init.c \
xf86VidMode.c xf86fbman.c xf86cmap.c \
xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
xf86Mode.c xorgHelper.c \
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index 1b6c9984c..3185baf3a 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -92,6 +92,7 @@ extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
#ifndef _NO_XF86_PROTOTYPES
/* PCI related */
+#ifdef XSERVER_LIBPCIACCESS
#include <pciaccess.h>
extern _X_EXPORT Bool pciSlotClaimed;
@@ -118,6 +119,15 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
EntityProc enter, EntityProc leave, pointer private);
+#else
+#define xf86VGAarbiterInit() do {} while (0)
+#define xf86VGAarbiterFini() do {} while (0)
+#define xf86VGAarbiterLock(x) do {} while (0)
+#define xf86VGAarbiterUnlock(x) do {} while (0)
+#define xf86VGAarbiterScrnInit(x) do {} while (0)
+#define xf86VGAarbiterDeviceDecodes() do {} while (0)
+#define xf86VGAarbiterWrapFunctions() do {} while (0)
+#endif
/* xf86Bus.c */
@@ -239,12 +249,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
SymTabPtr chips);
extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT 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);
extern _X_EXPORT const char *xf86GetVisualName(int visual);
extern _X_EXPORT int xf86GetVerbosity(void);
extern _X_EXPORT Pix24Flags xf86GetPix24(void);
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index 1b9253269..7fc6518d3 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -1,403 +1,403 @@
-/*
- * 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>.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "xf86Config.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86pciBus.h"
-#ifdef __sparc__
-# include "xf86sbusBus.h"
-#endif
-
-#ifdef sun
-# include <sys/visual_io.h>
-# include <ctype.h>
-#endif
-
-/* Sections for the default built-in configuration. */
-
-#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_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" \
- "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"
-
-static const char **builtinConfig = NULL;
-static int builtinLines = 0;
-
-static void listPossibleVideoDrivers(char *matches[], int nmatches);
-
-/*
- * 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;
- }
- free(str);
-}
-
-static void
-FreeList(const char ***list, int *lines)
-{
- int i;
-
- for (i = 0; i < *lines; i++) {
- free((char *)((*list)[i]));
- }
- free(*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)
-{
- char *deviceList[20];
- char **p;
- const char **cp;
- char buf[1024];
- ConfigStatus ret;
-
- listPossibleVideoDrivers(deviceList, 20);
-
- 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);
- for (p = deviceList; *p; p++) {
- snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
- AppendToConfig(buf);
- }
- AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
-
- for (p = deviceList; *p; p++) {
- free(*p);
- }
-
- xf86MsgVerb(X_DEFAULT, 0,
- "Using default built-in configuration (%d lines)\n",
- builtinLines);
-
- xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
- for (cp = builtinConfig; *cp; cp++)
- xf86ErrorFVerb(3, "\t%s", *cp);
- xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
-
- xf86initConfigFiles();
- xf86setBuiltinConfig(builtinConfig);
- ret = xf86HandleConfigFile(TRUE);
- FreeConfig();
-
- if (ret != CONFIG_OK)
- xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
-
- return ret == CONFIG_OK;
-}
-
-static void
-listPossibleVideoDrivers(char *matches[], int nmatches)
-{
- int i;
-
- for (i = 0 ; i < nmatches ; i++) {
- matches[i] = NULL;
- }
- i = 0;
-
-#ifdef sun
- /* Check for driver type based on /dev/fb type and if valid, use
- it instead of PCI bus probe results */
- if (xf86Info.consoleFd >= 0) {
- struct vis_identifier visid;
- const char *cp;
- extern char xf86SolarisFbDev[PATH_MAX];
- int iret;
-
- SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
- if (iret < 0) {
- int fbfd;
-
- fbfd = open(xf86SolarisFbDev, O_RDONLY);
- if (fbfd >= 0) {
- SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
- close(fbfd);
- }
- }
-
- if (iret < 0) {
- xf86Msg(X_WARNING,
- "could not get frame buffer identifier from %s\n",
- xf86SolarisFbDev);
- } else {
- xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
-
- /* Special case from before the general case was set */
- if (strcmp(visid.name, "NVDAnvda") == 0) {
- matches[i++] = xnfstrdup("nvidia");
- }
-
- /* General case - split into vendor name (initial all-caps
- prefix) & driver name (rest of the string). */
- if (strcmp(visid.name, "SUNWtext") != 0) {
- for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
- /* find end of all uppercase vendor section */
- }
- if ((cp != visid.name) && (*cp != '\0')) {
- char *driverName = xnfstrdup(cp);
- char *vendorName = xnfstrdup(visid.name);
- vendorName[cp - visid.name] = '\0';
-
- matches[i++] = vendorName;
- matches[i++] = driverName;
- }
- }
- }
- }
-#endif
-#ifdef __sparc__
- {
- char *sbusDriver = sparcDriverName();
- if (sbusDriver)
- matches[i++] = xnfstrdup(sbusDriver);
- }
-#endif
-
- i = xf86PciMatchDriver(matches, nmatches);
-
- /* Fallback to platform default hardware */
- if (i < (nmatches - 1)) {
-#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
- matches[i++] = xnfstrdup("vesa");
-#elif defined(__sparc__) && !defined(sun)
- matches[i++] = xnfstrdup("sunffb");
-#endif
- }
-
- /* Fallback to platform default frame buffer driver */
- if (i < (nmatches - 1)) {
-#if !defined(__linux__) && defined(__sparc__)
- matches[i++] = xnfstrdup("wsfb");
-#else
- matches[i++] = xnfstrdup("fbdev");
-#endif
- }
-}
-
-/* copy a screen section and enter the desired driver
- * and insert it at i in the list of screens */
-static Bool
-copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
-{
- confScreenPtr nscreen;
- GDevPtr cptr = NULL;
-
- nscreen = malloc(sizeof(confScreenRec));
- if (!nscreen)
- return FALSE;
- memcpy(nscreen, oscreen, sizeof(confScreenRec));
-
- cptr = malloc(sizeof(GDevRec));
- if (!cptr) {
- free(nscreen);
- return FALSE;
- }
- memcpy(cptr, odev, sizeof(GDevRec));
-
- if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver)
- == -1) {
- free(cptr);
- free(nscreen);
- return FALSE;
- }
- cptr->driver = driver;
-
- xf86ConfigLayout.screens[i].screen = nscreen;
-
- /* now associate the new driver entry with the new screen entry */
- xf86ConfigLayout.screens[i].screen->device = cptr;
- cptr->myScreenSection = xf86ConfigLayout.screens[i].screen;
-
- return TRUE;
-}
-
-GDevPtr
-autoConfigDevice(GDevPtr preconf_device)
-{
- GDevPtr ptr = NULL;
- char *matches[20]; /* If we have more than 20 drivers we're in trouble */
- int num_matches = 0, num_screens = 0, i;
- screenLayoutPtr slp;
-
- if (!xf86configptr) {
- return NULL;
- }
-
- /* If there's a configured section with no driver chosen, use it */
- if (preconf_device) {
- ptr = preconf_device;
- } else {
- ptr = calloc(1, sizeof(GDevRec));
- if (!ptr) {
- return NULL;
- }
- ptr->chipID = -1;
- ptr->chipRev = -1;
- ptr->irq = -1;
-
- ptr->active = TRUE;
- ptr->claimed = FALSE;
- ptr->identifier = "Autoconfigured Video Device";
- ptr->driver = NULL;
- }
- if (!ptr->driver) {
- /* get all possible video drivers and count them */
- listPossibleVideoDrivers(matches, 20);
- for (; matches[num_matches]; num_matches++) {
- xf86Msg(X_DEFAULT, "Matched %s as autoconfigured driver %d\n",
- matches[num_matches], num_matches);
- }
-
- slp = xf86ConfigLayout.screens;
- if (slp) {
- /* count the number of screens and make space for
- * a new screen for each additional possible driver
- * minus one for the already existing first one
- * plus one for the terminating NULL */
- for (; slp[num_screens].screen; num_screens++);
- xf86ConfigLayout.screens = xnfcalloc(num_screens + num_matches,
- sizeof(screenLayoutRec));
- xf86ConfigLayout.screens[0] = slp[0];
-
- /* do the first match and set that for the original first screen */
- ptr->driver = matches[0];
- if (!xf86ConfigLayout.screens[0].screen->device) {
- xf86ConfigLayout.screens[0].screen->device = ptr;
- ptr->myScreenSection = xf86ConfigLayout.screens[0].screen;
- }
-
- /* for each other driver found, copy the first screen, insert it
- * into the list of screens and set the driver */
- i = 0;
- while (i++ < num_matches) {
- if (!copyScreen(slp[0].screen, ptr, i, matches[i]))
- return NULL;
- }
-
- /* shift the rest of the original screen list
- * to the end of the current screen list
- *
- * TODO Handle rest of multiple screen sections */
- for (i = 1; i < num_screens; i++) {
- xf86ConfigLayout.screens[i+num_matches] = slp[i];
- }
- xf86ConfigLayout.screens[num_screens+num_matches-1].screen = NULL;
- free(slp);
- } else {
- /* layout does not have any screens, not much to do */
- ptr->driver = matches[0];
- for (i = 1; matches[i] ; i++) {
- if (matches[i] != matches[0]) {
- free(matches[i]);
- }
- }
- }
- }
-
- xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n");
-
- return ptr;
-}
+/*
+ * 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>.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86pciBus.h"
+#ifdef __sparc__
+# include "xf86sbusBus.h"
+#endif
+
+#ifdef sun
+# include <sys/visual_io.h>
+# include <ctype.h>
+#endif
+
+/* Sections for the default built-in configuration. */
+
+#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_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" \
+ "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"
+
+static const char **builtinConfig = NULL;
+static int builtinLines = 0;
+
+static void listPossibleVideoDrivers(char *matches[], int nmatches);
+
+/*
+ * 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;
+ }
+ free(str);
+}
+
+static void
+FreeList(const char ***list, int *lines)
+{
+ int i;
+
+ for (i = 0; i < *lines; i++) {
+ free((char *)((*list)[i]));
+ }
+ free(*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)
+{
+ char *deviceList[20];
+ char **p;
+ const char **cp;
+ char buf[1024];
+ ConfigStatus ret;
+
+ listPossibleVideoDrivers(deviceList, 20);
+
+ 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);
+ for (p = deviceList; *p; p++) {
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
+ AppendToConfig(buf);
+ }
+ AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
+
+ for (p = deviceList; *p; p++) {
+ free(*p);
+ }
+
+ xf86MsgVerb(X_DEFAULT, 0,
+ "Using default built-in configuration (%d lines)\n",
+ builtinLines);
+
+ xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
+ for (cp = builtinConfig; *cp; cp++)
+ xf86ErrorFVerb(3, "\t%s", *cp);
+ xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
+
+ xf86initConfigFiles();
+ xf86setBuiltinConfig(builtinConfig);
+ ret = xf86HandleConfigFile(TRUE);
+ FreeConfig();
+
+ if (ret != CONFIG_OK)
+ xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
+
+ return ret == CONFIG_OK;
+}
+
+static void
+listPossibleVideoDrivers(char *matches[], int nmatches)
+{
+ int i;
+
+ for (i = 0 ; i < nmatches ; i++) {
+ matches[i] = NULL;
+ }
+ i = 0;
+
+#ifdef sun
+ /* Check for driver type based on /dev/fb type and if valid, use
+ it instead of PCI bus probe results */
+ if (xf86Info.consoleFd >= 0) {
+ struct vis_identifier visid;
+ const char *cp;
+ extern char xf86SolarisFbDev[PATH_MAX];
+ int iret;
+
+ SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
+ if (iret < 0) {
+ int fbfd;
+
+ fbfd = open(xf86SolarisFbDev, O_RDONLY);
+ if (fbfd >= 0) {
+ SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
+ close(fbfd);
+ }
+ }
+
+ if (iret < 0) {
+ xf86Msg(X_WARNING,
+ "could not get frame buffer identifier from %s\n",
+ xf86SolarisFbDev);
+ } else {
+ xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
+
+ /* Special case from before the general case was set */
+ if (strcmp(visid.name, "NVDAnvda") == 0) {
+ matches[i++] = xnfstrdup("nvidia");
+ }
+
+ /* General case - split into vendor name (initial all-caps
+ prefix) & driver name (rest of the string). */
+ if (strcmp(visid.name, "SUNWtext") != 0) {
+ for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
+ /* find end of all uppercase vendor section */
+ }
+ if ((cp != visid.name) && (*cp != '\0')) {
+ char *driverName = xnfstrdup(cp);
+ char *vendorName = xnfstrdup(visid.name);
+ vendorName[cp - visid.name] = '\0';
+
+ matches[i++] = vendorName;
+ matches[i++] = driverName;
+ }
+ }
+ }
+ }
+#endif
+#ifdef __sparc__
+ {
+ char *sbusDriver = sparcDriverName();
+ if (sbusDriver)
+ matches[i++] = xnfstrdup(sbusDriver);
+ }
+#endif
+#ifdef XSERVER_LIBPCIACCESS
+ i = xf86PciMatchDriver(matches, nmatches);
+#endif
+ /* Fallback to platform default hardware */
+ if (i < (nmatches - 1)) {
+#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
+ matches[i++] = xnfstrdup("vesa");
+#elif defined(__sparc__) && !defined(sun)
+ matches[i++] = xnfstrdup("sunffb");
+#endif
+ }
+
+ /* Fallback to platform default frame buffer driver */
+ if (i < (nmatches - 1)) {
+#if !defined(__linux__) && defined(__sparc__)
+ matches[i++] = xnfstrdup("wsfb");
+#else
+ matches[i++] = xnfstrdup("fbdev");
+#endif
+ }
+}
+
+/* copy a screen section and enter the desired driver
+ * and insert it at i in the list of screens */
+static Bool
+copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
+{
+ confScreenPtr nscreen;
+ GDevPtr cptr = NULL;
+
+ nscreen = malloc(sizeof(confScreenRec));
+ if (!nscreen)
+ return FALSE;
+ memcpy(nscreen, oscreen, sizeof(confScreenRec));
+
+ cptr = malloc(sizeof(GDevRec));
+ if (!cptr) {
+ free(nscreen);
+ return FALSE;
+ }
+ memcpy(cptr, odev, sizeof(GDevRec));
+
+ if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver)
+ == -1) {
+ free(cptr);
+ free(nscreen);
+ return FALSE;
+ }
+ cptr->driver = driver;
+
+ xf86ConfigLayout.screens[i].screen = nscreen;
+
+ /* now associate the new driver entry with the new screen entry */
+ xf86ConfigLayout.screens[i].screen->device = cptr;
+ cptr->myScreenSection = xf86ConfigLayout.screens[i].screen;
+
+ return TRUE;
+}
+
+GDevPtr
+autoConfigDevice(GDevPtr preconf_device)
+{
+ GDevPtr ptr = NULL;
+ char *matches[20]; /* If we have more than 20 drivers we're in trouble */
+ int num_matches = 0, num_screens = 0, i;
+ screenLayoutPtr slp;
+
+ if (!xf86configptr) {
+ return NULL;
+ }
+
+ /* If there's a configured section with no driver chosen, use it */
+ if (preconf_device) {
+ ptr = preconf_device;
+ } else {
+ ptr = calloc(1, sizeof(GDevRec));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->chipID = -1;
+ ptr->chipRev = -1;
+ ptr->irq = -1;
+
+ ptr->active = TRUE;
+ ptr->claimed = FALSE;
+ ptr->identifier = "Autoconfigured Video Device";
+ ptr->driver = NULL;
+ }
+ if (!ptr->driver) {
+ /* get all possible video drivers and count them */
+ listPossibleVideoDrivers(matches, 20);
+ for (; matches[num_matches]; num_matches++) {
+ xf86Msg(X_DEFAULT, "Matched %s as autoconfigured driver %d\n",
+ matches[num_matches], num_matches);
+ }
+
+ slp = xf86ConfigLayout.screens;
+ if (slp) {
+ /* count the number of screens and make space for
+ * a new screen for each additional possible driver
+ * minus one for the already existing first one
+ * plus one for the terminating NULL */
+ for (; slp[num_screens].screen; num_screens++);
+ xf86ConfigLayout.screens = xnfcalloc(num_screens + num_matches,
+ sizeof(screenLayoutRec));
+ xf86ConfigLayout.screens[0] = slp[0];
+
+ /* do the first match and set that for the original first screen */
+ ptr->driver = matches[0];
+ if (!xf86ConfigLayout.screens[0].screen->device) {
+ xf86ConfigLayout.screens[0].screen->device = ptr;
+ ptr->myScreenSection = xf86ConfigLayout.screens[0].screen;
+ }
+
+ /* for each other driver found, copy the first screen, insert it
+ * into the list of screens and set the driver */
+ i = 0;
+ while (i++ < num_matches) {
+ if (!copyScreen(slp[0].screen, ptr, i, matches[i]))
+ return NULL;
+ }
+
+ /* shift the rest of the original screen list
+ * to the end of the current screen list
+ *
+ * TODO Handle rest of multiple screen sections */
+ for (i = 1; i < num_screens; i++) {
+ xf86ConfigLayout.screens[i+num_matches] = slp[i];
+ }
+ xf86ConfigLayout.screens[num_screens+num_matches-1].screen = NULL;
+ free(slp);
+ } else {
+ /* layout does not have any screens, not much to do */
+ ptr->driver = matches[0];
+ for (i = 1; matches[i] ; i++) {
+ if (matches[i] != matches[0]) {
+ free(matches[i]);
+ }
+ }
+ }
+ }
+
+ xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n");
+
+ return ptr;
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index 3b0896863..c665a2019 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -47,8 +47,9 @@
#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
+#ifdef XSERVER_LIBPCIACCESS
#include "xf86VGAarbiter.h"
-
+#endif
/* Entity data */
EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
int xf86NumEntities = 0;
@@ -75,7 +76,7 @@ Bool
xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
{
Bool foundScreen = FALSE;
-
+#ifdef XSERVER_LIBPCIACCESS
if (drv->PciProbe != NULL) {
if (xf86DoConfigure && xf86DoConfigurePass1) {
assert(detect_only);
@@ -86,7 +87,7 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
foundScreen = xf86PciProbeDev(drv);
}
}
-
+#endif
if (!foundScreen && (drv->Probe != NULL)) {
xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
drv->driverName);
@@ -195,7 +196,9 @@ xf86BusConfig(void)
void
xf86BusProbe(void)
{
+#ifdef XSERVER_LIBPCIACCESS
xf86PciProbe();
+#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
xf86SbusProbe();
#endif
@@ -308,7 +311,6 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
pScrn->numEntities * sizeof(int));
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
- pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
}
void
@@ -505,9 +507,14 @@ xf86PostProbe(void)
{
int i;
- if (fbSlotClaimed && (pciSlotClaimed
+ if (fbSlotClaimed && (
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- || sbusSlotClaimed
+ sbusSlotClaimed ||
+#endif
+#ifdef XSERVER_LIBPCIACCESS
+ pciSlotClaimed
+#else
+ TRUE
#endif
))
FatalError("Cannot run in framebuffer mode. Please specify busIDs "
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.h b/xorg-server/hw/xfree86/common/xf86Bus.h
index 4e3d7d7cb..0b2ebdb44 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.h
+++ b/xorg-server/hw/xfree86/common/xf86Bus.h
@@ -1,75 +1,74 @@
-/*
- * Copyright (c) 1997-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).
- */
-
-/*
- * This file contains definitions of the bus-related data structures/types.
- * Everything contained here is private to xf86Bus.c. In particular the
- * video drivers must not include this file.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86_BUS_H
-#define _XF86_BUS_H
-
-#include "xf86pciBus.h"
-#if defined(__sparc__) || defined(__sparc)
-#include "xf86sbusBus.h"
-#endif
-
-typedef struct {
- DriverPtr driver;
- int chipset;
- int entityProp;
- EntityProc entityInit;
- EntityProc entityEnter;
- EntityProc entityLeave;
- pointer private;
- Bool active;
- Bool inUse;
- BusRec bus;
- int lastScrnFlag;
- DevUnion * entityPrivates;
- int numInstances;
- GDevPtr * devices;
- IOADDRESS domainIO;
-} EntityRec, *EntityPtr;
-
-#define ACCEL_IS_SHARABLE 0x100
-#define IS_SHARED_ACCEL 0x200
-#define SA_PRIM_INIT_DONE 0x400
-
-extern EntityPtr *xf86Entities;
-extern int xf86NumEntities;
-extern BusRec primaryBus;
-
-int xf86AllocateEntity(void);
-BusType StringToBusType(const char* busID, const char **retID);
-
-#endif /* _XF86_BUS_H */
+/*
+ * Copyright (c) 1997-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).
+ */
+
+/*
+ * This file contains definitions of the bus-related data structures/types.
+ * Everything contained here is private to xf86Bus.c. In particular the
+ * video drivers must not include this file.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_BUS_H
+#define _XF86_BUS_H
+
+#include "xf86pciBus.h"
+#if defined(__sparc__) || defined(__sparc)
+#include "xf86sbusBus.h"
+#endif
+
+typedef struct {
+ DriverPtr driver;
+ int chipset;
+ int entityProp;
+ EntityProc entityInit;
+ EntityProc entityEnter;
+ EntityProc entityLeave;
+ pointer private;
+ Bool active;
+ Bool inUse;
+ BusRec bus;
+ int lastScrnFlag;
+ DevUnion * entityPrivates;
+ int numInstances;
+ GDevPtr * devices;
+} EntityRec, *EntityPtr;
+
+#define ACCEL_IS_SHARABLE 0x100
+#define IS_SHARED_ACCEL 0x200
+#define SA_PRIM_INIT_DONE 0x400
+
+extern EntityPtr *xf86Entities;
+extern int xf86NumEntities;
+extern BusRec primaryBus;
+
+int xf86AllocateEntity(void);
+BusType StringToBusType(const char* busID, const char **retID);
+
+#endif /* _XF86_BUS_H */
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index f8c1b6567..5c46152b2 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -2398,7 +2398,7 @@ xf86HandleConfigFile(Bool autoconfig)
}
xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
-
+#ifdef XSERVER_LIBPCIACCESS
if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
; /* IsolateDevice specified; overrides SingleCard */
} else {
@@ -2413,7 +2413,7 @@ xf86HandleConfigFile(Bool autoconfig)
} else
xf86PciIsolateDevice(scanptr);
}
-
+#endif
/* Now process everything else */
if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
ErrorF ("Problem when converting the config data structures\n");
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index ab0751507..99b8b48d7 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -87,9 +87,11 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
/* Check for duplicates */
for (i = 0; i < nDevToConfig; i++) {
switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
case BUS_PCI:
ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
- break;
+ break;
+#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
case BUS_SBUS:
ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
@@ -118,10 +120,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
case BUS_PCI:
xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
&DevToConfig[i].GDev, &chipset);
break;
+#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
case BUS_SBUS:
xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
diff --git a/xorg-server/hw/xfree86/common/xf86DPMS.c b/xorg-server/hw/xfree86/common/xf86DPMS.c
index 1a8aed306..613c7cf73 100644
--- a/xorg-server/hw/xfree86/common/xf86DPMS.c
+++ b/xorg-server/hw/xfree86/common/xf86DPMS.c
@@ -1,197 +1,198 @@
-/*
- * Copyright (c) 1997-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).
- */
-
-/*
- * This file contains the DPMS functions required by the extension.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "globals.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-#include "xf86VGAarbiter.h"
-
-
-#ifdef DPMSExtension
-static DevPrivateKeyRec DPMSKeyRec;
-static DevPrivateKey DPMSKey;
-static Bool DPMSClose(int i, ScreenPtr pScreen);
-static int DPMSCount = 0;
-#endif
-
-
-Bool
-xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
-{
-#ifdef DPMSExtension
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DPMSPtr pDPMS;
- pointer DPMSOpt;
- MessageType enabled_from;
-
- DPMSKey = &DPMSKeyRec;
-
- if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
- return FALSE;
-
- pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
- pScrn->DPMSSet = set;
- pDPMS->Flags = flags;
- DPMSOpt = xf86FindOption(pScrn->options, "dpms");
- if (DPMSDisabledSwitch) {
- enabled_from = X_CMDLINE;
- DPMSEnabled = FALSE;
- }
- else if (DPMSOpt) {
- enabled_from = X_CONFIG;
- DPMSEnabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE);
- xf86MarkOptionUsed(DPMSOpt);
- }
- else {
- enabled_from = X_DEFAULT;
- DPMSEnabled = TRUE;
- }
- if (DPMSEnabled)
- xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n");
- pDPMS->Enabled = DPMSEnabled;
- pDPMS->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = DPMSClose;
- DPMSCount++;
- return TRUE;
-#else
- return FALSE;
-#endif
-}
-
-
-#ifdef DPMSExtension
-
-static Bool
-DPMSClose(int i, ScreenPtr pScreen)
-{
- DPMSPtr pDPMS;
-
- /* This shouldn't happen */
- if (DPMSKey == NULL)
- return FALSE;
-
- pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
-
- /* This shouldn't happen */
- if (!pDPMS)
- return FALSE;
-
- pScreen->CloseScreen = pDPMS->CloseScreen;
-
- /*
- * Turn on DPMS when shutting down. If this function can be used
- * depends on the order the driver wraps things. If this is called
- * after the driver has shut down everything the driver will have
- * to deal with this internally.
- */
- if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) {
- xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
- }
-
- if (--DPMSCount == 0)
- DPMSKey = NULL;
- return pScreen->CloseScreen(i, pScreen);
-}
-
-
-/*
- * DPMSSet --
- * Device dependent DPMS mode setting hook. This is called whenever
- * the DPMS mode is to be changed.
- */
-int
-DPMSSet(ClientPtr client, int level)
-{
- int rc, i;
- DPMSPtr pDPMS;
- ScrnInfoPtr pScrn;
-
- DPMSPowerLevel = level;
-
- if (DPMSKey == NULL)
- return Success;
-
- if (level != DPMSModeOn) {
- rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
- if (rc != Success)
- return rc;
- }
-
- /* For each screen, set the DPMS level */
- for (i = 0; i < xf86NumScreens; i++) {
- pScrn = xf86Screens[i];
- pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
- if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
- xf86VGAarbiterLock(pScrn);
- pScrn->DPMSSet(pScrn, level, 0);
- xf86VGAarbiterUnlock(pScrn);
- }
- }
- return Success;
-}
-
-
-/*
- * DPMSSupported --
- * Return TRUE if any screen supports DPMS.
- */
-Bool
-DPMSSupported(void)
-{
- int i;
- DPMSPtr pDPMS;
- ScrnInfoPtr pScrn;
-
- if (DPMSKey == NULL) {
- return FALSE;
- }
-
- /* For each screen, check if DPMS is supported */
- for (i = 0; i < xf86NumScreens; i++) {
- pScrn = xf86Screens[i];
- pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
- if (pDPMS && pScrn->DPMSSet)
- return TRUE;
- }
- return FALSE;
-}
-
-#endif /* DPMSExtension */
+/*
+ * Copyright (c) 1997-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).
+ */
+
+/*
+ * This file contains the DPMS functions required by the extension.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#ifdef DPMSExtension
+#include <X11/extensions/dpmsconst.h>
+#include "dpmsproc.h"
+#endif
+#ifdef XSERVER_LIBPCIACCESS
+#include "xf86VGAarbiter.h"
+#endif
+
+#ifdef DPMSExtension
+static DevPrivateKeyRec DPMSKeyRec;
+static DevPrivateKey DPMSKey;
+static Bool DPMSClose(int i, ScreenPtr pScreen);
+static int DPMSCount = 0;
+#endif
+
+
+Bool
+xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
+{
+#ifdef DPMSExtension
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DPMSPtr pDPMS;
+ pointer DPMSOpt;
+ MessageType enabled_from;
+
+ DPMSKey = &DPMSKeyRec;
+
+ if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
+ return FALSE;
+
+ pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
+ pScrn->DPMSSet = set;
+ pDPMS->Flags = flags;
+ DPMSOpt = xf86FindOption(pScrn->options, "dpms");
+ if (DPMSDisabledSwitch) {
+ enabled_from = X_CMDLINE;
+ DPMSEnabled = FALSE;
+ }
+ else if (DPMSOpt) {
+ enabled_from = X_CONFIG;
+ DPMSEnabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE);
+ xf86MarkOptionUsed(DPMSOpt);
+ }
+ else {
+ enabled_from = X_DEFAULT;
+ DPMSEnabled = TRUE;
+ }
+ if (DPMSEnabled)
+ xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n");
+ pDPMS->Enabled = DPMSEnabled;
+ pDPMS->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = DPMSClose;
+ DPMSCount++;
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+
+#ifdef DPMSExtension
+
+static Bool
+DPMSClose(int i, ScreenPtr pScreen)
+{
+ DPMSPtr pDPMS;
+
+ /* This shouldn't happen */
+ if (DPMSKey == NULL)
+ return FALSE;
+
+ pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
+
+ /* This shouldn't happen */
+ if (!pDPMS)
+ return FALSE;
+
+ pScreen->CloseScreen = pDPMS->CloseScreen;
+
+ /*
+ * Turn on DPMS when shutting down. If this function can be used
+ * depends on the order the driver wraps things. If this is called
+ * after the driver has shut down everything the driver will have
+ * to deal with this internally.
+ */
+ if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) {
+ xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
+ }
+
+ if (--DPMSCount == 0)
+ DPMSKey = NULL;
+ return pScreen->CloseScreen(i, pScreen);
+}
+
+
+/*
+ * DPMSSet --
+ * Device dependent DPMS mode setting hook. This is called whenever
+ * the DPMS mode is to be changed.
+ */
+int
+DPMSSet(ClientPtr client, int level)
+{
+ int rc, i;
+ DPMSPtr pDPMS;
+ ScrnInfoPtr pScrn;
+
+ DPMSPowerLevel = level;
+
+ if (DPMSKey == NULL)
+ return Success;
+
+ if (level != DPMSModeOn) {
+ rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (rc != Success)
+ return rc;
+ }
+
+ /* For each screen, set the DPMS level */
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScrn = xf86Screens[i];
+ pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
+ if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
+ xf86VGAarbiterLock(pScrn);
+ pScrn->DPMSSet(pScrn, level, 0);
+ xf86VGAarbiterUnlock(pScrn);
+ }
+ }
+ return Success;
+}
+
+
+/*
+ * DPMSSupported --
+ * Return TRUE if any screen supports DPMS.
+ */
+Bool
+DPMSSupported(void)
+{
+ int i;
+ DPMSPtr pDPMS;
+ ScrnInfoPtr pScrn;
+
+ if (DPMSKey == NULL) {
+ return FALSE;
+ }
+
+ /* For each screen, check if DPMS is supported */
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScrn = xf86Screens[i];
+ pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
+ if (pDPMS && pScrn->DPMSSet)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#endif /* DPMSExtension */
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index a8aa316ae..cf577522a 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -1353,96 +1353,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
return i;
}
-/*
- * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
- */
-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)
-{
- register int status = vertsyncreg;
- unsigned long i, cnt, rcnt, sync;
-
- /* First save registers that get written on */
- (*ClockFunc)(pScrn, CLK_REG_SAVE);
-
- if (num > MAXCLOCKS)
- num = MAXCLOCKS;
-
- for (i = 0; i < num; i++)
- {
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, TRUE);
- if (!(*ClockFunc)(pScrn, i))
- {
- pScrn->clock[i] = -1;
- continue;
- }
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, FALSE);
- if (BlankScreen)
- (*BlankScreen)(pScrn, FALSE);
-
- usleep(50000); /* let VCO stabilise */
-
- cnt = 0;
- sync = 200000;
-
- while ((inb(status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((inb(status) & maskval) == maskval)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((inb(status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
-
- for (rcnt = 0; rcnt < 5; rcnt++)
- {
- while (!(inb(status) & maskval))
- cnt++;
- while ((inb(status) & maskval))
- cnt++;
- }
-
-finish:
- pScrn->clock[i] = cnt ? cnt : -1;
- if (BlankScreen)
- (*BlankScreen)(pScrn, TRUE);
- }
-
- for (i = 0; i < num; i++)
- {
- if (i != knownclkindex)
- {
- if (pScrn->clock[i] == -1)
- {
- pScrn->clock[i] = 0;
- }
- else
- {
- pScrn->clock[i] = (int)(0.5 +
- (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
- (pScrn->clock[i]));
- /* Round to nearest 10KHz */
- pScrn->clock[i] += 5;
- pScrn->clock[i] /= 10;
- pScrn->clock[i] *= 10;
- }
- }
- }
-
- pScrn->clock[knownclkindex] = knownclkvalue;
- pScrn->numClocks = num;
-
- /* Restore registers that were written on */
- (*ClockFunc)(pScrn, CLK_REG_RESTORE);
-}
-
const char *
xf86GetVisualName(int visual)
{
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 350918dfe..74e0bc220 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -78,7 +78,9 @@
#include "picturestr.h"
#include "xf86Bus.h"
+#ifdef XSERVER_LIBPCIACCESS
#include "xf86VGAarbiter.h"
+#endif
#include "globals.h"
#include "xserver-properties.h"
@@ -88,7 +90,6 @@
#endif
#include <hotplug.h>
-
#ifdef XF86PM
void (*xf86OSPMClose)(void) = NULL;
#endif
@@ -1355,6 +1356,7 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86DoShowOptions = TRUE;
return 1;
}
+#ifdef XSERVER_LIBPCIACCESS
if (!strcmp(argv[i], "-isolateDevice"))
{
CHECK_FOR_REQUIRED_ARGUMENT();
@@ -1364,6 +1366,7 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86PciIsolateDevice(argv[i]);
return 2;
}
+#endif
/* Notice cmdline xkbdir, but pass to dix as well */
if (!strcmp(argv[i], "-xkbdir"))
{
@@ -1432,7 +1435,9 @@ ddxUseMsg(void)
#endif
ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+#ifdef XSERVER_LIBPCIACCESS
ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
+#endif
ErrorF("-version show the server version\n");
ErrorF("-showDefaultModulePath show the server default module path\n");
ErrorF("-showDefaultLibPath show the server default library path\n");
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index 330d87ae8..a9645e77b 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -82,7 +82,7 @@ typedef enum {
* mask is 0xFFFF0000.
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(12, 0)
#define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
index 0aa6f2cf4..819ad6e7c 100644
--- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
+++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
@@ -1,1127 +1,1112 @@
-/*
- * This code was stolen from RAC and adapted to control the legacy vga
- * interface.
- *
- *
- * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti
- *
- * 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 AUTHORS OR COPYRIGHT
- * HOLDERS 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.
- *
- */
-
-#include "xorg-config.h"
-
-#include "xf86VGAarbiter.h"
-
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
-#include "xf86VGAarbiterPriv.h"
-#include "xf86Bus.h"
-#include "xf86Priv.h"
-#include "pciaccess.h"
-
-
-static GCFuncs VGAarbiterGCFuncs = {
- VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
- VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip,
- VGAarbiterCopyClip
-};
-
-static GCOps VGAarbiterGCOps = {
- VGAarbiterFillSpans, VGAarbiterSetSpans, VGAarbiterPutImage,
- VGAarbiterCopyArea, VGAarbiterCopyPlane, VGAarbiterPolyPoint,
- VGAarbiterPolylines, VGAarbiterPolySegment, VGAarbiterPolyRectangle,
- VGAarbiterPolyArc, VGAarbiterFillPolygon, VGAarbiterPolyFillRect,
- VGAarbiterPolyFillArc, VGAarbiterPolyText8, VGAarbiterPolyText16,
- VGAarbiterImageText8, VGAarbiterImageText16, VGAarbiterImageGlyphBlt,
- VGAarbiterPolyGlyphBlt, VGAarbiterPushPixels,
-};
-
-static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
- VGAarbiterSpriteRealizeCursor, VGAarbiterSpriteUnrealizeCursor,
- VGAarbiterSpriteSetCursor, VGAarbiterSpriteMoveCursor,
- VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
-};
-
-static DevPrivateKeyRec VGAarbiterScreenKeyRec;
-#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
-static DevPrivateKeyRec VGAarbiterGCKeyRec;
-#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
-
-static int vga_no_arb = 0;
-void
-xf86VGAarbiterInit(void)
-{
- if (pci_device_vgaarb_init() != 0) {
- vga_no_arb = 1;
- xf86Msg(X_WARNING, "VGA arbiter: cannot open kernel arbiter, no multi-card support\n");
- }
-}
-
-void
-xf86VGAarbiterFini(void)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_fini();
-}
-
-void
-xf86VGAarbiterLock(ScrnInfoPtr pScrn)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_set_target(pScrn->vgaDev);
- pci_device_vgaarb_lock();
-}
-
-void
-xf86VGAarbiterUnlock(ScrnInfoPtr pScrn)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_unlock();
-}
-
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
-{
- int vga_count;
- int rsrc_decodes;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if (vga_no_arb)
- return TRUE;
-
- pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
- if (vga_count > 1) {
- if (rsrc_decodes) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-void
-xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
-{
- struct pci_device *dev;
- EntityPtr pEnt;
-
- if (vga_no_arb)
- return;
-
- pEnt = xf86Entities[pScrn->entityList[0]];
- if (pEnt->bus.type != BUS_PCI)
- return;
-
- dev = pEnt->bus.id.pci;
- pScrn->vgaDev = dev;
-}
-
-void
-xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_set_target(pScrn->vgaDev);
- pci_device_vgaarb_decodes(rsrc);
-}
-
-Bool
-xf86VGAarbiterWrapFunctions(void)
-{
- ScrnInfoPtr pScrn;
- VGAarbiterScreenPtr pScreenPriv;
- miPointerScreenPtr PointPriv;
- PictureScreenPtr ps;
- ScreenPtr pScreen;
- int vga_count, i;
-
- if (vga_no_arb)
- return FALSE;
-
- /*
- * we need to wrap the arbiter if we have more than
- * one VGA card - hotplug cries.
- */
- pci_device_vgaarb_get_info(NULL, &vga_count, NULL);
- if (vga_count < 2 || !xf86Screens)
- return FALSE;
-
- xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n",
- vga_count);
-
- for (i = 0; i < xf86NumScreens; i++) {
- pScreen = xf86Screens[i]->pScreen;
- ps = GetPictureScreenIfSet(pScreen);
- pScrn = xf86Screens[pScreen->myNum];
- PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);
-
- WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen);
- WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen);
- WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler);
- WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler);
- WRAP_SCREEN(CreateGC, VGAarbiterCreateGC);
- WRAP_SCREEN(GetImage, VGAarbiterGetImage);
- WRAP_SCREEN(GetSpans, VGAarbiterGetSpans);
- WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate);
- WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow);
- WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground);
- WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap);
- WRAP_SCREEN(StoreColors, VGAarbiterStoreColors);
- WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor);
- WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor);
- WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
- WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
- WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
- WRAP_PICT(Composite,VGAarbiterComposite);
- WRAP_PICT(Glyphs,VGAarbiterGlyphs);
- WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
- WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
- WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
- WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
- WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT);
- WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen);
- WRAP_SPRITE;
- }
-
- return TRUE;
-}
-
-/* Screen funcs */
-static Bool
-VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
-{
- Bool val;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
- miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, miPointerScreenKey);
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- UNWRAP_SCREEN(CreateGC);
- UNWRAP_SCREEN(CloseScreen);
- UNWRAP_SCREEN(GetImage);
- UNWRAP_SCREEN(GetSpans);
- UNWRAP_SCREEN(SourceValidate);
- UNWRAP_SCREEN(CopyWindow);
- UNWRAP_SCREEN(ClearToBackground);
- UNWRAP_SCREEN(SaveScreen);
- UNWRAP_SCREEN(StoreColors);
- UNWRAP_SCREEN(DisplayCursor);
- UNWRAP_SCREEN(RealizeCursor);
- UNWRAP_SCREEN(UnrealizeCursor);
- UNWRAP_SCREEN(RecolorCursor);
- UNWRAP_SCREEN(SetCursorPosition);
- UNWRAP_PICT(Composite);
- UNWRAP_PICT(Glyphs);
- UNWRAP_PICT(CompositeRects);
- UNWRAP_SCREEN_INFO(AdjustFrame);
- UNWRAP_SCREEN_INFO(SwitchMode);
- UNWRAP_SCREEN_INFO(EnterVT);
- UNWRAP_SCREEN_INFO(LeaveVT);
- UNWRAP_SCREEN_INFO(FreeScreen);
- UNWRAP_SPRITE;
-
- free((pointer) pScreenPriv);
- xf86VGAarbiterLock(xf86Screens[i]);
- val = (*pScreen->CloseScreen) (i, pScreen);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- return val;
-}
-
-static void
-VGAarbiterBlockHandler(int i,
- pointer blockData, pointer pTimeout, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[i];
- SCREEN_PROLOG(BlockHandler);
- VGAGet(pScreen);
- pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
- VGAPut();
- SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler);
-}
-
-static void
-VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[i];
- SCREEN_PROLOG(WakeupHandler);
- VGAGet(pScreen);
- pScreen->WakeupHandler(i, blockData, result, pReadmask);
- VGAPut();
- SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler);
-}
-
-static void
-VGAarbiterGetImage (
- DrawablePtr pDrawable,
- int sx, int sy, int w, int h,
- unsigned int format,
- unsigned long planemask,
- char *pdstLine
- )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- SCREEN_PROLOG(GetImage);
-// if (xf86Screens[pScreen->myNum]->vtSema) {
- VGAGet(pScreen);
-// }
- (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
- format, planemask, pdstLine);
- VGAPut();
- SCREEN_EPILOG (GetImage, VGAarbiterGetImage);
-}
-
-static void
-VGAarbiterGetSpans (
- DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pdstStart
- )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
-
- SCREEN_PROLOG (GetSpans);
- VGAGet(pScreen);
- (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- VGAPut();
- SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans);
-}
-
-static void
-VGAarbiterSourceValidate (
- DrawablePtr pDrawable,
- int x, int y, int width, int height,
- unsigned int subWindowMode )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- SCREEN_PROLOG (SourceValidate);
- VGAGet(pScreen);
- if (pScreen->SourceValidate)
- (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
- VGAPut();
- SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate);
-}
-
-static void
-VGAarbiterCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc )
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOG (CopyWindow);
- VGAGet(pScreen);
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- VGAPut();
- SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow);
-}
-
-static void
-VGAarbiterClearToBackground (
- WindowPtr pWin,
- int x, int y,
- int w, int h,
- Bool generateExposures )
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOG ( ClearToBackground);
- VGAGet(pScreen);
- (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
- VGAPut();
- SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
-}
-
-static PixmapPtr
-VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
-{
- PixmapPtr pPix;
-
- SCREEN_PROLOG ( CreatePixmap);
- VGAGet(pScreen);
- pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
- VGAPut();
- SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
-
- return pPix;
-}
-
-static Bool
-VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
-{
- Bool val;
-
- SCREEN_PROLOG (SaveScreen);
- VGAGet(pScreen);
- val = (*pScreen->SaveScreen) (pScreen, unblank);
- VGAPut();
- SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen);
-
- return val;
-}
-
-static void
-VGAarbiterStoreColors (
- ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pmap->pScreen;
-
- SCREEN_PROLOG (StoreColors);
- VGAGet(pScreen);
- (*pScreen->StoreColors) (pmap,ndef,pdefs);
- VGAPut();
- SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors);
-}
-
-static void
-VGAarbiterRecolorCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCurs,
- Bool displayed
- )
-{
- SCREEN_PROLOG (RecolorCursor);
- VGAGet(pScreen);
- (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
- VGAPut();
- SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor);
-}
-
-static Bool
-VGAarbiterRealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (RealizeCursor);
- VGAGet(pScreen);
- val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
- VGAPut();
- SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor);
- return val;
-}
-
-static Bool
-VGAarbiterUnrealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (UnrealizeCursor);
- VGAGet(pScreen);
- val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
- VGAPut();
- SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor);
- return val;
-}
-
-static Bool
-VGAarbiterDisplayCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (DisplayCursor);
- VGAGet(pScreen);
- val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
- VGAPut();
- SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor);
- return val;
-}
-
-static Bool
-VGAarbiterSetCursorPosition (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- int x, int y,
- Bool generateEvent)
-{
- Bool val;
-
- SCREEN_PROLOG (SetCursorPosition);
- VGAGet(pScreen);
- val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
- VGAPut();
- SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition);
- return val;
-}
-
-static void
-VGAarbiterAdjustFrame(int index, int x, int y, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- (*pScreenPriv->AdjustFrame)(index, x, y, flags);
- VGAPut();
-}
-
-static Bool
-VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
-{
- Bool val;
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- val = (*pScreenPriv->SwitchMode)(index, mode, flags);
- VGAPut();
- return val;
-}
-
-static Bool
-VGAarbiterEnterVT(int index, int flags)
-{
- Bool val;
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- pScrn->EnterVT = pScreenPriv->EnterVT;
- val = (*pScrn->EnterVT)(index, flags);
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = VGAarbiterEnterVT;
- VGAPut();
- return val;
-}
-
-static void
-VGAarbiterLeaveVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- pScrn->LeaveVT = pScreenPriv->LeaveVT;
- (*pScreenPriv->LeaveVT)(index, flags);
- pScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = VGAarbiterLeaveVT;
- VGAPut();
-}
-
-static void
-VGAarbiterFreeScreen(int index, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- (*pScreenPriv->FreeScreen)(index, flags);
- VGAPut();
-}
-
-static Bool
-VGAarbiterCreateGC(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
- Bool ret;
-
- SCREEN_PROLOG(CreateGC);
- ret = (*pScreen->CreateGC)(pGC);
- GC_WRAP(pGC);
- SCREEN_EPILOG(CreateGC,VGAarbiterCreateGC);
-
- return ret;
-}
-
-/* GC funcs */
-static void
-VGAarbiterValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
-{
- GC_UNWRAP(pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterDestroyGC(GCPtr pGC)
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->DestroyGC)(pGC);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterChangeGC (
- GCPtr pGC,
- unsigned long mask)
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->ChangeGC) (pGC, mask);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterCopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst)
-{
- GC_UNWRAP (pGCDst);
- (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- GC_WRAP (pGCDst);
-}
-
-static void
-VGAarbiterChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects )
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- GC_UNWRAP (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- GC_WRAP (pgcDst);
-}
-
-static void
-VGAarbiterDestroyClip(GCPtr pGC)
-{
- GC_UNWRAP (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- GC_WRAP (pGC);
-}
-
-/* GC Ops */
-static void
-VGAarbiterFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterSetSpans(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- register DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static RegionPtr
-VGAarbiterCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty )
-{
- RegionPtr ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static RegionPtr
-VGAarbiterCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane )
-{
- RegionPtr ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty, bitPlane);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static void
-VGAarbiterPolyPoint(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterPolylines(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolySegment(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyRectangle(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterFillPolygon(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit)
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyFillArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static int
-VGAarbiterPolyText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- int ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static int
-VGAarbiterPolyText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- int ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static void
-VGAarbiterImageText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterImageText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterImageGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPushPixels(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-/* miSpriteFuncs */
-static Bool
-VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static Bool
-VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static void
-VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static void
-VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static Bool
-VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static void
-VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static void
-VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
- PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
- INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
- CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(Composite);
-
- VGAGet(pScreen);
- (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
- yDst, width, height);
- VGAPut();
- PICTURE_EPILOGUE(Composite, VGAarbiterComposite);
-}
-
-static void
-VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
- GlyphListPtr list, GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(Glyphs);
-
- VGAGet(pScreen);
- (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
- VGAPut();
- PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs);
-}
-
-static void
-VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect,
- xRectangle *rects)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(CompositeRects);
-
- VGAGet(pScreen);
- (*ps->CompositeRects)(op, pDst, color, nRect, rects);
- VGAPut();
- PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
-}
-#else
-/* dummy functions */
-void xf86VGAarbiterInit(void) {}
-void xf86VGAarbiterFini(void) {}
-
-void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
-void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) {}
-Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
-
-#endif
+/*
+ * This code was stolen from RAC and adapted to control the legacy vga
+ * interface.
+ *
+ *
+ * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti
+ *
+ * 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 AUTHORS OR COPYRIGHT
+ * HOLDERS 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.
+ *
+ */
+
+#include "xorg-config.h"
+
+#include "xf86VGAarbiter.h"
+#include "xf86VGAarbiterPriv.h"
+#include "xf86Bus.h"
+#include "xf86Priv.h"
+#include "pciaccess.h"
+
+
+static GCFuncs VGAarbiterGCFuncs = {
+ VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
+ VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip,
+ VGAarbiterCopyClip
+};
+
+static GCOps VGAarbiterGCOps = {
+ VGAarbiterFillSpans, VGAarbiterSetSpans, VGAarbiterPutImage,
+ VGAarbiterCopyArea, VGAarbiterCopyPlane, VGAarbiterPolyPoint,
+ VGAarbiterPolylines, VGAarbiterPolySegment, VGAarbiterPolyRectangle,
+ VGAarbiterPolyArc, VGAarbiterFillPolygon, VGAarbiterPolyFillRect,
+ VGAarbiterPolyFillArc, VGAarbiterPolyText8, VGAarbiterPolyText16,
+ VGAarbiterImageText8, VGAarbiterImageText16, VGAarbiterImageGlyphBlt,
+ VGAarbiterPolyGlyphBlt, VGAarbiterPushPixels,
+};
+
+static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
+ VGAarbiterSpriteRealizeCursor, VGAarbiterSpriteUnrealizeCursor,
+ VGAarbiterSpriteSetCursor, VGAarbiterSpriteMoveCursor,
+ VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
+};
+
+static DevPrivateKeyRec VGAarbiterScreenKeyRec;
+#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
+static DevPrivateKeyRec VGAarbiterGCKeyRec;
+#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
+
+static int vga_no_arb = 0;
+void
+xf86VGAarbiterInit(void)
+{
+ if (pci_device_vgaarb_init() != 0) {
+ vga_no_arb = 1;
+ xf86Msg(X_WARNING, "VGA arbiter: cannot open kernel arbiter, no multi-card support\n");
+ }
+}
+
+void
+xf86VGAarbiterFini(void)
+{
+ if (vga_no_arb)
+ return;
+ pci_device_vgaarb_fini();
+}
+
+void
+xf86VGAarbiterLock(ScrnInfoPtr pScrn)
+{
+ if (vga_no_arb)
+ return;
+ pci_device_vgaarb_set_target(pScrn->vgaDev);
+ pci_device_vgaarb_lock();
+}
+
+void
+xf86VGAarbiterUnlock(ScrnInfoPtr pScrn)
+{
+ if (vga_no_arb)
+ return;
+ pci_device_vgaarb_unlock();
+}
+
+Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
+{
+ int vga_count;
+ int rsrc_decodes;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if (vga_no_arb)
+ return TRUE;
+
+ pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
+ if (vga_count > 1) {
+ if (rsrc_decodes) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+void
+xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
+{
+ struct pci_device *dev;
+ EntityPtr pEnt;
+
+ if (vga_no_arb)
+ return;
+
+ pEnt = xf86Entities[pScrn->entityList[0]];
+ if (pEnt->bus.type != BUS_PCI)
+ return;
+
+ dev = pEnt->bus.id.pci;
+ pScrn->vgaDev = dev;
+}
+
+void
+xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc)
+{
+ if (vga_no_arb)
+ return;
+ pci_device_vgaarb_set_target(pScrn->vgaDev);
+ pci_device_vgaarb_decodes(rsrc);
+}
+
+Bool
+xf86VGAarbiterWrapFunctions(void)
+{
+ ScrnInfoPtr pScrn;
+ VGAarbiterScreenPtr pScreenPriv;
+ miPointerScreenPtr PointPriv;
+ PictureScreenPtr ps;
+ ScreenPtr pScreen;
+ int vga_count, i;
+
+ if (vga_no_arb)
+ return FALSE;
+
+ /*
+ * we need to wrap the arbiter if we have more than
+ * one VGA card - hotplug cries.
+ */
+ pci_device_vgaarb_get_info(NULL, &vga_count, NULL);
+ if (vga_count < 2 || !xf86Screens)
+ return FALSE;
+
+ xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n",
+ vga_count);
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScreen = xf86Screens[i]->pScreen;
+ ps = GetPictureScreenIfSet(pScreen);
+ pScrn = xf86Screens[pScreen->myNum];
+ PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);
+
+ WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen);
+ WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen);
+ WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler);
+ WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler);
+ WRAP_SCREEN(CreateGC, VGAarbiterCreateGC);
+ WRAP_SCREEN(GetImage, VGAarbiterGetImage);
+ WRAP_SCREEN(GetSpans, VGAarbiterGetSpans);
+ WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate);
+ WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow);
+ WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground);
+ WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap);
+ WRAP_SCREEN(StoreColors, VGAarbiterStoreColors);
+ WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor);
+ WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor);
+ WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
+ WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
+ WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
+ WRAP_PICT(Composite,VGAarbiterComposite);
+ WRAP_PICT(Glyphs,VGAarbiterGlyphs);
+ WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
+ WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
+ WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
+ WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
+ WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT);
+ WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen);
+ WRAP_SPRITE;
+ }
+
+ return TRUE;
+}
+
+/* Screen funcs */
+static Bool
+VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
+{
+ Bool val;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ UNWRAP_SCREEN(CreateGC);
+ UNWRAP_SCREEN(CloseScreen);
+ UNWRAP_SCREEN(GetImage);
+ UNWRAP_SCREEN(GetSpans);
+ UNWRAP_SCREEN(SourceValidate);
+ UNWRAP_SCREEN(CopyWindow);
+ UNWRAP_SCREEN(ClearToBackground);
+ UNWRAP_SCREEN(SaveScreen);
+ UNWRAP_SCREEN(StoreColors);
+ UNWRAP_SCREEN(DisplayCursor);
+ UNWRAP_SCREEN(RealizeCursor);
+ UNWRAP_SCREEN(UnrealizeCursor);
+ UNWRAP_SCREEN(RecolorCursor);
+ UNWRAP_SCREEN(SetCursorPosition);
+ UNWRAP_PICT(Composite);
+ UNWRAP_PICT(Glyphs);
+ UNWRAP_PICT(CompositeRects);
+ UNWRAP_SCREEN_INFO(AdjustFrame);
+ UNWRAP_SCREEN_INFO(SwitchMode);
+ UNWRAP_SCREEN_INFO(EnterVT);
+ UNWRAP_SCREEN_INFO(LeaveVT);
+ UNWRAP_SCREEN_INFO(FreeScreen);
+ UNWRAP_SPRITE;
+
+ free((pointer) pScreenPriv);
+ xf86VGAarbiterLock(xf86Screens[i]);
+ val = (*pScreen->CloseScreen) (i, pScreen);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ return val;
+}
+
+static void
+VGAarbiterBlockHandler(int i,
+ pointer blockData, pointer pTimeout, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ SCREEN_PROLOG(BlockHandler);
+ VGAGet(pScreen);
+ pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
+ VGAPut();
+ SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler);
+}
+
+static void
+VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ SCREEN_PROLOG(WakeupHandler);
+ VGAGet(pScreen);
+ pScreen->WakeupHandler(i, blockData, result, pReadmask);
+ VGAPut();
+ SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler);
+}
+
+static void
+VGAarbiterGetImage (
+ DrawablePtr pDrawable,
+ int sx, int sy, int w, int h,
+ unsigned int format,
+ unsigned long planemask,
+ char *pdstLine
+ )
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ SCREEN_PROLOG(GetImage);
+// if (xf86Screens[pScreen->myNum]->vtSema) {
+ VGAGet(pScreen);
+// }
+ (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
+ format, planemask, pdstLine);
+ VGAPut();
+ SCREEN_EPILOG (GetImage, VGAarbiterGetImage);
+}
+
+static void
+VGAarbiterGetSpans (
+ DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pdstStart
+ )
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ SCREEN_PROLOG (GetSpans);
+ VGAGet(pScreen);
+ (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ VGAPut();
+ SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans);
+}
+
+static void
+VGAarbiterSourceValidate (
+ DrawablePtr pDrawable,
+ int x, int y, int width, int height,
+ unsigned int subWindowMode )
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ SCREEN_PROLOG (SourceValidate);
+ VGAGet(pScreen);
+ if (pScreen->SourceValidate)
+ (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
+ VGAPut();
+ SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate);
+}
+
+static void
+VGAarbiterCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc )
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOG (CopyWindow);
+ VGAGet(pScreen);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ VGAPut();
+ SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow);
+}
+
+static void
+VGAarbiterClearToBackground (
+ WindowPtr pWin,
+ int x, int y,
+ int w, int h,
+ Bool generateExposures )
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOG ( ClearToBackground);
+ VGAGet(pScreen);
+ (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
+ VGAPut();
+ SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
+}
+
+static PixmapPtr
+VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
+{
+ PixmapPtr pPix;
+
+ SCREEN_PROLOG ( CreatePixmap);
+ VGAGet(pScreen);
+ pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
+ VGAPut();
+ SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
+
+ return pPix;
+}
+
+static Bool
+VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
+{
+ Bool val;
+
+ SCREEN_PROLOG (SaveScreen);
+ VGAGet(pScreen);
+ val = (*pScreen->SaveScreen) (pScreen, unblank);
+ VGAPut();
+ SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen);
+
+ return val;
+}
+
+static void
+VGAarbiterStoreColors (
+ ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+
+ SCREEN_PROLOG (StoreColors);
+ VGAGet(pScreen);
+ (*pScreen->StoreColors) (pmap,ndef,pdefs);
+ VGAPut();
+ SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors);
+}
+
+static void
+VGAarbiterRecolorCursor (
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCurs,
+ Bool displayed
+ )
+{
+ SCREEN_PROLOG (RecolorCursor);
+ VGAGet(pScreen);
+ (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
+ VGAPut();
+ SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor);
+}
+
+static Bool
+VGAarbiterRealizeCursor (
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor
+ )
+{
+ Bool val;
+
+ SCREEN_PROLOG (RealizeCursor);
+ VGAGet(pScreen);
+ val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
+ VGAPut();
+ SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor);
+ return val;
+}
+
+static Bool
+VGAarbiterUnrealizeCursor (
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor
+ )
+{
+ Bool val;
+
+ SCREEN_PROLOG (UnrealizeCursor);
+ VGAGet(pScreen);
+ val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
+ VGAPut();
+ SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor);
+ return val;
+}
+
+static Bool
+VGAarbiterDisplayCursor (
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor
+ )
+{
+ Bool val;
+
+ SCREEN_PROLOG (DisplayCursor);
+ VGAGet(pScreen);
+ val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
+ VGAPut();
+ SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor);
+ return val;
+}
+
+static Bool
+VGAarbiterSetCursorPosition (
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ int x, int y,
+ Bool generateEvent)
+{
+ Bool val;
+
+ SCREEN_PROLOG (SetCursorPosition);
+ VGAGet(pScreen);
+ val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
+ VGAPut();
+ SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition);
+ return val;
+}
+
+static void
+VGAarbiterAdjustFrame(int index, int x, int y, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+
+ VGAGet(pScreen);
+ (*pScreenPriv->AdjustFrame)(index, x, y, flags);
+ VGAPut();
+}
+
+static Bool
+VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
+{
+ Bool val;
+ ScreenPtr pScreen = screenInfo.screens[index];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+
+ VGAGet(pScreen);
+ val = (*pScreenPriv->SwitchMode)(index, mode, flags);
+ VGAPut();
+ return val;
+}
+
+static Bool
+VGAarbiterEnterVT(int index, int flags)
+{
+ Bool val;
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+
+ VGAGet(pScreen);
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ val = (*pScrn->EnterVT)(index, flags);
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = VGAarbiterEnterVT;
+ VGAPut();
+ return val;
+}
+
+static void
+VGAarbiterLeaveVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+
+ VGAGet(pScreen);
+ pScrn->LeaveVT = pScreenPriv->LeaveVT;
+ (*pScreenPriv->LeaveVT)(index, flags);
+ pScreenPriv->LeaveVT = pScrn->LeaveVT;
+ pScrn->LeaveVT = VGAarbiterLeaveVT;
+ VGAPut();
+}
+
+static void
+VGAarbiterFreeScreen(int index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, VGAarbiterScreenKey);
+
+ VGAGet(pScreen);
+ (*pScreenPriv->FreeScreen)(index, flags);
+ VGAPut();
+}
+
+static Bool
+VGAarbiterCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
+ Bool ret;
+
+ SCREEN_PROLOG(CreateGC);
+ ret = (*pScreen->CreateGC)(pGC);
+ GC_WRAP(pGC);
+ SCREEN_EPILOG(CreateGC,VGAarbiterCreateGC);
+
+ return ret;
+}
+
+/* GC funcs */
+static void
+VGAarbiterValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw )
+{
+ GC_UNWRAP(pGC);
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ GC_WRAP(pGC);
+}
+
+
+static void
+VGAarbiterDestroyGC(GCPtr pGC)
+{
+ GC_UNWRAP (pGC);
+ (*pGC->funcs->DestroyGC)(pGC);
+ GC_WRAP (pGC);
+}
+
+static void
+VGAarbiterChangeGC (
+ GCPtr pGC,
+ unsigned long mask)
+{
+ GC_UNWRAP (pGC);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ GC_WRAP (pGC);
+}
+
+static void
+VGAarbiterCopyGC (
+ GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst)
+{
+ GC_UNWRAP (pGCDst);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ GC_WRAP (pGCDst);
+}
+
+static void
+VGAarbiterChangeClip (
+ GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects )
+{
+ GC_UNWRAP (pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ GC_WRAP (pGC);
+}
+
+static void
+VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ GC_UNWRAP (pgcDst);
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ GC_WRAP (pgcDst);
+}
+
+static void
+VGAarbiterDestroyClip(GCPtr pGC)
+{
+ GC_UNWRAP (pGC);
+ (* pGC->funcs->DestroyClip)(pGC);
+ GC_WRAP (pGC);
+}
+
+/* GC Ops */
+static void
+VGAarbiterFillSpans(
+ DrawablePtr pDraw,
+ GC *pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterSetSpans(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ register DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPutImage(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad,
+ int format,
+ char *pImage )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static RegionPtr
+VGAarbiterCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty )
+{
+ RegionPtr ret;
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ ret = (*pGC->ops->CopyArea)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ VGAPut();
+ GC_WRAP(pGC);
+ return ret;
+}
+
+static RegionPtr
+VGAarbiterCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ unsigned long bitPlane )
+{
+ RegionPtr ret;
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
+ width, height, dstx, dsty, bitPlane);
+ VGAPut();
+ GC_WRAP(pGC);
+ return ret;
+}
+
+static void
+VGAarbiterPolyPoint(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+
+static void
+VGAarbiterPolylines(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolySegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolyRectangle(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolyArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterFillPolygon(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill,
+ xRectangle *prectInit)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolyFillArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static int
+VGAarbiterPolyText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars )
+{
+ int ret;
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+ VGAPut();
+ GC_WRAP(pGC);
+ return ret;
+}
+
+static int
+VGAarbiterPolyText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars )
+{
+ int ret;
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+ VGAPut();
+ GC_WRAP(pGC);
+ return ret;
+}
+
+static void
+VGAarbiterImageText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterImageText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+
+static void
+VGAarbiterImageGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
+ nglyph, ppci, pglyphBase);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPolyGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
+ nglyph, ppci, pglyphBase);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+static void
+VGAarbiterPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg )
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ GC_UNWRAP(pGC);
+ VGAGet(pScreen);
+ (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ VGAPut();
+ GC_WRAP(pGC);
+}
+
+
+/* miSpriteFuncs */
+static Bool
+VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
+{
+ Bool val;
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
+ VGAPut();
+ SPRITE_EPILOG;
+ return val;
+}
+
+static Bool
+VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
+{
+ Bool val;
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
+ VGAPut();
+ SPRITE_EPILOG;
+ return val;
+}
+
+static void
+VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
+{
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y);
+ VGAPut();
+ SPRITE_EPILOG;
+}
+
+static void
+VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y);
+ VGAPut();
+ SPRITE_EPILOG;
+}
+
+static Bool
+VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+ Bool val;
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
+ VGAPut();
+ SPRITE_EPILOG;
+ return val;
+}
+
+static void
+VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+ SPRITE_PROLOG;
+ VGAGet(pScreen);
+ PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
+ VGAPut();
+ SPRITE_EPILOG;
+}
+
+static void
+VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
+ PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
+ CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ PICTURE_PROLOGUE(Composite);
+
+ VGAGet(pScreen);
+ (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
+ yDst, width, height);
+ VGAPut();
+ PICTURE_EPILOGUE(Composite, VGAarbiterComposite);
+}
+
+static void
+VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
+ GlyphListPtr list, GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ PICTURE_PROLOGUE(Glyphs);
+
+ VGAGet(pScreen);
+ (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+ VGAPut();
+ PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs);
+}
+
+static void
+VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ PICTURE_PROLOGUE(CompositeRects);
+
+ VGAGet(pScreen);
+ (*ps->CompositeRects)(op, pDst, color, nRect, rects);
+ VGAPut();
+ PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86fbBus.c b/xorg-server/hw/xfree86/common/xf86fbBus.c
index 059e378e3..45929804f 100644
--- a/xorg-server/hw/xfree86/common/xf86fbBus.c
+++ b/xorg-server/hw/xfree86/common/xf86fbBus.c
@@ -54,8 +54,10 @@ xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
EntityPtr p;
int num;
+#ifdef XSERVER_LIBPCIACCESS
if (pciSlotClaimed)
return -1;
+#endif
#if defined(__sparc__) || defined (__sparc64__)
if (sbusSlotClaimed)
return -1;
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c
index 2f04ac12f..eb5323cf0 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.c
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.c
@@ -1,1359 +1,1364 @@
-/*
- * Copyright (c) 1997-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).
- */
-
-/*
- * This file contains the interfaces to the bus-specific code
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <X11/X.h>
-#include <pciaccess.h>
-#include "os.h"
-#include "Pci.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "dirent.h" /* DIR, FILE type definitions */
-
-/* Bus-specific headers */
-#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
-
-
-/* Bus-specific globals */
-Bool pciSlotClaimed = FALSE;
-
-#define PCIINFOCLASSES(c) \
- ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
-
-/*
- * PCI classes that have messages printed always. The others are only
- * have a message printed when the vendor/dev IDs are recognised.
- */
-#define PCIALWAYSPRINTCLASSES(c) \
- ( (((c) & 0x00ffff00) \
- == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) )
-
-#define IS_VGA(c) \
- (((c) & 0x00ffff00) \
- == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8)))
-
-
-static struct pci_slot_match xf86IsolateDevice = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
-};
-
-void
-xf86FormatPciBusNumber(int busnum, char *buffer)
-{
- /* 'buffer' should be at least 8 characters long */
- if (busnum < 256)
- sprintf(buffer, "%d", busnum);
- else
- sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
-}
-
-/*
- * xf86Bus.c interface
- */
-
-void
-xf86PciProbe(void)
-{
- int i = 0, k;
- int num = 0;
- struct pci_device *info;
- struct pci_device_iterator *iter;
- struct pci_device ** xf86PciVideoInfo = NULL;
-
-
- if (!xf86scanpci()) {
- xf86PciVideoInfo = NULL;
- return;
- }
-
- iter = pci_slot_match_iterator_create(& xf86IsolateDevice);
- while ((info = pci_device_next(iter)) != NULL) {
- if (PCIINFOCLASSES(info->device_class)) {
- num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- (sizeof(struct pci_device *)
- * (num + 1)));
- xf86PciVideoInfo[num] = NULL;
- xf86PciVideoInfo[num - 1] = info;
-
- pci_device_probe(info);
-#ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA
- if (pci_device_is_boot_vga(info)) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci = info;
- }
-#endif
- info->user_data = 0;
- }
- }
- free(iter);
-
- /* If we haven't found a primary device try a different heuristic */
- if (primaryBus.type == BUS_NONE && num) {
- for (i = 0; i < num; i++) {
- uint16_t command;
-
- info = xf86PciVideoInfo[i];
- pci_device_cfg_read_u16(info, & command, 4);
-
- if ((command & PCI_CMD_MEM_ENABLE)
- && ((num == 1) || IS_VGA(info->device_class))) {
- if (primaryBus.type == BUS_NONE) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci = info;
- } else {
- xf86Msg(X_NOTICE,
- "More than one possible primary device found\n");
- primaryBus.type ^= (BusType)(-1);
- }
- }
- }
- }
-
- /* Print a summary of the video devices found */
- for (k = 0; k < num; k++) {
- const char *prim = " ";
- Bool memdone = FALSE, iodone = FALSE;
-
-
- info = xf86PciVideoInfo[k];
-
- if (!PCIALWAYSPRINTCLASSES(info->device_class))
- continue;
-
- if (xf86IsPrimaryPci(info))
- prim = "*";
-
- xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim,
- info->domain, info->bus, info->dev, info->func,
- info->vendor_id, info->device_id,
- info->subvendor_id, info->subdevice_id);
-
- xf86ErrorF("rev %d", info->revision);
-
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
-
- if ( r->size && ! r->is_IO ) {
- if (!memdone) {
- xf86ErrorF(", Mem @ ");
- memdone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
-
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
-
- if ( r->size && r->is_IO ) {
- if (!iodone) {
- xf86ErrorF(", I/O @ ");
- iodone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
-
- if ( info->rom_size ) {
- xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", (long)info->rom_size);
- }
-
- xf86ErrorF("\n");
- }
- free(xf86PciVideoInfo);
-}
-
-/*
- * If the slot requested is already in use, return -1.
- * Otherwise, claim the slot for the screen requesting it.
- */
-
-int
-xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active)
-{
- EntityPtr p = NULL;
- int num;
-
- if (xf86CheckPciSlot(d)) {
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = chipset;
- p->bus.type = BUS_PCI;
- p->bus.id.pci = d;
- p->active = active;
- p->inUse = FALSE;
- if (dev)
- xf86AddDevToEntity(num, dev);
- pciSlotClaimed = TRUE;
-
- if (active) {
- /* Map in this domain's I/O space */
- p->domainIO = xf86MapLegacyIO(d);
- }
-
- return num;
- } else
- return -1;
-}
-
-/*
- * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
- */
-void
-xf86UnclaimPciSlot(struct pci_device *d)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
-
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- /* Probably the slot should be deallocated? */
- p->bus.type = BUS_NONE;
- return;
- }
- }
-}
-
-/*
- * Parse a BUS ID string, and return the PCI bus parameters if it was
- * in the correct format for a PCI bus id.
- */
-
-Bool
-xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
-{
- /*
- * The format is assumed to be "bus[@domain]:device[:func]", where domain,
- * bus, device and func are decimal integers. domain and func may be
- * omitted and assumed to be zero, although doing this isn't encouraged.
- */
-
- char *p, *s, *d;
- const char *id;
- int i;
-
- if (StringToBusType(busID, &id) != BUS_PCI)
- return FALSE;
-
- s = xstrdup(id);
- p = strtok(s, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
- }
- d = strpbrk(p, "@");
- if (d != NULL) {
- *(d++) = 0;
- for (i = 0; d[i] != 0; i++) {
- if (!isdigit(d[i])) {
- free(s);
- return FALSE;
- }
- }
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *bus = atoi(p);
- if (d != NULL && *d != 0)
- *bus += atoi(d) << 8;
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *device = atoi(p);
- *func = 0;
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return TRUE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *func = atoi(p);
- free(s);
- return TRUE;
-}
-
-/*
- * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
- */
-
-Bool
-xf86ComparePciBusString(const char *busID, int bus, int device, int func)
-{
- int ibus, idevice, ifunc;
-
- if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
- return bus == ibus && device == idevice && func == ifunc;
- } else {
- return FALSE;
- }
-}
-
-/*
- * xf86IsPrimaryPci() -- return TRUE if primary device
- * is PCI and bus, dev and func numbers match.
- */
-
-Bool
-xf86IsPrimaryPci(struct pci_device *pPci)
-{
- return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
-}
-
-/*
- * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
- */
-struct pci_device *
-xf86GetPciInfoForEntity(int entityIndex)
-{
- EntityPtr p;
-
- if (entityIndex >= xf86NumEntities)
- return NULL;
-
- p = xf86Entities[entityIndex];
- return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
-}
-
-/*
- * xf86CheckPciMemBase() checks that the memory base value matches one of the
- * PCI base address register values for the given PCI device.
- */
-Bool
-xf86CheckPciMemBase( struct pci_device * pPci, memType base )
-{
- int i;
-
- for (i = 0; i < 6; i++)
- if (base == pPci->regions[i].base_addr)
- return TRUE;
- return FALSE;
-}
-
-/*
- * Check if the slot requested is free. If it is already in use, return FALSE.
- */
-
-Bool
-xf86CheckPciSlot(const struct pci_device *d)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
-
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-#define END_OF_MATCHES(m) \
- (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
-
-Bool
-xf86PciAddMatchingDev(DriverPtr drvp)
-{
- const struct pci_id_match * const devices = drvp->supported_devices;
- int j;
- struct pci_device *pPci;
- struct pci_device_iterator *iter;
- int numFound = 0;
-
-
- iter = pci_id_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- /* Determine if this device is supported by the driver. If it is,
- * add it to the list of devices to configure.
- */
- for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
- && ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev = xf86AddBusDeviceToConfigure(
- drvp->driverName, BUS_PCI, pPci, -1);
- if (pGDev != NULL) {
- /* After configure pass 1, chipID and chipRev are
- * treated as over-rides, so clobber them here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
-
- numFound++;
- }
-
- break;
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
- return numFound != 0;
-}
-
-Bool
-xf86PciProbeDev(DriverPtr drvp)
-{
- int i, j;
- struct pci_device * pPci;
- Bool foundScreen = FALSE;
- const struct pci_id_match * const devices = drvp->supported_devices;
- GDevPtr *devList;
- const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList);
-
- for ( i = 0 ; i < numDevs ; i++ ) {
- struct pci_device_iterator *iter;
- unsigned device_id;
-
-
- /* Find the pciVideoRec associated with this device section.
- */
- iter = pci_id_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- if (devList[i]->busID && *devList[i]->busID) {
- if (xf86ComparePciBusString(devList[i]->busID,
- ((pPci->domain << 8)
- | pPci->bus),
- pPci->dev,
- pPci->func)) {
- break;
- }
- }
- else if (xf86IsPrimaryPci(pPci)) {
- break;
- }
- }
-
- pci_iterator_destroy(iter);
-
- if (pPci == NULL) {
- continue;
- }
- device_id = (devList[i]->chipID > 0)
- ? devList[i]->chipID : pPci->device_id;
-
-
- /* Once the pciVideoRec is found, determine if the device is supported
- * by the driver. If it is, probe it!
- */
- for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, device_id )
- && ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- int entry;
-
- /* Allow the same entity to be used more than once for
- * devices with multiple screens per entity. This assumes
- * implicitly that there will be a screen == 0 instance.
- *
- * FIXME Need to make sure that two different drivers don't
- * FIXME claim the same screen > 0 instance.
- */
- if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- drvp->driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- entry = xf86ClaimPciSlot(pPci, drvp, device_id,
- devList[i], devList[i]->active);
-
- if ((entry == -1) && (devList[i]->screen > 0)) {
- unsigned k;
-
- for (k = 0; k < xf86NumEntities; k++ ) {
- EntityPtr pEnt = xf86Entities[k];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- entry = k;
- xf86AddDevToEntity(k, devList[i]);
- break;
- }
- }
- }
-
- if (entry != -1) {
- if ((*drvp->PciProbe)(drvp, entry, pPci,
- devices[j].match_data)) {
- foundScreen = TRUE;
- } else
- xf86UnclaimPciSlot(pPci);
- }
-
- break;
- }
- }
- }
- free(devList);
-
- return foundScreen;
-}
-
-void
-xf86PciIsolateDevice(char *argument)
-{
- int bus, device, func;
-
- if (sscanf(argument, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus);
- xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
- xf86IsolateDevice.dev = device;
- xf86IsolateDevice.func = func;
- } else
- FatalError("Invalid isolated device specification\n");
-}
-
-static Bool
-pciDeviceHasBars(struct pci_device *pci)
-{
- int i;
-
- for (i = 0; i < 6; i++)
- if (pci->regions[i].size)
- return TRUE;
-
- if (pci->rom_size)
- return TRUE;
-
- return FALSE;
-}
-
-struct Inst {
- struct pci_device * pci;
- GDevPtr dev;
- Bool foundHW; /* PCIid in list of supported chipsets */
- Bool claimed; /* BusID matches with a device section */
- int chip;
- int screen;
-};
-
-
-/**
- * Find set of unclaimed devices matching a given vendor ID.
- *
- * Used by drivers to find as yet unclaimed devices matching the specified
- * vendor ID.
- *
- * \param driverName Name of the driver. This is used to find Device
- * sections in the config file.
- * \param vendorID PCI vendor ID of associated devices. If zero, then
- * the true vendor ID must be encoded in the \c PCIid
- * fields of the \c PCIchipsets entries.
- * \param chipsets Symbol table used to associate chipset names with
- * PCI IDs.
- * \param devList List of Device sections parsed from the config file.
- * \param numDevs Number of entries in \c devList.
- * \param drvp Pointer the driver's control structure.
- * \param foundEntities Returned list of entity indicies associated with the
- * driver.
- *
- * \returns
- * The number of elements in returned in \c foundEntities on success or zero
- * on failure.
- *
- * \todo
- * This function does a bit more than short description says. Fill in some
- * more of the details of its operation.
- *
- * \todo
- * The \c driverName parameter is redundant. It is the same as
- * \c DriverRec::driverName. In a future version of this function, remove
- * that parameter.
- */
-int
-xf86MatchPciInstances(const char *driverName, int vendorID,
- SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities)
-{
- int i,j;
- struct pci_device * pPci;
- struct pci_device_iterator *iter;
- struct Inst *instances = NULL;
- int numClaimedInstances = 0;
- int allocatedInstances = 0;
- int numFound = 0;
- SymTabRec *c;
- PciChipsets *id;
- int *retEntities = NULL;
-
- *foundEntities = NULL;
-
-
- /* Each PCI device will contribute at least one entry. Each device
- * section can contribute at most one entry. The sum of the two is
- * guaranteed to be larger than the maximum possible number of entries.
- * Do this calculation and memory allocation once now to eliminate the
- * need for realloc calls inside the loop.
- */
- if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
- unsigned max_entries = numDevs;
-
- iter = pci_slot_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- max_entries++;
- }
-
- pci_iterator_destroy(iter);
- instances = xnfalloc(max_entries * sizeof(struct Inst));
- }
-
- iter = pci_slot_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- unsigned device_class = pPci->device_class;
- Bool foundVendor = FALSE;
-
-
- /* Convert the pre-PCI 2.0 device class for a VGA adapter to the
- * 2.0 version of the same class.
- */
- if ( device_class == 0x00000101 ) {
- device_class = 0x00030000;
- }
-
-
- /* Find PCI devices that match the given vendor ID. The vendor ID is
- * either specified explicitly as a parameter to the function or
- * implicitly encoded in the high bits of id->PCIid.
- *
- * The first device with a matching vendor is recorded, even if the
- * device ID doesn't match. This is done because the Device section
- * in the xorg.conf file can over-ride the device ID. A matching PCI
- * ID might not be found now, but after the device ID over-ride is
- * applied there /might/ be a match.
- */
- for (id = PCIchipsets; id->PCIid != -1; id++) {
- const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
- | vendorID;
- const unsigned device_id = (id->PCIid & 0x0000FFFF);
- const unsigned match_class = 0x00030000 | id->PCIid;
-
- if ((vendor_id == pPci->vendor_id)
- || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
- if (!foundVendor && (instances != NULL)) {
- ++allocatedInstances;
- instances[allocatedInstances - 1].pci = pPci;
- instances[allocatedInstances - 1].dev = NULL;
- instances[allocatedInstances - 1].claimed = FALSE;
- instances[allocatedInstances - 1].foundHW = FALSE;
- instances[allocatedInstances - 1].screen = 0;
- }
-
- foundVendor = TRUE;
-
- if ( (device_id == pPci->device_id)
- || ((vendorID == PCI_VENDOR_GENERIC)
- && (match_class == device_class)) ) {
- if ( instances != NULL ) {
- instances[allocatedInstances - 1].foundHW = TRUE;
- instances[allocatedInstances - 1].chip = id->numChipset;
- }
-
-
- if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev =
- xf86AddBusDeviceToConfigure(drvp->driverName,
- BUS_PCI, pPci, -1);
- if (pGDev) {
- /* After configure pass 1, chipID and chipRev
- * are treated as over-rides, so clobber them
- * here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
-
- numFound++;
- }
- }
- else {
- numFound++;
- }
-
- break;
- }
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
-
- /* In "probe only" or "configure" mode (signaled by instances being NULL),
- * our work is done. Return the number of detected devices.
- */
- if ( instances == NULL ) {
- return numFound;
- }
-
-
- /*
- * This may be debatable, but if no PCI devices with a matching vendor
- * type is found, return zero now. It is probably not desirable to
- * allow the config file to override this.
- */
- if (allocatedInstances <= 0) {
- free(instances);
- return 0;
- }
-
-
- DebugF("%s instances found: %d\n", driverName, allocatedInstances);
-
- /*
- * Check for devices that need duplicated instances. This is required
- * when there is more than one screen per entity.
- *
- * XXX This currently doesn't work for cases where the BusID isn't
- * specified explicitly in the config file.
- */
-
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->screen > 0 && devList[j]->busID
- && *devList[j]->busID) {
- for (i = 0; i < allocatedInstances; i++) {
- pPci = instances[i].pci;
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func)) {
- allocatedInstances++;
- instances[allocatedInstances - 1] = instances[i];
- instances[allocatedInstances - 1].screen = devList[j]->screen;
- numFound++;
- break;
- }
- }
- }
- }
-
- for (i = 0; i < allocatedInstances; i++) {
- GDevPtr dev = NULL;
- GDevPtr devBus = NULL;
-
- pPci = instances[i].pci;
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->busID && *devList[j]->busID) {
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func) &&
- devList[j]->screen == instances[i].screen) {
-
- if (devBus)
- xf86MsgVerb(X_WARNING,0,
- "%s: More than one matching Device section for "
- "instances\n\t(BusID: %s) found: %s\n",
- driverName, devList[j]->busID,
- devList[j]->identifier);
- else
- devBus = devList[j];
- }
- } else {
- /*
- * if device section without BusID is found
- * only assign to it to the primary device.
- */
- if (xf86IsPrimaryPci(pPci)) {
- xf86Msg(X_PROBED, "Assigning device section with no busID"
- " to primary device\n");
- if (dev || devBus)
- xf86MsgVerb(X_WARNING, 0,
- "%s: More than one matching Device section "
- "found: %s\n", driverName, devList[j]->identifier);
- else
- dev = devList[j];
- }
- }
- }
- if (devBus) dev = devBus; /* busID preferred */
- if (!dev) {
- if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
- xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID PCI:%u@%u:%u:%u) found\n",
- driverName, pPci->domain, pPci->bus, pPci->dev,
- pPci->func);
- }
- } else {
- numClaimedInstances++;
- instances[i].claimed = TRUE;
- instances[i].dev = dev;
- }
- }
- DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
- /*
- * Now check that a chipset or chipID override in the device section
- * is valid. Chipset has precedence over chipID.
- * If chipset is not valid ignore BusSlot completely.
- */
- for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- MessageType from = X_PROBED;
-
- if (!instances[i].claimed) {
- continue;
- }
- if (instances[i].dev->chipset) {
- for (c = chipsets; c->token >= 0; c++) {
- if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
- break;
- }
- if (c->token == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = c->token;
-
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->numChipset == instances[i].chip)
- break;
- }
- if(id->numChipset >=0){
- xf86Msg(X_CONFIG,"Chipset override: %s\n",
- instances[i].dev->chipset);
- from = X_CONFIG;
- } else {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't a valid PCI chipset\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- }
- }
- } else if (instances[i].dev->chipID > 0) {
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->PCIid == instances[i].dev->chipID)
- break;
- }
- if (id->numChipset == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipID,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = id->numChipset;
-
- xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
- instances[i].dev->chipID);
- from = X_CONFIG;
- }
- } else if (!instances[i].foundHW) {
- /*
- * This means that there was no override and the PCI chipType
- * doesn't match one that is supported
- */
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- }
- if (instances[i].claimed == TRUE){
- for (c = chipsets; c->token >= 0; c++) {
- if (c->token == instances[i].chip)
- break;
- }
- xf86Msg(from,"Chipset %s found\n",
- c->name);
- }
- }
-
- /*
- * Of the claimed instances, check that another driver hasn't already
- * claimed its slot.
- */
- numFound = 0;
- for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- if (!instances[i].claimed)
- continue;
- pPci = instances[i].pci;
-
-
- /*
- * Allow the same entity to be used more than once for devices with
- * multiple screens per entity. This assumes implicitly that there
- * will be a screen == 0 instance.
- *
- * XXX Need to make sure that two different drivers don't claim
- * the same screen > 0 instance.
- */
- if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
- retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
- instances[i].chip,
- instances[i].dev,
- instances[i].dev->active);
- if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
- for (j = 0; j < xf86NumEntities; j++) {
- EntityPtr pEnt = xf86Entities[j];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- retEntities[numFound - 1] = j;
- xf86AddDevToEntity(j, instances[i].dev);
- break;
- }
- }
- }
- }
- free(instances);
- if (numFound > 0) {
- *foundEntities = retEntities;
- }
-
- return numFound;
-}
-
-/*
- * xf86ConfigPciEntityInactive() -- This function can be used
- * to configure an inactive entity as well as to reconfigure an
- * previously active entity inactive. If the entity has been
- * assigned to a screen before it will be removed. If p_chip is
- * non-NULL all static resources listed there will be registered.
- */
-static void
-xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
- EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
-{
- ScrnInfoPtr pScrn;
-
- if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
- xf86RemoveEntityFromScreen(pScrn,pEnt->index);
-
- /* shared resources are only needed when entity is active: remove */
- xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
-}
-
-ScrnInfoPtr
-xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return pScrn;
-
- if (!(pEnt->location.type == BUS_PCI)
- || !xf86GetPciInfoForEntity(entityIndex)) {
- free(pEnt);
- return pScrn;
- }
- if (!pEnt->active) {
- xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter,
- leave, private);
- free(pEnt);
- return pScrn;
- }
-
- if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
- if (xf86IsEntitySharable(entityIndex)) {
- xf86SetEntityShared(entityIndex);
- }
- xf86AddEntityToScreen(pScrn,entityIndex);
- if (xf86IsEntityShared(entityIndex)) {
- return pScrn;
- }
- free(pEnt);
-
- xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
-
- return pScrn;
-}
-
-/*
- * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
- * It is likely to be removed. Don't use!
- */
-Bool
-xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return FALSE;
-
- if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
- free(pEnt);
- return FALSE;
- }
- xf86AddEntityToScreen(pScrn,entityIndex);
-
- free(pEnt);
- if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
- return FALSE;
-
- return TRUE;
-}
-
-static int
-videoPtrToDriverList(struct pci_device *dev,
- char *returnList[], int returnListMax)
-{
- int i;
- /* Add more entries here if we ever return more than 4 drivers for
- any device */
- char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
-
- switch (dev->vendor_id)
- {
- /* AMD Geode LX */
- case 0x1022:
- if (dev->device_id == 0x2081)
- driverList[0] = "geode";
- break;
- /* older Geode products acquired by AMD still carry an NSC vendor_id */
- case 0x100b:
- if (dev->device_id == 0x0030) {
- /* NSC Geode GX2 specifically */
- driverList[0] = "geode";
- /* GX2 support started its life in the NSC tree and was later
- forked by AMD for GEODE so we keep it as a backup */
- driverList[1] = "nsc";
- } else
- /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
- driverList[0] = "nsc";
- break;
- /* Cyrix Geode GX1 */
- case 0x1078:
- if (dev->device_id == 0x0104)
- driverList[0] = "cyrix";
- break;
- case 0x1142: driverList[0] = "apm"; break;
- case 0xedd8: driverList[0] = "ark"; break;
- case 0x1a03: driverList[0] = "ast"; break;
- case 0x1002: driverList[0] = "ati"; break;
- case 0x102c: driverList[0] = "chips"; break;
- case 0x1013: driverList[0] = "cirrus"; break;
- case 0x3d3d: driverList[0] = "glint"; break;
- case 0x105d: driverList[0] = "i128"; break;
- case 0x8086:
- if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
- driverList[0] = "i740";
- } else if (dev->device_id == 0x8108) {
- break; /* "hooray" for poulsbo */
- } else {
- driverList[0] = "intel";
- }
- break;
- case 0x102b: driverList[0] = "mga"; break;
- case 0x10c8: driverList[0] = "neomagic"; break;
- case 0x10de: case 0x12d2: driverList[0] = "nv"; break;
- case 0x1106: driverList[0] = "openchrome"; break;
- case 0x1b36: driverList[0] = "qxl"; break;
- case 0x1163: driverList[0] = "rendition"; break;
- case 0x5333:
- switch (dev->device_id)
- {
- case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
- case 0x8812: case 0x8814: case 0x8901:
- driverList[0] = "s3"; break;
- case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
- case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
- driverList[0] = "s3virge"; break;
- default:
- driverList[0] = "savage"; break;
- }
- break;
- case 0x1039: driverList[0] = "sis"; break;
- case 0x126f: driverList[0] = "siliconmotion"; break;
- case 0x121a:
- if (dev->device_id < 0x0003)
- driverList[0] = "voodoo";
- else
- driverList[0] = "tdfx";
- break;
- case 0x1011: driverList[0] = "tga"; break;
- case 0x1023: driverList[0] = "trident"; break;
- case 0x100c: driverList[0] = "tseng"; break;
- case 0x80ee: driverList[0] = "vboxvideo"; break;
- case 0x15ad: driverList[0] = "vmware"; break;
- case 0x18ca:
- if (dev->device_id == 0x47)
- driverList[0] = "xgixp";
- else
- driverList[0] = "xgi";
- break;
- default: break;
- }
- for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
- returnList[i] = xnfstrdup(driverList[i]);
- }
- return i; /* Number of entries added */
-}
-
-#ifdef __linux__
-static int
-xchomp(char *line)
-{
- size_t len = 0;
-
- if (!line) {
- return 1;
- }
-
- len = strlen(line);
- if (line[len - 1] == '\n' && len > 0) {
- line[len - 1] = '\0';
- }
- return 0;
-}
-
-/* This function is used to provide a workaround for binary drivers that
- * don't export their PCI ID's properly. If distros don't end up using this
- * feature it can and should be removed because the symbol-based resolution
- * scheme should be the primary one */
-static void
-matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
-{
- DIR *idsdir;
- FILE *fp;
- struct dirent *direntry;
- char *line = NULL;
- size_t len;
- ssize_t read;
- char path_name[256], vendor_str[5], chip_str[5];
- uint16_t vendor, chip;
- int i, j;
-
- idsdir = opendir(PCI_TXT_IDS_PATH);
- if (!idsdir)
- return;
-
- xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
- direntry = readdir(idsdir);
- /* Read the directory */
- while (direntry) {
- if (direntry->d_name[0] == '.') {
- direntry = readdir(idsdir);
- continue;
- }
- len = strlen(direntry->d_name);
- /* A tiny bit of sanity checking. We should probably do better */
- if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
- /* We need the full path name to open the file */
- strncpy(path_name, PCI_TXT_IDS_PATH, 256);
- strncat(path_name, "/", 1);
- strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
- fp = fopen(path_name, "r");
- if (fp == NULL) {
- xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
- goto end;
- }
- /* Read the file */
-#ifdef __GLIBC__
- while ((read = getline(&line, &len, fp)) != -1) {
-#else
- while ((line = fgetln(fp, &len)) != (char *)NULL) {
-#endif /* __GLIBC __ */
- xchomp(line);
- if (isdigit(line[0])) {
- strncpy(vendor_str, line, 4);
- vendor_str[4] = '\0';
- vendor = (int)strtol(vendor_str, NULL, 16);
- if ((strlen(&line[4])) == 0) {
- chip_str[0] = '\0';
- chip = -1;
- } else {
- /* Handle trailing whitespace */
- if (isspace(line[4])) {
- chip_str[0] = '\0';
- chip = -1;
- } else {
- /* Ok, it's a real ID */
- strncpy(chip_str, &line[4], 4);
- chip_str[4] = '\0';
- chip = (int)strtol(chip_str, NULL, 16);
- }
- }
- if (vendor == match_vendor && chip == match_chip ) {
- i = 0;
- while (matches[i]) {
- i++;
- }
- matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3);
- if (!matches[i]) {
- xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
- goto end;
- }
- /* hack off the .ids suffix. This should guard
- * against other problems, but it will end up
- * taking off anything after the first '.' */
- for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
- if (direntry->d_name[j] == '.') {
- matches[i][j] = '\0';
- break;
- } else {
- matches[i][j] = direntry->d_name[j];
- }
- }
- xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
- }
- } else {
- /* TODO Handle driver overrides here */
- }
- }
- fclose(fp);
- }
- direntry = readdir(idsdir);
- }
- end:
- free(line);
- closedir(idsdir);
-}
-#endif /* __linux__ */
-
-/**
- * @return The numbers of found devices that match with the current system
- * drivers.
- */
-int
-xf86PciMatchDriver(char* matches[], int nmatches) {
- int i;
- struct pci_device * info = NULL;
- struct pci_device_iterator *iter;
-
- /* Find the primary device, and get some information about it. */
- iter = pci_slot_match_iterator_create(NULL);
- while ((info = pci_device_next(iter)) != NULL) {
- if (xf86IsPrimaryPci(info)) {
- break;
- }
- }
-
- pci_iterator_destroy(iter);
-#ifdef __linux__
- if (info)
- matchDriverFromFiles(matches, info->vendor_id, info->device_id);
-#endif
-
- for (i = 0; (i < nmatches) && (matches[i]); i++) {
- /* find end of matches list */
- }
-
- if ((info != NULL) && (i < nmatches)) {
- i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
- }
-
- return i;
-}
-
-Bool
-xf86PciConfigure(void *busData, struct pci_device *pDev)
-{
- struct pci_device * pVideo = NULL;
-
- pVideo = (struct pci_device *) busData;
- if (pDev &&
- (pDev->domain == pVideo->domain) &&
- (pDev->bus == pVideo->bus) &&
- (pDev->dev == pVideo->dev) &&
- (pDev->func == pVideo->func))
- return 0;
-
- return 1;
-}
-
-void
-xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
- GDevRec *GDev, int *chipset)
-{
- char busnum[8];
-
- pVideo = (struct pci_device *) busData;
-
- xf86FormatPciBusNumber(pVideo->bus, busnum);
- XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
- busnum, pVideo->dev, pVideo->func);
-
- GDev->chipID = pVideo->device_id;
- GDev->chipRev = pVideo->revision;
-
- if (*chipset < 0)
- *chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
-}
+/*
+ * Copyright (c) 1997-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).
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include <pciaccess.h>
+#include "os.h"
+#include "Pci.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "dirent.h" /* DIR, FILE type definitions */
+
+/* Bus-specific headers */
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+
+
+/* Bus-specific globals */
+Bool pciSlotClaimed = FALSE;
+
+#define PCIINFOCLASSES(c) \
+ ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
+ || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
+
+/*
+ * PCI classes that have messages printed always. The others are only
+ * have a message printed when the vendor/dev IDs are recognised.
+ */
+#define PCIALWAYSPRINTCLASSES(c) \
+ ( (((c) & 0x00ffff00) \
+ == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \
+ || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) )
+
+#define IS_VGA(c) \
+ (((c) & 0x00ffff00) \
+ == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8)))
+
+
+static struct pci_slot_match xf86IsolateDevice = {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
+};
+
+void
+xf86FormatPciBusNumber(int busnum, char *buffer)
+{
+ /* 'buffer' should be at least 8 characters long */
+ if (busnum < 256)
+ sprintf(buffer, "%d", busnum);
+ else
+ sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
+}
+
+/*
+ * xf86Bus.c interface
+ */
+
+void
+xf86PciProbe(void)
+{
+ int i = 0, k;
+ int num = 0;
+ struct pci_device *info;
+ struct pci_device_iterator *iter;
+ struct pci_device ** xf86PciVideoInfo = NULL;
+
+
+ if (!xf86scanpci()) {
+ xf86PciVideoInfo = NULL;
+ return;
+ }
+
+ iter = pci_slot_match_iterator_create(& xf86IsolateDevice);
+ while ((info = pci_device_next(iter)) != NULL) {
+ if (PCIINFOCLASSES(info->device_class)) {
+ num++;
+ xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
+ (sizeof(struct pci_device *)
+ * (num + 1)));
+ xf86PciVideoInfo[num] = NULL;
+ xf86PciVideoInfo[num - 1] = info;
+
+ pci_device_probe(info);
+ if (pci_device_is_boot_vga(info)) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci = info;
+ }
+ info->user_data = 0;
+ }
+ }
+ free(iter);
+
+ /* If we haven't found a primary device try a different heuristic */
+ if (primaryBus.type == BUS_NONE && num) {
+ for (i = 0; i < num; i++) {
+ uint16_t command;
+
+ info = xf86PciVideoInfo[i];
+ pci_device_cfg_read_u16(info, & command, 4);
+
+ if ((command & PCI_CMD_MEM_ENABLE)
+ && ((num == 1) || IS_VGA(info->device_class))) {
+ if (primaryBus.type == BUS_NONE) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci = info;
+ } else {
+ xf86Msg(X_NOTICE,
+ "More than one possible primary device found\n");
+ primaryBus.type ^= (BusType)(-1);
+ }
+ }
+ }
+ }
+
+ /* Print a summary of the video devices found */
+ for (k = 0; k < num; k++) {
+ const char *prim = " ";
+ Bool memdone = FALSE, iodone = FALSE;
+
+
+ info = xf86PciVideoInfo[k];
+
+ if (!PCIALWAYSPRINTCLASSES(info->device_class))
+ continue;
+
+ if (xf86IsPrimaryPci(info))
+ prim = "*";
+
+ xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim,
+ info->domain, info->bus, info->dev, info->func,
+ info->vendor_id, info->device_id,
+ info->subvendor_id, info->subdevice_id);
+
+ xf86ErrorF("rev %d", info->revision);
+
+ for (i = 0; i < 6; i++) {
+ struct pci_mem_region * r = & info->regions[i];
+
+ if ( r->size && ! r->is_IO ) {
+ if (!memdone) {
+ xf86ErrorF(", Mem @ ");
+ memdone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
+ }
+ }
+
+ for (i = 0; i < 6; i++) {
+ struct pci_mem_region * r = & info->regions[i];
+
+ if ( r->size && r->is_IO ) {
+ if (!iodone) {
+ xf86ErrorF(", I/O @ ");
+ iodone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
+ }
+ }
+
+ if ( info->rom_size ) {
+ xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", (long)info->rom_size);
+ }
+
+ xf86ErrorF("\n");
+ }
+ free(xf86PciVideoInfo);
+}
+
+/*
+ * If the slot requested is already in use, return -1.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p = NULL;
+ int num;
+
+ if (xf86CheckPciSlot(d)) {
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->bus.type = BUS_PCI;
+ p->bus.id.pci = d;
+ p->active = active;
+ p->inUse = FALSE;
+ if (dev)
+ xf86AddDevToEntity(num, dev);
+ pciSlotClaimed = TRUE;
+
+ return num;
+ } else
+ return -1;
+}
+
+/*
+ * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
+ */
+void
+xf86UnclaimPciSlot(struct pci_device *d)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ const EntityPtr p = xf86Entities[i];
+
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+ /* Probably the slot should be deallocated? */
+ p->bus.type = BUS_NONE;
+ return;
+ }
+ }
+}
+
+/*
+ * Parse a BUS ID string, and return the PCI bus parameters if it was
+ * in the correct format for a PCI bus id.
+ */
+
+Bool
+xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
+{
+ /*
+ * The format is assumed to be "bus[@domain]:device[:func]", where domain,
+ * bus, device and func are decimal integers. domain and func may be
+ * omitted and assumed to be zero, although doing this isn't encouraged.
+ */
+
+ char *p, *s, *d;
+ const char *id;
+ int i;
+
+ if (StringToBusType(busID, &id) != BUS_PCI)
+ return FALSE;
+
+ s = xstrdup(id);
+ p = strtok(s, ":");
+ if (p == NULL || *p == 0) {
+ free(s);
+ return FALSE;
+ }
+ d = strpbrk(p, "@");
+ if (d != NULL) {
+ *(d++) = 0;
+ for (i = 0; d[i] != 0; i++) {
+ if (!isdigit(d[i])) {
+ free(s);
+ return FALSE;
+ }
+ }
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
+ }
+ *bus = atoi(p);
+ if (d != NULL && *d != 0)
+ *bus += atoi(d) << 8;
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ free(s);
+ return FALSE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
+ }
+ *device = atoi(p);
+ *func = 0;
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ free(s);
+ return TRUE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
+ }
+ *func = atoi(p);
+ free(s);
+ return TRUE;
+}
+
+/*
+ * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
+ */
+
+Bool
+xf86ComparePciBusString(const char *busID, int bus, int device, int func)
+{
+ int ibus, idevice, ifunc;
+
+ if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
+ return bus == ibus && device == idevice && func == ifunc;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * xf86IsPrimaryPci() -- return TRUE if primary device
+ * is PCI and bus, dev and func numbers match.
+ */
+
+Bool
+xf86IsPrimaryPci(struct pci_device *pPci)
+{
+ return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
+}
+
+/*
+ * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
+ */
+struct pci_device *
+xf86GetPciInfoForEntity(int entityIndex)
+{
+ EntityPtr p;
+
+ if (entityIndex >= xf86NumEntities)
+ return NULL;
+
+ p = xf86Entities[entityIndex];
+ return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
+}
+
+/*
+ * xf86CheckPciMemBase() checks that the memory base value matches one of the
+ * PCI base address register values for the given PCI device.
+ */
+Bool
+xf86CheckPciMemBase( struct pci_device * pPci, memType base )
+{
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (base == pPci->regions[i].base_addr)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Check if the slot requested is free. If it is already in use, return FALSE.
+ */
+
+Bool
+xf86CheckPciSlot(const struct pci_device *d)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ const EntityPtr p = xf86Entities[i];
+
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+#define END_OF_MATCHES(m) \
+ (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
+
+Bool
+xf86PciAddMatchingDev(DriverPtr drvp)
+{
+ const struct pci_id_match * const devices = drvp->supported_devices;
+ int j;
+ struct pci_device *pPci;
+ struct pci_device_iterator *iter;
+ int numFound = 0;
+
+
+ iter = pci_id_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ /* Determine if this device is supported by the driver. If it is,
+ * add it to the list of devices to configure.
+ */
+ for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) {
+ if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
+ && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
+ && ((devices[j].device_class_mask & pPci->device_class)
+ == devices[j].device_class) ) {
+ if (xf86CheckPciSlot(pPci)) {
+ GDevPtr pGDev = xf86AddBusDeviceToConfigure(
+ drvp->driverName, BUS_PCI, pPci, -1);
+ if (pGDev != NULL) {
+ /* After configure pass 1, chipID and chipRev are
+ * treated as over-rides, so clobber them here.
+ */
+ pGDev->chipID = -1;
+ pGDev->chipRev = -1;
+ }
+
+ numFound++;
+ }
+
+ break;
+ }
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+ return numFound != 0;
+}
+
+Bool
+xf86PciProbeDev(DriverPtr drvp)
+{
+ int i, j;
+ struct pci_device * pPci;
+ Bool foundScreen = FALSE;
+ const struct pci_id_match * const devices = drvp->supported_devices;
+ GDevPtr *devList;
+ const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList);
+
+ for ( i = 0 ; i < numDevs ; i++ ) {
+ struct pci_device_iterator *iter;
+ unsigned device_id;
+
+
+ /* Find the pciVideoRec associated with this device section.
+ */
+ iter = pci_id_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ if (devList[i]->busID && *devList[i]->busID) {
+ if (xf86ComparePciBusString(devList[i]->busID,
+ ((pPci->domain << 8)
+ | pPci->bus),
+ pPci->dev,
+ pPci->func)) {
+ break;
+ }
+ }
+ else if (xf86IsPrimaryPci(pPci)) {
+ break;
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+ if (pPci == NULL) {
+ continue;
+ }
+ device_id = (devList[i]->chipID > 0)
+ ? devList[i]->chipID : pPci->device_id;
+
+
+ /* Once the pciVideoRec is found, determine if the device is supported
+ * by the driver. If it is, probe it!
+ */
+ for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) {
+ if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
+ && PCI_ID_COMPARE( devices[j].device_id, device_id )
+ && ((devices[j].device_class_mask & pPci->device_class)
+ == devices[j].device_class) ) {
+ int entry;
+
+ /* Allow the same entity to be used more than once for
+ * devices with multiple screens per entity. This assumes
+ * implicitly that there will be a screen == 0 instance.
+ *
+ * FIXME Need to make sure that two different drivers don't
+ * FIXME claim the same screen > 0 instance.
+ */
+ if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci))
+ continue;
+
+ DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ drvp->driverName, pPci->bus, pPci->dev, pPci->func);
+
+ /* Allocate an entry in the lists to be returned */
+ entry = xf86ClaimPciSlot(pPci, drvp, device_id,
+ devList[i], devList[i]->active);
+
+ if ((entry == -1) && (devList[i]->screen > 0)) {
+ unsigned k;
+
+ for (k = 0; k < xf86NumEntities; k++ ) {
+ EntityPtr pEnt = xf86Entities[k];
+ if (pEnt->bus.type != BUS_PCI)
+ continue;
+ if (pEnt->bus.id.pci == pPci) {
+ entry = k;
+ xf86AddDevToEntity(k, devList[i]);
+ break;
+ }
+ }
+ }
+
+ if (entry != -1) {
+ if ((*drvp->PciProbe)(drvp, entry, pPci,
+ devices[j].match_data)) {
+ foundScreen = TRUE;
+ } else
+ xf86UnclaimPciSlot(pPci);
+ }
+
+ break;
+ }
+ }
+ }
+ free(devList);
+
+ return foundScreen;
+}
+
+void
+xf86PciIsolateDevice(char *argument)
+{
+ int bus, device, func;
+
+ if (sscanf(argument, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+ xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus);
+ xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
+ xf86IsolateDevice.dev = device;
+ xf86IsolateDevice.func = func;
+ } else
+ FatalError("Invalid isolated device specification\n");
+}
+
+static Bool
+pciDeviceHasBars(struct pci_device *pci)
+{
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (pci->regions[i].size)
+ return TRUE;
+
+ if (pci->rom_size)
+ return TRUE;
+
+ return FALSE;
+}
+
+struct Inst {
+ struct pci_device * pci;
+ GDevPtr dev;
+ Bool foundHW; /* PCIid in list of supported chipsets */
+ Bool claimed; /* BusID matches with a device section */
+ int chip;
+ int screen;
+};
+
+
+/**
+ * Find set of unclaimed devices matching a given vendor ID.
+ *
+ * Used by drivers to find as yet unclaimed devices matching the specified
+ * vendor ID.
+ *
+ * \param driverName Name of the driver. This is used to find Device
+ * sections in the config file.
+ * \param vendorID PCI vendor ID of associated devices. If zero, then
+ * the true vendor ID must be encoded in the \c PCIid
+ * fields of the \c PCIchipsets entries.
+ * \param chipsets Symbol table used to associate chipset names with
+ * PCI IDs.
+ * \param devList List of Device sections parsed from the config file.
+ * \param numDevs Number of entries in \c devList.
+ * \param drvp Pointer the driver's control structure.
+ * \param foundEntities Returned list of entity indicies associated with the
+ * driver.
+ *
+ * \returns
+ * The number of elements in returned in \c foundEntities on success or zero
+ * on failure.
+ *
+ * \todo
+ * This function does a bit more than short description says. Fill in some
+ * more of the details of its operation.
+ *
+ * \todo
+ * The \c driverName parameter is redundant. It is the same as
+ * \c DriverRec::driverName. In a future version of this function, remove
+ * that parameter.
+ */
+int
+xf86MatchPciInstances(const char *driverName, int vendorID,
+ SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
+{
+ int i,j;
+ struct pci_device * pPci;
+ struct pci_device_iterator *iter;
+ struct Inst *instances = NULL;
+ int numClaimedInstances = 0;
+ int allocatedInstances = 0;
+ int numFound = 0;
+ SymTabRec *c;
+ PciChipsets *id;
+ int *retEntities = NULL;
+
+ *foundEntities = NULL;
+
+
+ /* Each PCI device will contribute at least one entry. Each device
+ * section can contribute at most one entry. The sum of the two is
+ * guaranteed to be larger than the maximum possible number of entries.
+ * Do this calculation and memory allocation once now to eliminate the
+ * need for realloc calls inside the loop.
+ */
+ if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
+ unsigned max_entries = numDevs;
+
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ max_entries++;
+ }
+
+ pci_iterator_destroy(iter);
+ instances = xnfalloc(max_entries * sizeof(struct Inst));
+ }
+
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ unsigned device_class = pPci->device_class;
+ Bool foundVendor = FALSE;
+
+
+ /* Convert the pre-PCI 2.0 device class for a VGA adapter to the
+ * 2.0 version of the same class.
+ */
+ if ( device_class == 0x00000101 ) {
+ device_class = 0x00030000;
+ }
+
+
+ /* Find PCI devices that match the given vendor ID. The vendor ID is
+ * either specified explicitly as a parameter to the function or
+ * implicitly encoded in the high bits of id->PCIid.
+ *
+ * The first device with a matching vendor is recorded, even if the
+ * device ID doesn't match. This is done because the Device section
+ * in the xorg.conf file can over-ride the device ID. A matching PCI
+ * ID might not be found now, but after the device ID over-ride is
+ * applied there /might/ be a match.
+ */
+ for (id = PCIchipsets; id->PCIid != -1; id++) {
+ const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
+ | vendorID;
+ const unsigned device_id = (id->PCIid & 0x0000FFFF);
+ const unsigned match_class = 0x00030000 | id->PCIid;
+
+ if ((vendor_id == pPci->vendor_id)
+ || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
+ if (!foundVendor && (instances != NULL)) {
+ ++allocatedInstances;
+ instances[allocatedInstances - 1].pci = pPci;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ instances[allocatedInstances - 1].foundHW = FALSE;
+ instances[allocatedInstances - 1].screen = 0;
+ }
+
+ foundVendor = TRUE;
+
+ if ( (device_id == pPci->device_id)
+ || ((vendorID == PCI_VENDOR_GENERIC)
+ && (match_class == device_class)) ) {
+ if ( instances != NULL ) {
+ instances[allocatedInstances - 1].foundHW = TRUE;
+ instances[allocatedInstances - 1].chip = id->numChipset;
+ }
+
+
+ if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
+ if (xf86CheckPciSlot(pPci)) {
+ GDevPtr pGDev =
+ xf86AddBusDeviceToConfigure(drvp->driverName,
+ BUS_PCI, pPci, -1);
+ if (pGDev) {
+ /* After configure pass 1, chipID and chipRev
+ * are treated as over-rides, so clobber them
+ * here.
+ */
+ pGDev->chipID = -1;
+ pGDev->chipRev = -1;
+ }
+
+ numFound++;
+ }
+ }
+ else {
+ numFound++;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+
+ /* In "probe only" or "configure" mode (signaled by instances being NULL),
+ * our work is done. Return the number of detected devices.
+ */
+ if ( instances == NULL ) {
+ return numFound;
+ }
+
+
+ /*
+ * This may be debatable, but if no PCI devices with a matching vendor
+ * type is found, return zero now. It is probably not desirable to
+ * allow the config file to override this.
+ */
+ if (allocatedInstances <= 0) {
+ free(instances);
+ return 0;
+ }
+
+
+ DebugF("%s instances found: %d\n", driverName, allocatedInstances);
+
+ /*
+ * Check for devices that need duplicated instances. This is required
+ * when there is more than one screen per entity.
+ *
+ * XXX This currently doesn't work for cases where the BusID isn't
+ * specified explicitly in the config file.
+ */
+
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->screen > 0 && devList[j]->busID
+ && *devList[j]->busID) {
+ for (i = 0; i < allocatedInstances; i++) {
+ pPci = instances[i].pci;
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+ pPci->dev,
+ pPci->func)) {
+ allocatedInstances++;
+ instances[allocatedInstances - 1] = instances[i];
+ instances[allocatedInstances - 1].screen = devList[j]->screen;
+ numFound++;
+ break;
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < allocatedInstances; i++) {
+ GDevPtr dev = NULL;
+ GDevPtr devBus = NULL;
+
+ pPci = instances[i].pci;
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->busID && *devList[j]->busID) {
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+ pPci->dev,
+ pPci->func) &&
+ devList[j]->screen == instances[i].screen) {
+
+ if (devBus)
+ xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching Device section for "
+ "instances\n\t(BusID: %s) found: %s\n",
+ driverName, devList[j]->busID,
+ devList[j]->identifier);
+ else
+ devBus = devList[j];
+ }
+ } else {
+ /*
+ * if device section without BusID is found
+ * only assign to it to the primary device.
+ */
+ if (xf86IsPrimaryPci(pPci)) {
+ xf86Msg(X_PROBED, "Assigning device section with no busID"
+ " to primary device\n");
+ if (dev || devBus)
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section "
+ "found: %s\n", driverName, devList[j]->identifier);
+ else
+ dev = devList[j];
+ }
+ }
+ }
+ if (devBus) dev = devBus; /* busID preferred */
+ if (!dev) {
+ if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID PCI:%u@%u:%u:%u) found\n",
+ driverName, pPci->domain, pPci->bus, pPci->dev,
+ pPci->func);
+ }
+ } else {
+ numClaimedInstances++;
+ instances[i].claimed = TRUE;
+ instances[i].dev = dev;
+ }
+ }
+ DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
+ /*
+ * Now check that a chipset or chipID override in the device section
+ * is valid. Chipset has precedence over chipID.
+ * If chipset is not valid ignore BusSlot completely.
+ */
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+ MessageType from = X_PROBED;
+
+ if (!instances[i].claimed) {
+ continue;
+ }
+ if (instances[i].dev->chipset) {
+ for (c = chipsets; c->token >= 0; c++) {
+ if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
+ break;
+ }
+ if (c->token == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ } else {
+ instances[i].chip = c->token;
+
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->numChipset == instances[i].chip)
+ break;
+ }
+ if(id->numChipset >=0){
+ xf86Msg(X_CONFIG,"Chipset override: %s\n",
+ instances[i].dev->chipset);
+ from = X_CONFIG;
+ } else {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't a valid PCI chipset\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ }
+ }
+ } else if (instances[i].dev->chipID > 0) {
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->PCIid == instances[i].dev->chipID)
+ break;
+ }
+ if (id->numChipset == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipID,
+ instances[i].dev->identifier);
+ } else {
+ instances[i].chip = id->numChipset;
+
+ xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
+ instances[i].dev->chipID);
+ from = X_CONFIG;
+ }
+ } else if (!instances[i].foundHW) {
+ /*
+ * This means that there was no override and the PCI chipType
+ * doesn't match one that is supported
+ */
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ }
+ if (instances[i].claimed == TRUE){
+ for (c = chipsets; c->token >= 0; c++) {
+ if (c->token == instances[i].chip)
+ break;
+ }
+ xf86Msg(from,"Chipset %s found\n",
+ c->name);
+ }
+ }
+
+ /*
+ * Of the claimed instances, check that another driver hasn't already
+ * claimed its slot.
+ */
+ numFound = 0;
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+ if (!instances[i].claimed)
+ continue;
+ pPci = instances[i].pci;
+
+
+ /*
+ * Allow the same entity to be used more than once for devices with
+ * multiple screens per entity. This assumes implicitly that there
+ * will be a screen == 0 instance.
+ *
+ * XXX Need to make sure that two different drivers don't claim
+ * the same screen > 0 instance.
+ */
+ if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
+ continue;
+
+ DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ driverName, pPci->bus, pPci->dev, pPci->func);
+
+ /* Allocate an entry in the lists to be returned */
+ numFound++;
+ retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
+ instances[i].chip,
+ instances[i].dev,
+ instances[i].dev->active);
+ if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
+ for (j = 0; j < xf86NumEntities; j++) {
+ EntityPtr pEnt = xf86Entities[j];
+ if (pEnt->bus.type != BUS_PCI)
+ continue;
+ if (pEnt->bus.id.pci == pPci) {
+ retEntities[numFound - 1] = j;
+ xf86AddDevToEntity(j, instances[i].dev);
+ break;
+ }
+ }
+ }
+ }
+ free(instances);
+ if (numFound > 0) {
+ *foundEntities = retEntities;
+ }
+
+ return numFound;
+}
+
+/*
+ * xf86ConfigPciEntityInactive() -- This function can be used
+ * to configure an inactive entity as well as to reconfigure an
+ * previously active entity inactive. If the entity has been
+ * assigned to a screen before it will be removed. If p_chip is
+ * non-NULL all static resources listed there will be registered.
+ */
+static void
+xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+ EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ ScrnInfoPtr pScrn;
+
+ if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+ xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+
+ /* shared resources are only needed when entity is active: remove */
+ xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+ScrnInfoPtr
+xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+ PciChipsets *p_chip, void *dummy, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return pScrn;
+
+ if (!(pEnt->location.type == BUS_PCI)
+ || !xf86GetPciInfoForEntity(entityIndex)) {
+ free(pEnt);
+ return pScrn;
+ }
+ if (!pEnt->active) {
+ xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter,
+ leave, private);
+ free(pEnt);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ if (xf86IsEntitySharable(entityIndex)) {
+ xf86SetEntityShared(entityIndex);
+ }
+ xf86AddEntityToScreen(pScrn,entityIndex);
+ if (xf86IsEntityShared(entityIndex)) {
+ return pScrn;
+ }
+ free(pEnt);
+
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+ return pScrn;
+}
+
+/*
+ * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
+ * It is likely to be removed. Don't use!
+ */
+Bool
+xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
+ PciChipsets *p_chip, void *dummy, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return FALSE;
+
+ if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
+ free(pEnt);
+ return FALSE;
+ }
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ free(pEnt);
+ if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
+ return FALSE;
+
+ return TRUE;
+}
+
+static int
+videoPtrToDriverList(struct pci_device *dev,
+ char *returnList[], int returnListMax)
+{
+ int i;
+ /* Add more entries here if we ever return more than 4 drivers for
+ any device */
+ char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
+
+ switch (dev->vendor_id)
+ {
+ /* AMD Geode LX */
+ case 0x1022:
+ if (dev->device_id == 0x2081)
+ driverList[0] = "geode";
+ break;
+ /* older Geode products acquired by AMD still carry an NSC vendor_id */
+ case 0x100b:
+ if (dev->device_id == 0x0030) {
+ /* NSC Geode GX2 specifically */
+ driverList[0] = "geode";
+ /* GX2 support started its life in the NSC tree and was later
+ forked by AMD for GEODE so we keep it as a backup */
+ driverList[1] = "nsc";
+ } else
+ /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
+ driverList[0] = "nsc";
+ break;
+ /* Cyrix Geode GX1 */
+ case 0x1078:
+ if (dev->device_id == 0x0104)
+ driverList[0] = "cyrix";
+ break;
+ case 0x1142: driverList[0] = "apm"; break;
+ case 0xedd8: driverList[0] = "ark"; break;
+ case 0x1a03: driverList[0] = "ast"; break;
+ case 0x1002: driverList[0] = "ati"; break;
+ case 0x102c: driverList[0] = "chips"; break;
+ case 0x1013: driverList[0] = "cirrus"; break;
+ case 0x3d3d: driverList[0] = "glint"; break;
+ case 0x105d: driverList[0] = "i128"; break;
+ case 0x8086:
+ if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
+ driverList[0] = "i740";
+ } else if (dev->device_id == 0x8108) {
+ break; /* "hooray" for poulsbo */
+ } else {
+ driverList[0] = "intel";
+ }
+ break;
+ case 0x102b: driverList[0] = "mga"; break;
+ case 0x10c8: driverList[0] = "neomagic"; break;
+ case 0x10de: case 0x12d2: driverList[0] = "nv"; break;
+ case 0x1106: driverList[0] = "openchrome"; break;
+ case 0x1b36: driverList[0] = "qxl"; break;
+ case 0x1163: driverList[0] = "rendition"; break;
+ case 0x5333:
+ switch (dev->device_id)
+ {
+ case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
+ case 0x8812: case 0x8814: case 0x8901:
+ driverList[0] = "s3"; break;
+ case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
+ case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
+ driverList[0] = "s3virge"; break;
+ default:
+ driverList[0] = "savage"; break;
+ }
+ break;
+ case 0x1039: driverList[0] = "sis"; break;
+ case 0x126f: driverList[0] = "siliconmotion"; break;
+ case 0x121a:
+ if (dev->device_id < 0x0003)
+ driverList[0] = "voodoo";
+ else
+ driverList[0] = "tdfx";
+ break;
+ case 0x1011: driverList[0] = "tga"; break;
+ case 0x1023: driverList[0] = "trident"; break;
+ case 0x100c: driverList[0] = "tseng"; break;
+ case 0x80ee: driverList[0] = "vboxvideo"; break;
+ case 0x15ad: driverList[0] = "vmware"; break;
+ case 0x18ca:
+ if (dev->device_id == 0x47)
+ driverList[0] = "xgixp";
+ else
+ driverList[0] = "xgi";
+ break;
+ default: break;
+ }
+ for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
+ returnList[i] = xnfstrdup(driverList[i]);
+ }
+ return i; /* Number of entries added */
+}
+
+#ifdef __linux__
+static int
+xchomp(char *line)
+{
+ size_t len = 0;
+
+ if (!line) {
+ return 1;
+ }
+
+ len = strlen(line);
+ if (line[len - 1] == '\n' && len > 0) {
+ line[len - 1] = '\0';
+ }
+ return 0;
+}
+
+/* This function is used to provide a workaround for binary drivers that
+ * don't export their PCI ID's properly. If distros don't end up using this
+ * feature it can and should be removed because the symbol-based resolution
+ * scheme should be the primary one */
+static void
+matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
+{
+ DIR *idsdir;
+ FILE *fp;
+ struct dirent *direntry;
+ char *line = NULL;
+ size_t len;
+ ssize_t read;
+ char path_name[256], vendor_str[5], chip_str[5];
+ uint16_t vendor, chip;
+ int i, j;
+
+ idsdir = opendir(PCI_TXT_IDS_PATH);
+ if (!idsdir)
+ return;
+
+ xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
+ direntry = readdir(idsdir);
+ /* Read the directory */
+ while (direntry) {
+ if (direntry->d_name[0] == '.') {
+ direntry = readdir(idsdir);
+ continue;
+ }
+ len = strlen(direntry->d_name);
+ /* A tiny bit of sanity checking. We should probably do better */
+ if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
+ /* We need the full path name to open the file */
+ strncpy(path_name, PCI_TXT_IDS_PATH, 256);
+ strncat(path_name, "/", 1);
+ strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
+ fp = fopen(path_name, "r");
+ if (fp == NULL) {
+ xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
+ goto end;
+ }
+ /* Read the file */
+#ifdef __GLIBC__
+ while ((read = getline(&line, &len, fp)) != -1) {
+#else
+ while ((line = fgetln(fp, &len)) != (char *)NULL) {
+#endif /* __GLIBC __ */
+ xchomp(line);
+ if (isdigit(line[0])) {
+ strncpy(vendor_str, line, 4);
+ vendor_str[4] = '\0';
+ vendor = (int)strtol(vendor_str, NULL, 16);
+ if ((strlen(&line[4])) == 0) {
+ chip_str[0] = '\0';
+ chip = -1;
+ } else {
+ /* Handle trailing whitespace */
+ if (isspace(line[4])) {
+ chip_str[0] = '\0';
+ chip = -1;
+ } else {
+ /* Ok, it's a real ID */
+ strncpy(chip_str, &line[4], 4);
+ chip_str[4] = '\0';
+ chip = (int)strtol(chip_str, NULL, 16);
+ }
+ }
+ if (vendor == match_vendor && chip == match_chip ) {
+ i = 0;
+ while (matches[i]) {
+ i++;
+ }
+ matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3);
+ if (!matches[i]) {
+ xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
+ goto end;
+ }
+ /* hack off the .ids suffix. This should guard
+ * against other problems, but it will end up
+ * taking off anything after the first '.' */
+ for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
+ if (direntry->d_name[j] == '.') {
+ matches[i][j] = '\0';
+ break;
+ } else {
+ matches[i][j] = direntry->d_name[j];
+ }
+ }
+ xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
+ }
+ } else {
+ /* TODO Handle driver overrides here */
+ }
+ }
+ fclose(fp);
+ }
+ direntry = readdir(idsdir);
+ }
+ end:
+ free(line);
+ closedir(idsdir);
+}
+#endif /* __linux__ */
+
+/**
+ * @return The numbers of found devices that match with the current system
+ * drivers.
+ */
+int
+xf86PciMatchDriver(char* matches[], int nmatches) {
+ int i;
+ struct pci_device * info = NULL;
+ struct pci_device_iterator *iter;
+
+ /* Find the primary device, and get some information about it. */
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((info = pci_device_next(iter)) != NULL) {
+ if (xf86IsPrimaryPci(info)) {
+ break;
+ }
+ }
+
+ pci_iterator_destroy(iter);
+#ifdef __linux__
+ if (info)
+ matchDriverFromFiles(matches, info->vendor_id, info->device_id);
+#endif
+
+ for (i = 0; (i < nmatches) && (matches[i]); i++) {
+ /* find end of matches list */
+ }
+
+ if ((info != NULL) && (i < nmatches)) {
+ i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
+ }
+
+ return i;
+}
+
+Bool
+xf86PciConfigure(void *busData, struct pci_device *pDev)
+{
+ struct pci_device * pVideo = NULL;
+
+ pVideo = (struct pci_device *) busData;
+ if (pDev &&
+ (pDev->domain == pVideo->domain) &&
+ (pDev->bus == pVideo->bus) &&
+ (pDev->dev == pVideo->dev) &&
+ (pDev->func == pVideo->func))
+ return 0;
+
+ return 1;
+}
+
+void
+xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
+ GDevRec *GDev, int *chipset)
+{
+ char busnum[8];
+
+ pVideo = (struct pci_device *) busData;
+
+ xf86FormatPciBusNumber(pVideo->bus, busnum);
+ XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
+ busnum, pVideo->dev, pVideo->func);
+
+ GDev->chipID = pVideo->device_id;
+ GDev->chipRev = pVideo->revision;
+
+ if (*chipset < 0)
+ *chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
+}
+
+struct pci_io_handle *
+xf86MapLegacyIO(struct pci_device *dev)
+{
+ return pci_legacy_open_io(dev, 0, 64 * 1024);
+}
+
+void
+xf86UnmapLegacyIO(struct pci_device *dev, struct pci_io_handle *handle)
+{
+ pci_device_close_io(dev, handle);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index 0493dc53c..e2ca55875 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -41,9 +41,6 @@
#include "colormapst.h"
#include "xf86Module.h"
#include "xf86Opt.h"
-#include "xf86Pci.h"
-
-#include <pciaccess.h>
/**
* Integer type that is of the size of the addressable memory (machine size).
@@ -309,6 +306,8 @@ typedef struct {
struct _SymTabRec;
struct _PciChipsets;
+struct pci_device;
+
typedef struct _DriverRec {
int driverVersion;
char * driverName;
@@ -350,8 +349,6 @@ typedef enum {
BUS_last /* Keep last */
} BusType;
-struct pci_device;
-
typedef struct {
int fbNum;
} SbusBusId;
@@ -742,7 +739,6 @@ typedef struct _ScrnInfoRec {
unsigned long biosBase; /* Base address of video BIOS */
unsigned long memPhysBase; /* Physical address of FB */
unsigned long fbOffset; /* Offset of FB in the above */
- IOADDRESS domainIOBase; /* Domain I/O base address */
int memClk; /* memory clock */
int textClockFreq; /* clock of text mode */
Bool flipPixels; /* swap default black/white */
diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.am b/xorg-server/hw/xfree86/dixmods/Makefile.am
index 68111631c..b6eb54f16 100644
--- a/xorg-server/hw/xfree86/dixmods/Makefile.am
+++ b/xorg-server/hw/xfree86/dixmods/Makefile.am
@@ -1,68 +1,68 @@
-noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la
-
-SUBDIRS = extmod
-
-if GLX
-GLXMODS = libglx.la
-endif
-
-if DBE
-DBEMOD = libdbe.la
-endif
-
-if RECORD
-RECORDMOD = librecord.la
-endif
-
-module_LTLIBRARIES = libfb.la \
- libwfb.la \
- libshadow.la
-
-extsmoduledir = $(moduledir)/extensions
-extsmodule_LTLIBRARIES = $(RECORDMOD) \
- $(DBEMOD) \
- $(GLXMODS)
-
-AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
-INCLUDES = @XORG_INCS@ \
- -I$(top_srcdir)/dbe \
- -I$(top_srcdir)/hw/xfree86/loader \
- -I$(top_srcdir)/miext/shadow \
- -I$(top_srcdir)/glx
-
-libdbe_la_LDFLAGS = -avoid-version
-libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
-libdbe_la_SOURCES = dbemodule.c
-
-libfb_la_LDFLAGS = -avoid-version
-libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
-libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
-libfb_la_CFLAGS = $(AM_CFLAGS)
-
-libwfb_la_LDFLAGS = -avoid-version
-libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
-libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
-libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
-
-libglx_la_LDFLAGS = -avoid-version
-if AIGLX_DRI_LOADER
-GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
-endif
-libglx_la_LIBADD = \
- $(top_builddir)/glx/libglx.la \
- $(GLXDRI_LIBRARY)
-libglx_la_SOURCES = glxmodule.c
-
-librecord_la_LDFLAGS = -avoid-version
-librecord_la_LIBADD = $(top_builddir)/record/librecord.la
-librecord_la_SOURCES = recordmod.c
-
-libshadow_la_LDFLAGS = -avoid-version
-libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
-libshadow_la_SOURCES = shmodule.c
-
-libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c
-libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS)
-
-libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c
-libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la
+noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la
+
+SUBDIRS = extmod
+
+if GLX
+GLXMODS = libglx.la
+endif
+
+if DBE
+DBEMOD = libdbe.la
+endif
+
+if RECORD
+RECORDMOD = librecord.la
+endif
+
+module_LTLIBRARIES = libfb.la \
+ libwfb.la \
+ libshadow.la
+
+extsmoduledir = $(moduledir)/extensions
+extsmodule_LTLIBRARIES = $(RECORDMOD) \
+ $(DBEMOD) \
+ $(GLXMODS)
+
+AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
+INCLUDES = @XORG_INCS@ \
+ -I$(top_srcdir)/dbe \
+ -I$(top_srcdir)/hw/xfree86/loader \
+ -I$(top_srcdir)/miext/shadow \
+ -I$(top_srcdir)/glx
+
+libdbe_la_LDFLAGS = -module -avoid-version
+libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
+libdbe_la_SOURCES = dbemodule.c
+
+libfb_la_LDFLAGS = -module -avoid-version
+libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
+libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libfb_la_CFLAGS = $(AM_CFLAGS)
+
+libwfb_la_LDFLAGS = -module -avoid-version
+libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
+libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
+
+libglx_la_LDFLAGS = -module -avoid-version
+if AIGLX_DRI_LOADER
+GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
+endif
+libglx_la_LIBADD = \
+ $(top_builddir)/glx/libglx.la \
+ $(GLXDRI_LIBRARY)
+libglx_la_SOURCES = glxmodule.c
+
+librecord_la_LDFLAGS = -module -avoid-version
+librecord_la_LIBADD = $(top_builddir)/record/librecord.la
+librecord_la_SOURCES = recordmod.c
+
+libshadow_la_LDFLAGS = -module -avoid-version
+libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
+libshadow_la_SOURCES = shmodule.c
+
+libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c
+libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS)
+
+libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c
+libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am
index c0b7ddc02..87c28a421 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am
+++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am
@@ -1,30 +1,30 @@
-sdk_HEADERS = dgaproc.h
-
-extsmoduledir = $(moduledir)/extensions
-extsmodule_LTLIBRARIES = libextmod.la
-
-if DGA
-DGA_SRCS = xf86dga2.c dgaproc.h
-endif
-
-if XV
-XV_SRCS = xvmod.c xvmodproc.h
-endif
-
-if XF86VIDMODE
-XF86VMODE_SRCS = xf86vmode.c
-endif
-
-AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@ \
- -I$(top_srcdir)/dbe \
- -I$(top_srcdir)/hw/xfree86/loader \
- -I$(top_srcdir)/miext/shadow
-
-libextmod_la_LDFLAGS = -avoid-version
-libextmod_la_SOURCES = modinit.c \
- modinit.h \
- $(DGA_SRCS) \
- $(XF86VMODE_SRCS) \
- $(XV_SRCS)
-libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la
+sdk_HEADERS = dgaproc.h
+
+extsmoduledir = $(moduledir)/extensions
+extsmodule_LTLIBRARIES = libextmod.la
+
+if DGA
+DGA_SRCS = xf86dga2.c dgaproc.h
+endif
+
+if XV
+XV_SRCS = xvmod.c xvmodproc.h
+endif
+
+if XF86VIDMODE
+XF86VMODE_SRCS = xf86vmode.c
+endif
+
+AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@
+INCLUDES = @XORG_INCS@ \
+ -I$(top_srcdir)/dbe \
+ -I$(top_srcdir)/hw/xfree86/loader \
+ -I$(top_srcdir)/miext/shadow
+
+libextmod_la_LDFLAGS = -module -avoid-version
+libextmod_la_SOURCES = modinit.c \
+ modinit.h \
+ $(DGA_SRCS) \
+ $(XF86VMODE_SRCS) \
+ $(XV_SRCS)
+libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la
diff --git a/xorg-server/hw/xfree86/exa/Makefile.am b/xorg-server/hw/xfree86/exa/Makefile.am
index 39f7a9057..3ced531fa 100644
--- a/xorg-server/hw/xfree86/exa/Makefile.am
+++ b/xorg-server/hw/xfree86/exa/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
module_LTLIBRARIES = libexa.la
-libexa_la_LDFLAGS = -avoid-version
+libexa_la_LDFLAGS = -module -avoid-version
INCLUDES = \
$(XORG_INCS) \
diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.am b/xorg-server/hw/xfree86/fbdevhw/Makefile.am
index 2a038905e..4472acd91 100644
--- a/xorg-server/hw/xfree86/fbdevhw/Makefile.am
+++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
module_LTLIBRARIES = libfbdevhw.la
-libfbdevhw_la_LDFLAGS = -avoid-version
+libfbdevhw_la_LDFLAGS = -module -avoid-version
if FBDEVHW
libfbdevhw_la_SOURCES = fbdevhw.c
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
index bc46b9c4f..34870c27d 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
@@ -5,8 +5,6 @@
#include "xf86str.h"
#include "colormapst.h"
-#include <pciaccess.h>
-
#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */
#define FBDEVHW_PLANES 1 /* Non interleaved planes */
#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */
diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c
index 994085493..fbc9b8507 100644
--- a/xorg-server/hw/xfree86/int10/generic.c
+++ b/xorg-server/hw/xfree86/int10/generic.c
@@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
static void *sysMem = NULL;
-/**
- * Read legacy VGA video BIOS associated with specified domain.
- *
- * Attempts to read up to 128KiB of legacy VGA video BIOS.
- *
- * \return
- * The number of bytes read on success or -1 on failure.
- *
- * \bug
- * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA,
- * etc.). How do we know that \c pci_device_read_rom will return the
- * legacy VGA BIOS image?
- */
-#ifndef _PC
-static int
-read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf)
-{
- const ADDRESS Base = 0xC0000;
- const int Len = 0x10000 * 2;
- const int pagemask = getpagesize() - 1;
- const ADDRESS offset = Base & ~pagemask;
- const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset;
- unsigned char *ptr, *src;
- int len;
-
-
- /* Try to use the civilized PCI interface first.
- */
- if (pci_device_read_rom(dev, Buf) == 0) {
- return dev->rom_size;
- }
-
- ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size);
-
- if (!ptr)
- return -1;
-
- /* Using memcpy() here can hang the system */
- src = ptr + (Base - offset);
- for (len = 0; len < (Len / 2); len++) {
- Buf[len] = src[len];
- }
-
- if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) {
- for ( /* empty */ ; len < Len; len++) {
- Buf[len] = src[len];
- }
- }
-
- xf86UnMapVidMem(-1, ptr, size);
-
- return Len;
-}
-#endif /* _PC */
-
-
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
{
@@ -159,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
MapVRam(pInt);
#ifdef _PC
if (!sysMem)
- sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS,
- BIOS_SIZE + SYS_BIOS - V_BIOS);
+ pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
+ PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
INTPriv(pInt)->sysMem = sysMem;
if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
@@ -232,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
*/
vbiosMem = (char *)base + V_BIOS;
memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
- if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
+ if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0C0000.\n");
}
@@ -294,10 +238,8 @@ MapVRam(xf86Int10InfoPtr pInt)
int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
- INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
- pInt->dev, V_RAM, size);
-
- pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase;
+ pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam));
+ pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
}
static void
@@ -307,7 +249,9 @@ UnmapVRam(xf86Int10InfoPtr pInt)
int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
- xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size);
+ pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size);
+ pci_device_close_io(pInt->dev, pInt->io);
+ pInt->io = NULL;
}
Bool
diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c
index 44d8a7fcd..638f5668b 100644
--- a/xorg-server/hw/xfree86/int10/helper_exec.c
+++ b/xorg-server/hw/xfree86/int10/helper_exec.c
@@ -331,7 +331,7 @@ x_inb(CARD16 port)
}
#endif /* __NOT_YET__ */
} else if (!pciCfg1inb(port, &val)) {
- val = inb(Int10Current->ioBase + port);
+ val = pci_io_read8(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inb(%#x) = %2.2x\n", port, val);
}
@@ -353,7 +353,7 @@ x_inw(CARD16 port)
X_GETTIMEOFDAY(&tv);
val = (CARD16)(tv.tv_usec / 3);
} else if (!pciCfg1inw(port, &val)) {
- val = inw(Int10Current->ioBase + port);
+ val = pci_io_read16(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inw(%#x) = %4.4x\n", port, val);
}
@@ -387,7 +387,7 @@ x_outb(CARD16 port, CARD8 val)
} else if (!pciCfg1outb(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outb(%#x, %2.2x)\n", port, val);
- outb(Int10Current->ioBase + port, val);
+ pci_io_write8(Int10Current->io, port, val);
}
}
@@ -398,7 +398,7 @@ x_outw(CARD16 port, CARD16 val)
if (!pciCfg1outw(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outw(%#x, %4.4x)\n", port, val);
- outw(Int10Current->ioBase + port, val);
+ pci_io_write16(Int10Current->io, port, val);
}
}
@@ -408,7 +408,7 @@ x_inl(CARD16 port)
CARD32 val;
if (!pciCfg1in(port, &val)) {
- val = inl(Int10Current->ioBase + port);
+ val = pci_io_read32(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val);
}
@@ -421,7 +421,7 @@ x_outl(CARD16 port, CARD32 val)
if (!pciCfg1out(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val);
- outl(Int10Current->ioBase + port, val);
+ pci_io_write32(Int10Current->io, port, val);
}
}
@@ -475,7 +475,7 @@ static struct pci_device*
pci_device_for_cfg_address (CARD32 addr)
{
struct pci_device *dev = NULL;
- PCITAG tag = PCI_TAG(addr);
+ CARD32 tag = PCI_TAG(addr);
struct pci_slot_match slot_match = {
.domain = PCI_DOM_FROM_TAG(tag),
.bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
@@ -650,29 +650,29 @@ bios_checksum(const CARD8 *start, int size)
void
LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
{
- vga->save_msr = inb(pInt->ioBase + 0x03CC);
- vga->save_vse = inb(pInt->ioBase + 0x03C3);
+ vga->save_msr = pci_io_read8(pInt->io, 0x03CC);
+ vga->save_vse = pci_io_read8(pInt->io, 0x03C3);
#ifndef __ia64__
- vga->save_46e8 = inb(pInt->ioBase + 0x46E8);
+ vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8);
#endif
- vga->save_pos102 = inb(pInt->ioBase + 0x0102);
- outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
- outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
+ vga->save_pos102 = pci_io_read8(pInt->io, 0x0102);
+ pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr);
+ pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse);
#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+ pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
#endif
- outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+ pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102);
}
void
UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
{
- outb(pInt->ioBase + 0x0102, vga->save_pos102);
+ pci_io_write8(pInt->io, 0x0102, vga->save_pos102);
#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, vga->save_46e8);
+ pci_io_write8(pInt->io, 0x46E8, vga->save_46e8);
#endif
- outb(pInt->ioBase + 0x03C3, vga->save_vse);
- outb(pInt->ioBase + 0x03C2, vga->save_msr);
+ pci_io_write8(pInt->io, 0x03C3, vga->save_vse);
+ pci_io_write8(pInt->io, 0x03C2, vga->save_msr);
}
#if defined (_PC)
@@ -680,10 +680,12 @@ static void
SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
{
int pagesize = getpagesize();
- unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
- VIDMEM_MMIO, 0, pagesize);
+ unsigned char* base;
int i;
+ if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+ return; /* eek */
+
if (set) {
for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
MEM_WW(pInt, i, *(base + i));
@@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
*(base + i) = MEM_RW(pInt, i);
}
- xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
+ pci_device_unmap_legacy(pInt->dev, base, pagesize);
}
void
@@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
|| (!save && !pInt->BIOSScratch))
return;
- base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
+ if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+ return; /* eek */
+
base += BIOS_SCRATCH_OFF;
if (save) {
if ((pInt->BIOSScratch
@@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
}
}
- xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
+ pci_device_unmap_legacy(pInt->dev, base, pagesize);
}
#endif
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.c b/xorg-server/hw/xfree86/int10/xf86int10.c
index 51eb91fbb..dd00e5465 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.c
+++ b/xorg-server/hw/xfree86/int10/xf86int10.c
@@ -84,7 +84,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented (except for clearing the screen) */
{ /* Localise */
- IOADDRESS ioport;
+ unsigned int ioport;
int i;
CARD16 int1d, regvals, tmp;
CARD8 mode, cgamode, cgacolour;
@@ -172,18 +172,15 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Rows */
MEM_WB(pInt, 0x0484, (25 - 1));
- /* Remap I/O port number into its domain */
- ioport += pInt->ioBase;
-
- /* Programme the mode */
- outb(ioport + 4, cgamode & 0x37); /* Turn off screen */
+ /* Program the mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */
for (i = 0; i < 0x10; i++) {
tmp = MEM_RB(pInt, regvals + i);
- outb(ioport, i);
- outb(ioport + 1, tmp);
+ pci_io_write8(pInt->io, ioport, i);
+ pci_io_write8(pInt->io, ioport + 1, tmp);
}
- outb(ioport + 5, cgacolour); /* Select colour mode */
- outb(ioport + 4, cgamode); /* Turn on screen */
+ pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */
}
break;
@@ -194,15 +191,15 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
MEM_WB(pInt, 0x0460, X86_CL);
MEM_WB(pInt, 0x0461, X86_CH);
- outb(ioport, 0x0A);
- outb(ioport + 1, X86_CH);
- outb(ioport, 0x0B);
- outb(ioport + 1, X86_CL);
+ pci_io_write8(pInt->io, ioport, 0x0A);
+ pci_io_write8(pInt->io, ioport + 1, X86_CH);
+ pci_io_write8(pInt->io, ioport, 0x0B);
+ pci_io_write8(pInt->io, ioport + 1, X86_CL);
}
break;
@@ -214,7 +211,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport;
+ unsigned int ioport;
CARD16 offset;
MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL);
@@ -226,11 +223,11 @@ int42_handler(xf86Int10InfoPtr pInt)
offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL;
offset += MEM_RW(pInt, 0x044E) << 1;
- ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
- outb(ioport, 0x0E);
- outb(ioport + 1, offset >> 8);
- outb(ioport, 0x0F);
- outb(ioport + 1, offset & 0xFF);
+ ioport = MEM_RW(pInt, 0x0463);
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, offset >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, offset & 0xFF);
}
break;
@@ -276,7 +273,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
CARD16 start;
CARD8 x, y;
@@ -287,10 +284,10 @@ int42_handler(xf86Int10InfoPtr pInt)
start <<= 1;
/* Update start address */
- outb(ioport, 0x0C);
- outb(ioport + 1, start >> 8);
- outb(ioport, 0x0D);
- outb(ioport + 1, start & 0xFF);
+ pci_io_write8(pInt->io, ioport, 0x0C);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0D);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
/* Switch cursor position */
y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
@@ -298,10 +295,10 @@ int42_handler(xf86Int10InfoPtr pInt)
start += (y * MEM_RW(pInt, 0x044A)) + x;
/* Update cursor position */
- outb(ioport, 0x0E);
- outb(ioport + 1, start >> 8);
- outb(ioport, 0x0F);
- outb(ioport + 1, start & 0xFF);
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
}
break;
@@ -426,7 +423,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463) + 5;
CARD8 cgacolour = MEM_RB(pInt, 0x0466);
if (X86_BH) {
@@ -438,7 +435,7 @@ int42_handler(xf86Int10InfoPtr pInt)
}
MEM_WB(pInt, 0x0466, cgacolour);
- outb(ioport, cgacolour);
+ pci_io_write8(pInt->io, ioport, cgacolour);
}
break;
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.h b/xorg-server/hw/xfree86/int10/xf86int10.h
index ba9ee5276..5bf326e78 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.h
+++ b/xorg-server/hw/xfree86/int10/xf86int10.h
@@ -41,7 +41,7 @@ typedef struct {
int flags;
int stackseg;
struct pci_device *dev;
- IOADDRESS ioBase;
+ struct pci_io_handle *io;
} xf86Int10InfoRec, *xf86Int10InfoPtr;
typedef struct _int10Mem {
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index 3fae039ed..cbe0b5cf6 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -3090,6 +3090,7 @@ xf86_crtc_box_area(BoxPtr box)
return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1);
}
+#ifdef XV
/*
* Return the crtc covering 'box'. If two crtcs cover a portion of
* 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
@@ -3178,6 +3179,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
return ret;
}
+#endif
xf86_crtc_notify_proc_ptr
xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index ffb2efff4..716499f8d 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -956,6 +956,7 @@ xf86_cursors_fini (ScreenPtr screen);
extern _X_EXPORT void
xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y);
+#ifdef XV
/*
* For overlay video, compute the relevant CRTC and
* clip video to that.
@@ -974,6 +975,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
RegionPtr reg,
INT32 width,
INT32 height);
+#endif
extern _X_EXPORT xf86_crtc_notify_proc_ptr
xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c
index 4a03428ea..669da0d5b 100644
--- a/xorg-server/hw/xfree86/modes/xf86Cursors.c
+++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <stdio.h>
+#include <X11/Xarch.h>
#include "xf86.h"
#include "xf86DDC.h"
#include "xf86Crtc.h"
diff --git a/xorg-server/hw/xfree86/os-support/Makefile.am b/xorg-server/hw/xfree86/os-support/Makefile.am
index 348b7ffec..a0140a16d 100644
--- a/xorg-server/hw/xfree86/os-support/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus misc linux solaris hurd
+DIST_SUBDIRS = bsd bus misc linux solaris stub hurd
sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
@@ -16,6 +16,3 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \
AM_CFLAGS = $(DIX_CFLAGS)
-# FIXME: These don't seem to be used anywhere
-EXTRA_DIST += \
- shared/bios_devmem.c
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
index 525bfb607..20dbde86a 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
@@ -202,10 +202,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
pVidMem->mapMem = mapVidMem;
pVidMem->unmapMem = unmapVidMem;
-#if HAVE_PCI_SYSTEM_INIT_DEV_MEM
if (useDevMem)
pci_system_init_dev_mem(devMemFd);
-#endif
#ifdef HAS_MTRR_SUPPORT
if (useDevMem) {
diff --git a/xorg-server/hw/xfree86/os-support/bus/Makefile.am b/xorg-server/hw/xfree86/os-support/bus/Makefile.am
index 41d8875fb..e09d4d21f 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/bus/Makefile.am
@@ -1,25 +1,24 @@
-noinst_LTLIBRARIES = libbus.la
-sdk_HEADERS = xf86Pci.h
-
-PCI_SOURCES = Pci.c Pci.h
-
-if XORG_BUS_LINUXPCI
-PCI_SOURCES += linuxPci.c
-endif
-
-if XORG_BUS_BSDPCI
-PCI_SOURCES += bsd_pci.c
-endif
-
-if XORG_BUS_SPARC
-PLATFORM_SOURCES = Sbus.c
-sdk_HEADERS += xf86Sbus.h
-endif
-
-libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES)
-
-INCLUDES = $(XORG_INCS)
-
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
-
-EXTRA_DIST = $(sdk_HEADERS)
+noinst_LTLIBRARIES = libbus.la
+sdk_HEADERS = xf86Pci.h
+
+PCI_SOURCES =
+if XORG_BUS_PCI
+PCI_SOURCES += Pci.c Pci.h
+endif
+
+if XORG_BUS_BSDPCI
+PCI_SOURCES += bsd_pci.c
+endif
+
+if XORG_BUS_SPARC
+PLATFORM_SOURCES = Sbus.c
+sdk_HEADERS += xf86Sbus.h
+endif
+
+libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) nobus.c
+
+INCLUDES = $(XORG_INCS)
+
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+
+EXTRA_DIST = $(sdk_HEADERS)
diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.c b/xorg-server/hw/xfree86/os-support/bus/Pci.c
index 8da149d16..0362a00e3 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Pci.c
+++ b/xorg-server/hw/xfree86/os-support/bus/Pci.c
@@ -1,146 +1,140 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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 Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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 1998 by Metro Link Incorporated
- *
- * 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 Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
- *
- * This software is derived from the original XFree86 PCI code
- * which includes the following copyright notices as well:
- *
- * Copyright 1995 by Robin Cutshaw <robin@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
- * 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 the above listed copyright holder(s)
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. The above listed
- * copyright holder(s) make(s) no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
- *
- * This code is also based heavily on the code in FreeBSD-current, which was
- * written by Wolfgang Stanglmeier, and contains the following copyright:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-/*
- * Copyright (c) 1999-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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "Pci.h"
-
-PCITAG
-pciTag(int busnum, int devnum, int funcnum)
-{
- return(PCI_MAKE_TAG(busnum,devnum,funcnum));
-}
-
-Bool
-xf86scanpci(void)
-{
- Bool success = FALSE;
-
- success = (pci_system_init() == 0);
-
- /* choose correct platform/OS specific PCI init routine */
- ARCH_PCI_INIT();
-
- return success;
-}
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * 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 Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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 1998 by Metro Link Incorporated
+ *
+ * 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 Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
+ *
+ * This software is derived from the original XFree86 PCI code
+ * which includes the following copyright notices as well:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@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
+ * 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 the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
+ *
+ * This code is also based heavily on the code in FreeBSD-current, which was
+ * written by Wolfgang Stanglmeier, and contains the following copyright:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/*
+ * Copyright (c) 1999-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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "Pci.h"
+
+Bool
+xf86scanpci(void)
+{
+ Bool success = FALSE;
+
+ success = (pci_system_init() == 0);
+
+ /* choose correct platform/OS specific PCI init routine */
+ osPciInit();
+
+ return success;
+}
diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.h b/xorg-server/hw/xfree86/os-support/bus/Pci.h
index fb0ad41f6..88560ecdc 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Pci.h
+++ b/xorg-server/hw/xfree86/os-support/bus/Pci.h
@@ -1,156 +1,150 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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 Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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 1998 by Metro Link Incorporated
- *
- * 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 Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
- *
- * This file is derived in part from the original xf86_PCI.h that included
- * following copyright message:
- *
- * Copyright 1995 by Robin Cutshaw <robin@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
- * 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 the above listed copyright holder(s)
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. The above listed
- * copyright holder(s) make(s) no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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) 1999-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).
- */
-
-
-/*
- * This file has the private Pci definitions. The public ones are imported
- * from xf86Pci.h. Drivers should not use this file.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _PCI_H
-#define _PCI_H 1
-
-#include "xf86Pci.h"
-#include "xf86PciInfo.h"
-
-/*
- * Global Definitions
- */
-#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
-#define PCI_DOM_MASK 0x01fful
-#else
-#define PCI_DOM_MASK 0x0ffu
-#endif
-
-#ifndef PCI_DOM_MASK
-# define PCI_DOM_MASK 0x0ffu
-#endif
-#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
-
-/*
- * "b" contains an optional domain number.
- */
-#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
- (((d) & 0x00001fu) << 11) | \
- (((f) & 0x000007u) << 8))
-
-#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
-
-#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
-#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
-#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
- defined(__OpenBSD__) || defined(__NetBSD__) || \
- defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
-#define ARCH_PCI_INIT bsdPciInit
-#endif
-
-#if defined(linux)
-#define ARCH_PCI_INIT linuxPciInit
-#endif /* defined(linux) */
-
-#ifndef ARCH_PCI_INIT
-#error No PCI support available for this architecture/OS combination
-#endif
-
-extern void ARCH_PCI_INIT(void);
-
-#endif /* _PCI_H */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * 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 Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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 1998 by Metro Link Incorporated
+ *
+ * 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 Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
+ *
+ * This file is derived in part from the original xf86_PCI.h that included
+ * following copyright message:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@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
+ * 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 the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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) 1999-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).
+ */
+
+
+/*
+ * This file has the private Pci definitions. The public ones are imported
+ * from xf86Pci.h. Drivers should not use this file.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _PCI_H
+#define _PCI_H 1
+
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+
+/*
+ * Global Definitions
+ */
+#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
+#define PCI_DOM_MASK 0x01fful
+#else
+#define PCI_DOM_MASK 0x0ffu
+#endif
+
+#ifndef PCI_DOM_MASK
+# define PCI_DOM_MASK 0x0ffu
+#endif
+#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
+
+/*
+ * "b" contains an optional domain number.
+ */
+#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
+ (((d) & 0x00001fu) << 11) | \
+ (((f) & 0x000007u) << 8))
+
+#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
+
+#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
+#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
+#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
+
+#if defined(linux)
+#define osPciInit(x) do {} while (0)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+ defined(__OpenBSD__) || defined(__NetBSD__) || \
+ defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
+extern void osPciInit(void);
+#else
+#error No PCI support available for this architecture/OS combination
+#endif
+
+#endif /* _PCI_H */
diff --git a/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c
index 17b52db49..7a5dbbb01 100644
--- a/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c
+++ b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c
@@ -48,22 +48,8 @@
#include "pciaccess.h"
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size)
-{
- return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-}
-
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
- (void)dev;
- return 0;
-}
-
void
-bsdPciInit(void)
+osPciInit(void)
{
xf86InitVidMem();
}
diff --git a/xorg-server/hw/xfree86/os-support/bus/linuxPci.c b/xorg-server/hw/xfree86/os-support/bus/linuxPci.c
deleted file mode 100644
index 77f724bf1..000000000
--- a/xorg-server/hw/xfree86/os-support/bus/linuxPci.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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 Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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 1998 by Metro Link Incorporated
- *
- * 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 Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "xf86_OSlib.h"
-#include "Pci.h"
-
-static const struct pci_id_match match_host_bridge = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
- (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8),
- 0x0000ffff00, 0
-};
-
-#define MAX_DOMAINS 257
-static pointer DomainMmappedIO[MAX_DOMAINS];
-
-void
-linuxPciInit(void)
-{
- memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
-}
-
-/**
- * \bug
- * The generation of the procfs file name for the domain != 0 case may not be
- * correct.
- */
-static int
-linuxPciOpenFile(struct pci_device *dev, Bool write)
-{
- static struct pci_device *last_dev = NULL;
- static int fd = -1,is_write = 0;
- char file[64];
- struct stat ignored;
- static int is26 = -1;
-
- if (dev == NULL) {
- return -1;
- }
-
- if (is26 == -1) {
- is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1;
- }
-
- if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) {
- if (fd != -1) {
- close(fd);
- fd = -1;
- }
-
- if (is26) {
- sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
- dev->domain, dev->bus, dev->dev, dev->func);
- } else {
- if (dev->domain == 0) {
- sprintf(file,"/proc/bus/pci/%02x", dev->bus);
- if (stat(file, &ignored) < 0) {
- sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x",
- dev->bus, dev->dev, dev->func);
- } else {
- sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
- dev->bus, dev->dev, dev->func);
- }
- } else {
- sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus);
- if (stat(file, &ignored) < 0) {
- sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x",
- dev->domain, dev->bus, dev->dev, dev->func);
- } else {
- sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x",
- dev->domain, dev->bus, dev->dev, dev->func);
- }
- }
- }
-
- if (write) {
- fd = open(file,O_RDWR);
- if (fd != -1) is_write = TRUE;
- } else {
- switch (is_write) {
- case TRUE:
- fd = open(file,O_RDWR);
- if (fd > -1)
- break;
- default:
- fd = open(file,O_RDONLY);
- is_write = FALSE;
- }
- }
-
- last_dev = dev;
- }
-
- return fd;
-}
-
-/*
- * Compiling the following simply requires the presence of <linux/pci.c>.
- * Actually running this is another matter altogether...
- *
- * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O
- * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is
- * determined by a prior ioctl().
- *
- * For the sparc64 port, this means 2.4.12 or later. For ppc, this
- * functionality is almost, but not quite there yet. Alpha and other kernel
- * ports to multi-domain architectures still need to implement this.
- *
- * This scheme is also predicated on the use of an IOADDRESS compatible type to
- * designate I/O addresses. Although IOADDRESS is defined as an unsigned
- * integral type, it is actually the virtual address of, i.e. a pointer to, the
- * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be
- * #define'd appropriately (as is done on SPARC's).
- *
- * Another requirement to port this scheme to another multi-domain architecture
- * is to add the appropriate entries in the pciControllerSizes array below.
- *
- * TO DO: Address the deleterious reaction some host bridges have to master
- * aborts. This is already done for secondary PCI buses, but not yet
- * for accesses to primary buses (except for the SPARC port, where
- * master aborts are avoided during PCI scans).
- */
-
-#include <linux/pci.h>
-
-#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */
-#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
-
-/* Get controller for PCI device. */
-#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00)
-/* Set mmap state to I/O space. */
-#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01)
-/* Set mmap state to MEM space. */
-#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02)
-/* Enable/disable write-combining. */
-#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03)
-
-#endif
-
-/* This probably shouldn't be Linux-specific */
-static struct pci_device *
-get_parent_bridge(struct pci_device *dev)
-{
- struct pci_id_match bridge_match = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
- (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8),
- 0
- };
- struct pci_device *bridge;
- struct pci_device_iterator *iter;
-
- if (dev == NULL) {
- return NULL;
- }
-
- iter = pci_id_match_iterator_create(& bridge_match);
- if (iter == NULL) {
- return NULL;
- }
-
- while ((bridge = pci_device_next(iter)) != NULL) {
- if (bridge->domain == dev->domain) {
- const struct pci_bridge_info *info =
- pci_device_get_bridge_info(bridge);
-
- if (info != NULL) {
- if (info->secondary_bus == dev->bus) {
- break;
- }
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
- return bridge;
-}
-
-/*
- * This is ugly, but until I can extract this information from the kernel,
- * it'll have to do. The default I/O space size is 64K, and 4G for memory.
- * Anything else needs to go in this table. (PowerPC folk take note.)
- *
- * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here.
- *
- * Please keep this table in ascending vendor/device order.
- */
-static const struct pciSizes {
- unsigned short vendor, device;
- unsigned long io_size, mem_size;
-} pciControllerSizes[] = {
- {
- PCI_VENDOR_SUN, PCI_CHIP_PSYCHO,
- 1U << 16, 1U << 31
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_SCHIZO,
- 1U << 24, 1U << 31 /* ??? */
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_SABRE,
- 1U << 24, (unsigned long)(1ULL << 32)
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD,
- 1U << 24, (unsigned long)(1ULL << 32)
- }
-};
-#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0]))
-
-static const struct pciSizes *
-linuxGetSizesStruct(const struct pci_device *dev)
-{
- static const struct pciSizes default_size = {
- 0, 0, 1U << 16, (unsigned long)(1ULL << 32)
- };
- int i;
-
- /* Look up vendor/device */
- if (dev != NULL) {
- for (i = 0; i < NUM_SIZES; i++) {
- if ((dev->vendor_id == pciControllerSizes[i].vendor)
- && (dev->device_id == pciControllerSizes[i].device)) {
- return & pciControllerSizes[i];
- }
- }
- }
-
- /* Default to 64KB I/O and 4GB memory. */
- return & default_size;
-}
-
-static __inline__ unsigned long
-linuxGetIOSize(const struct pci_device *dev)
-{
- const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
- return sizes->io_size;
-}
-
-static pointer
-linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size, int mmap_ioctl)
-{
- /* Align to page boundary */
- const ADDRESS realBase = Base & ~(getpagesize() - 1);
- const ADDRESS Offset = Base - realBase;
-
- do {
- unsigned char *result;
- int fd, mmapflags, prot;
-
- xf86InitVidMem();
-
- /* If dev is NULL, linuxPciOpenFile will return -1, and this routine
- * will fail gracefully.
- */
- prot = ((Flags & VIDMEM_READONLY) == 0);
- if (((fd = linuxPciOpenFile(dev, prot)) < 0) ||
- (ioctl(fd, mmap_ioctl, 0) < 0))
- break;
-
-/* Note: IA-64 doesn't compile this and doesn't need to */
-#ifdef __ia64__
-
-# ifndef MAP_WRITECOMBINED
-# define MAP_WRITECOMBINED 0x00010000
-# endif
-# ifndef MAP_NONCACHED
-# define MAP_NONCACHED 0x00020000
-# endif
-
- if (Flags & VIDMEM_FRAMEBUFFER)
- mmapflags = MAP_SHARED | MAP_WRITECOMBINED;
- else
- mmapflags = MAP_SHARED | MAP_NONCACHED;
-
-#else /* !__ia64__ */
-
- mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER;
-
- if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0)
- break;
-
- mmapflags = MAP_SHARED;
-
-#endif /* ?__ia64__ */
-
-
- if (Flags & VIDMEM_READONLY)
- prot = PROT_READ;
- else
- prot = PROT_READ | PROT_WRITE;
-
- result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase);
-
- if (!result || ((pointer)result == MAP_FAILED))
- return NULL;
-
- xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result);
-
- return result + Offset;
- } while (0);
-
- if (mmap_ioctl == PCIIOC_MMAP_IS_MEM)
- return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-
- return NULL;
-}
-
-static int
-linuxOpenLegacy(struct pci_device *dev, char *name)
-{
- static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s";
- char path[sizeof(PREFIX) + 10];
- int fd = -1;
-
- while (dev != NULL) {
- snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name);
- fd = open(path, O_RDWR);
- if (fd >= 0) {
- return fd;
- }
-
- dev = get_parent_bridge(dev);
- }
-
- return fd;
-}
-
-/*
- * xf86MapDomainMemory - memory map PCI domain memory
- *
- * This routine maps the memory region in the domain specified by Tag and
- * returns a pointer to it. The pointer is saved for future use if it's in
- * the legacy ISA memory space (memory in a domain between 0 and 1MB).
- */
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size)
-{
- int fd = -1;
- pointer addr;
-
- /*
- * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
- * legacy_mem interface is unavailable.
- */
- if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0))
- return linuxMapPci(ScreenNum, Flags, dev, Base, Size,
- PCIIOC_MMAP_IS_MEM);
- else
- addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
-
- if (fd >= 0)
- close(fd);
- if (addr == NULL || addr == MAP_FAILED) {
- perror("mmap failure");
- FatalError("xf86MapDomainMem(): mmap() failure\n");
- }
- return addr;
-}
-
-/**
- * Map I/O space in this domain
- *
- * Each domain has a legacy ISA I/O space. This routine will try to
- * map it using the Linux sysfs legacy_io interface. If that fails,
- * it'll fall back to using /proc/bus/pci.
- *
- * If the legacy_io interface \b does exist, the file descriptor (\c fd below)
- * will be saved in the \c DomainMmappedIO array in the upper bits of the
- * pointer. Callers will do I/O with small port numbers (<64k values), so
- * the platform I/O code can extract the port number and the \c fd, \c lseek
- * to the port number in the legacy_io file, and issue the read or write.
- *
- * This has no means of returning failure, so all errors are fatal
- */
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
- const int domain = dev->domain;
- struct pci_device *bridge = get_parent_bridge(dev);
- int fd;
-
- if (domain >= MAX_DOMAINS)
- FatalError("xf86MapLegacyIO(): domain out of range\n");
-
- if (DomainMmappedIO[domain] == NULL) {
- /* Permanently map all of I/O space */
- fd = linuxOpenLegacy(bridge, "legacy_io");
- if (fd < 0) {
- DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge,
- 0, linuxGetIOSize(bridge),
- PCIIOC_MMAP_IS_IO);
- }
- else { /* legacy_io file exists, encode fd */
- DomainMmappedIO[domain] = (pointer)(intptr_t)(fd << 24);
- }
- }
-
- return (IOADDRESS)DomainMmappedIO[domain];
-}
-
diff --git a/xorg-server/hw/xfree86/os-support/bus/nobus.c b/xorg-server/hw/xfree86/os-support/bus/nobus.c
new file mode 100644
index 000000000..ad23f5288
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/bus/nobus.c
@@ -0,0 +1 @@
+static void __noop_to_appease_ar__() { return; }
diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
index ce1336bf2..74ead201e 100644
--- a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
@@ -235,8 +235,8 @@
/* Primitive Types */
typedef unsigned long ADDRESS; /* Memory/PCI address */
-typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */
-typedef unsigned long PCITAG;
+typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */
+typedef CARD32 PCITAG _X_DEPRECATED;
typedef enum {
PCI_MEM,
@@ -251,12 +251,10 @@ typedef enum {
/* Public PCI access functions */
-extern _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum);
extern _X_EXPORT Bool xf86scanpci(void);
/* Domain access functions. Some of these probably shouldn't be public */
-extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size);
-extern _X_EXPORT IOADDRESS xf86MapLegacyIO(struct pci_device *dev);
+extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
+extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *);
#endif /* _XF86PCI_H */
diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.am b/xorg-server/hw/xfree86/os-support/linux/Makefile.am
index 7a82627fd..36748df2c 100644
--- a/xorg-server/hw/xfree86/os-support/linux/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.am
@@ -1,9 +1,5 @@
noinst_LTLIBRARIES = liblinux.la
-if LINUX_IA64
-PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c
-PLATFORM_INCLUDES = -I$(srcdir)/../shared
-endif
if LINUX_ALPHA
noinst_LTLIBRARIES += liblinuxev56.la
PLATFORM_PCI_SUPPORT = \
diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
index e3c8a984d..564447ff6 100644
--- a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
+++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
@@ -1,544 +1,541 @@
-/*
- * linux specific part of the int10 module
- * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2008 Egbert Eich
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86Pci.h"
-#include "compiler.h"
-#define _INT10_PRIVATE
-#include "xf86int10.h"
-#ifdef __sparc__
-#define DEV_MEM "/dev/fb"
-#else
-#define DEV_MEM "/dev/mem"
-#endif
-#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
-#define SHMERRORPTR (pointer)(-1)
-
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <unistd.h>
-#include <string.h>
-
-static int counter = 0;
-static unsigned long int10Generation = 0;
-
-static CARD8 read_b(xf86Int10InfoPtr pInt, int addr);
-static CARD16 read_w(xf86Int10InfoPtr pInt, int addr);
-static CARD32 read_l(xf86Int10InfoPtr pInt, int addr);
-static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val);
-static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val);
-static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val);
-
-int10MemRec linuxMem = {
- read_b,
- read_w,
- read_l,
- write_b,
- write_w,
- write_l
-};
-
-typedef struct {
- int lowMem;
- int highMem;
- char* base;
- char* base_high;
- int screen;
- char* alloc;
-} linuxInt10Priv;
-
-#if defined DoSubModules
-
-typedef enum {
- INT10_NOT_LOADED,
- INT10_LOADED_VM86,
- INT10_LOADED_X86EMU,
- INT10_LOAD_FAILED
-} Int10LinuxSubModuleState;
-
-static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
-
-static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
-
-#endif /* DoSubModules */
-
-xf86Int10InfoPtr
-xf86ExtendedInitInt10(int entityIndex, int Flags)
-{
- xf86Int10InfoPtr pInt = NULL;
- int screen;
- int fd;
- static void* vidMem = NULL;
- static void* sysMem = NULL;
- void* vMem = NULL;
- void *options = NULL;
- int low_mem;
- int high_mem = -1;
- char *base = SHMERRORPTR;
- char *base_high = SHMERRORPTR;
- int pagesize;
- memType cs;
- legacyVGARec vga;
- Bool videoBiosMapped = FALSE;
-
- if (int10Generation != serverGeneration) {
- counter = 0;
- int10Generation = serverGeneration;
- }
-
- screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
-
- options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
-
- if (int10skip(options)) {
- free(options);
- return NULL;
- }
-
-#if defined DoSubModules
- if (loadedSubModule == INT10_NOT_LOADED)
- loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
-
- if (loadedSubModule == INT10_LOAD_FAILED)
- return NULL;
-#endif
-
- if ((!vidMem) || (!sysMem)) {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (!sysMem) {
- DebugF("Mapping sys bios area\n");
- if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
- PROT_READ | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
- close(fd);
- goto error0;
- }
- }
- if (!vidMem) {
- DebugF("Mapping VRAM area\n");
- if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_RAM))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
- close(fd);
- goto error0;
- }
- }
- close(fd);
- } else {
- xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
- goto error0;
- }
- }
-
- pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
- pInt->scrnIndex = screen;
- pInt->entityIndex = entityIndex;
- pInt->dev = xf86GetPciInfoForEntity(entityIndex);
-
- if (!xf86Int10ExecSetup(pInt))
- goto error0;
- pInt->mem = &linuxMem;
- pagesize = getpagesize();
- pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv));
- ((linuxInt10Priv*)pInt->private)->screen = screen;
- ((linuxInt10Priv*)pInt->private)->alloc =
- (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize));
-
- if (!xf86IsEntityPrimary(entityIndex)) {
- DebugF("Mapping high memory area\n");
- if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- if (errno == ENOSYS)
- xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
- " your kernel to include System V IPC support\n");
- else
- xf86DrvMsg(screen, X_ERROR,
- "shmget(highmem) error: %s\n",strerror(errno));
- goto error1;
- }
- } else {
- DebugF("Mapping Video BIOS\n");
- videoBiosMapped = TRUE;
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
- close(fd);
- goto error1;
- }
- close (fd);
- } else
- goto error1;
- }
- ((linuxInt10Priv*)pInt->private)->highMem = high_mem;
-
- DebugF("Mapping 640kB area\n");
- if ((low_mem = shmget(counter++, V_RAM,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- xf86DrvMsg(screen, X_ERROR,
- "shmget(lowmem) error: %s\n",strerror(errno));
- goto error2;
- }
-
- ((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
- base = shmat(low_mem, 0, 0);
- if (base == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- goto error3;
- }
- ((linuxInt10Priv *)pInt->private)->base = base;
- if (high_mem > -1) {
- base_high = shmat(high_mem, 0, 0);
- if (base_high == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(high_mem) error: %s\n",strerror(errno));
- goto error3;
- }
- ((linuxInt10Priv*)pInt->private)->base_high = base_high;
- } else
- ((linuxInt10Priv*)pInt->private)->base_high = NULL;
-
- if (!MapCurrentInt10(pInt))
- goto error3;
-
- Int10Current = pInt;
-
- DebugF("Mapping int area\n");
- if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) {
- xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
- goto error3;
- }
- DebugF("done\n");
- /*
- * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes
- * have executable code there. Note that xf86ReadBIOS() can only bring in
- * 64K bytes at a time.
- */
- if (!videoBiosMapped) {
- memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
- DebugF("Reading BIOS\n");
- for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
- if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
- xf86DrvMsg(screen, X_WARNING,
- "Unable to retrieve all of segment 0x%06lX.\n",
- (long)cs);
- DebugF("done\n");
- }
-
- if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
- if (!xf86int10GetBiosSegment(pInt, NULL))
- goto error3;
-
- set_return_trap(pInt);
-#ifdef _PC
- pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
- if (! (pInt->Flags & SET_BIOS_SCRATCH))
- pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
- xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
-#endif
- } else {
- const BusType location_type = xf86int10GetBiosLocationType(pInt);
-
- switch (location_type) {
- case BUS_PCI: {
- int err;
- struct pci_device *rom_device =
- xf86GetPciInfoForEntity(pInt->entityIndex);
-
-#if HAVE_PCI_DEVICE_ENABLE
- pci_device_enable(rom_device);
-#endif
-
- err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
- if (err) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
- strerror(err));
- goto error3;
- }
-
- pInt->BIOSseg = V_BIOS >> 4;
- break;
- }
- default:
- goto error3;
- }
-
- pInt->num = 0xe6;
- reset_int_vect(pInt);
- set_return_trap(pInt);
- LockLegacyVGA(pInt, &vga);
- xf86ExecX86int10(pInt);
- UnlockLegacyVGA(pInt, &vga);
- }
-#ifdef DEBUG
- dprint(0xc0000, 0x20);
-#endif
-
- free(options);
- return pInt;
-
-error3:
- if (base_high)
- shmdt(base_high);
- shmdt(base);
- shmdt(0);
- if (base_high)
- shmdt((char*)HIGH_MEM);
- shmctl(low_mem, IPC_RMID, NULL);
- Int10Current = NULL;
-error2:
- if (high_mem > -1)
- shmctl(high_mem, IPC_RMID,NULL);
-error1:
- if (vMem)
- munmap(vMem, SYS_BIOS - V_BIOS);
- free(((linuxInt10Priv*)pInt->private)->alloc);
- free(pInt->private);
-error0:
- free(options);
- free(pInt);
- return NULL;
-}
-
-Bool
-MapCurrentInt10(xf86Int10InfoPtr pInt)
-{
- pointer addr;
- int fd = -1;
-
- if (Int10Current) {
- shmdt(0);
- if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
- }
- addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
- if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- return FALSE;
- }
- if (mprotect((void*)0, V_RAM, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on low memory: %s\n", strerror(errno));
-
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0) {
- addr = shmat(((linuxInt10Priv*)pInt->private)->highMem,
- (char*)HIGH_MEM, 0);
- if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot shmat() high memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmget error: %s\n",strerror(errno));
- return FALSE;
- }
- if (mprotect((void*)HIGH_MEM, HIGH_MEM_SIZE,
- PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on high memory: %s\n",
- strerror(errno));
- } else {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS)
- == MAP_FAILED) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
- close (fd);
- return FALSE;
- }
- } else {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM);
- return FALSE;
- }
- close (fd);
- }
-
- return TRUE;
-}
-
-void
-xf86FreeInt10(xf86Int10InfoPtr pInt)
-{
- if (!pInt)
- return;
-
-#ifdef _PC
- xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
-#endif
- if (Int10Current == pInt) {
- shmdt(0);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
- Int10Current = NULL;
- }
-
- if (((linuxInt10Priv*)pInt->private)->base_high)
- shmdt(((linuxInt10Priv*)pInt->private)->base_high);
- shmdt(((linuxInt10Priv*)pInt->private)->base);
- shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL);
- free(((linuxInt10Priv*)pInt->private)->alloc);
- free(pInt->private);
- free(pInt);
-}
-
-void *
-xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
-{
- int pagesize = getpagesize();
- int num_pages = ALLOC_ENTRIES(pagesize);
- int i, j;
-
- for (i = 0; i < (num_pages - num); i++) {
- if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) {
- for (j = i; j < (num + i); j++)
- if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0))
- break;
- if (j == (num + i))
- break;
- else
- i = i + num;
- }
- }
- if (i == (num_pages - num))
- return NULL;
-
- for (j = i; j < (i + num); j++)
- ((linuxInt10Priv*)pInt->private)->alloc[j] = 1;
-
- *off = (i + 1) * pagesize;
-
- return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize);
-}
-
-void
-xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
-{
- int pagesize = getpagesize();
- int first = (((unsigned long)pbase
- - (unsigned long)((linuxInt10Priv*)pInt->private)->base)
- / pagesize) - 1;
- int i;
-
- for (i = first; i < (first + num); i++)
- ((linuxInt10Priv*)pInt->private)->alloc[i] = 0;
-}
-
-static CARD8
-read_b(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD8 *)(memType)addr);
-}
-
-static CARD16
-read_w(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD16 *)(memType)addr);
-}
-
-static CARD32
-read_l(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD32 *)(memType)addr);
-}
-
-static void
-write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
-{
- *((CARD8 *)(memType)addr) = val;
-}
-
-static void
-write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
-{
- *((CARD16 *)(memType)addr) = val;
-}
-
-static
-void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
-{
- *((CARD32 *)(memType) addr) = val;
-}
-
-pointer
-xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
-{
- if (addr < V_RAM)
- return ((linuxInt10Priv*)pInt->private)->base + addr;
- else if (addr < V_BIOS)
- return (pointer)(memType)addr;
- else if (addr < SYS_BIOS) {
- if (((linuxInt10Priv*)pInt->private)->base_high)
- return (pointer)(((linuxInt10Priv*)pInt->private)->base_high
- - V_BIOS + addr);
- else
- return (pointer) (memType)addr;
- } else
- return (pointer) (memType)addr;
-}
-
-#if defined DoSubModules
-
-static Bool
-vm86_tst(void)
-{
- int __res;
-
-#ifdef __PIC__
- /* When compiling with -fPIC, we can't use asm constraint "b" because
- %ebx is already taken by gcc. */
- __asm__ __volatile__("pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "movl %1,%%eax\n\t"
- "int $0x80\n\t"
- "popl %%ebx"
- :"=a" (__res)
- :"n" ((int)113), "r" (NULL));
-#else
- __asm__ __volatile__("int $0x80\n\t"
- :"=a" (__res):"a" ((int)113),
- "b" ((struct vm86_struct *)NULL));
-#endif
-
- if (__res < 0 && __res == -ENOSYS)
- return FALSE;
-
- return TRUE;
-}
-
-static Int10LinuxSubModuleState
-int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
-{
- if (vm86_tst()) {
- if (xf86LoadSubModule(pScrn,"vm86"))
- return INT10_LOADED_VM86;
- }
- if (xf86LoadSubModule(pScrn,"x86emu"))
- return INT10_LOADED_X86EMU;
-
- return INT10_LOAD_FAILED;
-}
-
-#endif /* DoSubModules */
+/*
+ * linux specific part of the int10 module
+ * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2008 Egbert Eich
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86Pci.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "xf86int10.h"
+#ifdef __sparc__
+#define DEV_MEM "/dev/fb"
+#else
+#define DEV_MEM "/dev/mem"
+#endif
+#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
+#define SHMERRORPTR (pointer)(-1)
+
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <unistd.h>
+#include <string.h>
+
+static int counter = 0;
+static unsigned long int10Generation = 0;
+
+static CARD8 read_b(xf86Int10InfoPtr pInt, int addr);
+static CARD16 read_w(xf86Int10InfoPtr pInt, int addr);
+static CARD32 read_l(xf86Int10InfoPtr pInt, int addr);
+static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val);
+static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val);
+static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val);
+
+int10MemRec linuxMem = {
+ read_b,
+ read_w,
+ read_l,
+ write_b,
+ write_w,
+ write_l
+};
+
+typedef struct {
+ int lowMem;
+ int highMem;
+ char* base;
+ char* base_high;
+ int screen;
+ char* alloc;
+} linuxInt10Priv;
+
+#if defined DoSubModules
+
+typedef enum {
+ INT10_NOT_LOADED,
+ INT10_LOADED_VM86,
+ INT10_LOADED_X86EMU,
+ INT10_LOAD_FAILED
+} Int10LinuxSubModuleState;
+
+static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
+
+static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
+
+#endif /* DoSubModules */
+
+xf86Int10InfoPtr
+xf86ExtendedInitInt10(int entityIndex, int Flags)
+{
+ xf86Int10InfoPtr pInt = NULL;
+ int screen;
+ int fd;
+ static void* vidMem = NULL;
+ static void* sysMem = NULL;
+ void* vMem = NULL;
+ void *options = NULL;
+ int low_mem;
+ int high_mem = -1;
+ char *base = SHMERRORPTR;
+ char *base_high = SHMERRORPTR;
+ int pagesize;
+ memType cs;
+ legacyVGARec vga;
+ Bool videoBiosMapped = FALSE;
+
+ if (int10Generation != serverGeneration) {
+ counter = 0;
+ int10Generation = serverGeneration;
+ }
+
+ screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
+
+ options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
+
+ if (int10skip(options)) {
+ free(options);
+ return NULL;
+ }
+
+#if defined DoSubModules
+ if (loadedSubModule == INT10_NOT_LOADED)
+ loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
+
+ if (loadedSubModule == INT10_LOAD_FAILED)
+ return NULL;
+#endif
+
+ if ((!vidMem) || (!sysMem)) {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (!sysMem) {
+ DebugF("Mapping sys bios area\n");
+ if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
+ PROT_READ | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ if (!vidMem) {
+ DebugF("Mapping VRAM area\n");
+ if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_RAM))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ close(fd);
+ } else {
+ xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
+ goto error0;
+ }
+ }
+
+ pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
+ pInt->scrnIndex = screen;
+ pInt->entityIndex = entityIndex;
+ pInt->dev = xf86GetPciInfoForEntity(entityIndex);
+
+ if (!xf86Int10ExecSetup(pInt))
+ goto error0;
+ pInt->mem = &linuxMem;
+ pagesize = getpagesize();
+ pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv));
+ ((linuxInt10Priv*)pInt->private)->screen = screen;
+ ((linuxInt10Priv*)pInt->private)->alloc =
+ (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize));
+
+ if (!xf86IsEntityPrimary(entityIndex)) {
+ DebugF("Mapping high memory area\n");
+ if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
+ IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ if (errno == ENOSYS)
+ xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
+ " your kernel to include System V IPC support\n");
+ else
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(highmem) error: %s\n",strerror(errno));
+ goto error1;
+ }
+ } else {
+ DebugF("Mapping Video BIOS\n");
+ videoBiosMapped = TRUE;
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
+ close(fd);
+ goto error1;
+ }
+ close (fd);
+ } else
+ goto error1;
+ }
+ ((linuxInt10Priv*)pInt->private)->highMem = high_mem;
+
+ DebugF("Mapping 640kB area\n");
+ if ((low_mem = shmget(counter++, V_RAM,
+ IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(lowmem) error: %s\n",strerror(errno));
+ goto error2;
+ }
+
+ ((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
+ base = shmat(low_mem, 0, 0);
+ if (base == SHMERRORPTR) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(low_mem) error: %s\n",strerror(errno));
+ goto error3;
+ }
+ ((linuxInt10Priv *)pInt->private)->base = base;
+ if (high_mem > -1) {
+ base_high = shmat(high_mem, 0, 0);
+ if (base_high == SHMERRORPTR) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(high_mem) error: %s\n",strerror(errno));
+ goto error3;
+ }
+ ((linuxInt10Priv*)pInt->private)->base_high = base_high;
+ } else
+ ((linuxInt10Priv*)pInt->private)->base_high = NULL;
+
+ if (!MapCurrentInt10(pInt))
+ goto error3;
+
+ Int10Current = pInt;
+
+ DebugF("Mapping int area\n");
+ if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
+ goto error3;
+ }
+ DebugF("done\n");
+ /*
+ * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes
+ * have executable code there. Note that xf86ReadBIOS() can only bring in
+ * 64K bytes at a time.
+ */
+ if (!videoBiosMapped) {
+ memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
+ DebugF("Reading BIOS\n");
+ for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
+ if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
+ xf86DrvMsg(screen, X_WARNING,
+ "Unable to retrieve all of segment 0x%06lX.\n",
+ (long)cs);
+ DebugF("done\n");
+ }
+
+ if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
+ if (!xf86int10GetBiosSegment(pInt, NULL))
+ goto error3;
+
+ set_return_trap(pInt);
+#ifdef _PC
+ pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
+ if (! (pInt->Flags & SET_BIOS_SCRATCH))
+ pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
+ xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
+#endif
+ } else {
+ const BusType location_type = xf86int10GetBiosLocationType(pInt);
+
+ switch (location_type) {
+ case BUS_PCI: {
+ int err;
+ struct pci_device *rom_device =
+ xf86GetPciInfoForEntity(pInt->entityIndex);
+
+ pci_device_enable(rom_device);
+ err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
+ if (err) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
+ strerror(err));
+ goto error3;
+ }
+
+ pInt->BIOSseg = V_BIOS >> 4;
+ break;
+ }
+ default:
+ goto error3;
+ }
+
+ pInt->num = 0xe6;
+ reset_int_vect(pInt);
+ set_return_trap(pInt);
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
+ }
+#ifdef DEBUG
+ dprint(0xc0000, 0x20);
+#endif
+
+ free(options);
+ return pInt;
+
+error3:
+ if (base_high)
+ shmdt(base_high);
+ shmdt(base);
+ shmdt(0);
+ if (base_high)
+ shmdt((char*)HIGH_MEM);
+ shmctl(low_mem, IPC_RMID, NULL);
+ Int10Current = NULL;
+error2:
+ if (high_mem > -1)
+ shmctl(high_mem, IPC_RMID,NULL);
+error1:
+ if (vMem)
+ munmap(vMem, SYS_BIOS - V_BIOS);
+ free(((linuxInt10Priv*)pInt->private)->alloc);
+ free(pInt->private);
+error0:
+ free(options);
+ free(pInt);
+ return NULL;
+}
+
+Bool
+MapCurrentInt10(xf86Int10InfoPtr pInt)
+{
+ pointer addr;
+ int fd = -1;
+
+ if (Int10Current) {
+ shmdt(0);
+ if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0)
+ shmdt((char*)HIGH_MEM);
+ else
+ munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
+ }
+ addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
+ if (addr == SHMERRORPTR) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmat(low_mem) error: %s\n",strerror(errno));
+ return FALSE;
+ }
+ if (mprotect((void*)0, V_RAM, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot set EXEC bit on low memory: %s\n", strerror(errno));
+
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0) {
+ addr = shmat(((linuxInt10Priv*)pInt->private)->highMem,
+ (char*)HIGH_MEM, 0);
+ if (addr == SHMERRORPTR) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot shmat() high memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmget error: %s\n",strerror(errno));
+ return FALSE;
+ }
+ if (mprotect((void*)HIGH_MEM, HIGH_MEM_SIZE,
+ PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot set EXEC bit on high memory: %s\n",
+ strerror(errno));
+ } else {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS)
+ == MAP_FAILED) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
+ close (fd);
+ return FALSE;
+ }
+ } else {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM);
+ return FALSE;
+ }
+ close (fd);
+ }
+
+ return TRUE;
+}
+
+void
+xf86FreeInt10(xf86Int10InfoPtr pInt)
+{
+ if (!pInt)
+ return;
+
+#ifdef _PC
+ xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
+#endif
+ if (Int10Current == pInt) {
+ shmdt(0);
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
+ shmdt((char*)HIGH_MEM);
+ else
+ munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
+ Int10Current = NULL;
+ }
+
+ if (((linuxInt10Priv*)pInt->private)->base_high)
+ shmdt(((linuxInt10Priv*)pInt->private)->base_high);
+ shmdt(((linuxInt10Priv*)pInt->private)->base);
+ shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL);
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
+ shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL);
+ free(((linuxInt10Priv*)pInt->private)->alloc);
+ free(pInt->private);
+ free(pInt);
+}
+
+void *
+xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
+{
+ int pagesize = getpagesize();
+ int num_pages = ALLOC_ENTRIES(pagesize);
+ int i, j;
+
+ for (i = 0; i < (num_pages - num); i++) {
+ if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) {
+ for (j = i; j < (num + i); j++)
+ if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0))
+ break;
+ if (j == (num + i))
+ break;
+ else
+ i = i + num;
+ }
+ }
+ if (i == (num_pages - num))
+ return NULL;
+
+ for (j = i; j < (i + num); j++)
+ ((linuxInt10Priv*)pInt->private)->alloc[j] = 1;
+
+ *off = (i + 1) * pagesize;
+
+ return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize);
+}
+
+void
+xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
+{
+ int pagesize = getpagesize();
+ int first = (((unsigned long)pbase
+ - (unsigned long)((linuxInt10Priv*)pInt->private)->base)
+ / pagesize) - 1;
+ int i;
+
+ for (i = first; i < (first + num); i++)
+ ((linuxInt10Priv*)pInt->private)->alloc[i] = 0;
+}
+
+static CARD8
+read_b(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD8 *)(memType)addr);
+}
+
+static CARD16
+read_w(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD16 *)(memType)addr);
+}
+
+static CARD32
+read_l(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD32 *)(memType)addr);
+}
+
+static void
+write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
+{
+ *((CARD8 *)(memType)addr) = val;
+}
+
+static void
+write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
+{
+ *((CARD16 *)(memType)addr) = val;
+}
+
+static
+void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
+{
+ *((CARD32 *)(memType) addr) = val;
+}
+
+pointer
+xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
+{
+ if (addr < V_RAM)
+ return ((linuxInt10Priv*)pInt->private)->base + addr;
+ else if (addr < V_BIOS)
+ return (pointer)(memType)addr;
+ else if (addr < SYS_BIOS) {
+ if (((linuxInt10Priv*)pInt->private)->base_high)
+ return (pointer)(((linuxInt10Priv*)pInt->private)->base_high
+ - V_BIOS + addr);
+ else
+ return (pointer) (memType)addr;
+ } else
+ return (pointer) (memType)addr;
+}
+
+#if defined DoSubModules
+
+static Bool
+vm86_tst(void)
+{
+ int __res;
+
+#ifdef __PIC__
+ /* When compiling with -fPIC, we can't use asm constraint "b" because
+ %ebx is already taken by gcc. */
+ __asm__ __volatile__("pushl %%ebx\n\t"
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t"
+ "popl %%ebx"
+ :"=a" (__res)
+ :"n" ((int)113), "r" (NULL));
+#else
+ __asm__ __volatile__("int $0x80\n\t"
+ :"=a" (__res):"a" ((int)113),
+ "b" ((struct vm86_struct *)NULL));
+#endif
+
+ if (__res < 0 && __res == -ENOSYS)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Int10LinuxSubModuleState
+int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
+{
+ if (vm86_tst()) {
+ if (xf86LoadSubModule(pScrn,"vm86"))
+ return INT10_LOADED_VM86;
+ }
+ if (xf86LoadSubModule(pScrn,"x86emu"))
+ return INT10_LOADED_X86EMU;
+
+ return INT10_LOAD_FAILED;
+}
+
+#endif /* DoSubModules */
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c
deleted file mode 100644
index 4699fcb88..000000000
--- a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. 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 WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL 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.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include <string.h>
-
-/*
- * Read BIOS via /dev/mem.
- */
-
-#ifndef DEV_MEM
-# define DEV_MEM "/dev/mem"
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int fd;
-
-#ifdef __ia64__
- if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
-#else
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
-#endif
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- if (read(fd, Buf, Len) != Len)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- close(fd);
- return Len;
-}
diff --git a/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c b/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c
deleted file mode 100644
index c93c74c4a..000000000
--- a/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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
- * 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.
- */
-
-/*
- * This file contains the glue needed to support various IA-64 chipsets.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <linux/pci.h>
-
-#include "compiler.h"
-#include "Pci.h"
-
-/*
- * We use special in/out routines here since Altix platforms require the
- * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O
- * space of a given PCI domain; reads and writes are used to do port I/O.
- * The file descriptor for the file is stored in the upper bits of the
- * value passed in by the caller, and is created and populated by
- * xf86MapLegacyIO.
- *
- * If the legacy_io interface doesn't exist, we fall back to the glibc in/out
- * routines, which are prefixed by an underscore (e.g. _outb).
- */
-static int ia64_port_to_fd(unsigned long port)
-{
- return (port >> 24) & 0xffffffff;
-}
-
-void outb(unsigned long port, unsigned char val)
-{
- int fd = ia64_port_to_fd(port);
-
- if (!fd) {
- _outb(val, port & 0xffff);
- goto out;
- }
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- goto out;
- }
- if (write(fd, &val, 1) != 1) {
- ErrorF("I/O write failed\n");
- goto out;
- }
- out:
- return;
-}
-
-void outw(unsigned long port, unsigned short val)
-{
- int fd = ia64_port_to_fd(port);
-
- if (!fd) {
- _outw(val, port & 0xffff);
- goto out;
- }
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- goto out;
- }
- if (write(fd, &val, 2) != 2) {
- ErrorF("I/O write failed\n");
- goto out;
- }
- out:
- return;
-}
-
-void outl(unsigned long port, unsigned int val)
-{
- int fd = ia64_port_to_fd(port);
-
- if (!fd) {
- _outl(val, port & 0xffff);
- goto out;
- }
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- goto out;
- }
- if (write(fd, &val, 4) != 4) {
- ErrorF("I/O write failed\n");
- goto out;
- }
- out:
- return;
-}
-
-unsigned int inb(unsigned long port)
-{
- int fd = ia64_port_to_fd(port);
- unsigned char val;
-
- if (!fd)
- return _inb(port & 0xffff);
-
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- val = -1;
- goto out;
- }
- if (read(fd, &val, 1) != 1) {
- ErrorF("I/O read failed\n");
- val = -1;
- goto out;
- }
- out:
- return val;
-}
-
-unsigned int inw(unsigned long port)
-{
- int fd = ia64_port_to_fd(port);
- unsigned short val;
-
- if (!fd)
- return _inw(port & 0xffff);
-
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- val = -1;
- goto out;
- }
- if (read(fd, &val, 2) != 2) {
- ErrorF("I/O read failed\n");
- val = -1;
- goto out;
- }
- out:
- return val;
-}
-
-unsigned int inl(unsigned long port)
-{
- int fd = ia64_port_to_fd(port);
- unsigned int val;
-
- if (!fd)
- return _inl(port & 0xffff);
-
- if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
- ErrorF("I/O lseek failed\n");
- val = -1;
- goto out;
- }
- if (read(fd, &val, 4) != 4) {
- ErrorF("I/O read failed\n");
- val = -1;
- goto out;
- }
- out:
- return val;
-}
-
diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
index 6358138d8..54f6c6497 100644
--- a/xorg-server/hw/xfree86/os-support/shared/vidmem.c
+++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
@@ -1,296 +1,290 @@
-/*
- * Copyright (c) 1993-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).
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-/*
- * This file contains the common part of the video memory mapping functions
- */
-
-/*
- * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold
- * the MTRR option information, but it is likely to be expanded if we do
- * auto unmapping of memory at VT switch.
- *
- */
-
-typedef struct {
- unsigned long physBase;
- unsigned long size;
- pointer virtBase;
- pointer mtrrInfo;
- int flags;
-} MappingRec, *MappingPtr;
-
-typedef struct {
- int numMappings;
- MappingPtr * mappings;
- Bool mtrrEnabled;
- MessageType mtrrFrom;
- Bool mtrrOptChecked;
- ScrnInfoPtr pScrn;
-} VidMapRec, *VidMapPtr;
-
-static int vidMapIndex = -1;
-
-#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-
-static VidMemInfo vidMemInfo = {FALSE, };
-static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
-
-static VidMapPtr
-getVidMapRec(int scrnIndex)
-{
- VidMapPtr vp;
- ScrnInfoPtr pScrn;
-
- if ((scrnIndex < 0) ||
- !(pScrn = xf86Screens[scrnIndex]))
- return &vidMapRec;
-
- if (vidMapIndex < 0)
- vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
-
- if (VIDMAPPTR(pScrn) != NULL)
- return VIDMAPPTR(pScrn);
-
- vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
- vp->mtrrEnabled = TRUE; /* default to enabled */
- vp->mtrrFrom = X_DEFAULT;
- vp->mtrrOptChecked = FALSE;
- vp->pScrn = pScrn;
- return vp;
-}
-
-static MappingPtr
-newMapping(VidMapPtr vp)
-{
- vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
- (vp->numMappings + 1));
- vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
- return vp->mappings[vp->numMappings++];
-}
-
-static MappingPtr
-findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
-{
- int i;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i]->virtBase == vbase &&
- vp->mappings[i]->size == size)
- return vp->mappings[i];
- }
- return NULL;
-}
-
-static void
-removeMapping(VidMapPtr vp, MappingPtr mp)
-{
- int i, found = 0;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i] == mp) {
- found = 1;
- free(vp->mappings[i]);
- } else if (found) {
- vp->mappings[i - 1] = vp->mappings[i];
- }
- }
- vp->numMappings--;
- vp->mappings[vp->numMappings] = NULL;
-}
-
-enum { OPTION_MTRR };
-static const OptionInfoRec opts[] =
-{
- { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-
-static void
-checkMtrrOption(VidMapPtr vp)
-{
- if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(opts));
- (void)memcpy(options, opts, sizeof(opts));
- xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
- options);
- if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
- vp->mtrrFrom = X_CONFIG;
- free(options);
- vp->mtrrOptChecked = TRUE;
- }
-}
-
-void
-xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
-{
- VidMapPtr vp;
- MappingPtr mp;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->physBase = Base;
- mp->size = Size;
- mp->virtBase = Vbase;
- mp->flags = Flags;
-}
-
-void
-xf86InitVidMem(void)
-{
- if (!vidMemInfo.initialised) {
- memset(&vidMemInfo, 0, sizeof(VidMemInfo));
- xf86OSInitVidMem(&vidMemInfo);
- }
-}
-
-pointer
-xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
-{
- pointer vbase = NULL;
- VidMapPtr vp;
- MappingPtr mp;
-
- if (((Flags & VIDMEM_FRAMEBUFFER) &&
- (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
- FatalError("Mapping memory with more than one type\n");
-
- xf86InitVidMem();
- if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
- return NULL;
-
- vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
- if (!vbase || vbase == (pointer)-1)
- return NULL;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->physBase = Base;
- mp->size = Size;
- mp->virtBase = vbase;
- mp->flags = Flags;
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC) {
- if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
- vp->mtrrFrom);
- else if (Flags & VIDMEM_FRAMEBUFFER)
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
- vp->mtrrFrom);
- }
- return vbase;
-}
-
-void
-xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- VidMapPtr vp;
- MappingPtr mp;
-
- if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem() called before xf86MapVidMem()\n");
- return;
- }
-
- vp = getVidMapRec(ScreenNum);
- mp = findMapping(vp, Base, Size);
- if (!mp) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
- Base, Size);
- return;
- }
- if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
- vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
- vidMemInfo.unmapMem(ScreenNum, Base, Size);
- removeMapping(vp, mp);
-}
-
-Bool
-xf86CheckMTRR(int ScreenNum)
-{
- VidMapPtr vp = getVidMapRec(ScreenNum);
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC)
- return TRUE;
-
- return FALSE;
-}
-
-Bool
-xf86LinearVidMem(void)
-{
- xf86InitVidMem();
- return vidMemInfo.linearSupported;
-}
-
-void
-xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
- unsigned long Size)
-{
- if (!(Flags & VIDMEM_READSIDEEFFECT))
- return;
-
- if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
- return;
-
- vidMemInfo.readSideEffects(ScreenNum, base, Size);
-}
-
+/*
+ * Copyright (c) 1993-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).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+/*
+ * This file contains the common part of the video memory mapping functions
+ */
+
+/*
+ * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold
+ * the MTRR option information, but it is likely to be expanded if we do
+ * auto unmapping of memory at VT switch.
+ *
+ */
+
+typedef struct {
+ unsigned long size;
+ pointer virtBase;
+ pointer mtrrInfo;
+} MappingRec, *MappingPtr;
+
+typedef struct {
+ int numMappings;
+ MappingPtr * mappings;
+ Bool mtrrEnabled;
+ MessageType mtrrFrom;
+ Bool mtrrOptChecked;
+ ScrnInfoPtr pScrn;
+} VidMapRec, *VidMapPtr;
+
+static int vidMapIndex = -1;
+
+#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
+
+static VidMemInfo vidMemInfo = {FALSE, };
+static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
+
+static VidMapPtr
+getVidMapRec(int scrnIndex)
+{
+ VidMapPtr vp;
+ ScrnInfoPtr pScrn;
+
+ if ((scrnIndex < 0) ||
+ !(pScrn = xf86Screens[scrnIndex]))
+ return &vidMapRec;
+
+ if (vidMapIndex < 0)
+ vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
+
+ if (VIDMAPPTR(pScrn) != NULL)
+ return VIDMAPPTR(pScrn);
+
+ vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
+ vp->mtrrEnabled = TRUE; /* default to enabled */
+ vp->mtrrFrom = X_DEFAULT;
+ vp->mtrrOptChecked = FALSE;
+ vp->pScrn = pScrn;
+ return vp;
+}
+
+static MappingPtr
+newMapping(VidMapPtr vp)
+{
+ vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
+ (vp->numMappings + 1));
+ vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
+ return vp->mappings[vp->numMappings++];
+}
+
+static MappingPtr
+findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
+{
+ int i;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i]->virtBase == vbase &&
+ vp->mappings[i]->size == size)
+ return vp->mappings[i];
+ }
+ return NULL;
+}
+
+static void
+removeMapping(VidMapPtr vp, MappingPtr mp)
+{
+ int i, found = 0;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i] == mp) {
+ found = 1;
+ free(vp->mappings[i]);
+ } else if (found) {
+ vp->mappings[i - 1] = vp->mappings[i];
+ }
+ }
+ vp->numMappings--;
+ vp->mappings[vp->numMappings] = NULL;
+}
+
+enum { OPTION_MTRR };
+static const OptionInfoRec opts[] =
+{
+ { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+static void
+checkMtrrOption(VidMapPtr vp)
+{
+ if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(opts));
+ (void)memcpy(options, opts, sizeof(opts));
+ xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
+ options);
+ if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
+ vp->mtrrFrom = X_CONFIG;
+ free(options);
+ vp->mtrrOptChecked = TRUE;
+ }
+}
+
+void
+xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
+{
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->size = Size;
+ mp->virtBase = Vbase;
+}
+
+void
+xf86InitVidMem(void)
+{
+ if (!vidMemInfo.initialised) {
+ memset(&vidMemInfo, 0, sizeof(VidMemInfo));
+ xf86OSInitVidMem(&vidMemInfo);
+ }
+}
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ pointer vbase = NULL;
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (((Flags & VIDMEM_FRAMEBUFFER) &&
+ (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
+ FatalError("Mapping memory with more than one type\n");
+
+ xf86InitVidMem();
+ if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
+ return NULL;
+
+ vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
+
+ if (!vbase || vbase == (pointer)-1)
+ return NULL;
+
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->size = Size;
+ mp->virtBase = vbase;
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC) {
+ if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
+ vp->mtrrFrom);
+ else if (Flags & VIDMEM_FRAMEBUFFER)
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
+ vp->mtrrFrom);
+ }
+ return vbase;
+}
+
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem() called before xf86MapVidMem()\n");
+ return;
+ }
+
+ vp = getVidMapRec(ScreenNum);
+ mp = findMapping(vp, Base, Size);
+ if (!mp) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
+ Base, Size);
+ return;
+ }
+ if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
+ vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
+
+ vidMemInfo.unmapMem(ScreenNum, Base, Size);
+ removeMapping(vp, mp);
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+ VidMapPtr vp = getVidMapRec(ScreenNum);
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC)
+ return TRUE;
+
+ return FALSE;
+}
+
+Bool
+xf86LinearVidMem(void)
+{
+ xf86InitVidMem();
+ return vidMemInfo.linearSupported;
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
+ unsigned long Size)
+{
+ if (!(Flags & VIDMEM_READSIDEEFFECT))
+ return;
+
+ if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
+ return;
+
+ vidMemInfo.readSideEffects(ScreenNum, base, Size);
+}
+
diff --git a/xorg-server/hw/xfree86/os-support/stub/Makefile.am b/xorg-server/hw/xfree86/os-support/stub/Makefile.am
new file mode 100644
index 000000000..a1156ef1b
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/stub/Makefile.am
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = libstub.la
+
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+
+INCLUDES = $(XORG_INCS)
+
+libstub_la_SOURCES = \
+ $(srcdir)/../shared/VTsw_noop.c \
+ $(srcdir)/../shared/agp_noop.c \
+ $(srcdir)/../shared/ioperm_noop.c \
+ $(srcdir)/../shared/kmod_noop.c \
+ $(srcdir)/../shared/pm_noop.c \
+ $(srcdir)/../shared/vidmem.c \
+ $(srcdir)/../shared/posix_tty.c \
+ $(srcdir)/../shared/sigio.c \
+ stub_bell.c \
+ stub_bios.c \
+ stub_init.c \
+ stub_video.c
diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bell.c b/xorg-server/hw/xfree86/os-support/stub/stub_bell.c
new file mode 100644
index 000000000..48625928f
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/stub/stub_bell.c
@@ -0,0 +1,10 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+}
diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c
new file mode 100644
index 000000000..8628316dd
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c
@@ -0,0 +1,12 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ return -1;
+}
diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_init.c b/xorg-server/hw/xfree86/os-support/stub/stub_init.c
new file mode 100644
index 000000000..36fd2b818
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/stub/stub_init.c
@@ -0,0 +1,26 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OpenConsole()
+{
+}
+
+void
+xf86CloseConsole()
+{
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+}
diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_video.c b/xorg-server/hw/xfree86/os-support/stub/stub_video.c
new file mode 100644
index 000000000..327496839
--- /dev/null
+++ b/xorg-server/hw/xfree86/os-support/stub/stub_video.c
@@ -0,0 +1,13 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->initialised = TRUE;
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
index 6a29fbdc9..78ea6e660 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
@@ -132,10 +132,10 @@ _XFUNCPROTOBEGIN
/* public functions */
extern _X_EXPORT Bool xf86LinearVidMem(void);
-extern _X_EXPORT Bool xf86CheckMTRR(int);
-extern _X_EXPORT pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
-extern _X_EXPORT void xf86UnMapVidMem(int, pointer, unsigned long);
-extern _X_EXPORT void xf86MapReadSideEffects(int, int, pointer, unsigned long);
+extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
+extern _X_EXPORT _X_DEPRECATED pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
+extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, pointer, unsigned long);
+extern _X_EXPORT _X_DEPRECATED void xf86MapReadSideEffects(int, int, pointer, unsigned long);
extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
extern _X_EXPORT Bool xf86EnableIO(void);
extern _X_EXPORT void xf86DisableIO(void);
@@ -209,7 +209,7 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int);
extern _X_EXPORT void xf86UseMsg(void);
extern _X_EXPORT PMClose xf86OSPMOpen(void);
-extern _X_EXPORT void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
+extern _X_EXPORT _X_DEPRECATED void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
extern _X_EXPORT void xf86InitVidMem(void);
#endif /* XF86_OS_PRIVS */
diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh
index 18bb73523..b8e7023f3 100644
--- a/xorg-server/hw/xfree86/sdksyms.sh
+++ b/xorg-server/hw/xfree86/sdksyms.sh
@@ -52,7 +52,9 @@ cat > sdksyms.c << EOF
*/
#include "geext.h"
#include "geint.h"
+#ifdef MITSHM
#include "shmint.h"
+#endif
#include "syncsdk.h"
#if XINERAMA
# include "panoramiXsrv.h"
@@ -118,14 +120,16 @@ cat > sdksyms.c << EOF
#include "xf86.h"
#include "xf86Module.h"
#include "xf86Opt.h"
-#include "xf86PciInfo.h"
+#ifdef XSERVER_LIBPCIACCESS
+ #include "xf86PciInfo.h"
+ #include "xf86VGAarbiter.h"
+#endif
#include "xf86Priv.h"
#include "xf86Privstr.h"
#include "xf86cmap.h"
#include "xf86fbman.h"
#include "xf86str.h"
#include "xf86Xinput.h"
-#include "xf86VGAarbiter.h"
#include "xisb.h"
#if XV
# include "xf86xv.h"
@@ -170,7 +174,9 @@ cat > sdksyms.c << EOF
/* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
+#ifdef XSERVER_LIBPCIACCESS
+# include "xf86Pci.h"
+#endif
#if defined(__sparc__) || defined(__sparc)
# include "xf86Sbus.h"
#endif
diff --git a/xorg-server/hw/xfree86/shadowfb/Makefile.am b/xorg-server/hw/xfree86/shadowfb/Makefile.am
index 02d2dd4ea..39c66109e 100644
--- a/xorg-server/hw/xfree86/shadowfb/Makefile.am
+++ b/xorg-server/hw/xfree86/shadowfb/Makefile.am
@@ -1,5 +1,5 @@
module_LTLIBRARIES = libshadowfb.la
-libshadowfb_la_LDFLAGS = -avoid-version
+libshadowfb_la_LDFLAGS = -module -avoid-version
libshadowfb_la_SOURCES = sfbmodule.c shadow.c
sdk_HEADERS = shadowfb.h
diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c
index 1ff38118b..0de5ffea4 100644
--- a/xorg-server/hw/xfree86/utils/cvt/cvt.c
+++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c
@@ -1,300 +1,293 @@
-/*
- * Copyright 2005-2006 Luc Verhaegen.
- *
- * 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.
- *
- */
-
-/* Standalone VESA CVT standard timing modelines generator. */
-
-#include "xf86.h"
-
-/* Error implementation used by the server code we built in */
-void
-Error(const char *str)
-{
- perror(str);
-}
-
-/* FatalError implementation used by the server code we built in */
-void
-FatalError(const char *f, ...)
-{
- va_list args;
- va_start(args, f);
- vfprintf(stderr, f, args);
- va_end(args);
- exit(1);
-}
-
-/* xnfalloc implementation used by the server code we built in */
-pointer
-XNFalloc(unsigned long n)
-{
- pointer r;
-
- r = malloc(n);
- if (!r) {
- perror("malloc failed");
- exit(1);
- }
- return r;
-}
-
-/* xnfcalloc implementation used by the server code we built in */
-pointer
-XNFcalloc(unsigned long n)
-{
- pointer r;
-
- r = calloc(1, n);
- if (!r) {
- perror("calloc failed");
- exit(1);
- }
- return r;
-}
-
-/*
- * Quickly check wether this is a CVT standard mode.
- */
-static Bool
-CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Verbose)
-{
- Bool IsCVT = TRUE;
-
- if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) ||
- (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) ||
- (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)))
- ;
- else {
- if (Verbose)
- fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n");
- IsCVT = FALSE;
- }
-
- if ((VRefresh != 50.0) && (VRefresh != 60.0) &&
- (VRefresh != 75.0) && (VRefresh != 85.0)) {
- if (Verbose)
- fprintf(stderr, "Warning: Refresh Rate is not CVT standard "
- "(50, 60, 75 or 85Hz).\n");
- IsCVT = FALSE;
- }
-
- return IsCVT;
-}
-
-
-/*
- * I'm not documenting --interlaced for obvious reasons, even though I did
- * implement it. I also can't deny having looked at gtf here.
- */
-static void
-PrintUsage(char *Name)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n",
- Name);
- fprintf(stderr, "\n");
- fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n");
- fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking "
- "(default: normal blanking).\n");
- fprintf(stderr, " X : Desired horizontal resolution "
- "(multiple of 8, required).\n");
- fprintf(stderr, " Y : Desired vertical resolution (required).\n");
- fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n");
- fprintf(stderr, "\n");
-
- fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines"
- " for use with X.\n");
-}
-
-
-/*
- *
- */
-static void
-PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
-{
- printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh);
-
- if (CVT) {
- printf("(CVT %.2fM",
- ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0);
-
- if (!(Mode->VDisplay % 3) &&
- ((Mode->VDisplay * 4 / 3) == Mode->HDisplay))
- printf("3");
- else if (!(Mode->VDisplay % 9) &&
- ((Mode->VDisplay * 16 / 9) == Mode->HDisplay))
- printf("9");
- else if (!(Mode->VDisplay % 10) &&
- ((Mode->VDisplay * 16 / 10) == Mode->HDisplay))
- printf("A");
- else if (!(Mode->VDisplay % 4) &&
- ((Mode->VDisplay * 5 / 4) == Mode->HDisplay))
- printf("4");
- else if (!(Mode->VDisplay % 9) &&
- ((Mode->VDisplay * 15 / 9) == Mode->HDisplay))
- printf("9");
-
- if (Reduced)
- printf("-R");
-
- printf(") ");
- } else
- printf("(CVT) ");
-
- printf("hsync: %.2f kHz; ", Mode->HSync);
- printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0);
-
- printf("\n");
-}
-
-
-/*
- * Originally grabbed from xf86Mode.c.
- *
- * Ignoring the actual Mode->name, as the user will want something solid
- * to grab hold of.
- */
-static void
-PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced)
-{
- if (Reduced)
- printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay);
- else
- printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh);
-
- printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay,
- Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay,
- Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
-
- if (Mode->Flags & V_INTERLACE)
- printf(" interlace");
- if (Mode->Flags & V_PHSYNC)
- printf(" +hsync");
- if (Mode->Flags & V_NHSYNC)
- printf(" -hsync");
- if (Mode->Flags & V_PVSYNC)
- printf(" +vsync");
- if (Mode->Flags & V_NVSYNC)
- printf(" -vsync");
-
- printf("\n");
-}
-
-
-/*
- *
- */
-int
-main (int argc, char *argv[])
-{
- DisplayModeRec *Mode;
- int HDisplay = 0, VDisplay = 0;
- float VRefresh = 0.0;
- Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
- Bool Interlaced = FALSE;
- int n;
-
- if ((argc < 3) || (argc > 7)) {
- PrintUsage(argv[0]);
- return 1;
- }
-
- /* This doesn't filter out bad flags properly. Bad flags get passed down
- * to atoi/atof, which then return 0, so that these variables can get
- * filled next time round. So this is just a cosmetic problem.
- */
- for (n = 1; n < argc; n++) {
- if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced"))
- Reduced = TRUE;
- else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced"))
- Interlaced = TRUE;
- else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose"))
- Verbose = TRUE;
- else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
- PrintUsage(argv[0]);
- return 0;
- } else if (!HDisplay) {
- HDisplay = atoi(argv[n]);
- if (!HDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else if (!VDisplay) {
- VDisplay = atoi(argv[n]);
- if (!VDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else if (!VRefresh) {
- VRefresh = atof(argv[n]);
- if (!VRefresh) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else {
- PrintUsage(argv[0]);
- return 1;
- }
- }
-
- if (!HDisplay || !VDisplay) {
- PrintUsage(argv[0]);
- return 0;
- }
-
- /* Default to 60.0Hz */
- if (!VRefresh)
- VRefresh = 60.0;
-
- /* Horizontal timing is always a multiple of 8: round up. */
- if (HDisplay & 0x07) {
- HDisplay &= ~0x07;
- HDisplay += 8;
- }
-
- if (Reduced) {
- if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
- fprintf(stderr,
- "\nERROR: Multiple of 60Hz refresh rate required for "
- " reduced blanking.\n");
- PrintUsage(argv[0]);
- return 0;
- }
- }
-
- IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);
-
- Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);
-
- PrintComment(Mode, IsCVT, Reduced);
- PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
-
- return 0;
-}
+/*
+ * Copyright 2005-2006 Luc Verhaegen.
+ *
+ * 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.
+ *
+ */
+
+/* Standalone VESA CVT standard timing modelines generator. */
+
+#include "xf86.h"
+
+/* FatalError implementation used by the server code we built in */
+void
+FatalError(const char *f, ...)
+{
+ va_list args;
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ exit(1);
+}
+
+/* xnfalloc implementation used by the server code we built in */
+pointer
+XNFalloc(unsigned long n)
+{
+ pointer r;
+
+ r = malloc(n);
+ if (!r) {
+ perror("malloc failed");
+ exit(1);
+ }
+ return r;
+}
+
+/* xnfcalloc implementation used by the server code we built in */
+pointer
+XNFcalloc(unsigned long n)
+{
+ pointer r;
+
+ r = calloc(1, n);
+ if (!r) {
+ perror("calloc failed");
+ exit(1);
+ }
+ return r;
+}
+
+/*
+ * Quickly check wether this is a CVT standard mode.
+ */
+static Bool
+CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
+ Bool Verbose)
+{
+ Bool IsCVT = TRUE;
+
+ if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) ||
+ (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) ||
+ (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) ||
+ (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) ||
+ (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)))
+ ;
+ else {
+ if (Verbose)
+ fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n");
+ IsCVT = FALSE;
+ }
+
+ if ((VRefresh != 50.0) && (VRefresh != 60.0) &&
+ (VRefresh != 75.0) && (VRefresh != 85.0)) {
+ if (Verbose)
+ fprintf(stderr, "Warning: Refresh Rate is not CVT standard "
+ "(50, 60, 75 or 85Hz).\n");
+ IsCVT = FALSE;
+ }
+
+ return IsCVT;
+}
+
+
+/*
+ * I'm not documenting --interlaced for obvious reasons, even though I did
+ * implement it. I also can't deny having looked at gtf here.
+ */
+static void
+PrintUsage(char *Name)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n",
+ Name);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n");
+ fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking "
+ "(default: normal blanking).\n");
+ fprintf(stderr, " X : Desired horizontal resolution "
+ "(multiple of 8, required).\n");
+ fprintf(stderr, " Y : Desired vertical resolution (required).\n");
+ fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n");
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines"
+ " for use with X.\n");
+}
+
+
+/*
+ *
+ */
+static void
+PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
+{
+ printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh);
+
+ if (CVT) {
+ printf("(CVT %.2fM",
+ ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0);
+
+ if (!(Mode->VDisplay % 3) &&
+ ((Mode->VDisplay * 4 / 3) == Mode->HDisplay))
+ printf("3");
+ else if (!(Mode->VDisplay % 9) &&
+ ((Mode->VDisplay * 16 / 9) == Mode->HDisplay))
+ printf("9");
+ else if (!(Mode->VDisplay % 10) &&
+ ((Mode->VDisplay * 16 / 10) == Mode->HDisplay))
+ printf("A");
+ else if (!(Mode->VDisplay % 4) &&
+ ((Mode->VDisplay * 5 / 4) == Mode->HDisplay))
+ printf("4");
+ else if (!(Mode->VDisplay % 9) &&
+ ((Mode->VDisplay * 15 / 9) == Mode->HDisplay))
+ printf("9");
+
+ if (Reduced)
+ printf("-R");
+
+ printf(") ");
+ } else
+ printf("(CVT) ");
+
+ printf("hsync: %.2f kHz; ", Mode->HSync);
+ printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0);
+
+ printf("\n");
+}
+
+
+/*
+ * Originally grabbed from xf86Mode.c.
+ *
+ * Ignoring the actual Mode->name, as the user will want something solid
+ * to grab hold of.
+ */
+static void
+PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
+ Bool Reduced)
+{
+ if (Reduced)
+ printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay);
+ else
+ printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh);
+
+ printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay,
+ Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay,
+ Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
+
+ if (Mode->Flags & V_INTERLACE)
+ printf(" interlace");
+ if (Mode->Flags & V_PHSYNC)
+ printf(" +hsync");
+ if (Mode->Flags & V_NHSYNC)
+ printf(" -hsync");
+ if (Mode->Flags & V_PVSYNC)
+ printf(" +vsync");
+ if (Mode->Flags & V_NVSYNC)
+ printf(" -vsync");
+
+ printf("\n");
+}
+
+
+/*
+ *
+ */
+int
+main (int argc, char *argv[])
+{
+ DisplayModeRec *Mode;
+ int HDisplay = 0, VDisplay = 0;
+ float VRefresh = 0.0;
+ Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
+ Bool Interlaced = FALSE;
+ int n;
+
+ if ((argc < 3) || (argc > 7)) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+
+ /* This doesn't filter out bad flags properly. Bad flags get passed down
+ * to atoi/atof, which then return 0, so that these variables can get
+ * filled next time round. So this is just a cosmetic problem.
+ */
+ for (n = 1; n < argc; n++) {
+ if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced"))
+ Reduced = TRUE;
+ else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced"))
+ Interlaced = TRUE;
+ else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose"))
+ Verbose = TRUE;
+ else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
+ PrintUsage(argv[0]);
+ return 0;
+ } else if (!HDisplay) {
+ HDisplay = atoi(argv[n]);
+ if (!HDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
+ else if (!VDisplay) {
+ VDisplay = atoi(argv[n]);
+ if (!VDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
+ else if (!VRefresh) {
+ VRefresh = atof(argv[n]);
+ if (!VRefresh) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
+ else {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
+
+ if (!HDisplay || !VDisplay) {
+ PrintUsage(argv[0]);
+ return 0;
+ }
+
+ /* Default to 60.0Hz */
+ if (!VRefresh)
+ VRefresh = 60.0;
+
+ /* Horizontal timing is always a multiple of 8: round up. */
+ if (HDisplay & 0x07) {
+ HDisplay &= ~0x07;
+ HDisplay += 8;
+ }
+
+ if (Reduced) {
+ if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
+ fprintf(stderr,
+ "\nERROR: Multiple of 60Hz refresh rate required for "
+ " reduced blanking.\n");
+ PrintUsage(argv[0]);
+ return 0;
+ }
+ }
+
+ IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);
+
+ Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);
+
+ PrintComment(Mode, IsCVT, Reduced);
+ PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
+
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/vbe/Makefile.am b/xorg-server/hw/xfree86/vbe/Makefile.am
index 85c6fd82a..4b794e647 100644
--- a/xorg-server/hw/xfree86/vbe/Makefile.am
+++ b/xorg-server/hw/xfree86/vbe/Makefile.am
@@ -1,5 +1,5 @@
module_LTLIBRARIES = libvbe.la
-libvbe_la_LDFLAGS = -avoid-version
+libvbe_la_LDFLAGS = -module -avoid-version
libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c
sdk_HEADERS = vbe.h vbeModes.h
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c
index 7b1c95e62..4036a01f5 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c
@@ -1,1994 +1,2080 @@
-
-/*
- *
- * Copyright 1991-1999 by The XFree86 Project, Inc.
- *
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- */
-
-#define _NEED_SYSI86
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <X11/X.h>
-#include "misc.h"
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "vgaHW.h"
-
-#include "compiler.h"
-
-#include "xf86cmap.h"
-
-#include "Pci.h"
-
-#ifndef SAVE_FONT1
-#define SAVE_FONT1 1
-#endif
-
-/*
- * These used to be OS-specific, which made this module have an undesirable
- * OS dependency. Define them by default for all platforms.
- */
-#ifndef NEED_SAVED_CMAP
-#define NEED_SAVED_CMAP
-#endif
-#ifndef SAVE_TEXT
-#define SAVE_TEXT 1
-#endif
-#ifndef SAVE_FONT2
-#define SAVE_FONT2 1
-#endif
-
-/* bytes per plane to save for text */
-#define TEXT_AMOUNT 16384
-
-/* bytes per plane to save for font data */
-#define FONT_AMOUNT (8*8192)
-
-#if 0
-/* Override all of these for now */
-#undef SAVE_FONT1
-#define SAVE_FONT1 1
-#undef SAVE_FONT2
-#define SAVE_FONT2 1
-#undef SAVE_TEST
-#define SAVE_TEST 1
-#undef FONT_AMOUNT
-#define FONT_AMOUNT 65536
-#undef TEXT_AMOUNT
-#define TEXT_AMOUNT 65536
-#endif
-
-/* DAC indices for white and black */
-#define WHITE_VALUE 0x3F
-#define BLACK_VALUE 0x00
-#define OVERSCAN_VALUE 0x01
-
-
-/* Use a private definition of this here */
-#undef VGAHWPTR
-#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr
-#define VGAHWPTR(p) ((vgaHWPtr)(VGAHWPTRLVAL(p)))
-
-static int vgaHWPrivateIndex = -1;
-
-#define DAC_TEST_MASK 0x3F
-
-#ifdef NEED_SAVED_CMAP
-/* This default colourmap is used only when it can't be read from the VGA */
-
-static CARD8 defaultDAC[768] =
-{
- 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
- 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
- 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
- 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
- 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11,
- 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24,
- 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40,
- 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63,
- 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63,
- 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16,
- 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0,
- 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0,
- 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47,
- 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63,
- 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63,
- 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39,
- 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31,
- 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31,
- 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55,
- 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63,
- 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63,
- 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49,
- 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45,
- 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45,
- 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58,
- 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63,
- 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28,
- 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7,
- 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0,
- 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0,
- 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21,
- 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28,
- 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28,
- 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17,
- 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14,
- 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14,
- 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24,
- 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28,
- 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28,
- 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22,
- 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20,
- 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20,
- 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26,
- 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28,
- 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16,
- 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4,
- 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0,
- 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0,
- 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12,
- 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16,
- 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16,
- 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10,
- 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8,
- 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8,
- 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14,
- 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16,
- 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16,
- 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12,
- 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11,
- 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11,
- 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15,
- 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-#endif /* NEED_SAVED_CMAP */
-
-/*
- * Standard VGA versions of the register access functions.
- */
-static void
-stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value);
-}
-
-static CARD8
-stdReadCrtc(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
- return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET);
-}
-
-static void
-stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
- outb(hwp->PIOOffset + VGA_GRAPH_DATA, value);
-}
-
-static CARD8
-stdReadGr(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
- return inb(hwp->PIOOffset + VGA_GRAPH_DATA);
-}
-
-static void
-stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
- outb(hwp->PIOOffset + VGA_SEQ_DATA, value);
-}
-
-static CARD8
-stdReadSeq(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
- return inb(hwp->PIOOffset + VGA_SEQ_DATA);
-}
-
-static CARD8
-stdReadST00(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_IN_STAT_0);
-}
-
-static CARD8
-stdReadST01(vgaHWPtr hwp)
-{
- return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-}
-
-static CARD8
-stdReadFCR(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_FEATURE_R);
-}
-
-static void
-stdWriteFCR(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value);
-}
-
-static void
-stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
- outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value);
-}
-
-static CARD8
-stdReadAttr(vgaHWPtr hwp, CARD8 index)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
- return inb(hwp->PIOOffset + VGA_ATTR_DATA_R);
-}
-
-static void
-stdWriteMiscOut(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_MISC_OUT_W, value);
-}
-
-static CARD8
-stdReadMiscOut(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_MISC_OUT_R);
-}
-
-static void
-stdEnablePalette(vgaHWPtr hwp)
-{
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00);
- hwp->paletteEnabled = TRUE;
-}
-
-static void
-stdDisablePalette(vgaHWPtr hwp)
-{
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20);
- hwp->paletteEnabled = FALSE;
-}
-
-static void
-stdWriteDacMask(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_MASK, value);
-}
-
-static CARD8
-stdReadDacMask(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_DAC_MASK);
-}
-
-static void
-stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value);
-}
-
-static void
-stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value);
-}
-
-static void
-stdWriteDacData(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_DATA, value);
-}
-
-static CARD8
-stdReadDacData(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_DAC_DATA);
-}
-
-static CARD8
-stdReadEnable(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_ENABLE);
-}
-
-static void
-stdWriteEnable(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_ENABLE, value);
-}
-
-void
-vgaHWSetStdFuncs(vgaHWPtr hwp)
-{
- hwp->writeCrtc = stdWriteCrtc;
- hwp->readCrtc = stdReadCrtc;
- hwp->writeGr = stdWriteGr;
- hwp->readGr = stdReadGr;
- hwp->readST00 = stdReadST00;
- hwp->readST01 = stdReadST01;
- hwp->readFCR = stdReadFCR;
- hwp->writeFCR = stdWriteFCR;
- hwp->writeAttr = stdWriteAttr;
- hwp->readAttr = stdReadAttr;
- hwp->writeSeq = stdWriteSeq;
- hwp->readSeq = stdReadSeq;
- hwp->writeMiscOut = stdWriteMiscOut;
- hwp->readMiscOut = stdReadMiscOut;
- hwp->enablePalette = stdEnablePalette;
- hwp->disablePalette = stdDisablePalette;
- hwp->writeDacMask = stdWriteDacMask;
- hwp->readDacMask = stdReadDacMask;
- hwp->writeDacWriteAddr = stdWriteDacWriteAddr;
- hwp->writeDacReadAddr = stdWriteDacReadAddr;
- hwp->writeDacData = stdWriteDacData;
- hwp->readDacData = stdReadDacData;
- hwp->PIOOffset = 0;
- hwp->readEnable = stdReadEnable;
- hwp->writeEnable = stdWriteEnable;
-}
-
-/*
- * MMIO versions of the register access functions. These require
- * hwp->MemBase to be set in such a way that when the standard VGA port
- * adderss is added the correct memory address results.
- */
-
-#define minb(p) MMIO_IN8(hwp->MMIOBase, (hwp->MMIOOffset + (p)))
-#define moutb(p,v) MMIO_OUT8(hwp->MMIOBase, (hwp->MMIOOffset + (p)),(v))
-
-static void
-mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
- moutb(hwp->IOBase + VGA_CRTC_DATA_OFFSET, value);
-}
-
-static CARD8
-mmioReadCrtc(vgaHWPtr hwp, CARD8 index)
-{
- moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
- return minb(hwp->IOBase + VGA_CRTC_DATA_OFFSET);
-}
-
-static void
-mmioWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(VGA_GRAPH_INDEX, index);
- moutb(VGA_GRAPH_DATA, value);
-}
-
-static CARD8
-mmioReadGr(vgaHWPtr hwp, CARD8 index)
-{
- moutb(VGA_GRAPH_INDEX, index);
- return minb(VGA_GRAPH_DATA);
-}
-
-static void
-mmioWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(VGA_SEQ_INDEX, index);
- moutb(VGA_SEQ_DATA, value);
-}
-
-static CARD8
-mmioReadSeq(vgaHWPtr hwp, CARD8 index)
-{
- moutb(VGA_SEQ_INDEX, index);
- return minb(VGA_SEQ_DATA);
-}
-
-static CARD8
-mmioReadST00(vgaHWPtr hwp)
-{
- return minb(VGA_IN_STAT_0);
-}
-
-static CARD8
-mmioReadST01(vgaHWPtr hwp)
-{
- return minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
-}
-
-static CARD8
-mmioReadFCR(vgaHWPtr hwp)
-{
- return minb(VGA_FEATURE_R);
-}
-
-static void
-mmioWriteFCR(vgaHWPtr hwp, CARD8 value)
-{
- moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
-}
-
-static void
-mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, index);
- moutb(VGA_ATTR_DATA_W, value);
-}
-
-static CARD8
-mmioReadAttr(vgaHWPtr hwp, CARD8 index)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, index);
- return minb(VGA_ATTR_DATA_R);
-}
-
-static void
-mmioWriteMiscOut(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_MISC_OUT_W, value);
-}
-
-static CARD8
-mmioReadMiscOut(vgaHWPtr hwp)
-{
- return minb(VGA_MISC_OUT_R);
-}
-
-static void
-mmioEnablePalette(vgaHWPtr hwp)
-{
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, 0x00);
- hwp->paletteEnabled = TRUE;
-}
-
-static void
-mmioDisablePalette(vgaHWPtr hwp)
-{
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, 0x20);
- hwp->paletteEnabled = FALSE;
-}
-
-static void
-mmioWriteDacMask(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_MASK, value);
-}
-
-static CARD8
-mmioReadDacMask(vgaHWPtr hwp)
-{
- return minb(VGA_DAC_MASK);
-}
-
-static void
-mmioWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_READ_ADDR, value);
-}
-
-static void
-mmioWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_WRITE_ADDR, value);
-}
-
-static void
-mmioWriteDacData(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_DATA, value);
-}
-
-static CARD8
-mmioReadDacData(vgaHWPtr hwp)
-{
- return minb(VGA_DAC_DATA);
-}
-
-static CARD8
-mmioReadEnable(vgaHWPtr hwp)
-{
- return minb(VGA_ENABLE);
-}
-
-static void
-mmioWriteEnable(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_ENABLE, value);
-}
-
-void
-vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)
-{
- hwp->writeCrtc = mmioWriteCrtc;
- hwp->readCrtc = mmioReadCrtc;
- hwp->writeGr = mmioWriteGr;
- hwp->readGr = mmioReadGr;
- hwp->readST00 = mmioReadST00;
- hwp->readST01 = mmioReadST01;
- hwp->readFCR = mmioReadFCR;
- hwp->writeFCR = mmioWriteFCR;
- hwp->writeAttr = mmioWriteAttr;
- hwp->readAttr = mmioReadAttr;
- hwp->writeSeq = mmioWriteSeq;
- hwp->readSeq = mmioReadSeq;
- hwp->writeMiscOut = mmioWriteMiscOut;
- hwp->readMiscOut = mmioReadMiscOut;
- hwp->enablePalette = mmioEnablePalette;
- hwp->disablePalette = mmioDisablePalette;
- hwp->writeDacMask = mmioWriteDacMask;
- hwp->readDacMask = mmioReadDacMask;
- hwp->writeDacWriteAddr = mmioWriteDacWriteAddr;
- hwp->writeDacReadAddr = mmioWriteDacReadAddr;
- hwp->writeDacData = mmioWriteDacData;
- hwp->readDacData = mmioReadDacData;
- hwp->MMIOBase = base;
- hwp->MMIOOffset = offset;
- hwp->readEnable = mmioReadEnable;
- hwp->writeEnable = mmioWriteEnable;
-}
-
-/*
- * vgaHWProtect --
- * Protect VGA registers and memory from corruption during loads.
- */
-
-void
-vgaHWProtect(ScrnInfoPtr pScrn, Bool on)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- unsigned char tmp;
-
- if (pScrn->vtSema) {
- if (on) {
- /*
- * Turn off screen and disable sequencer.
- */
- tmp = hwp->readSeq(hwp, 0x01);
-
- vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
- hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
-
- hwp->enablePalette(hwp);
- } else {
- /*
- * Reenable sequencer, then turn on screen.
- */
-
- tmp = hwp->readSeq(hwp, 0x01);
-
- hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
- vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
-
- hwp->disablePalette(hwp);
- }
- }
-}
-
-vgaHWProtectProc *vgaHWProtectWeak(void) {
- return vgaHWProtect;
-}
-
-/*
- * vgaHWBlankScreen -- blank the screen.
- */
-
-void
-vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char scrn;
-
- scrn = hwp->readSeq(hwp, 0x01);
-
- if (on) {
- scrn &= ~0x20; /* enable screen */
- } else {
- scrn |= 0x20; /* blank screen */
- }
-
- vgaHWSeqReset(hwp, TRUE);
- hwp->writeSeq(hwp, 0x01, scrn); /* change mode */
- vgaHWSeqReset(hwp, FALSE);
-}
-
-vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) {
- return vgaHWBlankScreen;
-}
-
-/*
- * vgaHWSaveScreen -- blank the screen.
- */
-
-Bool
-vgaHWSaveScreen(ScreenPtr pScreen, int mode)
-{
- ScrnInfoPtr pScrn = NULL;
- Bool on;
-
- if (pScreen != NULL)
- pScrn = xf86Screens[pScreen->myNum];
-
- on = xf86IsUnblank(mode);
-
-#if 0
- if (on)
- SetTimeSinceLastInputEvent();
-#endif
-
- if ((pScrn != NULL) && pScrn->vtSema) {
- vgaHWBlankScreen(pScrn, on);
- }
- return TRUE;
-}
-
-
-/*
- * vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode
- *
- * This generic VGA function can only set the Off and On modes. If the
- * Standby and Suspend modes are to be supported, a chip specific replacement
- * for this function must be written.
- */
-
-void
-vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
-{
- unsigned char seq1 = 0, crtc17 = 0;
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- if (!pScrn->vtSema) return;
-
- switch (PowerManagementMode) {
- case DPMSModeOn:
- /* Screen: On; HSync: On, VSync: On */
- seq1 = 0x00;
- crtc17 = 0x80;
- break;
- case DPMSModeStandby:
- /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeSuspend:
- /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeOff:
- /* Screen: Off; HSync: Off, VSync: Off */
- seq1 = 0x20;
- crtc17 = 0x00;
- break;
- }
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20;
- hwp->writeSeq(hwp, 0x01, seq1);
- crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80;
- usleep(10000);
- hwp->writeCrtc(hwp, 0x17, crtc17);
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
-}
-
-
-/*
- * vgaHWSeqReset
- * perform a sequencer reset.
- */
-
-void
-vgaHWSeqReset(vgaHWPtr hwp, Bool start)
-{
- if (start)
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- else
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
-}
-
-
-void
-vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
-#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int savedIOBase;
- unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4;
- Bool doMap = FALSE;
-
- /* If nothing to do, return now */
- if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
- return;
-
- if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
- return;
- }
- }
-
- /* save the registers that are needed here */
- miscOut = hwp->readMiscOut(hwp);
- attr10 = hwp->readAttr(hwp, 0x10);
- gr1 = hwp->readGr(hwp, 0x01);
- gr3 = hwp->readGr(hwp, 0x03);
- gr4 = hwp->readGr(hwp, 0x04);
- gr5 = hwp->readGr(hwp, 0x05);
- gr6 = hwp->readGr(hwp, 0x06);
- gr8 = hwp->readGr(hwp, 0x08);
- seq2 = hwp->readSeq(hwp, 0x02);
- seq4 = hwp->readSeq(hwp, 0x04);
-
- /* save hwp->IOBase and temporarily set it for colour mode */
- savedIOBase = hwp->IOBase;
- hwp->IOBase = VGA_IOBASE_COLOR;
-
- /* Force into colour mode */
- hwp->writeMiscOut(hwp, miscOut | 0x01);
-
- vgaHWBlankScreen(scrninfp, FALSE);
-
- /*
- * here we temporarily switch to 16 colour planar mode, to simply
- * copy the font-info and saved text.
- *
- * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
- */
-#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
-#endif
-
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
-
- if (scrninfp->depth == 4) {
- /* GJA */
- hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */
- hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */
- hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
- }
-
-#if SAVE_FONT1
- if (hwp->FontInfo1) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
- }
-#endif
-
-#if SAVE_FONT2
- if (hwp->FontInfo2) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
- }
-#endif
-
-#if SAVE_TEXT
- if (hwp->TextInfo) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
- hwp->Base, TEXT_AMOUNT);
- }
-#endif
-
- vgaHWBlankScreen(scrninfp, TRUE);
-
- /* restore the registers that were changed */
- hwp->writeMiscOut(hwp, miscOut);
- hwp->writeAttr(hwp, 0x10, attr10);
- hwp->writeGr(hwp, 0x01, gr1);
- hwp->writeGr(hwp, 0x03, gr3);
- hwp->writeGr(hwp, 0x04, gr4);
- hwp->writeGr(hwp, 0x05, gr5);
- hwp->writeGr(hwp, 0x06, gr6);
- hwp->writeGr(hwp, 0x08, gr8);
- hwp->writeSeq(hwp, 0x02, seq2);
- hwp->writeSeq(hwp, 0x04, seq4);
- hwp->IOBase = savedIOBase;
-
- if (doMap)
- vgaHWUnmapMem(scrninfp);
-
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
-}
-
-
-void
-vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
- if (restore->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
- else
- hwp->IOBase = VGA_IOBASE_MONO;
-
- hwp->writeMiscOut(hwp, restore->MiscOutReg);
-
- for (i = 1; i < restore->numSequencer; i++)
- hwp->writeSeq(hwp, i, restore->Sequencer[i]);
-
- /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
- hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
-
- for (i = 0; i < restore->numCRTC; i++)
- hwp->writeCrtc(hwp, i, restore->CRTC[i]);
-
- for (i = 0; i < restore->numGraphics; i++)
- hwp->writeGr(hwp, i, restore->Graphics[i]);
-
- hwp->enablePalette(hwp);
- for (i = 0; i < restore->numAttribute; i++)
- hwp->writeAttr(hwp, i, restore->Attribute[i]);
- hwp->disablePalette(hwp);
-}
-
-
-void
-vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
-#if 0
- hwp->enablePalette(hwp);
-#endif
-
- hwp->writeDacMask(hwp, 0xFF);
- hwp->writeDacWriteAddr(hwp, 0x00);
- for (i = 0; i < 768; i++) {
- hwp->writeDacData(hwp, restore->DAC[i]);
- DACDelay(hwp);
- }
-
- hwp->disablePalette(hwp);
-}
-
-
-/*
- * vgaHWRestore --
- * restore the VGA state
- */
-
-void
-vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags)
-{
- if (flags & VGA_SR_MODE)
- vgaHWRestoreMode(scrninfp, restore);
-
- if (flags & VGA_SR_FONTS)
- vgaHWRestoreFonts(scrninfp, restore);
-
- if (flags & VGA_SR_CMAP)
- vgaHWRestoreColormap(scrninfp, restore);
-}
-
-void
-vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
-#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int savedIOBase;
- unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4;
- Bool doMap = FALSE;
-
- if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWSaveFonts: vgaHWMapMem() failed\n");
- return;
- }
- }
-
- /* If in graphics mode, don't save anything */
- attr10 = hwp->readAttr(hwp, 0x10);
- if (attr10 & 0x01)
- return;
-
- /* save the registers that are needed here */
- miscOut = hwp->readMiscOut(hwp);
- gr4 = hwp->readGr(hwp, 0x04);
- gr5 = hwp->readGr(hwp, 0x05);
- gr6 = hwp->readGr(hwp, 0x06);
- seq2 = hwp->readSeq(hwp, 0x02);
- seq4 = hwp->readSeq(hwp, 0x04);
-
- /* save hwp->IOBase and temporarily set it for colour mode */
- savedIOBase = hwp->IOBase;
- hwp->IOBase = VGA_IOBASE_COLOR;
-
- /* Force into colour mode */
- hwp->writeMiscOut(hwp, miscOut | 0x01);
-
- vgaHWBlankScreen(scrninfp, FALSE);
-
- /*
- * get the character sets, and text screen if required
- */
- /*
- * Here we temporarily switch to 16 colour planar mode, to simply
- * copy the font-info
- *
- * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
- */
-#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
-#endif
-
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
-
-#if SAVE_FONT1
- if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
- }
-#endif /* SAVE_FONT1 */
-#if SAVE_FONT2
- if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
- }
-#endif /* SAVE_FONT2 */
-#if SAVE_TEXT
- if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_frombus(hwp->Base,
- (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
- }
-#endif /* SAVE_TEXT */
-
- /* Restore clobbered registers */
- hwp->writeAttr(hwp, 0x10, attr10);
- hwp->writeSeq(hwp, 0x02, seq2);
- hwp->writeSeq(hwp, 0x04, seq4);
- hwp->writeGr(hwp, 0x04, gr4);
- hwp->writeGr(hwp, 0x05, gr5);
- hwp->writeGr(hwp, 0x06, gr6);
- hwp->writeMiscOut(hwp, miscOut);
- hwp->IOBase = savedIOBase;
-
- vgaHWBlankScreen(scrninfp, TRUE);
-
- if (doMap)
- vgaHWUnmapMem(scrninfp);
-
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
-}
-
-void
-vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
- save->MiscOutReg = hwp->readMiscOut(hwp);
- if (save->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
- else
- hwp->IOBase = VGA_IOBASE_MONO;
-
- for (i = 0; i < save->numCRTC; i++) {
- save->CRTC[i] = hwp->readCrtc(hwp, i);
- DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
- }
-
- hwp->enablePalette(hwp);
- for (i = 0; i < save->numAttribute; i++) {
- save->Attribute[i] = hwp->readAttr(hwp, i);
- DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
- }
- hwp->disablePalette(hwp);
-
- for (i = 0; i < save->numGraphics; i++) {
- save->Graphics[i] = hwp->readGr(hwp, i);
- DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
- }
-
- for (i = 1; i < save->numSequencer; i++) {
- save->Sequencer[i] = hwp->readSeq(hwp, i);
- DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
- }
-}
-
-
-void
-vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- Bool readError = FALSE;
- int i;
-
-#ifdef NEED_SAVED_CMAP
- /*
- * Some ET4000 chips from 1991 have a HW bug that prevents the reading
- * of the color lookup table. Mask rev 9042EAI is known to have this bug.
- *
- * If the colourmap is not readable, we set the saved map to a default
- * map (taken from Ferraro's "Programmer's Guide to the EGA and VGA
- * Cards" 2nd ed).
- */
-
- /* Only save it once */
- if (hwp->cmapSaved)
- return;
-
-#if 0
- hwp->enablePalette(hwp);
-#endif
-
- hwp->writeDacMask(hwp, 0xFF);
-
- /*
- * check if we can read the lookup table
- */
- hwp->writeDacReadAddr(hwp, 0x00);
- for (i = 0; i < 6; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
- }
-
- /*
- * Check if we can read the palette -
- * use foreground color to prevent flashing.
- */
- hwp->writeDacWriteAddr(hwp, 0x01);
- for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK);
- hwp->writeDacReadAddr(hwp, 0x01);
- for (i = 3; i < 6; i++) {
- if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK))
- readError = TRUE;
- }
- hwp->writeDacWriteAddr(hwp, 0x01);
- for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, save->DAC[i]);
-
- if (readError) {
- /*
- * save the default lookup table
- */
- memmove(save->DAC, defaultDAC, 768);
- xf86DrvMsg(scrninfp->scrnIndex, X_WARNING,
- "Cannot read colourmap from VGA. Will restore with default\n");
- } else {
- /* save the colourmap */
- hwp->writeDacReadAddr(hwp, 0x02);
- for (i = 6; i < 768; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- DACDelay(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
- }
- }
-
- hwp->disablePalette(hwp);
- hwp->cmapSaved = TRUE;
-#endif
-}
-
-/*
- * vgaHWSave --
- * save the current VGA state
- */
-
-void
-vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags)
-{
- if (save == NULL)
- return;
-
- if (flags & VGA_SR_CMAP)
- vgaHWSaveColormap(scrninfp, save);
-
- if (flags & VGA_SR_MODE)
- vgaHWSaveMode(scrninfp, save);
-
- if (flags & VGA_SR_FONTS)
- vgaHWSaveFonts(scrninfp, save);
-}
-
-
-/*
- * vgaHWInit --
- * Handle the initialization, etc. of a screen.
- * Return FALSE on failure.
- */
-
-Bool
-vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
-{
- unsigned int i;
- vgaHWPtr hwp;
- vgaRegPtr regp;
- int depth = scrninfp->depth;
-
- /*
- * make sure the vgaHWRec is allocated
- */
- if (!vgaHWGetHWRec(scrninfp))
- return FALSE;
- hwp = VGAHWPTR(scrninfp);
- regp = &hwp->ModeReg;
-
- /*
- * compute correct Hsync & Vsync polarity
- */
- if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
- && (mode->Flags & (V_PVSYNC | V_NVSYNC)))
- {
- regp->MiscOutReg = 0x23;
- if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40;
- if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80;
- }
- else
- {
- int VDisplay = mode->VDisplay;
- if (mode->Flags & V_DBLSCAN)
- VDisplay *= 2;
- if (mode->VScan > 1)
- VDisplay *= mode->VScan;
- if (VDisplay < 400)
- regp->MiscOutReg = 0xA3; /* +hsync -vsync */
- else if (VDisplay < 480)
- regp->MiscOutReg = 0x63; /* -hsync +vsync */
- else if (VDisplay < 768)
- regp->MiscOutReg = 0xE3; /* -hsync -vsync */
- else
- regp->MiscOutReg = 0x23; /* +hsync +vsync */
- }
-
- regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2;
-
- /*
- * Time Sequencer
- */
- if (depth == 4)
- regp->Sequencer[0] = 0x02;
- else
- regp->Sequencer[0] = 0x00;
- if (mode->Flags & V_CLKDIV2)
- regp->Sequencer[1] = 0x09;
- else
- regp->Sequencer[1] = 0x01;
- if (depth == 1)
- regp->Sequencer[2] = 1 << BIT_PLANE;
- else
- regp->Sequencer[2] = 0x0F;
- regp->Sequencer[3] = 0x00; /* Font select */
- if (depth < 8)
- regp->Sequencer[4] = 0x06; /* Misc */
- else
- regp->Sequencer[4] = 0x0E; /* Misc */
-
- /*
- * CRTC Controller
- */
- regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5;
- regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1;
- regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1;
- regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
- i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F);
- if (i < 0x80)
- regp->CRTC[3] |= i;
- regp->CRTC[4] = (mode->CrtcHSyncStart >> 3);
- regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2)
- | (((mode->CrtcHSyncEnd >> 3)) & 0x1F);
- regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF;
- regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8)
- | (((mode->CrtcVDisplay - 1) & 0x100) >> 7)
- | ((mode->CrtcVSyncStart & 0x100) >> 6)
- | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5)
- | 0x10
- | (((mode->CrtcVTotal - 2) & 0x200) >> 4)
- | (((mode->CrtcVDisplay - 1) & 0x200) >> 3)
- | ((mode->CrtcVSyncStart & 0x200) >> 2);
- regp->CRTC[8] = 0x00;
- regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40;
- if (mode->Flags & V_DBLSCAN)
- regp->CRTC[9] |= 0x80;
- if (mode->VScan >= 32)
- regp->CRTC[9] |= 0x1F;
- else if (mode->VScan > 1)
- regp->CRTC[9] |= mode->VScan - 1;
- regp->CRTC[10] = 0x00;
- regp->CRTC[11] = 0x00;
- regp->CRTC[12] = 0x00;
- regp->CRTC[13] = 0x00;
- regp->CRTC[14] = 0x00;
- regp->CRTC[15] = 0x00;
- regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF;
- regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20;
- regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF;
- regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */
- regp->CRTC[20] = 0x00;
- regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF;
- regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
- if (depth < 8)
- regp->CRTC[23] = 0xE3;
- else
- regp->CRTC[23] = 0xC3;
- regp->CRTC[24] = 0xFF;
-
- vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
- vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
-
- /*
- * Theory resumes here....
- */
-
- /*
- * Graphics Display Controller
- */
- regp->Graphics[0] = 0x00;
- regp->Graphics[1] = 0x00;
- regp->Graphics[2] = 0x00;
- regp->Graphics[3] = 0x00;
- if (depth == 1) {
- regp->Graphics[4] = BIT_PLANE;
- regp->Graphics[5] = 0x00;
- } else {
- regp->Graphics[4] = 0x00;
- if (depth == 4)
- regp->Graphics[5] = 0x02;
- else
- regp->Graphics[5] = 0x40;
- }
- regp->Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */
- regp->Graphics[7] = 0x0F;
- regp->Graphics[8] = 0xFF;
-
- if (depth == 1) {
- /* Initialise the Mono map according to which bit-plane gets used */
-
- Bool flipPixels = xf86GetFlipPixels();
-
- for (i=0; i<16; i++)
- if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
- regp->Attribute[i] = WHITE_VALUE;
- else
- regp->Attribute[i] = BLACK_VALUE;
-
- regp->Attribute[16] = 0x01; /* -VGA2- */ /* wrong for the ET4000 */
- if (!hwp->ShowOverscan)
- regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
- } else {
- regp->Attribute[0] = 0x00; /* standard colormap translation */
- regp->Attribute[1] = 0x01;
- regp->Attribute[2] = 0x02;
- regp->Attribute[3] = 0x03;
- regp->Attribute[4] = 0x04;
- regp->Attribute[5] = 0x05;
- regp->Attribute[6] = 0x06;
- regp->Attribute[7] = 0x07;
- regp->Attribute[8] = 0x08;
- regp->Attribute[9] = 0x09;
- regp->Attribute[10] = 0x0A;
- regp->Attribute[11] = 0x0B;
- regp->Attribute[12] = 0x0C;
- regp->Attribute[13] = 0x0D;
- regp->Attribute[14] = 0x0E;
- regp->Attribute[15] = 0x0F;
- if (depth == 4)
- regp->Attribute[16] = 0x81; /* wrong for the ET4000 */
- else
- regp->Attribute[16] = 0x41; /* wrong for the ET4000 */
- /* Attribute[17] (overscan) initialised in vgaHWGetHWRec() */
- }
- regp->Attribute[18] = 0x0F;
- regp->Attribute[19] = 0x00;
- regp->Attribute[20] = 0x00;
-
- return TRUE;
-}
-
- /*
- * OK, so much for theory. Now, let's deal with the >real< world...
- *
- * The above CRTC settings are precise in theory, except that many, if not
- * most, VGA clones fail to reset the blanking signal when the character or
- * line counter reaches [HV]Total. In this case, the signal is only
- * unblanked when the counter reaches [HV]BlankEnd (mod 64, 128 or 256 as
- * the case may be) at the start of the >next< scanline or frame, which
- * means only part of the screen shows. This affects how null overscans
- * are to be implemented on such adapters.
- *
- * Henceforth, VGA cores that implement this broken, but unfortunately
- * common, behaviour are to be designated as KGA's, in honour of Koen
- * Gadeyne, whose zeal to eliminate overscans (read: fury) set in motion
- * a series of events that led to the discovery of this problem.
- *
- * Some VGA's are KGA's only in the horizontal, or only in the vertical,
- * some in both, others in neither. Don't let anyone tell you there is
- * such a thing as a VGA "standard"... And, thank the Creator for the fact
- * that Hilbert spaces are not yet implemented in this industry.
- *
- * The following implements a trick suggested by David Dawes. This sets
- * [HV]BlankEnd to zero if the blanking interval does not already contain a
- * 0-point, and decrements it by one otherwise. In the latter case, this
- * will produce a left and/or top overscan which the colourmap code will
- * (still) need to ensure is as close to black as possible. This will make
- * the behaviour consistent across all chipsets, while allowing all
- * chipsets to display the entire screen. Non-KGA drivers can ignore the
- * following in their own copy of this code.
- *
- * -- TSI @ UQV, 1998.08.21
- */
-
-CARD32
-vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
-{
- int nExtBits = (nBits < 6) ? 0 : nBits - 6;
- CARD32 ExtBits;
- CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6;
-
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F)
- | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80)
- | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2);
- ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask;
-
- /* First the horizontal case */
- if ((Flags & KGA_FIX_OVERSCAN)
- && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3)))
- {
- int i = (regp->CRTC[3] & 0x1F)
- | ((regp->CRTC[5] & 0x80) >> 2)
- | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1)
- & (0x3F | ExtBitMask)))
- && (mode->CrtcHBlankEnd == mode->CrtcHTotal))
- i = 0;
- } else if (Flags & KGA_BE_TOT_DEC)
- i--;
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80);
- ExtBits = i & ExtBitMask;
- }
- return ExtBits >> 6;
-}
-
- /*
- * The vertical case is a little trickier. Some VGA's ignore bit 0x80 of
- * CRTC[22]. Also, in some cases, a zero CRTC[22] will still blank the
- * very first scanline in a double- or multi-scanned mode. This last case
- * needs further investigation.
- */
-CARD32
-vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
-{
- CARD32 ExtBits;
- CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8);
- CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8;
- /* If width is not known nBits should be 0. In this
- * case BitMask is set to 0 so we can check for it. */
- CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1);
- int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
- regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
- ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask;
-
- if ((Flags & KGA_FIX_OVERSCAN)
- && (mode->CrtcVBlankEnd == mode->CrtcVTotal))
- /* Null top overscan */
- {
- int i = regp->CRTC[22] | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask)))
- || ((i > VBlankStart) && /* 8-bit case */
- ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */
- !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */
- i = 0;
- else
- i = (i - 1);
- } else if (Flags & KGA_BE_TOT_DEC)
- i = (i - 1);
-
- regp->CRTC[22] = i & 0xFF;
- ExtBits = i & 0xFF00;
- }
- return ExtBits >> 8;
-}
-
-/*
- * these are some more hardware specific helpers, formerly in vga.c
- */
-static void
-vgaHWGetHWRecPrivate(void)
-{
- if (vgaHWPrivateIndex < 0)
- vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
- return;
-}
-
-
-static void
-vgaHWFreeRegs(vgaRegPtr regp)
-{
- free(regp->CRTC);
-
- regp->CRTC =
- regp->Sequencer =
- regp->Graphics =
- regp->Attribute = NULL;
-
- regp->numCRTC =
- regp->numSequencer =
- regp->numGraphics =
- regp->numAttribute = 0;
-}
-
-
-
-static Bool
-vgaHWAllocRegs(vgaRegPtr regp)
-{
- unsigned char *buf;
-
- if ((regp->numCRTC + regp->numSequencer + regp->numGraphics +
- regp->numAttribute) == 0)
- return FALSE;
-
- buf = calloc(regp->numCRTC +
- regp->numSequencer +
- regp->numGraphics +
- regp->numAttribute, 1);
- if (!buf)
- return FALSE;
-
- regp->CRTC = buf;
- regp->Sequencer = regp->CRTC + regp->numCRTC;
- regp->Graphics = regp->Sequencer + regp->numSequencer;
- regp->Attribute = regp->Graphics + regp->numGraphics;
-
- return TRUE;
-}
-
-
-Bool
-vgaHWAllocDefaultRegs(vgaRegPtr regp)
-{
- regp->numCRTC = VGA_NUM_CRTC;
- regp->numSequencer = VGA_NUM_SEQ;
- regp->numGraphics = VGA_NUM_GFX;
- regp->numAttribute = VGA_NUM_ATTR;
-
- return vgaHWAllocRegs(regp);
-}
-
-
-Bool
-vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute)
-{
-#define VGAHWMINNUM(regtype) \
- ((newMode.num##regtype < regp->num##regtype) ? \
- (newMode.num##regtype) : (regp->num##regtype))
-#define VGAHWCOPYREGSET(regtype) \
- memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype))
-
- vgaRegRec newMode, newSaved;
- vgaRegPtr regp;
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- memcpy (&newMode, regp, sizeof(vgaRegRec));
-
- /* allocate space for new registers */
-
- regp = &newMode;
- regp->numCRTC = numCRTC;
- regp->numSequencer = numSequencer;
- regp->numGraphics = numGraphics;
- regp->numAttribute = numAttribute;
- if (!vgaHWAllocRegs(regp))
- return FALSE;
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- memcpy (&newSaved, regp, sizeof(vgaRegRec));
-
- regp = &newSaved;
- regp->numCRTC = numCRTC;
- regp->numSequencer = numSequencer;
- regp->numGraphics = numGraphics;
- regp->numAttribute = numAttribute;
- if (!vgaHWAllocRegs(regp)) {
- vgaHWFreeRegs(&newMode);
- return FALSE;
- }
-
- /* allocations succeeded, copy register data into new space */
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- VGAHWCOPYREGSET(CRTC);
- VGAHWCOPYREGSET(Sequencer);
- VGAHWCOPYREGSET(Graphics);
- VGAHWCOPYREGSET(Attribute);
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- VGAHWCOPYREGSET(CRTC);
- VGAHWCOPYREGSET(Sequencer);
- VGAHWCOPYREGSET(Graphics);
- VGAHWCOPYREGSET(Attribute);
-
- /* free old register arrays */
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- vgaHWFreeRegs(regp);
- memcpy(regp, &newMode, sizeof(vgaRegRec));
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- vgaHWFreeRegs(regp);
- memcpy(regp, &newSaved, sizeof(vgaRegRec));
-
- return TRUE;
-
-#undef VGAHWMINNUM
-#undef VGAHWCOPYREGSET
-}
-
-
-Bool
-vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
-{
- vgaHWFreeRegs(dst);
-
- memcpy(dst, src, sizeof(vgaRegRec));
-
- if (!vgaHWAllocRegs(dst))
- return FALSE;
-
- memcpy(dst->CRTC, src->CRTC, src->numCRTC);
- memcpy(dst->Sequencer, src->Sequencer, src->numSequencer);
- memcpy(dst->Graphics, src->Graphics, src->numGraphics);
- memcpy(dst->Attribute, src->Attribute, src->numAttribute);
-
- return TRUE;
-}
-
-
-Bool
-vgaHWGetHWRec(ScrnInfoPtr scrp)
-{
- vgaRegPtr regp;
- vgaHWPtr hwp;
- int i;
-
- /*
- * Let's make sure that the private exists and allocate one.
- */
- vgaHWGetHWRecPrivate();
- /*
- * New privates are always set to NULL, so we can check if the allocation
- * has already been done.
- */
- if (VGAHWPTR(scrp))
- return TRUE;
- hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1);
- regp = &VGAHWPTR(scrp)->ModeReg;
-
- if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) ||
- (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) {
- free(hwp);
- return FALSE;
- }
-
- if (scrp->bitsPerPixel == 1) {
- rgb blackColour = scrp->display->blackColour,
- whiteColour = scrp->display->whiteColour;
-
- if (blackColour.red > 0x3F) blackColour.red = 0x3F;
- if (blackColour.green > 0x3F) blackColour.green = 0x3F;
- if (blackColour.blue > 0x3F) blackColour.blue = 0x3F;
-
- if (whiteColour.red > 0x3F) whiteColour.red = 0x3F;
- if (whiteColour.green > 0x3F) whiteColour.green = 0x3F;
- if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F;
-
- if ((blackColour.red == whiteColour.red ) &&
- (blackColour.green == whiteColour.green) &&
- (blackColour.blue == whiteColour.blue )) {
- blackColour.red ^= 0x3F;
- blackColour.green ^= 0x3F;
- blackColour.blue ^= 0x3F;
- }
-
- /*
- * initialize default colormap for monochrome
- */
- for (i=0; i<3; i++) regp->DAC[i] = 0x00;
- for (i=3; i<768; i++) regp->DAC[i] = 0x3F;
- i = BLACK_VALUE * 3;
- regp->DAC[i++] = blackColour.red;
- regp->DAC[i++] = blackColour.green;
- regp->DAC[i] = blackColour.blue;
- i = WHITE_VALUE * 3;
- regp->DAC[i++] = whiteColour.red;
- regp->DAC[i++] = whiteColour.green;
- regp->DAC[i] = whiteColour.blue;
- i = OVERSCAN_VALUE * 3;
- regp->DAC[i++] = 0x00;
- regp->DAC[i++] = 0x00;
- regp->DAC[i] = 0x00;
- } else {
- /* Set all colours to black */
- for (i=0; i<768; i++) regp->DAC[i] = 0x00;
- /* ... and the overscan */
- if (scrp->depth >= 4)
- regp->Attribute[OVERSCAN] = 0xFF;
- }
- if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) {
- xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan");
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n");
- regp->DAC[765] = 0x3F;
- regp->DAC[766] = 0x00;
- regp->DAC[767] = 0x3F;
- regp->Attribute[OVERSCAN] = 0xFF;
- hwp->ShowOverscan = TRUE;
- } else
- hwp->ShowOverscan = FALSE;
-
- hwp->paletteEnabled = FALSE;
- hwp->cmapSaved = FALSE;
- hwp->MapSize = 0;
- hwp->pScrn = scrp;
-
- /* Initialise the function pointers with the standard VGA versions */
- vgaHWSetStdFuncs(hwp);
-
- hwp->PIOOffset = scrp->domainIOBase;
- hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]);
-
- return TRUE;
-}
-
-
-void
-vgaHWFreeHWRec(ScrnInfoPtr scrp)
-{
- if (vgaHWPrivateIndex >= 0) {
- vgaHWPtr hwp = VGAHWPTR(scrp);
-
- if (!hwp)
- return;
-
- free(hwp->FontInfo1);
- free(hwp->FontInfo2);
- free(hwp->TextInfo);
-
- vgaHWFreeRegs (&hwp->ModeReg);
- vgaHWFreeRegs (&hwp->SavedReg);
-
- free(hwp);
- VGAHWPTRLVAL(scrp) = NULL;
- }
-}
-
-
-Bool
-vgaHWMapMem(ScrnInfoPtr scrp)
-{
- vgaHWPtr hwp = VGAHWPTR(scrp);
- int scr_index = scrp->scrnIndex;
-
- if (hwp->Base)
- return TRUE;
-
- /* If not set, initialise with the defaults */
- if (hwp->MapSize == 0)
- hwp->MapSize = VGA_DEFAULT_MEM_SIZE;
- if (hwp->MapPhys == 0)
- hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR;
-
- /*
- * Map as VIDMEM_MMIO_32BIT because WC
- * is bad when there is page flipping.
- * XXX This is not correct but we do it
- * for now.
- */
- DebugF("Mapping VGAMem\n");
- hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev,
- hwp->MapPhys, hwp->MapSize);
- return hwp->Base != NULL;
-}
-
-
-void
-vgaHWUnmapMem(ScrnInfoPtr scrp)
-{
- vgaHWPtr hwp = VGAHWPTR(scrp);
- int scr_index = scrp->scrnIndex;
-
- if (hwp->Base == NULL)
- return;
-
- DebugF("Unmapping VGAMem\n");
- xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize);
- hwp->Base = NULL;
-}
-
-int
-vgaHWGetIndex(void)
-{
- return vgaHWPrivateIndex;
-}
-
-
-void
-vgaHWGetIOBase(vgaHWPtr hwp)
-{
- hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ?
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
- xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3,
- "vgaHWGetIOBase: hwp->IOBase is 0x%04x, hwp->PIOOffset is 0x%04lx\n",
- hwp->IOBase, hwp->PIOOffset);
-}
-
-
-void
-vgaHWLock(vgaHWPtr hwp)
-{
- /* Protect CRTC[0-7] */
- hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) | 0x80);
-}
-
-void
-vgaHWUnlock(vgaHWPtr hwp)
-{
- /* Unprotect CRTC[0-7] */
- hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80);
-}
-
-
-void
-vgaHWEnable(vgaHWPtr hwp)
-{
- hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01);
-}
-
-
-void
-vgaHWDisable(vgaHWPtr hwp)
-{
- hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01);
-}
-
-
-static void
-vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
- VisualPtr pVisual)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- int i, index;
-
- for (i = 0; i < numColors; i++) {
- index = indices[i];
- hwp->writeDacWriteAddr(hwp, index);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].red);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].green);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].blue);
- DACDelay(hwp);
- }
-
- /* This shouldn't be necessary, but we'll play safe. */
- hwp->disablePalette(hwp);
-}
-
-
-static void
-vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- if (overscan < 0 || overscan > 255)
- return;
-
- hwp->enablePalette(hwp);
- hwp->writeAttr(hwp, OVERSCAN, overscan);
-
-#ifdef DEBUGOVERSCAN
- {
- int ov = hwp->readAttr(hwp, OVERSCAN);
- int red, green, blue;
-
- hwp->writeDacReadAddr(hwp, ov);
- red = hwp->readDacData(hwp);
- green = hwp->readDacData(hwp);
- blue = hwp->readDacData(hwp);
- ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n",
- ov, red, green, blue);
- }
-#endif
-
- hwp->disablePalette(hwp);
-}
-
-
-Bool
-vgaHWHandleColormaps(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if (pScrn->depth > 1 && pScrn->depth <= 8) {
- return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
- pScrn->rgbBits, vgaHWLoadPalette,
- pScrn->depth > 4 ? vgaHWSetOverscan : NULL,
- CMAP_RELOAD_ON_MODE_SWITCH);
- }
- return TRUE;
-}
-
-/* ----------------------- DDC support ------------------------*/
-/*
- * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total
- * to read out EDID at a faster rate. Allowed maximum is 25kHz with
- * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen
- * readback, enable access to cr00-cr07.
- */
-
-/* vertical timings */
-#define DISPLAY_END 0x04
-#define BLANK_START DISPLAY_END
-#define SYNC_START BLANK_START
-#define SYNC_END 0x09
-#define BLANK_END SYNC_END
-#define V_TOTAL BLANK_END
-/* this function doesn't have to be reentrant for our purposes */
-struct _vgaDdcSave {
- unsigned char cr03;
- unsigned char cr06;
- unsigned char cr07;
- unsigned char cr09;
- unsigned char cr10;
- unsigned char cr11;
- unsigned char cr12;
- unsigned char cr15;
- unsigned char cr16;
- unsigned char msr;
-};
-
-void
-vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char tmp;
- struct _vgaDdcSave* save;
- switch (speed) {
- case DDC_FAST:
-
- if (hwp->ddc != NULL) break;
- hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1);
- save = (struct _vgaDdcSave *)hwp->ddc;
- /* Lightpen register disable - allow access to cr10 & 11; just in case */
- save->cr03 = hwp->readCrtc(hwp, 0x03);
- hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80));
- save->cr12 = hwp->readCrtc(hwp, 0x12);
- hwp->writeCrtc(hwp,0x12,DISPLAY_END);
- save->cr15 = hwp->readCrtc(hwp, 0x15);
- hwp->writeCrtc(hwp,0x15,BLANK_START);
- save->cr10 = hwp->readCrtc(hwp, 0x10);
- hwp->writeCrtc(hwp,0x10,SYNC_START);
- save->cr11 = hwp->readCrtc(hwp, 0x11);
- /* unprotect group 1 registers; just in case ...*/
- hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END));
- save->cr16 = hwp->readCrtc(hwp, 0x16);
- hwp->writeCrtc(hwp,0x16,BLANK_END);
- save->cr06 = hwp->readCrtc(hwp, 0x06);
- hwp->writeCrtc(hwp,0x06,V_TOTAL);
- /* all values have less than 8 bit - mask out 9th and 10th bits */
- save->cr09 = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF));
- save->cr07 = hwp->readCrtc(hwp, 0x07);
- hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10));
- /* vsync polarity negativ & ensure a 25MHz clock */
- save->msr = hwp->readMiscOut(hwp);
- hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80));
- break;
- case DDC_SLOW:
- if (hwp->ddc == NULL) break;
- save = (struct _vgaDdcSave *)hwp->ddc;
- hwp->writeMiscOut(hwp,save->msr);
- hwp->writeCrtc(hwp,0x07,save->cr07);
- tmp = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF)));
- hwp->writeCrtc(hwp,0x06,save->cr06);
- hwp->writeCrtc(hwp,0x16,save->cr16);
- hwp->writeCrtc(hwp,0x11,save->cr11);
- hwp->writeCrtc(hwp,0x10,save->cr10);
- hwp->writeCrtc(hwp,0x15,save->cr15);
- hwp->writeCrtc(hwp,0x12,save->cr12);
- hwp->writeCrtc(hwp,0x03,save->cr03);
- free(save);
- hwp->ddc = NULL;
- break;
- default:
- break;
- }
-}
-
-DDC1SetSpeedProc
-vgaHWddc1SetSpeedWeak(void)
-{
- return vgaHWddc1SetSpeed;
-}
-
-SaveScreenProcPtr vgaHWSaveScreenWeak(void)
-{
- return vgaHWSaveScreen;
-}
+
+/*
+ *
+ * Copyright 1991-1999 by The XFree86 Project, Inc.
+ *
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ */
+
+#define _NEED_SYSI86
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <X11/X.h>
+#include "misc.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "vgaHW.h"
+
+#include "compiler.h"
+
+#include "xf86cmap.h"
+
+#include "Pci.h"
+
+#ifndef SAVE_FONT1
+#define SAVE_FONT1 1
+#endif
+
+/*
+ * These used to be OS-specific, which made this module have an undesirable
+ * OS dependency. Define them by default for all platforms.
+ */
+#ifndef NEED_SAVED_CMAP
+#define NEED_SAVED_CMAP
+#endif
+#ifndef SAVE_TEXT
+#define SAVE_TEXT 1
+#endif
+#ifndef SAVE_FONT2
+#define SAVE_FONT2 1
+#endif
+
+/* bytes per plane to save for text */
+#define TEXT_AMOUNT 16384
+
+/* bytes per plane to save for font data */
+#define FONT_AMOUNT (8*8192)
+
+#if 0
+/* Override all of these for now */
+#undef SAVE_FONT1
+#define SAVE_FONT1 1
+#undef SAVE_FONT2
+#define SAVE_FONT2 1
+#undef SAVE_TEST
+#define SAVE_TEST 1
+#undef FONT_AMOUNT
+#define FONT_AMOUNT 65536
+#undef TEXT_AMOUNT
+#define TEXT_AMOUNT 65536
+#endif
+
+/* DAC indices for white and black */
+#define WHITE_VALUE 0x3F
+#define BLACK_VALUE 0x00
+#define OVERSCAN_VALUE 0x01
+
+
+/* Use a private definition of this here */
+#undef VGAHWPTR
+#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr
+#define VGAHWPTR(p) ((vgaHWPtr)(VGAHWPTRLVAL(p)))
+
+static int vgaHWPrivateIndex = -1;
+
+#define DAC_TEST_MASK 0x3F
+
+#ifdef NEED_SAVED_CMAP
+/* This default colourmap is used only when it can't be read from the VGA */
+
+static CARD8 defaultDAC[768] =
+{
+ 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
+ 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
+ 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
+ 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
+ 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11,
+ 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24,
+ 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40,
+ 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63,
+ 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63,
+ 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16,
+ 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0,
+ 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0,
+ 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47,
+ 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63,
+ 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63,
+ 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39,
+ 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31,
+ 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31,
+ 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55,
+ 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63,
+ 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63,
+ 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49,
+ 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45,
+ 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45,
+ 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58,
+ 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63,
+ 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28,
+ 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7,
+ 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0,
+ 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0,
+ 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21,
+ 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28,
+ 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28,
+ 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17,
+ 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14,
+ 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14,
+ 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24,
+ 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28,
+ 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28,
+ 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22,
+ 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20,
+ 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20,
+ 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26,
+ 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28,
+ 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16,
+ 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4,
+ 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0,
+ 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0,
+ 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12,
+ 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16,
+ 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16,
+ 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10,
+ 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8,
+ 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8,
+ 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14,
+ 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16,
+ 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16,
+ 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12,
+ 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11,
+ 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11,
+ 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15,
+ 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+#endif /* NEED_SAVED_CMAP */
+
+/*
+ * Standard VGA versions of the register access functions.
+ */
+static void
+stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+ pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET, value);
+}
+
+static CARD8
+stdReadCrtc(vgaHWPtr hwp, CARD8 index)
+{
+ pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+ return pci_io_read8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET);
+}
+
+static void
+stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index);
+ pci_io_write8(hwp->io, VGA_GRAPH_DATA, value);
+}
+
+static CARD8
+stdReadGr(vgaHWPtr hwp, CARD8 index)
+{
+ pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index);
+ return pci_io_read8(hwp->io, VGA_GRAPH_DATA);
+}
+
+static void
+stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_SEQ_INDEX, index);
+ pci_io_write8(hwp->io, VGA_SEQ_DATA, value);
+}
+
+static CARD8
+stdReadSeq(vgaHWPtr hwp, CARD8 index)
+{
+ pci_io_write8(hwp->io, VGA_SEQ_INDEX, index);
+ return pci_io_read8(hwp->io, VGA_SEQ_DATA);
+}
+
+static CARD8
+stdReadST00(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_IN_STAT_0);
+}
+
+static CARD8
+stdReadST01(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+}
+
+static CARD8
+stdReadFCR(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_FEATURE_R);
+}
+
+static void
+stdWriteFCR(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
+}
+
+static void
+stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ if (hwp->paletteEnabled)
+ index &= ~0x20;
+ else
+ index |= 0x20;
+
+ (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
+ pci_io_write8(hwp->io, VGA_ATTR_DATA_W, value);
+}
+
+static CARD8
+stdReadAttr(vgaHWPtr hwp, CARD8 index)
+{
+ if (hwp->paletteEnabled)
+ index &= ~0x20;
+ else
+ index |= 0x20;
+
+ (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
+ return pci_io_read8(hwp->io, VGA_ATTR_DATA_R);
+}
+
+static void
+stdWriteMiscOut(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_MISC_OUT_W, value);
+}
+
+static CARD8
+stdReadMiscOut(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_MISC_OUT_R);
+}
+
+static void
+stdEnablePalette(vgaHWPtr hwp)
+{
+ (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x00);
+ hwp->paletteEnabled = TRUE;
+}
+
+static void
+stdDisablePalette(vgaHWPtr hwp)
+{
+ (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x20);
+ hwp->paletteEnabled = FALSE;
+}
+
+static void
+stdWriteDacMask(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_DAC_MASK, value);
+}
+
+static CARD8
+stdReadDacMask(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_DAC_MASK);
+}
+
+static void
+stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_DAC_READ_ADDR, value);
+}
+
+static void
+stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_DAC_WRITE_ADDR, value);
+}
+
+static void
+stdWriteDacData(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_DAC_DATA, value);
+}
+
+static CARD8
+stdReadDacData(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_DAC_DATA);
+}
+
+static CARD8
+stdReadEnable(vgaHWPtr hwp)
+{
+ return pci_io_read8(hwp->io, VGA_ENABLE);
+}
+
+static void
+stdWriteEnable(vgaHWPtr hwp, CARD8 value)
+{
+ pci_io_write8(hwp->io, VGA_ENABLE, value);
+}
+
+void
+vgaHWSetStdFuncs(vgaHWPtr hwp)
+{
+ hwp->writeCrtc = stdWriteCrtc;
+ hwp->readCrtc = stdReadCrtc;
+ hwp->writeGr = stdWriteGr;
+ hwp->readGr = stdReadGr;
+ hwp->readST00 = stdReadST00;
+ hwp->readST01 = stdReadST01;
+ hwp->readFCR = stdReadFCR;
+ hwp->writeFCR = stdWriteFCR;
+ hwp->writeAttr = stdWriteAttr;
+ hwp->readAttr = stdReadAttr;
+ hwp->writeSeq = stdWriteSeq;
+ hwp->readSeq = stdReadSeq;
+ hwp->writeMiscOut = stdWriteMiscOut;
+ hwp->readMiscOut = stdReadMiscOut;
+ hwp->enablePalette = stdEnablePalette;
+ hwp->disablePalette = stdDisablePalette;
+ hwp->writeDacMask = stdWriteDacMask;
+ hwp->readDacMask = stdReadDacMask;
+ hwp->writeDacWriteAddr = stdWriteDacWriteAddr;
+ hwp->writeDacReadAddr = stdWriteDacReadAddr;
+ hwp->writeDacData = stdWriteDacData;
+ hwp->readDacData = stdReadDacData;
+ hwp->readEnable = stdReadEnable;
+ hwp->writeEnable = stdWriteEnable;
+
+ hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 * 1024);
+}
+
+/*
+ * MMIO versions of the register access functions. These require
+ * hwp->MemBase to be set in such a way that when the standard VGA port
+ * adderss is added the correct memory address results.
+ */
+
+#define minb(p) MMIO_IN8(hwp->MMIOBase, (hwp->MMIOOffset + (p)))
+#define moutb(p,v) MMIO_OUT8(hwp->MMIOBase, (hwp->MMIOOffset + (p)),(v))
+
+static void
+mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+ moutb(hwp->IOBase + VGA_CRTC_DATA_OFFSET, value);
+}
+
+static CARD8
+mmioReadCrtc(vgaHWPtr hwp, CARD8 index)
+{
+ moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+ return minb(hwp->IOBase + VGA_CRTC_DATA_OFFSET);
+}
+
+static void
+mmioWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ moutb(VGA_GRAPH_INDEX, index);
+ moutb(VGA_GRAPH_DATA, value);
+}
+
+static CARD8
+mmioReadGr(vgaHWPtr hwp, CARD8 index)
+{
+ moutb(VGA_GRAPH_INDEX, index);
+ return minb(VGA_GRAPH_DATA);
+}
+
+static void
+mmioWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ moutb(VGA_SEQ_INDEX, index);
+ moutb(VGA_SEQ_DATA, value);
+}
+
+static CARD8
+mmioReadSeq(vgaHWPtr hwp, CARD8 index)
+{
+ moutb(VGA_SEQ_INDEX, index);
+ return minb(VGA_SEQ_DATA);
+}
+
+static CARD8
+mmioReadST00(vgaHWPtr hwp)
+{
+ return minb(VGA_IN_STAT_0);
+}
+
+static CARD8
+mmioReadST01(vgaHWPtr hwp)
+{
+ return minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+}
+
+static CARD8
+mmioReadFCR(vgaHWPtr hwp)
+{
+ return minb(VGA_FEATURE_R);
+}
+
+static void
+mmioWriteFCR(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
+}
+
+static void
+mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
+{
+ if (hwp->paletteEnabled)
+ index &= ~0x20;
+ else
+ index |= 0x20;
+
+ (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ moutb(VGA_ATTR_INDEX, index);
+ moutb(VGA_ATTR_DATA_W, value);
+}
+
+static CARD8
+mmioReadAttr(vgaHWPtr hwp, CARD8 index)
+{
+ if (hwp->paletteEnabled)
+ index &= ~0x20;
+ else
+ index |= 0x20;
+
+ (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ moutb(VGA_ATTR_INDEX, index);
+ return minb(VGA_ATTR_DATA_R);
+}
+
+static void
+mmioWriteMiscOut(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_MISC_OUT_W, value);
+}
+
+static CARD8
+mmioReadMiscOut(vgaHWPtr hwp)
+{
+ return minb(VGA_MISC_OUT_R);
+}
+
+static void
+mmioEnablePalette(vgaHWPtr hwp)
+{
+ (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ moutb(VGA_ATTR_INDEX, 0x00);
+ hwp->paletteEnabled = TRUE;
+}
+
+static void
+mmioDisablePalette(vgaHWPtr hwp)
+{
+ (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+ moutb(VGA_ATTR_INDEX, 0x20);
+ hwp->paletteEnabled = FALSE;
+}
+
+static void
+mmioWriteDacMask(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_DAC_MASK, value);
+}
+
+static CARD8
+mmioReadDacMask(vgaHWPtr hwp)
+{
+ return minb(VGA_DAC_MASK);
+}
+
+static void
+mmioWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_DAC_READ_ADDR, value);
+}
+
+static void
+mmioWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_DAC_WRITE_ADDR, value);
+}
+
+static void
+mmioWriteDacData(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_DAC_DATA, value);
+}
+
+static CARD8
+mmioReadDacData(vgaHWPtr hwp)
+{
+ return minb(VGA_DAC_DATA);
+}
+
+static CARD8
+mmioReadEnable(vgaHWPtr hwp)
+{
+ return minb(VGA_ENABLE);
+}
+
+static void
+mmioWriteEnable(vgaHWPtr hwp, CARD8 value)
+{
+ moutb(VGA_ENABLE, value);
+}
+
+void
+vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)
+{
+ hwp->writeCrtc = mmioWriteCrtc;
+ hwp->readCrtc = mmioReadCrtc;
+ hwp->writeGr = mmioWriteGr;
+ hwp->readGr = mmioReadGr;
+ hwp->readST00 = mmioReadST00;
+ hwp->readST01 = mmioReadST01;
+ hwp->readFCR = mmioReadFCR;
+ hwp->writeFCR = mmioWriteFCR;
+ hwp->writeAttr = mmioWriteAttr;
+ hwp->readAttr = mmioReadAttr;
+ hwp->writeSeq = mmioWriteSeq;
+ hwp->readSeq = mmioReadSeq;
+ hwp->writeMiscOut = mmioWriteMiscOut;
+ hwp->readMiscOut = mmioReadMiscOut;
+ hwp->enablePalette = mmioEnablePalette;
+ hwp->disablePalette = mmioDisablePalette;
+ hwp->writeDacMask = mmioWriteDacMask;
+ hwp->readDacMask = mmioReadDacMask;
+ hwp->writeDacWriteAddr = mmioWriteDacWriteAddr;
+ hwp->writeDacReadAddr = mmioWriteDacReadAddr;
+ hwp->writeDacData = mmioWriteDacData;
+ hwp->readDacData = mmioReadDacData;
+ hwp->MMIOBase = base;
+ hwp->MMIOOffset = offset;
+ hwp->readEnable = mmioReadEnable;
+ hwp->writeEnable = mmioWriteEnable;
+}
+
+/*
+ * vgaHWProtect --
+ * Protect VGA registers and memory from corruption during loads.
+ */
+
+void
+vgaHWProtect(ScrnInfoPtr pScrn, Bool on)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+ unsigned char tmp;
+
+ if (pScrn->vtSema) {
+ if (on) {
+ /*
+ * Turn off screen and disable sequencer.
+ */
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
+ hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
+
+ hwp->enablePalette(hwp);
+ } else {
+ /*
+ * Reenable sequencer, then turn on screen.
+ */
+
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
+ vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
+
+ hwp->disablePalette(hwp);
+ }
+ }
+}
+
+vgaHWProtectProc *vgaHWProtectWeak(void) {
+ return vgaHWProtect;
+}
+
+/*
+ * vgaHWBlankScreen -- blank the screen.
+ */
+
+void
+vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ unsigned char scrn;
+
+ scrn = hwp->readSeq(hwp, 0x01);
+
+ if (on) {
+ scrn &= ~0x20; /* enable screen */
+ } else {
+ scrn |= 0x20; /* blank screen */
+ }
+
+ vgaHWSeqReset(hwp, TRUE);
+ hwp->writeSeq(hwp, 0x01, scrn); /* change mode */
+ vgaHWSeqReset(hwp, FALSE);
+}
+
+vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) {
+ return vgaHWBlankScreen;
+}
+
+/*
+ * vgaHWSaveScreen -- blank the screen.
+ */
+
+Bool
+vgaHWSaveScreen(ScreenPtr pScreen, int mode)
+{
+ ScrnInfoPtr pScrn = NULL;
+ Bool on;
+
+ if (pScreen != NULL)
+ pScrn = xf86Screens[pScreen->myNum];
+
+ on = xf86IsUnblank(mode);
+
+#if 0
+ if (on)
+ SetTimeSinceLastInputEvent();
+#endif
+
+ if ((pScrn != NULL) && pScrn->vtSema) {
+ vgaHWBlankScreen(pScrn, on);
+ }
+ return TRUE;
+}
+
+
+/*
+ * vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode
+ *
+ * This generic VGA function can only set the Off and On modes. If the
+ * Standby and Suspend modes are to be supported, a chip specific replacement
+ * for this function must be written.
+ */
+
+void
+vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
+{
+ unsigned char seq1 = 0, crtc17 = 0;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+ if (!pScrn->vtSema) return;
+
+ switch (PowerManagementMode) {
+ case DPMSModeOn:
+ /* Screen: On; HSync: On, VSync: On */
+ seq1 = 0x00;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeStandby:
+ /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
+ seq1 = 0x20;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeSuspend:
+ /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
+ seq1 = 0x20;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeOff:
+ /* Screen: Off; HSync: Off, VSync: Off */
+ seq1 = 0x20;
+ crtc17 = 0x00;
+ break;
+ }
+ hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
+ seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20;
+ hwp->writeSeq(hwp, 0x01, seq1);
+ crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80;
+ usleep(10000);
+ hwp->writeCrtc(hwp, 0x17, crtc17);
+ hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
+}
+
+
+/*
+ * vgaHWSeqReset
+ * perform a sequencer reset.
+ */
+
+void
+vgaHWSeqReset(vgaHWPtr hwp, Bool start)
+{
+ if (start)
+ hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
+ else
+ hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
+}
+
+
+void
+vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
+{
+#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int savedIOBase;
+ unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4;
+ Bool doMap = FALSE;
+
+ /* If nothing to do, return now */
+ if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
+ return;
+
+ if (hwp->Base == NULL) {
+ doMap = TRUE;
+ if (!vgaHWMapMem(scrninfp)) {
+ xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
+ "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
+ return;
+ }
+ }
+
+ /* save the registers that are needed here */
+ miscOut = hwp->readMiscOut(hwp);
+ attr10 = hwp->readAttr(hwp, 0x10);
+ gr1 = hwp->readGr(hwp, 0x01);
+ gr3 = hwp->readGr(hwp, 0x03);
+ gr4 = hwp->readGr(hwp, 0x04);
+ gr5 = hwp->readGr(hwp, 0x05);
+ gr6 = hwp->readGr(hwp, 0x06);
+ gr8 = hwp->readGr(hwp, 0x08);
+ seq2 = hwp->readSeq(hwp, 0x02);
+ seq4 = hwp->readSeq(hwp, 0x04);
+
+ /* save hwp->IOBase and temporarily set it for colour mode */
+ savedIOBase = hwp->IOBase;
+ hwp->IOBase = VGA_IOBASE_COLOR;
+
+ /* Force into colour mode */
+ hwp->writeMiscOut(hwp, miscOut | 0x01);
+
+ vgaHWBlankScreen(scrninfp, FALSE);
+
+ /*
+ * here we temporarily switch to 16 colour planar mode, to simply
+ * copy the font-info and saved text.
+ *
+ * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
+ */
+#if 0
+ hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
+#endif
+
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
+
+ if (scrninfp->depth == 4) {
+ /* GJA */
+ hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */
+ hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */
+ hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
+ }
+
+#if SAVE_FONT1
+ if (hwp->FontInfo1) {
+ hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
+ hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
+ slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
+ }
+#endif
+
+#if SAVE_FONT2
+ if (hwp->FontInfo2) {
+ hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
+ hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
+ slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
+ }
+#endif
+
+#if SAVE_TEXT
+ if (hwp->TextInfo) {
+ hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
+ hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
+ slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
+ hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
+ slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
+ hwp->Base, TEXT_AMOUNT);
+ }
+#endif
+
+ vgaHWBlankScreen(scrninfp, TRUE);
+
+ /* restore the registers that were changed */
+ hwp->writeMiscOut(hwp, miscOut);
+ hwp->writeAttr(hwp, 0x10, attr10);
+ hwp->writeGr(hwp, 0x01, gr1);
+ hwp->writeGr(hwp, 0x03, gr3);
+ hwp->writeGr(hwp, 0x04, gr4);
+ hwp->writeGr(hwp, 0x05, gr5);
+ hwp->writeGr(hwp, 0x06, gr6);
+ hwp->writeGr(hwp, 0x08, gr8);
+ hwp->writeSeq(hwp, 0x02, seq2);
+ hwp->writeSeq(hwp, 0x04, seq4);
+ hwp->IOBase = savedIOBase;
+
+ if (doMap)
+ vgaHWUnmapMem(scrninfp);
+
+#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
+}
+
+
+void
+vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int i;
+
+ if (restore->MiscOutReg & 0x01)
+ hwp->IOBase = VGA_IOBASE_COLOR;
+ else
+ hwp->IOBase = VGA_IOBASE_MONO;
+
+ hwp->writeMiscOut(hwp, restore->MiscOutReg);
+
+ for (i = 1; i < restore->numSequencer; i++)
+ hwp->writeSeq(hwp, i, restore->Sequencer[i]);
+
+ /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
+ hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
+
+ for (i = 0; i < restore->numCRTC; i++)
+ hwp->writeCrtc(hwp, i, restore->CRTC[i]);
+
+ for (i = 0; i < restore->numGraphics; i++)
+ hwp->writeGr(hwp, i, restore->Graphics[i]);
+
+ hwp->enablePalette(hwp);
+ for (i = 0; i < restore->numAttribute; i++)
+ hwp->writeAttr(hwp, i, restore->Attribute[i]);
+ hwp->disablePalette(hwp);
+}
+
+
+void
+vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int i;
+
+#if 0
+ hwp->enablePalette(hwp);
+#endif
+
+ hwp->writeDacMask(hwp, 0xFF);
+ hwp->writeDacWriteAddr(hwp, 0x00);
+ for (i = 0; i < 768; i++) {
+ hwp->writeDacData(hwp, restore->DAC[i]);
+ DACDelay(hwp);
+ }
+
+ hwp->disablePalette(hwp);
+}
+
+
+/*
+ * vgaHWRestore --
+ * restore the VGA state
+ */
+
+void
+vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags)
+{
+ if (flags & VGA_SR_MODE)
+ vgaHWRestoreMode(scrninfp, restore);
+
+ if (flags & VGA_SR_FONTS)
+ vgaHWRestoreFonts(scrninfp, restore);
+
+ if (flags & VGA_SR_CMAP)
+ vgaHWRestoreColormap(scrninfp, restore);
+}
+
+void
+vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
+{
+#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int savedIOBase;
+ unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4;
+ Bool doMap = FALSE;
+
+ if (hwp->Base == NULL) {
+ doMap = TRUE;
+ if (!vgaHWMapMem(scrninfp)) {
+ xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
+ "vgaHWSaveFonts: vgaHWMapMem() failed\n");
+ return;
+ }
+ }
+
+ /* If in graphics mode, don't save anything */
+ attr10 = hwp->readAttr(hwp, 0x10);
+ if (attr10 & 0x01)
+ return;
+
+ /* save the registers that are needed here */
+ miscOut = hwp->readMiscOut(hwp);
+ gr4 = hwp->readGr(hwp, 0x04);
+ gr5 = hwp->readGr(hwp, 0x05);
+ gr6 = hwp->readGr(hwp, 0x06);
+ seq2 = hwp->readSeq(hwp, 0x02);
+ seq4 = hwp->readSeq(hwp, 0x04);
+
+ /* save hwp->IOBase and temporarily set it for colour mode */
+ savedIOBase = hwp->IOBase;
+ hwp->IOBase = VGA_IOBASE_COLOR;
+
+ /* Force into colour mode */
+ hwp->writeMiscOut(hwp, miscOut | 0x01);
+
+ vgaHWBlankScreen(scrninfp, FALSE);
+
+ /*
+ * get the character sets, and text screen if required
+ */
+ /*
+ * Here we temporarily switch to 16 colour planar mode, to simply
+ * copy the font-info
+ *
+ * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
+ */
+#if 0
+ hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
+#endif
+
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
+
+#if SAVE_FONT1
+ if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) {
+ hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
+ hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
+ slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
+ }
+#endif /* SAVE_FONT1 */
+#if SAVE_FONT2
+ if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) {
+ hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
+ hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
+ slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
+ }
+#endif /* SAVE_FONT2 */
+#if SAVE_TEXT
+ if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) {
+ hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
+ hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
+ slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
+ hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
+ slowbcopy_frombus(hwp->Base,
+ (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
+ }
+#endif /* SAVE_TEXT */
+
+ /* Restore clobbered registers */
+ hwp->writeAttr(hwp, 0x10, attr10);
+ hwp->writeSeq(hwp, 0x02, seq2);
+ hwp->writeSeq(hwp, 0x04, seq4);
+ hwp->writeGr(hwp, 0x04, gr4);
+ hwp->writeGr(hwp, 0x05, gr5);
+ hwp->writeGr(hwp, 0x06, gr6);
+ hwp->writeMiscOut(hwp, miscOut);
+ hwp->IOBase = savedIOBase;
+
+ vgaHWBlankScreen(scrninfp, TRUE);
+
+ if (doMap)
+ vgaHWUnmapMem(scrninfp);
+
+#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
+}
+
+void
+vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int i;
+
+ save->MiscOutReg = hwp->readMiscOut(hwp);
+ if (save->MiscOutReg & 0x01)
+ hwp->IOBase = VGA_IOBASE_COLOR;
+ else
+ hwp->IOBase = VGA_IOBASE_MONO;
+
+ for (i = 0; i < save->numCRTC; i++) {
+ save->CRTC[i] = hwp->readCrtc(hwp, i);
+ DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
+ }
+
+ hwp->enablePalette(hwp);
+ for (i = 0; i < save->numAttribute; i++) {
+ save->Attribute[i] = hwp->readAttr(hwp, i);
+ DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
+ }
+ hwp->disablePalette(hwp);
+
+ for (i = 0; i < save->numGraphics; i++) {
+ save->Graphics[i] = hwp->readGr(hwp, i);
+ DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
+ }
+
+ for (i = 1; i < save->numSequencer; i++) {
+ save->Sequencer[i] = hwp->readSeq(hwp, i);
+ DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
+ }
+}
+
+
+void
+vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ Bool readError = FALSE;
+ int i;
+
+#ifdef NEED_SAVED_CMAP
+ /*
+ * Some ET4000 chips from 1991 have a HW bug that prevents the reading
+ * of the color lookup table. Mask rev 9042EAI is known to have this bug.
+ *
+ * If the colourmap is not readable, we set the saved map to a default
+ * map (taken from Ferraro's "Programmer's Guide to the EGA and VGA
+ * Cards" 2nd ed).
+ */
+
+ /* Only save it once */
+ if (hwp->cmapSaved)
+ return;
+
+#if 0
+ hwp->enablePalette(hwp);
+#endif
+
+ hwp->writeDacMask(hwp, 0xFF);
+
+ /*
+ * check if we can read the lookup table
+ */
+ hwp->writeDacReadAddr(hwp, 0x00);
+ for (i = 0; i < 6; i++) {
+ save->DAC[i] = hwp->readDacData(hwp);
+ switch (i % 3) {
+ case 0:
+ DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
+ break;
+ case 1:
+ DebugF("0x%02x, ", save->DAC[i]);
+ break;
+ case 2:
+ DebugF("0x%02x\n", save->DAC[i]);
+ }
+ }
+
+ /*
+ * Check if we can read the palette -
+ * use foreground color to prevent flashing.
+ */
+ hwp->writeDacWriteAddr(hwp, 0x01);
+ for (i = 3; i < 6; i++)
+ hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK);
+ hwp->writeDacReadAddr(hwp, 0x01);
+ for (i = 3; i < 6; i++) {
+ if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK))
+ readError = TRUE;
+ }
+ hwp->writeDacWriteAddr(hwp, 0x01);
+ for (i = 3; i < 6; i++)
+ hwp->writeDacData(hwp, save->DAC[i]);
+
+ if (readError) {
+ /*
+ * save the default lookup table
+ */
+ memmove(save->DAC, defaultDAC, 768);
+ xf86DrvMsg(scrninfp->scrnIndex, X_WARNING,
+ "Cannot read colourmap from VGA. Will restore with default\n");
+ } else {
+ /* save the colourmap */
+ hwp->writeDacReadAddr(hwp, 0x02);
+ for (i = 6; i < 768; i++) {
+ save->DAC[i] = hwp->readDacData(hwp);
+ DACDelay(hwp);
+ switch (i % 3) {
+ case 0:
+ DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
+ break;
+ case 1:
+ DebugF("0x%02x, ", save->DAC[i]);
+ break;
+ case 2:
+ DebugF("0x%02x\n", save->DAC[i]);
+ }
+ }
+ }
+
+ hwp->disablePalette(hwp);
+ hwp->cmapSaved = TRUE;
+#endif
+}
+
+/*
+ * vgaHWSave --
+ * save the current VGA state
+ */
+
+void
+vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags)
+{
+ if (save == NULL)
+ return;
+
+ if (flags & VGA_SR_CMAP)
+ vgaHWSaveColormap(scrninfp, save);
+
+ if (flags & VGA_SR_MODE)
+ vgaHWSaveMode(scrninfp, save);
+
+ if (flags & VGA_SR_FONTS)
+ vgaHWSaveFonts(scrninfp, save);
+}
+
+
+/*
+ * vgaHWInit --
+ * Handle the initialization, etc. of a screen.
+ * Return FALSE on failure.
+ */
+
+Bool
+vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
+{
+ unsigned int i;
+ vgaHWPtr hwp;
+ vgaRegPtr regp;
+ int depth = scrninfp->depth;
+
+ /*
+ * make sure the vgaHWRec is allocated
+ */
+ if (!vgaHWGetHWRec(scrninfp))
+ return FALSE;
+ hwp = VGAHWPTR(scrninfp);
+ regp = &hwp->ModeReg;
+
+ /*
+ * compute correct Hsync & Vsync polarity
+ */
+ if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
+ && (mode->Flags & (V_PVSYNC | V_NVSYNC)))
+ {
+ regp->MiscOutReg = 0x23;
+ if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40;
+ if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80;
+ }
+ else
+ {
+ int VDisplay = mode->VDisplay;
+ if (mode->Flags & V_DBLSCAN)
+ VDisplay *= 2;
+ if (mode->VScan > 1)
+ VDisplay *= mode->VScan;
+ if (VDisplay < 400)
+ regp->MiscOutReg = 0xA3; /* +hsync -vsync */
+ else if (VDisplay < 480)
+ regp->MiscOutReg = 0x63; /* -hsync +vsync */
+ else if (VDisplay < 768)
+ regp->MiscOutReg = 0xE3; /* -hsync -vsync */
+ else
+ regp->MiscOutReg = 0x23; /* +hsync +vsync */
+ }
+
+ regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2;
+
+ /*
+ * Time Sequencer
+ */
+ if (depth == 4)
+ regp->Sequencer[0] = 0x02;
+ else
+ regp->Sequencer[0] = 0x00;
+ if (mode->Flags & V_CLKDIV2)
+ regp->Sequencer[1] = 0x09;
+ else
+ regp->Sequencer[1] = 0x01;
+ if (depth == 1)
+ regp->Sequencer[2] = 1 << BIT_PLANE;
+ else
+ regp->Sequencer[2] = 0x0F;
+ regp->Sequencer[3] = 0x00; /* Font select */
+ if (depth < 8)
+ regp->Sequencer[4] = 0x06; /* Misc */
+ else
+ regp->Sequencer[4] = 0x0E; /* Misc */
+
+ /*
+ * CRTC Controller
+ */
+ regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5;
+ regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1;
+ regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1;
+ regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
+ i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F);
+ if (i < 0x80)
+ regp->CRTC[3] |= i;
+ regp->CRTC[4] = (mode->CrtcHSyncStart >> 3);
+ regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2)
+ | (((mode->CrtcHSyncEnd >> 3)) & 0x1F);
+ regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF;
+ regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8)
+ | (((mode->CrtcVDisplay - 1) & 0x100) >> 7)
+ | ((mode->CrtcVSyncStart & 0x100) >> 6)
+ | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5)
+ | 0x10
+ | (((mode->CrtcVTotal - 2) & 0x200) >> 4)
+ | (((mode->CrtcVDisplay - 1) & 0x200) >> 3)
+ | ((mode->CrtcVSyncStart & 0x200) >> 2);
+ regp->CRTC[8] = 0x00;
+ regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40;
+ if (mode->Flags & V_DBLSCAN)
+ regp->CRTC[9] |= 0x80;
+ if (mode->VScan >= 32)
+ regp->CRTC[9] |= 0x1F;
+ else if (mode->VScan > 1)
+ regp->CRTC[9] |= mode->VScan - 1;
+ regp->CRTC[10] = 0x00;
+ regp->CRTC[11] = 0x00;
+ regp->CRTC[12] = 0x00;
+ regp->CRTC[13] = 0x00;
+ regp->CRTC[14] = 0x00;
+ regp->CRTC[15] = 0x00;
+ regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF;
+ regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20;
+ regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF;
+ regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */
+ regp->CRTC[20] = 0x00;
+ regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF;
+ regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
+ if (depth < 8)
+ regp->CRTC[23] = 0xE3;
+ else
+ regp->CRTC[23] = 0xC3;
+ regp->CRTC[24] = 0xFF;
+
+ vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
+ vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
+
+ /*
+ * Theory resumes here....
+ */
+
+ /*
+ * Graphics Display Controller
+ */
+ regp->Graphics[0] = 0x00;
+ regp->Graphics[1] = 0x00;
+ regp->Graphics[2] = 0x00;
+ regp->Graphics[3] = 0x00;
+ if (depth == 1) {
+ regp->Graphics[4] = BIT_PLANE;
+ regp->Graphics[5] = 0x00;
+ } else {
+ regp->Graphics[4] = 0x00;
+ if (depth == 4)
+ regp->Graphics[5] = 0x02;
+ else
+ regp->Graphics[5] = 0x40;
+ }
+ regp->Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */
+ regp->Graphics[7] = 0x0F;
+ regp->Graphics[8] = 0xFF;
+
+ if (depth == 1) {
+ /* Initialise the Mono map according to which bit-plane gets used */
+
+ Bool flipPixels = xf86GetFlipPixels();
+
+ for (i=0; i<16; i++)
+ if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
+ regp->Attribute[i] = WHITE_VALUE;
+ else
+ regp->Attribute[i] = BLACK_VALUE;
+
+ regp->Attribute[16] = 0x01; /* -VGA2- */ /* wrong for the ET4000 */
+ if (!hwp->ShowOverscan)
+ regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
+ } else {
+ regp->Attribute[0] = 0x00; /* standard colormap translation */
+ regp->Attribute[1] = 0x01;
+ regp->Attribute[2] = 0x02;
+ regp->Attribute[3] = 0x03;
+ regp->Attribute[4] = 0x04;
+ regp->Attribute[5] = 0x05;
+ regp->Attribute[6] = 0x06;
+ regp->Attribute[7] = 0x07;
+ regp->Attribute[8] = 0x08;
+ regp->Attribute[9] = 0x09;
+ regp->Attribute[10] = 0x0A;
+ regp->Attribute[11] = 0x0B;
+ regp->Attribute[12] = 0x0C;
+ regp->Attribute[13] = 0x0D;
+ regp->Attribute[14] = 0x0E;
+ regp->Attribute[15] = 0x0F;
+ if (depth == 4)
+ regp->Attribute[16] = 0x81; /* wrong for the ET4000 */
+ else
+ regp->Attribute[16] = 0x41; /* wrong for the ET4000 */
+ /* Attribute[17] (overscan) initialised in vgaHWGetHWRec() */
+ }
+ regp->Attribute[18] = 0x0F;
+ regp->Attribute[19] = 0x00;
+ regp->Attribute[20] = 0x00;
+
+ return TRUE;
+}
+
+ /*
+ * OK, so much for theory. Now, let's deal with the >real< world...
+ *
+ * The above CRTC settings are precise in theory, except that many, if not
+ * most, VGA clones fail to reset the blanking signal when the character or
+ * line counter reaches [HV]Total. In this case, the signal is only
+ * unblanked when the counter reaches [HV]BlankEnd (mod 64, 128 or 256 as
+ * the case may be) at the start of the >next< scanline or frame, which
+ * means only part of the screen shows. This affects how null overscans
+ * are to be implemented on such adapters.
+ *
+ * Henceforth, VGA cores that implement this broken, but unfortunately
+ * common, behaviour are to be designated as KGA's, in honour of Koen
+ * Gadeyne, whose zeal to eliminate overscans (read: fury) set in motion
+ * a series of events that led to the discovery of this problem.
+ *
+ * Some VGA's are KGA's only in the horizontal, or only in the vertical,
+ * some in both, others in neither. Don't let anyone tell you there is
+ * such a thing as a VGA "standard"... And, thank the Creator for the fact
+ * that Hilbert spaces are not yet implemented in this industry.
+ *
+ * The following implements a trick suggested by David Dawes. This sets
+ * [HV]BlankEnd to zero if the blanking interval does not already contain a
+ * 0-point, and decrements it by one otherwise. In the latter case, this
+ * will produce a left and/or top overscan which the colourmap code will
+ * (still) need to ensure is as close to black as possible. This will make
+ * the behaviour consistent across all chipsets, while allowing all
+ * chipsets to display the entire screen. Non-KGA drivers can ignore the
+ * following in their own copy of this code.
+ *
+ * -- TSI @ UQV, 1998.08.21
+ */
+
+CARD32
+vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags)
+{
+ int nExtBits = (nBits < 6) ? 0 : nBits - 6;
+ CARD32 ExtBits;
+ CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6;
+
+ regp->CRTC[3] = (regp->CRTC[3] & ~0x1F)
+ | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F);
+ regp->CRTC[5] = (regp->CRTC[5] & ~0x80)
+ | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2);
+ ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask;
+
+ /* First the horizontal case */
+ if ((Flags & KGA_FIX_OVERSCAN)
+ && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3)))
+ {
+ int i = (regp->CRTC[3] & 0x1F)
+ | ((regp->CRTC[5] & 0x80) >> 2)
+ | ExtBits;
+ if (Flags & KGA_ENABLE_ON_ZERO) {
+ if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1)
+ & (0x3F | ExtBitMask)))
+ && (mode->CrtcHBlankEnd == mode->CrtcHTotal))
+ i = 0;
+ } else if (Flags & KGA_BE_TOT_DEC)
+ i--;
+ regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F);
+ regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80);
+ ExtBits = i & ExtBitMask;
+ }
+ return ExtBits >> 6;
+}
+
+ /*
+ * The vertical case is a little trickier. Some VGA's ignore bit 0x80 of
+ * CRTC[22]. Also, in some cases, a zero CRTC[22] will still blank the
+ * very first scanline in a double- or multi-scanned mode. This last case
+ * needs further investigation.
+ */
+CARD32
+vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags)
+{
+ CARD32 ExtBits;
+ CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8);
+ CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8;
+ /* If width is not known nBits should be 0. In this
+ * case BitMask is set to 0 so we can check for it. */
+ CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1);
+ int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
+ regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
+ ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask;
+
+ if ((Flags & KGA_FIX_OVERSCAN)
+ && (mode->CrtcVBlankEnd == mode->CrtcVTotal))
+ /* Null top overscan */
+ {
+ int i = regp->CRTC[22] | ExtBits;
+ if (Flags & KGA_ENABLE_ON_ZERO) {
+ if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask)))
+ || ((i > VBlankStart) && /* 8-bit case */
+ ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */
+ !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */
+ i = 0;
+ else
+ i = (i - 1);
+ } else if (Flags & KGA_BE_TOT_DEC)
+ i = (i - 1);
+
+ regp->CRTC[22] = i & 0xFF;
+ ExtBits = i & 0xFF00;
+ }
+ return ExtBits >> 8;
+}
+
+/*
+ * these are some more hardware specific helpers, formerly in vga.c
+ */
+static void
+vgaHWGetHWRecPrivate(void)
+{
+ if (vgaHWPrivateIndex < 0)
+ vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+ return;
+}
+
+
+static void
+vgaHWFreeRegs(vgaRegPtr regp)
+{
+ free(regp->CRTC);
+
+ regp->CRTC =
+ regp->Sequencer =
+ regp->Graphics =
+ regp->Attribute = NULL;
+
+ regp->numCRTC =
+ regp->numSequencer =
+ regp->numGraphics =
+ regp->numAttribute = 0;
+}
+
+
+
+static Bool
+vgaHWAllocRegs(vgaRegPtr regp)
+{
+ unsigned char *buf;
+
+ if ((regp->numCRTC + regp->numSequencer + regp->numGraphics +
+ regp->numAttribute) == 0)
+ return FALSE;
+
+ buf = calloc(regp->numCRTC +
+ regp->numSequencer +
+ regp->numGraphics +
+ regp->numAttribute, 1);
+ if (!buf)
+ return FALSE;
+
+ regp->CRTC = buf;
+ regp->Sequencer = regp->CRTC + regp->numCRTC;
+ regp->Graphics = regp->Sequencer + regp->numSequencer;
+ regp->Attribute = regp->Graphics + regp->numGraphics;
+
+ return TRUE;
+}
+
+
+Bool
+vgaHWAllocDefaultRegs(vgaRegPtr regp)
+{
+ regp->numCRTC = VGA_NUM_CRTC;
+ regp->numSequencer = VGA_NUM_SEQ;
+ regp->numGraphics = VGA_NUM_GFX;
+ regp->numAttribute = VGA_NUM_ATTR;
+
+ return vgaHWAllocRegs(regp);
+}
+
+
+Bool
+vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
+ int numGraphics, int numAttribute)
+{
+#define VGAHWMINNUM(regtype) \
+ ((newMode.num##regtype < regp->num##regtype) ? \
+ (newMode.num##regtype) : (regp->num##regtype))
+#define VGAHWCOPYREGSET(regtype) \
+ memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype))
+
+ vgaRegRec newMode, newSaved;
+ vgaRegPtr regp;
+
+ regp = &VGAHWPTR(scrp)->ModeReg;
+ memcpy (&newMode, regp, sizeof(vgaRegRec));
+
+ /* allocate space for new registers */
+
+ regp = &newMode;
+ regp->numCRTC = numCRTC;
+ regp->numSequencer = numSequencer;
+ regp->numGraphics = numGraphics;
+ regp->numAttribute = numAttribute;
+ if (!vgaHWAllocRegs(regp))
+ return FALSE;
+
+ regp = &VGAHWPTR(scrp)->SavedReg;
+ memcpy (&newSaved, regp, sizeof(vgaRegRec));
+
+ regp = &newSaved;
+ regp->numCRTC = numCRTC;
+ regp->numSequencer = numSequencer;
+ regp->numGraphics = numGraphics;
+ regp->numAttribute = numAttribute;
+ if (!vgaHWAllocRegs(regp)) {
+ vgaHWFreeRegs(&newMode);
+ return FALSE;
+ }
+
+ /* allocations succeeded, copy register data into new space */
+
+ regp = &VGAHWPTR(scrp)->ModeReg;
+ VGAHWCOPYREGSET(CRTC);
+ VGAHWCOPYREGSET(Sequencer);
+ VGAHWCOPYREGSET(Graphics);
+ VGAHWCOPYREGSET(Attribute);
+
+ regp = &VGAHWPTR(scrp)->SavedReg;
+ VGAHWCOPYREGSET(CRTC);
+ VGAHWCOPYREGSET(Sequencer);
+ VGAHWCOPYREGSET(Graphics);
+ VGAHWCOPYREGSET(Attribute);
+
+ /* free old register arrays */
+
+ regp = &VGAHWPTR(scrp)->ModeReg;
+ vgaHWFreeRegs(regp);
+ memcpy(regp, &newMode, sizeof(vgaRegRec));
+
+ regp = &VGAHWPTR(scrp)->SavedReg;
+ vgaHWFreeRegs(regp);
+ memcpy(regp, &newSaved, sizeof(vgaRegRec));
+
+ return TRUE;
+
+#undef VGAHWMINNUM
+#undef VGAHWCOPYREGSET
+}
+
+
+Bool
+vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
+{
+ vgaHWFreeRegs(dst);
+
+ memcpy(dst, src, sizeof(vgaRegRec));
+
+ if (!vgaHWAllocRegs(dst))
+ return FALSE;
+
+ memcpy(dst->CRTC, src->CRTC, src->numCRTC);
+ memcpy(dst->Sequencer, src->Sequencer, src->numSequencer);
+ memcpy(dst->Graphics, src->Graphics, src->numGraphics);
+ memcpy(dst->Attribute, src->Attribute, src->numAttribute);
+
+ return TRUE;
+}
+
+
+Bool
+vgaHWGetHWRec(ScrnInfoPtr scrp)
+{
+ vgaRegPtr regp;
+ vgaHWPtr hwp;
+ int i;
+
+ /*
+ * Let's make sure that the private exists and allocate one.
+ */
+ vgaHWGetHWRecPrivate();
+ /*
+ * New privates are always set to NULL, so we can check if the allocation
+ * has already been done.
+ */
+ if (VGAHWPTR(scrp))
+ return TRUE;
+ hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1);
+ regp = &VGAHWPTR(scrp)->ModeReg;
+
+ if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) ||
+ (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) {
+ free(hwp);
+ return FALSE;
+ }
+
+ if (scrp->bitsPerPixel == 1) {
+ rgb blackColour = scrp->display->blackColour,
+ whiteColour = scrp->display->whiteColour;
+
+ if (blackColour.red > 0x3F) blackColour.red = 0x3F;
+ if (blackColour.green > 0x3F) blackColour.green = 0x3F;
+ if (blackColour.blue > 0x3F) blackColour.blue = 0x3F;
+
+ if (whiteColour.red > 0x3F) whiteColour.red = 0x3F;
+ if (whiteColour.green > 0x3F) whiteColour.green = 0x3F;
+ if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F;
+
+ if ((blackColour.red == whiteColour.red ) &&
+ (blackColour.green == whiteColour.green) &&
+ (blackColour.blue == whiteColour.blue )) {
+ blackColour.red ^= 0x3F;
+ blackColour.green ^= 0x3F;
+ blackColour.blue ^= 0x3F;
+ }
+
+ /*
+ * initialize default colormap for monochrome
+ */
+ for (i=0; i<3; i++) regp->DAC[i] = 0x00;
+ for (i=3; i<768; i++) regp->DAC[i] = 0x3F;
+ i = BLACK_VALUE * 3;
+ regp->DAC[i++] = blackColour.red;
+ regp->DAC[i++] = blackColour.green;
+ regp->DAC[i] = blackColour.blue;
+ i = WHITE_VALUE * 3;
+ regp->DAC[i++] = whiteColour.red;
+ regp->DAC[i++] = whiteColour.green;
+ regp->DAC[i] = whiteColour.blue;
+ i = OVERSCAN_VALUE * 3;
+ regp->DAC[i++] = 0x00;
+ regp->DAC[i++] = 0x00;
+ regp->DAC[i] = 0x00;
+ } else {
+ /* Set all colours to black */
+ for (i=0; i<768; i++) regp->DAC[i] = 0x00;
+ /* ... and the overscan */
+ if (scrp->depth >= 4)
+ regp->Attribute[OVERSCAN] = 0xFF;
+ }
+ if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) {
+ xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan");
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n");
+ regp->DAC[765] = 0x3F;
+ regp->DAC[766] = 0x00;
+ regp->DAC[767] = 0x3F;
+ regp->Attribute[OVERSCAN] = 0xFF;
+ hwp->ShowOverscan = TRUE;
+ } else
+ hwp->ShowOverscan = FALSE;
+
+ hwp->paletteEnabled = FALSE;
+ hwp->cmapSaved = FALSE;
+ hwp->MapSize = 0;
+ hwp->pScrn = scrp;
+
+ hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]);
+
+ return TRUE;
+}
+
+
+void
+vgaHWFreeHWRec(ScrnInfoPtr scrp)
+{
+ if (vgaHWPrivateIndex >= 0) {
+ vgaHWPtr hwp = VGAHWPTR(scrp);
+
+ if (!hwp)
+ return;
+
+ pci_device_close_io(hwp->dev, hwp->io);
+
+ free(hwp->FontInfo1);
+ free(hwp->FontInfo2);
+ free(hwp->TextInfo);
+
+ vgaHWFreeRegs (&hwp->ModeReg);
+ vgaHWFreeRegs (&hwp->SavedReg);
+
+ free(hwp);
+ VGAHWPTRLVAL(scrp) = NULL;
+ }
+}
+
+
+Bool
+vgaHWMapMem(ScrnInfoPtr scrp)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrp);
+
+ if (hwp->Base)
+ return TRUE;
+
+ /* If not set, initialise with the defaults */
+ if (hwp->MapSize == 0)
+ hwp->MapSize = VGA_DEFAULT_MEM_SIZE;
+ if (hwp->MapPhys == 0)
+ hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR;
+
+ /*
+ * Map as VIDMEM_MMIO_32BIT because WC
+ * is bad when there is page flipping.
+ * XXX This is not correct but we do it
+ * for now.
+ */
+ DebugF("Mapping VGAMem\n");
+ pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base);
+ return hwp->Base != NULL;
+}
+
+
+void
+vgaHWUnmapMem(ScrnInfoPtr scrp)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrp);
+
+ if (hwp->Base == NULL)
+ return;
+
+ DebugF("Unmapping VGAMem\n");
+ pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize);
+ hwp->Base = NULL;
+}
+
+int
+vgaHWGetIndex(void)
+{
+ return vgaHWPrivateIndex;
+}
+
+
+void
+vgaHWGetIOBase(vgaHWPtr hwp)
+{
+ hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ?
+ VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
+ xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3,
+ "vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase);
+}
+
+
+void
+vgaHWLock(vgaHWPtr hwp)
+{
+ /* Protect CRTC[0-7] */
+ hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) | 0x80);
+}
+
+void
+vgaHWUnlock(vgaHWPtr hwp)
+{
+ /* Unprotect CRTC[0-7] */
+ hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80);
+}
+
+
+void
+vgaHWEnable(vgaHWPtr hwp)
+{
+ hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01);
+}
+
+
+void
+vgaHWDisable(vgaHWPtr hwp)
+{
+ hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01);
+}
+
+
+static void
+vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
+ VisualPtr pVisual)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ int i, index;
+
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ hwp->writeDacWriteAddr(hwp, index);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].red);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].green);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].blue);
+ DACDelay(hwp);
+ }
+
+ /* This shouldn't be necessary, but we'll play safe. */
+ hwp->disablePalette(hwp);
+}
+
+
+static void
+vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+ if (overscan < 0 || overscan > 255)
+ return;
+
+ hwp->enablePalette(hwp);
+ hwp->writeAttr(hwp, OVERSCAN, overscan);
+
+#ifdef DEBUGOVERSCAN
+ {
+ int ov = hwp->readAttr(hwp, OVERSCAN);
+ int red, green, blue;
+
+ hwp->writeDacReadAddr(hwp, ov);
+ red = hwp->readDacData(hwp);
+ green = hwp->readDacData(hwp);
+ blue = hwp->readDacData(hwp);
+ ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n",
+ ov, red, green, blue);
+ }
+#endif
+
+ hwp->disablePalette(hwp);
+}
+
+
+Bool
+vgaHWHandleColormaps(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if (pScrn->depth > 1 && pScrn->depth <= 8) {
+ return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
+ pScrn->rgbBits, vgaHWLoadPalette,
+ pScrn->depth > 4 ? vgaHWSetOverscan : NULL,
+ CMAP_RELOAD_ON_MODE_SWITCH);
+ }
+ return TRUE;
+}
+
+/* ----------------------- DDC support ------------------------*/
+/*
+ * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total
+ * to read out EDID at a faster rate. Allowed maximum is 25kHz with
+ * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen
+ * readback, enable access to cr00-cr07.
+ */
+
+/* vertical timings */
+#define DISPLAY_END 0x04
+#define BLANK_START DISPLAY_END
+#define SYNC_START BLANK_START
+#define SYNC_END 0x09
+#define BLANK_END SYNC_END
+#define V_TOTAL BLANK_END
+/* this function doesn't have to be reentrant for our purposes */
+struct _vgaDdcSave {
+ unsigned char cr03;
+ unsigned char cr06;
+ unsigned char cr07;
+ unsigned char cr09;
+ unsigned char cr10;
+ unsigned char cr11;
+ unsigned char cr12;
+ unsigned char cr15;
+ unsigned char cr16;
+ unsigned char msr;
+};
+
+void
+vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ unsigned char tmp;
+ struct _vgaDdcSave* save;
+ switch (speed) {
+ case DDC_FAST:
+
+ if (hwp->ddc != NULL) break;
+ hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1);
+ save = (struct _vgaDdcSave *)hwp->ddc;
+ /* Lightpen register disable - allow access to cr10 & 11; just in case */
+ save->cr03 = hwp->readCrtc(hwp, 0x03);
+ hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80));
+ save->cr12 = hwp->readCrtc(hwp, 0x12);
+ hwp->writeCrtc(hwp,0x12,DISPLAY_END);
+ save->cr15 = hwp->readCrtc(hwp, 0x15);
+ hwp->writeCrtc(hwp,0x15,BLANK_START);
+ save->cr10 = hwp->readCrtc(hwp, 0x10);
+ hwp->writeCrtc(hwp,0x10,SYNC_START);
+ save->cr11 = hwp->readCrtc(hwp, 0x11);
+ /* unprotect group 1 registers; just in case ...*/
+ hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END));
+ save->cr16 = hwp->readCrtc(hwp, 0x16);
+ hwp->writeCrtc(hwp,0x16,BLANK_END);
+ save->cr06 = hwp->readCrtc(hwp, 0x06);
+ hwp->writeCrtc(hwp,0x06,V_TOTAL);
+ /* all values have less than 8 bit - mask out 9th and 10th bits */
+ save->cr09 = hwp->readCrtc(hwp, 0x09);
+ hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF));
+ save->cr07 = hwp->readCrtc(hwp, 0x07);
+ hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10));
+ /* vsync polarity negativ & ensure a 25MHz clock */
+ save->msr = hwp->readMiscOut(hwp);
+ hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80));
+ break;
+ case DDC_SLOW:
+ if (hwp->ddc == NULL) break;
+ save = (struct _vgaDdcSave *)hwp->ddc;
+ hwp->writeMiscOut(hwp,save->msr);
+ hwp->writeCrtc(hwp,0x07,save->cr07);
+ tmp = hwp->readCrtc(hwp, 0x09);
+ hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF)));
+ hwp->writeCrtc(hwp,0x06,save->cr06);
+ hwp->writeCrtc(hwp,0x16,save->cr16);
+ hwp->writeCrtc(hwp,0x11,save->cr11);
+ hwp->writeCrtc(hwp,0x10,save->cr10);
+ hwp->writeCrtc(hwp,0x15,save->cr15);
+ hwp->writeCrtc(hwp,0x12,save->cr12);
+ hwp->writeCrtc(hwp,0x03,save->cr03);
+ free(save);
+ hwp->ddc = NULL;
+ break;
+ default:
+ break;
+ }
+}
+
+DDC1SetSpeedProc
+vgaHWddc1SetSpeedWeak(void)
+{
+ return vgaHWddc1SetSpeed;
+}
+
+SaveScreenProcPtr vgaHWSaveScreenWeak(void)
+{
+ return vgaHWSaveScreen;
+}
+
+/*
+ * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
+ */
+void
+xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg,
+ int maskval, int knownclkindex, int knownclkvalue)
+{
+ register int status = vertsyncreg;
+ unsigned long i, cnt, rcnt, sync;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+ /* First save registers that get written on */
+ (*ClockFunc)(pScrn, CLK_REG_SAVE);
+
+ if (num > MAXCLOCKS)
+ num = MAXCLOCKS;
+
+ for (i = 0; i < num; i++)
+ {
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, TRUE);
+ if (!(*ClockFunc)(pScrn, i))
+ {
+ pScrn->clock[i] = -1;
+ continue;
+ }
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, FALSE);
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, FALSE);
+
+ usleep(50000); /* let VCO stabilise */
+
+ cnt = 0;
+ sync = 200000;
+
+ while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((pci_io_read8(hwp->io, status) & maskval) == maskval)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+
+ for (rcnt = 0; rcnt < 5; rcnt++)
+ {
+ while (!(pci_io_read8(hwp->io, status) & maskval))
+ cnt++;
+ while ((pci_io_read8(hwp->io, status) & maskval))
+ cnt++;
+ }
+
+finish:
+ pScrn->clock[i] = cnt ? cnt : -1;
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, TRUE);
+ }
+
+ for (i = 0; i < num; i++)
+ {
+ if (i != knownclkindex)
+ {
+ if (pScrn->clock[i] == -1)
+ {
+ pScrn->clock[i] = 0;
+ }
+ else
+ {
+ pScrn->clock[i] = (int)(0.5 +
+ (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
+ (pScrn->clock[i]));
+ /* Round to nearest 10KHz */
+ pScrn->clock[i] += 5;
+ pScrn->clock[i] /= 10;
+ pScrn->clock[i] *= 10;
+ }
+ }
+ }
+
+ pScrn->clock[knownclkindex] = knownclkvalue;
+ pScrn->numClocks = num;
+
+ /* Restore registers that were written on */
+ (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+}
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.h b/xorg-server/hw/xfree86/vgahw/vgaHW.h
index d7ac3cc62..e943aa391 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.h
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.h
@@ -1,235 +1,233 @@
-
-
-/*
- * Copyright (c) 1997,1998 The XFree86 Project, Inc.
- *
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Author: Dirk Hohndel
- */
-
-#ifndef _VGAHW_H
-#define _VGAHW_H
-
-#include <X11/X.h>
-#include "misc.h"
-#include "input.h"
-#include "scrnintstr.h"
-#include "colormapst.h"
-
-#include "xf86str.h"
-#include "xf86Pci.h"
-
-#include "xf86DDC.h"
-
-#include "globals.h"
-#include <X11/extensions/dpmsconst.h>
-
-extern _X_EXPORT int vgaHWGetIndex(void);
-
-/*
- * access macro
- */
-#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr))
-
-/* Standard VGA registers */
-#define VGA_ATTR_INDEX 0x3C0
-#define VGA_ATTR_DATA_W 0x3C0
-#define VGA_ATTR_DATA_R 0x3C1
-#define VGA_IN_STAT_0 0x3C2 /* read */
-#define VGA_MISC_OUT_W 0x3C2 /* write */
-#define VGA_ENABLE 0x3C3
-#define VGA_SEQ_INDEX 0x3C4
-#define VGA_SEQ_DATA 0x3C5
-#define VGA_DAC_MASK 0x3C6
-#define VGA_DAC_READ_ADDR 0x3C7
-#define VGA_DAC_WRITE_ADDR 0x3C8
-#define VGA_DAC_DATA 0x3C9
-#define VGA_FEATURE_R 0x3CA /* read */
-#define VGA_MISC_OUT_R 0x3CC /* read */
-#define VGA_GRAPH_INDEX 0x3CE
-#define VGA_GRAPH_DATA 0x3CF
-
-#define VGA_IOBASE_MONO 0x3B0
-#define VGA_IOBASE_COLOR 0x3D0
-
-#define VGA_CRTC_INDEX_OFFSET 0x04
-#define VGA_CRTC_DATA_OFFSET 0x05
-#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
-#define VGA_FEATURE_W_OFFSET 0x0A /* write */
-
-/* default number of VGA registers stored internally */
-#define VGA_NUM_CRTC 25
-#define VGA_NUM_SEQ 5
-#define VGA_NUM_GFX 9
-#define VGA_NUM_ATTR 21
-
-/* Flags for vgaHWSave() and vgaHWRestore() */
-#define VGA_SR_MODE 0x01
-#define VGA_SR_FONTS 0x02
-#define VGA_SR_CMAP 0x04
-#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP)
-
-/* Defaults for the VGA memory window */
-#define VGA_DEFAULT_PHYS_ADDR 0xA0000
-#define VGA_DEFAULT_MEM_SIZE (64 * 1024)
-
-/*
- * vgaRegRec contains settings of standard VGA registers.
- */
-typedef struct {
- unsigned char MiscOutReg; /* */
- unsigned char *CRTC; /* Crtc Controller */
- unsigned char *Sequencer; /* Video Sequencer */
- unsigned char *Graphics; /* Video Graphics */
- unsigned char *Attribute; /* Video Atribute */
- unsigned char DAC[768]; /* Internal Colorlookuptable */
- unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
- unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
- unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
- unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
-} vgaRegRec, *vgaRegPtr;
-
-typedef struct _vgaHWRec *vgaHWPtr;
-
-typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value);
-typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx);
-typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value);
-typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp);
-typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
-
-
-/*
- * vgaHWRec contains per-screen information required by the vgahw module.
- *
- * Note, the palette referred to by the paletteEnabled, enablePalette and
- * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed
- * via the first 17 attribute registers and not the main 8-bit palette.
- */
-typedef struct _vgaHWRec {
- pointer Base; /* Address of "VGA" memory */
- int MapSize; /* Size of "VGA" memory */
- unsigned long MapPhys; /* phys location of VGA mem */
- int IOBase; /* I/O Base address */
- CARD8 * MMIOBase; /* Pointer to MMIO start */
- int MMIOOffset; /* base + offset + vgareg
- = mmioreg */
- pointer FontInfo1; /* save area for fonts in
- plane 2 */
- pointer FontInfo2; /* save area for fonts in
- plane 3 */
- pointer TextInfo; /* save area for text */
- vgaRegRec SavedReg; /* saved registers */
- vgaRegRec ModeReg; /* register settings for
- current mode */
- Bool ShowOverscan;
- Bool paletteEnabled;
- Bool cmapSaved;
- ScrnInfoPtr pScrn;
- vgaHWWriteIndexProcPtr writeCrtc;
- vgaHWReadIndexProcPtr readCrtc;
- vgaHWWriteIndexProcPtr writeGr;
- vgaHWReadIndexProcPtr readGr;
- vgaHWReadProcPtr readST00;
- vgaHWReadProcPtr readST01;
- vgaHWReadProcPtr readFCR;
- vgaHWWriteProcPtr writeFCR;
- vgaHWWriteIndexProcPtr writeAttr;
- vgaHWReadIndexProcPtr readAttr;
- vgaHWWriteIndexProcPtr writeSeq;
- vgaHWReadIndexProcPtr readSeq;
- vgaHWWriteProcPtr writeMiscOut;
- vgaHWReadProcPtr readMiscOut;
- vgaHWMiscProcPtr enablePalette;
- vgaHWMiscProcPtr disablePalette;
- vgaHWWriteProcPtr writeDacMask;
- vgaHWReadProcPtr readDacMask;
- vgaHWWriteProcPtr writeDacWriteAddr;
- vgaHWWriteProcPtr writeDacReadAddr;
- vgaHWWriteProcPtr writeDacData;
- vgaHWReadProcPtr readDacData;
- pointer ddc;
- IOADDRESS PIOOffset; /* offset + vgareg
- = pioreg */
- vgaHWReadProcPtr readEnable;
- vgaHWWriteProcPtr writeEnable;
- struct pci_device *dev;
-} vgaHWRec;
-
-/* Some macros that VGA drivers can use in their ChipProbe() function */
-#define VGAHW_GET_IOBASE() ((inb(VGA_MISC_OUT_R) & 0x01) ? \
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO)
-
-#define OVERSCAN 0x11 /* Index of OverScan register */
-
-/* Flags that define how overscan correction should take place */
-#define KGA_FIX_OVERSCAN 1 /* overcan correction required */
-#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
- /* of next scanline/frame */
-#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
- /* to total - 1 */
-#define BIT_PLANE 3 /* Which plane we write to in mono mode */
-#define BITS_PER_GUN 6
-#define COLORMAP_SIZE 256
-
-#if defined(__powerpc__) || defined(__arm__) || defined(__s390__) || defined(__nds32__)
-#define DACDelay(hw) /* No legacy VGA support */
-#else
-#define DACDelay(hw) \
- do { \
- (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
- (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
- } while (0)
-#endif
-
-/* Function Prototypes */
-
-/* vgaHW.c */
-
-typedef void vgaHWProtectProc(ScrnInfoPtr, Bool);
-typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool);
-
-extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
-extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
-extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void);
-extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
-extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
-extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void);
-extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
-extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags);
-extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags);
-extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode);
-extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute);
-extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
-extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp);
-extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
-extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
-extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
-extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
-extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
-extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
-
-extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
-extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
-
-#endif /* _VGAHW_H */
+
+
+/*
+ * Copyright (c) 1997,1998 The XFree86 Project, Inc.
+ *
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Author: Dirk Hohndel
+ */
+
+#ifndef _VGAHW_H
+#define _VGAHW_H
+
+#include <X11/X.h>
+#include "misc.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "colormapst.h"
+
+#include "xf86str.h"
+#include "xf86Pci.h"
+
+#include "xf86DDC.h"
+
+#include "globals.h"
+#include <X11/extensions/dpmsconst.h>
+
+extern _X_EXPORT int vgaHWGetIndex(void);
+
+/*
+ * access macro
+ */
+#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr))
+
+/* Standard VGA registers */
+#define VGA_ATTR_INDEX 0x3C0
+#define VGA_ATTR_DATA_W 0x3C0
+#define VGA_ATTR_DATA_R 0x3C1
+#define VGA_IN_STAT_0 0x3C2 /* read */
+#define VGA_MISC_OUT_W 0x3C2 /* write */
+#define VGA_ENABLE 0x3C3
+#define VGA_SEQ_INDEX 0x3C4
+#define VGA_SEQ_DATA 0x3C5
+#define VGA_DAC_MASK 0x3C6
+#define VGA_DAC_READ_ADDR 0x3C7
+#define VGA_DAC_WRITE_ADDR 0x3C8
+#define VGA_DAC_DATA 0x3C9
+#define VGA_FEATURE_R 0x3CA /* read */
+#define VGA_MISC_OUT_R 0x3CC /* read */
+#define VGA_GRAPH_INDEX 0x3CE
+#define VGA_GRAPH_DATA 0x3CF
+
+#define VGA_IOBASE_MONO 0x3B0
+#define VGA_IOBASE_COLOR 0x3D0
+
+#define VGA_CRTC_INDEX_OFFSET 0x04
+#define VGA_CRTC_DATA_OFFSET 0x05
+#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
+#define VGA_FEATURE_W_OFFSET 0x0A /* write */
+
+/* default number of VGA registers stored internally */
+#define VGA_NUM_CRTC 25
+#define VGA_NUM_SEQ 5
+#define VGA_NUM_GFX 9
+#define VGA_NUM_ATTR 21
+
+/* Flags for vgaHWSave() and vgaHWRestore() */
+#define VGA_SR_MODE 0x01
+#define VGA_SR_FONTS 0x02
+#define VGA_SR_CMAP 0x04
+#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP)
+
+/* Defaults for the VGA memory window */
+#define VGA_DEFAULT_PHYS_ADDR 0xA0000
+#define VGA_DEFAULT_MEM_SIZE (64 * 1024)
+
+/*
+ * vgaRegRec contains settings of standard VGA registers.
+ */
+typedef struct {
+ unsigned char MiscOutReg; /* */
+ unsigned char *CRTC; /* Crtc Controller */
+ unsigned char *Sequencer; /* Video Sequencer */
+ unsigned char *Graphics; /* Video Graphics */
+ unsigned char *Attribute; /* Video Atribute */
+ unsigned char DAC[768]; /* Internal Colorlookuptable */
+ unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
+ unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
+ unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
+ unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
+} vgaRegRec, *vgaRegPtr;
+
+typedef struct _vgaHWRec *vgaHWPtr;
+
+typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value);
+typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx);
+typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value);
+typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp);
+typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
+
+
+/*
+ * vgaHWRec contains per-screen information required by the vgahw module.
+ *
+ * Note, the palette referred to by the paletteEnabled, enablePalette and
+ * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed
+ * via the first 17 attribute registers and not the main 8-bit palette.
+ */
+typedef struct _vgaHWRec {
+ pointer Base; /* Address of "VGA" memory */
+ int MapSize; /* Size of "VGA" memory */
+ unsigned long MapPhys; /* phys location of VGA mem */
+ int IOBase; /* I/O Base address */
+ CARD8 * MMIOBase; /* Pointer to MMIO start */
+ int MMIOOffset; /* base + offset + vgareg
+ = mmioreg */
+ pointer FontInfo1; /* save area for fonts in
+ plane 2 */
+ pointer FontInfo2; /* save area for fonts in
+ plane 3 */
+ pointer TextInfo; /* save area for text */
+ vgaRegRec SavedReg; /* saved registers */
+ vgaRegRec ModeReg; /* register settings for
+ current mode */
+ Bool ShowOverscan;
+ Bool paletteEnabled;
+ Bool cmapSaved;
+ ScrnInfoPtr pScrn;
+ vgaHWWriteIndexProcPtr writeCrtc;
+ vgaHWReadIndexProcPtr readCrtc;
+ vgaHWWriteIndexProcPtr writeGr;
+ vgaHWReadIndexProcPtr readGr;
+ vgaHWReadProcPtr readST00;
+ vgaHWReadProcPtr readST01;
+ vgaHWReadProcPtr readFCR;
+ vgaHWWriteProcPtr writeFCR;
+ vgaHWWriteIndexProcPtr writeAttr;
+ vgaHWReadIndexProcPtr readAttr;
+ vgaHWWriteIndexProcPtr writeSeq;
+ vgaHWReadIndexProcPtr readSeq;
+ vgaHWWriteProcPtr writeMiscOut;
+ vgaHWReadProcPtr readMiscOut;
+ vgaHWMiscProcPtr enablePalette;
+ vgaHWMiscProcPtr disablePalette;
+ vgaHWWriteProcPtr writeDacMask;
+ vgaHWReadProcPtr readDacMask;
+ vgaHWWriteProcPtr writeDacWriteAddr;
+ vgaHWWriteProcPtr writeDacReadAddr;
+ vgaHWWriteProcPtr writeDacData;
+ vgaHWReadProcPtr readDacData;
+ pointer ddc;
+ struct pci_io_handle *io;
+ vgaHWReadProcPtr readEnable;
+ vgaHWWriteProcPtr writeEnable;
+ struct pci_device *dev;
+} vgaHWRec;
+
+/* Some macros that VGA drivers can use in their ChipProbe() function */
+#define OVERSCAN 0x11 /* Index of OverScan register */
+
+/* Flags that define how overscan correction should take place */
+#define KGA_FIX_OVERSCAN 1 /* overcan correction required */
+#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
+ /* of next scanline/frame */
+#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
+ /* to total - 1 */
+#define BIT_PLANE 3 /* Which plane we write to in mono mode */
+#define BITS_PER_GUN 6
+#define COLORMAP_SIZE 256
+
+#define DACDelay(hw) \
+ do { \
+ pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+ pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+ } while (0)
+
+/* Function Prototypes */
+
+/* vgaHW.c */
+
+typedef void vgaHWProtectProc(ScrnInfoPtr, Bool);
+typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool);
+
+extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
+extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
+extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void);
+extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
+extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
+extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void);
+extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
+extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore);
+extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore);
+extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore);
+extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags);
+extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save);
+extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save);
+extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save);
+extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags);
+extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode);
+extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
+ int numGraphics, int numAttribute);
+extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
+extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp);
+extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp);
+extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp);
+extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp);
+extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
+extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
+extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
+extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags);
+extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags);
+extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
+
+extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
+extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
+extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+ Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool),
+ unsigned long vertsyncreg, int maskval,
+ int knownclkindex, int knownclkvalue);
+
+#endif /* _VGAHW_H */
diff --git a/xorg-server/hw/xfree86/xaa/Makefile.am b/xorg-server/hw/xfree86/xaa/Makefile.am
index fcbc53a73..7ebe0b91e 100644
--- a/xorg-server/hw/xfree86/xaa/Makefile.am
+++ b/xorg-server/hw/xfree86/xaa/Makefile.am
@@ -1,74 +1,74 @@
-LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c
-LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c
-MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c
-MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c
-LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c
-LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c
-MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c
-MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c
-POLYSEG = s-xaaLine.c s-xaaDashLine.c
-
-libxaa_la_LDFLAGS = -avoid-version
-if COMPOSITE
-libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la
-endif
-
-module_LTLIBRARIES = libxaa.la
-libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \
- xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \
- xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \
- xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c \
- xaaRect.c xaaLineMisc.c xaaBitOrder.c \
- xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \
- xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \
- xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \
- $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \
- $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED)
-${POLYSEG}:
- $(AM_V_GEN)echo "#define POLYSEGMENT" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:s-%=%}"' >> $@
-${LSB_FIRST}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:l-%=%}"' >> $@
-${LSB_3_FIRST}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@
-${LSB_FIXED}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@
-${LSB_3_FIXED}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@
-${MSB_FIRST}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:m-%=%}"' >> $@
-${MSB_3_FIRST}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@
-${MSB_FIXED}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@
-${MSB_3_FIXED}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@
-
-DISTCLEANFILES = $(POLYSEG) \
- $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \
- $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED)
-
-sdk_HEADERS = xaa.h xaalocal.h xaarop.h
-EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \
- xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \
- XAA.HOWTO
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../../../miext/cw
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c
+LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c
+MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c
+MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c
+LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c
+LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c
+MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c
+MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c
+POLYSEG = s-xaaLine.c s-xaaDashLine.c
+
+libxaa_la_LDFLAGS = -module -avoid-version
+if COMPOSITE
+libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la
+endif
+
+module_LTLIBRARIES = libxaa.la
+libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \
+ xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \
+ xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \
+ xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c \
+ xaaRect.c xaaLineMisc.c xaaBitOrder.c \
+ xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \
+ xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \
+ xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \
+ $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \
+ $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED)
+${POLYSEG}:
+ $(AM_V_GEN)echo "#define POLYSEGMENT" > $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:s-%=%}"' >> $@
+${LSB_FIRST}:
+ $(AM_V_GEN)echo "#define LSBFIRST" > $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:l-%=%}"' >> $@
+${LSB_3_FIRST}:
+ $(AM_V_GEN)echo "#define LSBFIRST" > $@
+ $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@
+${LSB_FIXED}:
+ $(AM_V_GEN)echo "#define LSBFIRST" > $@
+ $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@
+${LSB_3_FIXED}:
+ $(AM_V_GEN)echo "#define LSBFIRST" > $@
+ $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+ $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@
+${MSB_FIRST}:
+ $(AM_V_GEN)echo "#define MSBFIRST" > $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:m-%=%}"' >> $@
+${MSB_3_FIRST}:
+ $(AM_V_GEN)echo "#define MSBFIRST" > $@
+ $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@
+${MSB_FIXED}:
+ $(AM_V_GEN)echo "#define MSBFIRST" > $@
+ $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@
+${MSB_3_FIXED}:
+ $(AM_V_GEN)echo "#define MSBFIRST" > $@
+ $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+ $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+ $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@
+
+DISTCLEANFILES = $(POLYSEG) \
+ $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \
+ $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED)
+
+sdk_HEADERS = xaa.h xaalocal.h xaarop.h
+EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \
+ xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \
+ XAA.HOWTO
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../../../miext/cw
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)