]>
Commit | Line | Data |
---|---|---|
c7a34993 MM |
1 | /* |
2 | * The PCI Utilities -- List All PCI Devices | |
3 | * | |
6b056c8e | 4 | * Copyright (c) 1997--2018 Martin Mares <mj@ucw.cz> |
c7a34993 MM |
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 | */ | |
5c5ce192 | 17 | #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) || defined (__DJGPP__) |
c7a34993 MM |
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; | |
6b056c8e MM |
37 | /* Bus topology calculated by grow_tree() */ |
38 | struct device *bus_next; | |
39 | struct bus *parent_bus; | |
40 | struct bridge *bridge; | |
41 | /* Cache */ | |
c7a34993 MM |
42 | unsigned int config_cached, config_bufsize; |
43 | byte *config; /* Cached configuration space data */ | |
44 | byte *present; /* Maps which configuration bytes are present */ | |
45 | }; | |
46 | ||
47 | extern struct device *first_dev; | |
48 | extern struct pci_access *pacc; | |
49 | ||
50 | struct device *scan_device(struct pci_dev *p); | |
51 | void show_device(struct device *d); | |
52 | ||
53 | int config_fetch(struct device *d, unsigned int pos, unsigned int len); | |
54 | u32 get_conf_long(struct device *d, unsigned int pos); | |
55 | word get_conf_word(struct device *d, unsigned int pos); | |
56 | byte get_conf_byte(struct device *d, unsigned int pos); | |
57 | ||
58 | void get_subid(struct device *d, word *subvp, word *subdp); | |
59 | ||
769ff0a8 MM |
60 | /* Useful macros for decoding of bits and bit fields */ |
61 | ||
c7a34993 | 62 | #define FLAG(x,y) ((x & y) ? '+' : '-') |
769ff0a8 MM |
63 | #define BITS(x,at,width) (((x) >> (at)) & ((1 << (width)) - 1)) |
64 | #define TABLE(tab,x,buf) ((x) < sizeof(tab)/sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf))) | |
c7a34993 MM |
65 | |
66 | /* ls-vpd.c */ | |
67 | ||
68 | void cap_vpd(struct device *d); | |
69 | ||
70 | /* ls-caps.c */ | |
71 | ||
21510591 | 72 | void show_caps(struct device *d, int where); |
c7a34993 MM |
73 | |
74 | /* ls-ecaps.c */ | |
75 | ||
a1492b88 | 76 | void show_ext_caps(struct device *d, int type); |
c7a34993 | 77 | |
7ff8a323 GH |
78 | /* ls-caps-vendor.c */ |
79 | ||
80 | void show_vendor_caps(struct device *d, int where, int cap); | |
81 | ||
c7a34993 MM |
82 | /* ls-kernel.c */ |
83 | ||
84 | void show_kernel_machine(struct device *d UNUSED); | |
85 | void show_kernel(struct device *d UNUSED); | |
17ec7e70 | 86 | void show_kernel_cleanup(void); |
c7a34993 MM |
87 | |
88 | /* ls-tree.c */ | |
89 | ||
6b056c8e MM |
90 | struct bridge { |
91 | struct bridge *chain; /* Single-linked list of bridges */ | |
92 | struct bridge *next, *child; /* Tree of bridges */ | |
93 | struct bus *first_bus; /* List of buses connected to this bridge */ | |
94 | unsigned int domain; | |
95 | unsigned int primary, secondary, subordinate; /* Bus numbers */ | |
96 | struct device *br_dev; | |
97 | }; | |
98 | ||
99 | struct bus { | |
100 | unsigned int domain; | |
101 | unsigned int number; | |
102 | struct bus *sibling; | |
103 | struct bridge *parent_bridge; | |
104 | struct device *first_dev, **last_dev; | |
105 | }; | |
106 | ||
107 | extern struct bridge host_bridge; | |
108 | ||
109 | void grow_tree(void); | |
c7a34993 MM |
110 | void show_forest(void); |
111 | ||
112 | /* ls-map.c */ | |
113 | ||
114 | void map_the_bus(void); |