diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2019-06-02 02:37:13 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2019-06-02 02:37:13 +0000 |
commit | b0f2e9ed64ba7dfc5a876db38f69aaaefd4a3a0f (patch) | |
tree | 1134e48753d388ac56464f31a3023547ba9465d1 /usr.sbin | |
parent | 4a80a8ec4a5d6d7d4690398d18ba3e11a49f0d8d (diff) |
dump pcie Device Serial Number capability values
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pcidump/pcidump.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 5227ba2338d..7f4a47fabf7 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.53 2019/04/02 07:01:29 jmatthew Exp $ */ +/* $OpenBSD: pcidump.c,v 1.54 2019/06/02 02:37:12 dlg Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne <loki@animata.net> @@ -54,6 +54,7 @@ void dump_bars(int, int, int, int); void dump_caplist(int, int, int, u_int8_t); void dump_pci_powerstate(int, int, int, uint8_t); void dump_pcie_linkspeed(int, int, int, uint8_t); +void dump_pcie_devserial(int, int, int, uint16_t); void dump_msi(int, int, int, uint8_t); void dump_msix(int, int, int, uint8_t); void print_pcie_ls(uint8_t); @@ -400,6 +401,21 @@ dump_pcie_linkspeed(int bus, int dev, int func, uint8_t ptr) } void +dump_pcie_devserial(int bus, int dev, int func, u_int16_t ptr) +{ + uint32_t lower, upper; + uint64_t serial; + + if ((pci_read(bus, dev, func, ptr + 8, &upper) != 0) || + (pci_read(bus, dev, func, ptr + 4, &lower) != 0)) + return; + + serial = ((uint64_t)upper << 32) | (uint64_t)lower; + + printf("\t\tSerial Number: %016llx\n", serial); +} + +void dump_msi(int bus, int dev, int func, u_int8_t ptr) { u_int32_t reg; @@ -454,6 +470,12 @@ dump_pcie_enhanced_caplist(int bus, int dev, int func) printf("\t0x%04x: Enhanced Capability 0x%02x: ", ptr, ecap); printf("%s\n", pci_enhanced_capnames[capidx]); + switch (ecap) { + case 0x03: + dump_pcie_devserial(bus, dev, func, ptr); + break; + } + ptr = PCI_PCIE_ECAP_NEXT(reg); } while (ptr != PCI_PCIE_ECAP_LAST); |