-static int verbose; /* Show detailed information */
-static int buscentric_view; /* Show bus addresses/IRQ's instead of CPU-visible ones */
-static int show_hex; /* Show contents of config space as hexadecimal numbers */
-static int bus_filter = -1; /* Bus, slot, function, vendor and device ID filtering */
-static int slot_filter = -1;
-static int func_filter = -1;
-static int vend_filter = -1;
-static int dev_filter = -1;
-static int show_tree; /* Show bus tree */
-
-static char options[] = "nvbxB:S:F:V:D:t";
-
-static char help_msg[] = "\
-Usage: lspci [<switches>]\n\
-\n\
--v\tBe verbose\n\
--n\tShow numeric ID's\n\
--b\tBus-centric view (PCI addresses and IRQ's instead of those seen by the CPU)\n\
--x\tShow hex-dump of config space (-xx shows full 256 bytes)\n\
--B <bus>, -S <slot>, -F <func>, -V <vendor>, -D <device> Show only selected devices\n\
--t\tShow bus tree\n\
-";
-
-/* Our view of the PCI bus */
-
-struct device {
- struct device *next;
- byte bus, devfn;
- word vendid, devid;
- unsigned int kernel_irq;
- unsigned long kernel_base_addr[6];
- byte config[256];
-};
-
-static struct device *first_dev, **last_dev = &first_dev;
-
-/* Miscellaneous routines */
-
-void *
-xmalloc(unsigned int howmuch)
+int verbose; /* Show detailed information */
+static int opt_hex; /* Show contents of config space as hexadecimal numbers */
+struct pci_filter filter; /* Device filter */
+static int opt_filter; /* Any filter was given */
+static int opt_tree; /* Show bus tree */
+static int opt_path; /* Show bridge path */
+static int opt_machine; /* Generate machine-readable output */
+static int opt_map_mode; /* Bus mapping mode enabled */
+static int opt_domains; /* Show domain numbers (0=disabled, 1=auto-detected, 2=requested) */
+static int opt_kernel; /* Show kernel drivers */
+static int opt_query_dns; /* Query the DNS (0=disabled, 1=enabled, 2=refresh cache) */
+static int opt_query_all; /* Query the DNS for all entries */
+char *opt_pcimap; /* Override path to Linux modules.pcimap */
+
+const char program_name[] = "lspci";
+
+static char options[] = "nvbxs:d:tPi:mgp:qkMDQ" GENERIC_OPTIONS ;
+
+static char help_msg[] =
+"Usage: lspci [<switches>]\n"
+"\n"
+"Basic display modes:\n"
+"-mm\t\tProduce machine-readable output (single -m for an obsolete format)\n"
+"-t\t\tShow bus tree\n"
+"\n"
+"Display options:\n"
+"-v\t\tBe verbose (-vv or -vvv for higher verbosity)\n"
+#ifdef PCI_OS_LINUX
+"-k\t\tShow kernel drivers handling each device\n"
+#endif
+"-x\t\tShow hex-dump of the standard part of the config space\n"
+"-xxx\t\tShow hex-dump of the whole config space (dangerous; root only)\n"
+"-xxxx\t\tShow hex-dump of the 4096-byte extended config space (root only)\n"
+"-b\t\tBus-centric view (addresses and IRQ's as seen by the bus)\n"
+"-D\t\tAlways show domain numbers\n"
+"-P\t\tDisplay bridge path in addition to bus and device number\n"
+"-PP\t\tDisplay bus path in addition to bus and device number\n"
+"\n"
+"Resolving of device ID's to names:\n"
+"-n\t\tShow numeric ID's\n"
+"-nn\t\tShow both textual and numeric ID's (names & numbers)\n"
+#ifdef PCI_USE_DNS
+"-q\t\tQuery the PCI ID database for unknown ID's via DNS\n"
+"-qq\t\tAs above, but re-query locally cached entries\n"
+"-Q\t\tQuery the PCI ID database for all ID's via DNS\n"
+#endif
+"\n"
+"Selection of devices:\n"
+"-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]\tShow only devices in selected slots\n"
+"-d [<vendor>]:[<device>][:<class>]\t\tShow only devices with specified ID's\n"
+"\n"
+"Other options:\n"
+"-i <file>\tUse specified ID database instead of %s\n"
+#ifdef PCI_OS_LINUX
+"-p <file>\tLook up kernel modules in a given file instead of default modules.pcimap\n"
+#endif
+"-M\t\tEnable `bus mapping' mode (dangerous; root only)\n"
+"\n"
+"PCI access options:\n"
+GENERIC_HELP
+;
+
+/*** Our view of the PCI bus ***/
+
+struct pci_access *pacc;
+struct device *first_dev;
+static int seen_errors;
+static int need_topology;
+
+int
+config_fetch(struct device *d, unsigned int pos, unsigned int len)