From patchwork Sat Dec 26 21:11:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Baum X-Patchwork-Id: 41819 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 69AB1B7BE0 for ; Sun, 27 Dec 2009 08:45:44 +1100 (EST) Received: from localhost ([127.0.0.1]:58630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOeSD-00030F-H0 for incoming@patchwork.ozlabs.org; Sat, 26 Dec 2009 16:45:41 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NOe3D-0004Jz-O0 for qemu-devel@nongnu.org; Sat, 26 Dec 2009 16:19:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NOe35-0004Fe-Mz for qemu-devel@nongnu.org; Sat, 26 Dec 2009 16:19:48 -0500 Received: from [199.232.76.173] (port=43631 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOe34-0004FR-It for qemu-devel@nongnu.org; Sat, 26 Dec 2009 16:19:42 -0500 Received: from smarthost.c4l.co.uk ([82.197.83.77]:53801) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NOe34-0005Fb-1v for qemu-devel@nongnu.org; Sat, 26 Dec 2009 16:19:42 -0500 Received: from [93.97.162.229] (helo=mx.parenthephobia.org.uk) by smarthost.c4l.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1NOe2z-0007ui-WD for qemu-devel@nongnu.org; Sat, 26 Dec 2009 21:19:39 +0000 Received: from athens (93-97-162-231.zone5.bethere.co.uk [93.97.162.231]) by mx.parenthephobia.org.uk (Postfix) with ESMTP id 7BF385378A for ; Sat, 26 Dec 2009 21:26:54 +0000 (GMT) Received: by athens (Postfix, from userid 1000) id E45955EA96; Sat, 26 Dec 2009 21:11:41 +0000 (GMT) From: Nathan Baum To: qemu-devel@nongnu.org Date: Sat, 26 Dec 2009 21:11:32 +0000 Message-Id: <1261861899-1984-5-git-send-email-nathan@parenthephobia.org.uk> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1261861899-1984-1-git-send-email-nathan@parenthephobia.org.uk> References: <1261861899-1984-1-git-send-email-nathan@parenthephobia.org.uk> X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [RFC,PATCH 04/11] qdev: pcibus_dev_info 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 returns a QObject detailing the PCI-specific data about the device. Signed-off-by: Nathan Baum --- hw/pci.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 9722fce..8688d8a 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -27,6 +27,8 @@ #include "net.h" #include "sysemu.h" #include "loader.h" +#include "qjson.h" +#include "qint.h" //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -1585,6 +1587,52 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static QObject *pcibus_dev_info(Monitor *mon, DeviceState *dev) +{ + PCIDevice *d = (PCIDevice *)dev; + const pci_class_desc *desc; + PCIIORegion *r; + int i, class; + QObject *retval; + QList *regions; + + retval = qobject_from_jsonf("{ 'addr': { 'bus' : %d, 'slot' : %d, 'func': %d }, " + " 'device': { 'vendor': %d, 'id': %d }, " + " 'subsystem': { 'vendor': %d, 'id': %d } " + "}", + d->config[PCI_SECONDARY_BUS], + PCI_SLOT(d->devfn), + PCI_FUNC(d->devfn), + pci_get_word(d->config + PCI_VENDOR_ID), + pci_get_word(d->config + PCI_DEVICE_ID), + pci_get_word(d->config + PCI_SUBSYSTEM_VENDOR_ID), + pci_get_word(d->config + PCI_SUBSYSTEM_ID)); + class = pci_get_word(d->config + PCI_CLASS_DEVICE); + desc = pci_class_descriptions; + while (desc->desc && class != desc->class) + desc++; + if (desc->desc) { + qdict_put(qobject_to_qdict(retval), "class", qstring_from_str(desc->desc)); + } else { + qdict_put(qobject_to_qdict(retval), "class", qint_from_int(class)); + } + + regions = qlist_new(); + qdict_put(qobject_to_qdict(retval), "regions", regions); + + for (i = 0; i < PCI_NUM_REGIONS; i++) { + r = &d->io_regions[i]; + if (!r->size) + continue; + qlist_append_obj(regions, + qobject_from_jsonf("{'type':%s,'addr':%d,'size':%d}", + r->type & PCI_BASE_ADDRESS_SPACE_IO ? "i/o" : "mem", + (int) r->addr, + (int) r->size)); + } + return retval; +} + static PCIDeviceInfo bridge_info = { .qdev.name = "pci-bridge", .qdev.size = sizeof(PCIBridge),