From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC 02/20] cpu: introduce CPU_GET_ENV macros
Date: Tue, 18 Dec 2012 18:03:55 -0200 [thread overview]
Message-ID: <1355861053-11460-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1355861053-11460-1-git-send-email-ehabkost@redhat.com>
This will help us gradually convert code based on CPUArchState to
QOM-based code.
The macro checks for NULL cpu value, so a NULL cpu safely becomes a NULL
env pointer.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-alpha/cpu-qom.h | 7 +++++++
target-arm/cpu-qom.h | 7 +++++++
target-cris/cpu-qom.h | 7 +++++++
target-i386/cpu-qom.h | 7 +++++++
target-lm32/cpu-qom.h | 7 +++++++
target-m68k/cpu-qom.h | 7 +++++++
target-microblaze/cpu-qom.h | 7 +++++++
target-mips/cpu-qom.h | 7 +++++++
target-openrisc/cpu.h | 7 +++++++
target-ppc/cpu-qom.h | 7 +++++++
target-s390x/cpu-qom.h | 7 +++++++
target-sh4/cpu-qom.h | 7 +++++++
target-sparc/cpu-qom.h | 7 +++++++
target-unicore32/cpu-qom.h | 7 +++++++
target-xtensa/cpu-qom.h | 7 +++++++
15 files changed, 105 insertions(+)
diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h
index 6b4ca6d..3c816a2 100644
--- a/target-alpha/cpu-qom.h
+++ b/target-alpha/cpu-qom.h
@@ -67,5 +67,12 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
#define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e))
+static inline CPUAlphaState *alpha_cpu_get_env(AlphaCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) alpha_cpu_get_env(ALPHA_CPU(cpu))
+
#endif
diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
index beabf9a..d7801f3 100644
--- a/target-arm/cpu-qom.h
+++ b/target-arm/cpu-qom.h
@@ -107,6 +107,13 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
+static inline CPUARMState *arm_cpu_get_env(ARMCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) arm_cpu_get_env(ARM_CPU(cpu))
+
void arm_cpu_realize(ARMCPU *cpu);
void register_cp_regs_for_features(ARMCPU *cpu);
diff --git a/target-cris/cpu-qom.h b/target-cris/cpu-qom.h
index d0e5f04..042dca4 100644
--- a/target-cris/cpu-qom.h
+++ b/target-cris/cpu-qom.h
@@ -66,5 +66,12 @@ static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env)
#define ENV_GET_CPU(e) CPU(cris_env_get_cpu(e))
+static inline CPUCRISState *cris_cpu_get_env(CRISCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) cris_cpu_get_env(CRIS_CPU(cpu))
+
#endif
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 5901140..19afe28 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -72,6 +72,13 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env)
#define ENV_GET_CPU(e) CPU(x86_env_get_cpu(e))
+static inline CPUX86State *x86_cpu_get_env(X86CPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) x86_cpu_get_env(X86_CPU(cpu))
+
/* TODO Drop once ObjectClass::realize is available */
void x86_cpu_realize(Object *obj, Error **errp);
diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h
index 4ae2edd..4b15192 100644
--- a/target-lm32/cpu-qom.h
+++ b/target-lm32/cpu-qom.h
@@ -67,5 +67,12 @@ static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env)
#define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e))
+static inline CPULM32State *lm32_cpu_get_env(LM32CPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) lm32_cpu_get_env(LM32_CPU(cpu))
+
#endif
diff --git a/target-m68k/cpu-qom.h b/target-m68k/cpu-qom.h
index 805786b..fce1fe3 100644
--- a/target-m68k/cpu-qom.h
+++ b/target-m68k/cpu-qom.h
@@ -66,5 +66,12 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)
#define ENV_GET_CPU(e) CPU(m68k_env_get_cpu(e))
+static inline CPUM68KState *m68k_cpu_get_env(M68kCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) m68k_cpu_get_env(M68K_CPU(cpu))
+
#endif
diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h
index 4b23303..38baa32 100644
--- a/target-microblaze/cpu-qom.h
+++ b/target-microblaze/cpu-qom.h
@@ -66,5 +66,12 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)
#define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e))
+static inline CPUMBState *mb_cpu_get_env(MicroBlazeCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) mb_cpu_get_env(MICROBLAZE_CPU(cpu))
+
#endif
diff --git a/target-mips/cpu-qom.h b/target-mips/cpu-qom.h
index 6e22371..da8f187 100644
--- a/target-mips/cpu-qom.h
+++ b/target-mips/cpu-qom.h
@@ -70,5 +70,12 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)
#define ENV_GET_CPU(e) CPU(mips_env_get_cpu(e))
+static inline CPUMIPSState *mips_cpu_get_env(MIPSCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) mips_cpu_get_env(MIPS_CPU(cpu))
+
#endif
diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
index ebb5ad3..ca607b3 100644
--- a/target-openrisc/cpu.h
+++ b/target-openrisc/cpu.h
@@ -339,6 +339,13 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)
#define ENV_GET_CPU(e) CPU(openrisc_env_get_cpu(e))
+static inline CPUOpenRISCState *openrisc_cpu_get_env(OpenRISCCPU *cpu)
+{
+ return &cpu->env;;
+}
+
+#define CPU_GET_ENV(cpu) openrisc_cpu_get_env(OPENRISC_CPU(cpu))
+
OpenRISCCPU *cpu_openrisc_init(const char *cpu_model);
void openrisc_cpu_realize(Object *obj, Error **errp);
diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index fef6f95..d8a878e 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -73,5 +73,12 @@ static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
#define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e))
+static inline CPUPPCState *ppc_cpu_get_env(PowerPCCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) ppc_cpu_get_env(POWERPC_CPU(cpu))
+
#endif
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index 6fa55a8..7a51004 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -67,5 +67,12 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)
#define ENV_GET_CPU(e) CPU(s390_env_get_cpu(e))
+static inline CPUS390XState *s390_cpu_get_env(S390CPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) s390_cpu_get_env(S390_CPU(cpu))
+
#endif
diff --git a/target-sh4/cpu-qom.h b/target-sh4/cpu-qom.h
index c41164a..b8cf70a 100644
--- a/target-sh4/cpu-qom.h
+++ b/target-sh4/cpu-qom.h
@@ -66,5 +66,12 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)
#define ENV_GET_CPU(e) CPU(sh_env_get_cpu(e))
+static inline CPUSH4State *sh_cpu_get_env(SuperHCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) sh_cpu_get_env(SUPERH_CPU(cpu))
+
#endif
diff --git a/target-sparc/cpu-qom.h b/target-sparc/cpu-qom.h
index 3d3ac0f..1ed4e11 100644
--- a/target-sparc/cpu-qom.h
+++ b/target-sparc/cpu-qom.h
@@ -71,5 +71,12 @@ static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env)
#define ENV_GET_CPU(e) CPU(sparc_env_get_cpu(e))
+static inline CPUSPARCState *sparc_cpu_get_env(SPARCCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) sparc_cpu_get_env(SPARC_CPU(cpu))
+
#endif
diff --git a/target-unicore32/cpu-qom.h b/target-unicore32/cpu-qom.h
index 342d85e..0afe9b9 100644
--- a/target-unicore32/cpu-qom.h
+++ b/target-unicore32/cpu-qom.h
@@ -55,5 +55,12 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)
#define ENV_GET_CPU(e) CPU(uc32_env_get_cpu(e))
+static inline CPUUniCore32State *uc32_cpu_get_env(UniCore32CPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) uc32_cpu_get_env(UNICORE32_CPU(cpu))
+
#endif
diff --git a/target-xtensa/cpu-qom.h b/target-xtensa/cpu-qom.h
index 1fd2f27..cfab791 100644
--- a/target-xtensa/cpu-qom.h
+++ b/target-xtensa/cpu-qom.h
@@ -76,5 +76,12 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env)
#define ENV_GET_CPU(e) CPU(xtensa_env_get_cpu(e))
+static inline CPUXtensaState *xtensa_cpu_get_env(XtensaCPU *cpu)
+{
+ return cpu ? &cpu->env : NULL;
+}
+
+#define CPU_GET_ENV(cpu) xtensa_cpu_get_env(XTENSA_CPU(cpu))
+
#endif
--
1.7.11.7
next prev parent reply other threads:[~2012-12-18 20:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 20:03 [Qemu-devel] [RFC 00/20] generic_cpu_init() and generic_cpu_create() functions Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 01/20] qemu-common.h: "use" env parameter in no-op version of qemu_init_vcpu() Eduardo Habkost
2012-12-18 20:03 ` Eduardo Habkost [this message]
2012-12-18 20:03 ` [Qemu-devel] [RFC 03/20] cpu: make cpu_init return CPUState QOM object Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 04/20] cpu: replace trivial old_cpu_init functions Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 05/20] alpha: convert cpu_init to QOM Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 06/20] m68k: " Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 07/20] target-unicore32: " Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 08/20] cpu: move cpu_model_str to CPUState Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 09/20] cpu: introduce cpu_realize() Eduardo Habkost
2012-12-18 23:13 ` Andreas Färber
2012-12-18 20:04 ` [Qemu-devel] [RFC 10/20] cpu: introduce generic_cpu_init() & generic_cpu_create() functions Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 11/20] target-openrisc: implement CPU realize() method Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 12/20] hw/openrisc_sim.c: coding style/indentation fix Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 13/20] target-openrisc: replace cpu_openrisc_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 14/20] target-arm: move final steps of cpu_arm_init() to realize function Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 15/20] target-arm: replace cpu_arm_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 16/20] target-m68k: move final steps of cpu_m68k_init() to realize function Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 17/20] target-m68k: replace cpu_m68k_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 18/20] target-unicore32: move final steps of uc32_cpu_init() to realize function Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 19/20] target-unicore32: replace uc32_cpu_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 20/20] cpu: convert cpu_copy() to QOM Eduardo Habkost
2012-12-18 22:57 ` [Qemu-devel] [RFC 00/20] generic_cpu_init() and generic_cpu_create() functions Andreas Färber
2012-12-19 0:08 ` Eduardo Habkost
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=1355861053-11460-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--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).