From 3643ed853bebcb434316a802c7362111c894e4d9 Mon Sep 17 00:00:00 2001
Message-Id: <3643ed853bebcb434316a802c7362111c894e4d9.1302295418.git.blauwirbel@gmail.com>
In-Reply-To: <6a1748c587d34b0ce37488596c68c4aee58a4638.1302295418.git.blauwirbel@gmail.com>
References: <6a1748c587d34b0ce37488596c68c4aee58a4638.1302295418.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Fri, 8 Apr 2011 19:59:13 +0000
Subject: [PATCH 11/11] Introduce CPU state
WIP
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
cpu-all.h | 1 +
cpu-state.h | 8 ++++++++
cpus.h | 38 ++++++++++++++++++++++++++++++++++++++
gdbstub.h | 1 +
hw/hw.h | 1 +
hw/omap.h | 2 ++
hw/smbios.c | 1 +
hw/soc_dma.h | 2 ++
hw/sun4m.h | 2 +-
kvm.h | 1 +
qemu-common.h | 26 --------------------------
qemu-timer.h | 17 -----------------
scripts/feature_to_c.sh | 2 +-
13 files changed, 57 insertions(+), 45 deletions(-)
create mode 100644 cpu-state.h
@@ -20,6 +20,7 @@
#define CPU_ALL_H
#include "qemu-common.h"
+#include "cpus.h"
#include "cpu-common.h"
/* some important defines:
new file mode 100644
@@ -0,0 +1,8 @@
+#ifndef QEMU_CPU_STATE_H
+#define QEMU_CPU_STATE_H
+/*
+ * CPU state: All generic state related to CPU emulation.
+ */
+
+
+#endif
@@ -1,6 +1,11 @@
#ifndef QEMU_CPUS_H
#define QEMU_CPUS_H
+/* FIXME: Remove NEED_CPU_H. */
+#ifdef NEED_CPU_H
+#include "cpu.h"
+#endif /* !defined(NEED_CPU_H) */
+
/* cpus.c */
int qemu_init_main_loop(void);
void qemu_main_loop_start(void);
@@ -21,4 +26,37 @@ void set_numa_modes(void);
void set_cpu_log(const char *optarg);
void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg);
+void cpu_exec_init_all(unsigned long tb_size);
+
+/* CPU save/load. */
+void cpu_save(QEMUFile *f, void *opaque);
+int cpu_load(QEMUFile *f, void *opaque, int version_id);
+
+/* Unblock cpu */
+void qemu_cpu_kick(void *env1);
+void qemu_cpu_kick_self(void);
+int qemu_cpu_is_self(void *env1);
+
+#ifdef CONFIG_USER_ONLY
+#define qemu_init_vcpu(env) do { } while (0)
+#else
+void qemu_init_vcpu(void *env1);
+#endif
+
+extern int use_icount;
+#ifdef NEED_CPU_H
+/* Deterministic execution requires that IO only be performed on the last
+ instruction of a TB so that interrupts take effect immediately. */
+static inline int can_do_io(CPUState *env)
+{
+ if (!use_icount)
+ return 1;
+
+ /* If not executing code then assume we are ok. */
+ if (!env->current_tb)
+ return 1;
+
+ return env->can_do_io != 0;
+}
+#endif
#endif
@@ -1,6 +1,7 @@
#ifndef GDBSTUB_H
#define GDBSTUB_H
+#include "cpus.h"
#define DEFAULT_GDBSTUB_PORT "1234"
/* GDB breakpoint/watchpoint types */
@@ -4,6 +4,7 @@
#include "qemu-common.h"
+#include "cpus.h"
#if defined(TARGET_PHYS_ADDR_BITS) && !defined(NEED_CPU_H)
#include "cpu-common.h"
#endif
@@ -19,6 +19,8 @@
#ifndef hw_omap_h
# define hw_omap_h "omap.h"
+#include "cpus.h"
+
# define OMAP_EMIFS_BASE 0x00000000
# define OMAP2_Q0_BASE 0x00000000
# define OMAP_CS0_BASE 0x00000000
@@ -11,6 +11,7 @@
*
*/
+#include "hw/hw.h"
#include "sysemu.h"
#include "smbios.h"
#include "loader.h"
@@ -18,6 +18,8 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/hw.h"
+
struct soc_dma_s;
struct soc_dma_ch_s;
typedef void (*soc_dma_io_t)(void *opaque, uint8_t *buf, int len);
@@ -1,7 +1,7 @@
#ifndef SUN4M_H
#define SUN4M_H
-#include "qemu-common.h"
+#include "hw/hw.h"
/* Devices used by sparc32 system. */
@@ -17,6 +17,7 @@
#include <errno.h>
#include "config-host.h"
#include "qemu-queue.h"
+#include "cpus.h"
#ifdef CONFIG_KVM
#include <linux/kvm.h>
@@ -120,19 +120,10 @@ static inline char *realpath(const char *path, char *resolved_path)
#define PRIo64 "I64o"
#endif
-/* FIXME: Remove NEED_CPU_H. */
-#ifndef NEED_CPU_H
-
#include <setjmp.h>
#include "osdep.h"
#include "bswap.h"
-#else
-
-#include "cpu.h"
-
-#endif /* !defined(NEED_CPU_H) */
-
/* bottom halves */
typedef void QEMUBHFunc(void *opaque);
@@ -293,23 +284,12 @@ typedef struct VirtIODevice VirtIODevice;
typedef uint64_t pcibus_t;
-void cpu_exec_init_all(unsigned long tb_size);
-
-/* CPU save/load. */
-void cpu_save(QEMUFile *f, void *opaque);
-int cpu_load(QEMUFile *f, void *opaque, int version_id);
-
/* Force QEMU to stop what it's doing and service IO */
void qemu_service_io(void);
/* Force QEMU to process pending events */
void qemu_notify_event(void);
-/* Unblock cpu */
-void qemu_cpu_kick(void *env);
-void qemu_cpu_kick_self(void);
-int qemu_cpu_is_self(void *env);
-
/* work queue */
struct qemu_work_item {
struct qemu_work_item *next;
@@ -318,12 +298,6 @@ struct qemu_work_item {
int done;
};
-#ifdef CONFIG_USER_ONLY
-#define qemu_init_vcpu(env) do { } while (0)
-#else
-void qemu_init_vcpu(void *env);
-#endif
-
typedef struct QEMUIOVector {
struct iovec *iov;
int niov;
@@ -149,7 +149,6 @@ void qemu_get_ptimer(QEMUFile *f, ptimer_state *s);
/* icount */
int64_t qemu_icount_round(int64_t count);
extern int64_t qemu_icount;
-extern int use_icount;
extern int icount_time_shift;
extern int64_t qemu_icount_bias;
int64_t cpu_get_icount(void);
@@ -308,22 +307,6 @@ static inline int64_t cpu_get_real_ticks (void)
}
#endif
-#ifdef NEED_CPU_H
-/* Deterministic execution requires that IO only be performed on the last
- instruction of a TB so that interrupts take effect immediately. */
-static inline int can_do_io(CPUState *env)
-{
- if (!use_icount)
- return 1;
-
- /* If not executing code then assume we are ok. */
- if (!env->current_tb)
- return 1;
-
- return env->can_do_io != 0;
-}
-#endif
-
#ifdef CONFIG_PROFILER
static inline int64_t profile_getclock(void)
{
@@ -37,7 +37,7 @@ for input; do
${AWK:-awk} 'BEGIN { n = 0
printf "#include \"config.h\"\n"
- printf "#include \"qemu-common.h\"\n"
+ printf "#include \"cpus.h\"\n"
printf "#include \"gdbstub.h\"\n"
print "static const char '$arrayname'[] = {"
for (i = 0; i < 255; i++)
--
1.7.2.5
WIP Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- cpu-all.h | 1 + cpu-state.h | 8 ++++++++ cpus.h | 38 ++++++++++++++++++++++++++++++++++++++ gdbstub.h | 1 + hw/hw.h | 1 + hw/omap.h | 2 ++ hw/smbios.c | 1 + hw/soc_dma.h | 2 ++ hw/sun4m.h | 2 +- kvm.h | 1 + qemu-common.h | 26 -------------------------- qemu-timer.h | 17 ----------------- scripts/feature_to_c.sh | 2 +- 13 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 cpu-state.h