blob: e24d116c51c8dd4408be56d2db5b4f0c70096b32 [file] [log] [blame]
Andreas Färberdd83b062012-01-28 16:39:52 +01001/*
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#ifndef QEMU_CPU_H
21#define QEMU_CPU_H
22
23#include "qemu/object.h"
24
25/**
26 * SECTION:cpu
27 * @section_id: QEMU-cpu
28 * @title: CPU Class
29 * @short_description: Base class for all CPUs
30 */
31
32#define TYPE_CPU "cpu"
33
34#define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU)
35#define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)
36#define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU)
37
38typedef struct CPUState CPUState;
39
40/**
41 * CPUClass:
Andreas Färberf5df5ba2012-05-02 22:28:58 +020042 * @reset: Callback to reset the #CPUState to its initial state.
Peter Maydellad41b6e2012-05-10 15:32:50 +000043 * @copy: Callback to create a new #CPUState as a copy of this one.
Andreas Färberdd83b062012-01-28 16:39:52 +010044 *
45 * Represents a CPU family or model.
46 */
47typedef struct CPUClass {
48 /*< private >*/
49 ObjectClass parent_class;
50 /*< public >*/
51
52 void (*reset)(CPUState *cpu);
Peter Maydellad41b6e2012-05-10 15:32:50 +000053 CPUState *(*copy)(CPUState *cpu);
Andreas Färberdd83b062012-01-28 16:39:52 +010054} CPUClass;
55
56/**
57 * CPUState:
58 *
59 * State of one CPU core or thread.
60 */
61struct CPUState {
62 /*< private >*/
63 Object parent_obj;
64 /*< public >*/
65
Andreas Färberf5df5ba2012-05-02 22:28:58 +020066 /* TODO Move common fields from CPUArchState here. */
Andreas Färberdd83b062012-01-28 16:39:52 +010067};
68
69
70/**
71 * cpu_reset:
72 * @cpu: The CPU whose state is to be reset.
73 */
74void cpu_reset(CPUState *cpu);
75
Peter Maydellad41b6e2012-05-10 15:32:50 +000076/**
77 * cpu_copy:
78 * @cpu: The CPU whose state is to be copied to create a new CPU state.
79 */
80CPUState *cpu_copy(CPUState *cpu);
81
82/**
83 * cpu_default_copy:
84 * An implementation of the cpu_copy method suitable for
85 * use if the CPUClass subclass:
86 * (a) provides CPU_GET_ENV/ENV_GET_CPU macros in its cpu.h
87 * (b) has only members which can be safely shallow copied.
88 */
89CPUState *cpu_default_copy(CPUState *oldcpu);
Andreas Färberdd83b062012-01-28 16:39:52 +010090
91#endif