From patchwork Thu Feb 3 23:24:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 530781 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 p13NOhpH004558 for ; Thu, 3 Feb 2011 23:24:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754422Ab1BCXYh (ORCPT ); Thu, 3 Feb 2011 18:24:37 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:43469 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754378Ab1BCXYg (ORCPT ); Thu, 3 Feb 2011 18:24:36 -0500 Received: by mail-fx0-f46.google.com with SMTP id 20so1796535fxm.19 for ; Thu, 03 Feb 2011 15:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references:in-reply-to:references; bh=XAIMot6ML1aBrMvGUHYSnZIBXrYAafAOBsGoN2cgXG0=; b=SEMUbMfex16v1Z/sMnh6zXvTn+hqsgyifPdLtnd8gsxWnL7v4/GKOCU3CtNCD0+Ezr c7hmx4B+vaCaE3TyhSyPRkolZZkvlJ9vdGzWjbyBwtYUpuCETol9m2uWK5+Up1sqYzTe lnhh+pL7WuXpr3xq8P8IbgU9RemRHNzwYS098= 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=ZJHRxMtD95wdl7+BE+oOaD509UleMQRTlETKdCapLSj8iKQezzBWvwP/Ebb1+SG3LF grqO57Q1adnbBHAdFcnbYECUGf5PV5hNDb9qUDvGDGTt7WcUMGGOvVl+2nS+StuH43uV SLO+Uqz+oTvj9WYdFi5uz5T08N3FLRQYl0dA4= Received: by 10.223.112.79 with SMTP id v15mr10627830fap.143.1296775475936; Thu, 03 Feb 2011 15:24:35 -0800 (PST) Received: from localhost.localdomain ([188.25.245.29]) by mx.google.com with ESMTPS id b7sm15819faa.42.2011.02.03.15.24.32 (version=SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 15:24:33 -0800 (PST) From: Eduard - Gabriel Munteanu To: seabios@seabios.org Cc: kevin@koconnor.net, mst@redhat.com, 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 1/3] pci: add pci_find_capability() helper Date: Fri, 4 Feb 2011 01:24:13 +0200 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 23:24:44 +0000 (UTC) diff --git a/src/pci.c b/src/pci.c index 944a393..57caba6 100644 --- a/src/pci.c +++ b/src/pci.c @@ -185,6 +185,21 @@ pci_find_class(u16 classid) return -1; } +int pci_find_capability(int bdf, u8 capid) +{ + int ptr, cap; + + ptr = PCI_CAPABILITY_LIST; + do { + cap = pci_config_readb(bdf, ptr); + if (pci_config_readb(bdf, cap) == capid) + return cap; + ptr = cap + PCI_CAP_LIST_NEXT; + } while (cap); + + return -1; +} + int *PCIpaths; // Build the PCI path designations. diff --git a/src/pci.h b/src/pci.h index 9869a26..bf0d1b8 100644 --- a/src/pci.h +++ b/src/pci.h @@ -46,6 +46,7 @@ void pci_config_maskw(u16 bdf, u32 addr, u16 off, u16 on); int pci_find_vga(void); int pci_find_device(u16 vendid, u16 devid); int pci_find_class(u16 classid); +int pci_find_capability(int bdf, u8 capid); #define PP_ROOT (1<<17) #define PP_PCIBRIDGE (1<<18)