1 diff -urN pciutils-3.1.2.orig/lib/configure pciutils-3.1.2.new/lib/configure
2 --- pciutils-3.1.2.orig/lib/configure 2009-01-30 14:06:25.000000000 +0100
3 +++ pciutils-3.1.2.new/lib/configure 2009-02-04 18:45:31.000000000 +0100
8 -if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
9 - echo >&2 "Please run the configure script from the top-level Makefile"
13 echo_n "Configuring libpci for your system..."
14 if [ -z "$HOST" ] ; then
17 [ -n "$RELEASE" ] && rel="${RELEASE}"
18 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
19 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
20 -cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
21 -sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
22 +sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
23 +cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
24 echo " $host $rel $cpu $sys"
27 diff -urN pciutils-3.1.2.orig/Makefile pciutils-3.1.2.new/Makefile
28 --- pciutils-3.1.2.orig/Makefile 2009-02-01 17:49:22.000000000 +0100
29 +++ pciutils-3.1.2.new/Makefile 2009-02-04 13:32:50.000000000 +0100
34 -all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
35 +all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) \
36 + pcimodules pcimodules.8
38 lib/$(PCILIB): $(PCIINC) force
41 lib/config.h lib/config.mk:
44 +pcimodules: pcimodules.o common.o lib/$(PCILIB)
45 lspci: lspci.o ls-vpd.o ls-caps.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
46 setpci: setpci.o common.o lib/$(PCILIB)
48 +pcimodules.o: pcimodules.c pciutils.h
49 LSPCIINC=lspci.h pciutils.h $(PCIINC)
50 lspci.o: lspci.c $(LSPCIINC)
51 ls-vpd.o: ls-vpd.c $(LSPCIINC)
54 # -c is ignored on Linux, but required on FreeBSD
55 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
56 - $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
57 + $(INSTALL) -c -m 755 $(STRIP) lspci setpci pcimodules $(DESTDIR)$(SBINDIR)
58 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
59 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
60 - $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
61 + $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 pcimodules.8 $(DESTDIR)$(MANDIR)/man8
62 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
64 $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
69 - rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
70 + rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids $(DESTDIR)$(SBINDIR)/pcimodules
72 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
73 - rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
74 + rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8 $(DESTDIR)$(MANDIR)/man8/pcimodules.8
75 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
77 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
78 diff -urN pciutils-3.1.2.orig/pcimodules.c pciutils-3.1.2.new/pcimodules.c
79 --- pciutils-3.1.2.orig/pcimodules.c 1970-01-01 01:00:00.000000000 +0100
80 +++ pciutils-3.1.2.new/pcimodules.c 2009-02-04 12:19:47.000000000 +0100
83 + * pcimodules: Load all kernel modules for PCI device currently
84 + * plugged into any PCI slot.
86 + * Copyright 2000 Yggdrasil Computing, Incorporated
87 + * This file may be copied under the terms and conditions of version
88 + * two of the GNU General Public License, as published by the Free
89 + * Software Foundation (Cambridge, Massachusetts, USA).
91 + * This file is based on pciutils/lib/example.c, which has the following
92 + * authorship and copyright statement:
94 + * Written by Martin Mares and put to public domain. You can do
95 + * with it anything you want, but I don't give you any warranty.
103 +#include <sys/utsname.h>
104 +#include <sys/param.h>
105 +#include <sys/types.h>
110 +#include "pciutils.h"
112 +#define MODDIR "/lib/modules"
113 +#define PCIMAP "modules.pcimap"
115 +#define LINELENGTH 8000
117 +#define DEVICE_ANY 0xffffffff
118 +#define VENDOR_ANY 0xffffffff
120 +#include "lib/pci.h"
122 + const char program_name[] = "lspci";
124 +struct pcimap_entry {
125 + unsigned int vendor, subsys_vendor, dev, subsys_dev, class, class_mask;
127 + struct pcimap_entry *next;
130 +static struct pcimap_entry *pcimap_list = NULL;
132 +#define OPT_STRING "h"
133 +static struct option long_options[] = {
134 + {"class", required_argument, NULL, 'c'},
135 + {"classmask", required_argument, NULL, 'm'},
136 + {"help", no_argument, NULL, 'h'},
140 +static unsigned long desired_class;
141 +static unsigned long desired_classmask; /* Default is 0: accept all classes.*/
146 + struct utsname utsname;
147 + char filename[MAXPATHLEN];
149 + char line[LINELENGTH];
150 + struct pcimap_entry *entry;
151 + unsigned int driver_data;
152 + char *prevmodule = "";
153 + char module[LINELENGTH];
155 + if (uname(&utsname) < 0) {
159 + sprintf(filename, "%s/%s/%s", MODDIR, utsname.release, PCIMAP);
160 + if ((pcimap_file = fopen(filename, "r")) == NULL) {
165 + while(fgets(line, LINELENGTH, pcimap_file) != NULL) {
166 + if (line[0] == '#')
169 + entry = xmalloc(sizeof(struct pcimap_entry));
171 + if (sscanf(line, "%s 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
173 + &entry->vendor, &entry->dev,
174 + &entry->subsys_vendor, &entry->subsys_dev,
175 + &entry->class, &entry->class_mask,
176 + &driver_data) != 8) {
178 + "modules.pcimap unparsable line: %s.\n", line);
183 + /* Optimize memory allocation a bit, in case someday we
184 + have Linux systems with ~100,000 modules. It also
185 + allows us to just compare pointers to avoid trying
186 + to load a module twice. */
187 + if (strcmp(module, prevmodule) != 0) {
188 + prevmodule = xmalloc(strlen(module)+1);
189 + strcpy(prevmodule, module);
191 + entry->module = prevmodule;
192 + entry->next = pcimap_list;
193 + pcimap_list = entry;
195 + fclose(pcimap_file);
198 +/* Return a filled in pci_access->dev tree, with the device classes
199 + stored in dev->aux.
202 +match_pci_modules(void)
204 + struct pci_access *pacc;
205 + struct pci_dev *dev;
206 + unsigned int class, subsys_dev, subsys_vendor;
207 + struct pcimap_entry *map;
208 + const char *prevmodule = "";
210 + pacc = pci_alloc(); /* Get the pci_access structure */
211 + /* Set all options you want -- here we stick with the defaults */
212 + pci_init(pacc); /* Initialize the PCI library */
213 + pci_scan_bus(pacc); /* We want to get the list of devices */
214 + for(dev=pacc->devices; dev; dev=dev->next) {
215 + pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES);
216 + class = (pci_read_word(dev, PCI_CLASS_DEVICE) << 8)
217 + | pci_read_byte(dev, PCI_CLASS_PROG);
218 + subsys_dev = pci_read_word(dev, PCI_SUBSYSTEM_ID);
219 + subsys_vendor = pci_read_word(dev,PCI_SUBSYSTEM_VENDOR_ID);
220 + for(map = pcimap_list; map != NULL; map = map->next) {
221 + if (((map->class ^ class) & map->class_mask) == 0 &&
222 + ((desired_class ^ class) & desired_classmask)==0 &&
223 + (map->dev == DEVICE_ANY ||
224 + map->dev == dev->device_id) &&
225 + (map->vendor == VENDOR_ANY ||
226 + map->vendor == dev->vendor_id) &&
227 + (map->subsys_dev == DEVICE_ANY ||
228 + map->subsys_dev == subsys_dev) &&
229 + (map->subsys_vendor == VENDOR_ANY ||
230 + map->subsys_vendor == subsys_vendor) &&
231 + prevmodule != map->module) {
232 + printf("%s\n", map->module);
233 + prevmodule = map->module;
242 +main (int argc, char **argv)
247 + while ((opt = getopt_long(argc, argv, OPT_STRING, long_options,
248 + &opt_index)) != -1) {
251 + desired_class = strtol(optarg, NULL, 0);
254 + desired_classmask = strtol(optarg, NULL, 0);
257 + printf ("Usage: pcimodules [--help]\n"
258 + " Lists kernel modules corresponding to PCI devices currently plugged"
259 + " into the computer.\n");
264 + match_pci_modules();
267 diff -urN pciutils-3.1.2.orig/pcimodules.man pciutils-3.1.2.new/pcimodules.man
268 --- pciutils-3.1.2.orig/pcimodules.man 1970-01-01 01:00:00.000000000 +0100
269 +++ pciutils-3.1.2.new/pcimodules.man 2009-02-04 12:19:53.000000000 +0100
271 +.TH pcimodules 8 "@TODAY@" "@VERSION@" "Linux PCI Utilities"
274 +pcimodules \- List kernel driver modules available for all currently plugged
278 +.RB [ --class class_id ]
279 +.RB [ --classmask mask ]
283 +lists all driver modules for all currently plugged in PCI devices.
285 +should be run at boot time, and whenever a PCI device is "hot plugged"
286 +into the system. This can be done by the following Bourne shell syntax:
288 + for module in $(pcimodules) ; do
290 + modprobe -s -k "$module"
294 +When a PCI device is removed from the system, the Linux kernel will
295 +decrement a usage count on PCI driver module. If this count drops
296 +to zero (i.e., there are no PCI drivers), then the
298 +process that is normally configured to run from cron every few minutes
299 +will eventually remove the unneeded module.
301 +The --class and --classmask arguments can be used to limit the search
302 +to certain classes of PCI devices. This is useful, for example, to
303 +generate a list of ethernet card drivers to be loaded when the kernel
304 +has indicated that it is trying to resolve an unknown network interface.
306 +Modules are listed in the order in which the PCI devices are physically
307 +arranged so that the computer owner can arrange things like having scsi
308 +device 0 be on a controller that is not alphabetically the first scsi
312 +.B --class class --classmask mask
314 +--class and --classmask limit the search to PCI
315 +cards in particular classes. These arguments are always used together.
316 +The arguments to --class and --classmask
317 +can be given as hexadecimal numbers by prefixing a leading "0x".
318 +Note that the classes used by pcimodules are in "Linux" format,
319 +meaning the class value that you see with lspci would be shifted
320 +left eight bits, with the new low eight bits programming interface ID.
321 +An examples of how to use class and classmask is provided below.
323 +Print a help message and exit.
327 +lists all modules corresponding to currently plugged in PCI devices.
329 +pcimodules --class 0x200000 --classmask 0xffff00
330 +lists all modules corresponding to currently plugged in ethernet PCI devices.
333 +.B /lib/modules/<kernel-version>/modules.pcimap
334 +This file is automatically generated by
338 +to determine which modules correspond to which PCI ID's.
341 +An interface to PCI bus configuration space provided by the post-2.1.82 Linux
342 +kernels. Contains per-bus subdirectories with per-card config space files and a
344 +file containing a list of all PCI devices.
350 +The Linux PCI Utilities are maintained by Martin Mares <mj@suse.cz>.
354 +was written by Adam J. Richter <adam@yggdrasil.com>, based on public
355 +domain example code by Martin Mares <mj@suse.cz>.
359 +is copyright 2000, Yggdrasil Computing, Incorporated, and may
360 +be copied under the terms and conditions of version 2 of the GNU
361 +General Public License as published by the Free Software Foundation
362 +(Cambrige, Massachusetts, United States of America).