]> mj.ucw.cz Git - pciutils.git/commitdiff
lspci now understands PCI capability lists. Currently, the only capability I
authorMartin Mares <mj@ucw.cz>
Sun, 24 Jan 1999 21:38:46 +0000 (21:38 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:10:02 +0000 (14:10 +0200)
know about is AGP, but the fact it's numbered 0x02 tries to tell that
something else might be hiding behind the properties :)

ChangeLog
README
lspci.c

index 7081fd2bb27369956a30623bb0bc2e47eaf1f823..f65921d8093fd39ee9935b26f4dc4c253b7543ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Sun Jan 24 22:10:36 1999  Martin Mares  <mj@albireo.ucw.cz>
+
+       * lspci.c (show_verbose): Display `Cap' flag in device status.
+
+       * lspci.c (show_htype0): Display capability lists whereever
+       available. The only capability name we recognize now is `AGP'.
+       Unfortunately, capabilities are stored in device-dependent
+       portion of the configuration space and are thus available
+       only to root unless you read a dump.
+
+       * lspci.c (scan_devices): Use cache instead of buffering.
+
+       * lib/buffer.c: Removed (obsoleted by the cache).
+
+       * lib/access.c: Added general caching mechanism.
+
 Sat Jan 23 21:30:54 1999  Martin Mares  <mj@albireo.ucw.cz>
 
        * pci.ids: Added few devices.
diff --git a/README b/README
index 390d6ff5e7603c311aea83de8cb4da0c48f1cc6e..b79a626db0d9a1288bbe1a6226d99267cbc249b7 100644 (file)
--- a/README
+++ b/README
@@ -53,3 +53,4 @@ notes and other news: http://atrey.karlin.mff.cuni.cz/~mj/pciutils.html.
 TODO:
        - lspci: "scan hard" function
        - lib: "syscall" access method
+       - .lsm and .spec
diff --git a/lspci.c b/lspci.c
index 2b1c5e11bd1ed57b8a8c0d037a72c2043e845859..45390d919d27f8e113afdd5dc9a6c39e3fe1a64d 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1,5 +1,5 @@
 /*
- *     $Id: lspci.c,v 1.19 1999/01/22 21:04:54 mj Exp $
+ *     $Id: lspci.c,v 1.20 1999/01/24 21:38:47 mj Exp $
  *
  *     Linux PCI Utilities -- List All PCI Devices
  *
@@ -65,7 +65,7 @@ static struct pci_access *pacc;
 struct device {
   struct device *next;
   struct pci_dev *dev;
-  int config_cnt;
+  unsigned int config_cnt;
   byte config[256];
 };
 
@@ -97,11 +97,31 @@ scan_devices(void)
          how_much = 128;
        }
       d->config_cnt = how_much;
-      pci_setup_buffer(p, d->config);
+      pci_setup_cache(p, d->config, d->config_cnt);
       pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE);
     }
 }
 
+static int
+check_root(void)
+{
+  static int is_root = -1;
+
+  if (is_root < 0)
+    is_root = !geteuid();
+  return is_root;
+}
+
+static int
+config_fetch(struct device *d, unsigned int pos, unsigned int len)
+{
+  if (pos + len < d->config_cnt)
+    return 1;
+  if (pacc->method != PCI_ACCESS_DUMP && !check_root())
+    return 0;
+  return pci_read_block(d->dev, pos, d->config + pos, len);
+}
+
 /* Config space accesses */
 
 static inline byte
@@ -294,6 +314,38 @@ show_htype0(struct device *d)
   if (rom & 1)
     printf("\tExpansion ROM at %08lx%s\n", rom & PCI_ROM_ADDRESS_MASK,
           (rom & PCI_ROM_ADDRESS_ENABLE) ? "" : " [disabled]");
+  if (get_conf_word(d, PCI_STATUS) & PCI_STATUS_CAP_LIST)
+    {
+      int where = get_conf_byte(d, PCI_CAPABILITY_LIST);
+      while (where)
+       {
+         int id, next, ver;
+         printf("\tCapabilities: ");
+         if (!config_fetch(d, where, 4))
+           {
+             puts("<available only to root>");
+             break;
+           }
+         id = get_conf_byte(d, where);
+         next = get_conf_byte(d, where+1);
+         ver = get_conf_byte(d, where+2);
+         if (id == 0xff)
+           {
+             printf("<chain broken at %02x>\n", where);
+             break;
+           }
+         switch (id)
+           {
+           case 2:
+             printf("AGP");
+             break;
+           default:
+             printf("C%02x", id);
+           }
+         printf(" version %x.%x at %02x\n", ver/16, ver%16, where);
+         where = next;
+       }
+    }
 }
 
 static void
@@ -508,7 +560,8 @@ show_verbose(struct device *d)
             (cmd & PCI_COMMAND_WAIT) ? '+' : '-',
             (cmd & PCI_COMMAND_SERR) ? '+' : '-',
             (cmd & PCI_COMMAND_FAST_BACK) ? '+' : '-');
-      printf("\tStatus: 66Mhz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c >SERR%c <PERR%c\n",
+      printf("\tStatus: Cap%c 66Mhz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c >SERR%c <PERR%c\n",
+            (status & PCI_STATUS_CAP_LIST) ? '+' : '-',
             (status & PCI_STATUS_66MHZ) ? '+' : '-',
             (status & PCI_STATUS_UDF) ? '+' : '-',
             (status & PCI_STATUS_FAST_BACK) ? '+' : '-',
@@ -588,7 +641,7 @@ show_verbose(struct device *d)
 static void
 show_hex_dump(struct device *d)
 {
-  int i;
+  unsigned int i;
 
   for(i=0; i<d->config_cnt; i++)
     {