COPYING | 2 Makefile.am | 4 configure.ac | 21 +++-- include/Makefile.am | 1 m4/ac_define_dir.m4 | 49 ----------- m4/ax_define_dir.m4 | 49 +++++++++++ man/Makefile.am | 34 ++++++++ man/scanpci.man | 44 ++++++++++ scanpci/.gitignore | 1 scanpci/Makefile.am | 29 +++++++ scanpci/scanpci.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/.gitignore | 2 src/Makefile.am | 12 -- src/common_bridge.c | 8 - src/pci_tools.h | 2 src/scanpci.c | 215 ---------------------------------------------------- src/scanpci.man | 44 ---------- src/solx_devfs.c | 2 18 files changed, 395 insertions(+), 339 deletions(-)
New commits: commit d05ed57216726811388f17d7e87d7b6c7b8580ee Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Feb 2 20:50:17 2011 -0800 libpciaccess 0.12.1 Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 75d5b0a..c3203d8 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ dnl Process this file with autoconf to create configure. # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libpciaccess],[0.12.0], +AC_INIT([libpciaccess],[0.12.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess],[libpciaccess]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) commit 7b4bd8222579b60bec6ab9dbf834d61b1fc7cc74 Author: Gaetan Nadon <mems...@videotron.ca> Date: Fri Jan 28 16:07:07 2011 -0500 config: replace deprecated AC_HELP_STRING with AS_HELP_STRING This silences an Automake warning. Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/configure.ac b/configure.ac index 4966dae..75d5b0a 100644 --- a/configure.ac +++ b/configure.ac @@ -43,7 +43,7 @@ XORG_DEFAULT_OPTIONS AC_PROG_LIBTOOL pciids_path=/usr/share/hwdata -AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH], +AC_ARG_WITH(pciids-path, AS_HELP_STRING([--with-pciids-path=PCIIDS_PATH], [Path to pci.ids file]), [pciids_path="$withval"]) AX_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids]) @@ -56,7 +56,7 @@ if test "x$LINUX_ROM" = xyes; then fi use_zlib=no -AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib], +AC_ARG_WITH(zlib, AS_HELP_STRING([--with-zlib], [Enable zlib support to read gzip compressed pci.ids]), [use_zlib="$withval"]) if test "x$use_zlib" = xyes; then commit 5fdae72cc62f4341ae5fa0b7696809d4ccd1bd32 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Thu Jan 13 22:05:02 2011 -0800 config: remove AC_PROG_CC as it overrides AC_PROG_C_C99 XORG_STRICT_OPTION from XORG_DEFAULT_OPTIONS calls AC_PROG_C_C99. This sets gcc with -std=gnu99. If AC_PROG_CC macro is called afterwards, it resets CC to gcc. Signed-off-by: Gaetan Nadon <mems...@videotron.ca> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 873a514..4966dae 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,6 @@ XORG_MACROS_VERSION(1.3) XORG_DEFAULT_OPTIONS # Check for progs -AC_PROG_CC AC_PROG_LIBTOOL pciids_path=/usr/share/hwdata commit 48d08f09e36d4aa8e02812874794937d7c778b43 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Thu Jan 13 21:58:02 2011 -0800 config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS Regroup AC statements under the Autoconf initialization section. Regroup AM statements under the Automake initialization section. Add missing AC_CONFIG_SRCDIR Replace obsolete argument to AC_OUTPUT with AC_CONFIG_FILES Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 47cd733..873a514 100644 --- a/configure.ac +++ b/configure.ac @@ -22,9 +22,14 @@ dnl DEALINGS IN THE SOFTWARE. dnl dnl Process this file with autoconf to create configure. +# Initialize Autoconf AC_PREREQ([2.60]) +AC_INIT([libpciaccess],[0.12.0], + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess],[libpciaccess]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) -AC_INIT(libpciaccess, 0.12.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess) +# Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE @@ -33,7 +38,6 @@ m4_ifndef([XORG_MACROS_VERSION], [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])]) XORG_MACROS_VERSION(1.3) XORG_DEFAULT_OPTIONS -AM_CONFIG_HEADER(config.h) # Check for progs AC_PROG_CC @@ -122,9 +126,10 @@ AC_SUBST(PCIACCESS_CFLAGS) AC_SUBST(PCIACCESS_LIBS) -AC_OUTPUT([Makefile +AC_CONFIG_FILES([Makefile include/Makefile man/Makefile src/Makefile scanpci/Makefile pciaccess.pc]) +AC_OUTPUT commit 066032e08407311cfc24dbc1db3245cf8133ad94 Author: Bryce Harrington <br...@canonical.com> Date: Tue Dec 14 12:03:48 2010 -0500 Fix detection of multi-function cards Bit 7 of the pci device header type is an indicator of multi-function devices, so needs to be masked when examining the bridge type. Thanks go to Chih-Pin Wu for finding the bug and its fix. https://bugs.launchpad.net/ubuntu/+source/libpciaccess/+bug/681207 Reviewed-by: Adam Jackson <a...@redhat.com> Signed-off-by: Bryce Harrington <br...@canonical.com> diff --git a/src/common_bridge.c b/src/common_bridge.c index 2609d7c..871c1f6 100644 --- a/src/common_bridge.c +++ b/src/common_bridge.c @@ -290,7 +290,7 @@ pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus, case 0x04: if (priv->bridge.pci == NULL) read_bridge_info(priv); - if (priv->header_type == 0x01) { + if ((priv->header_type & 0x7f) == 0x01) { *primary_bus = priv->bridge.pci->primary_bus; *secondary_bus = priv->bridge.pci->secondary_bus; *subordinate_bus = priv->bridge.pci->subordinate_bus; @@ -304,7 +304,7 @@ pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus, case 0x07: if (priv->bridge.pcmcia == NULL) read_bridge_info(priv); - if (priv->header_type == 0x02) { + if ((priv->header_type & 0x7f) == 0x02) { *primary_bus = priv->bridge.pcmcia->primary_bus; *secondary_bus = priv->bridge.pcmcia->card_bus; *subordinate_bus = priv->bridge.pcmcia->subordinate_bus; commit 6220537628fb5e55c94d7dbe1ec190bf38d3b01b Author: Jesse Barnes <jbar...@virtuousgeek.org> Date: Mon Dec 6 12:18:19 2010 -0800 Revert "Don't try to use bogus bridge data" This reverts commit 2bda5b733bb12854760750c08138db95e77aea0c. It actually conflicts with 9ba94caf57e3a8c3e9c6f3f5f068f4a7a7b3ff9d which came earlier, but I didn't catch it probably because I did a blind rebase before pushing. When reading bridge bus info, we may need to read out the current bridge info if the PCI bridge private is uninitialized, so remove the check at the top that would always short circuit the case where the priv was still 0. References: https://bugs.launchpad.net/ubuntu/+source/libpciaccess/+bug/681207. Reported-by: Bryce Harrington <br...@canonical.com> Signed-off-by: Jesse Barnes <jbar...@virtuousgeek.org> diff --git a/src/common_bridge.c b/src/common_bridge.c index f37420f..2609d7c 100644 --- a/src/common_bridge.c +++ b/src/common_bridge.c @@ -270,10 +270,6 @@ pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus, return ENODEV; } - if (!priv->bridge.pci) { - return ENODEV; - } - switch ((dev->device_class >> 8) & 0x0ff) { case 0x00: /* What to do for host bridges? I'm pretty sure this isn't right. commit 30bfd795557cada4a3c2ce36329ceb22160acff8 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Nov 21 11:14:05 2010 -0800 Sun's copyrights belong to Oracle now Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/COPYING b/COPYING index 05c5941..2f9f9c3 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ (C) Copyright IBM Corporation 2006, 2007 (C) Copyright Eric Anholt 2006 -Copyright 2007, 2008, 2009 Sun Microsystems, Inc. +Copyright (c) 2007, 2008, 2009, Oracle and/or its affiliates. Copyright 2009 Red Hat, Inc. All Rights Reserved. diff --git a/src/pci_tools.h b/src/pci_tools.h index b353b31..3766890 100644 --- a/src/pci_tools.h +++ b/src/pci_tools.h @@ -1,5 +1,5 @@ /* - * Copyright © 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2007, Oracle and/or its affiliates. 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"), diff --git a/src/solx_devfs.c b/src/solx_devfs.c index 73538b2..24bb1b9 100644 --- a/src/solx_devfs.c +++ b/src/solx_devfs.c @@ -1,6 +1,6 @@ /* * (C) Copyright IBM Corporation 2006 - * Copyright 2007, 2009 Sun Microsystems, Inc. + * Copyright (c) 2007, 2009, Oracle and/or its affiliates. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a commit e29e477ff84ab16938e58ae2719358c14c86a500 Author: Gaetan Nadon <mems...@videotron.ca> Date: Fri Oct 15 17:34:16 2010 -0400 config: use LDADD to obtain appropriate dependencies In generated scanpci/Makefile, this line is added: scanpci_DEPENDENCIES = $(top_builddir)/src/libpciaccess.la If the content of the library changes, the tool will rebuild. When scanpci was in the same directory as the library, the .la file was used. This will also ensure the "installed" pciaccess library is not used. Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/scanpci/Makefile.am b/scanpci/Makefile.am index 6fdf86e..68d54f4 100644 --- a/scanpci/Makefile.am +++ b/scanpci/Makefile.am @@ -24,6 +24,6 @@ noinst_PROGRAMS = scanpci AM_CPPFLAGS = -I$(top_srcdir)/include -AM_LDFLAGS = -L$(top_builddir)/src -lpciaccess +LDADD = $(top_builddir)/src/libpciaccess.la scanpci_SOURCES = scanpci.c commit fd476deabb97d08086ad465c4d0e913c9437a6bb Author: Gaetan Nadon <mems...@videotron.ca> Date: Sun Sep 26 14:57:19 2010 -0400 include: add a Makefile to install and distribute header file Makefiles are simpler when they only handle what is in their directory. Reviewed-by: Rémi Cardona <r...@gentoo.org> Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/Makefile.am b/Makefile.am index ea30cd2..a285275 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ ACLOCAL_AMFLAGS = -I m4 # Order: scanpci depends on libpciaccess built in src -SUBDIRS = man src scanpci +SUBDIRS = include man src scanpci pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pciaccess.pc diff --git a/configure.ac b/configure.ac index 1c2a3ca..47cd733 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,7 @@ AC_SUBST(PCIACCESS_LIBS) AC_OUTPUT([Makefile + include/Makefile man/Makefile src/Makefile scanpci/Makefile diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..b668192 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +include_HEADERS = pciaccess.h diff --git a/src/Makefile.am b/src/Makefile.am index 523e4b1..7842118 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,8 +71,3 @@ libpciaccess_la_SOURCES = common_bridge.c \ libpciaccess_la_LIBADD = $(PCIACCESS_LIBS) libpciaccess_la_LDFLAGS = -version-number 0:10:8 -no-undefined - -libpciaccessincludedir = $(includedir) -libpciaccessinclude_HEADERS = \ - $(top_srcdir)/include/pciaccess.h - commit 2b5c81c2d8c643e58ac69d1d7f7a626fc392b1ea Author: Gaetan Nadon <mems...@videotron.ca> Date: Sun Sep 26 14:42:50 2010 -0400 config: replace INCLUDES, which is deprecated, with AM_CPPFLAGS Fixes an Automake warning. Reviewed-by: Rémi Cardona <r...@gentoo.org> Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/src/Makefile.am b/src/Makefile.am index 0d774e0..523e4b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS = $(CWARNFLAGS) @PCIACCESS_CFLAGS@ lib_LTLIBRARIES = libpciaccess.la @@ -67,8 +68,6 @@ libpciaccess_la_SOURCES = common_bridge.c \ $(VGA_ARBITER) \ $(OS_SUPPORT) -INCLUDES = -I$(top_srcdir)/include - libpciaccess_la_LIBADD = $(PCIACCESS_LIBS) libpciaccess_la_LDFLAGS = -version-number 0:10:8 -no-undefined commit b4ee1ccfcd9e9d41033db7b6b5e0a771ae5939d2 Author: Gaetan Nadon <mems...@videotron.ca> Date: Sun Aug 22 08:10:23 2010 -0400 config: provide a makefile for scanpci man pages Reviewed-by: Rémi Cardona <r...@gentoo.org> Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/Makefile.am b/Makefile.am index 31d20a0..ea30cd2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,13 +25,12 @@ ACLOCAL_AMFLAGS = -I m4 # Order: scanpci depends on libpciaccess built in src -SUBDIRS = src scanpci +SUBDIRS = man src scanpci pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pciaccess.pc MAINTAINERCLEANFILES = ChangeLog INSTALL -EXTRA_DIST = src/scanpci.man .PHONY: ChangeLog INSTALL diff --git a/configure.ac b/configure.ac index 6980675..1c2a3ca 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,7 @@ AC_SUBST(PCIACCESS_LIBS) AC_OUTPUT([Makefile + man/Makefile src/Makefile scanpci/Makefile pciaccess.pc]) diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000..45edd45 --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +appman_PRE = scanpci.man +noinst_DATA = $(appman_PRE:man=$(APP_MAN_SUFFIX)) + +EXTRA_DIST = $(appman_PRE) +CLEANFILES = $(noinst_DATA) + +# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure +SUFFIXES = .$(APP_MAN_SUFFIX) .man + +.man.$(APP_MAN_SUFFIX): + $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@ diff --git a/man/scanpci.man b/man/scanpci.man new file mode 100644 index 0000000..a748edf --- /dev/null +++ b/man/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/src/scanpci.man b/src/scanpci.man deleted file mode 100644 index aec7b2e..0000000 --- a/src/scanpci.man +++ /dev/null @@ -1,44 +0,0 @@ -.\" 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. - commit 8daa135ae9eae0a0ed48cc68d6abce16141cd426 Author: Gaetan Nadon <mems...@videotron.ca> Date: Sun Sep 26 08:39:57 2010 -0400 scanpci.c: remove offending whitespace as reported by git diff Reviewed-by: Rémi Cardona <r...@gentoo.org> Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/scanpci/scanpci.c b/scanpci/scanpci.c index 34ec664..36ecf04 100644 --- a/scanpci/scanpci.c +++ b/scanpci/scanpci.c @@ -67,7 +67,7 @@ print_pci_device( struct pci_device * dev, int verbose ) printf("domain 0x%04x ", dev->domain); printf("bus 0x%04x cardnum 0x%02x function 0x%02x:" " vendor 0x%04x device 0x%04x\n", - dev->bus, + dev->bus, dev->dev, dev->func, dev->vendor_id, @@ -78,7 +78,7 @@ print_pci_device( struct pci_device * dev, int verbose ) else { printf( " %s\n", dev_name ); } - + if ( verbose ) { unsigned i; uint16_t command, status; @@ -109,7 +109,7 @@ print_pci_device( struct pci_device * dev, int verbose ) pci_device_cfg_read_u16( dev, & command, 4 ); pci_device_cfg_read_u16( dev, & status, 6 ); - printf( " STATUS 0x%04x COMMAND 0x%04x\n", + printf( " STATUS 0x%04x COMMAND 0x%04x\n", status, command ); printf( " CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", @@ -128,7 +128,7 @@ print_pci_device( struct pci_device * dev, int verbose ) header_type, latency_timer, cache_line_size ); - + pci_device_probe( dev ); for ( i = 0 ; i < 6 ; i++ ) { if ( dev->regions[i].base_addr != 0 ) { @@ -143,7 +143,7 @@ print_pci_device( struct pci_device * dev, int verbose ) printf( " PREFETCHABLE" ); } } - + printf( "\n" ); } } commit dcb79a20cba1eaaa83158b80bb538d50b003bd79 Author: Gaetan Nadon <mems...@videotron.ca> Date: Sun Aug 22 08:10:23 2010 -0400 config: provide a makefile for scanpci dev tool No function changes. Note that automake generates a wrapper script if libpciaccess is not installed at configuration time, which is the most common case. If it is installed at configuration time, you get an executable. The makefile build order ensures the lib is build before scanpci. Reviewed-by: Rémi Cardona <r...@gentoo.org> Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/Makefile.am b/Makefile.am index ff8db2f..31d20a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,13 +24,14 @@ # Include autoconf macros from m4 subdir ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src +# Order: scanpci depends on libpciaccess built in src +SUBDIRS = src scanpci pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pciaccess.pc MAINTAINERCLEANFILES = ChangeLog INSTALL -EXTRA_DIST = src/scanpci.c src/scanpci.man +EXTRA_DIST = src/scanpci.man .PHONY: ChangeLog INSTALL diff --git a/configure.ac b/configure.ac index c0e1e9b..6980675 100644 --- a/configure.ac +++ b/configure.ac @@ -124,4 +124,5 @@ AC_SUBST(PCIACCESS_LIBS) AC_OUTPUT([Makefile src/Makefile + scanpci/Makefile pciaccess.pc]) diff --git a/scanpci/.gitignore b/scanpci/.gitignore new file mode 100644 index 0000000..485d4b9 --- /dev/null +++ b/scanpci/.gitignore @@ -0,0 +1 @@ +scanpci diff --git a/scanpci/Makefile.am b/scanpci/Makefile.am new file mode 100644 index 0000000..6fdf86e --- /dev/null +++ b/scanpci/Makefile.am @@ -0,0 +1,29 @@ +# +# (C) Copyright IBM Corporation 2006 +# 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. + +noinst_PROGRAMS = scanpci + +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_LDFLAGS = -L$(top_builddir)/src -lpciaccess + +scanpci_SOURCES = scanpci.c diff --git a/scanpci/scanpci.c b/scanpci/scanpci.c new file mode 100644 index 0000000..34ec664 --- /dev/null +++ b/scanpci/scanpci.c @@ -0,0 +1,215 @@ +/* + * (C) Copyright IBM Corporation 2006 + * 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. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <err.h> +#include <unistd.h> + +#include "pciaccess.h" + + +static void +print_pci_bridge( const struct pci_bridge_info * info ) +{ + printf( " Bus: primary=%02x, secondary=%02x, subordinate=%02x, " + "sec-latency=%u\n", + info->primary_bus, + info->secondary_bus, + info->subordinate_bus, + info->secondary_latency_timer ); + printf( " I/O behind bridge: %08x-%08x\n", + info->io_base, + info->io_limit ); + printf( " Memory behind bridge: %08x-%08x\n", + info->mem_base, + info->mem_limit ); + printf( " Prefetchable memory behind bridge: %08llx-%08llx\n", + info->prefetch_mem_base, + info->prefetch_mem_limit ); +} + +static void +print_pci_device( struct pci_device * dev, int verbose ) +{ + const char * dev_name; + const char * vend_name; + + vend_name = pci_device_get_vendor_name( dev ); + dev_name = pci_device_get_device_name( dev ); + if ( dev_name == NULL ) { + dev_name = "Device unknown"; + } + + printf("\npci "); + if (dev->domain != 0) + printf("domain 0x%04x ", dev->domain); + printf("bus 0x%04x cardnum 0x%02x function 0x%02x:" + " vendor 0x%04x device 0x%04x\n", + dev->bus, + dev->dev, + dev->func, + dev->vendor_id, + dev->device_id ); + if ( vend_name != NULL ) { + printf( " %s %s\n", vend_name, dev_name ); + } + else { + printf( " %s\n", dev_name ); + } + + if ( verbose ) { + unsigned i; + uint16_t command, status; + uint8_t bist; + uint8_t header_type; + uint8_t latency_timer; + uint8_t cache_line_size; + uint8_t max_latency; + uint8_t min_grant; + uint8_t int_pin; + + + vend_name = pci_device_get_subvendor_name( dev ); + dev_name = pci_device_get_subdevice_name( dev ); + if ( dev_name == NULL ) { + dev_name = "Card unknown"; + } + + printf( " CardVendor 0x%04x card 0x%04x (", + dev->subvendor_id, + dev->subdevice_id ); + if ( vend_name != NULL ) { + printf( "%s, %s)\n", vend_name, dev_name ); + } + else { + printf( "%s)\n", dev_name ); + } + + pci_device_cfg_read_u16( dev, & command, 4 ); + pci_device_cfg_read_u16( dev, & status, 6 ); + printf( " STATUS 0x%04x COMMAND 0x%04x\n", + status, + command ); + printf( " CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", + (dev->device_class >> 16) & 0x0ff, + (dev->device_class >> 8) & 0x0ff, + (dev->device_class >> 0) & 0x0ff, + dev->revision ); + + pci_device_cfg_read_u8( dev, & cache_line_size, 12 ); + pci_device_cfg_read_u8( dev, & latency_timer, 13 ); + pci_device_cfg_read_u8( dev, & header_type, 14 ); + pci_device_cfg_read_u8( dev, & bist, 15 ); + + printf( " BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n", + bist, + header_type, + latency_timer, + cache_line_size ); + + pci_device_probe( dev ); + for ( i = 0 ; i < 6 ; i++ ) { + if ( dev->regions[i].base_addr != 0 ) { + printf( " BASE%u 0x%08x SIZE %d %s", + i, + (intptr_t) dev->regions[i].base_addr, + (size_t) dev->regions[i].size, + (dev->regions[i].is_IO) ? "I/O" : "MEM" ); + + if ( ! dev->regions[i].is_IO ) { + if ( dev->regions[i].is_prefetchable ) { + printf( " PREFETCHABLE" ); + } + } + + printf( "\n" ); + } + } + + if ( dev->rom_size ) { + printf( " BASEROM 0x%08x addr 0x%08x\n", + 0, 0 ); + } + + pci_device_cfg_read_u8( dev, & int_pin, 61 ); + pci_device_cfg_read_u8( dev, & min_grant, 62 ); + pci_device_cfg_read_u8( dev, & max_latency, 63 ); + + printf( " MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n", + max_latency, + min_grant, + int_pin, + dev->irq ); + + if ( (dev->device_class >> 16) == 0x06 ) { + const void * info; + + if ( (info = pci_device_get_bridge_info(dev)) != NULL ) { + print_pci_bridge( (const struct pci_bridge_info *) info ); + } + else if ( (info = pci_device_get_pcmcia_bridge_info(dev)) != NULL ) { + /* Nothing yet. */ + } + } + } +} + + +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) + err(1, "Couldn't initialize PCI system"); + + iter = pci_slot_match_iterator_create( NULL ); + + while ( (dev = pci_device_next( iter )) != NULL ) { + print_pci_device( dev, verbose ); + } + + pci_system_cleanup(); + return 0; +} diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 5c8b286..0000000 --- a/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Add & Override for this directory and it's subdirectories -scanpci diff --git a/src/Makefile.am b/src/Makefile.am index 0ee8449..0d774e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -77,7 +77,3 @@ libpciaccessincludedir = $(includedir) libpciaccessinclude_HEADERS = \ $(top_srcdir)/include/pciaccess.h -noinst_PROGRAMS = scanpci - -scanpci_SOURCES = scanpci.c -scanpci_LDADD = libpciaccess.la diff --git a/src/scanpci.c b/src/scanpci.c deleted file mode 100644 index 34ec664..0000000 --- a/src/scanpci.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2006 - * 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. - */ - -#include <stdlib.h> -#include <stdio.h> -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1pm6js-0001hz...@alioth.debian.org