summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp/pciutils/pciutils-3.1.9
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-bsp/pciutils/pciutils-3.1.9')
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.1.9/configure.patch104
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.1.9/guess-fix.patch37
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.1.9/lib-build-fix.patch94
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.1.9/makefile.patch14
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.1.9/pcimodules-pciutils.diff340
5 files changed, 589 insertions, 0 deletions
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.1.9/configure.patch b/meta/recipes-bsp/pciutils/pciutils-3.1.9/configure.patch
new file mode 100644
index 0000000000..658e59772c
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.1.9/configure.patch
@@ -0,0 +1,104 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3#
4# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
5#
6---
7
87/30/2010 - rebased to 3.1.5 by Qing He <qing.he@intel.com>
91/22/2012 - rebased to 3.1.9 by Shane Wang <shane.wang@intel.com>
10
11diff -r af2b10cc3c14 Makefile
12--- a/Makefile Sun Jan 22 18:36:34 2012 +0800
13+++ b/Makefile Sun Jan 22 18:38:54 2012 +0800
14@@ -37,7 +37,6 @@
15 # Commands
16 INSTALL=install
17 DIRINSTALL=install -d
18-STRIP=-s
19 CC=$(CROSS_COMPILE)gcc
20 AR=$(CROSS_COMPILE)ar
21 RANLIB=$(CROSS_COMPILE)ranlib
22@@ -86,7 +85,7 @@
23 example.o: example.c $(PCIINC)
24
25 %: %.o
26- $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
27+ $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LIB_LDLIBS) -o $@
28
29 %.8 %.7: %.man
30 M=`echo $(DATE) | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <$< >$@ "s/@TODAY@/$$M/;s/@VERSION@/pciutils-$(VERSION)/;s#@IDSDIR@#$(IDSDIR)#"
31@@ -101,7 +100,7 @@
32 install: all
33 # -c is ignored on Linux, but required on FreeBSD
34 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
35- $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
36+ $(INSTALL) -c -m 755 lspci setpci $(DESTDIR)$(SBINDIR)
37 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
38 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
39 $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
40diff -r af2b10cc3c14 lib/configure
41--- a/lib/configure Sun Jan 22 18:36:34 2012 +0800
42+++ b/lib/configure Sun Jan 22 18:38:54 2012 +0800
43@@ -14,6 +14,10 @@
44 fi
45 }
46
47+VERSION=$1
48+IDSDIR=$2
49+DNS=yes
50+
51 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
52 echo >&2 "Please run the configure script from the top-level Makefile"
53 exit 1
54@@ -21,8 +25,8 @@
55
56 echo_n "Configuring libpci for your system..."
57 if [ -z "$HOST" ] ; then
58- sys=`uname -s`
59- rel=`uname -r`
60+ sys=${3:-`uname -s`}
61+ rel=
62 realsys="$sys"
63 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
64 then
65@@ -30,7 +34,7 @@
66 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
67 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
68 else
69- cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
70+ cpu=${4:-`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/`}
71 fi
72 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
73 then
74@@ -40,7 +44,7 @@
75 then
76 sys=cygwin
77 fi
78- HOST=${3:-$cpu-$sys}
79+ HOST=$cpu-$sys
80 fi
81 [ -n "$RELEASE" ] && rel="${RELEASE}"
82 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
83@@ -49,6 +53,21 @@
84 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
85 echo " $host $rel $cpu $sys"
86
87+if [ "$host" = "linux--gnueabi" ]
88+then
89+ sys=linux
90+fi
91+
92+if [ "$host" = "linux--uclibc" ]
93+then
94+ sys=linux
95+fi
96+
97+if [ "$host" = "linux--uclibceabi" ]
98+then
99+ sys=linux
100+fi
101+
102 c=config.h
103 m=config.mk
104 echo >$c '#define PCI_CONFIG_H'
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.1.9/guess-fix.patch b/meta/recipes-bsp/pciutils/pciutils-3.1.9/guess-fix.patch
new file mode 100644
index 0000000000..540b4a0d13
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.1.9/guess-fix.patch
@@ -0,0 +1,37 @@
1the original guess algorithm is broken for many archs
2for example, the following two would break:
3 arm-linux-gnueabi --> sys=gnueabi
4 x86_64-unknown-pc-linux-gnu --> sys = pc-linux-gnu
5
6use a simpler scheme here and hope it works for all the cases
7
8Upstream-Status: Pending
9
107/30/2010 - created by Qing He <qing.he@intel.com>
11
12diff --git a/lib/configure b/lib/configure
13index 4318b05..84f6acb 100755
14--- a/lib/configure
15+++ b/lib/configure
16@@ -53,20 +53,7 @@ cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
17 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
18 echo " $host $rel $cpu $sys"
19
20-if [ "$host" = "linux--gnueabi" ]
21-then
22- sys=linux
23-fi
24-
25-if [ "$host" = "linux--uclibc" ]
26-then
27- sys=linux
28-fi
29-
30-if [ "$host" = "linux--uclibceabi" ]
31-then
32- sys=linux
33-fi
34+{ echo "$host" | grep linux; } && sys=linux
35
36 c=config.h
37 m=config.mk
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.1.9/lib-build-fix.patch b/meta/recipes-bsp/pciutils/pciutils-3.1.9/lib-build-fix.patch
new file mode 100644
index 0000000000..7268d531d9
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.1.9/lib-build-fix.patch
@@ -0,0 +1,94 @@
1Link directly to lib/libpci.so.3.1.5 will hard code this versioned
2string into lspci and other utilities, which is not desirable and
3won't work. In the other hand, linking to a symbolic link lib/libpci.so
4doesn't have this issue.
5
6Upstream-Status: Pending
7
87/30/2010 - created by Qing He <qing.he@intel.com>
9
10diff --git a/Makefile b/Makefile
11index 1b48e18..21af4b3 100644
12--- a/Makefile
13+++ b/Makefile
14@@ -51,9 +51,9 @@ PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
15
16 export
17
18-all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) pcimodules pcimodules.8
19+all: lib/$(PCILIB_DEV) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) pcimodules pcimodules.8
20
21-lib/$(PCILIB): $(PCIINC) force
22+lib/$(PCILIB) lib/$(PCILIB_DEV): $(PCIINC) force
23 $(MAKE) -C lib all
24
25 force:
26@@ -61,9 +61,9 @@ force:
27 lib/config.h lib/config.mk:
28 cd lib && ./configure
29
30-pcimodules: pcimodules.o common.o lib/$(PCILIB)
31-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)
32-setpci: setpci.o common.o lib/$(PCILIB)
33+pcimodules: pcimodules.o common.o lib/$(PCILIB_DEV)
34+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_DEV)
35+setpci: setpci.o common.o lib/$(PCILIB_DEV)
36
37 pcimodules.o: pcimodules.c pciutils.h
38 LSPCIINC=lspci.h pciutils.h $(PCIINC)
39@@ -83,7 +83,7 @@ update-pciids: update-pciids.sh
40 chmod +x $@
41
42 # The example of use of libpci
43-example: example.o lib/$(PCILIB)
44+example: example.o lib/$(PCILIB_DEV)
45 example.o: example.c $(PCIINC)
46
47 %: %.o
48diff --git a/lib/Makefile b/lib/Makefile
49index 1eb06a5..a8dab56 100644
50--- a/lib/Makefile
51+++ b/lib/Makefile
52@@ -42,7 +42,7 @@ ifdef PCI_HAVE_PM_NBSD_LIBPCI
53 OBJS += nbsd-libpci
54 endif
55
56-all: $(PCILIB) $(PCILIBPC)
57+all: $(PCILIB_DEV) $(PCILIBPC)
58
59 ifeq ($(SHARED),no)
60 $(PCILIB): $(addsuffix .o,$(OBJS))
61@@ -53,6 +53,9 @@ else
62 CFLAGS += -fPIC -fvisibility=hidden
63 $(PCILIB): $(addsuffix .o,$(OBJS))
64 $(CC) -shared $(LDFLAGS) $(SONAME) -Wl,--version-script=libpci.ver -o $@ $^ $(LIB_LDLIBS)
65+
66+$(PCILIB_DEV): $(PCILIB)
67+ ln -s $< $@
68 endif
69
70 $(PCILIBPC): libpci.pc.in
71diff --git a/lib/configure b/lib/configure
72index eec225a..4318b05 100755
73--- a/lib/configure
74+++ b/lib/configure
75@@ -174,16 +193,18 @@ fi
76 echo "Checking whether to build a shared library... $SHARED (set manually)"
77 if [ "$SHARED" = no ] ; then
78 echo >>$m 'PCILIB=$(LIBNAME).a'
79+ echo >>$m 'PCILIB_DEV=$(LIBNAME).a'
80 echo >>$m 'LDLIBS=$(WITH_LIBS)'
81 echo >>$m 'LIB_LDLIBS='
82 else
83 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
84+ echo >>$m 'PCILIB_DEV=$(LIBNAME).so'
85 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
86 echo >>$m 'LDLIBS='
87 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
88 echo >>$c '#define PCI_SHARED_LIB'
89 if [ "$SHARED" = yes ] ; then
90- echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
91+ echo >>$m 'SONAME=-Wl,-soname -Wl,$(LIBNAME).so$(ABI_VERSION)'
92 fi
93 fi
94 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.1.9/makefile.patch b/meta/recipes-bsp/pciutils/pciutils-3.1.9/makefile.patch
new file mode 100644
index 0000000000..811aac8e13
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.1.9/makefile.patch
@@ -0,0 +1,14 @@
1Upstream-Status: Inappropriate [configuration]
2
3diff -ruN pciutils-3.1.7-orig/Makefile pciutils-3.1.7/Makefile
4--- pciutils-3.1.7-orig/Makefile 2011-07-11 14:41:59.000000000 +0800
5+++ pciutils-3.1.7/Makefile 2011-07-11 14:42:31.000000000 +0800
6@@ -31,7 +31,7 @@
7 IDSDIR=$(SHAREDIR)
8 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
9 INCDIR=$(PREFIX)/include
10-LIBDIR=$(PREFIX)/lib
11+LIBDIR=$(libdir)
12 PKGCFDIR=$(LIBDIR)/pkgconfig
13
14 # Commands
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.1.9/pcimodules-pciutils.diff b/meta/recipes-bsp/pciutils/pciutils-3.1.9/pcimodules-pciutils.diff
new file mode 100644
index 0000000000..0d4e0fb220
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.1.9/pcimodules-pciutils.diff
@@ -0,0 +1,340 @@
1Upstream-Status: Inappropriate [packaging]
2
37/30/2010 - rebased to 3.1.5 by Qing He <qing.he@intel.com>
4
5diff -uNr pciutils-3.1.5.orig/Makefile pciutils-3.1.5/Makefile
6--- pciutils-3.1.5.orig/Makefile 2010-07-30 14:02:15.000000000 +0800
7+++ pciutils-3.1.5/Makefile 2010-07-30 14:02:55.000000000 +0800
8@@ -51,7 +51,7 @@
9
10 export
11
12-all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
13+all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) pcimodules pcimodules.8
14
15 lib/$(PCILIB): $(PCIINC) force
16 $(MAKE) -C lib all
17@@ -61,9 +61,11 @@
18 lib/config.h lib/config.mk:
19 cd lib && ./configure
20
21+pcimodules: pcimodules.o common.o lib/$(PCILIB)
22 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)
23 setpci: setpci.o common.o lib/$(PCILIB)
24
25+pcimodules.o: pcimodules.c pciutils.h
26 LSPCIINC=lspci.h pciutils.h $(PCIINC)
27 lspci.o: lspci.c $(LSPCIINC)
28 ls-vpd.o: ls-vpd.c $(LSPCIINC)
29@@ -100,10 +102,10 @@
30 install: all
31 # -c is ignored on Linux, but required on FreeBSD
32 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
33- $(INSTALL) -c -m 755 lspci setpci $(DESTDIR)$(SBINDIR)
34+ $(INSTALL) -c -m 755 lspci setpci pcimodules $(DESTDIR)$(SBINDIR)
35 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
36 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
37- $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
38+ $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 pcimodules.8 $(DESTDIR)$(MANDIR)/man8
39 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
40 ifeq ($(SHARED),yes)
41 $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
42@@ -121,9 +123,9 @@
43 endif
44
45 uninstall: all
46- rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
47+ rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/pcimodules $(DESTDIR)$(SBINDIR)/update-pciids
48 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
49- rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
50+ rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/pcimodules.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
51 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
52 ifeq ($(SHARED),yes)
53 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
54Index: pciutils-3.0.3/pcimodules.c
55===================================================================
56--- /dev/null 1970-01-01 00:00:00.000000000 +0000
57+++ pciutils-3.0.3/pcimodules.c 2008-12-31 00:41:47.000000000 +0000
58@@ -0,0 +1,185 @@
59+/*
60+ * pcimodules: Load all kernel modules for PCI device currently
61+ * plugged into any PCI slot.
62+ *
63+ * Copyright 2000 Yggdrasil Computing, Incorporated
64+ * This file may be copied under the terms and conditions of version
65+ * two of the GNU General Public License, as published by the Free
66+ * Software Foundation (Cambridge, Massachusetts, USA).
67+ *
68+ * This file is based on pciutils/lib/example.c, which has the following
69+ * authorship and copyright statement:
70+ *
71+ * Written by Martin Mares and put to public domain. You can do
72+ * with it anything you want, but I don't give you any warranty.
73+ */
74+
75+#include <stdlib.h>
76+#include <stdio.h>
77+#include <malloc.h>
78+#include <string.h>
79+#include <unistd.h>
80+#include <sys/utsname.h>
81+#include <sys/param.h>
82+#include <sys/types.h>
83+
84+#define _GNU_SOURCE
85+#include <getopt.h>
86+
87+#include "pciutils.h"
88+
89+#define MODDIR "/lib/modules"
90+#define PCIMAP "modules.pcimap"
91+
92+#define LINELENGTH 8000
93+
94+#define DEVICE_ANY 0xffffffff
95+#define VENDOR_ANY 0xffffffff
96+
97+#include "lib/pci.h"
98+
99+ const char program_name[] = "lspci";
100+
101+struct pcimap_entry {
102+ unsigned int vendor, subsys_vendor, dev, subsys_dev, class, class_mask;
103+ char *module;
104+ struct pcimap_entry *next;
105+};
106+
107+static struct pcimap_entry *pcimap_list = NULL;
108+
109+#define OPT_STRING "h"
110+static struct option long_options[] = {
111+ {"class", required_argument, NULL, 'c'},
112+ {"classmask", required_argument, NULL, 'm'},
113+ {"help", no_argument, NULL, 'h'},
114+ { 0, 0, 0, 0}
115+};
116+
117+static unsigned long desired_class;
118+static unsigned long desired_classmask; /* Default is 0: accept all classes.*/
119+
120+void
121+read_pcimap(void)
122+{
123+ struct utsname utsname;
124+ char filename[MAXPATHLEN];
125+ FILE *pcimap_file;
126+ char line[LINELENGTH];
127+ struct pcimap_entry *entry;
128+ unsigned int driver_data;
129+ char *prevmodule = "";
130+ char module[LINELENGTH];
131+
132+ if (uname(&utsname) < 0) {
133+ perror("uname");
134+ exit(1);
135+ }
136+ sprintf(filename, "%s/%s/%s", MODDIR, utsname.release, PCIMAP);
137+ if ((pcimap_file = fopen(filename, "r")) == NULL) {
138+ perror(filename);
139+ exit(1);
140+ }
141+
142+ while(fgets(line, LINELENGTH, pcimap_file) != NULL) {
143+ if (line[0] == '#')
144+ continue;
145+
146+ entry = xmalloc(sizeof(struct pcimap_entry));
147+
148+ if (sscanf(line, "%s 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
149+ module,
150+ &entry->vendor, &entry->dev,
151+ &entry->subsys_vendor, &entry->subsys_dev,
152+ &entry->class, &entry->class_mask,
153+ &driver_data) != 8) {
154+ fprintf (stderr,
155+ "modules.pcimap unparsable line: %s.\n", line);
156+ free(entry);
157+ continue;
158+ }
159+
160+ /* Optimize memory allocation a bit, in case someday we
161+ have Linux systems with ~100,000 modules. It also
162+ allows us to just compare pointers to avoid trying
163+ to load a module twice. */
164+ if (strcmp(module, prevmodule) != 0) {
165+ prevmodule = xmalloc(strlen(module)+1);
166+ strcpy(prevmodule, module);
167+ }
168+ entry->module = prevmodule;
169+ entry->next = pcimap_list;
170+ pcimap_list = entry;
171+ }
172+ fclose(pcimap_file);
173+}
174+
175+/* Return a filled in pci_access->dev tree, with the device classes
176+ stored in dev->aux.
177+*/
178+static void
179+match_pci_modules(void)
180+{
181+ struct pci_access *pacc;
182+ struct pci_dev *dev;
183+ unsigned int class, subsys_dev, subsys_vendor;
184+ struct pcimap_entry *map;
185+ const char *prevmodule = "";
186+
187+ pacc = pci_alloc(); /* Get the pci_access structure */
188+ /* Set all options you want -- here we stick with the defaults */
189+ pci_init(pacc); /* Initialize the PCI library */
190+ pci_scan_bus(pacc); /* We want to get the list of devices */
191+ for(dev=pacc->devices; dev; dev=dev->next) {
192+ pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES);
193+ class = (pci_read_word(dev, PCI_CLASS_DEVICE) << 8)
194+ | pci_read_byte(dev, PCI_CLASS_PROG);
195+ subsys_dev = pci_read_word(dev, PCI_SUBSYSTEM_ID);
196+ subsys_vendor = pci_read_word(dev,PCI_SUBSYSTEM_VENDOR_ID);
197+ for(map = pcimap_list; map != NULL; map = map->next) {
198+ if (((map->class ^ class) & map->class_mask) == 0 &&
199+ ((desired_class ^ class) & desired_classmask)==0 &&
200+ (map->dev == DEVICE_ANY ||
201+ map->dev == dev->device_id) &&
202+ (map->vendor == VENDOR_ANY ||
203+ map->vendor == dev->vendor_id) &&
204+ (map->subsys_dev == DEVICE_ANY ||
205+ map->subsys_dev == subsys_dev) &&
206+ (map->subsys_vendor == VENDOR_ANY ||
207+ map->subsys_vendor == subsys_vendor) &&
208+ prevmodule != map->module) {
209+ printf("%s\n", map->module);
210+ prevmodule = map->module;
211+ }
212+ }
213+
214+ }
215+ pci_cleanup(pacc);
216+}
217+
218+int
219+main (int argc, char **argv)
220+{
221+ int opt_index = 0;
222+ int opt;
223+
224+ while ((opt = getopt_long(argc, argv, OPT_STRING, long_options,
225+ &opt_index)) != -1) {
226+ switch(opt) {
227+ case 'c':
228+ desired_class = strtol(optarg, NULL, 0);
229+ break;
230+ case 'm':
231+ desired_classmask = strtol(optarg, NULL, 0);
232+ break;
233+ case 'h':
234+ printf ("Usage: pcimodules [--help]\n"
235+ " Lists kernel modules corresponding to PCI devices currently plugged"
236+ " into the computer.\n");
237+ }
238+ }
239+
240+ read_pcimap();
241+ match_pci_modules();
242+ return 0;
243+}
244Index: pciutils-3.0.3/pcimodules.man
245===================================================================
246--- /dev/null 1970-01-01 00:00:00.000000000 +0000
247+++ pciutils-3.0.3/pcimodules.man 2008-12-31 00:41:47.000000000 +0000
248@@ -0,0 +1,92 @@
249+.TH pcimodules 8 "@TODAY@" "@VERSION@" "Linux PCI Utilities"
250+.IX pcimodules
251+.SH NAME
252+pcimodules \- List kernel driver modules available for all currently plugged
253+in PCI devices
254+.SH SYNOPSIS
255+.B pcimodules
256+.RB [ --class class_id ]
257+.RB [ --classmask mask ]
258+.RB [ --help ]
259+.SH DESCRIPTION
260+.B pcimodules
261+lists all driver modules for all currently plugged in PCI devices.
262+.B pcimodules
263+should be run at boot time, and whenever a PCI device is "hot plugged"
264+into the system. This can be done by the following Bourne shell syntax:
265+.IP
266+ for module in $(pcimodules) ; do
267+.IP
268+ modprobe -s -k "$module"
269+.IP
270+ done
271+.PP
272+When a PCI device is removed from the system, the Linux kernel will
273+decrement a usage count on PCI driver module. If this count drops
274+to zero (i.e., there are no PCI drivers), then the
275+.B modprobe -r
276+process that is normally configured to run from cron every few minutes
277+will eventually remove the unneeded module.
278+.PP
279+The --class and --classmask arguments can be used to limit the search
280+to certain classes of PCI devices. This is useful, for example, to
281+generate a list of ethernet card drivers to be loaded when the kernel
282+has indicated that it is trying to resolve an unknown network interface.
283+.PP
284+Modules are listed in the order in which the PCI devices are physically
285+arranged so that the computer owner can arrange things like having scsi
286+device 0 be on a controller that is not alphabetically the first scsi
287+controller.
288+.SH OPTIONS
289+.TP
290+.B --class class --classmask mask
291+.PP
292+--class and --classmask limit the search to PCI
293+cards in particular classes. These arguments are always used together.
294+The arguments to --class and --classmask
295+can be given as hexadecimal numbers by prefixing a leading "0x".
296+Note that the classes used by pcimodules are in "Linux" format,
297+meaning the class value that you see with lspci would be shifted
298+left eight bits, with the new low eight bits programming interface ID.
299+An examples of how to use class and classmask is provided below.
300+.B --help, -h
301+Print a help message and exit.
302+.SH EXAMPLES
303+.TP
304+pcimodules
305+lists all modules corresponding to currently plugged in PCI devices.
306+.TP
307+pcimodules --class 0x200000 --classmask 0xffff00
308+lists all modules corresponding to currently plugged in ethernet PCI devices.
309+.SH FILES
310+.TP
311+.B /lib/modules/<kernel-version>/modules.pcimap
312+This file is automatically generated by
313+.B depmod,
314+and used by
315+.B pcimodules
316+to determine which modules correspond to which PCI ID's.
317+.TP
318+.B /proc/bus/pci
319+An interface to PCI bus configuration space provided by the post-2.1.82 Linux
320+kernels. Contains per-bus subdirectories with per-card config space files and a
321+.I devices
322+file containing a list of all PCI devices.
323+
324+.SH SEE ALSO
325+.BR lspci (8)
326+
327+.SH MAINTAINER
328+The Linux PCI Utilities are maintained by Martin Mares <mj@suse.cz>.
329+
330+.SH AUTHOR
331+.B pcimodules
332+was written by Adam J. Richter <adam@yggdrasil.com>, based on public
333+domain example code by Martin Mares <mj@suse.cz>.
334+
335+.SH COPYRIGHT
336+.B pcimodules
337+is copyright 2000, Yggdrasil Computing, Incorporated, and may
338+be copied under the terms and conditions of version 2 of the GNU
339+General Public License as published by the Free Software Foundation
340+(Cambrige, Massachusetts, United States of America).