Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Oct 2000 16:28:37 +0100 (BST)
From:      Steve.Roome@sse0691.bri.hp.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/22124: patch to update pciconf to give a -v option
Message-ID:  <200010191528.QAA34743@sse0691.bri.hp.com>

next in thread | raw e-mail | index | archive | help

>Number:         22124
>Category:       bin
>Synopsis:       patch to update pciconf to give a -v option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 19 08:30:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Steve Roome
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
>Environment:
	
	4.1-stable pciconf

>Description:

	This patch gives a -v option to pciconf, it's
	documented in the changed manpage, it shows
	device types in english to save hassle for ppl
	who don't have a device using a particular
	pci resource but want to know what it is without
	searching through include files to find out what
	type of type the class is saying it is.

>How-To-Repeat:

	use pciconf -l and guess what the classes mean!


>Fix:

*** /usr/src/usr.sbin/pciconf/pciconf.8.orig	Wed Mar  1 14:08:12 2000
--- /usr/src/usr.sbin/pciconf/pciconf.8	Thu Oct 19 16:23:45 2000
***************
*** 32,37 ****
--- 32,38 ----
  .Nd diagnostic utility for the PCI bus
  .Sh SYNOPSIS
  .Nm pciconf Fl l
+ .Op Fl v
  .Nm pciconf Fl a Ar selector
  .Nm pciconf Fl r Ar selector 
  .Op Fl b | Fl h
***************
*** 50,58 ****
  .Fl l
  option, it lists all devices found by the boot probe in the following format:
  .Bd -literal
! foo0@pci0:4:0: class=0x010000 card=0x00000000 chip=0x000f1000 rev=0x01 hdr=0x00
! bar0@pci0:5:0: class=0x000100 card=0x00000000 chip=0x88c15333 rev=0x00 hdr=0x00
! none0@pci0:6:0: class=0x020000 card=0x00000000 chip=0x802910ec rev=0x00 hdr=0x00
  .Ed
  .Pp
  The first column gives the 
--- 51,73 ----
  .Fl l
  option, it lists all devices found by the boot probe in the following format:
  .Bd -literal
! atapci0@pci0:1:0:   class=0x01018a card=0x00000000 chip=0x06461095 rev=0x01 hdr=0x00
! ahc0@pci0:2:0:      class=0x010000 card=0x00000000 chip=0x80789004 rev=0x00 hdr=0x00
! .Ed
! .Pp
! With both the 
! .Fl v
! and 
! .Fl l
! options a more verbose listing is shown with the device type:
! .Bd -literal
! atapci0@pci0:1:0
!         class=0x01018a card=0x00000000 chip=0x06461095 rev=0x01 hdr=0x00
!         IDE storage controller
! 
! ahc0@pci0:2:0
!         class=0x010000 card=0x00000000 chip=0x80789004 rev=0x00 hdr=0x00
!         SCSI storage controller
  .Ed
  .Pp
  The first column gives the 
***************
*** 171,180 ****
  .Sh AUTHORS
  The
  .Nm
! facility was written by
  .An Stefan Esser
  and
! .An Garrett Wollman .
  .Sh BUGS
  The 
  .Fl b 
--- 186,197 ----
  .Sh AUTHORS
  The
  .Nm
! facility was originally written by
  .An Stefan Esser
  and
! .An Garrett Wollman.
! .An Steve Roome
! added the verbose option.
  .Sh BUGS
  The 
  .Fl b 





*** /usr/src/usr.sbin/pciconf/pciconf.c.orig	Wed Dec  8 17:43:20 1999
--- /usr/src/usr.sbin/pciconf/pciconf.c	Thu Oct 19 15:44:42 2000
***************
*** 29,35 ****
  
  #ifndef lint
  static const char rcsid[] =
!   "$FreeBSD: src/usr.sbin/pciconf/pciconf.c,v 1.11 1999/12/08 17:43:20 ken Exp $";
  #endif /* not lint */
  
  #include <sys/types.h>
--- 29,35 ----
  
  #ifndef lint
  static const char rcsid[] =
!   "$FreeBSD: /c/ncvs/src/usr.sbin/pciconf/pciconf.c,v 1.11 1999/12/08 17:43:20 ken Exp $";
  #endif /* not lint */
  
  #include <sys/types.h>
***************
*** 44,50 ****
  
  #include "pathnames.h"
  
! static void list_devs(void);
  static void readit(const char *, const char *, int);
  static void writeit(const char *, const char *, const char *, int);
  static void chkattached(const char *, int);
--- 44,50 ----
  
  #include "pathnames.h"
  
! static void list_devs(int);
  static void readit(const char *, const char *, int);
  static void writeit(const char *, const char *, const char *, int);
  static void chkattached(const char *, int);
***************
*** 55,61 ****
  usage()
  {
  	fprintf(stderr, "%s\n%s\n%s\n%s\n",
! 		"usage: pciconf -l",
  		"       pciconf -a sel",
  		"       pciconf -r [-b | -h] sel addr",
  		"       pciconf -w [-b | -h] sel addr [value]");
--- 55,61 ----
  usage()
  {
  	fprintf(stderr, "%s\n%s\n%s\n%s\n",
! 		"usage: pciconf -l [-v]",
  		"       pciconf -a sel",
  		"       pciconf -r [-b | -h] sel addr",
  		"       pciconf -w [-b | -h] sel addr [value]");
***************
*** 66,77 ****
  main(int argc, char **argv)
  {
  	int c;
! 	int listmode, readmode, writemode, attachedmode;
  	int byte, isshort;
  
! 	listmode = readmode = writemode = attachedmode = byte = isshort = 0;
  
! 	while ((c = getopt(argc, argv, "alrwbh")) != -1) {
  		switch(c) {
  		case 'a':
  			attachedmode = 1;
--- 66,77 ----
  main(int argc, char **argv)
  {
  	int c;
! 	int listmode, readmode, writemode, attachedmode, verbose;
  	int byte, isshort;
  
! 	verbose = listmode = readmode = writemode = attachedmode = byte = isshort = 0;
  
! 	while ((c = getopt(argc, argv, "alvrwbh")) != -1) {
  		switch(c) {
  		case 'a':
  			attachedmode = 1;
***************
*** 97,102 ****
--- 97,106 ----
  			isshort = 1;
  			break;
  
+ 		case 'v':
+ 		        verbose = 1;
+ 			break;
+ 			
  		default:
  			usage();
  		}
***************
*** 109,115 ****
  		usage();
  
  	if (listmode) {
! 		list_devs();
  	} else if(attachedmode) {
  		chkattached(argv[optind], 
  		       byte ? 1 : isshort ? 2 : 4);
--- 113,119 ----
  		usage();
  
  	if (listmode) {
! 		list_devs(verbose);
  	} else if(attachedmode) {
  		chkattached(argv[optind], 
  		       byte ? 1 : isshort ? 2 : 4);
***************
*** 127,133 ****
  }
  
  static void
! list_devs(void)
  {
  	int fd;
  	struct pci_conf_io pc;
--- 131,137 ----
  }
  
  static void
! list_devs(int verbose)
  {
  	int fd;
  	struct pci_conf_io pc;
***************
*** 166,187 ****
  			return;
  		}
  		for (p = conf; p < &conf[pc.num_matches]; p++) {
! 
! 			printf("%s%d@pci%d:%d:%d:\tclass=0x%06x card=0x%08x "
  			       "chip=0x%08x rev=0x%02x hdr=0x%02x\n", 
  			       (p->pd_name && *p->pd_name) ? p->pd_name :
  			       "none",
  			       (p->pd_name && *p->pd_name) ? (int)p->pd_unit :
  			       none_count++,
  			       p->pc_sel.pc_bus, p->pc_sel.pc_dev, 
! 			       p->pc_sel.pc_func, (p->pc_class << 16) |
  			       (p->pc_subclass << 8) | p->pc_progif,
  			       (p->pc_subdevice << 16) | p->pc_subvendor,
  			       (p->pc_device << 16) | p->pc_vendor,
  			       p->pc_revid, p->pc_hdr);
  		}
  	} while (pc.status == PCI_GETCONF_MORE_DEVS);
- 
  	close(fd);
  }
  
--- 170,357 ----
  			return;
  		}
  		for (p = conf; p < &conf[pc.num_matches]; p++) {
! 		    if (!verbose) {
! 		        int char_count;
! 		        char_count=printf("%s%d@pci%d:%d:%d:",
! 					  (p->pd_name && *p->pd_name) ? p->pd_name :
! 					  "none",
! 					  (p->pd_name && *p->pd_name) ? (int)p->pd_unit :
! 					  none_count++,
! 					  p->pc_sel.pc_bus, p->pc_sel.pc_dev, 
! 					  p->pc_sel.pc_func);
! 			if (char_count<20) while (char_count++<20) printf(" ");
! 			printf("class=0x%06x card=0x%08x "
  			       "chip=0x%08x rev=0x%02x hdr=0x%02x\n",
+ 			       (p->pc_class << 16) |
+ 			       (p->pc_subclass << 8) | p->pc_progif,
+ 			       (p->pc_subdevice << 16) | p->pc_subvendor,
+ 			       (p->pc_device << 16) | p->pc_vendor,
+ 			       p->pc_revid, p->pc_hdr);
+ 		    } else {
+ 		        int char_count;
+ 			printf("%s%d@pci%d:%d:%d\n\t",
  					  (p->pd_name && *p->pd_name) ? p->pd_name :
  					  "none",
  					  (p->pd_name && *p->pd_name) ? (int)p->pd_unit :
  					  none_count++,
  					  p->pc_sel.pc_bus, p->pc_sel.pc_dev, 
! 					  p->pc_sel.pc_func);
! 			printf("class=0x%06x card=0x%08x "
! 			       "chip=0x%08x rev=0x%02x hdr=0x%02x\n",
! 			       (p->pc_class << 16) |
  			       (p->pc_subclass << 8) | p->pc_progif,
  			       (p->pc_subdevice << 16) | p->pc_subvendor,
  			       (p->pc_device << 16) | p->pc_vendor,
  			       p->pc_revid, p->pc_hdr);
+ 
+ 			printf("\t");
+ 			    switch (p->pc_class)
+ 				{
+ 				case (0) : printf("Device not classified.\n");	break;
+ 				case (1) : 
+ 				    switch(p->pc_subclass)
+ 					{
+ 					case(0x00): printf("SCSI"); break;
+ 					case(0x01): printf("IDE"); break;
+ 					case(0x02): printf("FLOPPY"); break;
+ 					case(0x03): printf("IPI"); break;
+ 					case(0x04): printf("RAID"); break;
+ 					case(0x80): printf("OTHER"); break;
+ 					default : printf("Unknown"); break;
+ 					}
+ 				    printf(" storage controller\n");
+ 				    break;
+ 				case (2) : 
+ 				    switch(p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("Ethernet"); break;
+ 					case (0x01) : printf("Tokenring"); break;
+ 					case (0x02) : printf("FDDI"); break;
+ 					case (0x03) : printf("ATM"); break;
+ 					case (0x80) : printf("Other"); break;
+ 					default : printf("Unknown"); break;
+ 					}
+ 				    printf(" network device\n");
+ 				    break;
+ 				case (3) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf ("VGA");  break;
+ 					case (0x01) : printf ("XGA"); break;
+ 					case (0x80) : printf ("Other"); break;
+ 					default : printf ("Unknown"); break;
+ 					} 
+ 				    printf(" display device\n");
+ 				    break;
+ 				case (4) : printf("Multimedia device - "); 
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("video\n"); break;
+ 					case (0x01) : printf("audio\n"); break;
+ 					case (0x80) : printf("other\n"); break;
+ 					default : printf("unkown type\n"); break;
+ 					}
+ 				    break;
+ 				case (5) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("RAM "); break;
+ 					case (0x01) : printf("Flash "); break;
+ 					case (0x80) : printf("'Other' "); break;
+ 					default : printf("Unknown type\n"); break;
+ 					}
+ 				    printf("Memory\n");
+ 				    break;
+ 				case (6) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("Host"); break;
+ 					case (0x01) : printf("ISA"); break;
+ 					case (0x02) : printf("EISA"); break;
+ 					case (0x03) : printf("MCA"); break;
+ 					case (0x04) : printf("PCI"); break;
+ 					case (0x05) : printf("PCMCIA"); break;
+ 					case (0x06) : printf("NUBUS"); break;
+ 					case (0x07) : printf("Cardbus"); break;
+ 					case (0x80) : printf("Other"); break;
+ 					default : printf("Unknown"); break;
+ 					}
+ 				    printf(" bridge device\n");
+ 				    break;
+ 				case (7) :
+ 				    switch  (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("UART"); break;
+ 					case (0x01) : printf("PAR"); break;
+ 					case (0x80) : printf("Other"); break;
+ 					default : printf ("Unknown"); break;
+ 					}
+ 				    printf(" simple communications device\n");
+ 				    break;
+ 				case (8) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("PIC"); break;
+ 					case (0x01) : printf("DMA"); break;
+ 					case (0x02) : printf("Timer"); break;
+ 					case (0x03) : printf("RTC"); break;
+ 					case (0x80) : printf("other"); break;
+ 					default : printf("unknown"); break;
+ 					}
+ 				     printf(" base peripheral device\n");
+ 				     break;
+ 				case (9) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("keyboard"); break;
+ 					case (0x01) : printf("digitizer"); break;
+ 					case (0x02) : printf("mouse"); break;
+ 					case (0x80) : printf("other"); break;
+ 					default : printf("unknown"); break;
+ 					}
+ 				    printf(" input device\n");
+ 				    break;
+ 				case (10) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf("generic"); break;
+ 					case (0x80) : printf("other"); break;
+ 					default : printf("unkown"); break;
+ 					}
+ 				    printf(" docking device\n");
+ 				    break;
+ 				case (11) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf ("386"); break;
+ 					case (0x01) : printf ("486"); break;
+ 					case (0x02) : printf ("Pentium"); break;
+ 					case (0x10) : printf ("Alpha"); break;
+ 					case (0x20) : printf ("PowerPC"); break;
+ 					case (0x40) : printf ("Coprocessor"); break;
+ 					default : printf ("unkown");
+ 					}
+ 				    printf(" processor device\n");
+ 				    break;
+ 				case (12) :
+ 				    switch (p->pc_subclass)
+ 					{
+ 					case (0x00) : printf ("Firewire"); break;
+ 					case (0x01) : printf ("Access"); break;
+ 					case (0x02) : printf ("SSA"); break;
+ 					case (0x03) : printf ("USB"); break;
+ 					case (0x04) : printf ("Fibrechannel"); break;
+ 					default : printf ("unkown");
+ 					}
+ 				    printf("Serial Bus device\n");
+ 				    break;
+ 				case (15) : printf ("'Other' device type\n"); break;
+ 				default : printf("Unknown device type\n"); break;
+ 				}
+ 			    printf("\n");
+ 			}
  		}
  	} while (pc.status == PCI_GETCONF_MORE_DEVS);
  	close(fd);
  }
  

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010191528.QAA34743>