From cf3c8ce0b9dd304a4b94699a0b53e292cd03aa76 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 28 Jul 2018 15:28:51 +0000 Subject: [PATCH] Add function to convert a PCI device "tag" into a PCIe requester ID. ok patrick@, mlarkin@, deraadt@ --- sys/dev/pci/pci.c | 11 ++++++++++- sys/dev/pci/pcivar.h | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e7ebc08d9bd..1ece6e3526d 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.111 2015/11/27 15:28:22 kettenis Exp $ */ +/* $OpenBSD: pci.c,v 1.112 2018/07/28 15:28:51 kettenis Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -659,6 +659,15 @@ pci_get_ht_capability(pci_chipset_tag_t pc, pcitag_t tag, int capid, return (0); } +uint16_t +pci_requester_id(pci_chipset_tag_t pc, pcitag_t tag) +{ + int bus, dev, func; + + pci_decompose_tag(pc, tag, &bus, &dev, &func); + return ((bus << 8) | (dev << 3) | func); +} + int pci_find_device(struct pci_attach_args *pa, int (*match)(struct pci_attach_args *)) diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index fcd72371075..a0858204b77 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcivar.h,v 1.69 2013/08/08 17:54:11 kettenis Exp $ */ +/* $OpenBSD: pcivar.h,v 1.70 2018/07/28 15:28:51 kettenis Exp $ */ /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -226,7 +226,6 @@ int pci_mapreg_map(struct pci_attach_args *, int, pcireg_t, int, bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *, bus_size_t *, bus_size_t); - int pci_io_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *, bus_size_t *); int pci_mem_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *, @@ -237,6 +236,8 @@ int pci_get_capability(pci_chipset_tag_t, pcitag_t, int, int pci_get_ht_capability(pci_chipset_tag_t, pcitag_t, int, int *, pcireg_t *); +uint16_t pci_requester_id(pci_chipset_tag_t, pcitag_t); + struct pci_matchid { pci_vendor_id_t pm_vid; pci_product_id_t pm_pid; -- 2.20.1