2 * The PCI Utilities -- List All PCI Devices
4 * Copyright (c) 1997--2018 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
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
17 #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) || defined (__DJGPP__)
18 /* alloca() is defined in stdlib.h */
19 #elif defined(__GNUC__) && !defined(PCI_OS_WINDOWS)
23 #define alloca xmalloc
29 extern struct pci_filter filter;
30 extern char *opt_pcimap;
32 /*** PCI devices and access to their config space ***/
37 /* Bus topology calculated by grow_tree() */
38 struct device *bus_next;
39 struct bus *parent_bus;
40 struct bridge *bridge;
43 unsigned int config_cached, config_bufsize;
44 byte *config; /* Cached configuration space data */
45 byte *present; /* Maps which configuration bytes are present */
48 extern struct device *first_dev;
49 extern struct pci_access *pacc;
51 struct device *scan_device(struct pci_dev *p);
52 void show_device(struct device *d);
54 int config_fetch(struct device *d, unsigned int pos, unsigned int len);
55 u32 get_conf_long(struct device *d, unsigned int pos);
56 word get_conf_word(struct device *d, unsigned int pos);
57 byte get_conf_byte(struct device *d, unsigned int pos);
59 /* Useful macros for decoding of bits and bit fields */
61 #define FLAG(x,y) ((x & y) ? '+' : '-')
62 #define BITS(x,at,width) (((x) >> (at)) & ((1 << (width)) - 1))
63 #define TABLE(tab,x,buf) ((x) < sizeof(tab)/sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf)))
67 void cap_vpd(struct device *d);
71 void show_caps(struct device *d, int where);
75 void show_ext_caps(struct device *d, int type);
77 /* ls-caps-vendor.c */
79 void show_vendor_caps(struct device *d, int where, int cap);
83 void show_kernel_machine(struct device *d UNUSED);
84 void show_kernel(struct device *d UNUSED);
85 void show_kernel_cleanup(void);
90 struct bridge *chain; /* Single-linked list of bridges */
91 struct bridge *next, *child; /* Tree of bridges */
92 struct bus *first_bus, *last_bus; /* List of buses connected to this bridge */
94 unsigned int primary, secondary, subordinate; /* Bus numbers */
95 struct device *br_dev;
102 struct bridge *parent_bridge;
103 struct device *first_dev, **last_dev;
106 extern struct bridge host_bridge;
108 void grow_tree(void);
109 void show_forest(struct pci_filter *filter);
113 void map_the_bus(void);