aboutsummaryrefslogtreecommitdiff
path: root/target-m68k/helper.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-10 15:15:54 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-10 15:15:54 +0000
commitaaed909a495e78364abc6812df672d2e764961a8 (patch)
tree704ab4280f250fa310bee6a3d0ba94e5417daef3 /target-m68k/helper.c
parent7d77bf200682ed8cbd0c94bdfbac64dc4b23b149 (diff)
added cpu_model parameter to cpu_init()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3562 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-m68k/helper.c')
-rw-r--r--target-m68k/helper.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index f3c629979d..8fef672264 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -33,6 +33,8 @@ enum m68k_cpuid {
M68K_CPUID_ANY,
};
+typedef struct m68k_def_t m68k_def_t;
+
struct m68k_def_t {
const char * name;
enum m68k_cpuid id;
@@ -51,7 +53,7 @@ static void m68k_set_feature(CPUM68KState *env, int feature)
env->features |= (1u << feature);
}
-int cpu_m68k_set_model(CPUM68KState *env, const char * name)
+static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
{
m68k_def_t *def;
@@ -60,7 +62,7 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name)
break;
}
if (!def->name)
- return 1;
+ return -1;
switch (def->id) {
case M68K_CPUID_M5206:
@@ -98,8 +100,43 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name)
}
register_m68k_insns(env);
+}
+
+void cpu_reset(CPUM68KState *env)
+{
+ memset(env, 0, offsetof(CPUM68KState, breakpoints));
+#if !defined (CONFIG_USER_ONLY)
+ env->sr = 0x2700;
+#endif
+ m68k_switch_sp(env);
+ /* ??? FP regs should be initialized to NaN. */
+ env->cc_op = CC_OP_FLAGS;
+ /* TODO: We should set PC from the interrupt vector. */
+ env->pc = 0;
+ tlb_flush(env, 1);
+}
- return 0;
+CPUM68KState *cpu_m68k_init(const char *cpu_model)
+{
+ CPUM68KState *env;
+
+ env = malloc(sizeof(CPUM68KState));
+ if (!env)
+ return NULL;
+ cpu_exec_init(env);
+
+ if (cpu_m68k_set_model(env, cpu_model) < 0) {
+ cpu_m68k_close(env);
+ return NULL;
+ }
+
+ cpu_reset(env);
+ return env;
+}
+
+void cpu_m68k_close(CPUM68KState *env)
+{
+ qemu_free(env);
}
void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op)