diff mbox

[next,v2,35/74] armv7m: Use cpu_arm_init() to obtain ARMCPU

Message ID 1336608892-30501-36-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber May 10, 2012, 12:14 a.m. UTC
Needed for armv7m_reset().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/armv7m.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Comments

Peter Maydell May 11, 2012, 11:18 a.m. UTC | #1
On 10 May 2012 01:14, Andreas Färber <afaerber@suse.de> wrote:
> Needed for armv7m_reset().
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Acked-by: Peter Maydell <peter.maydell@linaro.org>

I'd have preferred it if you hadn't made the style change
from "if (!foo)" to "if (foo == NULL)", incidentally, but I'm
not going to insist on a respin for it.

-- PMM
Andreas Färber May 11, 2012, 1:34 p.m. UTC | #2
Am 11.05.2012 13:18, schrieb Peter Maydell:
> On 10 May 2012 01:14, Andreas Färber <afaerber@suse.de> wrote:
>> Needed for armv7m_reset().
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> Acked-by: Peter Maydell <peter.maydell@linaro.org>

Thanks, applied to qom-next:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-next

> I'd have preferred it if you hadn't made the style change
> from "if (!foo)" to "if (foo == NULL)", incidentally, but I'm
> not going to insist on a respin for it.

For the record, Peter's request here was to not propagate such stylistic
changes unneccessarily throughout old code. In these two cases on one
line I added the missing opening brace and on the other I had to change
the variable name so it does not add to the patch.

Both styles are valid C and can be expected to produce identical machine
code with an optimizing compiler.

What we might do though is assist the compiler in determining which code
paths are likely() vs. unlikely(). For stylistic reasons I prefer to
have the unlikely error case in the if, e.g. in cpu_sh4_init(). These
are not hot paths though so it shouldn't matter much.

/-F
diff mbox

Patch

diff --git a/hw/armv7m.c b/hw/armv7m.c
index 4aac076..4e5971c 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -160,6 +160,7 @@  qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
                       int flash_size, int sram_size,
                       const char *kernel_filename, const char *cpu_model)
 {
+    ARMCPU *cpu;
     CPUARMState *env;
     DeviceState *nvic;
     /* FIXME: make this local state.  */
@@ -177,13 +178,15 @@  qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
     flash_size *= 1024;
     sram_size *= 1024;
 
-    if (!cpu_model)
+    if (cpu_model == NULL) {
 	cpu_model = "cortex-m3";
-    env = cpu_init(cpu_model);
-    if (!env) {
+    }
+    cpu = cpu_arm_init(cpu_model);
+    if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
         exit(1);
     }
+    env = &cpu->env;
 
 #if 0
     /* > 32Mb SRAM gets complicated because it overlaps the bitband area.