diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2009-04-14 20:14:24 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2009-04-14 20:14:24 +0000 |
commit | 1c95206e49f7ae447f7a7ef9d50ec6c5d47500ce (patch) | |
tree | cb9d73486729c4f4c591131651f57aa1c8e22b61 /lib | |
parent | feb40e05b39842a1f0ec9b935b4a1994f9804e65 (diff) |
Merge libpciaccess 0.10.5. No functionnal change on OpenBSD.
Diffstat (limited to 'lib')
23 files changed, 2624 insertions, 742 deletions
diff --git a/lib/libpciaccess/COPYING b/lib/libpciaccess/COPYING index 2f825cb9e..b38c33ec6 100644 --- a/lib/libpciaccess/COPYING +++ b/lib/libpciaccess/COPYING @@ -1,4 +1,5 @@ -(C) Copyright IBM Corporation 2006 +(C) Copyright IBM Corporation 2006, 2007 +(C) Copyright Eric Anholt 2006 All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -19,3 +20,49 @@ IBM AND/OR THEIR SUPPLIERS 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. + +------------------------------------------------------------------------------ + +Copyright 2007, 2008 Sun Microsystems, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +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 +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL +INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING +FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +------------------------------------------------------------------------------ + +Copyright (c) 2008 Juan Romero Pardines +Copyright (c) 2008 Mark Kettenis + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/lib/libpciaccess/ChangeLog b/lib/libpciaccess/ChangeLog index ff44cba47..2f90678be 100644 --- a/lib/libpciaccess/ChangeLog +++ b/lib/libpciaccess/ChangeLog @@ -136,6 +136,169 @@ Date: Thu Oct 18 15:59:14 2007 -0700 Update bug reporting link. +commit 7aca9465a61934d57781352f4fcc42b779392cd0 +Author: Julien Cristau <jcristau@debian.org> +Date: Fri Oct 31 18:07:52 2008 +0100 + + Bump to 0.10.5 + +commit 8b0be8751279f9bc8f15ced4e5384fa2b0f78711 +Author: Julien Cristau <jcristau@debian.org> +Date: Fri Oct 31 17:33:50 2008 +0100 + + Make --without-zlib work + +commit 7a5ed759f13c3fc5f379cce2ca02c9ebfae5eae9 +Author: Robert Noland <rnoland@2hip.net> +Date: Wed Oct 29 22:20:35 2008 -0400 + + Fix FreeBSD systems which support pci domains. + + Support for FreeBSD based systems which support pci domains was broken + in the commit to support kFreeBSD. Include config.h so that things are + happy again. + +commit 067f979cbd410ddb82aee702d8434552e35c7154 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Fri Oct 17 14:09:52 2008 -0700 + + Version 0.10.4 + +commit 714fef70e66b651e9a535d3d3cb20d055595a12d +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Fri Oct 17 14:09:43 2008 -0700 + + Add scanpci.man to EXTRA_DIST + +commit 77f274b6386301cb31c074061a8c947a78b49da9 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Fri Oct 17 13:51:28 2008 -0700 + + Update COPYING with the rest of the copyright/license notices from the code + +commit 482d1da02498a6a31a6d829a5be41727f6333f94 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Fri Oct 17 13:48:46 2008 -0700 + + Add scanpci man page from Xorg + +commit f537fc50e014063d1a1297bfd82680ae3f170281 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu Oct 16 21:17:24 2008 -0700 + + More minor Solaris cleanups + +commit 9a5565c72c13aa107167c9c4a4469dd11ac13714 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu Oct 16 18:18:09 2008 -0700 + + Clean up formatting of solx_devfs.c + +commit de97e7e4c63146032c0badb9e0f0b1899dc8debf +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu Oct 16 16:55:27 2008 -0700 + + Fix bus probing on Solaris/SPARC + +commit 110cdac97ca1bca3ec811ce0a71b2b24c1f80525 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu Oct 16 13:33:01 2008 -0700 + + Correct Sun license notice + +commit 4c0d050c72a38e66a7b4ccb134e7e872eb0bf557 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Wed Oct 15 18:23:03 2008 -0700 + + scanpci: add -v flag to enable verbose mode like old scanpci + +commit 64d0c836d547847b752da6539792b94c803f206b +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Wed Oct 15 16:14:18 2008 -0700 + + Correct comment about devices used on Solaris + +commit d43d21c8cb0f917b65228852a03a7d501636f227 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Wed Oct 15 15:35:25 2008 -0700 + + Fix various typos (mostly in comments) + +commit 4c1c607c602e5e8d9277b9c01edfa7a8d10333cd +Author: Juan RP <xtraeme@gmail.com> +Date: Sat Oct 11 20:28:03 2008 +0200 + + Add NetBSD support + + It's based in the OpenBSD code, but with differences because on NetBSD, + to set MTRRs we have to use i386/x86_64_set_mtrr() and link to libi386 + or libx86_64. + + X.Org bug#17931 <http://bugs.freedesktop.org/show_bug.cgi?id=17931> + +commit 6ae378611bb4caaf57311734d3adcb7e10ac3622 +Author: Petr Salinger <petr.salinger@seznam.cz> +Date: Sat Oct 11 20:22:28 2008 +0200 + + Add support for GNU/kFreeBSD + + We need to initialize the FreeBSD backend on GNU/kFreeBSD and detect + whether pci_io.pi_sel.pc_domain member exists. + + X.Org bug#17882 <http://bugs.freedesktop.org/show_bug.cgi?id=17882> + +commit 968289fc3137ac0863c62d3c343153fa3e4aeb10 +Author: John Tapsell <johnflux@gmail.com> +Date: Tue Sep 23 17:26:09 2008 +0300 + + configure.ac: Make mtrr.h test more portable + + Use the standard AC_CHECK_HEADERS, which works for cross-compiling as + well as in various other locations. + +commit 79ed41882fd721a15c8b0bea7efeb98864d85dfb +Author: Matthieu Herrb <matthieu.herrb@laas.fr> +Date: Sat Sep 20 18:28:59 2008 +0200 + + OpenBSD: allow 2 successives calls to pci_system_init(). + + And fix pci_system_cleanup() to make it possible to call pci_system_init() + again. + ok kettenis at openbsd. + +commit 45015ab30b36bdaefd3f3aeab73d287023928826 +Author: Kel Modderman <kel@otaku42.de> +Date: Tue Jul 8 13:09:52 2008 +0200 + + Handle compressed pci.ids + + Add an option to build with zlib support so we can find + vendor/device information if the pci.ids file is gzipped. + + Signed-off-by: Julien Cristau <jcristau@debian.org> + +commit 32c64bb2386c55d5c7a3878ae9e3f95577f00875 +Author: Julien Cristau <jcristau@debian.org> +Date: Wed Mar 12 15:00:26 2008 +0100 + + Hide one more private symbol + +commit 7282b53c47c2435c1ea23948272c9ccf1798178a +Author: Jesse Barnes <jbarnes@hobbes.(none)> +Date: Mon Jun 23 11:24:04 2008 -0700 + + Support write combine resource files in Linux sysfs + + Starting with version 2.6.26, Linux will support resourceN_wc files which + export write combining mappings of PCI resource ranges, so support them if + present in libpciaccess. + +commit f49f66710b6c3cc5edfd0681cf7b69063cb4b893 +Author: Stefan Dirsch <sndirsch@suse.de> +Date: Mon Jun 23 10:50:30 2008 +0200 + + Fixed typo in output ("performace" --> "performance"). + commit ed0555e4225aec26aaaa40f4f3c15fd914390817 Author: Adam Jackson <ajax@redhat.com> Date: Tue Jun 10 15:24:56 2008 -0400 diff --git a/lib/libpciaccess/Makefile.am b/lib/libpciaccess/Makefile.am index 214721bb0..06b2bd056 100644 --- a/lib/libpciaccess/Makefile.am +++ b/lib/libpciaccess/Makefile.am @@ -26,7 +26,7 @@ SUBDIRS = src pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pciaccess.pc -EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c +EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c src/scanpci.man EXTRA_DIST += ChangeLog MAINTAINERCLEANFILES = ChangeLog diff --git a/lib/libpciaccess/Makefile.in b/lib/libpciaccess/Makefile.in index 901ee8709..baff1a11c 100644 --- a/lib/libpciaccess/Makefile.in +++ b/lib/libpciaccess/Makefile.in @@ -153,6 +153,8 @@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ +NETBSD_FALSE = @NETBSD_FALSE@ +NETBSD_TRUE = @NETBSD_TRUE@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OPENBSD_FALSE = @OPENBSD_FALSE@ @@ -223,7 +225,8 @@ target_alias = @target_alias@ SUBDIRS = src pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pciaccess.pc -EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c ChangeLog +EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c src/scanpci.man \ + ChangeLog MAINTAINERCLEANFILES = ChangeLog all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/lib/libpciaccess/aclocal.m4 b/lib/libpciaccess/aclocal.m4 index 242ffab37..445b64f2d 100644 --- a/lib/libpciaccess/aclocal.m4 +++ b/lib/libpciaccess/aclocal.m4 @@ -7473,6 +7473,466 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +dnl xorg-macros.m4. Generated from xorg-macros.m4.in:xorgversion.m4 by configure. +dnl +dnl Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved. +dnl +dnl Permission is hereby granted, free of charge, to any person obtaining a +dnl copy of this software and associated documentation files (the +dnl "Software"), to deal in the Software without restriction, including +dnl without limitation the rights to use, copy, modify, merge, publish, +dnl distribute, and/or sell copies of the Software, and to permit persons +dnl to whom the Software is furnished to do so, provided that the above +dnl copyright notice(s) and this permission notice appear in all copies of +dnl the Software and that both the above copyright notice(s) and this +dnl permission notice appear in supporting documentation. +dnl +dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +dnl OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +dnl HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL +dnl INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING +dnl FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +dnl NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +dnl WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +dnl +dnl Except as contained in this notice, the name of a copyright holder +dnl shall not be used in advertising or otherwise to promote the sale, use +dnl or other dealings in this Software without prior written authorization +dnl of the copyright holder. + +# XORG_MACROS_VERSION(required-version) +# ------------------------------------- +# Minimum version: 1.1.0 +# +# If you're using a macro added in Version 1.1 or newer, include this in +# your configure.ac with the minimum required version, such as: +# XORG_MACROS_VERSION(1.1) +# +# To force at least a version with this macro defined, also add: +# m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1 or later before running autoconf/autogen])]) +# +# +# See the "minimum version" comment for each macro you use to see what +# version you require. +AC_DEFUN([XORG_MACROS_VERSION],[ + [XORG_MACROS_needed_version=$1 + XORG_MACROS_needed_major=`echo $XORG_MACROS_needed_version | sed 's/\..*$//'` + XORG_MACROS_needed_minor=`echo $XORG_MACROS_needed_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`] + AC_MSG_CHECKING([if xorg-macros used to generate configure is at least ${XORG_MACROS_needed_major}.${XORG_MACROS_needed_minor}]) + [XORG_MACROS_version=1.2.1 + XORG_MACROS_major=`echo $XORG_MACROS_version | sed 's/\..*$//'` + XORG_MACROS_minor=`echo $XORG_MACROS_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`] + if test $XORG_MACROS_major -ne $XORG_MACROS_needed_major ; then + AC_MSG_ERROR([configure built with incompatible version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.x]) + fi + if test $XORG_MACROS_minor -lt $XORG_MACROS_needed_minor ; then + AC_MSG_ERROR([configure built with too old of a version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.${XORG_MACROS_minor}.0 or newer]) + fi + AC_MSG_RESULT([yes, $XORG_MACROS_version]) +]) # XORG_MACROS_VERSION + +# XORG_PROG_RAWCPP() +# ------------------ +# Minimum version: 1.0.0 +# +# Find cpp program and necessary flags for use in pre-processing text files +# such as man pages and config files +AC_DEFUN([XORG_PROG_RAWCPP],[ +AC_REQUIRE([AC_PROG_CPP]) +AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}], + [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib]) + +# Check for flag to avoid builtin definitions - assumes unix is predefined, +# which is not the best choice for supporting other OS'es, but covers most +# of the ones we need for now. +AC_MSG_CHECKING([if $RAWCPP requires -undef]) +AC_LANG_CONFTEST([Does cpp redefine unix ?]) +if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then + AC_MSG_RESULT([no]) +else + if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then + RAWCPPFLAGS=-undef + AC_MSG_RESULT([yes]) + # under Cygwin unix is still defined even with -undef + elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then + RAWCPPFLAGS="-undef -ansi" + AC_MSG_RESULT([yes, with -ansi]) + else + AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef. I don't know what to do.]) + fi +fi +rm -f conftest.$ac_ext + +AC_MSG_CHECKING([if $RAWCPP requires -traditional]) +AC_LANG_CONFTEST([Does cpp preserve "whitespace"?]) +if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then + AC_MSG_RESULT([no]) +else + if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then + RAWCPPFLAGS="${RAWCPPFLAGS} -traditional" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional. I don't know what to do.]) + fi +fi +rm -f conftest.$ac_ext +AC_SUBST(RAWCPPFLAGS) +]) # XORG_PROG_RAWCPP + +# XORG_MANPAGE_SECTIONS() +# ----------------------- +# Minimum version: 1.0.0 +# +# Determine which sections man pages go in for the different man page types +# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files. +# Not sure if there's any better way than just hardcoding by OS name. +# Override default settings by setting environment variables + +AC_DEFUN([XORG_MANPAGE_SECTIONS],[ +AC_REQUIRE([AC_CANONICAL_HOST]) + +if test x$APP_MAN_SUFFIX = x ; then + APP_MAN_SUFFIX=1 +fi +if test x$APP_MAN_DIR = x ; then + APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)' +fi + +if test x$LIB_MAN_SUFFIX = x ; then + LIB_MAN_SUFFIX=3 +fi +if test x$LIB_MAN_DIR = x ; then + LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)' +fi + +if test x$FILE_MAN_SUFFIX = x ; then + case $host_os in + solaris*) FILE_MAN_SUFFIX=4 ;; + *) FILE_MAN_SUFFIX=5 ;; + esac +fi +if test x$FILE_MAN_DIR = x ; then + FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)' +fi + +if test x$MISC_MAN_SUFFIX = x ; then + case $host_os in + solaris*) MISC_MAN_SUFFIX=5 ;; + *) MISC_MAN_SUFFIX=7 ;; + esac +fi +if test x$MISC_MAN_DIR = x ; then + MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)' +fi + +if test x$DRIVER_MAN_SUFFIX = x ; then + case $host_os in + solaris*) DRIVER_MAN_SUFFIX=7 ;; + *) DRIVER_MAN_SUFFIX=4 ;; + esac +fi +if test x$DRIVER_MAN_DIR = x ; then + DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)' +fi + +if test x$ADMIN_MAN_SUFFIX = x ; then + case $host_os in + solaris*) ADMIN_MAN_SUFFIX=1m ;; + *) ADMIN_MAN_SUFFIX=8 ;; + esac +fi +if test x$ADMIN_MAN_DIR = x ; then + ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)' +fi + + +AC_SUBST([APP_MAN_SUFFIX]) +AC_SUBST([LIB_MAN_SUFFIX]) +AC_SUBST([FILE_MAN_SUFFIX]) +AC_SUBST([MISC_MAN_SUFFIX]) +AC_SUBST([DRIVER_MAN_SUFFIX]) +AC_SUBST([ADMIN_MAN_SUFFIX]) +AC_SUBST([APP_MAN_DIR]) +AC_SUBST([LIB_MAN_DIR]) +AC_SUBST([FILE_MAN_DIR]) +AC_SUBST([MISC_MAN_DIR]) +AC_SUBST([DRIVER_MAN_DIR]) +AC_SUBST([ADMIN_MAN_DIR]) +]) # XORG_MANPAGE_SECTIONS + +# XORG_CHECK_LINUXDOC +# ------------------- +# Minimum version: 1.0.0 +# +# Defines the variable MAKE_TEXT if the necessary tools and +# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt. +# Whether or not the necessary tools and files are found can be checked +# with the AM_CONDITIONAL "BUILD_LINUXDOC" +AC_DEFUN([XORG_CHECK_LINUXDOC],[ +if test x$XORG_SGML_PATH = x ; then + XORG_SGML_PATH=$prefix/share/sgml +fi +HAVE_DEFS_ENT= + +if test x"$cross_compiling" = x"yes" ; then + HAVE_DEFS_ENT=no +else + AC_CHECK_FILE([$XORG_SGML_PATH/X11/defs.ent], [HAVE_DEFS_ENT=yes]) +fi + +AC_PATH_PROG(LINUXDOC, linuxdoc) +AC_PATH_PROG(PS2PDF, ps2pdf) + +AC_MSG_CHECKING([Whether to build documentation]) + +if test x$HAVE_DEFS_ENT != x && test x$LINUXDOC != x ; then + BUILDDOC=yes +else + BUILDDOC=no +fi + +AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes]) + +AC_MSG_RESULT([$BUILDDOC]) + +AC_MSG_CHECKING([Whether to build pdf documentation]) + +if test x$PS2PDF != x && test x$BUILD_PDFDOC != xno; then + BUILDPDFDOC=yes +else + BUILDPDFDOC=no +fi + +AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes]) + +AC_MSG_RESULT([$BUILDPDFDOC]) + +MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt" +MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps" +MAKE_PDF="$PS2PDF" +MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B html --split=0" + +AC_SUBST(MAKE_TEXT) +AC_SUBST(MAKE_PS) +AC_SUBST(MAKE_PDF) +AC_SUBST(MAKE_HTML) +]) # XORG_CHECK_LINUXDOC + +# XORG_CHECK_DOCBOOK +# ------------------- +# Minimum version: 1.0.0 +# +# Checks for the ability to build output formats from SGML DocBook source. +# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC" +# indicates whether the necessary tools and files are found and, if set, +# $(MAKE_XXX) blah.sgml will produce blah.xxx. +AC_DEFUN([XORG_CHECK_DOCBOOK],[ +if test x$XORG_SGML_PATH = x ; then + XORG_SGML_PATH=$prefix/share/sgml +fi +HAVE_DEFS_ENT= +BUILDTXTDOC=no +BUILDPDFDOC=no +BUILDPSDOC=no +BUILDHTMLDOC=no + +AC_CHECK_FILE([$XORG_SGML_PATH/X11/defs.ent], [HAVE_DEFS_ENT=yes]) + +AC_PATH_PROG(DOCBOOKPS, docbook2ps) +AC_PATH_PROG(DOCBOOKPDF, docbook2pdf) +AC_PATH_PROG(DOCBOOKHTML, docbook2html) +AC_PATH_PROG(DOCBOOKTXT, docbook2txt) + +AC_MSG_CHECKING([Whether to build text documentation]) +if test x$HAVE_DEFS_ENT != x && test x$DOCBOOKTXT != x && + test x$BUILD_TXTDOC != xno; then + BUILDTXTDOC=yes +fi +AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes]) +AC_MSG_RESULT([$BUILDTXTDOC]) + +AC_MSG_CHECKING([Whether to build PDF documentation]) +if test x$HAVE_DEFS_ENT != x && test x$DOCBOOKPDF != x && + test x$BUILD_PDFDOC != xno; then + BUILDPDFDOC=yes +fi +AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes]) +AC_MSG_RESULT([$BUILDPDFDOC]) + +AC_MSG_CHECKING([Whether to build PostScript documentation]) +if test x$HAVE_DEFS_ENT != x && test x$DOCBOOKPS != x && + test x$BUILD_PSDOC != xno; then + BUILDPSDOC=yes +fi +AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes]) +AC_MSG_RESULT([$BUILDPSDOC]) + +AC_MSG_CHECKING([Whether to build HTML documentation]) +if test x$HAVE_DEFS_ENT != x && test x$DOCBOOKHTML != x && + test x$BUILD_HTMLDOC != xno; then + BUILDHTMLDOC=yes +fi +AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes]) +AC_MSG_RESULT([$BUILDHTMLDOC]) + +MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT" +MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS" +MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF" +MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML" + +AC_SUBST(MAKE_TEXT) +AC_SUBST(MAKE_PS) +AC_SUBST(MAKE_PDF) +AC_SUBST(MAKE_HTML) +]) # XORG_CHECK_DOCBOOK + +# XORG_CHECK_MALLOC_ZERO +# ---------------------- +# Minimum version: 1.0.0 +# +# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if +# malloc(0) returns NULL. Packages should add one of these cflags to +# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them. +AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[ +AC_ARG_ENABLE(malloc0returnsnull, + AC_HELP_STRING([--enable-malloc0returnsnull], + [malloc(0) returns NULL (default: auto)]), + [MALLOC_ZERO_RETURNS_NULL=$enableval], + [MALLOC_ZERO_RETURNS_NULL=auto]) + +AC_MSG_CHECKING([whether malloc(0) returns NULL]) +if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then + AC_RUN_IFELSE([ +char *malloc(); +char *realloc(); +char *calloc(); +main() { + char *m0, *r0, *c0, *p; + m0 = malloc(0); + p = malloc(10); + r0 = realloc(p,0); + c0 = calloc(0); + exit(m0 == 0 || r0 == 0 || c0 == 0 ? 0 : 1); +}], + [MALLOC_ZERO_RETURNS_NULL=yes], + [MALLOC_ZERO_RETURNS_NULL=no]) +fi +AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL]) + +if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then + MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL" + XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS + XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC" +else + MALLOC_ZERO_CFLAGS="" + XMALLOC_ZERO_CFLAGS="" + XTMALLOC_ZERO_CFLAGS="" +fi + +AC_SUBST([MALLOC_ZERO_CFLAGS]) +AC_SUBST([XMALLOC_ZERO_CFLAGS]) +AC_SUBST([XTMALLOC_ZERO_CFLAGS]) +]) # XORG_CHECK_MALLOC_ZERO + +# XORG_WITH_LINT() +# ---------------- +# Minimum version: 1.1.0 +# +# Sets up flags for source checkers such as lint and sparse if --with-lint +# is specified. (Use --with-lint=sparse for sparse.) +# Sets $LINT to name of source checker passed with --with-lint (default: lint) +# Sets $LINT_FLAGS to flags to pass to source checker +# Sets LINT automake conditional if enabled (default: disabled) +# +AC_DEFUN([XORG_WITH_LINT],[ + +# Allow checking code with lint, sparse, etc. +AC_ARG_WITH(lint, [AC_HELP_STRING([--with-lint], + [Use a lint-style source code checker (default: disabled)])], + [use_lint=$withval], [use_lint=no]) +if test "x$use_lint" = "xyes" ; then + LINT="lint" +else + LINT="$use_lint" +fi +if test "x$LINT_FLAGS" = "x" -a "x$LINT" != "xno" ; then + case $LINT in + lint|*/lint) + case $host_os in + solaris*) + LINT_FLAGS="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2" + ;; + esac + ;; + esac +fi + +AC_SUBST(LINT) +AC_SUBST(LINT_FLAGS) +AM_CONDITIONAL(LINT, [test x$LINT != xno]) + +]) # XORG_WITH_LINT + +# XORG_LINT_LIBRARY(LIBNAME) +# -------------------------- +# Minimum version: 1.1.0 +# +# Sets up flags for building lint libraries for checking programs that call +# functions in the library. +# Disabled by default, enable with --enable-lint-library +# Sets: +# @LINTLIB@ - name of lint library file to make +# MAKE_LINT_LIB - automake conditional +# + +AC_DEFUN([XORG_LINT_LIBRARY],[ +AC_REQUIRE([XORG_WITH_LINT]) +# Build lint "library" for more indepth checks of programs calling this library +AC_ARG_ENABLE(lint-library, [AC_HELP_STRING([--enable-lint-library], + [Create lint library (default: disabled)])], + [make_lint_lib=$enableval], [make_lint_lib=no]) +if test "x$make_lint_lib" != "xno" ; then + if test "x$LINT" = "xno" ; then + AC_MSG_ERROR([Cannot make lint library without --with-lint]) + fi + if test "x$make_lint_lib" = "xyes" ; then + LINTLIB=llib-l$1.ln + else + LINTLIB=$make_lint_lib + fi +fi +AC_SUBST(LINTLIB) +AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno]) + +]) # XORG_LINT_LIBRARY + +# XORG_CWARNFLAGS +# --------------- +# Minimum version: 1.2.0 +# +# Defines CWARNFLAGS to enable C compiler warnings. +# +AC_DEFUN([XORG_CWARNFLAGS], [ +AC_REQUIRE([AC_PROG_CC]) +if test "x$GCC" = xyes ; then + CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ +-Wmissing-declarations -Wnested-externs -fno-strict-aliasing \ +-Wbad-function-cast" + case `gcc -dumpversion` in + 3.4.* | 4.*) + CWARNFLAGS+=" -Wold-style-definition -Wdeclaration-after-statement" + ;; + esac +else + AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) + if test "x$SUNCC" = "xyes"; then + CWARNFLAGS="-v" + fi +fi +AC_SUBST(CWARNFLAGS) +]) # XORG_CWARNFLAGS dnl Copyright 2005 Red Hat, Inc dnl dnl Permission to use, copy, modify, distribute, and sell this software and its @@ -7535,3 +7995,20 @@ AC_DEFUN([XORG_RELEASE_VERSION],[ [Patch version of this package]) ]) +# XORG_CHANGELOG() +# ---------------- +# Minimum version: 1.2.0 +# +# Defines the variable CHANGELOG_CMD as the command to generate +# ChangeLog from git. +# +# Arrange that distcleancheck ignores ChangeLog left over by distclean. +# +AC_DEFUN([XORG_CHANGELOG], [ +CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > .changelog.tmp && \ +mv .changelog.tmp ChangeLog) || (rm -f .changelog.tmp; touch ChangeLog; \ +echo 'git directory not found: installing possibly empty changelog.' >&2)" +AC_SUBST([CHANGELOG_CMD]) +AC_SUBST([distcleancheck_listfiles], ['find . -type f ! -name ChangeLog -print']) +]) # XORG_CHANGELOG + diff --git a/lib/libpciaccess/config.h.in b/lib/libpciaccess/config.h.in index 5f2ab6a21..6519b6fd6 100644 --- a/lib/libpciaccess/config.h.in +++ b/lib/libpciaccess/config.h.in @@ -12,6 +12,9 @@ /* Use MTRRs on mappings */ #undef HAVE_MTRR +/* Have the pci_io.pi_sel.pc_domain member. */ +#undef HAVE_PCI_IO_PC_DOMAIN + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H @@ -33,6 +36,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Use zlib to read gzip compressed pci.ids */ +#undef HAVE_ZLIB + /* Name of package */ #undef PACKAGE diff --git a/lib/libpciaccess/configure b/lib/libpciaccess/configure index fd26d3bc2..a9b307bec 100644 --- a/lib/libpciaccess/configure +++ b/lib/libpciaccess/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for libpciaccess 0.10.2. +# Generated by GNU Autoconf 2.59 for libpciaccess 0.10.5. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess>. # @@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='libpciaccess' PACKAGE_TARNAME='libpciaccess' -PACKAGE_VERSION='0.10.2' -PACKAGE_STRING='libpciaccess 0.10.2' +PACKAGE_VERSION='0.10.5' +PACKAGE_STRING='libpciaccess 0.10.5' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess' # Factoring default headers for most tests. @@ -464,7 +464,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PCIIDS_PATH LINUX_TRUE LINUX_FALSE FREEBSD_TRUE FREEBSD_FALSE OPENBSD_TRUE OPENBSD_FALSE SOLARIS_TRUE SOLARIS_FALSE PCIACCESS_CFLAGS PCIACCESS_LIBS LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PCIIDS_PATH LINUX_TRUE LINUX_FALSE FREEBSD_TRUE FREEBSD_FALSE NETBSD_TRUE NETBSD_FALSE OPENBSD_TRUE OPENBSD_FALSE SOLARIS_TRUE SOLARIS_FALSE PCIACCESS_CFLAGS PCIACCESS_LIBS LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -953,7 +953,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libpciaccess 0.10.2 to adapt to many kinds of systems. +\`configure' configures libpciaccess 0.10.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1019,7 +1019,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpciaccess 0.10.2:";; + short | recursive ) echo "Configuration of libpciaccess 0.10.5:";; esac cat <<\_ACEOF @@ -1048,6 +1048,7 @@ Optional Packages: include additional configurations [automatic] --with-pciids-path=PCIIDS_PATH Path to pci.ids file + --with-zlib Enable zlib support to read gzip compressed pci.ids --with-release-version=STRING Use release version string in package name @@ -1164,7 +1165,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -libpciaccess configure 0.10.2 +libpciaccess configure 0.10.5 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1178,7 +1179,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpciaccess $as_me 0.10.2, which was +It was created by libpciaccess $as_me 0.10.5, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1776,7 +1777,7 @@ fi # Define the identity of the package. PACKAGE='libpciaccess' - VERSION='0.10.2' + VERSION='0.10.5' cat >>confdefs.h <<_ACEOF @@ -3671,7 +3672,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 3674 "configure"' > conftest.$ac_ext + echo '#line 3675 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5281,7 +5282,7 @@ fi # Provide some information about the compiler. -echo "$as_me:5284:" \ +echo "$as_me:5285:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 @@ -6630,11 +6631,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6633: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6634: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6637: \$? = $ac_status" >&5 + echo "$as_me:6638: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -6920,11 +6921,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6923: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6924: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6927: \$? = $ac_status" >&5 + echo "$as_me:6928: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7024,11 +7025,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7027: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7028: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7031: \$? = $ac_status" >&5 + echo "$as_me:7032: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9425,7 +9426,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9428 "configure" +#line 9429 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9525,7 +9526,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9528 "configure" +#line 9529 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11930,11 +11931,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11933: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11934: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11937: \$? = $ac_status" >&5 + echo "$as_me:11938: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12034,11 +12035,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12037: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12038: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12041: \$? = $ac_status" >&5 + echo "$as_me:12042: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13617,11 +13618,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13620: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13621: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13624: \$? = $ac_status" >&5 + echo "$as_me:13625: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13721,11 +13722,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13724: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13725: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13728: \$? = $ac_status" >&5 + echo "$as_me:13729: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15933,11 +15934,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15936: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15937: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15940: \$? = $ac_status" >&5 + echo "$as_me:15941: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16223,11 +16224,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16226: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16227: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16230: \$? = $ac_status" >&5 + echo "$as_me:16231: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16327,11 +16328,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16330: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16331: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16334: \$? = $ac_status" >&5 + echo "$as_me:16335: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19039,6 +19040,239 @@ _ACEOF test "$exec_prefix_NONE" && exec_prefix=NONE + +# Check whether --with-zlib or --without-zlib was given. +if test "${with_zlib+set}" = set; then + withval="$with_zlib" + use_zlib="$withval" +else + use_zlib="no" +fi; +if test "x$use_zlib" = xyes; then + echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 +echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 +if test "${ac_cv_lib_z_gzopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gzopen (); +int +main () +{ +gzopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_z_gzopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_z_gzopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 +if test $ac_cv_lib_z_gzopen = yes; then + PCIACCESS_LIBS="$PCIACCESS_LIBS -lz" +else + { { echo "$as_me:$LINENO: error: Check for zlib library failed" >&5 +echo "$as_me: error: Check for zlib library failed" >&2;} + { (exit 1); exit 1; }; } +fi + + if test "${ac_cv_header_zlib_h+set}" = set; then + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <zlib.h> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <zlib.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## --------------------------------------------------------------------------------------------- ## +## Report this to https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess ## +## --------------------------------------------------------------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 + +fi +if test $ac_cv_header_zlib_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ZLIB 1 +_ACEOF + +else + { { echo "$as_me:$LINENO: error: Check for zlib.h header file failed" >&5 +echo "$as_me: error: Check for zlib.h header file failed" >&2;} + { (exit 1); exit 1; }; } +fi + + +fi + if test "x$GCC" = "xyes"; then GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes" GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations" @@ -19057,6 +19291,17 @@ case $host_os in *linux*) linux=yes ;; + *netbsd*) + case $host in + *i386*) + PCIACCESS_LIBS="-li386" + ;; + *x86_64*|*amd64*) + PCIACCESS_LIBS="-lx86_64" + ;; + esac + netbsd=yes + ;; *openbsd*) openbsd=yes ;; @@ -19088,6 +19333,16 @@ fi +if test "x$netbsd" = xyes; then + NETBSD_TRUE= + NETBSD_FALSE='#' +else + NETBSD_TRUE='#' + NETBSD_FALSE= +fi + + + if test "x$openbsd" = xyes; then OPENBSD_TRUE= OPENBSD_FALSE='#' @@ -19107,29 +19362,151 @@ else fi -echo "$as_me:$LINENO: checking for /usr/include/asm/mtrr.h" >&5 -echo $ECHO_N "checking for /usr/include/asm/mtrr.h... $ECHO_C" >&6 -if test "${ac_cv_file__usr_include_asm_mtrr_h+set}" = set; then +if test "${ac_cv_header_asm_mtrr_h+set}" = set; then + echo "$as_me:$LINENO: checking for asm/mtrr.h" >&5 +echo $ECHO_N "checking for asm/mtrr.h... $ECHO_C" >&6 +if test "${ac_cv_header_asm_mtrr_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_asm_mtrr_h" >&5 +echo "${ECHO_T}$ac_cv_header_asm_mtrr_h" >&6 else - test "$cross_compiling" = yes && - { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 -echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} - { (exit 1); exit 1; }; } -if test -r "/usr/include/asm/mtrr.h"; then - ac_cv_file__usr_include_asm_mtrr_h=yes + # Is the header compilable? +echo "$as_me:$LINENO: checking asm/mtrr.h usability" >&5 +echo $ECHO_N "checking asm/mtrr.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <asm/mtrr.h> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking asm/mtrr.h presence" >&5 +echo $ECHO_N "checking asm/mtrr.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <asm/mtrr.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: asm/mtrr.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: asm/mtrr.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: asm/mtrr.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: asm/mtrr.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: asm/mtrr.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: asm/mtrr.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: asm/mtrr.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: asm/mtrr.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: asm/mtrr.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## --------------------------------------------------------------------------------------------- ## +## Report this to https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess ## +## --------------------------------------------------------------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for asm/mtrr.h" >&5 +echo $ECHO_N "checking for asm/mtrr.h... $ECHO_C" >&6 +if test "${ac_cv_header_asm_mtrr_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_file__usr_include_asm_mtrr_h=no + ac_cv_header_asm_mtrr_h=$ac_header_preproc fi +echo "$as_me:$LINENO: result: $ac_cv_header_asm_mtrr_h" >&5 +echo "${ECHO_T}$ac_cv_header_asm_mtrr_h" >&6 + fi -echo "$as_me:$LINENO: result: $ac_cv_file__usr_include_asm_mtrr_h" >&5 -echo "${ECHO_T}$ac_cv_file__usr_include_asm_mtrr_h" >&6 -if test $ac_cv_file__usr_include_asm_mtrr_h = yes; then +if test $ac_cv_header_asm_mtrr_h = yes; then have_mtrr_h="yes" else have_mtrr_h="no" fi + + if test "x$have_mtrr_h" = xyes; then cat >>confdefs.h <<\_ACEOF @@ -19138,6 +19515,122 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for struct pci_io.pi_sel.pc_domain" >&5 +echo $ECHO_N "checking for struct pci_io.pi_sel.pc_domain... $ECHO_C" >&6 +if test "${ac_cv_member_struct_pci_io_pi_sel_pc_domain+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include <sys/types.h> + #include <sys/pciio.h> + + +int +main () +{ +static struct pci_io ac_aggr; +if (ac_aggr.pi_sel.pc_domain) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_pci_io_pi_sel_pc_domain=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include <sys/types.h> + #include <sys/pciio.h> + + +int +main () +{ +static struct pci_io ac_aggr; +if (sizeof ac_aggr.pi_sel.pc_domain) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_pci_io_pi_sel_pc_domain=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_pci_io_pi_sel_pc_domain=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_pci_io_pi_sel_pc_domain" >&5 +echo "${ECHO_T}$ac_cv_member_struct_pci_io_pi_sel_pc_domain" >&6 +if test $ac_cv_member_struct_pci_io_pi_sel_pc_domain = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PCI_IO_PC_DOMAIN 1 +_ACEOF + +fi + + @@ -19315,6 +19808,13 @@ echo "$as_me: error: conditional \"FREEBSD\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${NETBSD_TRUE}" && test -z "${NETBSD_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"NETBSD\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"NETBSD\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${OPENBSD_TRUE}" && test -z "${OPENBSD_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"OPENBSD\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -19600,7 +20100,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by libpciaccess $as_me 0.10.2, which was +This file was extended by libpciaccess $as_me 0.10.5, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19663,7 +20163,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libpciaccess config.status 0.10.2 +libpciaccess config.status 0.10.5 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -19941,6 +20441,8 @@ s,@LINUX_TRUE@,$LINUX_TRUE,;t t s,@LINUX_FALSE@,$LINUX_FALSE,;t t s,@FREEBSD_TRUE@,$FREEBSD_TRUE,;t t s,@FREEBSD_FALSE@,$FREEBSD_FALSE,;t t +s,@NETBSD_TRUE@,$NETBSD_TRUE,;t t +s,@NETBSD_FALSE@,$NETBSD_FALSE,;t t s,@OPENBSD_TRUE@,$OPENBSD_TRUE,;t t s,@OPENBSD_FALSE@,$OPENBSD_FALSE,;t t s,@SOLARIS_TRUE@,$SOLARIS_TRUE,;t t diff --git a/lib/libpciaccess/configure.ac b/lib/libpciaccess/configure.ac index 9293b4a7b..b15c4be25 100644 --- a/lib/libpciaccess/configure.ac +++ b/lib/libpciaccess/configure.ac @@ -40,7 +40,7 @@ dnl refers to ${prefix}. Thus we have to use `eval' twice. AC_PREREQ([2.57]) -AC_INIT(libpciaccess, 0.10.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess) +AC_INIT(libpciaccess, 0.10.5, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess) AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE @@ -59,6 +59,19 @@ AC_ARG_WITH(pciids-path, [PCIIDS_PATH="$DEFAULT_PCIIDS_PATH"]) AC_DEFINE_DIR(PCIIDS_PATH, PCIIDS_PATH, [Path to pci.ids]) +AC_ARG_WITH(zlib, + AS_HELP_STRING([--with-zlib], [Enable zlib support to read gzip compressed pci.ids]), + [use_zlib="$withval"], + [use_zlib="no"]) +if test "x$use_zlib" = xyes; then + AC_CHECK_LIB(z, gzopen, + [PCIACCESS_LIBS="$PCIACCESS_LIBS -lz"], + [AC_MSG_ERROR(Check for zlib library failed)]) + AC_CHECK_HEADER([zlib.h], + [AC_DEFINE(HAVE_ZLIB, 1, [Use zlib to read gzip compressed pci.ids])], + [AC_MSG_ERROR(Check for zlib.h header file failed)]) +fi + if test "x$GCC" = "xyes"; then GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes" GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations" @@ -77,6 +90,17 @@ case $host_os in *linux*) linux=yes ;; + *netbsd*) + case $host in + *i386*) + PCIACCESS_LIBS="-li386" + ;; + *x86_64*|*amd64*) + PCIACCESS_LIBS="-lx86_64" + ;; + esac + netbsd=yes + ;; *openbsd*) openbsd=yes ;; @@ -88,15 +112,24 @@ esac AM_CONDITIONAL(LINUX, [test "x$linux" = xyes]) AM_CONDITIONAL(FREEBSD, [test "x$freebsd" = xyes]) +AM_CONDITIONAL(NETBSD, [test "x$netbsd" = xyes]) AM_CONDITIONAL(OPENBSD, [test "x$openbsd" = xyes]) AM_CONDITIONAL(SOLARIS, [test "x$solaris" = xyes]) -AC_CHECK_FILE([/usr/include/asm/mtrr.h], - [have_mtrr_h="yes"], [have_mtrr_h="no"]) +AC_CHECK_HEADER([asm/mtrr.h], [have_mtrr_h="yes"], [have_mtrr_h="no"]) + if test "x$have_mtrr_h" = xyes; then AC_DEFINE(HAVE_MTRR, 1, [Use MTRRs on mappings]) fi +dnl check for the pci_io.pi_sel.pc_domain +AC_CHECK_MEMBER([struct pci_io.pi_sel.pc_domain], + [AC_DEFINE(HAVE_PCI_IO_PC_DOMAIN,1,[Have the pci_io.pi_sel.pc_domain member.])], + [], + [ #include <sys/types.h> + #include <sys/pciio.h> + ]) + AC_SUBST(PCIACCESS_CFLAGS) AC_SUBST(PCIACCESS_LIBS) diff --git a/lib/libpciaccess/ltmain.sh b/lib/libpciaccess/ltmain.sh index 248cd4047..fccf69e28 100644 --- a/lib/libpciaccess/ltmain.sh +++ b/lib/libpciaccess/ltmain.sh @@ -2127,17 +2127,6 @@ EOF ;; esac for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" diff --git a/lib/libpciaccess/src/Makefile.am b/lib/libpciaccess/src/Makefile.am index 8c53de5ed..3e504060c 100644 --- a/lib/libpciaccess/src/Makefile.am +++ b/lib/libpciaccess/src/Makefile.am @@ -33,6 +33,10 @@ if FREEBSD OS_SUPPORT = freebsd_pci.c endif +if NETBSD +OS_SUPPORT = netbsd_pci.c +endif + if OPENBSD OS_SUPPORT = openbsd_pci.c endif diff --git a/lib/libpciaccess/src/Makefile.in b/lib/libpciaccess/src/Makefile.in index ed916bf14..0a63e9246 100644 --- a/lib/libpciaccess/src/Makefile.in +++ b/lib/libpciaccess/src/Makefile.in @@ -87,10 +87,11 @@ am__libpciaccess_la_SOURCES_DIST = common_bridge.c common_iterator.c \ common_init.c common_interface.c common_capability.c \ common_device_name.c common_map.c pciaccess_private.h \ freebsd_pci.c linux_sysfs.c linux_devmem.c linux_devmem.h \ - openbsd_pci.c solx_devfs.c pci_tools.h -@FREEBSD_FALSE@@LINUX_FALSE@@OPENBSD_FALSE@@SOLARIS_TRUE@am__objects_1 = solx_devfs.lo -@FREEBSD_FALSE@@LINUX_FALSE@@OPENBSD_TRUE@am__objects_1 = \ -@FREEBSD_FALSE@@LINUX_FALSE@@OPENBSD_TRUE@ openbsd_pci.lo + netbsd_pci.c openbsd_pci.c solx_devfs.c pci_tools.h +@FREEBSD_FALSE@@LINUX_FALSE@@NETBSD_FALSE@@OPENBSD_FALSE@@SOLARIS_TRUE@am__objects_1 = solx_devfs.lo +@FREEBSD_FALSE@@LINUX_FALSE@@NETBSD_FALSE@@OPENBSD_TRUE@am__objects_1 = openbsd_pci.lo +@FREEBSD_FALSE@@LINUX_FALSE@@NETBSD_TRUE@am__objects_1 = \ +@FREEBSD_FALSE@@LINUX_FALSE@@NETBSD_TRUE@ netbsd_pci.lo @FREEBSD_FALSE@@LINUX_TRUE@am__objects_1 = linux_sysfs.lo \ @FREEBSD_FALSE@@LINUX_TRUE@ linux_devmem.lo @FREEBSD_TRUE@am__objects_1 = freebsd_pci.lo @@ -169,6 +170,8 @@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ +NETBSD_FALSE = @NETBSD_FALSE@ +NETBSD_TRUE = @NETBSD_TRUE@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OPENBSD_FALSE = @OPENBSD_FALSE@ @@ -240,6 +243,7 @@ AM_CFLAGS = @PCIACCESS_CFLAGS@ lib_LTLIBRARIES = libpciaccess.la @FREEBSD_TRUE@OS_SUPPORT = freebsd_pci.c @LINUX_TRUE@OS_SUPPORT = linux_sysfs.c linux_devmem.c linux_devmem.h +@NETBSD_TRUE@OS_SUPPORT = netbsd_pci.c @OPENBSD_TRUE@OS_SUPPORT = openbsd_pci.c @SOLARIS_TRUE@OS_SUPPORT = solx_devfs.c pci_tools.h libpciaccess_la_SOURCES = common_bridge.c \ @@ -351,6 +355,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freebsd_pci.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_devmem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_sysfs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netbsd_pci.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openbsd_pci.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanpci.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/solx_devfs.Plo@am__quote@ diff --git a/lib/libpciaccess/src/common_device_name.c b/lib/libpciaccess/src/common_device_name.c index b10518714..877f21861 100644 --- a/lib/libpciaccess/src/common_device_name.c +++ b/lib/libpciaccess/src/common_device_name.c @@ -50,6 +50,31 @@ #define DO_MATCH(a,b) (((a) == PCI_MATCH_ANY) || ((a) == (b))) +#ifdef HAVE_ZLIB +#include <zlib.h> +typedef gzFile pci_id_file; + +static pci_id_file +pci_id_file_open() +{ + pci_id_file result; + + result = gzopen(PCIIDS_PATH "/pci.ids.gz", "rb"); + if (result) + return result; + + return gzopen(PCIIDS_PATH "/pci.ids", "rb"); +} + +#define pci_id_file_gets(l, s, f) gzgets(f, l, s) +#define pci_id_file_close(f) gzclose(f) +#else +typedef FILE pci_id_file; +#define pci_id_file_open() fopen(PCIIDS_PATH "/pci.ids", "r") +#define pci_id_file_gets(l, s, f) fgets(l, s, f) +#define pci_id_file_close(f) fclose(f) +#endif + /** * Node for sorting vendor IDs. * @@ -96,12 +121,6 @@ struct pci_device_leaf { _pci_hidden struct pci_id_node * tree = NULL; /** - * Name of the file containing the PCI ID information. - */ -static const char pci_id_file[] = PCIIDS_PATH "/pci.ids"; - - -/** * Get a pointer to the leaf node for a vendor ID. * * If the vendor ID does not exist in the tree, it is added. @@ -170,7 +189,7 @@ insert( uint16_t vendor ) static void populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) { - FILE * f = fopen( pci_id_file, "r" ); + pci_id_file * f = pci_id_file_open(); char buf[128]; unsigned vendor = PCI_MATCH_ANY; @@ -186,12 +205,12 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) * anything. This avoids wasted processing and potential memory leaks. */ if (vend->num_devices != 0) { - fclose(f); + pci_id_file_close( f ); return; } - while( fgets( buf, sizeof( buf ), f ) != NULL ) { + while( pci_id_file_gets( buf, sizeof( buf ), f ) != NULL ) { unsigned num_tabs; char * new_line; size_t length; @@ -284,7 +303,7 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) } } - fclose( f ); + pci_id_file_close( f ); } diff --git a/lib/libpciaccess/src/common_init.c b/lib/libpciaccess/src/common_init.c index ff241838b..6b83d972d 100644 --- a/lib/libpciaccess/src/common_init.c +++ b/lib/libpciaccess/src/common_init.c @@ -54,8 +54,10 @@ pci_system_init( void ) #ifdef linux err = pci_system_linux_sysfs_create(); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) err = pci_system_freebsd_create(); +#elif defined(__NetBSD__) + err = pci_system_netbsd_create(); #elif defined(__OpenBSD__) err = pci_system_openbsd_create(); #elif defined(__sun) diff --git a/lib/libpciaccess/src/common_interface.c b/lib/libpciaccess/src/common_interface.c index 663ab44ef..0cdf25d25 100644 --- a/lib/libpciaccess/src/common_interface.c +++ b/lib/libpciaccess/src/common_interface.c @@ -64,7 +64,7 @@ #define HTOLE_16(x) htole16(x) #define HTOLE_32(x) htole32(x) -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) #define LETOH_16(x) le16toh(x) #define LETOH_32(x) le32toh(x) #else @@ -110,7 +110,7 @@ pci_device_read_rom( struct pci_device * dev, void * buffer ) * \param dev Device to be probed. * * \return - * Zero on succes or an \c errno value on failure. + * Zero on success or an \c errno value on failure. */ int pci_device_probe( struct pci_device * dev ) @@ -127,7 +127,7 @@ pci_device_probe( struct pci_device * dev ) /** * Map the specified BAR so that it can be accessed by the CPU. * - * Maps the specified BAR for acces by the processor. The pointer to the + * Maps the specified BAR for access by the processor. The pointer to the * mapped region is stored in the \c pci_mem_region::memory pointer for the * BAR. * @@ -166,7 +166,7 @@ pci_device_map_region(struct pci_device * dev, unsigned region, * Map the specified memory range so that it can be accessed by the CPU. * * Maps the specified memory range for access by the processor. The pointer - * to the mapped region is stored in \c addr. In addtion, the + * to the mapped region is stored in \c addr. In addition, the * \c pci_mem_region::memory pointer for the BAR will be updated. * * \param dev Device whose memory region is to be mapped. @@ -194,7 +194,7 @@ int pci_device_map_memory_range(struct pci_device *dev, * Map the specified memory range so that it can be accessed by the CPU. * * Maps the specified memory range for access by the processor. The pointer - * to the mapped region is stored in \c addr. In addtion, the + * to the mapped region is stored in \c addr. In addition, the * \c pci_mem_region::memory pointer for the BAR will be updated. * * \param dev Device whose memory region is to be mapped. @@ -415,7 +415,7 @@ pci_device_unmap_range(struct pci_device *dev, void *memory, * * Reads data from the device's PCI configuration space. As with the system * read command, less data may be returned, without an error, than was - * requested. This is particuarly the case if a non-root user tries to read + * requested. This is particularly the case if a non-root user tries to read * beyond the first 64-bytes of configuration space. * * \param dev Device whose PCI configuration data is to be read. @@ -429,7 +429,7 @@ pci_device_unmap_range(struct pci_device *dev, void *memory, * Zero on success or an errno value on failure. * * \note - * Data read from PCI configuartion space using this routine is \b not + * Data read from PCI configuration space using this routine is \b not * byte-swapped to the host's byte order. PCI configuration data is always * stored in little-endian order, and that is what this routine returns. */ @@ -500,7 +500,7 @@ pci_device_cfg_read_u32( struct pci_device * dev, uint32_t * data, /** * Write arbitrary bytes to device's PCI config space * - * Writess data to the device's PCI configuration space. As with the system + * Writes data to the device's PCI configuration space. As with the system * write command, less data may be written, without an error, than was * requested. * @@ -515,7 +515,7 @@ pci_device_cfg_read_u32( struct pci_device * dev, uint32_t * data, * Zero on success or an errno value on failure. * * \note - * Data written to PCI configuartion space using this routine is \b not + * Data written to PCI configuration space using this routine is \b not * byte-swapped from the host's byte order. PCI configuration data is always * stored in little-endian order, so data written with this routine should be * put in that order in advance. diff --git a/lib/libpciaccess/src/freebsd_pci.c b/lib/libpciaccess/src/freebsd_pci.c index 67ca9e312..567b8f533 100644 --- a/lib/libpciaccess/src/freebsd_pci.c +++ b/lib/libpciaccess/src/freebsd_pci.c @@ -43,12 +43,7 @@ #include <sys/mman.h> #include <sys/memrange.h> -#if __FreeBSD_version >= 700053 -#define DOMAIN_SUPPORT 1 -#else -#define DOMAIN_SUPPORT 0 -#endif - +#include "config.h" #include "pciaccess.h" #include "pciaccess_private.h" @@ -64,6 +59,7 @@ * * It is initialized once and used as a global, just as pci_system is used. */ +_pci_hidden struct freebsd_pci_system { /* This must be the first entry in the structure, as pci_system_cleanup() * frees pci_sys. @@ -167,7 +163,7 @@ pci_device_freebsd_read( struct pci_device * dev, void * data, { struct pci_io io; -#if DOMAIN_SUPPORT +#if HAVE_PCI_IO_PC_DOMAIN io.pi_sel.pc_domain = dev->domain; #endif io.pi_sel.pc_bus = dev->bus; @@ -207,7 +203,7 @@ pci_device_freebsd_write( struct pci_device * dev, const void * data, { struct pci_io io; -#if DOMAIN_SUPPORT +#if HAVE_PCI_IO_PC_DOMAIN io.pi_sel.pc_domain = dev->domain; #endif io.pi_sel.pc_bus = dev->bus; @@ -487,7 +483,7 @@ pci_system_freebsd_create( void ) for ( i = 0; i < pciconfio.num_matches; i++ ) { struct pci_conf *p = &pciconf[ i ]; -#if DOMAIN_SUPPORT +#if HAVE_PCI_IO_PC_DOMAIN pci_sys->devices[ i ].base.domain = p->pc_sel.pc_domain; #else pci_sys->devices[ i ].base.domain = 0; diff --git a/lib/libpciaccess/src/linux_devmem.c b/lib/libpciaccess/src/linux_devmem.c index 21b45efdd..271e53f84 100644 --- a/lib/libpciaccess/src/linux_devmem.c +++ b/lib/libpciaccess/src/linux_devmem.c @@ -145,7 +145,7 @@ pci_device_linux_devmem_read_rom(struct pci_device *dev, void *buffer) const int tmp_err = pci_device_cfg_write_u32(& priv->base, rom_base_tmp, 48); - /* Prefer to return the first error that occured. + /* Prefer to return the first error that occurred. */ if (err == 0) { err = tmp_err; diff --git a/lib/libpciaccess/src/linux_sysfs.c b/lib/libpciaccess/src/linux_sysfs.c index 9e53fac21..8c3cf6750 100644 --- a/lib/libpciaccess/src/linux_sysfs.c +++ b/lib/libpciaccess/src/linux_sysfs.c @@ -26,7 +26,7 @@ * \file linux_sysfs.c * Access PCI subsystem using Linux's sysfs interface. This interface is * available starting somewhere in the late 2.5.x kernel phase, and is the - * prefered method on all 2.6.x kernels. + * preferred method on all 2.6.x kernels. * * \author Ian Romanick <idr@us.ibm.com> */ @@ -73,7 +73,7 @@ static int pci_device_linux_sysfs_read( struct pci_device * dev, void * data, static int pci_device_linux_sysfs_write( struct pci_device * dev, const void * data, pciaddr_t offset, pciaddr_t size, - pciaddr_t * bytes_wrtten ); + pciaddr_t * bytes_written ); static const struct pci_system_methods linux_sysfs_methods = { .destroy = NULL, @@ -484,6 +484,40 @@ pci_device_linux_sysfs_write( struct pci_device * dev, const void * data, return err; } +static int +pci_device_linux_sysfs_map_range_wc(struct pci_device *dev, + struct pci_device_mapping *map) +{ + char name[256]; + int fd; + const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) + ? (PROT_READ | PROT_WRITE) : PROT_READ; + const int open_flags = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) + ? O_RDWR : O_RDONLY; + const off_t offset = map->base - dev->regions[map->region].base_addr; + + snprintf(name, 255, "%s/%04x:%02x:%02x.%1u/resource%u_wc", + SYS_BUS_PCI, + dev->domain, + dev->bus, + dev->dev, + dev->func, + map->region); + fd = open(name, open_flags); + if (fd == -1) + return errno; + + map->memory = mmap(NULL, map->size, prot, MAP_SHARED, fd, offset); + if (map->memory == MAP_FAILED) { + map->memory = NULL; + close(fd); + return errno; + } + + close(fd); + + return 0; +} /** * Map a memory region for a device using the Linux sysfs interface. @@ -521,6 +555,11 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev, }; #endif + /* For WC mappings, try sysfs resourceN_wc file first */ + if ((map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE) && + !pci_device_linux_sysfs_map_range_wc(dev, map)) + return 0; + snprintf(name, 255, "%s/%04x:%02x:%02x.%1u/resource%u", SYS_BUS_PCI, dev->domain, @@ -537,12 +576,11 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev, map->memory = mmap(NULL, map->size, prot, MAP_SHARED, fd, offset); if (map->memory == MAP_FAILED) { - err = errno; map->memory = NULL; + close(fd); + return errno; } - close(fd); - #ifdef HAVE_MTRR if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) != 0) { sentry.type = MTRR_TYPE_WRBACK; @@ -562,11 +600,27 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev, } /* KLUDGE ALERT -- rewrite the PTEs to turn off the CD and WT bits */ mprotect (map->memory, map->size, PROT_NONE); - mprotect (map->memory, map->size, PROT_READ|PROT_WRITE); + err = mprotect (map->memory, map->size, PROT_READ|PROT_WRITE); + + if (err != 0) { + fprintf(stderr, "mprotect(PROT_READ | PROT_WRITE) failed: %s\n", + strerror(errno)); + fprintf(stderr, "remapping without mprotect performance kludge.\n"); + + munmap(map->memory, map->size); + map->memory = mmap(NULL, map->size, prot, MAP_SHARED, fd, offset); + if (map->memory == MAP_FAILED) { + map->memory = NULL; + close(fd); + return errno; + } + } } #endif - return err; + close(fd); + + return 0; } /** diff --git a/lib/libpciaccess/src/netbsd_pci.c b/lib/libpciaccess/src/netbsd_pci.c new file mode 100644 index 000000000..8b39edf67 --- /dev/null +++ b/lib/libpciaccess/src/netbsd_pci.c @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2008 Juan Romero Pardines + * Copyright (c) 2008 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/types.h> + +#include <machine/sysarch.h> +#include <machine/mtrr.h> + +#include <dev/pci/pciio.h> +#include <dev/pci/pcireg.h> +#include <dev/pci/pcidevs.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +#include "pciaccess.h" +#include "pciaccess_private.h" + +static int pcifd; + +static int +pci_read(int bus, int dev, int func, uint32_t reg, uint32_t *val) +{ + struct pciio_bdf_cfgreg io; + int err; + + bzero(&io, sizeof(io)); + io.bus = bus; + io.device = dev; + io.function = func; + io.cfgreg.reg = reg; + + err = ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io); + if (err) + return (err); + + *val = io.cfgreg.val; + + return 0; +} + +static int +pci_write(int bus, int dev, int func, uint32_t reg, uint32_t val) +{ + struct pciio_bdf_cfgreg io; + + bzero(&io, sizeof(io)); + io.bus = bus; + io.device = dev; + io.function = func; + io.cfgreg.reg = reg; + io.cfgreg.val = val; + + return ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io); +} + +static int +pci_nfuncs(int bus, int dev) +{ + uint32_t hdr; + + if (pci_read(bus, dev, 0, PCI_BHLC_REG, &hdr) != 0) + return -1; + + return (PCI_HDRTYPE_MULTIFN(hdr) ? 8 : 1); +} + +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; + + if ((fd = open("/dev/mem", O_RDWR)) == -1) + return errno; + + if (map->flags & PCI_DEV_MAP_FLAG_WRITABLE) + prot |= PROT_WRITE; + + map->memory = mmap(NULL, map->size, prot, MAP_SHARED, + fd, map->base); + if (map->memory == MAP_FAILED) + return errno; + + /* No need to set an MTRR if it's the default mode. */ + if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) || + (map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)) { + mtrr.base = map->base; + mtrr.len = map->size; + mtrr.flags = MTRR_VALID; + + if (map->flags & PCI_DEV_MAP_FLAG_CACHABLE) + mtrr.type = MTRR_TYPE_WB; + 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; + } + } + + close(fd); + + return 0; +} + +static int +pci_device_netbsd_unmap_range(struct pci_device *dev, + struct pci_device_mapping *map) +{ + struct mtrr mtrr; + int nmtrr, error; + + 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; + } + + return pci_device_generic_unmap_range(dev, map); +} + +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; + + *bytes_read = 0; + while (size > 0) { + int toread = MIN(size, 4 - (offset & 0x3)); + + io.cfgreg.reg = (offset & ~0x3); + + if (ioctl(pcifd, PCI_IOC_BDF_CFGREAD, &io) == -1) + return errno; + + io.cfgreg.val = htole32(io.cfgreg.val); + io.cfgreg.val >>= ((offset & 0x3) * 8); + + memcpy(data, &io.cfgreg.val, toread); + + offset += toread; + data = (char *)data + toread; + size -= toread; + *bytes_read += toread; + } + + return 0; +} + +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; + + 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); + + if (ioctl(pcifd, PCI_IOC_BDF_CFGWRITE, &io) == -1) + return errno; + + offset += 4; + data = (char *)data + 4; + size -= 4; + *bytes_written += 4; + } + + return 0; +} + +static void +pci_system_netbsd_destroy(void) +{ + close(pcifd); + free(pci_sys); + pci_sys = NULL; +} + +static int +pci_device_netbsd_probe(struct pci_device *device) +{ + struct pci_device_private *priv = (struct pci_device_private *)device; + struct pci_mem_region *region; + uint64_t reg64, size64; + uint32_t bar, reg, size; + int bus, dev, func, err; + + bus = device->bus; + dev = device->dev; + func = device->func; + + err = pci_read(bus, dev, func, PCI_BHLC_REG, ®); + if (err) + return err; + + priv->header_type = PCI_HDRTYPE_TYPE(reg); + if (priv->header_type != 0) + return 0; + + region = device->regions; + for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END; + bar += sizeof(uint32_t), region++) { + err = pci_read(bus, dev, func, bar, ®); + if (err) + return err; + + /* Probe the size of the region. */ + err = pci_write(bus, dev, func, bar, ~0); + if (err) + return err; + pci_read(bus, dev, func, bar, &size); + pci_write(bus, dev, func, bar, reg); + + if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_IO) { + region->is_IO = 1; + region->base_addr = PCI_MAPREG_IO_ADDR(reg); + region->size = PCI_MAPREG_IO_SIZE(size); + } else { + if (PCI_MAPREG_MEM_PREFETCHABLE(reg)) + region->is_prefetchable = 1; + switch(PCI_MAPREG_MEM_TYPE(reg)) { + case PCI_MAPREG_MEM_TYPE_32BIT: + case PCI_MAPREG_MEM_TYPE_32BIT_1M: + region->base_addr = PCI_MAPREG_MEM_ADDR(reg); + region->size = PCI_MAPREG_MEM_SIZE(size); + break; + case PCI_MAPREG_MEM_TYPE_64BIT: + region->is_64 = 1; + + reg64 = reg; + size64 = size; + + bar += sizeof(uint32_t); + + err = pci_read(bus, dev, func, bar, ®); + if (err) + return err; + reg64 |= (uint64_t)reg << 32; + + err = pci_write(bus, dev, func, bar, ~0); + if (err) + return err; + pci_read(bus, dev, func, bar, &size); + pci_write(bus, dev, func, bar, reg64 >> 32); + size64 |= (uint64_t)size << 32; + + region->base_addr = PCI_MAPREG_MEM64_ADDR(reg64); + region->size = PCI_MAPREG_MEM64_SIZE(size64); + region++; + break; + } + } + } + + return 0; +} + +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 +}; + +int +pci_system_netbsd_create(void) +{ + struct pci_device_private *device; + int bus, dev, func, ndevs, nfuncs; + uint32_t reg; + + pcifd = open("/dev/pci0", O_RDWR); + if (pcifd == -1) + return ENXIO; + + 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); + for (func = 0; func < nfuncs; func++) { + if (pci_read(bus, dev, func, PCI_ID_REG, + ®) != 0) + continue; + if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID || + PCI_VENDOR(reg) == 0) + continue; + + ndevs++; + } + } + } + + pci_sys->num_devices = ndevs; + pci_sys->devices = calloc(ndevs, sizeof(struct pci_device_private)); + if (pci_sys->devices == NULL) { + 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 (func = 0; func < nfuncs; func++) { + if (pci_read(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.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) + continue; + + device->base.device_class = + PCI_INTERFACE(reg) | PCI_CLASS(reg) << 16 | + PCI_SUBCLASS(reg) << 8; + device->base.revision = PCI_REVISION(reg); + + if (pci_read(bus, dev, func, PCI_SUBSYS_ID_REG, + ®) != 0) + continue; + + device->base.subvendor_id = PCI_VENDOR(reg); + device->base.subdevice_id = PCI_PRODUCT(reg); + + device++; + } + } + } + + return 0; +} diff --git a/lib/libpciaccess/src/pci_tools.h b/lib/libpciaccess/src/pci_tools.h index 03059230a..e9010f206 100644 --- a/lib/libpciaccess/src/pci_tools.h +++ b/lib/libpciaccess/src/pci_tools.h @@ -1,25 +1,30 @@ /* - * Copyright (c) 2007, Sun Microsystems, Inc. - * All Rights Reserved. - * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM AND/OR THEIR SUPPLIERS 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. + * 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, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * 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 + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. */ #ifndef _SYS_PCI_TOOLS_H #define _SYS_PCI_TOOLS_H @@ -184,7 +189,7 @@ typedef struct pcitool_intr_get { #define PCITOOL_ACC_IS_BIG_ENDIAN(x) (x & PCITOOL_ACC_ATTR_ENDN_BIG) /* - * Data stucture to read and write to pci device registers. + * Data structure to read and write to pci device registers. * This is the argument to the following ioctls: * PCITOOL_DEVICE_SET/GET_REG * PCITOOL_NEXUS_SET/GET_REG diff --git a/lib/libpciaccess/src/pciaccess_private.h b/lib/libpciaccess/src/pciaccess_private.h index 6048af1fa..bff69039e 100644 --- a/lib/libpciaccess/src/pciaccess_private.h +++ b/lib/libpciaccess/src/pciaccess_private.h @@ -136,6 +136,7 @@ extern struct pci_system * pci_sys; extern int pci_system_linux_sysfs_create( void ); extern int pci_system_freebsd_create( void ); +extern int pci_system_netbsd_create( void ); extern int pci_system_openbsd_create( void ); extern void pci_system_openbsd_init_dev_mem( int ); extern int pci_system_solx_devfs_create( void ); diff --git a/lib/libpciaccess/src/scanpci.c b/lib/libpciaccess/src/scanpci.c index c8a6adf81..c640258c2 100644 --- a/lib/libpciaccess/src/scanpci.c +++ b/lib/libpciaccess/src/scanpci.c @@ -181,6 +181,23 @@ int main( int argc, char ** argv ) struct pci_device_iterator * iter; struct pci_device * dev; int ret; + int verbose = 0; + int c; + int errors = 0; + + while ((c = getopt(argc, argv, "v")) != -1) { + switch (c) { + case 'v': + verbose = 1; + break; + case '?': + errors++; + } + } + if (errors != 0) { + fprintf(stderr, "usage: %s [-v]\n", argv[0]); + exit(2); + } ret = pci_system_init(); if (ret != 0) @@ -189,7 +206,7 @@ int main( int argc, char ** argv ) iter = pci_slot_match_iterator_create( NULL ); while ( (dev = pci_device_next( iter )) != NULL ) { - print_pci_device( dev, 1 ); + print_pci_device( dev, verbose ); } pci_system_cleanup(); diff --git a/lib/libpciaccess/src/scanpci.man b/lib/libpciaccess/src/scanpci.man new file mode 100644 index 000000000..aec7b2ed3 --- /dev/null +++ b/lib/libpciaccess/src/scanpci.man @@ -0,0 +1,44 @@ +.\" Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved. +.\" +.\" Permission is hereby granted, free of charge, to any person obtaining a copy +.\" of this software and associated documentation files (the "Software"), to +.\" deal in the Software without restriction, including without limitation the +.\" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +.\" sell copies of the Software, and to permit persons to whom the Software is +.\" furnished to do so, subject to the following conditions: +.\" +.\" The above copyright notice and this permission notice shall be included in +.\" all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +.\" XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +.\" IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of the XFree86 Project shall +.\" not be used in advertising or otherwise to promote the sale, use or other +.\" dealings in this Software without prior written authorization from the +.\" XFree86 Project. +.\" +.TH SCANPCI 1 __xorgversion__ +.SH NAME +scanpci - scan/probe PCI buses +.SH SYNOPSIS +.B scanpci +.RB [ \-v ] +.SH DESCRIPTION +.I Scanpci +is a utility that can be used to scan PCI buses and report information +about the configuration space settings for each PCI device. +On most platforms, +.I scanpci +can only be run by the root user. +.SH OPTIONS +.TP 8 +.B \-v +Print the configuration space information for each device in a verbose +format. Without this option, only a brief description is printed for +each device. + diff --git a/lib/libpciaccess/src/solx_devfs.c b/lib/libpciaccess/src/solx_devfs.c index a2daec164..e1848418a 100644 --- a/lib/libpciaccess/src/solx_devfs.c +++ b/lib/libpciaccess/src/solx_devfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Sun Microsystems, Inc. + * (C) Copyright IBM Corporation 2006 * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -21,48 +21,78 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * 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 + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ /* * Solaris devfs interfaces */ -#define _GNU_SOURCE - #include <stdlib.h> #include <strings.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> -#include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> -#include <dirent.h> #include <errno.h> #include <sys/pci.h> -#include <assert.h> #include <libdevinfo.h> #include "pci_tools.h" #include "pciaccess.h" #include "pciaccess_private.h" -#define PCI_NEXUS_1 "/devices/pci@0,0:reg" #define MAX_DEVICES 256 -#define CELL_NUMS_1275 (sizeof(pci_regspec_t)/sizeof(uint_t)) +#define CELL_NUMS_1275 (sizeof(pci_regspec_t) / sizeof(uint_t)) + typedef union { - uint8_t bytes[16 * sizeof (uint32_t)]; - uint32_t dwords[16]; + 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; - uint8_t func; - di_node_t node; -}i_devnode_t; - -static int root_fd = -1; + uint8_t bus; + uint8_t dev; + uint8_t func; + di_node_t node; +} i_devnode_t; + +typedef struct nexus { + int fd; + int domain; + struct nexus *next; +} nexus_t; + +static nexus_t *nexus_list = NULL; +static int num_domains = 0; static int xsvc_fd = -1; + /* * Read config space in native processor endianness. Endian-neutral * processing can then take place. On big endian machines, MSB and LSB @@ -70,11 +100,11 @@ static int xsvc_fd = -1; * They are in correct order if read as big endian. */ #if defined(__sparc) -#define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_BIG +# define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_BIG #elif defined(__x86) -#define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_LTL +# define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_LTL #else -#error "ISA is neither __sparc nor __x86" +# error "ISA is neither __sparc nor __x86" #endif /* @@ -90,11 +120,11 @@ static int xsvc_fd = -1; * otherwise disappear. */ #if (NATIVE_ENDIAN == PCITOOL_ACC_ATTR_ENDN_BIG) -#define U45_SB_DEVID_VID 0xb9104952 -#define U45_SB_CLASS_RID 0x00000406 +# 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 +# define U45_SB_DEVID_VID 0x524910b9 +# define U45_SB_CLASS_RID 0x06040000 #endif #define DEBUGON 0 @@ -113,26 +143,21 @@ static int pci_device_solx_devfs_read( struct pci_device * dev, void * data, static int pci_device_solx_devfs_write( struct pci_device * dev, const void * data, pciaddr_t offset, pciaddr_t size, - pciaddr_t * bytes_wrtten ); + pciaddr_t * bytes_written ); -static int -probe_dev(int fd, pcitool_reg_t *prg_p, struct pci_system *pci_sys); +static int probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, + struct pci_system *pci_sys); -static int -do_probe(int fd, struct pci_system *pci_sys); +static int do_probe(nexus_t *nexus, struct pci_system *pci_sys); -static void -pci_system_solx_devfs_destroy( void ); - -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); - -int -pci_system_solx_devfs_create( void ); +static int probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg); +static void pci_system_solx_devfs_destroy( void ); +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); +int pci_system_solx_devfs_create( void ); static const struct pci_system_methods solx_devfs_methods = { .destroy = pci_system_solx_devfs_destroy, @@ -148,78 +173,108 @@ static const struct pci_system_methods solx_devfs_methods = { .fill_capabilities = pci_fill_capabilities_generic }; +static nexus_t * +find_nexus_for_domain( int domain ) +{ + nexus_t *nexus; + + for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) { + if (nexus->domain == domain) { + return nexus; + } + } + return NULL; +} + +#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)) + /* - * Rlease all the resources + * Release all the resources * Solaris version */ static void pci_system_solx_devfs_destroy( void ) { - /* - * the memory allocated in create routines - * will be freed in pci_system_init - * It is more reasonable to free them here - */ - if (root_fd >= 0) { - close(root_fd); - root_fd = -1; - } - - if (xsvc_fd >= 0) { - close(xsvc_fd); - xsvc_fd = -1; - } - + /* + * The memory allocated for pci_sys & devices in create routines + * will be freed in pci_system_cleanup. + * Need to free system-specific allocations here. + */ + nexus_t *nexus, *next; + + for (nexus = nexus_list ; nexus != NULL ; nexus = next) { + next = nexus->next; + close(nexus->fd); + free(nexus); + } + nexus_list = NULL; + + if (xsvc_fd >= 0) { + close(xsvc_fd); + xsvc_fd = -1; + } } + /* * Attempt to access PCI subsystem using Solaris's devfs interface. * Solaris version */ -int +_pci_hidden int pci_system_solx_devfs_create( void ) { - int err = 0; + int err = 0; + di_node_t di_node; - if (root_fd >= 0) - return (err); - /* If the directory "/sys/bus/pci/devices" exists, - * then the PCI subsystem can be accessed using - * this interface. - */ - if ((root_fd = open(PCI_NEXUS_1, O_RDWR)) == -1) { - (void) fprintf(stderr, - "Could not open nexus node %s: %s\n", - PCI_NEXUS_1, strerror(errno)); + if (nexus_list != NULL) { + return 0; + } - err = errno; + /* + * Only allow MAX_DEVICES exists + * I will fix it later to get + * the total devices first + */ + if ((pci_sys = calloc(1, sizeof (struct pci_system))) != NULL) { + pci_sys->methods = &solx_devfs_methods; - return (err); - } else { - /* - * Only allow MAX_DEVICES exists - * I will fix it later to get - * the total devices first - */ - if ((pci_sys = calloc(1, sizeof (struct pci_system))) != NULL) { - pci_sys->methods = &solx_devfs_methods; - if ((pci_sys->devices = - calloc(MAX_DEVICES, - sizeof (struct pci_device_private))) != NULL) { - (void) do_probe(root_fd, pci_sys); - } - else { - err = errno; - free(pci_sys); - pci_sys = NULL; - } - } else { - err = errno; - } - + if ((pci_sys->devices = + calloc(MAX_DEVICES, sizeof (struct pci_device_private))) + != NULL) { + + if ((di_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { + err = errno; + (void) fprintf(stderr, "di_init() failed: %s\n", + strerror(errno)); + } else { + (void) di_walk_minor(di_node, DDI_NT_REGACC, 0, pci_sys, + probe_nexus_node); + di_fini(di_node); + } } - - return (err); + else { + err = errno; + } + } else { + err = errno; + } + + if (err != 0) { + if (pci_sys != NULL) { + free(pci_sys->devices); + free(pci_sys); + pci_sys = NULL; + } + } + + return (err); } /* @@ -228,32 +283,31 @@ pci_system_solx_devfs_create( void ) */ 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) + pci_conf_hdr_t *config_hdr_p) { - 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; + 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); + return (rval); } @@ -261,178 +315,232 @@ get_config_header(int fd, uint8_t bus_no, uint8_t dev_no, uint8_t func_no, * Probe device's functions. Modifies many fields in the prg_p. */ static int -probe_dev(int fd, pcitool_reg_t *prg_p, struct pci_system *pci_sys) +probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, struct pci_system *pci_sys) { - 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; - + 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; /* - * Loop through at least func=first_func. Continue looping through - * functions if there are no errors and the device is a multi-function - * device. + * 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. * - * (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. + * 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. */ - 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; - if (((rval = ioctl(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; - } - - /* - * 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; - } - - /* - * 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)) { - - 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 amd 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(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 numer, device number and - * function number. - */ - - /* - * Domain is peer bus?? - */ - pci_sys->devices[pci_sys->num_devices].base.domain = 0; - pci_sys->devices[pci_sys->num_devices].base.bus = - prg_p->bus_no; - pci_sys->devices[pci_sys->num_devices].base.dev = - prg_p->dev_no; - pci_sys->devices[pci_sys->num_devices].base.func = func; - /* - * for the format of device_class, see struct pci_device; - */ - pci_sys->devices[pci_sys->num_devices].base.device_class = - config_hdr.dwords[2]>>8; - pci_sys->devices[pci_sys->num_devices].base.revision = - (uint8_t)(config_hdr.dwords[2] & 0xff); - pci_sys->devices[pci_sys->num_devices].base.vendor_id = - (uint16_t)(config_hdr.dwords[0] & 0xffff); - pci_sys->devices[pci_sys->num_devices].base.device_id = - (uint16_t)((config_hdr.dwords[0]>>16) & 0xffff); - pci_sys->devices[pci_sys->num_devices].base.subvendor_id = - (uint16_t)(config_hdr.dwords[11] & 0xffff); - pci_sys->devices[pci_sys->num_devices].base.subdevice_id = - (uint16_t)((config_hdr.dwords[11]>>16) & 0xffff); - pci_sys->devices[pci_sys->num_devices].header_type = - (uint8_t)(((config_hdr.dwords[3])&0xff0000)>>16); + + 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; + } + + /* + * 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; + } + + /* + * 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)) { + 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 = &pci_sys->devices[pci_sys->num_devices].base; + + /* + * Domain is peer bus?? + */ + 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_sys->devices[pci_sys->num_devices].header_type + = GET_CONFIG_VAL_8(PCI_CONF_HEADER); + #if DEBUGON - fprintf(stderr, "busno = %x, devno = %x, funcno = %x\n", - prg_p->bus_no, prg_p->dev_no, func); + fprintf(stderr, "busno = %x, devno = %x, funcno = %x\n", + prg_p->bus_no, prg_p->dev_no, func); #endif - pci_sys->num_devices++; - - /* - * Accomodate 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; - } - } + pci_sys->num_devices++; + + /* + * 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; + } } + } - return (rval); + return (rval); } /* + * This function is called from di_walk_minor() when any PROBE is processed + */ +static int +probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg) +{ + struct pci_system *pci_sys = (struct pci_system *) arg; + char *nexus_name; + nexus_t *nexus; + int fd; + char nexus_path[MAXPATHLEN]; + + nexus = calloc(1, sizeof(nexus_t)); + if (nexus == NULL) { + (void) fprintf(stderr, "Error allocating memory for nexus: %s\n", + strerror(errno)); + return DI_WALK_TERMINATE; + } + + nexus_name = di_devfs_minor_path(minor); + if (nexus_name == NULL) { + (void) fprintf(stderr, "Error getting nexus path: %s\n", + strerror(errno)); + free(nexus); + return (DI_WALK_CONTINUE); + } + + snprintf(nexus_path, sizeof(nexus_path), "/devices%s", nexus_name); + di_devfs_path_free(nexus_name); + + if ((fd = open(nexus_path, O_RDWR)) >= 0) { + nexus->fd = fd; + nexus->domain = num_domains++; + if ((do_probe(nexus, pci_sys) != 0) && (errno != ENXIO)) { + (void) fprintf(stderr, "Error probing node %s: %s\n", + nexus_path, strerror(errno)); + (void) close(fd); + free(nexus); + } else { + nexus->next = nexus_list; + nexus_list = nexus; + } + } else { + (void) fprintf(stderr, "Error opening %s: %s\n", + nexus_path, strerror(errno)); + free(nexus); + } + + return DI_WALK_CONTINUE; +} + + +/* * Solaris version * Probe a given nexus config space for devices. * @@ -440,112 +548,112 @@ probe_dev(int fd, pcitool_reg_t *prg_p, struct pci_system *pci_sys) * input_args contains commandline options as specified by the user. */ static int -do_probe(int fd, struct pci_system *pci_sys) +do_probe(nexus_t *nexus, struct pci_system *pci_sys) { - pcitool_reg_t prg; - uint32_t bus; - uint8_t dev; - uint32_t last_bus = PCI_REG_BUS_M >> PCI_REG_BUS_SHIFT; - uint8_t last_dev = PCI_REG_DEV_M >> PCI_REG_DEV_SHIFT; - uint8_t first_bus = 0; - 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; + pcitool_reg_t prg; + uint32_t bus; + uint8_t dev; + uint32_t last_bus = PCI_REG_BUS_M >> PCI_REG_BUS_SHIFT; + uint8_t last_dev = PCI_REG_DEV_M >> PCI_REG_DEV_SHIFT; + uint8_t first_bus = 0; + 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, pci_sys); + } /* - * 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. + * Ultra-45 southbridge workaround: + * ECANCELED tells to skip to the next bus. */ - 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(fd, &prg, pci_sys); - } - - /* - * Ultra-45 southbridge workaround: - * ECANCELED tells to skip to the next bus. - */ - if (rval == ECANCELED) { - rval = 0; - } - } - if (pci_sys->num_devices > MAX_DEVICES) { - (void) fprintf(stderr, "pci devices reach maximu number\n"); + if (rval == ECANCELED) { + rval = 0; } + } + if (pci_sys->num_devices > MAX_DEVICES) { + (void) fprintf(stderr, "pci devices reach maximum number\n"); + } - return (rval); + return (rval); } static int find_target_node(di_node_t node, void *arg) { - int *regbuf = NULL; - int len = 0; - uint32_t busno, funcno, devno; - i_devnode_t *devnode; - void *prop = DI_PROP_NIL; - int i; - - devnode = (i_devnode_t *)arg; - - /* - * Test the property funtions, only for testing - */ - /* - (void) fprintf(stderr, "start of node 0x%x\n", node->nodeid); - while ((prop = di_prop_hw_next(node, prop)) != DI_PROP_NIL) { - (void) fprintf(stderr, "name=%s: ", di_prop_name(prop)); - len = 0; - if (!strcmp(di_prop_name(prop), "reg")) { - len = di_prop_ints(prop, ®buf); - } - for (i = 0; i < len; i++) { - fprintf(stderr, "0x%0x.", regbuf[i]); - } - fprintf(stderr, "\n"); + int *regbuf = NULL; + int len = 0; + uint32_t busno, funcno, devno; + i_devnode_t *devnode; + void *prop = DI_PROP_NIL; + int i; + + devnode = (i_devnode_t *)arg; + + /* + * Test the property functions, only for testing + */ + /* + (void) fprintf(stderr, "start of node 0x%x\n", node->nodeid); + while ((prop = di_prop_hw_next(node, prop)) != DI_PROP_NIL) { + (void) fprintf(stderr, "name=%s: ", di_prop_name(prop)); + len = 0; + if (!strcmp(di_prop_name(prop), "reg")) { + len = di_prop_ints(prop, ®buf); } - (void) fprintf(stderr, "end of node 0x%x\n", node->nodeid); - */ - - len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", - ®buf); + for (i = 0; i < len; i++) { + fprintf(stderr, "0x%0x.", regbuf[i]); + } + fprintf(stderr, "\n"); + } + (void) fprintf(stderr, "end of node 0x%x\n", node->nodeid); + */ + + len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", ®buf); - if (len <= 0) { + if (len <= 0) { #if DEBUGON - fprintf(stderr, "error = %x\n", errno); - fprintf(stderr, "can not find assigned-address\n"); + fprintf(stderr, "error = %x\n", errno); + fprintf(stderr, "can not find assigned-address\n"); #endif - return (DI_WALK_CONTINUE); - } - busno = PCI_REG_BUS_G(regbuf[0]); - devno = PCI_REG_DEV_G(regbuf[0]); - funcno = PCI_REG_FUNC_G(regbuf[0]); - - if ((busno == devnode->bus) && - (devno == devnode->dev) && - (funcno == devnode->func)) { - devnode->node = node; - - return (DI_WALK_TERMINATE); - } - return (DI_WALK_CONTINUE); + } + + busno = PCI_REG_BUS_G(regbuf[0]); + devno = PCI_REG_DEV_G(regbuf[0]); + funcno = PCI_REG_FUNC_G(regbuf[0]); + + if ((busno == devnode->bus) && + (devno == devnode->dev) && + (funcno == devnode->func)) { + devnode->node = node; + + return (DI_WALK_TERMINATE); + } + + return (DI_WALK_CONTINUE); } /* @@ -554,177 +662,162 @@ find_target_node(di_node_t node, void *arg) static int pci_device_solx_devfs_probe( struct pci_device * dev ) { - uint8_t config[256]; - int err; - di_node_t rnode; - i_devnode_t args; - int *regbuf; - pci_regspec_t *reg; - int i; - pciaddr_t bytes; - int len = 0; - - err = pci_device_solx_devfs_read( dev, config, 0, 256, & bytes ); - args.node = DI_NODE_NIL; - if ( bytes >= 64 ) { - struct pci_device_private *priv = - (struct pci_device_private *) dev; - - dev->vendor_id = - (uint16_t)config[0] + ((uint16_t)config[1] << 8); - dev->device_id = - (uint16_t)config[2] + ((uint16_t)config[3] << 8); - dev->device_class = (uint32_t)config[9] + - ((uint32_t)config[10] << 8) + - ((uint16_t)config[11] << 16); - /* - * device class code is already there. - * see probe_dev function. - */ - dev->revision = config[8]; - dev->subvendor_id = - (uint16_t)config[44] + ((uint16_t)config[45] << 8); - dev->subdevice_id = - (uint16_t)config[46] + ((uint16_t)config[47] << 8); - dev->irq = config[60]; - - priv->header_type = config[14]; - /* - * starting to find if it is MEM/MEM64/IO - * using libdevinfo - */ - if ((rnode = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { - (void) fprintf(stderr, "di_init failed: %s\n", - strerror(errno)); - err = errno; - } else { - args.bus = dev->bus; - args.dev = dev->dev; - args.func = dev->func; - (void) di_walk_node(rnode, DI_WALK_CLDFIRST, - (void *)&args, find_target_node); - di_fini(rnode); - } - } - if (args.node != DI_NODE_NIL) { - /* - * It will success for sure, because it was - * successfully called in find_target_node - */ - len = di_prop_lookup_ints(DDI_DEV_T_ANY, args.node, - "assigned-addresses", - ®buf); + uint8_t config[256]; + int err; + di_node_t rnode; + i_devnode_t args; + int *regbuf; + pci_regspec_t *reg; + int i; + pciaddr_t bytes; + int len = 0; + + err = pci_device_solx_devfs_read( dev, config, 0, 256, & bytes ); + args.node = DI_NODE_NIL; + + if ( bytes >= 64 ) { + struct pci_device_private *priv = + (struct pci_device_private *) dev; + + dev->vendor_id = (uint16_t)config[0] + ((uint16_t)config[1] << 8); + dev->device_id = (uint16_t)config[2] + ((uint16_t)config[3] << 8); + dev->device_class = (uint32_t)config[9] + + ((uint32_t)config[10] << 8) + + ((uint16_t)config[11] << 16); + + /* + * device class code is already there. + * see probe_dev function. + */ + dev->revision = config[8]; + dev->subvendor_id = (uint16_t)config[44] + ((uint16_t)config[45] << 8); + dev->subdevice_id = (uint16_t)config[46] + ((uint16_t)config[47] << 8); + dev->irq = config[60]; + priv->header_type = config[14]; + /* + * starting to find if it is MEM/MEM64/IO + * using libdevinfo + */ + if ((rnode = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { + err = errno; + (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno)); + } else { + args.bus = dev->bus; + args.dev = dev->dev; + args.func = dev->func; + (void) di_walk_node(rnode, DI_WALK_CLDFIRST, + (void *)&args, find_target_node); + di_fini(rnode); } + } + if (args.node != DI_NODE_NIL) { + /* + * It will succeed for sure, because it was + * successfully called in find_target_node + */ + len = di_prop_lookup_ints(DDI_DEV_T_ANY, args.node, + "assigned-addresses", + ®buf); - if (len <= 0) - return (err); + } + if (len <= 0) + return (err); + + /* + * 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) { /* - * 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. + * rom can only be 32 bits */ - 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; + 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. To be sure that + * Xorg has the same BAR number as solaris. ???? + */ + for (i = 0; i < len; i = i + CELL_NUMS_1275) { + int ent = i/CELL_NUMS_1275; + + reg = (pci_regspec_t *)®buf[i]; + + /* + * 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; } - else { - /* - * size default to 64K and base address - * default to 0xC0000 - */ - dev->rom_size = 0x10000; + + 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; + break; } /* - * solaris has its own BAR index. To be sure that - * Xorg has the same BAR number as solaris. ???? + * We split the shift count 32 into two 16 to + * avoid the complaining of the compiler */ - for (i = 0; i < len; i = i + CELL_NUMS_1275) { - int ent = i/CELL_NUMS_1275; - - reg = (pci_regspec_t *)®buf[i]; - - /* - * 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; - } - - 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; - break; - } - /* - * 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); - } - + 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); + } return (err); } /* - * Solaris version: read the ROM data + * Solaris version: read the VGA ROM data */ static int pci_device_solx_devfs_read_rom( struct pci_device * dev, void * buffer ) { - void *prom = MAP_FAILED; - - if (xsvc_fd < 0) { - if ((xsvc_fd = open("/dev/xsvc", O_RDWR)) < 0) { - (void) fprintf(stderr, "can not open xsvc driver\n"); - - return (-1); - } - } - - prom = mmap(NULL, dev->rom_size, - PROT_READ, MAP_SHARED, - xsvc_fd, 0xC0000); - - if (prom == MAP_FAILED) { - (void) fprintf(stderr, "map rom base =0xC0000 failed"); - return (-1); + int err; + struct pci_device_mapping prom = { + .base = 0xC0000, + .size = dev->rom_size, + .flags = 0 + }; + + 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) { + err = errno; } - (void) bcopy(prom, buffer, dev->rom_size); - - - /* - * Still used xsvc to do the user space mapping - */ - return (0); - + } + return err; } /* @@ -735,41 +828,47 @@ pci_device_solx_devfs_read( struct pci_device * dev, void * data, pciaddr_t offset, pciaddr_t size, pciaddr_t * bytes_read ) { - pcitool_reg_t cfg_prg; - int err = 0; - int i = 0; - - cfg_prg.offset = offset; - cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN; - cfg_prg.bus_no = dev->bus; - cfg_prg.dev_no = dev->dev; - cfg_prg.func_no = dev->func; - cfg_prg.barnum = 0; - cfg_prg.user_version = PCITOOL_USER_VERSION; - *bytes_read = 0; - - for (i = 0; i < size; i = i + PCITOOL_ACC_ATTR_SIZE(PCITOOL_ACC_ATTR_SIZE_1)) { - - cfg_prg.offset = offset + i; - if ((err = ioctl(root_fd, PCITOOL_DEVICE_GET_REG, - &cfg_prg)) != 0) { - fprintf(stderr, "read bdf<%x,%x,%x,%llx> config space failure\n", - cfg_prg.bus_no, - cfg_prg.dev_no, - cfg_prg.func_no, - cfg_prg.offset); - fprintf(stderr, "Failure cause = %x\n", err); - break; - } - - ((uint8_t *)data)[i] = (uint8_t)cfg_prg.data; - /* - * DWORDS Offset or bytes Offset ?? - */ + pcitool_reg_t cfg_prg; + int err = 0; + int i = 0; + nexus_t *nexus = find_nexus_for_domain(dev->domain); + + *bytes_read = 0; + + if ( nexus == NULL ) { + return ENODEV; + } + + cfg_prg.offset = offset; + cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN; + cfg_prg.bus_no = dev->bus; + cfg_prg.dev_no = dev->dev; + cfg_prg.func_no = dev->func; + cfg_prg.barnum = 0; + cfg_prg.user_version = PCITOOL_USER_VERSION; + + for (i = 0; i < size; i += PCITOOL_ACC_ATTR_SIZE(PCITOOL_ACC_ATTR_SIZE_1)) + { + cfg_prg.offset = offset + i; + + if ((err = ioctl(nexus->fd, PCITOOL_DEVICE_GET_REG, &cfg_prg)) != 0) { + fprintf(stderr, "read bdf<%x,%x,%x,%llx> config space failure\n", + cfg_prg.bus_no, + cfg_prg.dev_no, + cfg_prg.func_no, + cfg_prg.offset); + fprintf(stderr, "Failure cause = %x\n", err); + break; } - *bytes_read = i; - return (err); + ((uint8_t *)data)[i] = (uint8_t)cfg_prg.data; + /* + * DWORDS Offset or bytes Offset ?? + */ + } + *bytes_read = i; + + return (err); } /* @@ -780,63 +879,67 @@ pci_device_solx_devfs_write( struct pci_device * dev, const void * data, pciaddr_t offset, pciaddr_t size, pciaddr_t * bytes_written ) { - pcitool_reg_t cfg_prg; - int err = 0; - int cmd; - - - if ( bytes_written != NULL ) { - *bytes_written = 0; - } - - cfg_prg.offset = offset; - switch (size) { - case 1: - cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN; - break; - case 2: - cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_2 + NATIVE_ENDIAN; - break; - case 4: - cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN; - break; - case 8: - cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 + NATIVE_ENDIAN; - break; - default: - assert(0); - - } - cfg_prg.bus_no = dev->bus; - cfg_prg.dev_no = dev->dev; - cfg_prg.func_no = dev->func; - cfg_prg.barnum = 0; - cfg_prg.user_version = PCITOOL_USER_VERSION; - cfg_prg.data = *((uint64_t *)data); - /* - * Check if this device is bridge device. - * If it is, it is also a nexus node??? - * It seems that there is no explicit - * PCI nexus device for X86, so not applicable - * from pcitool_bus_reg_ops in pci_tools.c - */ - cmd = PCITOOL_DEVICE_SET_REG; - - if ((err = ioctl(root_fd, cmd, &cfg_prg)) != 0) { - return (err); - } - *bytes_written = size; - + pcitool_reg_t cfg_prg; + int err = 0; + int cmd; + nexus_t *nexus = find_nexus_for_domain(dev->domain); + + if ( bytes_written != NULL ) { + *bytes_written = 0; + } + + if ( nexus == NULL ) { + return ENODEV; + } + + cfg_prg.offset = offset; + switch (size) { + case 1: + cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN; + break; + case 2: + cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_2 + NATIVE_ENDIAN; + break; + case 4: + cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN; + break; + case 8: + cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 + NATIVE_ENDIAN; + break; + default: + return EINVAL; + } + cfg_prg.bus_no = dev->bus; + cfg_prg.dev_no = dev->dev; + cfg_prg.func_no = dev->func; + cfg_prg.barnum = 0; + cfg_prg.user_version = PCITOOL_USER_VERSION; + cfg_prg.data = *((uint64_t *)data); + + /* + * Check if this device is bridge device. + * If it is, it is also a nexus node??? + * It seems that there is no explicit + * PCI nexus device for X86, so not applicable + * from pcitool_bus_reg_ops in pci_tools.c + */ + cmd = PCITOOL_DEVICE_SET_REG; + + if ((err = ioctl(nexus->fd, cmd, &cfg_prg)) != 0) { return (err); + } + *bytes_written = size; + + return (err); } /** * Map a memory region for a device using /dev/xsvc. - * + * * \param dev Device whose memory region is to be mapped. * \param map Parameters of the mapping that is to be created. - * + * * \return * Zero on success or an \c errno value on failure. */ @@ -844,26 +947,29 @@ static int pci_device_solx_devfs_map_range(struct pci_device *dev, struct pci_device_mapping *map) { - const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) - ? (PROT_READ | PROT_WRITE) : PROT_READ; - int err = 0; - - - if (xsvc_fd < 0) { - if ((xsvc_fd = open("/dev/xsvc", O_RDWR)) < 0) { - (void) fprintf(stderr, "can not open xsvc driver\n"); - return errno; - } + const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) + ? (PROT_READ | PROT_WRITE) : PROT_READ; + int err = 0; + + /* + * Still used xsvc to do the user space mapping + */ + if (xsvc_fd < 0) { + if ((xsvc_fd = open("/dev/xsvc", O_RDWR)) < 0) { + err = errno; + (void) fprintf(stderr, "can not open /dev/xsvc: %s\n", + strerror(errno)); + return err; } + } - map->memory = mmap(NULL, map->size, prot, MAP_SHARED, xsvc_fd, - map->base); - if (map->memory == MAP_FAILED) { - err = errno; + map->memory = mmap(NULL, map->size, prot, MAP_SHARED, xsvc_fd, map->base); + if (map->memory == MAP_FAILED) { + err = errno; - (void) fprintf(stderr, "map rom region =%llx failed", - map->base); - } + (void) fprintf(stderr, "map rom region =%llx failed: %s\n", + map->base, strerror(errno)); + } - return err; + return err; } |