Andreas Färber | dd83b06 | 2012-01-28 16:39:52 +0100 | [diff] [blame] | 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 | #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 | |
| 38 | typedef struct CPUState CPUState; |
| 39 | |
| 40 | /** |
| 41 | * CPUClass: |
Andreas Färber | f5df5ba | 2012-05-02 22:28:58 +0200 | [diff] [blame] | 42 | * @reset: Callback to reset the #CPUState to its initial state. |
Peter Maydell | ad41b6e | 2012-05-10 15:32:50 +0000 | [diff] [blame] | 43 | * @copy: Callback to create a new #CPUState as a copy of this one. |
Andreas Färber | dd83b06 | 2012-01-28 16:39:52 +0100 | [diff] [blame] | 44 | * |
| 45 | * Represents a CPU family or model. |
| 46 | */ |
| 47 | typedef struct CPUClass { |
| 48 | /*< private >*/ |
| 49 | ObjectClass parent_class; |
| 50 | /*< public >*/ |
| 51 | |
| 52 | void (*reset)(CPUState *cpu); |
Peter Maydell | ad41b6e | 2012-05-10 15:32:50 +0000 | [diff] [blame] | 53 | CPUState *(*copy)(CPUState *cpu); |
Andreas Färber | dd83b06 | 2012-01-28 16:39:52 +0100 | [diff] [blame] | 54 | } CPUClass; |
| 55 | |
| 56 | /** |
| 57 | * CPUState: |
| 58 | * |
| 59 | * State of one CPU core or thread. |
| 60 | */ |
| 61 | struct CPUState { |
| 62 | /*< private >*/ |
| 63 | Object parent_obj; |
| 64 | /*< public >*/ |
| 65 | |
Andreas Färber | f5df5ba | 2012-05-02 22:28:58 +0200 | [diff] [blame] | 66 | /* TODO Move common fields from CPUArchState here. */ |
Andreas Färber | dd83b06 | 2012-01-28 16:39:52 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * cpu_reset: |
| 72 | * @cpu: The CPU whose state is to be reset. |
| 73 | */ |
| 74 | void cpu_reset(CPUState *cpu); |
| 75 | |
Peter Maydell | ad41b6e | 2012-05-10 15:32:50 +0000 | [diff] [blame] | 76 | /** |
| 77 | * cpu_copy: |
| 78 | * @cpu: The CPU whose state is to be copied to create a new CPU state. |
| 79 | */ |
| 80 | CPUState *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 | */ |
| 89 | CPUState *cpu_default_copy(CPUState *oldcpu); |
Andreas Färber | dd83b06 | 2012-01-28 16:39:52 +0100 | [diff] [blame] | 90 | |
| 91 | #endif |