summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp/pciutils/pciutils-3.2.0/pcimodules-pciutils.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-bsp/pciutils/pciutils-3.2.0/pcimodules-pciutils.diff')
-rw-r--r--meta/recipes-bsp/pciutils/pciutils-3.2.0/pcimodules-pciutils.diff340
1 files changed, 340 insertions, 0 deletions
diff --git a/meta/recipes-bsp/pciutils/pciutils-3.2.0/pcimodules-pciutils.diff b/meta/recipes-bsp/pciutils/pciutils-3.2.0/pcimodules-pciutils.diff
new file mode 100644
index 0000000000..0d4e0fb220
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils-3.2.0/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).