On 15/10/13 22:46, Peter Maydell wrote:

On 15 October 2013 21:19, Mark Cave-Ayland
<mark.cave-ayl...@ilande.co.uk>  wrote:
+    /* FCode ROM */
+    memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE);
+    vmstate_register_ram_global(&s->rom);
+    memory_region_set_readonly(&s->rom, true);
+    sysbus_init_mmio(dev,&s->rom);
+
+    fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE);
+    if (fcode_filename) {
+        ret = load_image_targphys(fcode_filename, s->prom_addr,
+                                  FCODE_MAX_ROM_SIZE);
+    }

Ideally we would have a 'load image into RAM memory region' function,
and then we wouldn't need to pass the device the address of its own
memory region. Oh well...

Yes, definitely the ROM image code is lacking from post-MemoryRegion love. For example load_image_targphys() indirectly creates a MemoryRegion to hold the loaded ROM contents, but it only becomes visible (presumably because of SysBus) when another RAM MemoryRegion is installed at the same address. Hence you actually end up having to claim twice the memory requirement of your original ROM.


ATB,

Mark.

Reply via email to