diff options
author | Eric Anholt <eric@anholt.net> | 2007-08-28 10:08:38 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2007-08-28 10:13:27 -0700 |
commit | adf46b57ce6c69ab13a38b09a8104c802d54d052 (patch) | |
tree | e29e4e3c8f8a0bf5e8bad347c0cea31da3aefb3d /hw | |
parent | 3fe67d23edaae3ddde20cd5f349aa5dfde1d26a3 (diff) |
Replace BSD custom PCI code with a stub implementation thanks to pciaccess.
Note that pciaccess doesn't yet have Net/OpenBSD support, but the relevant
code should go there instead of disconnected code in the X Server.
While here, remove the now-disabled INCLUDE_XF86_NO_DOMAIN from the headers,
and un-disable xf8StdAccResFromOS for those OSes without domain support which
will need it.
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/os-support/bus/Makefile.am | 8 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/Pci.c | 18 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/Pci.h | 41 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/bsd_pci.c | 84 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/freebsdPci.c | 164 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/netbsdPci.c | 129 | ||||
-rw-r--r-- | hw/xfree86/os-support/shared/stdResource.c | 7 |
7 files changed, 96 insertions, 355 deletions
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index fba6e5421..381b9923c 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -7,12 +7,8 @@ if XORG_BUS_LINUXPCI PCI_SOURCES += linuxPci.c endif -if XORG_BUS_FREEBSDPCI -PCI_SOURCES += freebsdPci.c -endif - -if XORG_BUS_NETBSDPCI -PCI_SOURCES += netbsdPci.c +if XORG_BUS_BSDPCI +PCI_SOURCES += bsd_pci.c endif if XORG_BUS_IX86PCI diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index 31e9023f0..a34ed99d0 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -286,21 +286,3 @@ xf86scanpci(void) return success; } - -#ifdef INCLUDE_XF86_NO_DOMAIN - -_X_EXPORT 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; -} - -#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 632a7a048..bb93260d1 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -184,35 +184,30 @@ #define PCI_CFGMECH1_MAXDEV 32 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) +#define ARCH_PCI_INIT bsdPciInit +#endif + +#if !defined(ARCH_PCI_INIT) /* * Select architecture specific PCI init function */ #if defined(__alpha__) # if defined(linux) # define ARCH_PCI_INIT axpPciInit -# elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -# define ARCH_PCI_INIT freebsdPciInit -# define INCLUDE_XF86_NO_DOMAIN -# elif defined(__NetBSD__) -# define ARCH_PCI_INIT netbsdPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__arm__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__hppa__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__ia64__) # if defined(linux) # define ARCH_PCI_INIT ia64linuxPciInit -# elif defined(FreeBSD) -# define ARCH_PCI_INIT freebsdPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper #elif defined(__i386__) || defined(i386) @@ -221,70 +216,50 @@ # else # define ARCH_PCI_INIT ix86PciInit # endif -# define INCLUDE_XF86_NO_DOMAIN #elif defined(__mc68000__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__mips__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__powerpc__) || defined(__powerpc64__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */ -# elif defined(__FreeBSD__) || defined(__OpenBSD__) -# define ARCH_PCI_INIT freebsdPciInit -# define INCLUDE_XF86_NO_DOMAIN -# elif defined(__NetBSD__) -# define ARCH_PCI_INIT netbsdPciInit -# define INCLUDE_XF86_NO_DOMAIN # else # define ARCH_PCI_INIT ppcPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__s390__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__sh__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__sparc__) || defined(sparc) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit # elif defined(sun) # define ARCH_PCI_INIT sparcPciInit -# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__) -# define ARCH_PCI_INIT freebsdPciInit -# define INCLUDE_XF86_NO_DOMAIN # endif # if !defined(__FreeBSD__) && !defined(linux) # define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge # endif #elif defined(__amd64__) || defined(__amd64) -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# define ARCH_PCI_INIT freebsdPciInit -# elif defined(linux) +# if defined(linux) # define ARCH_PCI_INIT linuxPciInit # else # define ARCH_PCI_INIT ix86PciInit # endif -# define INCLUDE_XF86_NO_DOMAIN #endif +#endif /* !defined(ARCH_PCI_INIT) */ #ifndef ARCH_PCI_INIT #error No PCI support available for this architecture/OS combination #endif -#undef INCLUDE_XF86_NO_DOMAIN - extern void ARCH_PCI_INIT(void); #if defined(XF86SCANPCI_WRAPPER) diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c new file mode 100644 index 000000000..bceb1087f --- /dev/null +++ b/hw/xfree86/os-support/bus/bsd_pci.c @@ -0,0 +1,84 @@ +/* + * Copyright © 2007 Intel Corporation + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Eric Anholt <eric@anholt.net> + * + */ + +/** + * @file bsd_pci.c + * + * This is a trivial implementation of the remaining PCI support hooks in the + * X Server that is unaware of domains. + * + * Most of even this should go away once drivers are converted and the + * old interfaces are confirmed to all be obsolete. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" + +#include "pciaccess.h" + +static pciBusFuncs_t bsd_funcs = { + .pciAddrBusToHost = pciAddrNOOP, +}; + +static pciBusInfo_t bsd_pci = { + .configMech = PCI_CFG_MECH_OTHER, + .numDevices = 32, + .secondary = FALSE, + .primary_bus = 0, + .funcs = &bsd_funcs, + .pciBusPriv = NULL, + .bridge = NULL, +}; + +_X_EXPORT 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) +{ + pciNumBuses = 1; + pciBusInfo[0] = &bsd_pci; +} diff --git a/hw/xfree86/os-support/bus/freebsdPci.c b/hw/xfree86/os-support/bus/freebsdPci.c deleted file mode 100644 index ff11c72f4..000000000 --- a/hw/xfree86/os-support/bus/freebsdPci.c +++ /dev/null @@ -1,164 +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 "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#include <sys/pciio.h> - -/* - * freebsd platform specific PCI access functions -- using /dev/pci - * needs kernel version 2.2.x - */ -static CARD32 freebsdPciCfgRead(PCITAG tag, int off); -static void freebsdPciCfgWrite(PCITAG, int off, CARD32 val); -static void freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits); - -static pciBusFuncs_t freebsdFuncs0 = { -/* pciReadLong */ freebsdPciCfgRead, -/* pciWriteLong */ freebsdPciCfgWrite, -/* pciSetBitsLong */ freebsdPciCfgSetBits, -/* pciAddrHostToBus */ pciAddrNOOP, -/* pciAddrBusToHost */ pciAddrNOOP -}; - -static pciBusInfo_t freebsdPci0 = { -/* configMech */ PCI_CFG_MECH_OTHER, -/* numDevices */ 32, -/* secondary */ FALSE, -/* primary_bus */ 0, -/* funcs */ &freebsdFuncs0, -/* pciBusPriv */ NULL, -/* bridge */ NULL -}; - -#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) -#if X_BYTE_ORDER == X_BIG_ENDIAN -#ifdef __sparc__ -#ifndef ASI_PL -#define ASI_PL 0x88 -#endif -#define PCI_CPU(val) ({ \ -int __ret; \ -__asm__ __volatile__("lduwa [%1] %2, %0" : "=r" (__ret) : "r" (&val), "i" (ASI_PL)); \ -__ret; \ -}) -#else -#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \ - ((val >> 8) & 0x0000ff00) | \ - ((val << 8) & 0x00ff0000) | \ - ((val << 24) & 0xff000000)) -#endif -#else -#define PCI_CPU(val) (val) -#endif -#else /* ! OpenBSD */ -/* OpenBSD has already the bytes in the right order - for all architectures */ -#define PCI_CPU(val) (val) -#endif - - -#define BUS(tag) (((tag)>>16)&0xff) -#define DFN(tag) (((tag)>>8)&0xff) - -static int pciFd = -1; - -void -freebsdPciInit() -{ - pciFd = open("/dev/pci", O_RDWR); - if (pciFd < 0) - return; - - pciNumBuses = 1; - pciBusInfo[0] = &freebsdPci0; -} - -static CARD32 -freebsdPciCfgRead(PCITAG tag, int off) -{ - struct pci_io io; - int error; - io.pi_sel.pc_bus = BUS(tag); - io.pi_sel.pc_dev = DFN(tag) >> 3; - io.pi_sel.pc_func = DFN(tag) & 7; - io.pi_reg = off; - io.pi_width = 4; - error = ioctl(pciFd, PCIOCREAD, &io); - if (error) - return ~0; - return PCI_CPU(io.pi_data); -} - -static void -freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val) -{ - struct pci_io io; - io.pi_sel.pc_bus = BUS(tag); - io.pi_sel.pc_dev = DFN(tag) >> 3; - io.pi_sel.pc_func = DFN(tag) & 7; - io.pi_reg = off; - io.pi_width = 4; - io.pi_data = PCI_CPU(val); - ioctl(pciFd, PCIOCWRITE, &io); -} - -static void -freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits) -{ - CARD32 val = freebsdPciCfgRead(tag, off); - val = (val & ~mask) | (bits & mask); - freebsdPciCfgWrite(tag, off, val); -} diff --git a/hw/xfree86/os-support/bus/netbsdPci.c b/hw/xfree86/os-support/bus/netbsdPci.c deleted file mode 100644 index 760302752..000000000 --- a/hw/xfree86/os-support/bus/netbsdPci.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 1994-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. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> -#include <dev/pci/pciio.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" - -#include "Pci.h" - -static CARD32 netbsdPciConfRead(PCITAG, int); -static void netbsdPciConfWrite(PCITAG, int, CARD32); -static void netbsdPciSetBits(PCITAG, int, CARD32, CARD32); - -static int devpci = -1; - -static pciBusFuncs_t netbsdFuncs0 = { -/* pciReadLong */ netbsdPciConfRead, -/* pciWriteLong */ netbsdPciConfWrite, -/* pciSetBitsLong */ netbsdPciSetBits, -/* pciAddrHostToBus */ pciAddrNOOP, -/* pciAddrBusToHost */ pciAddrNOOP -}; - -static pciBusInfo_t netbsdPci0 = { -/* configMech */ PCI_CFG_MECH_OTHER, -/* numDevices */ 32, -/* secondary */ FALSE, -/* primary_bus */ 0, -/* funcs */ &netbsdFuncs0, -/* pciBusPriv */ NULL, -/* bridge */ NULL -}; - -void -netbsdPciInit() -{ - struct pciio_businfo pci_businfo; - - devpci = open("/dev/pci0", O_RDWR); - if (devpci == -1) - FatalError("netbsdPciInit: can't open /dev/pci0\n"); - - pciNumBuses = 1; - pciBusInfo[0] = &netbsdPci0; - /* use businfo to get the number of devs */ - if (ioctl(devpci, PCI_IOC_BUSINFO, &pci_businfo) != 0) - FatalError("netbsdPciInit: not a PCI bus device"); - netbsdPci0.numDevices = pci_businfo.maxdevs; -} - -static CARD32 -netbsdPciConfRead(PCITAG tag, int reg) -{ - struct pciio_bdf_cfgreg bdfr; - - bdfr.bus = PCI_BUS_FROM_TAG(tag); - bdfr.device = PCI_DEV_FROM_TAG(tag); - bdfr.function = PCI_FUNC_FROM_TAG(tag); - bdfr.cfgreg.reg = reg; - - if (ioctl(devpci, PCI_IOC_BDF_CFGREAD, &bdfr) == -1) - FatalError("netbsdPciConfRead: failed on %d/%d/%d\n", - bdfr.bus, bdfr.device, bdfr.function); - - return (bdfr.cfgreg.val); -} - -static void -netbsdPciConfWrite(PCITAG tag, int reg, CARD32 val) -{ - struct pciio_bdf_cfgreg bdfr; - - bdfr.bus = PCI_BUS_FROM_TAG(tag); - bdfr.device = PCI_DEV_FROM_TAG(tag); - bdfr.function = PCI_FUNC_FROM_TAG(tag); - bdfr.cfgreg.reg = reg; - bdfr.cfgreg.val = val; - - if (ioctl(devpci, PCI_IOC_BDF_CFGWRITE, &bdfr) == -1) - FatalError("netbsdPciConfWrite: failed on %d/%d/%d\n", - bdfr.bus, bdfr.device, bdfr.function); -} - -static void -netbsdPciSetBits(PCITAG tag, int reg, CARD32 mask, CARD32 bits) -{ - CARD32 val; - - val = netbsdPciConfRead(tag, reg); - val = (val & ~mask) | (bits & mask); - netbsdPciConfWrite(tag, reg, val); -} diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c index 51d1a2adf..2e5c2cf98 100644 --- a/hw/xfree86/os-support/shared/stdResource.c +++ b/hw/xfree86/os-support/shared/stdResource.c @@ -43,14 +43,13 @@ /* Avoid Imakefile changes */ #include "bus/Pci.h" -#ifdef USESTDRES +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) #define xf86StdAccResFromOS xf86AccResFromOS _X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END}; #endif -#ifdef INCLUDE_XF86_NO_DOMAIN - resPtr xf86StdAccResFromOS(resPtr ret) { @@ -117,5 +116,3 @@ xf86StdAccResFromOS(resPtr ret) /* XXX add others */ return ret; } - -#endif /* INCLUDE_XF86_NO_DOMAIN */ |