diff mbox

[4/7] target-arm: support AArch64 for arm_cpu_set_pc

Message ID 1399305623-22016-5-git-send-email-robherring2@gmail.com
State New
Headers show

Commit Message

Rob Herring May 5, 2014, 4 p.m. UTC
From: Rob Herring <rob.herring@linaro.org>

Add AArch64 support to arm_cpu_set_pc and make it available to other files.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
---
 target-arm/cpu.c |  7 -------
 target-arm/cpu.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)

Comments

Peter Maydell May 5, 2014, 4:22 p.m. UTC | #1
On 5 May 2014 17:00, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <rob.herring@linaro.org>
>
> Add AArch64 support to arm_cpu_set_pc and make it available to other files.
>
> Signed-off-by: Rob Herring <rob.herring@linaro.org>
> ---
>  target-arm/cpu.c |  7 -------
>  target-arm/cpu.h | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/target-arm/cpu.c b/target-arm/cpu.c
> index 03c025b..2d18a20 100644
> --- a/target-arm/cpu.c
> +++ b/target-arm/cpu.c
> @@ -30,13 +30,6 @@
>  #include "sysemu/sysemu.h"
>  #include "sysemu/kvm.h"
>
> -static void arm_cpu_set_pc(CPUState *cs, vaddr value)
> -{
> -    ARMCPU *cpu = ARM_CPU(cs);
> -
> -    cpu->env.regs[15] = value;
> -}
> -
>  static bool arm_cpu_has_work(CPUState *cs)
>  {
>      ARMCPU *cpu = ARM_CPU(cs);
> diff --git a/target-arm/cpu.h b/target-arm/cpu.h
> index 905ba02..efe3cd2 100644
> --- a/target-arm/cpu.h
> +++ b/target-arm/cpu.h
> @@ -1197,6 +1197,18 @@ static inline void cpu_pc_from_tb(CPUARMState *env, TranslationBlock *tb)
>      }
>  }
>
> +static inline void arm_cpu_set_pc(CPUState *cs, vaddr value)
> +{
> +    ARMCPU *cpu = ARM_CPU(cs);
> +
> +    if (is_a64(&cpu->env)) {
> +        cpu->env.pc = value;
> +    } else {
> +        cpu->env.regs[15] = value;
> +    }
> +
> +}

The set_pc() functions are supposed to be private implementations
of methods on the CPU object. This one is fine where it is;
the AArch64 support is in aarch64_cpu_set_pc(). In either case
you should only be calling it via the CPUClass->set_pc pointer.
Assuming you have a CPUState *cpu, then:

    CPUClass *cc = CPU_GET_CLASS(cpu);
    cc->set_pc(cpu, pc);

thanks
-- PMM
diff mbox

Patch

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 03c025b..2d18a20 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -30,13 +30,6 @@ 
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 
-static void arm_cpu_set_pc(CPUState *cs, vaddr value)
-{
-    ARMCPU *cpu = ARM_CPU(cs);
-
-    cpu->env.regs[15] = value;
-}
-
 static bool arm_cpu_has_work(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 905ba02..efe3cd2 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -1197,6 +1197,18 @@  static inline void cpu_pc_from_tb(CPUARMState *env, TranslationBlock *tb)
     }
 }
 
+static inline void arm_cpu_set_pc(CPUState *cs, vaddr value)
+{
+    ARMCPU *cpu = ARM_CPU(cs);
+
+    if (is_a64(&cpu->env)) {
+        cpu->env.pc = value;
+    } else {
+        cpu->env.regs[15] = value;
+    }
+
+}
+
 /* Load an instruction and return it in the standard little-endian order */
 static inline uint32_t arm_ldl_code(CPUARMState *env, target_ulong addr,
                                     bool do_swap)