]> mj.ucw.cz Git - pciutils.git/blobdiff - lspci.c
Add device-tree node path to the verbose output
[pciutils.git] / lspci.c
diff --git a/lspci.c b/lspci.c
index 5b6716e7f862c855d402642a6882a7ee6ab4cb54..e207e03e366e4d4a8bd46042a4e4ef7425dfe1e3 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1,7 +1,7 @@
 /*
  *     The PCI Utilities -- List All PCI Devices
  *
- *     Copyright (c) 1997--2015 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2016 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -315,6 +315,8 @@ show_terse(struct device *d)
       word subsys_v, subsys_d;
       char ssnamebuf[256];
 
+      pci_fill_info(p, PCI_FILL_LABEL);
+
       if (p->label)
         printf("\tDeviceName: %s", p->label);
       get_subid(d, &subsys_v, &subsys_d);
@@ -329,7 +331,7 @@ show_terse(struct device *d)
 /*** Verbose output ***/
 
 static void
-show_size(pciaddr_t x)
+show_size(u64 x)
 {
   static const char suffix[][2] = { "", "K", "M", "G", "T" };
   unsigned i;
@@ -343,6 +345,32 @@ show_size(pciaddr_t x)
   printf(" [size=%u%s]", (unsigned)x, suffix[i]);
 }
 
+static void
+show_range(char *prefix, u64 base, u64 limit, int is_64bit)
+{
+  if (base > limit)
+    {
+      if (!verbose)
+       return;
+      else if (verbose < 3)
+       {
+         printf("%s: None\n", prefix);
+         return;
+       }
+    }
+
+  printf("%s: ", prefix);
+  if (is_64bit)
+    printf("%016" PCI_U64_FMT_X "-%016" PCI_U64_FMT_X, base, limit);
+  else
+    printf("%08x-%08x", (unsigned) base, (unsigned) limit);
+  if (base <= limit)
+    show_size(limit - base + 1);
+  else
+    printf(" [empty]");
+  putchar('\n');
+}
+
 static void
 show_bases(struct device *d, int cnt)
 {
@@ -367,8 +395,9 @@ show_bases(struct device *d, int cnt)
        putchar('\t');
       if (ioflg & PCI_IORESOURCE_PCI_EA_BEI)
          printf("[enhanced] ");
-      else if (pos && !flg)    /* Reported by the OS, but not by the device */
+      else if (pos && !(flg & ((flg & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)))
        {
+         /* Reported by the OS, but not by the device */
          printf("[virtual] ");
          flg = pos;
          virtual = 1;
@@ -486,7 +515,6 @@ show_htype1(struct device *d)
   u32 pref_type = pref_base & PCI_PREF_RANGE_TYPE_MASK;
   word sec_stat = get_conf_word(d, PCI_SEC_STATUS);
   word brc = get_conf_word(d, PCI_BRIDGE_CONTROL);
-  int verb = verbose > 2;
 
   show_bases(d, 2);
   printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
@@ -507,8 +535,7 @@ show_htype1(struct device *d)
          io_base |= (get_conf_word(d, PCI_IO_BASE_UPPER16) << 16);
          io_limit |= (get_conf_word(d, PCI_IO_LIMIT_UPPER16) << 16);
        }
-      if (io_base <= io_limit || verb)
-       printf("\tI/O behind bridge: %08x-%08x\n", io_base, io_limit+0xfff);
+      show_range("\tI/O behind bridge", io_base, io_limit+0xfff, 0);
     }
 
   if (mem_type != (mem_limit & PCI_MEMORY_RANGE_TYPE_MASK) ||
@@ -518,8 +545,7 @@ show_htype1(struct device *d)
     {
       mem_base = (mem_base & PCI_MEMORY_RANGE_MASK) << 16;
       mem_limit = (mem_limit & PCI_MEMORY_RANGE_MASK) << 16;
-      if (mem_base <= mem_limit || verb)
-       printf("\tMemory behind bridge: %08x-%08x\n", mem_base, mem_limit + 0xfffff);
+      show_range("\tMemory behind bridge", mem_base, mem_limit + 0xfffff, 0);
     }
 
   if (pref_type != (pref_limit & PCI_PREF_RANGE_TYPE_MASK) ||
@@ -527,19 +553,14 @@ show_htype1(struct device *d)
     printf("\t!!! Unknown prefetchable memory range types %x/%x\n", pref_base, pref_limit);
   else
     {
-      pref_base = (pref_base & PCI_PREF_RANGE_MASK) << 16;
-      pref_limit = (pref_limit & PCI_PREF_RANGE_MASK) << 16;
-      if (pref_base <= pref_limit || verb)
+      u64 pref_base_64 = (pref_base & PCI_PREF_RANGE_MASK) << 16;
+      u64 pref_limit_64 = (pref_limit & PCI_PREF_RANGE_MASK) << 16;
+      if (pref_type == PCI_PREF_RANGE_TYPE_64)
        {
-         if (pref_type == PCI_PREF_RANGE_TYPE_32)
-           printf("\tPrefetchable memory behind bridge: %08x-%08x\n", pref_base, pref_limit + 0xfffff);
-         else
-           printf("\tPrefetchable memory behind bridge: %08x%08x-%08x%08x\n",
-                  get_conf_long(d, PCI_PREF_BASE_UPPER32),
-                  pref_base,
-                  get_conf_long(d, PCI_PREF_LIMIT_UPPER32),
-                  pref_limit + 0xfffff);
+         pref_base_64 |= (u64) get_conf_long(d, PCI_PREF_BASE_UPPER32) << 32;
+         pref_limit_64 |= (u64) get_conf_long(d, PCI_PREF_LIMIT_UPPER32) << 32;
        }
+      show_range("\tPrefetchable memory behind bridge", pref_base_64, pref_limit_64 + 0xfffff, (pref_type == PCI_PREF_RANGE_TYPE_64));
     }
 
   if (verbose > 1)
@@ -560,11 +581,12 @@ show_htype1(struct device *d)
 
   if (verbose > 1)
     {
-      printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c MAbort%c >Reset%c FastB2B%c\n",
+      printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c VGA16%c MAbort%c >Reset%c FastB2B%c\n",
        FLAG(brc, PCI_BRIDGE_CTL_PARITY),
        FLAG(brc, PCI_BRIDGE_CTL_SERR),
        FLAG(brc, PCI_BRIDGE_CTL_NO_ISA),
        FLAG(brc, PCI_BRIDGE_CTL_VGA),
+       FLAG(brc, PCI_BRIDGE_CTL_VGA_16BIT),
        FLAG(brc, PCI_BRIDGE_CTL_MASTER_ABORT),
        FLAG(brc, PCI_BRIDGE_CTL_BUS_RESET),
        FLAG(brc, PCI_BRIDGE_CTL_FAST_BACK));
@@ -664,7 +686,7 @@ show_verbose(struct device *d)
   show_terse(d);
 
   pci_fill_info(p, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES |
-    PCI_FILL_PHYS_SLOT | PCI_FILL_LABEL | PCI_FILL_NUMA_NODE);
+    PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE);
   irq = p->irq;
 
   switch (htype)
@@ -695,6 +717,8 @@ show_verbose(struct device *d)
 
   if (verbose > 1)
     {
+      if (p->dt_node)
+        printf("\tDT Node: %s\n", p->dt_node);
       printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c DisINTx%c\n",
             FLAG(cmd, PCI_COMMAND_IO),
             FLAG(cmd, PCI_COMMAND_MEMORY),
@@ -748,6 +772,8 @@ show_verbose(struct device *d)
     }
   else
     {
+      if (p->dt_node)
+        printf("\tDT Node: %s\n", p->dt_node);
       printf("\tFlags: ");
       if (cmd & PCI_COMMAND_MASTER)
        printf("bus master, ");
@@ -846,7 +872,7 @@ show_machine(struct device *d)
 
   if (verbose)
     {
-      pci_fill_info(p, PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE);
+      pci_fill_info(p, PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE);
       printf((opt_machine >= 2) ? "Slot:\t" : "Device:\t");
       show_slot_name(d);
       putchar('\n');
@@ -873,6 +899,8 @@ show_machine(struct device *d)
        show_kernel_machine(d);
       if (p->numa_node != -1)
        printf("NUMANode:\t%d\n", p->numa_node);
+      if (p->dt_node)
+        printf("DTNode:\t%s\n", p->dt_node);
     }
   else
     {