]>
Commit | Line | Data |
---|---|---|
339894be AF |
1 | /* |
2 | * QEMU SuperH CPU | |
3 | * | |
c4bb0f99 | 4 | * Copyright (c) 2005 Samuel Tardieu |
339894be AF |
5 | * Copyright (c) 2012 SUSE LINUX Products GmbH |
6 | * | |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2.1 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
18 | * License along with this library; if not, see | |
19 | * <http://www.gnu.org/licenses/lgpl-2.1.html> | |
20 | */ | |
21 | ||
22 | #include "cpu.h" | |
23 | #include "qemu-common.h" | |
1e45d31b | 24 | #include "migration/vmstate.h" |
339894be AF |
25 | |
26 | ||
27 | /* CPUClass::reset() */ | |
28 | static void superh_cpu_reset(CPUState *s) | |
29 | { | |
30 | SuperHCPU *cpu = SUPERH_CPU(s); | |
31 | SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(cpu); | |
32 | CPUSH4State *env = &cpu->env; | |
33 | ||
c4bb0f99 | 34 | if (qemu_loglevel_mask(CPU_LOG_RESET)) { |
55e5c285 | 35 | qemu_log("CPU Reset (CPU %d)\n", s->cpu_index); |
c4bb0f99 AF |
36 | log_cpu_state(env, 0); |
37 | } | |
38 | ||
339894be AF |
39 | scc->parent_reset(s); |
40 | ||
c4bb0f99 AF |
41 | memset(env, 0, offsetof(CPUSH4State, breakpoints)); |
42 | tlb_flush(env, 1); | |
43 | ||
44 | env->pc = 0xA0000000; | |
45 | #if defined(CONFIG_USER_ONLY) | |
46 | env->fpscr = FPSCR_PR; /* value for userspace according to the kernel */ | |
47 | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); /* ?! */ | |
48 | #else | |
49 | env->sr = SR_MD | SR_RB | SR_BL | SR_I3 | SR_I2 | SR_I1 | SR_I0; | |
50 | env->fpscr = FPSCR_DN | FPSCR_RM_ZERO; /* CPU reset value according to SH4 manual */ | |
51 | set_float_rounding_mode(float_round_to_zero, &env->fp_status); | |
52 | set_flush_to_zero(1, &env->fp_status); | |
53 | #endif | |
54 | set_default_nan_mode(1, &env->fp_status); | |
339894be AF |
55 | } |
56 | ||
55acb588 AF |
57 | static void superh_cpu_realizefn(DeviceState *dev, Error **errp) |
58 | { | |
59 | SuperHCPU *cpu = SUPERH_CPU(dev); | |
60 | SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev); | |
61 | ||
62 | cpu_reset(CPU(cpu)); | |
63 | qemu_init_vcpu(&cpu->env); | |
64 | ||
65 | scc->parent_realize(dev, errp); | |
66 | } | |
67 | ||
2b4b4906 AF |
68 | static void superh_cpu_initfn(Object *obj) |
69 | { | |
c05efcb1 | 70 | CPUState *cs = CPU(obj); |
2b4b4906 AF |
71 | SuperHCPU *cpu = SUPERH_CPU(obj); |
72 | CPUSH4State *env = &cpu->env; | |
73 | ||
c05efcb1 | 74 | cs->env_ptr = env; |
2b4b4906 AF |
75 | cpu_exec_init(env); |
76 | ||
77 | env->movcal_backup_tail = &(env->movcal_backup); | |
aa7408ec AF |
78 | |
79 | if (tcg_enabled()) { | |
80 | sh4_translate_init(); | |
81 | } | |
2b4b4906 AF |
82 | } |
83 | ||
1e45d31b AF |
84 | static const VMStateDescription vmstate_sh_cpu = { |
85 | .name = "cpu", | |
86 | .unmigratable = 1, | |
87 | }; | |
88 | ||
339894be AF |
89 | static void superh_cpu_class_init(ObjectClass *oc, void *data) |
90 | { | |
1e45d31b | 91 | DeviceClass *dc = DEVICE_CLASS(oc); |
339894be AF |
92 | CPUClass *cc = CPU_CLASS(oc); |
93 | SuperHCPUClass *scc = SUPERH_CPU_CLASS(oc); | |
94 | ||
55acb588 AF |
95 | scc->parent_realize = dc->realize; |
96 | dc->realize = superh_cpu_realizefn; | |
97 | ||
339894be AF |
98 | scc->parent_reset = cc->reset; |
99 | cc->reset = superh_cpu_reset; | |
1e45d31b AF |
100 | |
101 | dc->vmsd = &vmstate_sh_cpu; | |
339894be AF |
102 | } |
103 | ||
104 | static const TypeInfo superh_cpu_type_info = { | |
105 | .name = TYPE_SUPERH_CPU, | |
106 | .parent = TYPE_CPU, | |
107 | .instance_size = sizeof(SuperHCPU), | |
2b4b4906 | 108 | .instance_init = superh_cpu_initfn, |
339894be AF |
109 | .abstract = false, |
110 | .class_size = sizeof(SuperHCPUClass), | |
111 | .class_init = superh_cpu_class_init, | |
112 | }; | |
113 | ||
114 | static void superh_cpu_register_types(void) | |
115 | { | |
116 | type_register_static(&superh_cpu_type_info); | |
117 | } | |
118 | ||
119 | type_init(superh_cpu_register_types) |