From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39360 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OpMxd-0004Qx-8G for qemu-devel@nongnu.org; Sat, 28 Aug 2010 11:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OpMxW-0001Uu-61 for qemu-devel@nongnu.org; Sat, 28 Aug 2010 11:04:43 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:58651) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OpMxW-0001Uo-1a for qemu-devel@nongnu.org; Sat, 28 Aug 2010 11:04:42 -0400 Received: by bwz3 with SMTP id 3so2805290bwz.4 for ; Sat, 28 Aug 2010 08:04:41 -0700 (PDT) Sender: Eduard - Gabriel Munteanu From: Eduard - Gabriel Munteanu Date: Sat, 28 Aug 2010 18:02:56 +0300 Message-Id: <1283007778-11012-2-git-send-email-eduard.munteanu@linux360.ro> In-Reply-To: <1283007778-11012-1-git-send-email-eduard.munteanu@linux360.ro> References: <1283007778-11012-1-git-send-email-eduard.munteanu@linux360.ro> Subject: [Qemu-devel] [PATCH 2/4] pci: add foreachcap() helper List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: seabios@seabios.org Cc: kvm@vger.kernel.org, mst@redhat.com, joro@8bytes.org, qemu-devel@nongnu.org, blauwirbel@gmail.com, yamahata@valinux.co.jp, kevin@koconnor.net, avi@redhat.com, Eduard - Gabriel Munteanu , paul@codesourcery.com This iterates over capabilities exposed by PCI devices. It's needed by IOMMU initialization code to discover the Secure Device capability. Signed-off-by: Eduard - Gabriel Munteanu --- src/pci.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/pci.h b/src/pci.h index 9c3108c..60e0359 100644 --- a/src/pci.h +++ b/src/pci.h @@ -2,6 +2,7 @@ #define __PCI_H #include "types.h" // u32 +#include "pci_regs.h" // PCI_CAPABILITY_LIST et al. static inline u8 pci_bdf_to_bus(u16 bdf) { return bdf >> 8; @@ -52,6 +53,10 @@ int pci_next(int bdf, int *pmax); for (MAX=0x0100, BDF=pci_next(0, &MAX) \ ; BDF >= 0 \ ; BDF=pci_next(BDF+1, &MAX)) +#define foreachcap(BDF, PTR, CAP) \ + for (PTR = PCI_CAPABILITY_LIST, CAP = pci_config_readb(BDF, PTR); \ + CAP; \ + PTR = CAP + PCI_CAP_LIST_NEXT, CAP = pci_config_readb(BDF, PTR)) #define foreachpci_in_bus(BDF, MAX, BUS) \ for (MAX = pci_bus_devfn_to_bdf(BUS, 0) + 0x0100, \ -- 1.7.1