aboutsummaryrefslogtreecommitdiff
path: root/target-m68k
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
parent7d77bf200682ed8cbd0c94bdfbac64dc4b23b149 (diff)
downloadqemu-aaed909a495e78364abc6812df672d2e764961a8.zip
qemu-aaed909a495e78364abc6812df672d2e764961a8.tar.gz
qemu-aaed909a495e78364abc6812df672d2e764961a8.tar.bz2
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')
-rw-r--r--target-m68k/cpu.h10
-rw-r--r--target-m68k/helper.c43
-rw-r--r--target-m68k/translate.c32
3 files changed, 43 insertions, 42 deletions
diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h
index 5004a91..732929b 100644
--- a/target-m68k/cpu.h
+++ b/target-m68k/cpu.h
@@ -100,8 +100,6 @@ typedef struct CPUM68KState {
uint32_t rambar0;
uint32_t cacr;
- uint32_t features;
-
/* ??? remove this. */
uint32_t t1;
@@ -118,9 +116,11 @@ typedef struct CPUM68KState {
uint32_t qregs[MAX_QREGS];
CPU_COMMON
+
+ uint32_t features;
} CPUM68KState;
-CPUM68KState *cpu_m68k_init(void);
+CPUM68KState *cpu_m68k_init(const char *cpu_model);
int cpu_m68k_exec(CPUM68KState *s);
void cpu_m68k_close(CPUM68KState *s);
void do_interrupt(int is_hw);
@@ -174,10 +174,6 @@ enum {
#define MACSR_V 0x002
#define MACSR_EV 0x001
-typedef struct m68k_def_t m68k_def_t;
-
-int cpu_m68k_set_model(CPUM68KState *env, const char * name);
-
void m68k_set_irq_level(CPUM68KState *env, int level, uint8_t vector);
void m68k_set_macsr(CPUM68KState *env, uint32_t val);
void m68k_switch_sp(CPUM68KState *env);
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index f3c6299..8fef672 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)
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index f6b4fad..499f053 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -3279,38 +3279,6 @@ int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
return gen_intermediate_code_internal(env, tb, 1);
}
-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);
-}
-
-CPUM68KState *cpu_m68k_init(void)
-{
- CPUM68KState *env;
-
- env = malloc(sizeof(CPUM68KState));
- if (!env)
- return NULL;
- cpu_exec_init(env);
-
- cpu_reset(env);
- return env;
-}
-
-void cpu_m68k_close(CPUM68KState *env)
-{
- free(env);
-}
-
void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)