qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [Patch v4 6/8] target_arm: Change the reset values based on


From: Alistair Francis
Subject: [Qemu-devel] [Patch v4 6/8] target_arm: Change the reset values based on the ELF entry
Date: Wed, 8 Oct 2014 00:13:06 +1000

The Netduino 2 machine won't run unless the reset_pc is based
on the ELF entry point.

Signed-off-by: Alistair Francis <address@hidden>
Signed-off-by: Peter Crosthwaite <address@hidden>
---
V2:
 - Malloc straight away, thanks to Peter C

 hw/arm/armv7m.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 7169027..07b36e2 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -155,11 +155,19 @@ static void armv7m_bitband_init(void)
 
 /* Board init.  */
 
+typedef struct ARMV7MResetArgs {
+    ARMCPU *cpu;
+    uint32_t reset_pc;
+} ARMV7MResetArgs;
+
 static void armv7m_reset(void *opaque)
 {
-    ARMCPU *cpu = opaque;
+    ARMV7MResetArgs *args = opaque;
+
+    cpu_reset(CPU(args->cpu));
 
-    cpu_reset(CPU(cpu));
+    args->cpu->env.thumb = args->reset_pc & 1;
+    args->cpu->env.regs[15] = args->reset_pc & ~1;
 }
 
 /* Init CPU and memory for a v7-M based board.
@@ -180,6 +188,7 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int 
mem_size, int num_irq,
     int i;
     int big_endian;
     MemoryRegion *hack = g_new(MemoryRegion, 1);
+    ARMV7MResetArgs *reset_args = g_new0(ARMV7MResetArgs, 1);
 
     if (cpu_model == NULL) {
        cpu_model = "cortex-m3";
@@ -234,7 +243,11 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int 
mem_size, int num_irq,
     vmstate_register_ram_global(hack);
     memory_region_add_subregion(system_memory, 0xfffff000, hack);
 
-    qemu_register_reset(armv7m_reset, cpu);
+    *reset_args = (ARMV7MResetArgs) {
+        .cpu = cpu,
+        .reset_pc = entry,
+    };
+    qemu_register_reset(armv7m_reset, reset_args);
     return pic;
 }
 
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]