From df2b55a25b7056ac92c1f6cbee9f16bd0a37ba8c Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Tue, 6 Jul 2004 14:37:48 +0000 Subject: [PATCH] Separated Intel drivers from default DriDrivers to avoid building them on IA64 (Egbert Eich). Fixed wrong function prototype (Egbert Eich). Don't test for generic VGA on IA64 (Egbert Eich). Fixed a segfault when accessing a structure before verifying the pointer exists (Egbert Eich). Added a showcache option for debugging (Egbert Eich). Increase default video RAM size to 16MB when DRI is enabled and more than 128MB are available (Egbert Eich). Fixed lockups during mode switch. Problem was introduced when attempting to copy the behavior during LeaveVT()/EnterVT() but but forgetting to call I810DRILeave() before I810DRIEnter(). The entire DRILeave()/Enter() scenario has been commented out as it didn't seem to be necessary (Egbert Eich). Fix TweakMemorySize() (tested with i855/i865) (Egbert Eich). increased MAX_DEVICES to 128 (Egbert Eich). Use OS provided PCI config space access as default method (Egbert Eich). Added support for Linux 2.6 proc file format. Fixed unaligned accesses to pieces of the VBE info block. VESA did not align elements to size (Egbert Eich). --- hw/xfree86/common/xf86Bus.c | 2 +- hw/xfree86/common/xf86Globals.c | 2 +- hw/xfree86/common/xf86pciBus.c | 10 +++++--- hw/xfree86/os-support/bus/Pci.h | 26 +++++++++++++------- hw/xfree86/os-support/bus/ix86Pci.c | 36 ++++++++++++++++------------ hw/xfree86/os-support/bus/linuxPci.c | 24 +++++++++++++------ hw/xfree86/vbe/vbe.c | 17 ++++++++----- 7 files changed, 76 insertions(+), 41 deletions(-) diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 5e002c8db..2904f533f 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -2988,7 +2988,7 @@ static void CheckGenericGA() { /* This needs to be changed for multiple domains */ -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) +#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined ( __ia64__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index a2bb3f504..6f2e9135a 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -157,7 +157,7 @@ xf86InfoRec xf86Info = { FALSE, /* vidModeAllowNonLocal */ TRUE, /* miscModInDevEnabled */ FALSE, /* miscModInDevAllowNonLocal */ - PCIProbe1, /* pciFlags */ + PCIOsConfig, /* pciFlags */ Pix24DontCare, /* pixmap24 */ X_DEFAULT, /* pix24From */ #if defined(i386) || defined(__i386__) diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 790bf7409..74b2a3488 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -3230,10 +3230,14 @@ pciVideoPtr xf86GetPciInfoForEntity(int entityIndex) { pciVideoPtr *ppPci; - EntityPtr p = xf86Entities[entityIndex]; + EntityPtr p; - if (entityIndex >= xf86NumEntities - || p->busType != BUS_PCI) return NULL; + if (entityIndex >= xf86NumEntities) + return NULL; + + p = xf86Entities[entityIndex]; + if (p->busType != BUS_PCI) + return NULL; for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { if (p->pciBusId.bus == (*ppPci)->bus && diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 529613ad7..2d85eba9a 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.42 2003/08/29 21:08:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.45 2004/02/02 03:55:31 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -112,7 +112,7 @@ /* * Global Definitions */ -#define MAX_PCI_DEVICES 64 /* Max number of devices accomodated */ +#define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */ /* by xf86scanpci */ #if defined(sun) && defined(SVR4) && defined(sparc) # define MAX_PCI_BUSES 4096 /* Max number of PCI buses */ @@ -255,9 +255,13 @@ # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN +# elif defined(FreeBSD) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN # endif # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper -#elif defined(__i386__) +#elif defined(__i386__) || defined(i386) # define ARCH_PCI_INIT ix86PciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN @@ -308,21 +312,27 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif -#elif defined(__sparc__) +#elif defined(__sparc__) || defined(sparc) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM # elif defined(sun) # define ARCH_PCI_INIT sparcPciInit # define INCLUDE_XF86_MAP_PCI_MEM -# elif defined(__OpenBSD__) && defined(__sparc64__) +# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__) # define ARCH_PCI_INIT freebsdPciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif -# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge -#elif defined(__AMD64__) -# define ARCH_PCI_INIT ix86PciInit +# if !defined(__FreeBSD__) +# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge +# endif +#elif defined(__amd64__) +# if defined(__FreeBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# else +# define ARCH_PCI_INIT ix86PciInit +# endif # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # if defined(linux) diff --git a/hw/xfree86/os-support/bus/ix86Pci.c b/hw/xfree86/os-support/bus/ix86Pci.c index 4ce835acb..da1aa7d2f 100644 --- a/hw/xfree86/os-support/bus/ix86Pci.c +++ b/hw/xfree86/os-support/bus/ix86Pci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c,v 1.24 2003/08/29 20:49:03 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c,v 1.25 2003/09/24 02:43:34 dawes Exp $ */ /* * ix86Pci.c - x86 PCI driver * @@ -272,10 +272,16 @@ void ix86PciSelectCfgmech(void) */ switch (xf86Info.pciFlags) { - case PCIProbe1: /* { */ + case PCIOsConfig: +#if ARCH_PCI_OS_INIT + return; +#endif + + case PCIProbe1: - xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 1\n"); - oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); + xf86MsgVerb(X_INFO, 2, + "PCI: Probing config type using method 1\n"); + oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); #ifdef DEBUGPCI if (xf86Verbose > 2) { @@ -345,8 +351,9 @@ void ix86PciSelectCfgmech(void) xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); xf86MsgVerb(X_INFO, 3, - "PCI: stages = 0x%02x, oldVal1 = 0x%08x, mode1Res1" - " = 0x%08x\n", stages, oldVal1, mode1Res1); + "PCI: stages = 0x%02x, oldVal1 = 0x%08lx, mode1Res1" + " = 0x%08lx\n", stages, (unsigned long)oldVal1, + (unsigned long)mode1Res1); return; } @@ -399,9 +406,10 @@ void ix86PciSelectCfgmech(void) xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); xf86MsgVerb(X_INFO, 3, - "PCI: stages = 0x%02x, oldVal1 = 0x%08x,\n" - "\tmode1Res1 = 0x%08x, mode1Res2 = 0x%08x\n", - stages, oldVal1, mode1Res1, mode1Res2); + "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" + "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", + stages, (unsigned long)oldVal1, + (unsigned long)mode1Res1, (unsigned long)mode1Res2); return; } @@ -415,9 +423,10 @@ void ix86PciSelectCfgmech(void) } xf86MsgVerb(X_INFO, 3, "PCI: Standard check for type 1 failed.\n"); - xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08x,\n" - "\tmode1Res1 = 0x%08x, mode1Res2 = 0x%08x\n", - stages, oldVal1, mode1Res1, mode1Res2); + xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" + "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", + stages, (unsigned long)oldVal1, (unsigned long)mode1Res1, + (unsigned long)mode1Res2); /* Try config type 2 */ oldVal2 = inb(PCI_CFGMECH2_ENABLE_REG); @@ -489,9 +498,6 @@ void ix86PciSelectCfgmech(void) ix86Pci0.funcs = &ix86Funcs2; return; - case PCIOsConfig: - return; - case PCIForceNone: break; } diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 76194802f..6e33c2550 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c,v 1.10 2002/11/17 18:42:01 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c,v 1.9 2002/09/24 16:14:16 tsi Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -104,6 +104,7 @@ linuxPciOpenFile(PCITAG tag) static int lbus,ldev,lfunc,fd = -1; int bus, dev, func; char file[32]; + struct stat ignored; bus = PCI_BUS_FROM_TAG(tag); dev = PCI_DEV_FROM_TAG(tag); @@ -111,12 +112,21 @@ linuxPciOpenFile(PCITAG tag) if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) { if (fd != -1) close(fd); - if (bus < 256) - sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", - bus, dev, func); - else - sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", - bus, dev, func); + if (bus < 256) { + if (stat("/proc/bus/pci/00", &ignored) < 0) + sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", + bus, dev, func); + else + sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", + bus, dev, func); + } else { + if (stat("/proc/bus/pci/00", &ignored) < 0) + sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x", + bus, dev, func); + else + sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", + bus, dev, func); + } fd = open(file,O_RDWR); lbus = bus; ldev = dev; diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c index 9cc8be74d..a8203e910 100644 --- a/hw/xfree86/vbe/vbe.c +++ b/hw/xfree86/vbe/vbe.c @@ -57,8 +57,11 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) vbeControllerInfoPtr vbe = NULL; Bool init_int10 = FALSE; vbeInfoPtr vip = NULL; - int screen = pScrn->scrnIndex; + int screen; + if (!pScrn) return NULL; + screen = pScrn->scrnIndex; + if (!pInt) { if (!xf86LoadSubModule(pScrn, "int10")) goto error; @@ -336,6 +339,8 @@ vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule) return pMonitor; } +#define GET_UNALIGNED2(x) \ + ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16) VbeInfoBlock * VBEGetVBEInfo(vbeInfoPtr pVbe) @@ -381,7 +386,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4); major = (unsigned)block->VESAVersion >> 8; - pStr = *(CARD32*)(((char*)pVbe->memory) + 6); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OEMStringPtr = strdup(str); @@ -390,7 +395,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) block->Capabilities[2] = ((char*)pVbe->memory)[12]; block->Capabilities[3] = ((char*)pVbe->memory)[13]; - pModes = *(CARD32*)(((char*)pVbe->memory) + 14); + pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14)); modes = xf86int10Addr(pVbe->pInt10, FARP(pModes)); i = 0; while (modes[i] != 0xffff) @@ -405,13 +410,13 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236); else { block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20); - pStr = *(CARD32*)(((char*)pVbe->memory) + 22); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemVendorNamePtr = strdup(str); - pStr = *(CARD32*)(((char*)pVbe->memory) + 26); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemProductNamePtr = strdup(str); - pStr = *(CARD32*)(((char*)pVbe->memory) + 30); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemProductRevPtr = strdup(str); memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222);