Commit adf46b57 authored by Eric Anholt's avatar Eric Anholt

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.
parent 3fe67d23
......@@ -1287,8 +1287,7 @@ XORG_CORE_LIBS="$DIX_LIB $CONFIG_LIB"
AC_SUBST([XORG_CORE_LIBS])
xorg_bus_linuxpci=no
xorg_bus_freebsdpci=no
xorg_bus_netbsdpci=no
xorg_bus_bsdpci=no
xorg_bus_ix86pci=no
xorg_bus_ppcpci=no
xorg_bus_sparcpci=no
......@@ -1397,35 +1396,17 @@ return 0;}
freebsd* | kfreebsd*-gnu)
XORG_OS="freebsd"
XORG_OS_SUBDIR="bsd"
case $host_cpu in
i*86)
;;
*)
xorg_bus_freebsdpci="yes"
;;
esac
xorg_bus_bsdpci="yes"
;;
netbsd*)
XORG_OS="netbsd"
XORG_OS_SUBDIR="bsd"
case $host_cpu in
i*86|amd64*|x86_64*|ia64*)
;;
*)
xorg_bus_netbsdpci="yes"
;;
esac
xorg_bus_bsdpci="yes"
;;
openbsd*)
XORG_OS="openbsd"
XORG_OS_SUBDIR="bsd"
case $host_cpu in
i*86|amd64*|x86_64*|ia64*)
;;
*)
xorg_bus_freebsdpci="yes"
;;
esac
xorg_bus_bsdpci="yes"
;;
solaris*)
XORG_OS="solaris"
......@@ -1495,6 +1476,7 @@ return 0;}
i*86)
case $host_os in
darwin*) ;;
*bsd*) ;;
*) xorg_bus_ix86pci=yes ;;
esac
;;
......@@ -1513,8 +1495,7 @@ return 0;}
;;
x86_64*|amd64*)
case $host_os in
darwin*|freebsd*|kfreebsd*-gnu)
# FreeBSD uses the system pci interface
darwin*|*bsd*)
;;
*)
xorg_bus_ix86pci="yes"
......@@ -1608,8 +1589,7 @@ return 0;}
fi
AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
AM_CONDITIONAL([XORG_BUS_FREEBSDPCI], [test "x$xorg_bus_freebsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_NETBSDPCI], [test "x$xorg_bus_netbsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_IX86PCI], [test "x$xorg_bus_ix86pci" = xyes])
AM_CONDITIONAL([XORG_BUS_PPCPCI], [test "x$xorg_bus_ppcpci" = xyes])
AM_CONDITIONAL([XORG_BUS_SPARCPCI], [test "x$xorg_bus_sparcpci" = xyes])
......
......@@ -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
......
......@@ -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 */
......@@ -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)
......
/*
* 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;
}
/*
* 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);
}
/*
* 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);
}
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment