Introduce CPUState.

This patch splits the definitions previously found in CPUArchState,
to place some of them in a common data structure called CPUState,
to mirror upstream.

Note that upstream also makes CPUState a complete QOM object that
derives from DeviceState / DeviceClass, but this patch doesn't do
that. That's why the target-*/cpu-qom.h files, as well as
include/qom/cpu.h are not the real ones from upstream yet.

Future patches will get rid of CPUOldState, which is currently used
as an alias for CPUArchState, but will be replaced entirely by
CPUState, requiring changing the signature of many functions to
match upstream.

QOM-ification will probably happen after that, but may require
a few more patches due to layering / coupling issues.

Change-Id: Ifc33f8abe2aa80b20da13f5c83c109e37aff7e11

Conflicts:
	cputlb.c
	target-arm/op_helper.c
	target-i386/op_helper.c
	target-mips/op_helper.c
diff --git a/cpus.c b/cpus.c
index 38ecaf3..ed08a34 100644
--- a/cpus.c
+++ b/cpus.c
@@ -36,25 +36,25 @@
 
 #include "sysemu/cpus.h"
 
-static CPUOldState *cur_cpu;
-static CPUOldState *next_cpu;
+static CPUState *cur_cpu;
+static CPUState *next_cpu;
 
 /***********************************************************/
 void hw_error(const char *fmt, ...)
 {
     va_list ap;
-    CPUState *env;
+    CPUState *cpu;
 
     va_start(ap, fmt);
     fprintf(stderr, "qemu: hardware error: ");
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
-    CPU_FOREACH(env) {
-        fprintf(stderr, "CPU #%d:\n", env->cpu_index);
+    CPU_FOREACH(cpu) {
+        fprintf(stderr, "CPU #%d:\n", cpu->cpu_index);
 #ifdef TARGET_I386
-        cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU);
+        cpu_dump_state(cpu->env_ptr, stderr, fprintf, X86_DUMP_FPU);
 #else
-        cpu_dump_state(env, stderr, fprintf, 0);
+        cpu_dump_state(cpu->env_ptr, stderr, fprintf, 0);
 #endif
     }
     va_end(ap);
@@ -71,27 +71,28 @@
     }
 }
 
-static int cpu_can_run(CPUOldState *env)
+static int cpu_can_run(CPUArchState *env)
 {
-    if (env->stop)
+    CPUState *cpu = ENV_GET_CPU(env);
+    if (cpu->stop)
         return 0;
-    if (env->stopped)
+    if (cpu->stopped)
         return 0;
     return 1;
 }
 
 int tcg_has_work(void)
 {
-    CPUOldState *env;
+    CPUState *cpu;
 
-    CPU_FOREACH(env) {
-        if (env->stop)
+    CPU_FOREACH(cpu) {
+        if (cpu->stop)
             return 1;
-        if (env->stopped)
+        if (cpu->stopped)
             return 0;
-        if (!env->halted)
+        if (!cpu->halted)
             return 1;
-        if (cpu_has_work(env))
+        if (cpu_has_work(cpu))
             return 1;
         return 0;
     }
@@ -136,10 +137,10 @@
 
 void qemu_notify_event(void)
 {
-    CPUOldState *env = cpu_single_env;
+    CPUState *cpu = current_cpu;
 
-    if (env) {
-        cpu_exit(env);
+    if (cpu) {
+        cpu_exit(cpu->env_ptr);
     /*
      * This is mainly for the Windows host, where the timer may be in
      * a different thread with vcpu. Thus the timer function needs to
@@ -223,8 +224,9 @@
 
     if (next_cpu == NULL)
         next_cpu = QTAILQ_FIRST(&cpus);
-    for (; next_cpu != NULL; next_cpu = QTAILQ_NEXT(next_cpu, node)) {
-        CPUOldState *env = cur_cpu = next_cpu;
+    for (; next_cpu != NULL; next_cpu = QTAILQ_NEXT(next_cpu, node)) {\
+        cur_cpu = next_cpu;
+        CPUOldState *env = cur_cpu->env_ptr;
 
         if (!vm_running)
             break;