From patchwork Sat Jan 7 00:06:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 134715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DAD5EB6F9D for ; Sat, 7 Jan 2012 11:09:03 +1100 (EST) Received: from localhost ([::1]:59987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjJqF-0008BA-PH for incoming@patchwork.ozlabs.org; Fri, 06 Jan 2012 19:09:00 -0500 Received: from eggs.gnu.org ([140.186.70.92]:36718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjJpp-0006pT-1f for qemu-devel@nongnu.org; Fri, 06 Jan 2012 19:08:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjJpm-0004g4-PS for qemu-devel@nongnu.org; Fri, 06 Jan 2012 19:08:33 -0500 Received: from mout.web.de ([212.227.15.3]:58635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjJpm-0004fj-E6; Fri, 06 Jan 2012 19:08:30 -0500 Received: from localhost.localdomain ([84.148.24.27]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0McneT-1S0iE70iZN-00HxDu; Sat, 07 Jan 2012 01:08:26 +0100 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sat, 7 Jan 2012 01:06:47 +0100 Message-Id: <1325894809-17322-2-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1325894809-17322-1-git-send-email-andreas.faerber@web.de> References: <1325894809-17322-1-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 X-Provags-ID: V02:K0:6iMvimr/A0K/IRBegh0fd+kBAfQPOcgSXCBVGyw/iiE BpYc1UVHHzXu6bILgucyvFaAghJxkuUnhyulzoVgSJYB/Nntew tJGlaGUcMi9rT52xl8OB3g+1C6kwL9Xi97jyXfoAI7HWuLFrHc HqFQPMH8OHzl/OfpsK1gE5RWH3rGZKdtiE2p2/F4pC7z0rUv40 581UR3t8fmGHg5xrgzDFg== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.15.3 Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-ppc@nongnu.org, Anthony Liguori , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v2 1/3] prep: qdev'ify Raven host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move initialization of vendor ID, etc. to PCIDeviceInfo. Add VMState. Signed-off-by: Andreas Färber Cc: Hervé Poussineau Cc: Michael S. Tsirkin Cc: Anthony Liguori --- hw/prep_pci.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-) diff --git a/hw/prep_pci.c b/hw/prep_pci.c index ea9fb69..741b273 100644 --- a/hw/prep_pci.c +++ b/hw/prep_pci.c @@ -29,6 +29,10 @@ typedef PCIHostState PREPPCIState; +typedef struct RavenPCIState { + PCIDevice dev; +} RavenPCIState; + static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr) { int i; @@ -111,7 +115,6 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_io) { PREPPCIState *s; - PCIDevice *d; s = g_malloc0(sizeof(PREPPCIState)); s->bus = pci_register_bus(NULL, "pci", @@ -133,16 +136,50 @@ PCIBus *pci_prep_init(qemu_irq *pic, memory_region_init_io(&s->mmcfg, &PPC_PCIIO_ops, s, "pciio", 0x00400000); memory_region_add_subregion(address_space_mem, 0x80800000, &s->mmcfg); - /* PCI host bridge */ - d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven", - sizeof(PCIDevice), 0, NULL, NULL); - pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); - pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); - d->config[0x08] = 0x00; // revision - pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); + pci_create_simple(s->bus, 0, "raven"); + + return s->bus; +} + +static int raven_init(PCIDevice *d) +{ d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x34] = 0x00; // capabilities_pointer - return s->bus; + return 0; } + +static const VMStateDescription vmstate_raven = { + .name = "raven", + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_PCI_DEVICE(dev, RavenPCIState), + VMSTATE_END_OF_LIST() + }, +}; + +static PCIDeviceInfo raven_info = { + .qdev.name = "raven", + .qdev.desc = "PReP Host Bridge - Motorola Raven", + .qdev.size = sizeof(RavenPCIState), + .qdev.vmsd = &vmstate_raven, + .qdev.no_user = 1, + .no_hotplug = 1, + .init = raven_init, + .vendor_id = PCI_VENDOR_ID_MOTOROLA, + .device_id = PCI_DEVICE_ID_MOTOROLA_RAVEN, + .revision = 0x00, + .class_id = PCI_CLASS_BRIDGE_HOST, + .qdev.props = (Property[]) { + DEFINE_PROP_END_OF_LIST() + }, +}; + +static void raven_register_devices(void) +{ + pci_qdev_register(&raven_info); +} + +device_init(raven_register_devices)