]> git.proxmox.com Git - qemu.git/blame - target-lm32/cpu.c
cpu: Move singlestep_enabled field from CPU_COMMON to CPUState
[qemu.git] / target-lm32 / cpu.c
CommitLineData
fc0ced2f
AF
1/*
2 * QEMU LatticeMico32 CPU
3 *
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/lgpl-2.1.html>
19 */
20
0347d689 21#include "cpu.h"
fc0ced2f
AF
22#include "qemu-common.h"
23
24
f45748f1
AF
25static void lm32_cpu_set_pc(CPUState *cs, vaddr value)
26{
27 LM32CPU *cpu = LM32_CPU(cs);
28
29 cpu->env.pc = value;
30}
31
fc0ced2f
AF
32/* CPUClass::reset() */
33static void lm32_cpu_reset(CPUState *s)
34{
35 LM32CPU *cpu = LM32_CPU(s);
36 LM32CPUClass *lcc = LM32_CPU_GET_CLASS(cpu);
37 CPULM32State *env = &cpu->env;
38
39 lcc->parent_reset(s);
40
3eab1690
AF
41 /* reset cpu state */
42 memset(env, 0, offsetof(CPULM32State, breakpoints));
a5b0f6d5
MW
43
44 tlb_flush(env, 1);
fc0ced2f
AF
45}
46
9c23169e
AF
47static void lm32_cpu_realizefn(DeviceState *dev, Error **errp)
48{
49 LM32CPU *cpu = LM32_CPU(dev);
50 LM32CPUClass *lcc = LM32_CPU_GET_CLASS(dev);
51
52 cpu_reset(CPU(cpu));
53
9c23169e
AF
54 lcc->parent_realize(dev, errp);
55}
56
8d7d505a
AF
57static void lm32_cpu_initfn(Object *obj)
58{
c05efcb1 59 CPUState *cs = CPU(obj);
8d7d505a
AF
60 LM32CPU *cpu = LM32_CPU(obj);
61 CPULM32State *env = &cpu->env;
868e2824 62 static bool tcg_initialized;
8d7d505a 63
c05efcb1 64 cs->env_ptr = env;
8d7d505a
AF
65 cpu_exec_init(env);
66
67 env->flags = 0;
868e2824
AF
68
69 if (tcg_enabled() && !tcg_initialized) {
70 tcg_initialized = true;
71 lm32_translate_init();
72 }
8d7d505a
AF
73}
74
fc0ced2f
AF
75static void lm32_cpu_class_init(ObjectClass *oc, void *data)
76{
77 LM32CPUClass *lcc = LM32_CPU_CLASS(oc);
78 CPUClass *cc = CPU_CLASS(oc);
9c23169e
AF
79 DeviceClass *dc = DEVICE_CLASS(oc);
80
81 lcc->parent_realize = dc->realize;
82 dc->realize = lm32_cpu_realizefn;
fc0ced2f
AF
83
84 lcc->parent_reset = cc->reset;
85 cc->reset = lm32_cpu_reset;
97a8ea5a
AF
86
87 cc->do_interrupt = lm32_cpu_do_interrupt;
878096ee 88 cc->dump_state = lm32_cpu_dump_state;
f45748f1 89 cc->set_pc = lm32_cpu_set_pc;
0ad6773f 90 cpu_class_set_vmsd(cc, &vmstate_lm32_cpu);
fc0ced2f
AF
91}
92
93static const TypeInfo lm32_cpu_type_info = {
94 .name = TYPE_LM32_CPU,
95 .parent = TYPE_CPU,
96 .instance_size = sizeof(LM32CPU),
8d7d505a 97 .instance_init = lm32_cpu_initfn,
fc0ced2f
AF
98 .abstract = false,
99 .class_size = sizeof(LM32CPUClass),
100 .class_init = lm32_cpu_class_init,
101};
102
103static void lm32_cpu_register_types(void)
104{
105 type_register_static(&lm32_cpu_type_info);
106}
107
108type_init(lm32_cpu_register_types)