diff options
author | kettenis <kettenis@openbsd.org> | 2010-12-19 23:06:10 +0000 |
---|---|---|
committer | kettenis <kettenis@openbsd.org> | 2010-12-19 23:06:10 +0000 |
commit | 5d2ed882d6ac165e067b9ed24dde07776522c07c (patch) | |
tree | a601afe2cec5fdf339acf3bb8dc9d7565091b6e5 /usr.sbin/pcidump/pcidump.c | |
parent | Don't nuke the index counter when a session group comes up. (diff) | |
download | wireguard-openbsd-5d2ed882d6ac165e067b9ed24dde07776522c07c.tar.xz wireguard-openbsd-5d2ed882d6ac165e067b9ed24dde07776522c07c.zip |
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) |