The pflash image is added to the roms using the memory
region buffer and rom_add_file_buf_fixed.

Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com>
---
 hw/pcflash.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/hw/pcflash.c b/hw/pcflash.c
index eece7ec..e28bdb0 100644
--- a/hw/pcflash.c
+++ b/hw/pcflash.c
@@ -65,6 +65,21 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
     memory_region_set_readonly(isa_bios, true);
 }
 
+static void pc_flash_add_qemu_rom(DriveInfo *pflash_drv,
+                                  MemoryRegion *flash_mem)
+{
+    const char *filename;
+    void *data;
+    uint64_t size;
+    uint32_t addr;
+
+    filename = qemu_opt_get(pflash_drv->opts, "file");
+    data = memory_region_get_ram_ptr(flash_mem);
+    size = memory_region_size(flash_mem);
+    addr = (uint32_t) -((int32_t)size);
+    rom_add_file_buf_fixed(filename, data, size, addr, -1);
+}
+
 static void pc_default_system_flash_init(void)
 {
     QemuOpts *opts;
@@ -118,6 +133,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
     flash_mem = pflash_cfi01_get_memory(system_flash);
 
     pc_isa_bios_init(rom_memory, flash_mem, size);
+    pc_flash_add_qemu_rom(pflash_drv, flash_mem);
 }
 
 void pc_system_firmware_init(MemoryRegion *rom_memory)
-- 
1.7.1


Reply via email to