diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-12-19 23:06:11 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-12-19 23:06:11 +0000 |
commit | 79fdfffd08f40e4033383bddd7ae721765e4b25f (patch) | |
tree | 2048df11352ea28c0e8c2de66e3d1a93e0361a28 /usr.sbin/pcidump/pcidump.c | |
parent | 800292242d3df928fc9ef7c737d4ff560246df27 (diff) |
Add -xxx option that print PCIe extended config space.
ok mikeb@, deraadt@
Diffstat (limited to 'usr.sbin/pcidump/pcidump.c')
-rw-r--r-- | usr.sbin/pcidump/pcidump.c | 23 |
1 files changed, 16 insertions, 7 deletions
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, ®) != 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, ®) != 0) - warn("unable to read 0x%02x", i); printf(" %08x", reg); if ((i % 16) == 12) |