From patchwork Sat Aug 28 15:02:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 62915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4E863B711B for ; Sun, 29 Aug 2010 01:39:58 +1000 (EST) Received: from localhost ([127.0.0.1]:56767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OpN6O-0007De-MI for incoming@patchwork.ozlabs.org; Sat, 28 Aug 2010 11:13:52 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=CC4ylKgZBmWJsx+pjB5/AImlZ6IwMBYtjofqVhUQ2DE=; b=e0ZvYqLJBAmClCHRrzF+VJvbQO3/70Oc3NjT4WBLBVyQBBfHT/XRn6eoz9uwpbxYwg /TbgcMHOnNvdyPVO0cZQPSzOgURr4HAKh2A/ZGGlgUtkcowhJFUgj1D6LtWBc5jR6FDF yEJgBn/h/vklzShotEgGK4v6/ryfexz0QRE4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=Nf+gOc0E0iqZUasmR785zTA8z8ZS4GB93ynb5WXL3ZJQl60vb+sZP0XpFOvZZUKdLy HLPvfA7Vsq/9PISL1syi+H+/+13ufEW6+jTFSVkEhUfDKcL4VvkEMXCboAi4ND6WvJmP 36IXvpZskob0hRZsvWe3WKBy8OMykzXKiPck8= Received: by 10.204.68.10 with SMTP id t10mr1531032bki.77.1283007881142; Sat, 28 Aug 2010 08:04:41 -0700 (PDT) Received: from localhost ([188.25.93.165]) by mx.google.com with ESMTPS id y2sm3516665bkx.20.2010.08.28.08.04.40 (version=SSLv3 cipher=RC4-MD5); Sat, 28 Aug 2010 08:04:40 -0700 (PDT) From: Eduard - Gabriel Munteanu To: seabios@seabios.org Date: Sat, 28 Aug 2010 18:02:56 +0300 Message-Id: <1283007778-11012-2-git-send-email-eduard.munteanu@linux360.ro> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1283007778-11012-1-git-send-email-eduard.munteanu@linux360.ro> References: <1283007778-11012-1-git-send-email-eduard.munteanu@linux360.ro> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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 Subject: [Qemu-devel] [PATCH 2/4] pci: add foreachcap() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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, \