]> git.proxmox.com Git - qemu.git/blob - qom/cpu.c
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
[qemu.git] / qom / cpu.c
1 /*
2 * QEMU CPU model
3 *
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see
18 * <http://www.gnu.org/licenses/gpl-2.0.html>
19 */
20
21 #include "qom/cpu.h"
22 #include "qemu-common.h"
23
24 void cpu_reset_interrupt(CPUState *cpu, int mask)
25 {
26 cpu->interrupt_request &= ~mask;
27 }
28
29 void cpu_reset(CPUState *cpu)
30 {
31 CPUClass *klass = CPU_GET_CLASS(cpu);
32
33 if (klass->reset != NULL) {
34 (*klass->reset)(cpu);
35 }
36 }
37
38 static void cpu_common_reset(CPUState *cpu)
39 {
40 cpu->exit_request = 0;
41 cpu->interrupt_request = 0;
42 cpu->current_tb = NULL;
43 cpu->halted = 0;
44 }
45
46 ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
47 {
48 CPUClass *cc = CPU_CLASS(object_class_by_name(typename));
49
50 return cc->class_by_name(cpu_model);
51 }
52
53 static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
54 {
55 return NULL;
56 }
57
58 static void cpu_common_realizefn(DeviceState *dev, Error **errp)
59 {
60 }
61
62 static void cpu_class_init(ObjectClass *klass, void *data)
63 {
64 DeviceClass *dc = DEVICE_CLASS(klass);
65 CPUClass *k = CPU_CLASS(klass);
66
67 k->class_by_name = cpu_common_class_by_name;
68 k->reset = cpu_common_reset;
69 dc->realize = cpu_common_realizefn;
70 dc->no_user = 1;
71 }
72
73 static const TypeInfo cpu_type_info = {
74 .name = TYPE_CPU,
75 .parent = TYPE_DEVICE,
76 .instance_size = sizeof(CPUState),
77 .abstract = true,
78 .class_size = sizeof(CPUClass),
79 .class_init = cpu_class_init,
80 };
81
82 static void cpu_register_types(void)
83 {
84 type_register_static(&cpu_type_info);
85 }
86
87 type_init(cpu_register_types)