From 826609c33ca9ae4b051b3fe109df473be3f166c4 Mon Sep 17 00:00:00 2001 From: Mike Larkin Date: Sat, 25 Mar 2017 07:33:47 +0000 Subject: More PCI extended capabilities handling in pcidump. From Simon Mages ok deraadt@ --- sys/dev/pci/pcireg.h | 4 ++-- usr.sbin/pcidump/pcidump.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h index 9676ad44a2d..ab53be0dce2 100644 --- a/sys/dev/pci/pcireg.h +++ b/sys/dev/pci/pcireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcireg.h,v 1.52 2017/03/22 07:21:39 jsg Exp $ */ +/* $OpenBSD: pcireg.h,v 1.53 2017/03/25 07:33:46 mlarkin Exp $ */ /* $NetBSD: pcireg.h,v 1.26 2000/05/10 16:58:42 thorpej Exp $ */ /* @@ -606,7 +606,7 @@ typedef u_int8_t pci_revision_t; #define PCI_PCIE_ECAP 0x100 #define PCI_PCIE_ECAP_ID(x) (((x) & 0x0000ffff)) #define PCI_PCIE_ECAP_VER(x) (((x) >> 16) & 0x0f) -#define PCI_PCIE_ECAP_NEXT(x) ((x) >> 20) +#define PCI_PCIE_ECAP_NEXT(x) (((x) >> 20) & 0xffc) #define PCI_PCIE_ECAP_LAST 0x0 /* diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 73d9e7c24e9..2acd7b209df 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.42 2017/03/16 22:05:46 deraadt Exp $ */ +/* $OpenBSD: pcidump.c,v 1.43 2017/03/25 07:33:46 mlarkin Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne @@ -392,6 +392,7 @@ void dump_pcie_enhanced_caplist(int bus, int dev, int func) { u_int32_t reg; + u_int32_t capidx; u_int16_t ptr; u_int16_t ecap; @@ -407,10 +408,12 @@ dump_pcie_enhanced_caplist(int bus, int dev, int func) ecap = PCI_PCIE_ECAP_ID(reg); if (ecap >= nitems(pci_enhanced_capnames)) - ecap = 0; + capidx = 0; + else + capidx = ecap; printf("\t0x%04x: Enhanced Capability 0x%02x: ", ptr, ecap); - printf("%s\n", pci_enhanced_capnames[ecap]); + printf("%s\n", pci_enhanced_capnames[capidx]); ptr = PCI_PCIE_ECAP_NEXT(reg); -- cgit v1.2.3