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: 139871 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o7SF4tUY025963 for ; Sat, 28 Aug 2010 15:04:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752098Ab0H1PEo (ORCPT ); Sat, 28 Aug 2010 11:04:44 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:34314 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812Ab0H1PEn (ORCPT ); Sat, 28 Aug 2010 11:04:43 -0400 Received: by bwz11 with SMTP id 11so2655339bwz.19 for ; Sat, 28 Aug 2010 08:04:42 -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 Cc: mst@redhat.com, kevin@koconnor.net, joro@8bytes.org, blauwirbel@gmail.com, paul@codesourcery.com, avi@redhat.com, anthony@codemonkey.ws, av1474@comtv.ru, yamahata@valinux.co.jp, kvm@vger.kernel.org, qemu-devel@nongnu.org, Eduard - Gabriel Munteanu Subject: [PATCH 2/4] pci: add foreachcap() helper 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 28 Aug 2010 15:04:56 +0000 (UTC) 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, \