From patchwork Tue Jan 5 20:34:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42228 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 A8E0CB6EEE for ; Wed, 6 Jan 2010 10:46:34 +1100 (EST) Received: from localhost ([127.0.0.1]:55054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSJ6L-0004VN-E7 for incoming@patchwork.ozlabs.org; Tue, 05 Jan 2010 18:46:13 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSG7f-0005JX-O7 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSG7a-0005Cs-FX for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:22 -0500 Received: from [199.232.76.173] (port=50769 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSG7a-0005CQ-4q for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37983) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSG7Z-0003Mu-Hz for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:17 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o05KZGo8032381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jan 2010 15:35:16 -0500 Received: from localhost (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o05KZF89010862; Tue, 5 Jan 2010 15:35:15 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 5 Jan 2010 18:34:58 -0200 Message-Id: <1262723698-23658-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1262723698-23658-1-git-send-email-lcapitulino@redhat.com> References: <1262723698-23658-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 5/5] PCI: do_pci_info(): PCI bridge devices support 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 commit completes the do_pci_info() conversion to QObject by adding support to PCI bridge devices. This is done by recursively adding devices in the "pci_bridge" key. This code is being added separately because I could not test it properly. According to Michael Tsirkin, it depends on ultrasparc and it would take time to do the proper setup. Signed-off-by: Luiz Capitulino --- hw/pci.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 4db392d..f38176c 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1159,7 +1159,14 @@ static void pci_device_print(Monitor *mon, QDict *device) monitor_printf(mon, " id \"%s\"\n", qdict_get_str(device, "qdev_id")); - /* TODO: PCI bridge devices */ + if (qdict_haskey(device, "pci_bridge")) { + QListEntry *dev; + + qdict = qdict_get_qdict(device, "pci_bridge"); + QLIST_FOREACH_ENTRY(qdict_get_qlist(qdict, "devices"), dev) { + pci_device_print(mon, qobject_to_qdict(qlist_entry_obj(dev))); + } + } } void do_pci_info_print(Monitor *mon, const QObject *data) @@ -1233,7 +1240,9 @@ static QObject *pci_get_regions_list(const PCIDevice *dev) return QOBJECT(regions_list); } -static QObject *pci_get_dev_dict(PCIDevice *dev, int bus_num) +static QObject *pci_get_devices_list(PCIBus *bus, int bus_num); + +static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num) { int class; QObject *obj; @@ -1272,6 +1281,12 @@ static QObject *pci_get_dev_dict(PCIDevice *dev, int bus_num) pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH)); + if (dev->config[0x19] != 0) { + qdict = qobject_to_qdict(pci_bridge); + qdict_put_obj(qdict, "devices", + pci_get_devices_list(bus, dev->config[0x19])); + } + qdict = qobject_to_qdict(obj); qdict_put_obj(qdict, "pci_bridge", pci_bridge); } @@ -1290,7 +1305,7 @@ static QObject *pci_get_devices_list(PCIBus *bus, int bus_num) for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) { dev = bus->devices[devfn]; if (dev) { - qlist_append_obj(dev_list, pci_get_dev_dict(dev, bus_num)); + qlist_append_obj(dev_list, pci_get_dev_dict(dev, bus, bus_num)); } } @@ -1342,6 +1357,7 @@ static QObject *pci_get_bus_dict(PCIBus *bus, int bus_num) * - "io_range": a QDict with memory range information * - "memory_range": a QDict with memory range information * - "prefetchable_range": a QDict with memory range information + * - "devices": a QList of PCI devices if there's any attached * - "regions": a QList of QDicts, each QDict represents a * memory region of this device *