diff options
Diffstat (limited to 'hw/mips_r4k.c')
-rw-r--r-- | hw/mips_r4k.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index d525c63b58..497885bb3e 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -70,7 +70,12 @@ static CPUReadMemoryFunc * const mips_qemu_read[] = { static int mips_qemu_iomemtype = 0; -static void load_kernel (CPUState *env) +typedef struct ResetData { + CPUState *env; + uint64_t vector; +} ResetData; + +static int64_t load_kernel(void) { int64_t entry, kernel_low, kernel_high; long kernel_size, initrd_size; @@ -89,7 +94,6 @@ static void load_kernel (CPUState *env) if (kernel_size >= 0) { if ((entry & ~0x7fffffffULL) == 0x80000000) entry = (int32_t)entry; - env->active_tc.PC = entry; } else { fprintf(stderr, "qemu: could not load kernel '%s'\n", loaderparams.kernel_filename); @@ -135,15 +139,16 @@ static void load_kernel (CPUState *env) stl_phys((16 << 20) - 260, 0x12345678); stl_phys((16 << 20) - 264, ram_size); + return entry; } static void main_cpu_reset(void *opaque) { - CPUState *env = opaque; - cpu_reset(env); + ResetData *s = (ResetData *)opaque; + CPUState *env = s->env; - if (loaderparams.kernel_filename) - load_kernel (env); + cpu_reset(env); + env->active_tc.PC = s->vector; } static const int sector_len = 32 * 1024; @@ -158,6 +163,7 @@ void mips_r4k_init (ram_addr_t ram_size, ram_addr_t bios_offset; int bios_size; CPUState *env; + ResetData *reset_info; RTCState *rtc_state; int i; qemu_irq *i8259; @@ -177,7 +183,10 @@ void mips_r4k_init (ram_addr_t ram_size, fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } - qemu_register_reset(main_cpu_reset, env); + reset_info = qemu_mallocz(sizeof(ResetData)); + reset_info->env = env; + reset_info->vector = env->active_tc.PC; + qemu_register_reset(main_cpu_reset, reset_info); /* allocate RAM */ if (ram_size > (256 << 20)) { @@ -237,7 +246,7 @@ void mips_r4k_init (ram_addr_t ram_size, loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; - load_kernel (env); + reset_info->vector = load_kernel(); } /* Init CPU internal devices */ |