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 v2+
8 * SPDX-License-Identifier: GPL-2.0-or-later
11 #define PCIUTILS_LSPCI
15 * If we aren't being compiled by GCC, use xmalloc() instead of alloca().
16 * This increases our memory footprint, but only slightly since we don't
19 #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) || defined (__DJGPP__)
20 /* alloca() is defined in stdlib.h */
21 #elif defined(__GNUC__) && !defined(PCI_OS_WINDOWS)
25 #define alloca xmalloc
31 extern struct pci_filter filter;
32 extern char *opt_pcimap;
34 /*** PCI devices and access to their config space ***/
39 /* Bus topology calculated by grow_tree() */
40 struct device *bus_next;
41 struct bus *parent_bus;
42 struct bridge *bridge;
45 unsigned int config_cached, config_bufsize;
46 byte *config; /* Cached configuration space data */
47 byte *present; /* Maps which configuration bytes are present */
50 extern struct device *first_dev;
51 extern struct pci_access *pacc;
53 struct device *scan_device(struct pci_dev *p);
54 void show_device(struct device *d);
56 int config_fetch(struct device *d, unsigned int pos, unsigned int len);
57 u32 get_conf_long(struct device *d, unsigned int pos);
58 word get_conf_word(struct device *d, unsigned int pos);
59 byte get_conf_byte(struct device *d, unsigned int pos);
63 void cap_vpd(struct device *d);
67 void show_caps(struct device *d, int where);
71 void show_ext_caps(struct device *d, int type);
73 /* ls-caps-vendor.c */
75 void show_vendor_caps(struct device *d, int where, int cap);
79 void show_kernel_machine(struct device *d UNUSED);
80 void show_kernel(struct device *d UNUSED);
81 void show_kernel_cleanup(void);
86 struct bridge *chain; /* Single-linked list of bridges */
87 struct bridge *next, *prev, *child; /* Tree of bridges */
88 struct bus *first_bus, *last_bus; /* List of buses connected to this bridge */
90 unsigned int primary, secondary, subordinate; /* Bus numbers */
91 struct device *br_dev;
98 struct bridge *parent_bridge;
99 struct device *first_dev, **last_dev;
102 extern struct bridge host_bridge;
104 void grow_tree(void);
105 void show_forest(struct pci_filter *filter);
109 void map_the_bus(void);