Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
v2
- rewritten
- favour cpu_reset over resettable_reset(cs)
---
hw/m68k/mcf5208.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index c6d1c5fae9f..38e2d1307a6 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -27,6 +27,7 @@
#include "qemu/timer.h"
#include "hw/core/ptimer.h"
#include "system/system.h"
+#include "system/reset.h"
#include "system/qtest.h"
#include "net/net.h"
#include "hw/core/boards.h"
@@ -274,6 +275,13 @@ static void mcf_fec_init(MemoryRegion *sysmem, hwaddr base, qemu_irq *irqs)
memory_region_add_subregion(sysmem, base, sysbus_mmio_get_region(s, 0));
}
+static void mcf5208evb_reset(MachineState *ms, ResetType type)
+{
+ CPUState *cs = first_cpu;
+ qemu_devices_reset(type);
+ cpu_reset(cs);
+}
+
static void mcf5208evb_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
@@ -289,11 +297,8 @@ static void mcf5208evb_init(MachineState *machine)
MemoryRegion *sram = g_new(MemoryRegion, 1);
cpu = M68K_CPU(cpu_create(machine->cpu_type));
- env = &cpu->env;
- /* Initialize CPU registers. */
- env->vbr = 0;
- /* TODO: Configure BARs. */
+ env = &cpu->env;
/* ROM at 0x00000000 */
memory_region_init_rom(rom, NULL, "mcf5208.rom", ROM_SIZE, &error_fatal);
@@ -343,10 +348,7 @@ static void mcf5208evb_init(MachineState *machine)
/* Load firmware */
if (machine->firmware) {
- char *fn;
- uint8_t *ptr;
-
- fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
+ g_autofree char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
if (!fn) {
error_report("Could not find ROM image '%s'", machine->firmware);
exit(1);
@@ -355,11 +357,6 @@ static void mcf5208evb_init(MachineState *machine)
error_report("Could not load ROM image '%s'", machine->firmware);
exit(1);
}
- g_free(fn);
- /* Initial PC is always at offset 4 in firmware binaries */
- ptr = rom_ptr(0x4, 4);
- assert(ptr != NULL);
- env->pc = ldl_be_p(ptr);
}
/* Load kernel. */
@@ -388,13 +385,14 @@ static void mcf5208evb_init(MachineState *machine)
exit(1);
}
- env->pc = entry;
+ env->direct_kernel_boot_pc = entry;
}
static void mcf5208evb_machine_init(MachineClass *mc)
{
mc->desc = "MCF5208EVB";
mc->init = mcf5208evb_init;
+ mc->reset = mcf5208evb_reset;
mc->is_default = true;
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5208");
mc->default_ram_id = "mcf5208.ram";
--
2.47.3