1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "cpu.h"
25#include "qemu-common.h"
26#include "mmu.h"
27
28
29
30static void cris_cpu_reset(CPUState *s)
31{
32 CRISCPU *cpu = CRIS_CPU(s);
33 CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(cpu);
34 CPUCRISState *env = &cpu->env;
35 uint32_t vr;
36
37 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
38 qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
39 log_cpu_state(env, 0);
40 }
41
42 ccc->parent_reset(s);
43
44 vr = env->pregs[PR_VR];
45 memset(env, 0, offsetof(CPUCRISState, breakpoints));
46 env->pregs[PR_VR] = vr;
47 tlb_flush(env, 1);
48
49#if defined(CONFIG_USER_ONLY)
50
51 env->pregs[PR_CCS] |= U_FLAG | I_FLAG | P_FLAG;
52#else
53 cris_mmu_init(env);
54 env->pregs[PR_CCS] = 0;
55#endif
56}
57
58static void cris_cpu_initfn(Object *obj)
59{
60 CRISCPU *cpu = CRIS_CPU(obj);
61 CPUCRISState *env = &cpu->env;
62
63 cpu_exec_init(env);
64}
65
66static void cris_cpu_class_init(ObjectClass *oc, void *data)
67{
68 CPUClass *cc = CPU_CLASS(oc);
69 CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
70
71 ccc->parent_reset = cc->reset;
72 cc->reset = cris_cpu_reset;
73}
74
75static const TypeInfo cris_cpu_type_info = {
76 .name = TYPE_CRIS_CPU,
77 .parent = TYPE_CPU,
78 .instance_size = sizeof(CRISCPU),
79 .instance_init = cris_cpu_initfn,
80 .abstract = false,
81 .class_size = sizeof(CRISCPUClass),
82 .class_init = cris_cpu_class_init,
83};
84
85static void cris_cpu_register_types(void)
86{
87 type_register_static(&cris_cpu_type_info);
88}
89
90type_init(cris_cpu_register_types)
91