diff options
author | wiz <wiz> | 2013-07-21 09:42:40 +0000 |
---|---|---|
committer | wiz <wiz> | 2013-07-21 09:42:40 +0000 |
commit | 7b9b7953ca9ba7e623a0f2826cfc609aa5e56aa5 (patch) | |
tree | 631a16a36ed6fb10ed07743ed3ecc639b977e63b /sysutils | |
parent | 20d81e64134b473d18e9671336998e8cfa917efe (diff) | |
download | pkgsrc-7b9b7953ca9ba7e623a0f2826cfc609aa5e56aa5.tar.gz |
Update to 0.13.2. Set LICENSE.
This release provides a lot of platform-specific improvements for various
platforms, including Solaris (SPARC & x64), FreeBSD, NetBSD, and Hurd.
It also provides some platform-independent fixes & code cleanup.
Adam Jackson (1):
configure: Remove AM_MAINTAINER_MODE
Alan Coopersmith (10):
Solaris: Implement map_legacy & legacy_io functions
Solaris: refactor pci_device_solx_devfs_map_range to reduce code duplication
Bug 63583 - add legacy IO routines for FreeBSD
Define PCI_MATCH_ANY as an unsigned int
pci_id_file_open: move variable inside the #ifndef that uses it
pci_device_solx_devfs_read: fix sign conversion/comparison warnings
Solaris: Remove #defines for Ultra 45 southbridge device ids
pci_device_solx_devfs_probe: implicit conversion changes signedness warnings
Resync COPYING file with copyrights/licenses from code
libpciaccess 0.13.2
Colin Walters (1):
autogen.sh: Implement GNOME Build API
Egbert Eich (1):
PCI: set correct mask value when matching for bridges.
Henry Zhao (5):
libpciaccess: implementation of boot_vga in Solaris
libpciaccess: sparc rom read fix
scanpci: print meaningful info on BASEROM
Solaris: Add domain support for sparc platform
Solaris: probe improvement
John Martin (1):
Fix Sun bug #7035791: scanpci should report 64 bit registers
Mark Logan (1):
libpciaccess: fix memory usage errors
Samuel Thibault (1):
Implement legacy io & map for x86 backend
Thomas Klausner (6):
Protect config.h like usual.
Move 'const' to correct place, so it has meaning.
Update NetBSD support.
Enable boot_vga support only if WSDISPLAYIO_GET_BUSID is defined.
Fix build on NetBSD-4.
Support more pci functions on NetBSD.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/libpciaccess/Makefile | 23 | ||||
-rw-r--r-- | sysutils/libpciaccess/distinfo | 18 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-ac | 1053 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-configure | 23 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-configure.ac | 51 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-scanpci_Makefile.am | 15 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-scanpci_scanpci.c | 28 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-src_common__bridge.c | 25 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-src_freebsd__pci.c | 174 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-src_pciaccess__private.h | 16 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-src_solx__devfs.c | 1153 | ||||
-rw-r--r-- | sysutils/libpciaccess/patches/patch-src_x86__pci.c | 127 |
12 files changed, 34 insertions, 2672 deletions
diff --git a/sysutils/libpciaccess/Makefile b/sysutils/libpciaccess/Makefile index d0ff4c6d0d1..127030b9a80 100644 --- a/sysutils/libpciaccess/Makefile +++ b/sysutils/libpciaccess/Makefile @@ -1,7 +1,6 @@ -# $NetBSD: Makefile,v 1.16 2013/06/03 14:19:38 wiz Exp $ +# $NetBSD: Makefile,v 1.17 2013/07/21 09:42:40 wiz Exp $ -DISTNAME= libpciaccess-0.13.1 -PKGREVISION= 3 +DISTNAME= libpciaccess-0.13.2 CATEGORIES= sysutils x11 MASTER_SITES= ${MASTER_SITE_XORG:=lib/} EXTRACT_SUFX= .tar.bz2 @@ -9,6 +8,7 @@ EXTRACT_SUFX= .tar.bz2 MAINTAINER= pkgsrc-users@NetBSD.org HOMEPAGE= http://xorg.freedesktop.org/ COMMENT= PCI access utility library from X.org +LICENSE= mit AND x11 ### ### XXX This list is probably not exhaustive. @@ -19,23 +19,12 @@ ONLY_FOR_PLATFORM+= DragonFly-*-i386 DragonFly-*-x86_64 ONLY_FOR_PLATFORM+= Linux-*-* SunOS-*-* ONLY_FOR_PLATFORM+= NetBSD-*-sparc64 NetBSD-*-hppa -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 - +GNU_CONFIGURE= yes CONFIGURE_ARGS+= --with-zlib +USE_LIBTOOL= yes +USE_TOOLS+= pkg-config PKGCONFIG_OVERRIDE+= pciaccess.pc.in -BUILD_DEPENDS+= xorg-util-macros>=1.3:../../devel/xorg-util-macros - -pre-configure: - cd ${WRKSRC} && autoreconf -v -i -f - .include "../../devel/zlib/buildlink3.mk" .include "../../mk/bsd.pkg.mk" diff --git a/sysutils/libpciaccess/distinfo b/sysutils/libpciaccess/distinfo index 688add88ca9..3846017df5d 100644 --- a/sysutils/libpciaccess/distinfo +++ b/sysutils/libpciaccess/distinfo @@ -1,14 +1,6 @@ -$NetBSD: distinfo,v 1.22 2013/06/04 10:16:00 obache Exp $ +$NetBSD: distinfo,v 1.23 2013/07/21 09:42:40 wiz Exp $ -SHA1 (libpciaccess-0.13.1.tar.bz2) = ae4dcf27a1b52c6a1fd90b21165fbaecae34e8ac -RMD160 (libpciaccess-0.13.1.tar.bz2) = 2e4c94bd782e98d360664cc0ce3d5ad2d1b0045c -Size (libpciaccess-0.13.1.tar.bz2) = 352351 bytes -SHA1 (patch-ac) = 254cb4ce079f64f80ec56b5caaae8390b214411e -SHA1 (patch-configure.ac) = 7c5042225016fcd47e8cfd8242c0533ea86b8c5e -SHA1 (patch-scanpci_Makefile.am) = 086fead04b4a2e506a35aca5d5fe82395708e90c -SHA1 (patch-scanpci_scanpci.c) = 795d0572af9afb13af60f878f9f44d40edb33463 -SHA1 (patch-src_common__bridge.c) = 658815c38b4f2e318bf083bc81b9042f88d04b2f -SHA1 (patch-src_freebsd__pci.c) = 6b96f4c60a386a129069c3cd4593ba27938346e4 -SHA1 (patch-src_pciaccess__private.h) = 56853598f50e5656ff7ba190b31f2940d66ec468 -SHA1 (patch-src_solx__devfs.c) = 924649d561bc9922b6ee8335ffe5e997b1cb8c3c -SHA1 (patch-src_x86__pci.c) = b9820f8ff9306c18d040444e57270f520f95a58f +SHA1 (libpciaccess-0.13.2.tar.bz2) = 63df515a4c5d5a339a7c1f9e4baa6543efa3c7da +RMD160 (libpciaccess-0.13.2.tar.bz2) = d02d6be193cbea6a56c08b041c5ef3d3902f330c +Size (libpciaccess-0.13.2.tar.bz2) = 359231 bytes +SHA1 (patch-configure) = 92a80491413c1e6882290498745f5f841f2a2362 diff --git a/sysutils/libpciaccess/patches/patch-ac b/sysutils/libpciaccess/patches/patch-ac deleted file mode 100644 index 9ac0e5c7efb..00000000000 --- a/sysutils/libpciaccess/patches/patch-ac +++ /dev/null @@ -1,1053 +0,0 @@ -$NetBSD: patch-ac,v 1.15 2013/06/04 10:16:00 obache Exp $ - -Improve NetBSD support. From Michael Lorenz <macallan@NetBSD.org>. -Enable boot_vga support only if WSDISPLAYIO_GET_BUSID is defined. - ---- src/netbsd_pci.c.orig 2012-04-09 10:02:57.000000000 -0700 -+++ src/netbsd_pci.c 2013-06-02 06:52:58.000000000 -0700 -@@ -1,6 +1,7 @@ - /* - * Copyright (c) 2008 Juan Romero Pardines - * Copyright (c) 2008 Mark Kettenis -+ * Copyright (c) 2009 Michael Lorenz - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above -@@ -20,8 +21,22 @@ - #include <sys/mman.h> - #include <sys/types.h> - -+#include "config.h" -+ -+#ifdef HAVE_MTRR - #include <machine/sysarch.h> - #include <machine/mtrr.h> -+#ifdef _X86_SYSARCH_L -+#define netbsd_set_mtrr(mr, num) _X86_SYSARCH_L(set_mtrr)(mr, num) -+#else -+#ifdef __i386__ -+#define netbsd_set_mtrr(mr, num) i386_set_mtrr((mr), (num)) -+#endif -+#ifdef __amd64__ -+#define netbsd_set_mtrr(mr, num) x86_64_set_mtrr((mr), (num)) -+#endif -+#endif -+#endif - - #include <dev/pci/pciio.h> - #include <dev/pci/pcireg.h> -@@ -35,126 +50,152 @@ - #include <unistd.h> - - -+#include <pci.h> -+#include <dev/wscons/wsconsio.h> -+ - #include "pciaccess.h" - #include "pciaccess_private.h" - --static int pcifd; -+typedef struct _pcibus { -+ int fd; /* /dev/pci* */ -+ int num; /* bus number */ -+ int maxdevs; /* maximum number of devices */ -+} PciBus; -+ -+static PciBus buses[32]; /* indexed by pci_device.domain */ -+static int nbuses = 0; /* number of buses found */ -+ -+/* -+ * NetBSD's userland has a /dev/pci* entry for each bus but userland has no way -+ * to tell if a bus is a subordinate of another one or if it's on a different -+ * host bridge. On some architectures ( macppc for example ) all root buses have -+ * bus number 0 but on sparc64 for example the two roots in an Ultra60 have -+ * different bus numbers - one is 0 and the other 128. -+ * With each /dev/pci* we can map everything on the same root and we can also -+ * see all devices on the same root, trying to do that causes problems though: -+ * - since we can't tell which /dev/pci* is a subordinate we would find some -+ * devices more than once -+ * - we would have to guess subordinate bus numbers which is a waste of time -+ * since we can ask each /dev/pci* for its bus number so we can scan only the -+ * buses we know exist, not all 256 which may exist in each domain. -+ * - some bus_space_mmap() methods may limit mappings to address ranges which -+ * belong to known devices on that bus only. -+ * Each host bridge may or may not have its own IO range, to avoid guesswork -+ * here each /dev/pci* will let userland map its appropriate IO range at -+ * PCI_MAGIC_IO_RANGE if defined in <machine/param.h> -+ * With all this we should be able to use any PCI graphics device on any PCI -+ * bus on any architecture as long as Xorg has a driver, without allowing -+ * arbitrary mappings via /dev/mem and without userland having to know or care -+ * about translating bus addresses to physical addresses or the other way -+ * around. -+ */ - - static int --pci_read(int bus, int dev, int func, uint32_t reg, uint32_t *val) -+pci_read(int domain, 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 ((domain < 0) || (domain > nbuses)) -+ return -1; - -- err = ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io); -- if (err) -- return (err); -+ if (pcibus_conf_read(buses[domain].fd, (unsigned int)bus, -+ (unsigned int)dev, (unsigned int)func, reg, &rval) == -1) -+ return (-1); - -- *val = io.cfgreg.val; -+ *val = rval; - - return 0; - } - - static int --pci_write(int bus, int dev, int func, uint32_t reg, uint32_t val) -+pci_write(int domain, 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; -+ if ((domain < 0) || (domain > nbuses)) -+ return -1; - -- return ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io); -+ return pcibus_conf_write(buses[domain].fd, (unsigned int)bus, -+ (unsigned int)dev, (unsigned int)func, reg, val); - } - - static int --pci_nfuncs(int bus, int dev) -+pci_nfuncs(int domain, int bus, int dev) - { - uint32_t hdr; - -- if (pci_read(bus, dev, 0, PCI_BHLC_REG, &hdr) != 0) -+ if ((domain < 0) || (domain > nbuses)) -+ return -1; -+ -+ if (pci_read(domain, bus, dev, 0, PCI_BHLC_REG, &hdr) != 0) - return -1; - - return (PCI_HDRTYPE_MULTIFN(hdr) ? 8 : 1); - } - -+/*ARGSUSED*/ - 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, ret = 0; - -- if ((fd = open("/dev/mem", O_RDWR | O_CLOEXEC)) == -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); -+ map->memory = mmap(NULL, (size_t)map->size, prot, MAP_SHARED, -+ buses[dev->domain].fd, (off_t)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; -- -+ m.base = map->base; -+ m.flags = MTRR_VALID | MTRR_PRIVATE; -+ m.len = map->size; -+ m.owner = getpid(); - if (map->flags & PCI_DEV_MAP_FLAG_CACHABLE) -- mtrr.type = MTRR_TYPE_WB; -+ 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) { -+ fprintf(stderr, "mtrr set failed: %s\n", -+ strerror(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 = map->size; -+ m.type = MTRR_TYPE_UC; -+ (void)netbsd_set_mtrr(&m, &n); - } -+#endif - - return pci_device_generic_unmap_range(dev, map); - } -@@ -163,25 +204,23 @@ 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)); -+ size_t toread = MIN(size, 4 - (offset & 0x3)); - -- io.cfgreg.reg = (offset & ~0x3); -+ reg = (u_int)(offset & ~0x3); - -- if (ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io) == -1) -+ if ((pcibus_conf_read(buses[dev->domain].fd, -+ (unsigned int)dev->bus, (unsigned int)dev->dev, -+ (unsigned int)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,25 +235,23 @@ 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 = (u_int)offset; -+ memcpy(&val, data, 4); - -- if (ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io) == -1) -+ if ((pcibus_conf_write(buses[dev->domain].fd, -+ (unsigned int)dev->bus, (unsigned int)dev->dev, -+ (unsigned int)dev->func, reg, val)) == -1) - return errno; - - offset += 4; -- data = (char *)data + 4; -+ data = (const char *)data + 4; - size -= 4; - *bytes_written += 4; - } -@@ -222,10 +259,53 @@ pci_device_netbsd_write(struct pci_devic - return 0; - } - -+#if defined(WSDISPLAYIO_GET_BUSID) -+static int -+pci_device_netbsd_boot_vga(struct pci_device *dev) -+{ -+ int ret; -+ struct wsdisplayio_bus_id busid; -+ int fd; -+ -+ fd = open("/dev/ttyE0", O_RDONLY); -+ if (fd == -1) { -+ fprintf(stderr, "failed to open /dev/ttyE0: %s\n", -+ strerror(errno)); -+ return 0; -+ } -+ -+ ret = ioctl(fd, WSDISPLAYIO_GET_BUSID, &busid); -+ close(fd); -+ if (ret == -1) { -+ fprintf(stderr, "ioctl WSDISPLAYIO_GET_BUSID failed: %s\n", -+ strerror(errno)); -+ return 0; -+ } -+ -+ if (busid.bus_type != WSDISPLAYIO_BUS_PCI) -+ return 0; -+ -+ if (busid.ubus.pci.domain != dev->domain) -+ return 0; -+ if (busid.ubus.pci.bus != dev->bus) -+ return 0; -+ if (busid.ubus.pci.device != dev->dev) -+ return 0; -+ if (busid.ubus.pci.function != dev->func) -+ return 0; -+ -+ return 1; -+} -+#endif -+ - static void - pci_system_netbsd_destroy(void) - { -- close(pcifd); -+ int i; -+ -+ for (i = 0; i < nbuses; i++) { -+ close(buses[i].fd); -+ } - free(pci_sys); - pci_sys = NULL; - } -@@ -233,17 +313,34 @@ pci_system_netbsd_destroy(void) - static int - pci_device_netbsd_probe(struct pci_device *device) - { -- struct pci_device_private *priv = (struct pci_device_private *)device; -+ struct pci_device_private *priv = -+ (struct pci_device_private *)(void *)device; - struct pci_mem_region *region; - uint64_t reg64, size64; - uint32_t bar, reg, size; -- int bus, dev, func, err; -+ int bus, dev, func, err, domain; - -+ domain = device->domain; - bus = device->bus; - dev = device->dev; - func = device->func; - -- err = pci_read(bus, dev, func, PCI_BHLC_REG, ®); -+ /* Enable the device if necessary */ -+ err = pci_read(domain, bus, dev, func, PCI_COMMAND_STATUS_REG, ®); -+ if (err) -+ return err; -+ if ((reg & (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) != -+ (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) { -+ reg |= PCI_COMMAND_IO_ENABLE | -+ PCI_COMMAND_MEM_ENABLE | -+ PCI_COMMAND_MASTER_ENABLE; -+ err = pci_write(domain, bus, dev, func, PCI_COMMAND_STATUS_REG, -+ reg); -+ if (err) -+ return err; -+ } -+ -+ err = pci_read(domain, bus, dev, func, PCI_BHLC_REG, ®); - if (err) - return err; - -@@ -254,16 +351,16 @@ pci_device_netbsd_probe(struct pci_devic - region = device->regions; - for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END; - bar += sizeof(uint32_t), region++) { -- err = pci_read(bus, dev, func, bar, ®); -+ err = pci_read(domain, bus, dev, func, bar, ®); - if (err) - return err; - - /* Probe the size of the region. */ -- err = pci_write(bus, dev, func, bar, ~0); -+ err = pci_write(domain, bus, dev, func, bar, (unsigned int)~0); - if (err) - return err; -- pci_read(bus, dev, func, bar, &size); -- pci_write(bus, dev, func, bar, reg); -+ pci_read(domain, bus, dev, func, bar, &size); -+ pci_write(domain, bus, dev, func, bar, reg); - - if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_IO) { - region->is_IO = 1; -@@ -286,66 +383,524 @@ pci_device_netbsd_probe(struct pci_devic - - bar += sizeof(uint32_t); - -- err = pci_read(bus, dev, func, bar, ®); -+ err = pci_read(domain, bus, dev, func, bar, ®); - if (err) - return err; - reg64 |= (uint64_t)reg << 32; - -- err = pci_write(bus, dev, func, bar, ~0); -+ err = pci_write(domain, bus, dev, func, bar, -+ (unsigned int)~0); - if (err) - return err; -- pci_read(bus, dev, func, bar, &size); -- pci_write(bus, dev, func, bar, reg64 >> 32); -+ pci_read(domain, bus, dev, func, bar, &size); -+ pci_write(domain, bus, dev, func, bar, -+ (unsigned int)(reg64 >> 32)); - size64 |= (uint64_t)size << 32; - -- region->base_addr = PCI_MAPREG_MEM64_ADDR(reg64); -- region->size = PCI_MAPREG_MEM64_SIZE(size64); -+ region->base_addr = -+ (unsigned long)PCI_MAPREG_MEM64_ADDR(reg64); -+ region->size = -+ (unsigned long)PCI_MAPREG_MEM64_SIZE(size64); - region++; - break; - } - } - } - -+ /* Probe expansion ROM if present */ -+ err = pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, ®); -+ if (err) -+ return err; -+ if (reg != 0) { -+ err = pci_write(domain, bus, dev, func, PCI_MAPREG_ROM, -+ (uint32_t)(~PCI_MAPREG_ROM_ENABLE)); -+ if (err) -+ return err; -+ pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, &size); -+ pci_write(domain, bus, dev, func, PCI_MAPREG_ROM, reg); -+ if ((reg & PCI_MAPREG_MEM_ADDR_MASK) != 0) { -+ priv->rom_base = reg & PCI_MAPREG_MEM_ADDR_MASK; -+ device->rom_size = -(size & PCI_MAPREG_MEM_ADDR_MASK); -+ } -+ } -+ - return 0; - } - -+/** -+ * Read a VGA rom using the 0xc0000 mapping. -+ * -+ * This function should be extended to handle access through PCI resources, -+ * which should be more reliable when available. -+ */ -+static int -+pci_device_netbsd_read_rom(struct pci_device *dev, void *buffer) -+{ -+ struct pci_device_private *priv = (struct pci_device_private *)(void *)dev; -+ void *bios; -+ pciaddr_t rom_base; -+ size_t rom_size; -+ uint32_t bios_val, command_val; -+ int pci_rom; -+ -+ if (((priv->base.device_class >> 16) & 0xff) != PCI_CLASS_DISPLAY || -+ ((priv->base.device_class >> 8) & 0xff) != PCI_SUBCLASS_DISPLAY_VGA) -+ return ENOSYS; -+ -+ if (priv->rom_base == 0) { -+#if defined(__amd64__) || defined(__i386__) -+ /* -+ * We need a way to detect when this isn't the console and reject -+ * this request outright. -+ */ -+ rom_base = 0xc0000; -+ rom_size = 0x10000; -+ pci_rom = 0; -+#else -+ return ENOSYS; -+#endif -+ } else { -+ rom_base = priv->rom_base; -+ rom_size = dev->rom_size; -+ pci_rom = 1; -+ if ((pcibus_conf_read(buses[dev->domain].fd, (unsigned int)dev->bus, -+ (unsigned int)dev->dev, (unsigned int)dev->func, -+ PCI_COMMAND_STATUS_REG, &command_val)) == -1) -+ return errno; -+ if ((command_val & PCI_COMMAND_MEM_ENABLE) == 0) { -+ if ((pcibus_conf_write(buses[dev->domain].fd, -+ (unsigned int)dev->bus, (unsigned int)dev->dev, -+ (unsigned int)dev->func, PCI_COMMAND_STATUS_REG, -+ command_val | PCI_COMMAND_MEM_ENABLE)) == -1) -+ return errno; -+ } -+ if ((pcibus_conf_read(buses[dev->domain].fd, (unsigned int)dev->bus, -+ (unsigned int)dev->dev, (unsigned int)dev->func, -+ PCI_MAPREG_ROM, &bios_val)) == -1) -+ return errno; -+ if ((bios_val & PCI_MAPREG_ROM_ENABLE) == 0) { -+ if ((pcibus_conf_write(buses[dev->domain].fd, -+ (unsigned int)dev->bus, -+ (unsigned int)dev->dev, (unsigned int)dev->func, -+ PCI_MAPREG_ROM, bios_val | PCI_MAPREG_ROM_ENABLE)) == -1) -+ return errno; -+ } -+ } -+ -+ fprintf(stderr, "Using rom_base = 0x%lx 0x%lx (pci_rom=%d)\n", -+ (long)rom_base, (long)rom_size, pci_rom); -+ -+ bios = mmap(NULL, rom_size, PROT_READ, MAP_SHARED, buses[dev->domain].fd, -+ (off_t)rom_base); -+ if (bios == MAP_FAILED) { -+ int serrno = errno; -+ return serrno; -+ } -+ -+ memcpy(buffer, bios, rom_size); -+ -+ munmap(bios, rom_size); -+ -+ if (pci_rom) { -+ if ((command_val & PCI_COMMAND_MEM_ENABLE) == 0) { -+ if ((pcibus_conf_write(buses[dev->domain].fd, -+ (unsigned int)dev->bus, -+ (unsigned int)dev->dev, (unsigned int)dev->func, -+ PCI_COMMAND_STATUS_REG, command_val)) == -1) -+ return errno; -+ } -+ if ((bios_val & PCI_MAPREG_ROM_ENABLE) == 0) { -+ if ((pcibus_conf_write(buses[dev->domain].fd, -+ (unsigned int)dev->bus, -+ (unsigned int)dev->dev, (unsigned int)dev->func, -+ PCI_MAPREG_ROM, bios_val)) == -1) -+ return errno; -+ } -+ } -+ -+ return 0; -+} -+ -+#if defined(__i386__) || defined(__amd64__) -+#include <machine/sysarch.h> -+//#include <machine/pio.h> -+ -+/* -+ * Functions to provide access to x86 programmed I/O instructions. -+ * -+ * The in[bwl]() and out[bwl]() functions are split into two varieties: one to -+ * use a small, constant, 8-bit port number, and another to use a large or -+ * variable port number. The former can be compiled as a smaller instruction. -+ */ -+ -+ -+#ifdef __OPTIMIZE__ -+ -+#define __use_immediate_port(port) \ -+ (__builtin_constant_p((port)) && (port) < 0x100) -+ -+#else -+ -+#define __use_immediate_port(port) 0 -+ -+#endif -+ -+ -+#define inb(port) \ -+ (/* CONSTCOND */ __use_immediate_port(port) ? __inbc(port) : __inb(port)) -+ -+static __inline u_int8_t -+__inbc(unsigned port) -+{ -+ u_int8_t data; -+ __asm __volatile("inb %w1,%0" : "=a" (data) : "id" (port)); -+ return data; -+} -+ -+static __inline u_int8_t -+__inb(unsigned port) -+{ -+ u_int8_t data; -+ __asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port)); -+ return data; -+} -+ -+static __inline void -+insb(unsigned port, void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\tinsb" : -+ "=D" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt) : -+ "memory"); -+} -+ -+#define inw(port) \ -+ (/* CONSTCOND */ __use_immediate_port(port) ? __inwc(port) : __inw(port)) -+ -+static __inline u_int16_t -+__inwc(unsigned port) -+{ -+ u_int16_t data; -+ __asm __volatile("inw %w1,%0" : "=a" (data) : "id" (port)); -+ return data; -+} -+ -+static __inline u_int16_t -+__inw(unsigned port) -+{ -+ u_int16_t data; -+ __asm __volatile("inw %w1,%0" : "=a" (data) : "d" (port)); -+ return data; -+} -+ -+static __inline void -+insw(unsigned port, void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\tinsw" : -+ "=D" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt) : -+ "memory"); -+} -+ -+#define inl(port) \ -+ (/* CONSTCOND */ __use_immediate_port(port) ? __inlc(port) : __inl(port)) -+ -+static __inline u_int32_t -+__inlc(unsigned port) -+{ -+ u_int32_t data; -+ __asm __volatile("inl %w1,%0" : "=a" (data) : "id" (port)); -+ return data; -+} -+ -+static __inline u_int32_t -+__inl(unsigned port) -+{ -+ u_int32_t data; -+ __asm __volatile("inl %w1,%0" : "=a" (data) : "d" (port)); -+ return data; -+} -+ -+static __inline void -+insl(unsigned port, void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\tinsl" : -+ "=D" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt) : -+ "memory"); -+} -+ -+#define outb(port, data) \ -+ (/* CONSTCOND */__use_immediate_port(port) ? __outbc(port, data) : \ -+ __outb(port, data)) -+ -+static __inline void -+__outbc(unsigned port, u_int8_t data) -+{ -+ __asm __volatile("outb %0,%w1" : : "a" (data), "id" (port)); -+} -+ -+static __inline void -+__outb(unsigned port, u_int8_t data) -+{ -+ __asm __volatile("outb %0,%w1" : : "a" (data), "d" (port)); -+} -+ -+static __inline void -+outsb(unsigned port, const void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\toutsb" : -+ "=S" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt)); -+} -+ -+#define outw(port, data) \ -+ (/* CONSTCOND */ __use_immediate_port(port) ? __outwc(port, data) : \ -+ __outw(port, data)) -+ -+static __inline void -+__outwc(unsigned port, u_int16_t data) -+{ -+ __asm __volatile("outw %0,%w1" : : "a" (data), "id" (port)); -+} -+ -+static __inline void -+__outw(unsigned port, u_int16_t data) -+{ -+ __asm __volatile("outw %0,%w1" : : "a" (data), "d" (port)); -+} -+ -+static __inline void -+outsw(unsigned port, const void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\toutsw" : -+ "=S" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt)); -+} -+ -+#define outl(port, data) \ -+ (/* CONSTCOND */ __use_immediate_port(port) ? __outlc(port, data) : \ -+ __outl(port, data)) -+ -+static __inline void -+__outlc(unsigned port, u_int32_t data) -+{ -+ __asm __volatile("outl %0,%w1" : : "a" (data), "id" (port)); -+} -+ -+static __inline void -+__outl(unsigned port, u_int32_t data) -+{ -+ __asm __volatile("outl %0,%w1" : : "a" (data), "d" (port)); -+} -+ -+static __inline void -+outsl(unsigned port, const void *addr, int cnt) -+{ -+ void *dummy1; -+ int dummy2; -+ __asm __volatile("cld\n\trepne\n\toutsl" : -+ "=S" (dummy1), "=c" (dummy2) : -+ "d" (port), "0" (addr), "1" (cnt)); -+} -+ -+#endif -+ -+ -+static struct pci_io_handle * -+pci_device_netbsd_open_legacy_io(struct pci_io_handle *ret, -+ struct pci_device *dev, pciaddr_t base, pciaddr_t size) -+{ -+#if defined(__i386__) -+ struct i386_iopl_args ia; -+ -+ ia.iopl = 1; -+ if (sysarch(I386_IOPL, &ia)) -+ return NULL; -+ -+ ret->base = base; -+ ret->size = size; -+ return ret; -+#elif defined(__amd64__) -+ struct x86_64_iopl_args ia; -+ -+ ia.iopl = 1; -+ if (sysarch(X86_64_IOPL, &ia)) -+ return NULL; -+ -+ ret->base = base; -+ ret->size = size; -+ return ret; -+#elif defined(PCI_MAGIC_IO_RANGE) -+ ret->memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, -+ aperturefd, PCI_MAGIC_IO_RANGE + base); -+ if (ret->memory == MAP_FAILED) -+ return NULL; -+ -+ ret->base = base; -+ ret->size = size; -+ return ret; -+#else -+ return NULL; -+#endif -+} -+ -+static uint32_t -+pci_device_netbsd_read32(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ return inl(handle->base + reg); -+#else -+ return *(uint32_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint16_t -+pci_device_netbsd_read16(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ return inw(handle->base + reg); -+#else -+ return *(uint16_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint8_t -+pci_device_netbsd_read8(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ return inb(handle->base + reg); -+#else -+ return *(uint8_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static void -+pci_device_netbsd_write32(struct pci_io_handle *handle, uint32_t reg, -+ uint32_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ outl(handle->base + reg, data); -+#else -+ *(uint16_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static void -+pci_device_netbsd_write16(struct pci_io_handle *handle, uint32_t reg, -+ uint16_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ outw(handle->base + reg, data); -+#else -+ *(uint8_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static void -+pci_device_netbsd_write8(struct pci_io_handle *handle, uint32_t reg, -+ uint8_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) -+ outb(handle->base + reg, data); -+#else -+ *(uint32_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static int -+pci_device_netbsd_map_legacy(struct pci_device *dev, pciaddr_t base, -+ pciaddr_t size, unsigned map_flags, void **addr) -+{ -+ struct pci_device_mapping map; -+ int err; -+ -+ map.base = base; -+ map.size = size; -+ map.flags = map_flags; -+ map.memory = NULL; -+ err = pci_device_netbsd_map_range(dev, &map); -+ *addr = map.memory; -+ -+ return err; -+} -+ -+static int -+pci_device_netbsd_unmap_legacy(struct pci_device *dev, void *addr, -+ pciaddr_t size) -+{ -+ struct pci_device_mapping map; -+ -+ map.memory = addr; -+ map.size = size; -+ map.flags = 0; -+ return pci_device_netbsd_unmap_range(dev, &map); -+} -+ - static const struct pci_system_methods netbsd_pci_methods = { -- pci_system_netbsd_destroy, -- NULL, -- NULL, -- pci_device_netbsd_probe, -- pci_device_netbsd_map_range, -- pci_device_netbsd_unmap_range, -- pci_device_netbsd_read, -- pci_device_netbsd_write, -- pci_fill_capabilities_generic -+ .destroy = pci_system_netbsd_destroy, -+ .destroy_device = NULL, -+ .read_rom = pci_device_netbsd_read_rom, -+ .probe = pci_device_netbsd_probe, -+ .map_range = pci_device_netbsd_map_range, -+ .unmap_range = pci_device_netbsd_unmap_range, -+ .read = pci_device_netbsd_read, -+ .write = pci_device_netbsd_write, -+ .fill_capabilities = pci_fill_capabilities_generic, -+#if defined(WSDISPLAYIO_GET_BUSID) -+ .boot_vga = pci_device_netbsd_boot_vga, -+#else -+ .boot_vga = NULL, -+#endif -+ .open_legacy_io = pci_device_netbsd_open_legacy_io, -+ .read32 = pci_device_netbsd_read32, -+ .read16 = pci_device_netbsd_read16, -+ .read8 = pci_device_netbsd_read8, -+ .write32 = pci_device_netbsd_write32, -+ .write16 = pci_device_netbsd_write16, -+ .write8 = pci_device_netbsd_write8, -+ .map_legacy = pci_device_netbsd_map_legacy, -+ .unmap_legacy = pci_device_netbsd_unmap_legacy, - }; - - int - pci_system_netbsd_create(void) - { - struct pci_device_private *device; -- int bus, dev, func, ndevs, nfuncs; -+ int bus, dev, func, ndevs, nfuncs, domain, pcifd; - uint32_t reg; -- -- pcifd = open("/dev/pci0", O_RDWR | O_CLOEXEC); -- if (pcifd == -1) -- return ENXIO; -+ char netbsd_devname[32]; -+ struct pciio_businfo businfo; - - pci_sys = calloc(1, sizeof(struct pci_system)); -- if (pci_sys == NULL) { -- close(pcifd); -- return ENOMEM; -- } - - pci_sys->methods = &netbsd_pci_methods; - - ndevs = 0; -- for (bus = 0; bus < 256; bus++) { -- for (dev = 0; dev < 32; dev++) { -- nfuncs = pci_nfuncs(bus, dev); -+ nbuses = 0; -+ snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses); -+ pcifd = open(netbsd_devname, O_RDWR); -+ while (pcifd > 0) { -+ ioctl(pcifd, PCI_IOC_BUSINFO, &businfo); -+ buses[nbuses].fd = pcifd; -+ buses[nbuses].num = bus = businfo.busno; -+ buses[nbuses].maxdevs = businfo.maxdevs; -+ domain = nbuses; -+ nbuses++; -+ for (dev = 0; dev < businfo.maxdevs; dev++) { -+ nfuncs = pci_nfuncs(domain, bus, dev); - for (func = 0; func < nfuncs; func++) { -- if (pci_read(bus, dev, func, PCI_ID_REG, -+ if (pci_read(domain, bus, dev, func, PCI_ID_REG, - ®) != 0) - continue; - if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID || -@@ -355,37 +910,43 @@ pci_system_netbsd_create(void) - ndevs++; - } - } -+ snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses); -+ pcifd = open(netbsd_devname, O_RDWR); - } - - pci_sys->num_devices = ndevs; - pci_sys->devices = calloc(ndevs, sizeof(struct pci_device_private)); - if (pci_sys->devices == NULL) { -+ int i; -+ -+ for (i = 0; i < nbuses; i++) -+ close(buses[i].fd); - free(pci_sys); -- close(pcifd); - return ENOMEM; - } - - device = pci_sys->devices; -- for (bus = 0; bus < 256; bus++) { -- for (dev = 0; dev < 32; dev++) { -- nfuncs = pci_nfuncs(bus, dev); -+ for (domain = 0; domain < nbuses; domain++) { -+ bus = buses[domain].num; -+ for (dev = 0; dev < buses[domain].maxdevs; dev++) { -+ nfuncs = pci_nfuncs(domain, bus, dev); - for (func = 0; func < nfuncs; func++) { -- if (pci_read(bus, dev, func, PCI_ID_REG, -- ®) != 0) -+ if (pci_read(domain, bus, dev, func, -+ PCI_ID_REG, ®) != 0) - continue; - if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID || - PCI_VENDOR(reg) == 0) - continue; - -- device->base.domain = 0; -+ device->base.domain = domain; - device->base.bus = bus; - device->base.dev = dev; - device->base.func = func; - device->base.vendor_id = PCI_VENDOR(reg); - device->base.device_id = PCI_PRODUCT(reg); - -- if (pci_read(bus, dev, func, PCI_CLASS_REG, -- ®) != 0) -+ if (pci_read(domain, bus, dev, func, -+ PCI_CLASS_REG, ®) != 0) - continue; - - device->base.device_class = -@@ -393,8 +954,8 @@ pci_system_netbsd_create(void) - PCI_SUBCLASS(reg) << 8; - device->base.revision = PCI_REVISION(reg); - -- if (pci_read(bus, dev, func, PCI_SUBSYS_ID_REG, -- ®) != 0) -+ if (pci_read(domain, bus, dev, func, -+ PCI_SUBSYS_ID_REG, ®) != 0) - continue; - - device->base.subvendor_id = PCI_VENDOR(reg); diff --git a/sysutils/libpciaccess/patches/patch-configure b/sysutils/libpciaccess/patches/patch-configure new file mode 100644 index 00000000000..a62bf9ff468 --- /dev/null +++ b/sysutils/libpciaccess/patches/patch-configure @@ -0,0 +1,23 @@ +$NetBSD: patch-configure,v 1.1 2013/07/21 09:42:40 wiz Exp $ + +Fix + CCLD scanpci +../src/.libs/libpciaccess.so: undefined reference to `gzopen' +../src/.libs/libpciaccess.so: undefined reference to `gzclose' +../src/.libs/libpciaccess.so: undefined reference to `gzgets' + +--- configure.orig 2013-07-21 09:36:37.000000000 +0000 ++++ configure +@@ -18015,10 +18015,10 @@ case $host_os in + *netbsd*) + case $host in + *i386*) +- PCIACCESS_LIBS="-li386 -lpci" ++ PCIACCESS_LIBS="$PCIACCESS_LIBS -li386 -lpci" + ;; + *x86_64*|*amd64*) +- PCIACCESS_LIBS="-lx86_64 -lpci" ++ PCIACCESS_LIBS="$PCIACCESS_LIBS -lx86_64 -lpci" + ;; + esac + netbsd=yes diff --git a/sysutils/libpciaccess/patches/patch-configure.ac b/sysutils/libpciaccess/patches/patch-configure.ac deleted file mode 100644 index c79ecc727c1..00000000000 --- a/sysutils/libpciaccess/patches/patch-configure.ac +++ /dev/null @@ -1,51 +0,0 @@ -$NetBSD: patch-configure.ac,v 1.1 2013/05/15 03:20:15 richard Exp $ - -configure: Remove AM_MAINTAINER_MODE - -Check for libpci and mtrr headers on NetBSD. ---- configure.ac.orig 2012-04-09 17:04:39.000000000 +0000 -+++ configure.ac -@@ -30,7 +30,6 @@ AC_CONFIG_HEADERS([config.h]) - - # Initialize Automake - AM_INIT_AUTOMAKE([foreign dist-bzip2]) --AM_MAINTAINER_MODE - AC_USE_SYSTEM_EXTENSIONS - - # Initialize libtool -@@ -77,11 +77,11 @@ case $host_os in - ;; - *netbsd*) - case $host in -- *i386*) -- PCIACCESS_LIBS="-li386" -+ *i[[3-9]]86*) -+ PCIACCESS_LIBS="-li386 $PCIACCESS_LIBS" - ;; - *x86_64*|*amd64*) -- PCIACCESS_LIBS="-lx86_64" -+ PCIACCESS_LIBS="-lx86_64 $PCIACCESS_LIBS" - ;; - esac - netbsd=yes -@@ -109,7 +109,20 @@ AC_SYS_LARGEFILE - - AC_CHECK_HEADERS([err.h]) - -+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_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-scanpci_Makefile.am b/sysutils/libpciaccess/patches/patch-scanpci_Makefile.am deleted file mode 100644 index e3558ecf586..00000000000 --- a/sysutils/libpciaccess/patches/patch-scanpci_Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -$NetBSD: patch-scanpci_Makefile.am,v 1.1 2013/05/15 03:20:16 richard Exp $ - -scanpci: print meaningful info on BASEROM - ---- scanpci/Makefile.am.orig 2012-04-09 17:02:57.000000000 +0000 -+++ scanpci/Makefile.am -@@ -23,7 +23,7 @@ - - noinst_PROGRAMS = scanpci - --AM_CPPFLAGS = -I$(top_srcdir)/include -+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src - LDADD = $(top_builddir)/src/libpciaccess.la - - scanpci_SOURCES = scanpci.c diff --git a/sysutils/libpciaccess/patches/patch-scanpci_scanpci.c b/sysutils/libpciaccess/patches/patch-scanpci_scanpci.c deleted file mode 100644 index 69017269e3d..00000000000 --- a/sysutils/libpciaccess/patches/patch-scanpci_scanpci.c +++ /dev/null @@ -1,28 +0,0 @@ -$NetBSD: patch-scanpci_scanpci.c,v 1.1 2013/05/15 03:20:16 richard Exp $ - -scanpci: print meaningful info on BASEROM - ---- scanpci/scanpci.c.orig 2012-04-09 17:02:57.000000000 +0000 -+++ scanpci/scanpci.c -@@ -47,6 +47,7 @@ - #endif - - #include "pciaccess.h" -+#include "pciaccess_private.h" - - - static void -@@ -168,8 +169,11 @@ print_pci_device( struct pci_device * de - } - - if ( dev->rom_size ) { -- printf( " BASEROM 0x%08x addr 0x%08x\n", -- 0, 0 ); -+ struct pci_device_private *priv = -+ (struct pci_device_private *) dev; -+ -+ printf( " BASEROM 0x%08"PRIxPTR" SIZE %zu\n", -+ (intptr_t) priv->rom_base, (size_t) dev->rom_size); - } - - pci_device_cfg_read_u8( dev, & int_pin, 61 ); diff --git a/sysutils/libpciaccess/patches/patch-src_common__bridge.c b/sysutils/libpciaccess/patches/patch-src_common__bridge.c deleted file mode 100644 index cb5b6bd3f19..00000000000 --- a/sysutils/libpciaccess/patches/patch-src_common__bridge.c +++ /dev/null @@ -1,25 +0,0 @@ -$NetBSD: patch-src_common__bridge.c,v 1.1 2013/05/15 03:20:16 richard Exp $ - -PCI: set correct mask value when matching for bridges. -The mask must not be zero otherwise the matching condition will never be true: ((val & mask) == set). - ---- src/common_bridge.c.orig 2012-04-09 17:02:57.000000000 +0000 -+++ src/common_bridge.c -@@ -321,6 +321,8 @@ pci_device_get_bridge_buses(struct pci_d - - #define PCI_CLASS_BRIDGE 0x06 - #define PCI_SUBCLASS_BRIDGE_PCI 0x04 -+#define PCI_CLASS_MASK 0xFF -+#define PCI_SUBCLASS_MASK 0xFF - - struct pci_device * - pci_device_get_parent_bridge(struct pci_device *dev) -@@ -328,7 +330,7 @@ pci_device_get_parent_bridge(struct pci_ - struct pci_id_match bridge_match = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, - (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8), -- 0 -+ (PCI_CLASS_MASK << 16) | (PCI_SUBCLASS_MASK << 8) - }; - - struct pci_device *bridge; diff --git a/sysutils/libpciaccess/patches/patch-src_freebsd__pci.c b/sysutils/libpciaccess/patches/patch-src_freebsd__pci.c deleted file mode 100644 index 58b27b7257c..00000000000 --- a/sysutils/libpciaccess/patches/patch-src_freebsd__pci.c +++ /dev/null @@ -1,174 +0,0 @@ -$NetBSD: patch-src_freebsd__pci.c,v 1.1 2013/05/18 13:46:35 wiz Exp $ - -https://bugs.freedesktop.org/attachment.cgi?id=78130 - ---- src/freebsd_pci.c.orig 2013-05-17 21:55:52.935930000 +0000 -+++ src/freebsd_pci.c -@@ -1,6 +1,8 @@ - /* - * (C) Copyright Eric Anholt 2006 - * (C) Copyright IBM Corporation 2006 -+ * (C) Copyright Mark Kettenis 2011 -+ * (C) Copyright Robert Millan 2012 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a -@@ -561,6 +563,139 @@ pci_system_freebsd_destroy(void) - freebsd_pci_sys = NULL; - } - -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+#include <machine/cpufunc.h> -+#endif -+ -+static struct pci_io_handle * -+pci_device_freebsd_open_legacy_io(struct pci_io_handle *ret, -+ struct pci_device *dev, pciaddr_t base, pciaddr_t size) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ ret->fd = open("/dev/io", O_RDWR | O_CLOEXEC); -+ -+ if (ret->fd < 0) -+ return NULL; -+ -+ ret->base = base; -+ ret->size = size; -+ return ret; -+#elif defined(PCI_MAGIC_IO_RANGE) -+ ret->memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, -+ aperturefd, PCI_MAGIC_IO_RANGE + base); -+ if (ret->memory == MAP_FAILED) -+ return NULL; -+ -+ ret->base = base; -+ ret->size = size; -+ return ret; -+#else -+ return NULL; -+#endif -+} -+ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+static void -+pci_device_freebsd_close_io(struct pci_device *dev, struct pci_io_handle *handle) -+{ -+ if (handle->fd > -1) -+ close(handle->fd); -+} -+#endif -+ -+static uint32_t -+pci_device_freebsd_read32(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ return inl(handle->base + reg); -+#else -+ return *(uint32_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint16_t -+pci_device_freebsd_read16(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ return inw(handle->base + reg); -+#else -+ return *(uint16_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint8_t -+pci_device_freebsd_read8(struct pci_io_handle *handle, uint32_t reg) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ return inb(handle->base + reg); -+#else -+ return *(uint8_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static void -+pci_device_freebsd_write32(struct pci_io_handle *handle, uint32_t reg, -+ uint32_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ outl(handle->base + reg, data); -+#else -+ *(uint16_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static void -+pci_device_freebsd_write16(struct pci_io_handle *handle, uint32_t reg, -+ uint16_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ outw(handle->base + reg, data); -+#else -+ *(uint8_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static void -+pci_device_freebsd_write8(struct pci_io_handle *handle, uint32_t reg, -+ uint8_t data) -+{ -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ outb(handle->base + reg, data); -+#else -+ *(uint32_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static int -+pci_device_freebsd_map_legacy(struct pci_device *dev, pciaddr_t base, -+ pciaddr_t size, unsigned map_flags, void **addr) -+{ -+ struct pci_device_mapping map; -+ int err; -+ -+ map.base = base; -+ map.size = size; -+ map.flags = map_flags; -+ map.memory = NULL; -+ err = pci_device_freebsd_map_range(dev, &map); -+ *addr = map.memory; -+ -+ return err; -+} -+ -+static int -+pci_device_freebsd_unmap_legacy(struct pci_device *dev, void *addr, -+ pciaddr_t size) -+{ -+ struct pci_device_mapping map; -+ -+ map.memory = addr; -+ map.size = size; -+ map.flags = 0; -+ return pci_device_freebsd_unmap_range(dev, &map); -+} -+ -+ - static const struct pci_system_methods freebsd_pci_methods = { - .destroy = pci_system_freebsd_destroy, - .destroy_device = NULL, /* nothing to do for this */ -@@ -571,6 +706,18 @@ static const struct pci_system_methods f - .read = pci_device_freebsd_read, - .write = pci_device_freebsd_write, - .fill_capabilities = pci_fill_capabilities_generic, -+ .open_legacy_io = pci_device_freebsd_open_legacy_io, -+#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) -+ .close_io = pci_device_freebsd_close_io, -+#endif -+ .read32 = pci_device_freebsd_read32, -+ .read16 = pci_device_freebsd_read16, -+ .read8 = pci_device_freebsd_read8, -+ .write32 = pci_device_freebsd_write32, -+ .write16 = pci_device_freebsd_write16, -+ .write8 = pci_device_freebsd_write8, -+ .map_legacy = pci_device_freebsd_map_legacy, -+ .unmap_legacy = pci_device_freebsd_unmap_legacy, - }; - - /** diff --git a/sysutils/libpciaccess/patches/patch-src_pciaccess__private.h b/sysutils/libpciaccess/patches/patch-src_pciaccess__private.h deleted file mode 100644 index 498dec711e3..00000000000 --- a/sysutils/libpciaccess/patches/patch-src_pciaccess__private.h +++ /dev/null @@ -1,16 +0,0 @@ -$NetBSD: patch-src_pciaccess__private.h,v 1.1 2013/05/15 03:20:16 richard Exp $ - -libpciaccess: implementation of boot_vga in Solaris - ---- src/pciaccess_private.h.orig 2012-04-09 17:02:57.000000000 +0000 -+++ src/pciaccess_private.h -@@ -146,6 +146,9 @@ struct pci_device_private { - struct pci_device_mapping *mappings; - unsigned num_mappings; - /*@}*/ -+#ifdef __sun -+ int is_primary; -+#endif - }; - - diff --git a/sysutils/libpciaccess/patches/patch-src_solx__devfs.c b/sysutils/libpciaccess/patches/patch-src_solx__devfs.c deleted file mode 100644 index 4519dba7d85..00000000000 --- a/sysutils/libpciaccess/patches/patch-src_solx__devfs.c +++ /dev/null @@ -1,1153 +0,0 @@ -$NetBSD: patch-src_solx__devfs.c,v 1.1 2013/05/15 03:20:16 richard Exp $ - -Solaris: probe improvementHEADmaster -Remove pcitool dependency in probing phase. Use the data collected from devinfo tree instead in creating pci file system. - -Solaris: Add domain support for sparc platform -As a result the code of finding nexus node for a device in sparc is simplified and made the same as x86. - -libpciaccess: sparc rom read fix -Get rom address and size from device's "assigned-addresses" property if they exist. - -libpciaccess: implementation of boot_vga in Solaris - -libpciaccess: fix memory usage errors -This patch fixes memory usage errors that only occur on large SPARC machines with more than 256 PCI devices. In this case, memory is being used after it has been freed by calls to both free() and realloc(). This error was introduced by a previous patch: 2011-03-30 Solaris support for multiple PCI segments (domains) - -Solaris: Implement map_legacy & legacy_io functions - -Solaris: refactor pci_device_solx_devfs_map_range to reduce code duplication -The sparc & x86 cases were doing essentially the same things with different paths, so make the path setup be inside the platform specific #ifdefs, make the open, mmap, & error handling common code. - ---- src/solx_devfs.c.orig 2012-04-09 17:02:57.000000000 +0000 -+++ src/solx_devfs.c -@@ -1,6 +1,6 @@ - /* - * (C) Copyright IBM Corporation 2006 -- * Copyright (c) 2007, 2009, 2011, Oracle and/or its affiliates. -+ * Copyright (c) 2007, 2009, 2011, 2012, 2013 Oracle and/or its affiliates. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a -@@ -38,6 +38,11 @@ - #include <libdevinfo.h> - #include "pci_tools.h" - -+#ifdef __x86 -+# include <sys/sysi86.h> -+# include <sys/psw.h> -+#endif -+ - #include "pciaccess.h" - #include "pciaccess_private.h" - -@@ -46,11 +51,6 @@ - #define INITIAL_NUM_DEVICES 256 - #define CELL_NUMS_1275 (sizeof(pci_regspec_t) / sizeof(uint_t)) - --typedef union { -- uint8_t bytes[16 * sizeof (uint32_t)]; -- uint32_t dwords[16]; --} pci_conf_hdr_t; -- - typedef struct i_devnode { - uint8_t bus; - uint8_t dev; -@@ -66,11 +66,6 @@ typedef struct nexus { - char *path; /* for errors/debugging; fd is all we need */ - char *dev_path; - struct nexus *next; --#ifdef __sparc -- struct pci_device **devlist; -- volatile size_t num_allocated_elems; -- volatile size_t num_devices; --#endif - } nexus_t; - - typedef struct probe_info { -@@ -79,6 +74,17 @@ typedef struct probe_info { - struct pci_device_private * volatile devices; - } probe_info_t; - -+typedef struct probe_args { -+ probe_info_t *pinfo; -+ nexus_t *nexus; -+ int ret; -+} probe_args_t; -+ -+typedef struct property_info { -+ const char *name; -+ int value; -+} property_info_t; -+ - static nexus_t *nexus_list = NULL; - #if !defined(__sparc) - static int xsvc_fd = -1; -@@ -86,6 +92,7 @@ static int xsvc_fd = -1; - - #ifdef __sparc - static di_prom_handle_t di_phdl; -+static size_t nexus_count = 0; - #endif - - /* -@@ -126,22 +133,6 @@ static di_prom_handle_t di_phdl; - # define U45_SB_CLASS_RID 0x06040000 - #endif - --#ifdef __sparc --static nexus_t * --find_nexus_for_dev(struct pci_device *dev) --{ -- nexus_t *nexus; -- int i; -- -- for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) { -- for (i = 0; i < nexus->num_devices; i++) { -- if (nexus->devlist[i] == dev) -- return nexus; -- } -- } -- return NULL; --} --#else - static nexus_t * - find_nexus_for_bus( int domain, int bus ) - { -@@ -155,16 +146,6 @@ find_nexus_for_bus( int domain, int bus - } - return NULL; - } --#endif -- --#define GET_CONFIG_VAL_8(offset) (config_hdr.bytes[offset]) --#define GET_CONFIG_VAL_16(offset) \ -- (uint16_t) (GET_CONFIG_VAL_8(offset) + (GET_CONFIG_VAL_8(offset+1) << 8)) --#define GET_CONFIG_VAL_32(offset) \ -- (uint32_t) (GET_CONFIG_VAL_8(offset) + \ -- (GET_CONFIG_VAL_8(offset+1) << 8) + \ -- (GET_CONFIG_VAL_8(offset+2) << 16) + \ -- (GET_CONFIG_VAL_8(offset+3) << 24)) - - /* - * Release all the resources -@@ -185,19 +166,6 @@ pci_system_solx_devfs_destroy( void ) - close(nexus->fd); - free(nexus->path); - free(nexus->dev_path); --#ifdef __sparc -- { -- struct pci_device *dev; -- int i; -- -- for (i = 0; i < nexus->num_devices; i++) { -- dev = nexus->devlist[i]; -- if (MAPPING_DEV_PATH(dev)) -- di_devfs_path_free((char *) MAPPING_DEV_PATH(dev)); -- } -- } -- free(nexus->devlist); --#endif - free(nexus); - } - nexus_list = NULL; -@@ -213,316 +181,122 @@ pci_system_solx_devfs_destroy( void ) - #endif - } - -+ -+#ifdef __sparc - /* -- * Retrieve first 16 dwords of device's config header, except for the first -- * dword. First 16 dwords are defined by the PCI specification. -+ * Release resources per device - */ --static int --get_config_header(int fd, uint8_t bus_no, uint8_t dev_no, uint8_t func_no, -- pci_conf_hdr_t *config_hdr_p) -+static void -+pci_system_solx_devfs_destroy_device( struct pci_device *dev ) - { -- pcitool_reg_t cfg_prg; -- int i; -- int rval = 0; -- -- /* Prepare a local pcitool_reg_t so as to not disturb the caller's. */ -- cfg_prg.offset = 0; -- cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN; -- cfg_prg.bus_no = bus_no; -- cfg_prg.dev_no = dev_no; -- cfg_prg.func_no = func_no; -- cfg_prg.barnum = 0; -- cfg_prg.user_version = PCITOOL_USER_VERSION; -- -- /* Get dwords 1-15 of config space. They must be read as uint32_t. */ -- for (i = 1; i < (sizeof (pci_conf_hdr_t) / sizeof (uint32_t)); i++) { -- cfg_prg.offset += sizeof (uint32_t); -- if ((rval = ioctl(fd, PCITOOL_DEVICE_GET_REG, &cfg_prg)) != 0) { -- break; -- } -- config_hdr_p->dwords[i] = (uint32_t)cfg_prg.data; -- } -- -- return (rval); -+ if (MAPPING_DEV_PATH(dev)) -+ di_devfs_path_free((char *) MAPPING_DEV_PATH(dev)); - } -+#endif - - --/* -- * Probe device's functions. Modifies many fields in the prg_p. -- */ - static int --probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, probe_info_t *pinfo) -+probe_device_node(di_node_t node, void *arg) - { -- pci_conf_hdr_t config_hdr; -- boolean_t multi_function_device; -- int8_t func; -- int8_t first_func = 0; -- int8_t last_func = PCI_REG_FUNC_M >> PCI_REG_FUNC_SHIFT; -- int rval = 0; -- struct pci_device * pci_base; -- -- /* -- * Loop through at least func=first_func. Continue looping through -- * functions if there are no errors and the device is a multi-function -- * device. -- * -- * (Note, if first_func == 0, header will show whether multifunction -- * device and set multi_function_device. If first_func != 0, then we -- * will force the loop as the user wants a specific function to be -- * checked. -- */ -- for (func = first_func, multi_function_device = B_FALSE; -- ((func <= last_func) && -- ((func == first_func) || (multi_function_device))); -- func++) { -- prg_p->func_no = func; -- -- /* -- * Four things can happen here: -- * -- * 1) ioctl comes back as EFAULT and prg_p->status is -- * PCITOOL_INVALID_ADDRESS. There is no device at this location. -- * -- * 2) ioctl comes back successful and the data comes back as -- * zero. Config space is mapped but no device responded. -- * -- * 3) ioctl comes back successful and the data comes back as -- * non-zero. We've found a device. -- * -- * 4) Some other error occurs in an ioctl. -- */ -- -- prg_p->status = PCITOOL_SUCCESS; -- prg_p->offset = 0; -- prg_p->data = 0; -- prg_p->user_version = PCITOOL_USER_VERSION; -- -- errno = 0; -- if (((rval = ioctl(nexus->fd, PCITOOL_DEVICE_GET_REG, prg_p)) != 0) || -- (prg_p->data == 0xffffffff)) { -- -- /* -- * Accept errno == EINVAL along with status of -- * PCITOOL_OUT_OF_RANGE because some systems -- * don't implement the full range of config space. -- * Leave the loop quietly in this case. -- */ -- if ((errno == EINVAL) || -- (prg_p->status == PCITOOL_OUT_OF_RANGE)) { -- break; -- } -+ int *retbuf = NULL; -+ int len = 0, i; -+ struct pci_device *pci_base; -+ probe_info_t *pinfo = ((probe_args_t *)arg)->pinfo; -+ nexus_t *nexus = ((probe_args_t *)arg)->nexus; -+ property_info_t property_list[] = { -+ { "class-code", 0 }, -+ { "device-id", 0 }, -+ { "vendor-id", 0 }, -+ { "revision-id", 0}, -+ { "subsystem-vendor-id", 0}, -+ { "subsystem-id", 0}, -+ }; -+#define NUM_PROPERTIES sizeof(property_list)/sizeof(property_info_t) - -- /* -- * Exit silently with ENXIO as this means that there are -- * no devices under the pci root nexus. -- */ -- else if ((errno == ENXIO) && -- (prg_p->status == PCITOOL_IO_ERROR)) { -- break; -- } -+ len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", &retbuf); - -- /* -- * Expect errno == EFAULT along with status of -- * PCITOOL_INVALID_ADDRESS because there won't be -- * devices at each stop. Quit on any other error. -- */ -- else if (((errno != EFAULT) || -- (prg_p->status != PCITOOL_INVALID_ADDRESS)) && -- (prg_p->data != 0xffffffff)) { - #ifdef __sparc --/* on sparc, devices can be enumerated discontiguously. Do not quit */ -- rval = 0; -+ if ((len <= 0) && di_phdl) -+ len = di_prom_prop_lookup_ints(di_phdl, node, "reg", &retbuf); - #endif -- break; -- } - -- /* -- * If no function at this location, -- * just advance to the next function. -- */ -- else { -- rval = 0; -- } -- -- /* -- * Data came back as 0. -- * Treat as unresponsive device and check next device. -- */ -- } else if (prg_p->data == 0) { -- rval = 0; -- break; /* Func loop. */ -- -- /* Found something. */ -- } else { -- config_hdr.dwords[0] = (uint32_t)prg_p->data; -- -- /* Get the rest of the PCI header. */ -- if ((rval = get_config_header(nexus->fd, prg_p->bus_no, -- prg_p->dev_no, prg_p->func_no, -- &config_hdr)) != 0) { -- break; -- } -- -- /* -- * Special case for the type of Southbridge found on -- * Ultra-45 and other sun4u fire workstations. -- */ -- if ((config_hdr.dwords[0] == U45_SB_DEVID_VID) && -- (config_hdr.dwords[2] == U45_SB_CLASS_RID)) { -- rval = ECANCELED; -- break; -- } -- -- /* -- * Found one device with bus number, device number and -- * function number. -- */ -- -- pci_base = &pinfo->devices[pinfo->num_devices].base; -- -- pci_base->domain = nexus->domain; -- pci_base->bus = prg_p->bus_no; -- pci_base->dev = prg_p->dev_no; -- pci_base->func = func; -- -- /* -- * for the format of device_class, see struct pci_device; -- */ -- -- pci_base->device_class = -- (GET_CONFIG_VAL_8(PCI_CONF_BASCLASS) << 16) | -- (GET_CONFIG_VAL_8(PCI_CONF_SUBCLASS) << 8) | -- GET_CONFIG_VAL_8(PCI_CONF_PROGCLASS); -- -- pci_base->revision = GET_CONFIG_VAL_8(PCI_CONF_REVID); -- pci_base->vendor_id = GET_CONFIG_VAL_16(PCI_CONF_VENID); -- pci_base->device_id = GET_CONFIG_VAL_16(PCI_CONF_DEVID); -- pci_base->subvendor_id = GET_CONFIG_VAL_16(PCI_CONF_SUBVENID); -- pci_base->subdevice_id = GET_CONFIG_VAL_16(PCI_CONF_SUBSYSID); -- pci_base->irq = GET_CONFIG_VAL_8(PCI_CONF_ILINE); -+ /* Exclude usb devices */ -+ if (len < 5) { -+ return DI_WALK_CONTINUE; -+ } - -- pinfo->devices[pinfo->num_devices].header_type -- = GET_CONFIG_VAL_8(PCI_CONF_HEADER); -+ pci_base = &pinfo->devices[pinfo->num_devices].base; - --#ifdef DEBUG -- fprintf(stderr, -- "nexus = %s, busno = %x, devno = %x, funcno = %x\n", -- nexus->path, prg_p->bus_no, prg_p->dev_no, func); --#endif -- -- pinfo->num_devices++; -- if (pinfo->num_devices == pinfo->num_allocated_elems) { -- struct pci_device_private *new_devs; -- size_t new_num_elems = pinfo->num_allocated_elems * 2; -- -- new_devs = realloc(pinfo->devices, -- new_num_elems * sizeof (struct pci_device_private)); -- if (new_devs == NULL) { -- (void) fprintf(stderr, -- "Error allocating memory for PCI devices:" -- " %s\n discarding additional devices\n", -- strerror(errno)); -- return (rval); -- } -- (void) memset(&new_devs[pinfo->num_devices], 0, -- pinfo->num_allocated_elems * -- sizeof (struct pci_device_private)); -- pinfo->num_allocated_elems = new_num_elems; -- pinfo->devices = new_devs; -- } -+ pci_base->domain = nexus->domain; -+ pci_base->bus = PCI_REG_BUS_G(retbuf[0]); -+ pci_base->dev = PCI_REG_DEV_G(retbuf[0]); -+ pci_base->func = PCI_REG_FUNC_G(retbuf[0]); - -+ /* Get property values */ -+ for (i = 0; i < NUM_PROPERTIES; i++) { -+ len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, -+ property_list[i].name, &retbuf); - #ifdef __sparc -- nexus->devlist[nexus->num_devices++] = pci_base; -- -- if (nexus->num_devices == nexus->num_allocated_elems) { -- struct pci_device **new_devs; -- size_t new_num_elems = nexus->num_allocated_elems * 2; -- -- new_devs = realloc(nexus->devlist, -- new_num_elems * sizeof (struct pci_device *)); -- if (new_devs == NULL) -- return (rval); -- (void) memset(&new_devs[nexus->num_devices], 0, -- nexus->num_allocated_elems * -- sizeof (struct pci_device *)); -- nexus->num_allocated_elems = new_num_elems; -- nexus->devlist = new_devs; -- } -+ if ((len <= 0) && di_phdl) -+ len = di_prom_prop_lookup_ints(di_phdl, node, -+ property_list[i].name, &retbuf); - #endif - -- /* -- * Accommodate devices which state their -- * multi-functionality only in their function 0 config -- * space. Note multi-functionality throughout probing -- * of all of this device's functions. -- */ -- if (config_hdr.bytes[PCI_CONF_HEADER] & PCI_HEADER_MULTI) { -- multi_function_device = B_TRUE; -- } -+ if (len > 0) -+ property_list[i].value = retbuf[0]; -+ else { -+ /* a device must have property "class-code", "device-id", "vendor-id" */ -+ if (i < 3) -+ return DI_WALK_CONTINUE; -+#ifdef DEBUG -+ fprintf(stderr, "cannot get property \"%s\" for nexus = %s :\n", -+ property_list[i].name, nexus->path); -+ fprintf(stderr, " domain = %x, busno = %x, devno = %x, funcno = %x\n", -+ pci_base->domain, pci_base->bus, pci_base->dev, pci_base->func); -+#endif - } - } - -- return (rval); --} -+ if ((property_list[1].value == 0) && (property_list[2].value == 0)) -+ return DI_WALK_CONTINUE; - -+ pci_base->device_class = property_list[0].value; -+ pci_base->device_id = property_list[1].value; -+ pci_base->vendor_id = property_list[2].value; -+ pci_base->revision = property_list[3].value; -+ pci_base->subvendor_id = property_list[4].value; -+ pci_base->subdevice_id = property_list[5].value; - --/* -- * Solaris version -- * Probe a given nexus config space for devices. -- * -- * fd is the file descriptor of the nexus. -- * input_args contains commandline options as specified by the user. -- */ --static int --do_probe(nexus_t *nexus, probe_info_t *pinfo) --{ -- pcitool_reg_t prg; -- uint32_t bus; -- uint8_t dev; -- uint32_t last_bus = nexus->last_bus; -- uint8_t last_dev = PCI_REG_DEV_M >> PCI_REG_DEV_SHIFT; -- uint8_t first_bus = nexus->first_bus; -- uint8_t first_dev = 0; -- int rval = 0; -- -- prg.barnum = 0; /* Config space. */ -- -- /* Must read in 4-byte quantities. */ -- prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN; -- -- prg.data = 0; -- -- /* -- * Loop through all valid bus / dev / func combinations to check for -- * all devices, with the following exceptions: -- * -- * When nothing is found at function 0 of a bus / dev combination, skip -- * the other functions of that bus / dev combination. -- * -- * When a found device's function 0 is probed and it is determined that -- * it is not a multifunction device, skip probing of that device's -- * other functions. -- */ -- for (bus = first_bus; ((bus <= last_bus) && (rval == 0)); bus++) { -- prg.bus_no = (uint8_t)bus; -- -- for (dev = first_dev; ((dev <= last_dev) && (rval == 0)); dev++) { -- prg.dev_no = dev; -- rval = probe_dev(nexus, &prg, pinfo); -- } -- -- /* -- * Ultra-45 southbridge workaround: -- * ECANCELED tells to skip to the next bus. -- */ -- if (rval == ECANCELED) { -- rval = 0; -- } -+#ifdef DEBUG -+ fprintf(stderr, -+ "nexus = %s, domain = %x, busno = %x, devno = %x, funcno = %x\n", -+ nexus->path, pci_base->domain, pci_base->bus, pci_base->dev, pci_base->func); -+#endif -+ -+ pinfo->num_devices++; -+ if (pinfo->num_devices == pinfo->num_allocated_elems) { -+ struct pci_device_private *new_devs; -+ size_t new_num_elems = pinfo->num_allocated_elems * 2; -+ -+ new_devs = realloc(pinfo->devices, -+ new_num_elems * sizeof (struct pci_device_private)); -+ if (new_devs == NULL) { -+ (void) fprintf(stderr, -+ "Error allocating memory for PCI devices:" -+ " %s\n discarding additional devices\n", -+ strerror(errno)); -+ ((probe_args_t *)arg)->ret = 1; -+ return (DI_WALK_TERMINATE); -+ } -+ (void) memset(&new_devs[pinfo->num_devices], 0, -+ pinfo->num_allocated_elems * -+ sizeof (struct pci_device_private)); -+ pinfo->num_allocated_elems = new_num_elems; -+ pinfo->devices = new_devs; - } - -- return (rval); -+ return (DI_WALK_CONTINUE); - } -- - /* - * This function is called from di_walk_minor() when any PROBE is processed - */ -@@ -542,6 +316,7 @@ probe_nexus_node(di_node_t di_node, di_m - int pci_node = 0; - int first_bus = 0, last_bus = PCI_REG_BUS_G(PCI_REG_BUS_M); - int domain = 0; -+ di_node_t rnode = DI_NODE_NIL; - #ifdef __sparc - int bus_range_found = 0; - int device_type_found = 0; -@@ -552,6 +327,7 @@ probe_nexus_node(di_node_t di_node, di_m - #ifdef DEBUG - nexus_name = di_devfs_minor_path(minor); - fprintf(stderr, "-- device name: %s\n", nexus_name); -+ di_devfs_path_free(nexus_name); - #endif - - for (prop = di_prop_next(di_node, NULL); prop != NULL; -@@ -591,12 +367,16 @@ probe_nexus_node(di_node_t di_node, di_m - #endif - } - } -+#ifdef __sparc -+ domain = nexus_count; -+#else - else if (strcmp(prop_name, "pciseg") == 0) { - numval = di_prop_ints(prop, &ints); - if (numval == 1) { - domain = ints[0]; - } - } -+#endif - } - - #ifdef __sparc -@@ -636,15 +416,7 @@ probe_nexus_node(di_node_t di_node, di_m - nexus->domain = domain; - - #ifdef __sparc -- if ((nexus->devlist = calloc(INITIAL_NUM_DEVICES, -- sizeof (struct pci_device *))) == NULL) { -- (void) fprintf(stderr, "Error allocating memory for nexus devlist: %s\n", -- strerror(errno)); -- free (nexus); -- return (DI_WALK_TERMINATE); -- } -- nexus->num_allocated_elems = INITIAL_NUM_DEVICES; -- nexus->num_devices = 0; -+ nexus_count++; - #endif - - nexus_name = di_devfs_minor_path(minor); -@@ -664,28 +436,50 @@ probe_nexus_node(di_node_t di_node, di_m - #endif - - if ((fd = open(nexus_path, O_RDWR | O_CLOEXEC)) >= 0) { -+ probe_args_t args; -+ - nexus->fd = fd; - nexus->path = strdup(nexus_path); - nexus_dev_path = di_devfs_path(di_node); - nexus->dev_path = strdup(nexus_dev_path); - di_devfs_path_free(nexus_dev_path); -- if ((do_probe(nexus, pinfo) != 0) && (errno != ENXIO)) { -- (void) fprintf(stderr, "Error probing node %s: %s\n", -- nexus_path, strerror(errno)); -- (void) close(fd); -+ -+ if ((rnode = di_init(nexus->dev_path, DINFOCPYALL)) == DI_NODE_NIL) { -+ (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno)); -+ close(nexus->fd); - free(nexus->path); - free(nexus->dev_path); - free(nexus); -- } else { -- nexus->next = nexus_list; -- nexus_list = nexus; -+ return (DI_WALK_TERMINATE); - } -+ -+ /* Walk through devices under the rnode */ -+ args.pinfo = pinfo; -+ args.nexus = nexus; -+ args.ret = 0; -+ -+ (void) di_walk_node(rnode, DI_WALK_CLDFIRST, (void *)&args, probe_device_node); -+ if (args.ret) { -+ close(nexus->fd); -+ free(nexus->path); -+ free(nexus->dev_path); -+ free(nexus); -+ di_fini(rnode); -+ return (DI_WALK_TERMINATE); -+ } -+ -+ nexus->next = nexus_list; -+ nexus_list = nexus; - } else { - (void) fprintf(stderr, "Error opening %s: %s\n", - nexus_path, strerror(errno)); - free(nexus); - } - -+ if (rnode != DI_NODE_NIL) { -+ di_fini(rnode); -+ } -+ - return DI_WALK_CONTINUE; - } - -@@ -763,15 +557,17 @@ pci_device_solx_devfs_probe( struct pci_ - int i; - int len = 0; - uint ent = 0; -+ struct pci_device_private *priv = -+ (struct pci_device_private *) dev; - nexus_t *nexus; - --#ifdef __sparc -- if ( (nexus = find_nexus_for_dev(dev)) == NULL ) --#else - if ( (nexus = find_nexus_for_bus(dev->domain, dev->bus)) == NULL ) --#endif - return ENODEV; - -+ pci_device_cfg_read_u8(dev, &priv->header_type, PCI_CONF_HEADER); -+ -+ pci_device_cfg_read_u8(dev, (uint8_t *)&dev->irq, PCI_CONF_ILINE); -+ - /* - * starting to find if it is MEM/MEM64/IO - * using libdevinfo -@@ -788,10 +584,13 @@ pci_device_solx_devfs_probe( struct pci_ - } - - if (args.node != DI_NODE_NIL) { -+ int *prop; - #ifdef __sparc - di_minor_t minor; - #endif - -+ priv->is_primary = 0; -+ - #ifdef __sparc - if (minor = di_minor_next(args.node, DI_MINOR_NIL)) - MAPPING_DEV_PATH(dev) = di_devfs_minor_path (minor); -@@ -799,6 +598,12 @@ pci_device_solx_devfs_probe( struct pci_ - MAPPING_DEV_PATH(dev) = NULL; - #endif - -+ if (di_prop_lookup_ints(DDI_DEV_T_ANY, args.node, -+ "primary-controller", &prop) >= 1) { -+ if (prop[0]) -+ priv->is_primary = 1; -+ } -+ - /* - * It will succeed for sure, because it was - * successfully called in find_target_node -@@ -818,83 +623,69 @@ pci_device_solx_devfs_probe( struct pci_ - if (len <= 0) - goto cleanup; - -- - /* -- * how to find the size of rom??? -- * if the device has expansion rom, -- * it must be listed in the last -- * cells because solaris find probe -- * the base address from offset 0x10 -- * to 0x30h. So only check the last -- * item. -- */ -- reg = (pci_regspec_t *)®buf[len - CELL_NUMS_1275]; -- if (PCI_REG_REG_G(reg->pci_phys_hi) == PCI_CONF_ROM) { -- /* -- * rom can only be 32 bits -- */ -- dev->rom_size = reg->pci_size_low; -- len = len - CELL_NUMS_1275; -- } -- else { -- /* -- * size default to 64K and base address -- * default to 0xC0000 -- */ -- dev->rom_size = 0x10000; -- } -- -- /* -- * Solaris has its own BAR index. -+ * Each BAR address get its own region slot in sequence. -+ * 32 bit BAR: -+ * BAR 0x10 -> slot0, BAR 0x14 -> slot1... -+ * 64 bit BAR: -+ * BAR 0x10 -> slot0, BAR 0x18 -> slot2..., -+ * slot1 is part of BAR 0x10 - * Linux give two region slot for 64 bit address. - */ - for (i = 0; i < len; i = i + CELL_NUMS_1275) { - - reg = (pci_regspec_t *)®buf[i]; - ent = reg->pci_phys_hi & 0xff; -- /* -- * G35 broken in BAR0 -- */ -- ent = (ent - PCI_CONF_BASE0) >> 2; -- if (ent >= 6) { -+ -+ if (ent > PCI_CONF_ROM) { - fprintf(stderr, "error ent = %d\n", ent); - break; - } -- - /* -- * non relocatable resource is excluded -- * such like 0xa0000, 0x3b0. If it is met, -- * the loop is broken; -+ * G35 broken in BAR0 - */ -- if (!PCI_REG_REG_G(reg->pci_phys_hi)) -+ if (ent < PCI_CONF_BASE0) { -+ /* -+ * VGA resource here and ignore it -+ */ - break; -+ } else if (ent == PCI_CONF_ROM) { -+ priv->rom_base = reg->pci_phys_low | -+ ((uint64_t)reg->pci_phys_mid << 32); -+ dev->rom_size = reg->pci_size_low; -+ } else { -+ ent = (ent - PCI_CONF_BASE0) >> 2; -+ /* -+ * non relocatable resource is excluded -+ * such like 0xa0000, 0x3b0. If it is met, -+ * the loop is broken; -+ */ -+ if (!PCI_REG_REG_G(reg->pci_phys_hi)) -+ break; - -- if (reg->pci_phys_hi & PCI_PREFETCH_B) { -- dev->regions[ent].is_prefetchable = 1; -- } -+ if (reg->pci_phys_hi & PCI_PREFETCH_B) { -+ dev->regions[ent].is_prefetchable = 1; -+ } - - -- /* -- * We split the shift count 32 into two 16 to -- * avoid the complaining of the compiler -- */ -- dev->regions[ent].base_addr = reg->pci_phys_low + -- ((reg->pci_phys_mid << 16) << 16); -- dev->regions[ent].size = reg->pci_size_low + -- ((reg->pci_size_hi << 16) << 16); -- -- switch (reg->pci_phys_hi & PCI_REG_ADDR_M) { -- case PCI_ADDR_IO: -- dev->regions[ent].is_IO = 1; -- break; -- case PCI_ADDR_MEM32: -- break; -- case PCI_ADDR_MEM64: -- dev->regions[ent].is_64 = 1; -- /* -- * Skip one slot for 64 bit address -- */ -- break; -+ dev->regions[ent].base_addr = reg->pci_phys_low | -+ ((uint64_t)reg->pci_phys_mid << 32); -+ dev->regions[ent].size = reg->pci_size_low | -+ ((uint64_t)reg->pci_size_hi << 32); -+ -+ switch (reg->pci_phys_hi & PCI_REG_ADDR_M) { -+ case PCI_ADDR_IO: -+ dev->regions[ent].is_IO = 1; -+ break; -+ case PCI_ADDR_MEM32: -+ break; -+ case PCI_ADDR_MEM64: -+ dev->regions[ent].is_64 = 1; -+ /* -+ * Skip one slot for 64 bit address -+ */ -+ break; -+ } - } - } - -@@ -906,7 +697,7 @@ pci_device_solx_devfs_probe( struct pci_ - } - - /** -- * Map a memory region for a device using /dev/xsvc. -+ * Map a memory region for a device using /dev/xsvc (x86) or fb device (sparc) - * - * \param dev Device whose memory region is to be mapped. - * \param map Parameters of the mapping that is to be created. -@@ -922,44 +713,45 @@ pci_device_solx_devfs_map_range(struct p - ? (PROT_READ | PROT_WRITE) : PROT_READ; - int err = 0; - --#ifdef __sparc -- char map_dev[128]; -+ const char *map_dev; - int map_fd; - -- if (MAPPING_DEV_PATH(dev)) -- snprintf(map_dev, sizeof (map_dev), "%s%s", "/devices", MAPPING_DEV_PATH(dev)); -- else -- strcpy (map_dev, "/dev/fb0"); -+#ifdef __sparc -+ char map_dev_buf[128]; - -- if ((map_fd = open(map_dev, O_RDWR | O_CLOEXEC)) < 0) { -- err = errno; -- (void) fprintf(stderr, "can not open %s: %s\n", map_dev, -- strerror(errno)); -- return err; -+ if (MAPPING_DEV_PATH(dev)) { -+ snprintf(map_dev_buf, sizeof (map_dev_buf), "%s%s", -+ "/devices", MAPPING_DEV_PATH(dev)); -+ map_dev = map_dev_buf; - } -+ else -+ map_dev = "/dev/fb0"; - -- map->memory = mmap(NULL, map->size, prot, MAP_SHARED, map_fd, map->base); -+ map_fd = -1; - #else - /* -- * Still used xsvc to do the user space mapping -+ * Still uses xsvc to do the user space mapping on x86/x64, -+ * caches open fd across multiple calls. - */ -- if (xsvc_fd < 0) { -- if ((xsvc_fd = open("/dev/xsvc", O_RDWR | O_CLOEXEC)) < 0) { -+ map_dev = "/dev/xsvc"; -+ map_fd = xsvc_fd; -+#endif -+ -+ if (map_fd < 0) { -+ if ((map_fd = open(map_dev, O_RDWR | O_CLOEXEC)) < 0) { - err = errno; -- (void) fprintf(stderr, "can not open /dev/xsvc: %s\n", -+ (void) fprintf(stderr, "can not open %s: %s\n", map_dev, - strerror(errno)); - return err; - } - } - -- map->memory = mmap(NULL, map->size, prot, MAP_SHARED, xsvc_fd, map->base); --#endif -- -+ map->memory = mmap(NULL, map->size, prot, MAP_SHARED, map_fd, map->base); - if (map->memory == MAP_FAILED) { - err = errno; - - (void) fprintf(stderr, "map rom region =%llx failed: %s\n", -- map->base, strerror(errno)); -+ (unsigned long long) map->base, strerror(errno)); - } - - #ifdef __sparc -@@ -978,15 +770,22 @@ pci_device_solx_devfs_read_rom( struct p - int err; - struct pci_device_mapping prom = { - .base = 0xC0000, -- .size = dev->rom_size, -+ .size = 0x10000, - .flags = 0 - }; -+ struct pci_device_private *priv = -+ (struct pci_device_private *) dev; -+ -+ if (priv->rom_base) { -+ prom.base = priv->rom_base; -+ prom.size = dev->rom_size; -+ } - - err = pci_device_solx_devfs_map_range(dev, &prom); - if (err == 0) { - (void) bcopy(prom.memory, buffer, dev->rom_size); - -- if (munmap(prom.memory, dev->rom_size) == -1) { -+ if (munmap(prom.memory, prom.size) == -1) { - err = errno; - } - } -@@ -1006,11 +805,7 @@ pci_device_solx_devfs_read( struct pci_d - int i = 0; - nexus_t *nexus; - --#ifdef __sparc -- nexus = find_nexus_for_dev(dev); --#else - nexus = find_nexus_for_bus(dev->domain, dev->bus); --#endif - - *bytes_read = 0; - -@@ -1036,7 +831,7 @@ pci_device_solx_devfs_read( struct pci_d - cfg_prg.bus_no, - cfg_prg.dev_no, - cfg_prg.func_no, -- cfg_prg.offset); -+ (unsigned long long) cfg_prg.offset); - fprintf(stderr, "Failure cause = %x\n", err); - break; - } -@@ -1064,11 +859,7 @@ pci_device_solx_devfs_write( struct pci_ - int cmd; - nexus_t *nexus; - --#ifdef __sparc -- nexus = find_nexus_for_dev(dev); --#else - nexus = find_nexus_for_bus(dev->domain, dev->bus); --#endif - - if ( bytes_written != NULL ) { - *bytes_written = 0; -@@ -1122,11 +913,142 @@ pci_device_solx_devfs_write( struct pci_ - return (err); - } - -+static int pci_device_solx_devfs_boot_vga(struct pci_device *dev) -+{ -+ struct pci_device_private *priv = -+ (struct pci_device_private *) dev; -+ -+ return (priv->is_primary); -+ -+} -+ -+static struct pci_io_handle * -+pci_device_solx_devfs_open_legacy_io(struct pci_io_handle *ret, -+ struct pci_device *dev, -+ pciaddr_t base, pciaddr_t size) -+{ -+#ifdef __x86 -+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) == 0) { -+ ret->base = base; -+ ret->size = size; -+ return ret; -+ } -+#endif -+ return NULL; -+} -+ -+static uint32_t -+pci_device_solx_devfs_read32(struct pci_io_handle *handle, uint32_t reg) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ uint32_t ret; -+ __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port)); -+ return ret; -+#else -+ return *(uint32_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint16_t -+pci_device_solx_devfs_read16(struct pci_io_handle *handle, uint32_t reg) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ uint16_t ret; -+ __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port)); -+ return ret; -+#else -+ return *(uint16_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static uint8_t -+pci_device_solx_devfs_read8(struct pci_io_handle *handle, uint32_t reg) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ uint8_t ret; -+ __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port)); -+ return ret; -+#else -+ return *(uint8_t *)((uintptr_t)handle->memory + reg); -+#endif -+} -+ -+static void -+pci_device_solx_devfs_write32(struct pci_io_handle *handle, uint32_t reg, -+ uint32_t data) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ __asm__ __volatile__("outl %0,%1"::"a"(data), "d"(port)); -+#else -+ *(uint16_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static void -+pci_device_solx_devfs_write16(struct pci_io_handle *handle, uint32_t reg, -+ uint16_t data) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ __asm__ __volatile__("outw %0,%1"::"a"(data), "d"(port)); -+#else -+ *(uint8_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} - -+static void -+pci_device_solx_devfs_write8(struct pci_io_handle *handle, uint32_t reg, -+ uint8_t data) -+{ -+#ifdef __x86 -+ uint16_t port = (uint16_t) (handle->base + reg); -+ __asm__ __volatile__("outb %0,%1"::"a"(data), "d"(port)); -+#else -+ *(uint32_t *)((uintptr_t)handle->memory + reg) = data; -+#endif -+} -+ -+static int -+pci_device_solx_devfs_map_legacy(struct pci_device *dev, pciaddr_t base, -+ pciaddr_t size, unsigned map_flags, -+ void **addr) -+{ -+ int err; -+ struct pci_device_mapping map = { -+ .base = base, -+ .size = size, -+ .flags = map_flags, -+ }; -+ -+ err = pci_device_solx_devfs_map_range(dev, &map); -+ if (err == 0) -+ *addr = map.memory; -+ return err; -+} -+ -+static int -+pci_device_solx_devfs_unmap_legacy(struct pci_device *dev, -+ void *addr, pciaddr_t size) -+{ -+ struct pci_device_mapping map = { -+ .memory = addr, -+ .size = size, -+ }; -+ -+ return pci_device_generic_unmap_range(dev, &map); -+} - - static const struct pci_system_methods solx_devfs_methods = { - .destroy = pci_system_solx_devfs_destroy, -+#ifdef __sparc -+ .destroy_device = pci_system_solx_devfs_destroy_device, -+#else - .destroy_device = NULL, -+#endif - .read_rom = pci_device_solx_devfs_read_rom, - .probe = pci_device_solx_devfs_probe, - .map_range = pci_device_solx_devfs_map_range, -@@ -1135,7 +1057,18 @@ static const struct pci_system_methods s - .read = pci_device_solx_devfs_read, - .write = pci_device_solx_devfs_write, - -- .fill_capabilities = pci_fill_capabilities_generic -+ .fill_capabilities = pci_fill_capabilities_generic, -+ .boot_vga = pci_device_solx_devfs_boot_vga, -+ -+ .open_legacy_io = pci_device_solx_devfs_open_legacy_io, -+ .read32 = pci_device_solx_devfs_read32, -+ .read16 = pci_device_solx_devfs_read16, -+ .read8 = pci_device_solx_devfs_read8, -+ .write32 = pci_device_solx_devfs_write32, -+ .write16 = pci_device_solx_devfs_write16, -+ .write8 = pci_device_solx_devfs_write8, -+ .map_legacy = pci_device_solx_devfs_map_legacy, -+ .unmap_legacy = pci_device_solx_devfs_unmap_legacy, - }; - - /* -@@ -1176,6 +1109,9 @@ pci_system_solx_devfs_create( void ) - pinfo.num_allocated_elems = INITIAL_NUM_DEVICES; - pinfo.num_devices = 0; - pinfo.devices = devices; -+#ifdef __sparc -+ nexus_count = 0; -+#endif - (void) di_walk_minor(di_node, DDI_NT_REGACC, 0, &pinfo, probe_nexus_node); - - di_fini(di_node); diff --git a/sysutils/libpciaccess/patches/patch-src_x86__pci.c b/sysutils/libpciaccess/patches/patch-src_x86__pci.c deleted file mode 100644 index 7ff13072a65..00000000000 --- a/sysutils/libpciaccess/patches/patch-src_x86__pci.c +++ /dev/null @@ -1,127 +0,0 @@ -$NetBSD: patch-src_x86__pci.c,v 1.1 2013/05/15 03:20:16 richard Exp $ - - -Implement legacy io & map for x86 backend -Add the legacy io and map methods for the x86 backend, using ioperm, in/out, and the existing mmap method. - ---- src/x86_pci.c.orig 2012-04-09 17:02:57.000000000 +0000 -+++ src/x86_pci.c -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2009 Samuel Thibault -+ * Copyright (c) 2009, 2012 Samuel Thibault - * Heavily inspired from the freebsd, netbsd, and openbsd backends - * (C) Copyright Eric Anholt 2006 - * (C) Copyright IBM Corporation 2006 -@@ -550,6 +550,94 @@ pci_system_x86_destroy(void) - x86_disable_io(); - } - -+static struct pci_io_handle * -+pci_device_x86_open_legacy_io(struct pci_io_handle *ret, -+ struct pci_device *dev, pciaddr_t base, pciaddr_t size) -+{ -+ x86_enable_io(); -+ -+ ret->base = base; -+ ret->size = size; -+ -+ return ret; -+} -+ -+static void -+pci_device_x86_close_io(struct pci_device *dev, struct pci_io_handle *handle) -+{ -+ /* Like in the Linux case, do not disable I/O, as it may be opened several -+ * times, and closed fewer times. */ -+ /* x86_disable_io(); */ -+} -+ -+static uint32_t -+pci_device_x86_read32(struct pci_io_handle *handle, uint32_t reg) -+{ -+ return inl(reg + handle->base); -+} -+ -+static uint16_t -+pci_device_x86_read16(struct pci_io_handle *handle, uint32_t reg) -+{ -+ return inw(reg + handle->base); -+} -+ -+static uint8_t -+pci_device_x86_read8(struct pci_io_handle *handle, uint32_t reg) -+{ -+ return inb(reg + handle->base); -+} -+ -+static void -+pci_device_x86_write32(struct pci_io_handle *handle, uint32_t reg, -+ uint32_t data) -+{ -+ outl(data, reg + handle->base); -+} -+ -+static void -+pci_device_x86_write16(struct pci_io_handle *handle, uint32_t reg, -+ uint16_t data) -+{ -+ outw(data, reg + handle->base); -+} -+ -+static void -+pci_device_x86_write8(struct pci_io_handle *handle, uint32_t reg, -+ uint8_t data) -+{ -+ outb(data, reg + handle->base); -+} -+ -+static int -+pci_device_x86_map_legacy(struct pci_device *dev, pciaddr_t base, -+ pciaddr_t size, unsigned map_flags, void **addr) -+{ -+ struct pci_device_mapping map; -+ int err; -+ -+ map.base = base; -+ map.size = size; -+ map.flags = map_flags; -+ err = pci_device_x86_map_range(dev, &map); -+ *addr = map.memory; -+ -+ return err; -+} -+ -+static int -+pci_device_x86_unmap_legacy(struct pci_device *dev, void *addr, -+ pciaddr_t size) -+{ -+ struct pci_device_mapping map; -+ -+ map.size = size; -+ map.flags = 0; -+ map.memory = addr; -+ -+ return pci_device_generic_unmap_range(dev, &map); -+} -+ - static const struct pci_system_methods x86_pci_methods = { - .destroy = pci_system_x86_destroy, - .read_rom = pci_device_x86_read_rom, -@@ -559,6 +647,16 @@ static const struct pci_system_methods x - .read = pci_device_x86_read, - .write = pci_device_x86_write, - .fill_capabilities = pci_fill_capabilities_generic, -+ .open_legacy_io = pci_device_x86_open_legacy_io, -+ .close_io = pci_device_x86_close_io, -+ .read32 = pci_device_x86_read32, -+ .read16 = pci_device_x86_read16, -+ .read8 = pci_device_x86_read8, -+ .write32 = pci_device_x86_write32, -+ .write16 = pci_device_x86_write16, -+ .write8 = pci_device_x86_write8, -+ .map_legacy = pci_device_x86_map_legacy, -+ .unmap_legacy = pci_device_x86_unmap_legacy, - }; - - static int pci_probe(struct pci_system_x86 *pci_sys_x86) |