summaryrefslogtreecommitdiff
path: root/sysutils/libpciaccess
diff options
context:
space:
mode:
authorbjs <bjs>2008-10-30 20:58:11 +0000
committerbjs <bjs>2008-10-30 20:58:11 +0000
commit404d226ebaa5d729c743207fd586b29c29975032 (patch)
tree47a9aeb67c76afed989d45571689e0d32150fd38 /sysutils/libpciaccess
parent9982131aaaba5f70e842a3a47d5150bc746a462f (diff)
downloadpkgsrc-404d226ebaa5d729c743207fd586b29c29975032.tar.gz
Import libpciaccess-0.10.4 (X.org PCI wrapper library) + patches.
Tested on NetBSD-current (i386 and amd64); support for other architectures is in the works. Currently this should work with: ONLY_FOR_PLATFORM= FreeBSD-*-i386 NetBSD-*-i386 OpenBSD-*-i386 ONLY_FOR_PLATFORM+= FreeBSD-*-x86_64 NetBSD-*-x86_64 OpenBSD-*-x86_64 ONLY_FOR_PLATFORM+= DragonFly-i386-* DragonFly-x86_64-* ONLY_FOR_PLATFORM+= Linux-*-* SunOS-*-*
Diffstat (limited to 'sysutils/libpciaccess')
-rw-r--r--sysutils/libpciaccess/DESCR2
-rw-r--r--sysutils/libpciaccess/Makefile36
-rw-r--r--sysutils/libpciaccess/PLIST4
-rw-r--r--sysutils/libpciaccess/buildlink3.mk19
-rw-r--r--sysutils/libpciaccess/distinfo9
-rw-r--r--sysutils/libpciaccess/patches/patch-aa26
-rw-r--r--sysutils/libpciaccess/patches/patch-ab12
-rw-r--r--sysutils/libpciaccess/patches/patch-ac247
-rw-r--r--sysutils/libpciaccess/patches/patch-ad12
9 files changed, 367 insertions, 0 deletions
diff --git a/sysutils/libpciaccess/DESCR b/sysutils/libpciaccess/DESCR
new file mode 100644
index 00000000000..030437284f1
--- /dev/null
+++ b/sysutils/libpciaccess/DESCR
@@ -0,0 +1,2 @@
+The pciaccess library wraps platform-dependent PCI access methods
+in a convenient library.
diff --git a/sysutils/libpciaccess/Makefile b/sysutils/libpciaccess/Makefile
new file mode 100644
index 00000000000..5917de4fb24
--- /dev/null
+++ b/sysutils/libpciaccess/Makefile
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+#
+
+DISTNAME= libpciaccess-0.10.4
+CATEGORIES= sysutils x11
+MASTER_SITES= ${MASTER_SITE_XORG:=lib/}
+EXTRACT_SUFX= .tar.bz2
+
+MAINTAINER= bjs@NetBSD.org
+HOMEPAGE= http://xorg.freedesktop.org/
+COMMENT= PCI access utility library from X.org
+
+PKG_DESTDIR_SUPPORT= user-destdir
+###
+### XXX This list is probably not exhaustive.
+###
+ONLY_FOR_PLATFORM= FreeBSD-*-i386 NetBSD-*-i386 OpenBSD-*-i386
+ONLY_FOR_PLATFORM+= FreeBSD-*-x86_64 NetBSD-*-x86_64 OpenBSD-*-x86_64
+ONLY_FOR_PLATFORM+= DragonFly-i386-* DragonFly-x86_64-*
+ONLY_FOR_PLATFORM+= Linux-*-* SunOS-*-*
+
+GNU_CONFIGURE= yes
+USE_LIBTOOL= yes
+USE_TOOLS+= pkg-config
+###
+### XXX When our patches make it upstream, this will no longer be
+### necessary.
+###
+USE_TOOLS+= autoconf automake autoreconf
+
+PKGCONFIG_OVERRIDE+= pciaccess.pc.in
+
+pre-configure:
+ cd ${WRKSRC} && autoreconf -v -i -f
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/libpciaccess/PLIST b/sysutils/libpciaccess/PLIST
new file mode 100644
index 00000000000..9bb9003b268
--- /dev/null
+++ b/sysutils/libpciaccess/PLIST
@@ -0,0 +1,4 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+include/pciaccess.h
+lib/libpciaccess.la
+lib/pkgconfig/pciaccess.pc
diff --git a/sysutils/libpciaccess/buildlink3.mk b/sysutils/libpciaccess/buildlink3.mk
new file mode 100644
index 00000000000..1ea93f6ca1a
--- /dev/null
+++ b/sysutils/libpciaccess/buildlink3.mk
@@ -0,0 +1,19 @@
+# $NetBSD: buildlink3.mk,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
+LIBPCIACCESS_BUILDLINK3_MK:= ${LIBPCIACCESS_BUILDLINK3_MK}+
+
+.if ${BUILDLINK_DEPTH} == "+"
+BUILDLINK_DEPENDS+= libpciaccess
+.endif
+
+BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nlibpciaccess}
+BUILDLINK_PACKAGES+= libpciaccess
+BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}libpciaccess
+
+.if ${LIBPCIACCESS_BUILDLINK3_MK} == "+"
+BUILDLINK_API_DEPENDS.libpciaccess+= libpciaccess>=0.10.4
+BUILDLINK_PKGSRCDIR.libpciaccess?= ../../sysutils/libpciaccess
+.endif # LIBPCIACCESS_BUILDLINK3_MK
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
diff --git a/sysutils/libpciaccess/distinfo b/sysutils/libpciaccess/distinfo
new file mode 100644
index 00000000000..15e263b334a
--- /dev/null
+++ b/sysutils/libpciaccess/distinfo
@@ -0,0 +1,9 @@
+$NetBSD: distinfo,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+SHA1 (libpciaccess-0.10.4.tar.bz2) = e5dbfca1d0a767ad9d0278c7e8ba551c90d9c980
+RMD160 (libpciaccess-0.10.4.tar.bz2) = fe398273b491e6ba06dcdaf506721e02ed295f0c
+Size (libpciaccess-0.10.4.tar.bz2) = 256407 bytes
+SHA1 (patch-aa) = 6b8be37409cda8068e214b137d944a09a107ed8a
+SHA1 (patch-ab) = 3ff43112679d8e66e2f00fe706c332a401335ff5
+SHA1 (patch-ac) = c95282a53b5b2bd3eb5f2e233c45d44be997de24
+SHA1 (patch-ad) = 241890e819177262d9207cdb26f23aafd614e1da
diff --git a/sysutils/libpciaccess/patches/patch-aa b/sysutils/libpciaccess/patches/patch-aa
new file mode 100644
index 00000000000..8c5307906ab
--- /dev/null
+++ b/sysutils/libpciaccess/patches/patch-aa
@@ -0,0 +1,26 @@
+$NetBSD: patch-aa,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+--- configure.ac.orig 2008-10-17 16:59:42.000000000 -0400
++++ configure.ac
+@@ -116,7 +116,21 @@ AM_CONDITIONAL(NETBSD, [test "x$netbsd"
+ AM_CONDITIONAL(OPENBSD, [test "x$openbsd" = xyes])
+ AM_CONDITIONAL(SOLARIS, [test "x$solaris" = xyes])
+
++if test "x$netbsd" = xyes; then
++AC_CHECK_LIB([pci], [pcibus_conf_read],
++ [PCIACCESS_LIBS="-lpci $PCIACCESS_LIBS"],
++ [AC_MSG_ERROR(check for libpci failed.)])
++AC_CHECK_HEADERS([machine/sysarch.h], [],
++ [AC_MSG_ERROR(sysarch.h not found)])
++AC_CHECK_HEADERS([machine/mtrr.h], [have_mtrr_h="yes"], [have_mtrr_h="no"],
++[#ifdef HAVE_MACHINE_SYSARCH_H
++#include <sys/types.h>
++#include <machine/sysarch.h>
++#endif
++])
++else
+ AC_CHECK_HEADER([asm/mtrr.h], [have_mtrr_h="yes"], [have_mtrr_h="no"])
++fi
+
+ if test "x$have_mtrr_h" = xyes; then
+ AC_DEFINE(HAVE_MTRR, 1, [Use MTRRs on mappings])
diff --git a/sysutils/libpciaccess/patches/patch-ab b/sysutils/libpciaccess/patches/patch-ab
new file mode 100644
index 00000000000..d80d8ca6560
--- /dev/null
+++ b/sysutils/libpciaccess/patches/patch-ab
@@ -0,0 +1,12 @@
+$NetBSD: patch-ab,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+--- src/freebsd_pci.c.orig 2008-10-15 18:35:53.000000000 -0400
++++ src/freebsd_pci.c
+@@ -43,6 +43,7 @@
+ #include <sys/mman.h>
+ #include <sys/memrange.h>
+
++#include "config.h"
+ #include "pciaccess.h"
+ #include "pciaccess_private.h"
+
diff --git a/sysutils/libpciaccess/patches/patch-ac b/sysutils/libpciaccess/patches/patch-ac
new file mode 100644
index 00000000000..626067267a5
--- /dev/null
+++ b/sysutils/libpciaccess/patches/patch-ac
@@ -0,0 +1,247 @@
+$NetBSD: patch-ac,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+--- src/netbsd_pci.c.orig 2008-10-15 18:35:53.000000000 -0400
++++ src/netbsd_pci.c
+@@ -1,5 +1,4 @@
+-/*
+- * Copyright (c) 2008 Juan Romero Pardines
++/* Copyright (c) 2008 Blair Sadewitz
+ * Copyright (c) 2008 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+@@ -20,12 +19,15 @@
+ #include <sys/mman.h>
+ #include <sys/types.h>
+
++#ifdef HAVE_MTRR
+ #include <machine/sysarch.h>
+ #include <machine/mtrr.h>
++#define netbsd_set_mtrr(mr, num) _X86_SYSARCH_L(set_mtrr)(mr, num)
++#endif
+
++#include <dev/pci/pcidevs.h>
+ #include <dev/pci/pciio.h>
+ #include <dev/pci/pcireg.h>
+-#include <dev/pci/pcidevs.h>
+
+ #include <errno.h>
+ #include <fcntl.h>
+@@ -35,6 +37,8 @@
+ #include <unistd.h>
+
+
++#include <pci.h>
++
+ #include "pciaccess.h"
+ #include "pciaccess_private.h"
+
+@@ -43,20 +47,12 @@ static int pcifd;
+ static int
+ pci_read(int bus, int dev, int func, uint32_t reg, uint32_t *val)
+ {
+- struct pciio_bdf_cfgreg io;
+- int err;
++ uint32_t rval;
+
+- bzero(&io, sizeof(io));
+- io.bus = bus;
+- io.device = dev;
+- io.function = func;
+- io.cfgreg.reg = reg;
++ if (pcibus_conf_read(pcifd, bus, dev, func, reg, &rval) == -1)
++ return (-1);
+
+- err = ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io);
+- if (err)
+- return (err);
+-
+- *val = io.cfgreg.val;
++ *val = rval;
+
+ return 0;
+ }
+@@ -64,16 +60,7 @@ pci_read(int bus, int dev, int func, uin
+ static int
+ pci_write(int bus, int dev, int func, uint32_t reg, uint32_t val)
+ {
+- struct pciio_bdf_cfgreg io;
+-
+- bzero(&io, sizeof(io));
+- io.bus = bus;
+- io.device = dev;
+- io.function = func;
+- io.cfgreg.reg = reg;
+- io.cfgreg.val = val;
+-
+- return ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io);
++ return pcibus_conf_write(pcifd, bus, dev, func, reg, val);
+ }
+
+ static int
+@@ -91,70 +78,68 @@ static int
+ pci_device_netbsd_map_range(struct pci_device *dev,
+ struct pci_device_mapping *map)
+ {
+- struct mtrr mtrr;
+- int fd, error, nmtrr, prot = PROT_READ;
++#ifdef HAVE_MTRR
++ struct mtrr m;
++ int n = 1;
++#endif
++ int prot, fd, ret = 0;
+
+- if ((fd = open("/dev/mem", O_RDWR)) == -1)
+- return errno;
++ prot = PROT_READ;
+
+ if (map->flags & PCI_DEV_MAP_FLAG_WRITABLE)
+ prot |= PROT_WRITE;
+
+- map->memory = mmap(NULL, map->size, prot, MAP_SHARED,
+- fd, map->base);
++ fd = open("/dev/mem", O_RDWR);
++ if (fd == -1)
++ return errno;
++ map->memory = mmap(NULL, map->size, prot, MAP_SHARED, fd, map->base);
+ if (map->memory == MAP_FAILED)
+ return errno;
+
++#ifdef HAVE_MTRR
++ memset(&m, 0, sizeof(m));
++
+ /* No need to set an MTRR if it's the default mode. */
+ if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) ||
+ (map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)) {
+- mtrr.base = map->base;
+- mtrr.len = map->size;
+- mtrr.flags = MTRR_VALID;
+-
+- if (map->flags & PCI_DEV_MAP_FLAG_CACHABLE)
+- mtrr.type = MTRR_TYPE_WB;
++ m.base = base;
++ m.flags = MTRR_VALID | MTRR_PRIVATE;
++ m.len = size;
++ m.owner = getpid();
++ if (map->flags & PCI_DEV_MAP_FLAG_CACHEABLE)
++ m.type = MTRR_TYPE_WB;
+ if (map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)
+- mtrr.type = MTRR_TYPE_WC;
+-#ifdef __i386__
+- error = i386_set_mtrr(&mtrr, &nmtrr);
+-#endif
+-#ifdef __amd64__
+- error = x86_64_set_mtrr(&mtrr, &nmtrr);
+-#endif
+- if (error) {
+- close(fd);
+- return errno;
+- }
++ m.type = MTRR_TYPE_WC;
++
++ if ((netbsd_set_mtrr(&m, &n)) == -1)
++ ret = errno;
+ }
++#endif
+
+ close(fd);
+
+- return 0;
++ return ret;
+ }
+
+ static int
+ pci_device_netbsd_unmap_range(struct pci_device *dev,
+ struct pci_device_mapping *map)
+ {
+- struct mtrr mtrr;
+- int nmtrr, error;
++#ifdef HAVE_MTRR
++ struct mtrr m;
++ int n = 1;
++
++ memset(&m, 0, sizeof(m));
+
+ if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) ||
+ (map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)) {
+- mtrr.base = map->base;
+- mtrr.len = map->size;
+- mtrr.type = MTRR_TYPE_UC;
+- mtrr.flags = 0; /* clear/set MTRR */
+-#ifdef __i386__
+- error = i386_set_mtrr(&mtrr, &nmtrr);
+-#endif
+-#ifdef __amd64__
+- error = x86_64_set_mtrr(&mtrr, &nmtrr);
+-#endif
+- if (error)
+- return errno;
++ m.base = map->base;
++ m.flags = 0;
++ m.len = size;
++ m.type = MTRR_TYPE_UC;
++ (void)netbsd_set_mtrr(&m, &n);
+ }
++#endif
+
+ return pci_device_generic_unmap_range(dev, map);
+ }
+@@ -163,25 +148,22 @@ static int
+ pci_device_netbsd_read(struct pci_device *dev, void *data,
+ pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_read)
+ {
+- struct pciio_bdf_cfgreg io;
+-
+- io.bus = dev->bus;
+- io.device = dev->dev;
+- io.function = dev->func;
++ u_int reg, rval;
+
+ *bytes_read = 0;
+ while (size > 0) {
+ int toread = MIN(size, 4 - (offset & 0x3));
+
+- io.cfgreg.reg = (offset & ~0x3);
++ reg = (offset & ~0x3);
+
+- if (ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io) == -1)
++ if ((pcibus_conf_read(pcifd, dev->bus, dev->dev, dev->func,
++ reg, &rval)) == -1)
+ return errno;
+
+- io.cfgreg.val = htole32(io.cfgreg.val);
+- io.cfgreg.val >>= ((offset & 0x3) * 8);
++ rval = htole32(rval);
++ rval >>= ((offset & 0x3) * 8);
+
+- memcpy(data, &io.cfgreg.val, toread);
++ memcpy(data, &rval, toread);
+
+ offset += toread;
+ data = (char *)data + toread;
+@@ -196,21 +178,18 @@ static int
+ pci_device_netbsd_write(struct pci_device *dev, const void *data,
+ pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_written)
+ {
+- struct pciio_bdf_cfgreg io;
++ u_int reg, val;
+
+ if ((offset % 4) == 0 || (size % 4) == 0)
+ return EINVAL;
+
+- io.bus = dev->bus;
+- io.device = dev->dev;
+- io.function = dev->func;
+-
+ *bytes_written = 0;
+ while (size > 0) {
+- io.cfgreg.reg = offset;
+- memcpy(&io.cfgreg.val, data, 4);
++ reg = offset;
++ memcpy(&val, data, 4);
+
+- if (ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io) == -1)
++ if ((pcibus_conf_write(pcifd, dev->bus, dev->dev, dev->func,
++ reg, val)) == -1)
+ return errno;
+
+ offset += 4;
diff --git a/sysutils/libpciaccess/patches/patch-ad b/sysutils/libpciaccess/patches/patch-ad
new file mode 100644
index 00000000000..5bd6fcbb111
--- /dev/null
+++ b/sysutils/libpciaccess/patches/patch-ad
@@ -0,0 +1,12 @@
+$NetBSD: patch-ad,v 1.1.1.1 2008/10/30 20:58:11 bjs Exp $
+
+--- src/scanpci.c.orig 2008-10-16 21:36:11.000000000 -0400
++++ src/scanpci.c
+@@ -25,6 +25,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <err.h>
++#include <unistd.h>
+
+ #include "pciaccess.h"
+