]>
Commit | Line | Data |
---|---|---|
c7a34993 MM |
1 | /* |
2 | * The PCI Utilities -- List All PCI Devices | |
3 | * | |
4 | * Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #define PCIUTILS_LSPCI | |
10 | #include "pciutils.h" | |
11 | ||
12 | /* | |
13 | * If we aren't being compiled by GCC, use xmalloc() instead of alloca(). | |
14 | * This increases our memory footprint, but only slightly since we don't | |
15 | * use alloca() much. | |
16 | */ | |
17 | #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) | |
18 | /* alloca() is defined in stdlib.h */ | |
19 | #elif defined(__GNUC__) && !defined(PCI_OS_WINDOWS) | |
20 | #include <alloca.h> | |
21 | #else | |
22 | #undef alloca | |
23 | #define alloca xmalloc | |
24 | #endif | |
25 | ||
26 | /*** Options ***/ | |
27 | ||
28 | extern int verbose; | |
29 | extern struct pci_filter filter; | |
30 | extern char *opt_pcimap; | |
31 | ||
32 | /*** PCI devices and access to their config space ***/ | |
33 | ||
34 | struct device { | |
35 | struct device *next; | |
36 | struct pci_dev *dev; | |
37 | unsigned int config_cached, config_bufsize; | |
38 | byte *config; /* Cached configuration space data */ | |
39 | byte *present; /* Maps which configuration bytes are present */ | |
40 | }; | |
41 | ||
42 | extern struct device *first_dev; | |
43 | extern struct pci_access *pacc; | |
44 | ||
45 | struct device *scan_device(struct pci_dev *p); | |
46 | void show_device(struct device *d); | |
47 | ||
48 | int config_fetch(struct device *d, unsigned int pos, unsigned int len); | |
49 | u32 get_conf_long(struct device *d, unsigned int pos); | |
50 | word get_conf_word(struct device *d, unsigned int pos); | |
51 | byte get_conf_byte(struct device *d, unsigned int pos); | |
52 | ||
53 | void get_subid(struct device *d, word *subvp, word *subdp); | |
54 | ||
55 | #define FLAG(x,y) ((x & y) ? '+' : '-') | |
56 | ||
57 | /* ls-vpd.c */ | |
58 | ||
59 | void cap_vpd(struct device *d); | |
60 | ||
61 | /* ls-caps.c */ | |
62 | ||
63 | void show_caps(struct device *d); | |
64 | ||
65 | /* ls-ecaps.c */ | |
66 | ||
67 | void show_ext_caps(struct device *d); | |
68 | ||
69 | /* ls-kernel.c */ | |
70 | ||
71 | void show_kernel_machine(struct device *d UNUSED); | |
72 | void show_kernel(struct device *d UNUSED); | |
73 | ||
74 | /* ls-tree.c */ | |
75 | ||
76 | void show_forest(void); | |
77 | ||
78 | /* ls-map.c */ | |
79 | ||
80 | void map_the_bus(void); |