qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 4/6] roms: rework rom loading via fw
Date: Fri,  8 Jan 2010 15:25:40 +0100	[thread overview]
Message-ID: <1262960742-18267-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1262960742-18267-1-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>
---
 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,
-- 
1.6.5.2

  parent reply	other threads:[~2010-01-08 14:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08 14:25 [Qemu-devel] [PATCH 0/6] rom loading saga continued Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 1/6] pc: add machine type for 0.12 Gerd Hoffmann
2010-01-11 19:50   ` Anthony Liguori
2010-01-12 17:10     ` Gerd Hoffmann
2010-01-12 19:18       ` Anthony Liguori
2010-01-12 19:36       ` Anthony Liguori
2010-01-12 20:43         ` Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 2/6] roms: minor fixes and cleanups Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 3/6] fw_cfg: rom loader tweaks Gerd Hoffmann
2010-01-08 14:25 ` Gerd Hoffmann [this message]
2010-01-08 14:25 ` [Qemu-devel] [PATCH 5/6] pci: allow loading roms via fw_cfg Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 6/6] pc: add rombar to compat properties for pc-0.10 and pc-0.11 Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1262960742-18267-5-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).