From e18d34f4238e13e226b0407fa2f5f77d2038de39 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 21 Jul 2006 16:47:45 -0700 Subject: [PATCH] Make the various implementations of xf86ExtendedInitInt10 use the libpciaccess interfaces. This eliminates all calls to mapPciRom, which in turn allows the elimination of hw/xfree86/int10/pci.c. --- hw/xfree86/common/xf86str.h | 16 +++++-- hw/xfree86/int10/Makefile.am | 1 - hw/xfree86/int10/generic.c | 51 ++++++++++++----------- hw/xfree86/int10/pci.c | 45 -------------------- hw/xfree86/int10/xf86int10.h | 3 -- hw/xfree86/os-support/linux/int10/linux.c | 21 ++++++---- 6 files changed, 51 insertions(+), 86 deletions(-) delete mode 100644 hw/xfree86/int10/pci.c diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 60d9c66ef..d9e2557d8 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -46,11 +46,19 @@ #include -/* - * memType is of the size of the addressable memory (machine size) - * usually unsigned long. +/** + * Integer type that is of the size of the addressable memory (machine size). + * On most platforms \c uintptr_t will suffice. However, on some mixed + * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this + * must be 64-bits. */ -typedef unsigned long memType; +#include +#if defined(__powerpc__) +typedef uint64_t memType; +#else +typedef uintptr_t memType; +#endif + /* Video mode flags */ diff --git a/hw/xfree86/int10/Makefile.am b/hw/xfree86/int10/Makefile.am index c059070ec..4656d6869 100644 --- a/hw/xfree86/int10/Makefile.am +++ b/hw/xfree86/int10/Makefile.am @@ -9,7 +9,6 @@ libint10_la_LDFLAGS = -avoid-version COMMON_SOURCES = \ helper_exec.c \ helper_mem.c \ - pci.c \ xf86int10.c \ xf86int10module.c diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 281e702ab..aca0cccf4 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -57,8 +57,8 @@ int10MemRec genericMem = { static void MapVRam(xf86Int10InfoPtr pInt); static void UnmapVRam(xf86Int10InfoPtr pInt); #ifdef _PC -#define GET_HIGH_BASE(x) (((V_BIOS + size + getpagesize() - 1)/getpagesize()) \ - * getpagesize()) +#define GET_HIGH_BASE(x) (((V_BIOS + (x) + getpagesize() - 1)/getpagesize()) \ + * getpagesize()) #endif static void *sysMem = NULL; @@ -165,18 +165,22 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) switch (location_type) { case BUS_PCI: { - const int pci_entity = (bios.bus == BUS_PCI) - ? xf86GetPciEntity(bios.location.pci.bus, - bios.location.pci.dev, - bios.location.pci.func) - : pInt->entityIndex; + int err; + struct pci_device *rom_device = (bios.bus == BUS_PCI) + ? pci_device_find_by_slot(PCI_DOM_FROM_BUS(bios.location.pci.bus), + PCI_BUS_NO_DOM(bios.location.pci.bus), + bios.location.pci.dev, + bios.location.pci.func) + : xf86GetPciInfoForEntity(pInt->entityIndex); vbiosMem = (unsigned char *)base + bios_location; - if (!(size = mapPciRom(pci_entity,(unsigned char *)(vbiosMem)))) { - xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3)\n"); + err = pci_device_read_rom(rom_device, vbiosMem); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3) %s\n", + strerror(err)); goto error1; } - INTPriv(pInt)->highMemory = GET_HIGH_BASE(size); + INTPriv(pInt)->highMemory = GET_HIGH_BASE(rom_device->rom_size); break; } case BUS_ISA: @@ -262,24 +266,21 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) "No legacy BIOS found -- trying PCI\n"); } if (!done) { - int pci_entity; - - if (bios.bus == BUS_PCI) { - xf86DrvMsg(screen,X_CONFIG,"Looking for BIOS at PCI:%i%i%i\n", - bios.location.pci.bus,bios.location.pci.dev, - bios.location.pci.func); - pci_entity = xf86GetPciEntity(bios.location.pci.bus, - bios.location.pci.dev, - bios.location.pci.func); - } else - pci_entity = pInt->entityIndex; + int err; + struct pci_device *rom_device = (bios.bus == BUS_PCI) + ? pci_device_find_by_slot(PCI_DOM_FROM_BUS(bios.location.pci.bus), + PCI_BUS_NO_DOM(bios.location.pci.bus), + bios.location.pci.dev, + bios.location.pci.func) + : xf86GetPciInfoForEntity(pInt->entityIndex); - if (!mapPciRom(pci_entity, vbiosMem)) { - xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS (5)\n"); - goto error1; + err = pci_device_read_rom(rom_device, vbiosMem); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3) %s\n", + strerror(err)); + goto error1; } } - } pInt->BIOSseg = V_BIOS >> 4; diff --git a/hw/xfree86/int10/pci.c b/hw/xfree86/int10/pci.c deleted file mode 100644 index d5758e720..000000000 --- a/hw/xfree86/int10/pci.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/pci.c,v 1.11 2001/10/01 13:44:13 eich Exp $ */ - -/* - * XFree86 int10 module - * execute BIOS int 10h calls in x86 real mode environment - * Copyright 1999 Egbert Eich - */ -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include - -#include "xf86Pci.h" -#include "xf86.h" -#define _INT10_PRIVATE -#include "xf86int10.h" - -int -mapPciRom(int pciEntity, unsigned char * address) -{ - struct pci_device * pvp = xf86GetPciInfoForEntity(pciEntity); - int err; - - if (pvp == NULL) { -#ifdef DEBUG - ErrorF("mapPciRom: no PCI info\n"); -#endif - return 0; - } - - /* Read in entire PCI ROM */ - err = pci_device_read_rom( pvp, address ); - -#ifdef DEBUG - if ( err != 0 ) - ErrorF("mapPciRom: no BIOS found\n"); -#ifdef PRINT_PCI - else - dprint(address,0x20); -#endif -#endif - - return pvp->rom_size; -} diff --git a/hw/xfree86/int10/xf86int10.h b/hw/xfree86/int10/xf86int10.h index 47f965d74..a2e4c2a47 100644 --- a/hw/xfree86/int10/xf86int10.h +++ b/hw/xfree86/int10/xf86int10.h @@ -196,8 +196,5 @@ Bool xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void dprint(unsigned long start, unsigned long size); #endif -/* pci.c */ -int mapPciRom(int pciEntity, unsigned char *address); - #endif /* _INT10_PRIVATE */ #endif /* _XF86INT10_H */ diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c index 9f6d07ee6..d34bf6dce 100644 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ b/hw/xfree86/os-support/linux/int10/linux.c @@ -279,16 +279,21 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) switch (location_type) { case BUS_PCI: { - const int pci_entity = (bios.bus == BUS_PCI) - ? xf86GetPciEntity(bios.location.pci.bus, - bios.location.pci.dev, - bios.location.pci.func) - : pInt->entityIndex; - - if (!mapPciRom(pci_entity, (unsigned char *)(V_BIOS))) { - xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS\n"); + int err; + struct pci_device *rom_device = (bios.bus == BUS_PCI) + ? pci_device_find_by_slot(PCI_DOM_FROM_BUS(bios.location.pci.bus), + PCI_BUS_NO_DOM(bios.location.pci.bus), + bios.location.pci.dev, + bios.location.pci.func) + : xf86GetPciInfoForEntity(pInt->entityIndex); + + 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; }