From: James Hogan <james.ho...@imgtec.com> Commit a427338 (mips_malta: correct reading MIPS revision at 0x1fc00010) altered the behaviour of the monitor flash mapping at the reset address by making it read only. However this causes data bus error exceptions when it is written to since it is effectively unassigned memory for writes. This isn't how the real hardware behaves. That memory can be written to (even with the MFWR jumper not fitted) and the new value read back from, but it doesn't get written back to the monitor flash so is volatile and may be lost after reading other parts of the flash.
This is fixed by making the bios copy ram writeable, but loaded via rom_add_blob_fixed() so that it it restored on reset. That's not as volatile as real hardware but should be good enough. Signed-off-by: James Hogan <james.ho...@imgtec.com> Cc: Paul Burton <paul.bur...@imgtec.com> Cc: Leon Alrae <leon.al...@imgtec.com> Cc: Aurelien Jarno <aurel...@aurel32.net> Cc: Andreas Färber <afaer...@suse.de> Signed-off-by: Leon Alrae <leon.al...@imgtec.com> --- Changes in v2: - This fixes it slightly differently, but is cleaner I think. The bios copy region is now writable, but is restored on reset. The revision ID is now possible to overwrite (temporarily). hw/mips/mips_malta.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index f8d064c..06e5b50 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -905,6 +905,7 @@ void mips_malta_init(QEMUMachineInitArgs *args) int fl_idx = 0; int fl_sectors = bios_size >> 16; int be; + void *bios_start; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); @@ -1044,16 +1045,19 @@ void mips_malta_init(QEMUMachineInitArgs *args) * regions are not executable. */ memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); - if (!rom_copy(memory_region_get_ram_ptr(bios_copy), - FLASH_ADDRESS, BIOS_SIZE)) { - memcpy(memory_region_get_ram_ptr(bios_copy), - memory_region_get_ram_ptr(bios), BIOS_SIZE); - } - memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); + bios_start = rom_ptr(FLASH_ADDRESS); + if (!bios_start) { + bios_start = memory_region_get_ram_ptr(bios); + /* in case qtest_enabled() */ + if (bios_size < 0) { + bios_size = BIOS_SIZE; + } + } + rom_add_blob_fixed("bios.1fc", bios_start, bios_size, RESET_ADDRESS); /* Board ID = 0x420 (Malta Board with CoreLV) */ - stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); + stl_p(rom_ptr(RESET_ADDRESS + 0x10), 0x00000420); /* Init internal devices */ cpu_mips_irq_init_cpu(env); -- 1.7.5.4