As the mbar/rambar0 values are currently fixed we can migrate the setting of them to the reset handler as well.
Signed-off-by: Alex Bennée <[email protected]> --- hw/m68k/an5206.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c index f92a5d6a339..918c376a384 100644 --- a/hw/m68k/an5206.c +++ b/hw/m68k/an5206.c @@ -15,11 +15,26 @@ #include "elf.h" #include "qemu/error-report.h" #include "system/qtest.h" +#include "system/reset.h" #define KERNEL_LOAD_ADDR 0x10000 #define AN5206_MBAR_ADDR 0x10000000 #define AN5206_RAMBAR_ADDR 0x20000000 +static void an5206_cpu_reset(void *opaque) +{ + M68kCPU *cpu = opaque; + CPUM68KState *env = &cpu->env; + CPUState *cs = CPU(cpu); + + cpu_reset(cs); + cpu->env.vbr = 0; + cpu->env.mbar = AN5206_MBAR_ADDR | 1; + cpu->env.rambar0 = AN5206_RAMBAR_ADDR | 1; + + cpu->env.pc = env->reset_pc; +} + static void mcf5206_init(M68kCPU *cpu, MemoryRegion *sysmem, uint32_t base) { DeviceState *dev; @@ -47,14 +62,9 @@ static void an5206_init(MachineState *machine) MemoryRegion *sram = g_new(MemoryRegion, 1); cpu = M68K_CPU(cpu_create(machine->cpu_type)); + qemu_register_reset(an5206_cpu_reset, cpu); env = &cpu->env; - /* Initialize CPU registers. */ - env->vbr = 0; - /* TODO: allow changing MBAR and RAMBAR. */ - env->mbar = AN5206_MBAR_ADDR | 1; - env->rambar0 = AN5206_RAMBAR_ADDR | 1; - /* DRAM at address zero */ memory_region_add_subregion(address_space_mem, 0, machine->ram); @@ -90,7 +100,7 @@ static void an5206_init(MachineState *machine) exit(1); } - env->pc = entry; + env->reset_pc = entry; } static void an5206_machine_init(MachineClass *mc) -- 2.47.3
