[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 20/20] cpu: convert cpu_copy() to QOM
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC 20/20] cpu: convert cpu_copy() to QOM |
Date: |
Tue, 18 Dec 2012 18:04:13 -0200 |
Instead of using CPUArchState for parameters and return value,
get/return CPUState objects.
It is still an ugly hack that should die, but at least it's an ugly hack
that can use the QOM CPU object if necessary, and allows the calling
code to be converted to QOM as well.
This also keeps the cpu_copy() hack that we need to eventually kill.
The result of this series is:
$ g grep class_by_name target-*/cpu.c
$
That means all architectures that used CPU class lookup on its cpu_init()
implementation were converted to use generic_cpu_init().
Signed-off-by: Eduardo Habkost <address@hidden>
---
cpu-all.h | 1 -
exec.c | 9 +++++----
include/qemu/cpu.h | 4 ++++
linux-user/syscall.c | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index d6b2b19..24662ce 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -352,7 +352,6 @@ void page_set_flags(target_ulong start, target_ulong end,
int flags);
int page_check_range(target_ulong start, target_ulong len, int flags);
#endif
-CPUArchState *cpu_copy(CPUArchState *env);
CPUArchState *qemu_get_cpu(int cpu);
#define CPU_DUMP_CODE 0x00010000
diff --git a/exec.c b/exec.c
index 3919145..5af5652 100644
--- a/exec.c
+++ b/exec.c
@@ -524,10 +524,11 @@ void cpu_abort(CPUArchState *env, const char *fmt, ...)
abort();
}
-CPUArchState *cpu_copy(CPUArchState *env)
+CPUState *cpu_copy(CPUState *old_cpu)
{
- CPUState *old_cpu = ENV_GET_CPU(env);
- CPUArchState *new_env = CPU_GET_ENV(cpu_init(old_cpu->cpu_model_str));
+ CPUArchState *env = CPU_GET_ENV(old_cpu);
+ CPUState *new_cpu = cpu_init(old_cpu->cpu_model_str);
+ CPUArchState *new_env = CPU_GET_ENV(new_cpu);
CPUArchState *next_cpu = new_env->next_cpu;
int cpu_index = new_env->cpu_index;
#if defined(TARGET_HAS_ICE)
@@ -556,7 +557,7 @@ CPUArchState *cpu_copy(CPUArchState *env)
}
#endif
- return new_env;
+ return new_cpu;
}
#if !defined(CONFIG_USER_ONLY)
diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index 7461319..9cfbc94 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -174,5 +174,9 @@ CPUState *generic_cpu_create(const char *base_class_name,
*/
CPUState *generic_cpu_init(const char *base_class_name, const char *cpu_model);
+/* Legacy hacks that should eventually die: */
+
+/* CPU clone/copy hack, that does a memcpy of the ->env field */
+CPUState *cpu_copy(CPUState *cpu);
#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 31d5276..400cf47 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4362,7 +4362,7 @@ static int do_fork(CPUArchState *env, unsigned int flags,
abi_ulong newsp,
ts = g_malloc0(sizeof(TaskState));
init_task_state(ts);
/* we create a new CPU instance. */
- new_env = cpu_copy(env);
+ new_env = CPU_GET_ENV(cpu_copy(ENV_GET_CPU(env)));
#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
cpu_reset(ENV_GET_CPU(new_env));
#endif
--
1.7.11.7
- Re: [Qemu-devel] [RFC 09/20] cpu: introduce cpu_realize(), (continued)
- [Qemu-devel] [RFC 15/20] target-arm: replace cpu_arm_init() with generic_cpu_init(), Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 17/20] target-m68k: replace cpu_m68k_init() with generic_cpu_init(), Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 05/20] alpha: convert cpu_init to QOM, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 04/20] cpu: replace trivial old_cpu_init functions, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 13/20] target-openrisc: replace cpu_openrisc_init() with generic_cpu_init(), Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 16/20] target-m68k: move final steps of cpu_m68k_init() to realize function, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 18/20] target-unicore32: move final steps of uc32_cpu_init() to realize function, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 19/20] target-unicore32: replace uc32_cpu_init() with generic_cpu_init(), Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 14/20] target-arm: move final steps of cpu_arm_init() to realize function, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 20/20] cpu: convert cpu_copy() to QOM,
Eduardo Habkost <=
- [Qemu-devel] [RFC 08/20] cpu: move cpu_model_str to CPUState, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 10/20] cpu: introduce generic_cpu_init() & generic_cpu_create() functions, Eduardo Habkost, 2012/12/18
- [Qemu-devel] [RFC 03/20] cpu: make cpu_init return CPUState QOM object, Eduardo Habkost, 2012/12/18
- Re: [Qemu-devel] [RFC 00/20] generic_cpu_init() and generic_cpu_create() functions, Andreas Färber, 2012/12/18