qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
To: qemu-devel@nongnu.org
Cc: alistair23@gmail.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH target-arm] arm: armv7m: Respect elf entry point
Date: Sat,  2 Aug 2014 09:41:03 +1000	[thread overview]
Message-ID: <1406936463-7330-1-git-send-email-crosthwaite.peter@gmail.com> (raw)

ARMv7M has it's own bootloader (separate from the regular ARM
bootloader) that is elf aware. It is able to load elfs but it does
not set the program counter to the elf entry point. Make it more
consistent with the regular ARM bootloader by setting the program
counter to the given elf entry point.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 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 397e8df..d1b983f 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -155,11 +155,18 @@ 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(cpu));
+    cpu_reset(CPU(args->cpu));
+    args->cpu->env.regs[15] = args->reset_pc;
+    args->cpu->env.thumb = args->reset_pc & 1;
 }
 
 /* Init CPU and memory for a v7-M based board.
@@ -183,6 +190,7 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
     MemoryRegion *sram = g_new(MemoryRegion, 1);
     MemoryRegion *flash = g_new(MemoryRegion, 1);
     MemoryRegion *hack = g_new(MemoryRegion, 1);
+    ARMV7MResetArgs reset_args;
 
     flash_size *= 1024;
     sram_size *= 1024;
@@ -259,7 +267,12 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
     vmstate_register_ram_global(hack);
     memory_region_add_subregion(address_space_mem, 0xfffff000, hack);
 
-    qemu_register_reset(armv7m_reset, cpu);
+    reset_args = (ARMV7MResetArgs) {
+        .cpu = cpu,
+        .reset_pc = entry,
+    };
+    qemu_register_reset(armv7m_reset,
+                        g_memdup(&reset_args, sizeof(reset_args)));
     return pic;
 }
 
-- 
1.9.1

             reply	other threads:[~2014-08-01 23:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 23:41 Peter Crosthwaite [this message]
2014-08-04  7:54 ` [Qemu-devel] [PATCH target-arm] arm: armv7m: Respect elf entry point Alistair Francis
2014-08-07 12:18   ` Peter Crosthwaite
2014-08-04 12:22 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406936463-7330-1-git-send-email-crosthwaite.peter@gmail.com \
    --to=crosthwaitepeter@gmail.com \
    --cc=alistair23@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).