COPYING | 36 + autogen.sh | 4 configure.ac | 17 include/pciaccess.h | 2 scanpci/Makefile.am | 2 scanpci/scanpci.c | 14 src/common_bridge.c | 7 src/common_device_name.c | 5 src/common_init.c | 1 src/common_interface.c | 2 src/freebsd_pci.c | 146 ++++++++ src/netbsd_pci.c | 817 +++++++++++++++++++++++++++++++++++++-------- src/pciaccess_private.h | 3 src/solx_devfs.c | 850 +++++++++++++++++++++-------------------------- src/x86_pci.c | 100 +++++ 15 files changed, 1389 insertions(+), 617 deletions(-)
New commits: commit aa7925c4a798b9ed2cd43bd3c99c2df2a1824311 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sat Jul 20 15:53:42 2013 -0700 libpciaccess 0.13.2 Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 537cfe3..9b7cd8c 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libpciaccess],[0.13.1], +AC_INIT([libpciaccess],[0.13.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess],[libpciaccess]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) commit bdcb46d33c6514278d2209fd00ed58c580da5ff3 Author: John Martin <john.m.mar...@oracle.com> Date: Sat Jul 20 15:49:05 2013 -0700 Fix Sun bug #7035791: scanpci should report 64 bit registers On a system which has allocated 64-bit device addresses scanpci -v will show entries such as: [...] BASE0 0xce000000 SIZE 16777216 MEM BASE1 0x00000fc1f8000000 SIZE 134217728 MEM64 PREFETCHABLE BASE3 0x00000fc1f6000000 SIZE 33554432 MEM64 PREFETCHABLE [...] instead of: [...] BASE0 0xce000000 SIZE 16777216 MEM BASE1 0xf8000000 SIZE 134217728 MEM PREFETCHABLE BASE3 0xf6000000 SIZE 33554432 MEM PREFETCHABLE [...] Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/scanpci/scanpci.c b/scanpci/scanpci.c index a427692..2f86833 100644 --- a/scanpci/scanpci.c +++ b/scanpci/scanpci.c @@ -152,11 +152,13 @@ print_pci_device( struct pci_device * dev, int verbose ) pci_device_probe( dev ); for ( i = 0 ; i < 6 ; i++ ) { if ( dev->regions[i].base_addr != 0 ) { - printf( " BASE%u 0x%08"PRIxPTR" SIZE %zu %s", + printf( " BASE%u 0x%0*"PRIxPTR" SIZE %zu %s", i, + dev->regions[i].is_64 ? 16 : 8, (intptr_t) dev->regions[i].base_addr, (size_t) dev->regions[i].size, - (dev->regions[i].is_IO) ? "I/O" : "MEM" ); + (dev->regions[i].is_IO) ? "I/O" : + ((dev->regions[i].is_64) ? "MEM64" : "MEM")); if ( ! dev->regions[i].is_IO ) { if ( dev->regions[i].is_prefetchable ) { commit f806b95d029d36c977befed4096734f6461efa08 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sat Jul 20 15:00:40 2013 -0700 Resync COPYING file with copyrights/licenses from code Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/COPYING b/COPYING index b67a2c5..2c39a67 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,9 @@ (C) Copyright IBM Corporation 2006, 2007 (C) Copyright Eric Anholt 2006 -Copyright (c) 2007, 2008, 2009, 2011, Oracle and/or its affiliates. -Copyright 2009 Red Hat, Inc. +(C) Copyright Mark Kettenis 2011 +(C) Copyright Robert Millan 2012 +Copyright (c) 2007, 2008, 2009, 2011, 2012, 2013 Oracle and/or its affiliates. +Copyright 2009, 2012 Red Hat, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +28,9 @@ IN THE SOFTWARE. ------------------------------------------------------------------------------ Copyright (c) 2008 Juan Romero Pardines -Copyright (c) 2008 Mark Kettenis +Copyright (c) 2008, 2011 Mark Kettenis +Copyright (c) 2009 Michael Lorenz +Copyright (c) 2009, 2012 Samuel Thibault Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -65,3 +69,29 @@ Except as contained in this notice, the name of the XFree86 Project shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project. + +------------------------------------------------------------------------------ + +Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti +Copyright (c) 2009 Tiago Vignatti + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. commit 3bf035fcfd0ad55220f484f7fb5d5f18690bdb10 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sat Jul 6 10:09:31 2013 -0700 pci_device_solx_devfs_probe: implicit conversion changes signedness warnings solx_devfs.c:615:32: warning: implicit conversion changes signedness: 'unsigned long' to 'int' [-Wsign-conversion] for (i = 0; i < len; i = i + CELL_NUMS_1275) { ~ ~~^~~~~~~~~~~~~~~~ solx_devfs.c:615:30: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion] for (i = 0; i < len; i = i + CELL_NUMS_1275) { ^ ~ Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/solx_devfs.c b/src/solx_devfs.c index b365de9..41f5c19 100644 --- a/src/solx_devfs.c +++ b/src/solx_devfs.c @@ -612,7 +612,7 @@ pci_device_solx_devfs_probe( struct pci_device * dev ) * 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) { + for (i = 0; i < len; i = i + (int)CELL_NUMS_1275) { reg = (pci_regspec_t *)®buf[i]; ent = reg->pci_phys_hi & 0xff; commit 883acb4bf30735c7d8f3147341345fa9e3bc76b2 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sat Jul 6 10:00:44 2013 -0700 Solaris: Remove #defines for Ultra 45 southbridge device ids Workaround for these chipsets was removed in commit d76fb36d9c28be0f7c with the switch of probing methods from the PCI address poking that upset them to using the already collected data from the kernel via devinfo, but the #define to identify them was left behind unused - remove it too. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/solx_devfs.c b/src/solx_devfs.c index df64e71..b365de9 100644 --- a/src/solx_devfs.c +++ b/src/solx_devfs.c @@ -113,26 +113,6 @@ static size_t nexus_count = 0; #define MAPPING_DEV_PATH(dev) (((struct pci_device_private *) dev)->device_string) #endif -/* - * Identify problematic southbridges. These have device id 0x5249 and - * vendor id 0x10b9. Check for revision ID 0 and class code 060400 as well. - * Values are little endian, so they are reversed for SPARC. - * - * Check for these southbridges on all architectures, as the issue is a - * southbridge issue, independent of processor. - * - * If one of these is found during probing, skip probing other devs/funcs on - * the rest of the bus, since the southbridge and all devs underneath will - * otherwise disappear. - */ -#if (NATIVE_ENDIAN == PCITOOL_ACC_ATTR_ENDN_BIG) -# define U45_SB_DEVID_VID 0xb9104952 -# define U45_SB_CLASS_RID 0x00000406 -#else -# define U45_SB_DEVID_VID 0x524910b9 -# define U45_SB_CLASS_RID 0x06040000 -#endif - static nexus_t * find_nexus_for_bus( int domain, int bus ) { commit 3773eea8d4e22aaedf675051e5e96af53b925152 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sat Jul 6 09:56:46 2013 -0700 pci_device_solx_devfs_read: fix sign conversion/comparison warnings Fixes: solx_devfs.c:824:19: warning: comparison of integers of different signs: 'int' and 'pciaddr_t' (aka 'unsigned long') [-Wsign-compare] for (i = 0; i < size; i += PCITOOL_ACC_ATTR_SIZE(PCITOOL_ACC_ATTR_SIZE_1)) ~ ^ ~~~~ solx_devfs.c:826:28: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion] cfg_prg.offset = offset + i; ~ ^ solx_devfs.c:844:19: warning: implicit conversion changes signedness: 'int' to 'pciaddr_t' (aka 'unsigned long') [-Wsign-conversion] *bytes_read = i; ~ ^ Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/solx_devfs.c b/src/solx_devfs.c index 433969f..df64e71 100644 --- a/src/solx_devfs.c +++ b/src/solx_devfs.c @@ -802,7 +802,7 @@ pci_device_solx_devfs_read( struct pci_device * dev, void * data, { pcitool_reg_t cfg_prg; int err = 0; - int i = 0; + unsigned int i = 0; nexus_t *nexus; nexus = find_nexus_for_bus(dev->domain, dev->bus); commit 22f4b45056587f5700b87d09e9fe91bbb0eda4c5 Author: Thomas Klausner <w...@netbsd.org> Date: Sat Jun 29 20:49:54 2013 +0200 Support more pci functions on NetBSD. Signed-off-by: Thomas Klausner <w...@netbsd.org> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c index 295e927..b3f7f2d 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -525,6 +525,322 @@ pci_device_netbsd_read_rom(struct pci_device *dev, void *buffer) return 0; } +#if defined(__i386__) || defined(__amd64__) +#include <machine/sysarch.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; +#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 = { .destroy = pci_system_netbsd_destroy, .destroy_device = NULL, @@ -540,6 +856,15 @@ static const struct pci_system_methods netbsd_pci_methods = { #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 commit 9a13ecb8f1462efaf741fed293e29ba38757ff70 Author: Thomas Klausner <w...@netbsd.org> Date: Sat Jun 29 20:49:53 2013 +0200 Fix build on NetBSD-4. Signed-off-by: Thomas Klausner <w...@netbsd.org> Reviewed-by: Matthieu Herrb <matthieu.he...@laas.fr> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 3441b63..537cfe3 100644 --- a/configure.ac +++ b/configure.ac @@ -108,7 +108,17 @@ AC_SYS_LARGEFILE AC_CHECK_HEADERS([err.h]) +if test "x$netbsd" = xyes; then +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/src/netbsd_pci.c b/src/netbsd_pci.c index c9bd052..295e927 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -21,10 +21,25 @@ #include <sys/mman.h> #include <sys/types.h> +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef HAVE_MTRR #include <machine/sysarch.h> #include <machine/mtrr.h> +#ifdef _X86_SYSARCH_L +/* NetBSD 5.x and newer */ #define netbsd_set_mtrr(mr, num) _X86_SYSARCH_L(set_mtrr)(mr, num) +#else +/* NetBSD 4.x and older */ +#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/pcidevs.h> commit 1d364cb2f5b5cb1b18601735f42bada7a521be19 Author: Thomas Klausner <w...@netbsd.org> Date: Sat Jun 29 20:49:52 2013 +0200 Enable boot_vga support only if WSDISPLAYIO_GET_BUSID is defined. Fixes build on NetBSD-5. Signed-off-by: Thomas Klausner <w...@netbsd.org> Reviewed-by: Matthieu Herrb <matthieu.he...@laas.fr> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c index 3566d7b..c9bd052 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -248,6 +248,7 @@ pci_device_netbsd_write(struct pci_device *dev, const void *data, return 0; } +#if defined(WSDISPLAYIO_GET_BUSID) static int pci_device_netbsd_boot_vga(struct pci_device *dev) { @@ -284,6 +285,7 @@ pci_device_netbsd_boot_vga(struct pci_device *dev) return 1; } +#endif static void pci_system_netbsd_destroy(void) @@ -518,7 +520,11 @@ static const struct pci_system_methods netbsd_pci_methods = { .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 }; int commit 7f388e466bd7fbb7f9eba531e494e7efbd3a65dc Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Mon Jun 24 21:20:27 2013 -0700 pci_id_file_open: move variable inside the #ifndef that uses it Clears up gcc warning on Solaris: common_device_name.c: In function 'pci_id_file_open': common_device_name.c:83:17: warning: unused variable 'result' [-Wunused-variable] Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/common_device_name.c b/src/common_device_name.c index 8c73dbd..a990ac8 100644 --- a/src/common_device_name.c +++ b/src/common_device_name.c @@ -80,9 +80,9 @@ typedef FILE * pci_id_file; static pci_id_file pci_id_file_open(void) { +#ifndef __sun pci_id_file result; -#ifndef __sun result = fopen(PCIIDS_PATH "/pci.ids", "re"); if (result) return result; commit a39f054649e773a4b33bf8f52152f7c5139bb90e Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Mon Jun 24 21:09:52 2013 -0700 Define PCI_MATCH_ANY as an unsigned int Clears a bunch of clang warnings of the forms: common_device_name.c:345:23: warning: comparison of integers of different signs: 'const uint32_t' (aka 'const unsigned int') and 'int' [-Wsign-compare] if ( m->vendor_id == PCI_MATCH_ANY ) { ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~ common_device_name.c:498:19: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion] m.device_id = PCI_MATCH_ANY; ~ ^~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/include/pciaccess.h b/include/pciaccess.h index c457424..22faf89 100644 --- a/include/pciaccess.h +++ b/include/pciaccess.h @@ -178,7 +178,7 @@ int pci_device_cfg_write_bits(struct pci_device *dev, uint32_t mask, /*@}*/ -#define PCI_MATCH_ANY (~0) +#define PCI_MATCH_ANY (~0U) /** * Compare two PCI ID values (either vendor or device). This is used commit 5aff35d1ef659babd71f44f7963e4e908dcd86c4 Author: Thomas Klausner <w...@netbsd.org> Date: Tue Jun 11 11:46:26 2013 +0200 Update NetBSD support. Signed-off-by: Michael Lorenz <macal...@netbsd.org> Signed-off-by: Thomas Klausner <w...@netbsd.org> Reviewed-by: Matthieu Herrb <matthieu.he...@laas.fr> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 91374e5..3441b63 100644 --- a/configure.ac +++ b/configure.ac @@ -77,10 +77,10 @@ case $host_os in *netbsd*) case $host in *i386*) - PCIACCESS_LIBS="-li386" + PCIACCESS_LIBS="-li386 -lpci" ;; *x86_64*|*amd64*) - PCIACCESS_LIBS="-lx86_64" + PCIACCESS_LIBS="-lx86_64 -lpci" ;; esac netbsd=yes diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c index 63585e3..3566d7b 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -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,12 +21,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,126 +39,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 -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1v8p9f-0006v9...@vasks.debian.org