1 |
vapier 08/04/13 22:38:52 |
2 |
|
3 |
Added: pcimodules-pciutils-3.0.0.patch |
4 |
Log: |
5 |
Version bump #217433 by Arfrever Frehtes Taifersar Arahesis. |
6 |
(Portage version: 2.2_pre5) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 sys-apps/pciutils/files/pcimodules-pciutils-3.0.0.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/pcimodules-pciutils-3.0.0.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/pcimodules-pciutils-3.0.0.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: pcimodules-pciutils-3.0.0.patch |
15 |
=================================================================== |
16 |
--- pciutils-3.0.0/Makefile |
17 |
+++ pciutils-3.0.0/Makefile |
18 |
@@ -34,9 +34,11 @@ |
19 |
lib/config.h lib/config.mk: |
20 |
cd lib && ./configure |
21 |
|
22 |
+pcimodules: pcimodules.o common.o lib/$(PCILIB) |
23 |
lspci: lspci.o common.o lib/$(PCILIB) |
24 |
setpci: setpci.o common.o lib/$(PCILIB) |
25 |
|
26 |
+pcimodules.o: pcimodules.c pciutils.h $(PCIINC) |
27 |
lspci.o: lspci.c pciutils.h $(PCIINC) |
28 |
setpci.o: setpci.c pciutils.h $(PCIINC) |
29 |
common.o: common.c pciutils.h $(PCIINC) |
30 |
--- pciutils-3.0.0/pcimodules.c |
31 |
+++ pciutils-3.0.0/pcimodules.c |
32 |
@@ -0,0 +1,184 @@ |
33 |
+/* |
34 |
+ * pcimodules: Load all kernel modules for PCI device currently |
35 |
+ * plugged into any PCI slot. |
36 |
+ * |
37 |
+ * Copyright 2000 Yggdrasil Computing, Incorporated |
38 |
+ * This file may be copied under the terms and conditions of version |
39 |
+ * two of the GNU General Public License, as published by the Free |
40 |
+ * Software Foundation (Cambridge, Massachusetts, USA). |
41 |
+ * |
42 |
+ * This file is based on pciutils/lib/example.c, which has the following |
43 |
+ * authorship and copyright statement: |
44 |
+ * |
45 |
+ * Written by Martin Mares and put to public domain. You can do |
46 |
+ * with it anything you want, but I don't give you any warranty. |
47 |
+ */ |
48 |
+ |
49 |
+#include <stdlib.h> |
50 |
+#include <stdio.h> |
51 |
+#include <string.h> |
52 |
+#include <unistd.h> |
53 |
+#include <sys/utsname.h> |
54 |
+#include <sys/param.h> |
55 |
+#include <sys/types.h> |
56 |
+ |
57 |
+#define _GNU_SOURCE |
58 |
+#include <getopt.h> |
59 |
+ |
60 |
+#include "pciutils.h" |
61 |
+ |
62 |
+#define MODDIR "/lib/modules" |
63 |
+#define PCIMAP "modules.pcimap" |
64 |
+ |
65 |
+#define LINELENGTH 8000 |
66 |
+ |
67 |
+#define DEVICE_ANY 0xffffffff |
68 |
+#define VENDOR_ANY 0xffffffff |
69 |
+ |
70 |
+#include "lib/pci.h" |
71 |
+ |
72 |
+struct pcimap_entry { |
73 |
+ unsigned int vendor, subsys_vendor, dev, subsys_dev, class, class_mask; |
74 |
+ char *module; |
75 |
+ struct pcimap_entry *next; |
76 |
+}; |
77 |
+ |
78 |
+static struct pcimap_entry *pcimap_list = NULL; |
79 |
+ |
80 |
+const char program_name[] = "pcimodules"; |
81 |
+ |
82 |
+#define OPT_STRING "hcm" |
83 |
+static struct option long_options[] = { |
84 |
+ {"class", required_argument, NULL, 'c'}, |
85 |
+ {"classmask", required_argument, NULL, 'm'}, |
86 |
+ {"help", no_argument, NULL, 'h'}, |
87 |
+ { 0, 0, 0, 0} |
88 |
+}; |
89 |
+ |
90 |
+static unsigned long desired_class; |
91 |
+static unsigned long desired_classmask; /* Default is 0: accept all classes.*/ |
92 |
+ |
93 |
+static void |
94 |
+read_pcimap(void) |
95 |
+{ |
96 |
+ struct utsname utsname; |
97 |
+ char filename[MAXPATHLEN]; |
98 |
+ FILE *pcimap_file; |
99 |
+ char line[LINELENGTH]; |
100 |
+ struct pcimap_entry *entry; |
101 |
+ unsigned int driver_data; |
102 |
+ char *prevmodule = ""; |
103 |
+ char module[LINELENGTH]; |
104 |
+ |
105 |
+ if (uname(&utsname) < 0) { |
106 |
+ perror("uname"); |
107 |
+ exit(1); |
108 |
+ } |
109 |
+ sprintf(filename, "%s/%s/%s", MODDIR, utsname.release, PCIMAP); |
110 |
+ if ((pcimap_file = fopen(filename, "r")) == NULL) { |
111 |
+ perror(filename); |
112 |
+ exit(1); |
113 |
+ } |
114 |
+ |
115 |
+ while(fgets(line, LINELENGTH, pcimap_file) != NULL) { |
116 |
+ if (line[0] == '#') |
117 |
+ continue; |
118 |
+ |
119 |
+ entry = xmalloc(sizeof(struct pcimap_entry)); |
120 |
+ |
121 |
+ if (sscanf(line, "%s 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", |
122 |
+ module, |
123 |
+ &entry->vendor, &entry->dev, |
124 |
+ &entry->subsys_vendor, &entry->subsys_dev, |
125 |
+ &entry->class, &entry->class_mask, |
126 |
+ &driver_data) != 8) { |
127 |
+ fprintf (stderr, |
128 |
+ "modules.pcimap unparsable line: %s.\n", line); |
129 |
+ free(entry); |
130 |
+ continue; |
131 |
+ } |
132 |
+ |
133 |
+ /* Optimize memory allocation a bit, in case someday we |
134 |
+ have Linux systems with ~100,000 modules. It also |
135 |
+ allows us to just compare pointers to avoid trying |
136 |
+ to load a module twice. */ |
137 |
+ if (strcmp(module, prevmodule) != 0) { |
138 |
+ prevmodule = xmalloc(strlen(module)+1); |
139 |
+ strcpy(prevmodule, module); |
140 |
+ } |
141 |
+ entry->module = prevmodule; |
142 |
+ entry->next = pcimap_list; |
143 |
+ pcimap_list = entry; |
144 |
+ } |
145 |
+ fclose(pcimap_file); |
146 |
+} |
147 |
+ |
148 |
+/* Return a filled in pci_access->dev tree, with the device classes |
149 |
+ stored in dev->aux. |
150 |
+*/ |
151 |
+static void |
152 |
+match_pci_modules(void) |
153 |
+{ |
154 |
+ struct pci_access *pacc; |
155 |
+ struct pci_dev *dev; |
156 |
+ unsigned int class, subsys_dev, subsys_vendor; |
157 |
+ struct pcimap_entry *map; |
158 |
+ const char *prevmodule = ""; |
159 |
+ |
160 |
+ pacc = pci_alloc(); /* Get the pci_access structure */ |
161 |
+ /* Set all options you want -- here we stick with the defaults */ |
162 |
+ pci_init(pacc); /* Initialize the PCI library */ |
163 |
+ pci_scan_bus(pacc); /* We want to get the list of devices */ |
164 |
+ for(dev=pacc->devices; dev; dev=dev->next) { |
165 |
+ pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES); |
166 |
+ class = (pci_read_word(dev, PCI_CLASS_DEVICE) << 8) |
167 |
+ | pci_read_byte(dev, PCI_CLASS_PROG); |
168 |
+ subsys_dev = pci_read_word(dev, PCI_SUBSYSTEM_ID); |
169 |
+ subsys_vendor = pci_read_word(dev,PCI_SUBSYSTEM_VENDOR_ID); |
170 |
+ for(map = pcimap_list; map != NULL; map = map->next) { |
171 |
+ if (((map->class ^ class) & map->class_mask) == 0 && |
172 |
+ ((desired_class ^ class) & desired_classmask)==0 && |
173 |
+ (map->dev == DEVICE_ANY || |
174 |
+ map->dev == dev->device_id) && |
175 |
+ (map->vendor == VENDOR_ANY || |
176 |
+ map->vendor == dev->vendor_id) && |
177 |
+ (map->subsys_dev == DEVICE_ANY || |
178 |
+ map->subsys_dev == subsys_dev) && |
179 |
+ (map->subsys_vendor == VENDOR_ANY || |
180 |
+ map->subsys_vendor == subsys_vendor) && |
181 |
+ prevmodule != map->module) { |
182 |
+ printf("%s\n", map->module); |
183 |
+ prevmodule = map->module; |
184 |
+ } |
185 |
+ } |
186 |
+ |
187 |
+ } |
188 |
+ pci_cleanup(pacc); |
189 |
+} |
190 |
+ |
191 |
+int |
192 |
+main (int argc, char **argv) |
193 |
+{ |
194 |
+ int opt_index = 0; |
195 |
+ int opt; |
196 |
+ |
197 |
+ while ((opt = getopt_long(argc, argv, OPT_STRING, long_options, |
198 |
+ &opt_index)) != -1) { |
199 |
+ switch(opt) { |
200 |
+ case 'c': |
201 |
+ desired_class = strtol(optarg, NULL, 0); |
202 |
+ break; |
203 |
+ case 'm': |
204 |
+ desired_classmask = strtol(optarg, NULL, 0); |
205 |
+ break; |
206 |
+ case 'h': |
207 |
+ printf ("Usage: pcimodules [--help]\n" |
208 |
+ " Lists kernel modules corresponding to PCI devices currently plugged" |
209 |
+ " into the computer.\n"); |
210 |
+ } |
211 |
+ } |
212 |
+ |
213 |
+ read_pcimap(); |
214 |
+ match_pci_modules(); |
215 |
+ return 0; |
216 |
+} |
217 |
--- pciutils-3.0.0/pcimodules.man |
218 |
+++ pciutils-3.0.0/pcimodules.man |
219 |
@@ -0,0 +1,92 @@ |
220 |
+.TH pcimodules 8 "@TODAY@" "@VERSION@" "Linux PCI Utilities" |
221 |
+.IX pcimodules |
222 |
+.SH NAME |
223 |
+pcimodules \- List kernel driver modules available for all currently plugged |
224 |
+in PCI devices |
225 |
+.SH SYNOPSIS |
226 |
+.B pcimodules |
227 |
+.RB [ --class class_id ] |
228 |
+.RB [ --classmask mask ] |
229 |
+.RB [ --help ] |
230 |
+.SH DESCRIPTION |
231 |
+.B pcimodules |
232 |
+lists all driver modules for all currently plugged in PCI devices. |
233 |
+.B pcimodules |
234 |
+should be run at boot time, and whenever a PCI device is "hot plugged" |
235 |
+into the system. This can be done by the following Bourne shell syntax: |
236 |
+.IP |
237 |
+ for module in $(pcimodules) ; do |
238 |
+.IP |
239 |
+ modprobe -s -k "$module" |
240 |
+.IP |
241 |
+ done |
242 |
+.PP |
243 |
+When a PCI device is removed from the system, the Linux kernel will |
244 |
+decrement a usage count on PCI driver module. If this count drops |
245 |
+to zero (i.e., there are no PCI drivers), then the |
246 |
+.B modprobe -r |
247 |
+process that is normally configured to run from cron every few minutes |
248 |
+will eventually remove the unneeded module. |
249 |
+.PP |
250 |
+The --class and --classmask arguments can be used to limit the search |
251 |
+to certain classes of PCI devices. This is useful, for example, to |
252 |
+generate a list of ethernet card drivers to be loaded when the kernel |
253 |
+has indicated that it is trying to resolve an unknown network interface. |
254 |
+.PP |
255 |
+Modules are listed in the order in which the PCI devices are physically |
256 |
+arranged so that the computer owner can arrange things like having scsi |
257 |
+device 0 be on a controller that is not alphabetically the first scsi |
258 |
+controller. |
259 |
+.SH OPTIONS |
260 |
+.TP |
261 |
+.B --class class --classmask mask |
262 |
+.PP |
263 |
+--class and --classmask limit the search to PCI |
264 |
+cards in particular classes. These arguments are always used together. |
265 |
+The arguments to --class and --classmask |
266 |
+can be given as hexadecimal numbers by prefixing a leading "0x". |
267 |
+Note that the classes used by pcimodules are in "Linux" format, |
268 |
+meaning the class value that you see with lspci would be shifted |
269 |
+left eight bits, with the new low eight bits programming interface ID. |
270 |
+An examples of how to use class and classmask is provided below. |
271 |
+.B --help, -h |
272 |
+Print a help message and exit. |
273 |
+.SH EXAMPLES |
274 |
+.TP |
275 |
+pcimodules |
276 |
+lists all modules corresponding to currently plugged in PCI devices. |
277 |
+.TP |
278 |
+pcimodules --class 0x200000 --classmask 0xffff00 |
279 |
+lists all modules corresponding to currently plugged in ethernet PCI devices. |
280 |
+.SH FILES |
281 |
+.TP |
282 |
+.B /lib/modules/<kernel-version>/modules.pcimap |
283 |
+This file is automatically generated by |
284 |
+.B depmod, |
285 |
+and used by |
286 |
+.B pcimodules |
287 |
+to determine which modules correspond to which PCI ID's. |
288 |
+.TP |
289 |
+.B /proc/bus/pci |
290 |
+An interface to PCI bus configuration space provided by the post-2.1.82 Linux |
291 |
+kernels. Contains per-bus subdirectories with per-card config space files and a |
292 |
+.I devices |
293 |
+file containing a list of all PCI devices. |
294 |
+ |
295 |
+.SH SEE ALSO |
296 |
+.BR lspci (8) |
297 |
+ |
298 |
+.SH MAINTAINER |
299 |
+The Linux PCI Utilities are maintained by Martin Mares <mj@××××.cz>. |
300 |
+ |
301 |
+.SH AUTHOR |
302 |
+.B pcimodules |
303 |
+was written by Adam J. Richter <adam@×××××××××.com>, based on public |
304 |
+domain example code by Martin Mares <mj@××××.cz>. |
305 |
+ |
306 |
+.SH COPYRIGHT |
307 |
+.B pcimodules |
308 |
+is copyright 2000, Yggdrasil Computing, Incorporated, and may |
309 |
+be copied under the terms and conditions of version 2 of the GNU |
310 |
+General Public License as published by the Free Software Foundation |
311 |
+(Cambrige, Massachusetts, United States of America). |
312 |
|
313 |
|
314 |
|
315 |
-- |
316 |
gentoo-commits@l.g.o mailing list |