Re: [Qemu-devel] [PATCH qom-next 04/12] target-i386: move tcg initialization into x86_cpu_initfn()

2012-05-30 Thread Andreas Färber
Am 30.05.2012 00:10, schrieb Igor Mammedov:
 In order to make cpu object not depended on external ad-hoc
 initialization routines, move tcg initialization from cpu_x86_init
 inside cpu object x86_cpu_initfn().
 
 Signed-off-by: Igor Mammedov imamm...@redhat.com

Modulo the cpu_set_debug_excp_handler() issue that Jan pointed out this
looks good now.

Andreas

 ---
  target-i386/cpu.c|   10 ++
  target-i386/cpu.h|2 ++
  target-i386/helper.c |   11 +--
  3 files changed, 13 insertions(+), 10 deletions(-)
 
 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 89b4ac7..41a0436 100644
 --- a/target-i386/cpu.c
 +++ b/target-i386/cpu.c
 @@ -1734,6 +1734,7 @@ static void x86_cpu_initfn(Object *obj)
  {
  X86CPU *cpu = X86_CPU(obj);
  CPUX86State *env = cpu-env;
 +static int inited;
  
  cpu_exec_init(env);
  
 @@ -1763,6 +1764,15 @@ static void x86_cpu_initfn(Object *obj)
  x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
  
  env-cpuid_apic_id = env-cpu_index;
 +
 +/* init various static tables used in TCG mode */
 +if (tcg_enabled()  !inited) {
 +inited = 1;
 +optimize_flags_init();
 +#ifndef CONFIG_USER_ONLY
 +cpu_set_debug_excp_handler(breakpoint_handler);
 +#endif
 +}
  }
  
  static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 diff --git a/target-i386/cpu.h b/target-i386/cpu.h
 index adc569c..0caa942 100644
 --- a/target-i386/cpu.h
 +++ b/target-i386/cpu.h
 @@ -932,6 +932,8 @@ void hw_breakpoint_insert(CPUX86State *env, int index);
  void hw_breakpoint_remove(CPUX86State *env, int index);
  int check_hw_breakpoints(CPUX86State *env, int force_dr6_update);
  
 +void breakpoint_handler(CPUX86State *env);
 +
  /* will be suppressed */
  void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
  void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
 diff --git a/target-i386/helper.c b/target-i386/helper.c
 index da6f850..a94be0a 100644
 --- a/target-i386/helper.c
 +++ b/target-i386/helper.c
 @@ -941,7 +941,7 @@ int check_hw_breakpoints(CPUX86State *env, int 
 force_dr6_update)
  return hit_enabled;
  }
  
 -static void breakpoint_handler(CPUX86State *env)
 +void breakpoint_handler(CPUX86State *env)
  {
  CPUBreakpoint *bp;
  
 @@ -1153,20 +1153,11 @@ X86CPU *cpu_x86_init(const char *cpu_model)
  {
  X86CPU *cpu;
  CPUX86State *env;
 -static int inited;
  
  cpu = X86_CPU(object_new(TYPE_X86_CPU));
  env = cpu-env;
  env-cpu_model_str = cpu_model;
  
 -/* init various static tables used in TCG mode */
 -if (tcg_enabled()  !inited) {
 -inited = 1;
 -optimize_flags_init();
 -#ifndef CONFIG_USER_ONLY
 -cpu_set_debug_excp_handler(breakpoint_handler);
 -#endif
 -}
  if (cpu_x86_register(cpu, cpu_model)  0) {
  object_delete(OBJECT(cpu));
  return NULL;

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH qom-next 04/12] target-i386: move tcg initialization into x86_cpu_initfn()

2012-05-29 Thread Igor Mammedov
In order to make cpu object not depended on external ad-hoc
initialization routines, move tcg initialization from cpu_x86_init
inside cpu object x86_cpu_initfn().

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
 target-i386/cpu.c|   10 ++
 target-i386/cpu.h|2 ++
 target-i386/helper.c |   11 +--
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 89b4ac7..41a0436 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1734,6 +1734,7 @@ static void x86_cpu_initfn(Object *obj)
 {
 X86CPU *cpu = X86_CPU(obj);
 CPUX86State *env = cpu-env;
+static int inited;
 
 cpu_exec_init(env);
 
@@ -1763,6 +1764,15 @@ static void x86_cpu_initfn(Object *obj)
 x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
 
 env-cpuid_apic_id = env-cpu_index;
+
+/* init various static tables used in TCG mode */
+if (tcg_enabled()  !inited) {
+inited = 1;
+optimize_flags_init();
+#ifndef CONFIG_USER_ONLY
+cpu_set_debug_excp_handler(breakpoint_handler);
+#endif
+}
 }
 
 static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index adc569c..0caa942 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -932,6 +932,8 @@ void hw_breakpoint_insert(CPUX86State *env, int index);
 void hw_breakpoint_remove(CPUX86State *env, int index);
 int check_hw_breakpoints(CPUX86State *env, int force_dr6_update);
 
+void breakpoint_handler(CPUX86State *env);
+
 /* will be suppressed */
 void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
 void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index da6f850..a94be0a 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -941,7 +941,7 @@ int check_hw_breakpoints(CPUX86State *env, int 
force_dr6_update)
 return hit_enabled;
 }
 
-static void breakpoint_handler(CPUX86State *env)
+void breakpoint_handler(CPUX86State *env)
 {
 CPUBreakpoint *bp;
 
@@ -1153,20 +1153,11 @@ X86CPU *cpu_x86_init(const char *cpu_model)
 {
 X86CPU *cpu;
 CPUX86State *env;
-static int inited;
 
 cpu = X86_CPU(object_new(TYPE_X86_CPU));
 env = cpu-env;
 env-cpu_model_str = cpu_model;
 
-/* init various static tables used in TCG mode */
-if (tcg_enabled()  !inited) {
-inited = 1;
-optimize_flags_init();
-#ifndef CONFIG_USER_ONLY
-cpu_set_debug_excp_handler(breakpoint_handler);
-#endif
-}
 if (cpu_x86_register(cpu, cpu_model)  0) {
 object_delete(OBJECT(cpu));
 return NULL;
-- 
1.7.7.6