From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTFmm-0003IF-LT for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTFmh-0003El-Vf for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:55 -0500 Received: from [199.232.76.173] (port=43426 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTFmh-0003Eb-P6 for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60052) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTFmg-0006Kp-Sv for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:51 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08EPnj0027262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Jan 2010 09:25:50 -0500 From: Gerd Hoffmann Date: Fri, 8 Jan 2010 15:25:41 +0100 Message-Id: <1262960742-18267-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1262960742-18267-1-git-send-email-kraxel@redhat.com> References: <1262960742-18267-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 5/6] pci: allow loading roms via fw_cfg. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann This patch adds a pci bus property 'rombar' which specifies whenever the pci rom should be loaded via pci rom bar (default) or via fw_cfg. The later can be used for compatibility with older qemu versions where no pci rom bar is present. Signed-off-by: Gerd Hoffmann --- hw/pci.c | 15 +++++++++++++++ hw/pci.h | 1 + 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 0814383..c584dba 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -65,6 +65,7 @@ static struct BusInfo pci_bus_info = { .props = (Property[]) { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), + DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), DEFINE_PROP_END_OF_LIST() } }; @@ -1477,6 +1478,20 @@ static int pci_add_option_rom(PCIDevice *pdev) if (strlen(pdev->romfile) == 0) return 0; + if (!pdev->rom_bar) { + /* + * Load rom via fw_cfg instead of creating a rom bar, + * for 0.11 compatibility. + */ + int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE); + if (class == 0x0300) { + rom_add_vga(pdev->romfile); + } else { + rom_add_option(pdev->romfile); + } + return 0; + } + path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile); if (path == NULL) { path = qemu_strdup(pdev->romfile); diff --git a/hw/pci.h b/hw/pci.h index fd16460..5d8bf97 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -244,6 +244,7 @@ struct PCIDevice { /* Location of option rom */ char *romfile; ram_addr_t rom_offset; + uint32_t rom_bar; }; PCIDevice *pci_register_device(PCIBus *bus, const char *name, -- 1.6.5.2