]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-map.c
libpci: ecam: Fix big address range mappings
[pciutils.git] / ls-map.c
index c812f503d63a30b211d9df7ed88851a5d244b551..a77eb0c85f55ab3b9bc176be358f6bf234900bc2 100644 (file)
--- a/ls-map.c
+++ b/ls-map.c
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <stdio.h>
@@ -38,7 +40,7 @@ map_bridge(struct bus_info *bi, struct device *d, int np, int ns, int nl)
   b->func = p->func;
   b->first = get_conf_byte(d, ns);
   b->last = get_conf_byte(d, nl);
-  printf("## %02x.%02x:%d is a bridge from %02x to %02x-%02x\n",
+  printf("## %02x:%02x.%d is a bridge from %02x to %02x-%02x\n",
         p->bus, p->dev, p->func, b->this, b->first, b->last);
   if (b->this != p->bus)
     printf("!!! Bridge points to invalid primary bus.\n");
@@ -52,13 +54,14 @@ map_bridge(struct bus_info *bi, struct device *d, int np, int ns, int nl)
 static void
 do_map_bus(int bus)
 {
+  int domain = (filter.domain >= 0 ? filter.domain : 0);
   int dev, func;
   int verbose = pacc->debugging;
   struct bus_info *bi = bus_info + bus;
   struct device *d;
 
   if (verbose)
-    printf("Mapping bus %02x\n", bus);
+    printf("Mapping bus %04x:%02x\n", domain, bus);
   for (dev = 0; dev < 32; dev++)
     if (filter.slot < 0 || filter.slot == dev)
       {
@@ -66,15 +69,14 @@ do_map_bus(int bus)
        for (func = 0; func < func_limit; func++)
          if (filter.func < 0 || filter.func == func)
            {
-             /* XXX: Bus mapping supports only domain 0 */
-             struct pci_dev *p = pci_get_dev(pacc, 0, bus, dev, func);
+             struct pci_dev *p = pci_get_dev(pacc, domain, bus, dev, func);
              u16 vendor = pci_read_word(p, PCI_VENDOR_ID);
              if (vendor && vendor != 0xffff)
                {
                  if (!func && (pci_read_byte(p, PCI_HEADER_TYPE) & 0x80))
                    func_limit = 8;
                  if (verbose)
-                   printf("Discovered device %02x:%02x.%d\n", bus, dev, func);
+                   printf("Discovered device %04x:%02x:%02x.%d\n", domain, bus, dev, func);
                  bi->exists = 1;
                  if (d = scan_device(p))
                    {
@@ -164,6 +166,8 @@ void
 map_the_bus(void)
 {
   if (pacc->method == PCI_ACCESS_PROC_BUS_PCI ||
+      pacc->method == PCI_ACCESS_SYS_BUS_PCI ||
+      pacc->method == PCI_ACCESS_WIN32_CFGMGR32 ||
       pacc->method == PCI_ACCESS_DUMP)
     printf("WARNING: Bus mapping can be reliable only with direct hardware access enabled.\n\n");
   bus_info = xmalloc(sizeof(struct bus_info) * 256);