From patchwork Fri Jan 8 14:25:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 42504 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 6C041B7C06 for ; Sat, 9 Jan 2010 01:26:34 +1100 (EST) Received: from localhost ([127.0.0.1]:33700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTFnL-0003HK-8r for incoming@patchwork.ozlabs.org; Fri, 08 Jan 2010 09:26:31 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTFmj-0003Ft-Ag for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTFme-0003Bp-RW for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:53 -0500 Received: from [199.232.76.173] (port=43420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTFme-0003Bg-Jt for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59382) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTFme-0006J0-6y for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:48 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08EPkvd029347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Jan 2010 09:25:46 -0500 Received: from zweiblum.home.kraxel.org (vpn2-11-198.ams2.redhat.com [10.36.11.198]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o08EPi62016870; Fri, 8 Jan 2010 09:25:45 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 6A92070FCB; Fri, 8 Jan 2010 15:25:43 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 8 Jan 2010 15:25:40 +0100 Message-Id: <1262960742-18267-5-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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 4/6] roms: rework rom loading via fw 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 patch changes the way rom loading via fw_cfg is handled. Instead of having pc_init1() call a function which passed all roms to the firmware config we simply pass a pointer to fw_cfg to the rom loader. Advantage: loading roms via firmware works also for devices which are initialized after pc_init1(), i.e. everyting added via -device. Signed-off-by: Gerd Hoffmann --- hw/loader.c | 15 +++++---------- hw/loader.h | 2 +- hw/pc.c | 3 +-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/hw/loader.c b/hw/loader.c index 38ee2da..b3bbd77 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -535,6 +535,7 @@ struct Rom { QTAILQ_ENTRY(Rom) next; }; +static FWCfgState *fw_cfg; static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms); int rom_enable_driver_roms; @@ -592,6 +593,8 @@ int rom_add_file(const char *file, const char *fw_dir, } close(fd); rom_insert(rom); + if (rom->fw_file && fw_cfg) + fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize); return 0; err: @@ -681,17 +684,9 @@ int rom_load_all(void) return 0; } -int rom_load_fw(void *fw_cfg) +void rom_set_fw(void *f) { - Rom *rom; - - QTAILQ_FOREACH(rom, &roms, next) { - if (!rom->fw_file) { - continue; - } - fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize); - } - return 0; + fw_cfg = f; } static Rom *find_rom(target_phys_addr_t addr) diff --git a/hw/loader.h b/hw/loader.h index 698160b..8ff3c94 100644 --- a/hw/loader.h +++ b/hw/loader.h @@ -25,7 +25,7 @@ int rom_add_file(const char *file, const char *fw_dir, int rom_add_blob(const char *name, const void *blob, size_t len, target_phys_addr_t addr); int rom_load_all(void); -int rom_load_fw(void *fw_cfg); +void rom_set_fw(void *f); int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size); void *rom_ptr(target_phys_addr_t addr); void do_info_roms(Monitor *mon); diff --git a/hw/pc.c b/hw/pc.c index ea5ac8e..3ed43f5 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1099,6 +1099,7 @@ static void pc_init1(ram_addr_t ram_size, bios_size, bios_offset | IO_MEM_ROM); fw_cfg = bochs_bios_init(); + rom_set_fw(fw_cfg); if (linux_boot) { load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); @@ -1259,8 +1260,6 @@ static void pc_init1(ram_addr_t ram_size, } } } - - rom_load_fw(fw_cfg); } static void pc_init_pci(ram_addr_t ram_size,