From patchwork Wed Dec 16 14:15:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 41269 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 75D02B6F09 for ; Thu, 17 Dec 2009 01:43:08 +1100 (EST) Received: from localhost ([127.0.0.1]:57443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKv5l-00066f-FC for incoming@patchwork.ozlabs.org; Wed, 16 Dec 2009 09:43:05 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKufe-00078n-LD for qemu-devel@nongnu.org; Wed, 16 Dec 2009 09:16:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKufZ-00076L-Kt for qemu-devel@nongnu.org; Wed, 16 Dec 2009 09:16:05 -0500 Received: from [199.232.76.173] (port=59611 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKufY-000763-Qc for qemu-devel@nongnu.org; Wed, 16 Dec 2009 09:16:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64937) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKufW-0000zw-A7 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 09:15:59 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBGEFv55029939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Dec 2009 09:15:57 -0500 Received: from zweiblum.home.kraxel.org (vpn2-9-244.ams2.redhat.com [10.36.9.244]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBGEFpnM017474; Wed, 16 Dec 2009 09:15:52 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id A695B70FCE; Wed, 16 Dec 2009 15:15:50 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 16 Dec 2009 15:15:50 +0100 Message-Id: <1260972950-31543-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1260972950-31543-1-git-send-email-kraxel@redhat.com> References: <1260972950-31543-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 4/4] pci: specify default romfile in PCIDeviceInfo. 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 Signed-off-by: Gerd Hoffmann --- hw/cirrus_vga.c | 6 +----- hw/e1000.c | 5 +---- hw/pci.c | 17 +++++++++++------ hw/pci.h | 5 ++++- hw/rtl8139.c | 5 +---- hw/virtio-pci.c | 5 +---- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index b2886c4..6fe433d 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -3209,11 +3209,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev) pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE, PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map); } - - /* ROM BIOS */ - if (dev->rom_filename == NULL) { - dev->rom_filename = qemu_strdup(VGABIOS_CIRRUS_FILENAME); - } return 0; } @@ -3228,6 +3223,7 @@ static PCIDeviceInfo cirrus_vga_info = { .qdev.size = sizeof(PCICirrusVGAState), .qdev.vmsd = &vmstate_pci_cirrus_vga, .init = pci_cirrus_vga_initfn, + .romfile = VGABIOS_CIRRUS_FILENAME, .config_write = pci_cirrus_write_config, }; diff --git a/hw/e1000.c b/hw/e1000.c index 021f666..33c4bc6 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1121,10 +1121,6 @@ static int pci_e1000_init(PCIDevice *pci_dev) d->dev.qdev.info->name, d->dev.qdev.id, d); qemu_format_nic_info_str(&d->nic->nc, macaddr); - - if (pci_dev->rom_filename == NULL) { - pci_dev->rom_filename = qemu_strdup("pxe-e1000.bin"); - } return 0; } @@ -1142,6 +1138,7 @@ static PCIDeviceInfo e1000_info = { .qdev.vmsd = &vmstate_e1000, .init = pci_e1000_init, .exit = pci_e1000_uninit, + .romfile = "pxe-e1000.bin", .qdev.props = (Property[]) { DEFINE_NIC_PROPERTIES(E1000State, conf), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/pci.c b/hw/pci.c index 3ff7d0c..d54f05e 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -63,7 +63,7 @@ static struct BusInfo pci_bus_info = { .print_dev = pcibus_dev_print, .props = (Property[]) { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), - DEFINE_PROP_STRING("romfile", PCIDevice, rom_filename), + DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_END_OF_LIST() } }; @@ -1389,7 +1389,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) rc = info->init(pci_dev); if (rc != 0) return rc; + + /* rom loading */ + if (pci_dev->romfile == NULL && info->romfile != NULL) + pci_dev->romfile = qemu_strdup(info->romfile); pci_add_option_rom(pci_dev); + if (qdev->hotplugged) bus->hotplug(pci_dev, 1); return 0; @@ -1479,20 +1484,20 @@ static int pci_add_option_rom(PCIDevice *pdev) char *path; void *ptr; - if (!pdev->rom_filename) + if (!pdev->romfile) return 0; - if (strlen(pdev->rom_filename) == 0) + if (strlen(pdev->romfile) == 0) return 0; - path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->rom_filename); + path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile); if (path == NULL) { - path = qemu_strdup(pdev->rom_filename); + path = qemu_strdup(pdev->romfile); } size = get_image_size(path); if (size < 0) { qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__, - pdev->rom_filename); + pdev->romfile); return -1; } if (size & (size - 1)) { diff --git a/hw/pci.h b/hw/pci.h index c27e800..39da7df 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -245,7 +245,7 @@ struct PCIDevice { int32_t version_id; /* Location of option rom */ - char *rom_filename; + char *romfile; ram_addr_t rom_offset; }; @@ -385,6 +385,9 @@ typedef struct { /* pcie stuff */ int is_express; /* is this device pci express? */ + + /* rom bar */ + const char *romfile; } PCIDeviceInfo; void pci_qdev_register(PCIDeviceInfo *info); diff --git a/hw/rtl8139.c b/hw/rtl8139.c index d096711..fcdcd1d 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -3353,10 +3353,6 @@ static int pci_rtl8139_init(PCIDevice *dev) qemu_mod_timer(s->timer, rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock))); #endif /* RTL8139_ONBOARD_TIMER */ - - if (dev->rom_filename == NULL) { - dev->rom_filename = qemu_strdup("pxe-rtl8139.bin"); - } return 0; } @@ -3367,6 +3363,7 @@ static PCIDeviceInfo rtl8139_info = { .qdev.vmsd = &vmstate_rtl8139, .init = pci_rtl8139_init, .exit = pci_rtl8139_uninit, + .romfile = "pxe-rtl8139.bin", .qdev.props = (Property[]) { DEFINE_NIC_PROPERTIES(RTL8139State, conf), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index e38fe70..62b46bd 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -518,10 +518,6 @@ static int virtio_net_init_pci(PCIDevice *pci_dev) /* make the actual value visible */ proxy->nvectors = vdev->nvectors; - - if (pci_dev->rom_filename == NULL) { - pci_dev->rom_filename = qemu_strdup("pxe-virtio.bin"); - } return 0; } @@ -565,6 +561,7 @@ static PCIDeviceInfo virtio_info[] = { .qdev.size = sizeof(VirtIOPCIProxy), .init = virtio_net_init_pci, .exit = virtio_net_exit_pci, + .romfile = "pxe-virtio.bin", .qdev.props = (Property[]) { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3), DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),