]> mj.ucw.cz Git - pciutils.git/commitdiff
Added support for printing of subsystem IDs.
authorMartin Mares <mj@ucw.cz>
Fri, 17 Jul 1998 08:57:11 +0000 (08:57 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:09:54 +0000 (14:09 +0200)
Releasing as version 1.07.

ChangeLog
lspci.8
lspci.c
names.c
pci.ids
pciutils.h
pciutils.lsm
setpci.8

index 358ee4825383166982cdff337a29f84b5d51a96b..0b37ee55eb453ab119bf3c817fb7fc5343ba065d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Jul 17 10:43:30 1998  Martin Mares  <mj@albireo.ucw.cz>
+
+       * lspci.c (show_verbose): Print subsystem ID using the new resolver.
+       (show_machine): Print subsystem ID.
+
+       * names.c: New name resolution engine supporting subsystem IDs.
+
+       * Released as version 1.07.
+
 Wed Jul 15 15:37:21 1998  Martin Mares  <mj@albireo.ucw.cz>
 
        * lspci.c (show_htype2 etc.): Displaying of CardBus headers.
diff --git a/lspci.8 b/lspci.8
index 1bf95b29bbab3fb6e4e78f76a2a39bd4614d5277..d98a91da8d955b6257c3d455e97bdd39e9154bdd 100644 (file)
--- a/lspci.8
+++ b/lspci.8
@@ -1,4 +1,4 @@
-.TH lspci 8 "12 June 1998" "pciutils-1.06" "Linux PCI Utilities"
+.TH lspci 8 "17 July 1998" "pciutils-1.07" "Linux PCI Utilities"
 .IX lspci
 .SH NAME
 lspci \- list all PCI devices
diff --git a/lspci.c b/lspci.c
index 7517896aada3e15855cc144300f219611bb1c084..8a1fdbff41c5cd325ea8b9ba4a5044b03162edd0 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1,5 +1,5 @@
 /*
- *     $Id: lspci.c,v 1.13 1998/07/15 20:37:12 mj Exp $
+ *     $Id: lspci.c,v 1.14 1998/07/17 08:57:14 mj Exp $
  *
  *     Linux PCI Utilities -- List All PCI Devices
  *
@@ -520,10 +520,11 @@ show_verbose(struct device *d)
   else
     irq = d->kernel_irq;
 
+  if (verbose && subsys_v && subsys_v != 0xffff)
+    printf("\tSubsystem: %s\n", lookup_subsys_device_full(subsys_v, subsys_d));
+
   if (verbose > 1)
     {
-      if (subsys_v)
-       printf("\tSubsystem ID: %04x:%04x\n", subsys_v, subsys_d);
       printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c\n",
             (cmd & PCI_COMMAND_IO) ? '+' : '-',
             (cmd & PCI_COMMAND_MEMORY) ? '+' : '-',
@@ -634,6 +635,19 @@ static void
 show_machine(struct device *d)
 {
   int c;
+  word sv_id=0, sd_id=0;
+
+  switch (get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f)
+    {
+    case PCI_HEADER_TYPE_NORMAL:
+      sv_id = get_conf_word(d, PCI_SUBSYSTEM_VENDOR_ID);
+      sd_id = get_conf_word(d, PCI_SUBSYSTEM_ID);
+      break;
+    case PCI_HEADER_TYPE_CARDBUS:
+      sv_id = get_conf_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID);
+      sd_id = get_conf_word(d, PCI_CB_SUBSYSTEM_ID);
+      break;
+    }
 
   if (verbose)
     {
@@ -641,6 +655,11 @@ show_machine(struct device *d)
       printf("Class:\t%s\n", lookup_class(get_conf_word(d, PCI_CLASS_DEVICE)));
       printf("Vendor:\t%s\n", lookup_vendor(d->vendid));
       printf("Device:\t%s\n", lookup_device(d->vendid, d->devid));
+      if (sv_id && sv_id != 0xffff)
+       {
+         printf("SVendor:\t%s\n", lookup_subsys_vendor(sv_id));
+         printf("SDevice:\t%s\n", lookup_subsys_device(sv_id, sd_id));
+       }
       if (c = get_conf_byte(d, PCI_REVISION_ID))
        printf("Rev:\t%02x\n", c);
       if (c = get_conf_byte(d, PCI_CLASS_PROG))
@@ -657,6 +676,10 @@ show_machine(struct device *d)
        printf(" -r%02x", c);
       if (c = get_conf_byte(d, PCI_CLASS_PROG))
        printf(" -p%02x", c);
+      if (sv_id && sv_id != 0xffff)
+       printf(" \"%s\" \"%s\"", lookup_subsys_vendor(sv_id), lookup_subsys_device(sv_id, sd_id));
+      else
+       printf(" \"\" \"\"");
       putchar('\n');
     }
 }
diff --git a/names.c b/names.c
index 27c9a90a85937e5e01572add86d8528b783074e8..5067dec17d12c1641aecd15b59bc386c5fed97cb 100644 (file)
--- a/names.c
+++ b/names.c
@@ -1,5 +1,5 @@
 /*
- *     $Id: names.c,v 1.5 1998/06/09 19:16:45 mj Exp $
+ *     $Id: names.c,v 1.6 1998/07/17 08:57:16 mj Exp $
  *
  *     Linux PCI Utilities -- Device ID to Name Translation
  *
@@ -26,50 +26,54 @@ static int name_list_loaded;
 
 struct nl_entry {
   struct nl_entry *next;
-  int id1, id2;
+  word id1, id2;
+  int cat;
   byte *name;
 };
 
-#define ID1_VENDOR -1
-#define ID1_CLASS -2
-#define ID1_SUBCLASS -3
-#define ID1_ERROR -4
+#define NL_VENDOR 0
+#define NL_DEVICE 1
+#define NL_CLASS 2
+#define NL_SUBCLASS 3
+#define NL_SUBSYSTEM_VENDOR 4
+#define NL_SUBSYSTEM_DEVICE 5
 
 #define HASH_SIZE 1024
 
 static struct nl_entry *nl_hash[HASH_SIZE];
 
-static inline unsigned int nl_calc_hash(int id1, int id2)
+static inline unsigned int nl_calc_hash(int cat, int id1, int id2)
 {
   unsigned int h;
 
-  h = id1 ^ id2;
-  h ^= (h >> 6);
+  h = id1 ^ id2 ^ (cat << 5);
+  h += (h >> 6);
   return h & (HASH_SIZE-1);
 }
 
-static struct nl_entry *nl_lookup(int id1, int id2)
+static struct nl_entry *nl_lookup(int cat, int id1, int id2)
 {
-  unsigned int h = nl_calc_hash(id1, id2);
+  unsigned int h = nl_calc_hash(cat, id1, id2);
   struct nl_entry *n = nl_hash[h];
 
-  while (n && (n->id1 != id1 || n->id2 != id2))
+  while (n && (n->id1 != id1 || n->id2 != id2 || n->cat != cat))
     n = n->next;
   return n;
 }
 
-static int nl_add(int id1, int id2, byte *text)
+static int nl_add(int cat, int id1, int id2, byte *text)
 {
-  unsigned int h = nl_calc_hash(id1, id2);
+  unsigned int h = nl_calc_hash(cat, id1, id2);
   struct nl_entry *n = nl_hash[h];
 
-  while (n && (n->id1 != id1 || n->id2 != id2))
+  while (n && (n->id1 != id1 || n->id2 != id2 || n->cat != cat))
     n = n->next;
   if (n)
     return 1;
   n = xmalloc(sizeof(struct nl_entry));
   n->id1 = id1;
   n->id2 = id2;
+  n->cat = cat;
   n->name = text;
   n->next = nl_hash[h];
   nl_hash[h] = n;
@@ -89,9 +93,8 @@ parse_name_list(void)
   byte *p = name_list;
   byte *q, *r;
   int lino = 0;
-  int id1 = ID1_ERROR;
-  int id2 = 0;
-  int i, j;
+  unsigned int id1=0, id2=0;
+  int cat, last_cat = -1;
 
   while (*p)
     {
@@ -120,45 +123,52 @@ parse_name_list(void)
       r = q;
       while (*q == ' ')
        q++;
-      if (strlen(q) < 5 || q[4] != ' ')
-       goto parserr;
       if (r == q)
        {
          if (q[0] == 'C' && q[1] == ' ')
            {
-             if (sscanf(q+2, "%x", &j) != 1)
+             if (strlen(q+2) < 3 ||
+                 q[4] != ' ' ||
+                 sscanf(q+2, "%x", &id1) != 1)
                goto parserr;
-             i = ID1_CLASS;
+             cat = last_cat = NL_CLASS;
+           }
+         else if (q[0] == 'S' && q[1] == ' ')
+           {
+             if (strlen(q+2) < 5 ||
+                 q[6] != ' ' ||
+                 sscanf(q+2, "%x", &id1) != 1)
+               goto parserr;
+             cat = last_cat = NL_SUBSYSTEM_VENDOR;
+             q += 2;
            }
          else
            {
-             if (sscanf(q, "%x", &j) != 1)
+             if (strlen(q) < 5 ||
+                 q[4] != ' ' ||
+                 sscanf(q, "%x", &id1) != 1)
                goto parserr;
-             i = ID1_VENDOR;
+             cat = last_cat = NL_VENDOR;
            }
-         id1 = i;
-         id2 = j;
+         id2 = 0;
        }
       else
        {
-         if (sscanf(q, "%x", &j) != 1)
+         if (sscanf(q, "%x", &id2) != 1)
            goto parserr;
-         if (id1 == ID1_ERROR)
+         if (last_cat < 0)
            goto parserr;
-         if (id1 == ID1_CLASS)
-           {
-             i = ID1_SUBCLASS;
-             j |= (id2 << 8);
-           }
+         if (last_cat == NL_CLASS)
+           cat = NL_SUBCLASS;
          else
-           i = id2;
+           cat = last_cat+1;
        }
       q += 4;
       while (*q == ' ')
        q++;
       if (!*q)
        goto parserr;
-      if (nl_add(i, j, q))
+      if (nl_add(cat, id1, id2, q))
        {
          fprintf(stderr, "%s, line %d: duplicate entry\n", pci_ids, lino);
          exit(1);
@@ -195,7 +205,7 @@ load_name_list(void)
 }
 
 char *
-lookup_vendor(word i)
+do_lookup_vendor(int cat, word i)
 {
   static char vendbuf[6];
 
@@ -205,7 +215,7 @@ lookup_vendor(word i)
     {
       struct nl_entry *e;
 
-      e = nl_lookup(ID1_VENDOR, i);
+      e = nl_lookup(cat, i, 0);
       if (e)
        return e->name;
     }
@@ -214,7 +224,7 @@ lookup_vendor(word i)
 }
 
 char *
-lookup_device(word v, word i)
+do_lookup_device(int cat, word v, word i)
 {
   static char devbuf[6];
 
@@ -224,7 +234,7 @@ lookup_device(word v, word i)
     {
       struct nl_entry *e;
 
-      e = nl_lookup(v, i);
+      e = nl_lookup(cat, v, i);
       if (e)
        return e->name;
     }
@@ -233,7 +243,7 @@ lookup_device(word v, word i)
 }
 
 char *
-lookup_device_full(word v, word i)
+do_lookup_device_full(int cat, word v, word i)
 {
   static char fullbuf[256];
 
@@ -243,8 +253,8 @@ lookup_device_full(word v, word i)
     {
       struct nl_entry *e, *e2;
 
-      e = nl_lookup(ID1_VENDOR, v);
-      e2 = nl_lookup(v, i);
+      e = nl_lookup(cat, v, 0);
+      e2 = nl_lookup(cat+1, v, i);
       if (!e)
        sprintf(fullbuf, "Unknown device %04x:%04x", v, i);
       else if (!e2)
@@ -257,6 +267,42 @@ lookup_device_full(word v, word i)
   return fullbuf;
 }
 
+char *
+lookup_vendor(word i)
+{
+  return do_lookup_vendor(NL_VENDOR, i);
+}
+
+char *
+lookup_subsys_vendor(word i)
+{
+  return do_lookup_vendor(NL_SUBSYSTEM_VENDOR, i);
+}
+
+char *
+lookup_device(word i, word v)
+{
+  return do_lookup_device(NL_DEVICE, v, i);
+}
+
+char *
+lookup_subsys_device(word v, word i)
+{
+  return do_lookup_device(NL_SUBSYSTEM_DEVICE, v, i);
+}
+
+char *
+lookup_device_full(word v, word i)
+{
+  return do_lookup_device_full(NL_VENDOR, v, i);
+}
+
+char *
+lookup_subsys_device_full(word v, word i)
+{
+  return do_lookup_device_full(NL_SUBSYSTEM_VENDOR, v, i);
+}
+
 char *
 lookup_class(word c)
 {
@@ -268,10 +314,10 @@ lookup_class(word c)
     {
       struct nl_entry *e;
 
-      e = nl_lookup(ID1_SUBCLASS, c);
+      e = nl_lookup(NL_SUBCLASS, c >> 8, c & 0xff);
       if (e)
        return e->name;
-      e = nl_lookup(ID1_CLASS, c);
+      e = nl_lookup(NL_CLASS, c, 0);
       if (e)
        sprintf(classbuf, "%s [%04x]", e->name, c);
       else
diff --git a/pci.ids b/pci.ids
index 7f27ed5f86bbfa37da361cda1e5bb67f47702582..b9bcac8eac9335445c66f6e9de718512f28d94fe 100644 (file)
--- a/pci.ids
+++ b/pci.ids
@@ -4,7 +4,7 @@
 #      Maintained by Jens Maurer <linux-pcisupport@cck.uni-kl.de>
 #      If you have any new entries, send them to the maintainer.
 #
-#      $Id: pci.ids,v 1.10 1998/06/08 07:53:25 mj Exp $
+#      $Id: pci.ids,v 1.11 1998/07/17 08:57:18 mj Exp $
 #
 
 # Vendors and devices. Please keep sorted.
@@ -1832,3 +1832,4 @@ C 0C  Serial bus controller
        0002  SSA
        0003  USB Controller
        0004  Fiber Channel
+
index 666dafe558b4fd9ffc225bc85ca4a04e1968ca86..f46f2b4d97f0576aaa58f20111248d6381bf7de8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     $Id: pciutils.h,v 1.7 1998/07/15 20:37:15 mj Exp $
+ *     $Id: pciutils.h,v 1.8 1998/07/17 08:57:20 mj Exp $
  *
  *     Linux PCI Utilities -- Declarations
  *
@@ -40,6 +40,9 @@ char *lookup_vendor(word);
 char *lookup_device(word, word);
 char *lookup_device_full(word, word);
 char *lookup_class(word);
+char *lookup_subsys_vendor(word);
+char *lookup_subsys_device(word, word);
+char *lookup_subsys_device_full(word, word);
 
 /* filter.c */
 
index d73bb9177bde2080d646d19d1b5936b5ab49fcee..0460212aab9467b87473dd89f0f7e2bde8fd7bd1 100644 (file)
@@ -1,7 +1,7 @@
 Begin3
 Title:          Linux PCI Utilities
-Version:        1.06
-Entered-date:   980612
+Version:        1.07
+Entered-date:   980717
 Description:    This package contains various utilities for inspecting and
                setting of devices connected to the PCI bus. Requires
                kernel version 2.1.82 or newer (supporting the /proc/bus/pci
@@ -9,7 +9,7 @@ Description:    This package contains various utilities for inspecting and
 Keywords:       kernel, pci, proc, lspci, setpci
 Author:         mj@atrey.karlin.mff.cuni.cz (Martin Mares)
 Maintained-by:  mj@atrey.karlin.mff.cuni.cz (Martin Mares)
-Primary-site:   atrey.karlin.mff.cuni.cz pub/linux/pci/pciutils-1.06.tar.gz
-Alternate-site: sunsite.unc.edu pub/Linux/hardware/pciutils-1.06.tar.gz
+Primary-site:   atrey.karlin.mff.cuni.cz pub/linux/pci/pciutils-1.07.tar.gz
+Alternate-site: sunsite.unc.edu pub/Linux/hardware/pciutils-1.07.tar.gz
 Copying-policy: GPL
 End
index 318958805d24b3b42d2a42913b7b24d3cdeb687d..e9c275fa91e48beaf5dd709465cc5a49f76eb75e 100644 (file)
--- a/setpci.8
+++ b/setpci.8
@@ -1,4 +1,4 @@
-.TH setpci 8 "12 June 1998" "pciutils-1.06" "Linux PCI Utilities"
+.TH setpci 8 "17 July 1998" "pciutils-1.07" "Linux PCI Utilities"
 .IX setpci
 .SH NAME
 lspci \- configure PCI devices