Add "list -n" to print ID and class numerical, instead of resolving to strings:

miyu% pcictl /dev/pci1 list
	001:00:0: ATI Technologies Rage Fury MAXX AGP 4x (TMDS) (VGA display)
	miyu% pcictl /dev/pci1 list -n
	001:00:0: 0x50461002 (0x3000000)

OK'd by thorpej@
This commit is contained in:
hubertf 2006-10-01 00:13:27 +00:00
parent b850659285
commit fe81bd2f72
3 changed files with 24 additions and 10 deletions

View File

@ -1,4 +1,4 @@
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.716 $>
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.717 $>
[Note: This file does not mention every change made to the NetBSD source tree.
@ -93,3 +93,5 @@ Changes from NetBSD 4.0 to NetBSD 5.0:
ofctl(8): initial import, formerly known as ofdump2. For macppc,
shark, sparc64.
Written by Matt Thomas. [macallan 20060929]
pcictl(8): Add "list -n" to print ID and class numerical, instead
of resolving to strings [hubertf 20061001]

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pcictl.8,v 1.3 2003/08/18 16:12:58 yyamano Exp $
.\" $NetBSD: pcictl.8,v 1.4 2006/10/01 00:13:28 hubertf Exp $
.\"
.\" Copyright 2001 Wasabi Systems, Inc.
.\" All rights reserved.
@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 12, 2001
.Dd October 1, 2006
.Os
.Dt PCICTL 8
.Sh NAME
@ -55,11 +55,15 @@ on a PCI bus.
The following commands are available:
.Pp
.Nm list
.Op Fl n
.Op Fl b Ar bus
.Op Fl d Ar device
.Op Fl f Ar function
.Pp
List the devices in the PCI domain. The bus, device, and function
List the devices in the PCI domain, either as names or if
.Fl n
is given as numbers.
The bus, device, and function
numbers may be specified by flags. If the bus is not
specified, it defaults to the bus number of the PCI bus specified
on the command line. Any other locator not specified defaults

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcictl.c,v 1.9 2006/08/24 07:30:16 bsh Exp $ */
/* $NetBSD: pcictl.c,v 1.10 2006/10/01 00:13:28 hubertf Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -74,13 +74,14 @@ const char *dvname;
char dvname_store[MAXPATHLEN];
const char *cmdname;
const char *argnames;
int print_numbers = 0;
void cmd_list(int, char *[]);
void cmd_dump(int, char *[]);
const struct command commands[] = {
{ "list",
"[-b bus] [-d device] [-f function]",
"[-n] [-b bus] [-d device] [-f function]",
cmd_list,
O_RDONLY },
@ -165,7 +166,7 @@ cmd_list(int argc, char *argv[])
bus = pci_businfo.busno;
dev = func = -1;
while ((ch = getopt(argc, argv, "b:d:f:")) != -1) {
while ((ch = getopt(argc, argv, "nb:d:f:")) != -1) {
switch (ch) {
case 'b':
bus = parse_bdf(optarg);
@ -176,6 +177,9 @@ cmd_list(int argc, char *argv[])
case 'f':
func = parse_bdf(optarg);
break;
case 'n':
print_numbers = 1;
break;
default:
usage();
}
@ -316,9 +320,13 @@ scan_pci_list(u_int bus, u_int dev, u_int func)
if (pcibus_conf_read(pcifd, bus, dev, func, PCI_CLASS_REG, &class) != 0)
return;
printf("%03u:%02u:%01u: ", bus, dev, func);
if (print_numbers) {
printf("0x%x (0x%x)\n", id, class);
} else {
pci_devinfo(id, class, 1, devinfo, sizeof(devinfo));
printf("%03u:%02u:%01u: %s\n", bus, dev, func, devinfo);
printf("%s\n", devinfo);
}
}
void