summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-12-19 23:06:11 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-12-19 23:06:11 +0000
commit79fdfffd08f40e4033383bddd7ae721765e4b25f (patch)
tree2048df11352ea28c0e8c2de66e3d1a93e0361a28
parent800292242d3df928fc9ef7c737d4ff560246df27 (diff)
Add -xxx option that print PCIe extended config space.
ok mikeb@, deraadt@
-rw-r--r--usr.sbin/pcidump/pcidump.88
-rw-r--r--usr.sbin/pcidump/pcidump.c23
2 files changed, 21 insertions, 10 deletions
diff --git a/usr.sbin/pcidump/pcidump.8 b/usr.sbin/pcidump/pcidump.8
index 43602753824..b8a83ece8fb 100644
--- a/usr.sbin/pcidump/pcidump.8
+++ b/usr.sbin/pcidump/pcidump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pcidump.8,v 1.10 2010/03/22 21:53:42 weerd Exp $
+.\" $OpenBSD: pcidump.8,v 1.11 2010/12/19 23:06:10 kettenis Exp $
.\"
.\" Copyright (c) 2007 Paul de Weerd <weerd@weirdnet.nl>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 22 2010 $
+.Dd $Mdocdate: December 19 2010 $
.Dt PCIDUMP 8
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm pcidump
.Op Fl v
-.Op Fl x | xx
+.Op Fl x | xx | xxx
.Op Fl d Ar pcidev
.Sm off
.Op Ar bus : dev : func
@@ -65,6 +65,8 @@ Shows detailed information about PCI devices.
Shows a hexadecimal dump of the first 64 bytes of PCI config space.
.It Fl xx
Shows a hexadecimal dump of the full PCI config space.
+.It Fl xxx
+Shows a hexadecimal dump of the PCIe extended config space.
.It Xo
.Sm off
.Ar bus : dev : func
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c
index 942e86d5c8b..654048db3b5 100644
--- a/usr.sbin/pcidump/pcidump.c
+++ b/usr.sbin/pcidump/pcidump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcidump.c,v 1.24 2010/09/05 18:14:33 kettenis Exp $ */
+/* $OpenBSD: pcidump.c,v 1.25 2010/12/19 23:06:10 kettenis Exp $ */
/*
* Copyright (c) 2006, 2007 David Gwynne <loki@animata.net>
@@ -66,6 +66,7 @@ int pcifd;
int romfd;
int verbose = 0;
int hex = 0;
+int size = 64;
const char *pci_capnames[] = {
"Reserved",
@@ -131,6 +132,11 @@ main(int argc, char *argv[])
err(1, "%s", romfile);
}
+ if (hex > 1)
+ size = 256;
+ if (hex > 2)
+ size = 4096;
+
if (argc == 1)
dumpall = 0;
@@ -263,7 +269,7 @@ probe(int bus, int dev, int func)
if (verbose)
dump(bus, dev, func);
if (hex > 0)
- hexdump(bus, dev, func, hex > 1);
+ hexdump(bus, dev, func, size);
return (0);
}
@@ -616,17 +622,20 @@ dump(int bus, int dev, int func)
}
void
-hexdump(int bus, int dev, int func, int full)
+hexdump(int bus, int dev, int func, int size)
{
u_int32_t reg;
int i;
- for (i = 0; i < (full ? 256 : 64); i += 4) {
+ for (i = 0; i < size; i += 4) {
+ if (pci_read(bus, dev, func, i, &reg) != 0) {
+ if (errno == EINVAL)
+ return;
+ warn("unable to read 0x%02x", i);
+ }
+
if ((i % 16) == 0)
printf("\t0x%04x:", i);
-
- if (pci_read(bus, dev, func, i, &reg) != 0)
- warn("unable to read 0x%02x", i);
printf(" %08x", reg);
if ((i % 16) == 12)