]> git.proxmox.com Git - mirror_qemu.git/blame - target-arm/cpu-qom.h
hw/arm/musicpal: Avoid shifting left into sign bit
[mirror_qemu.git] / target-arm / cpu-qom.h
CommitLineData
dec9c2d4
AF
1/*
2 * QEMU ARM CPU
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_ARM_CPU_QOM_H
21#define QEMU_ARM_CPU_QOM_H
22
14cccb61 23#include "qom/cpu.h"
dec9c2d4
AF
24
25#define TYPE_ARM_CPU "arm-cpu"
26
27#define ARM_CPU_CLASS(klass) \
28 OBJECT_CLASS_CHECK(ARMCPUClass, (klass), TYPE_ARM_CPU)
29#define ARM_CPU(obj) \
30 OBJECT_CHECK(ARMCPU, (obj), TYPE_ARM_CPU)
31#define ARM_CPU_GET_CLASS(obj) \
32 OBJECT_GET_CLASS(ARMCPUClass, (obj), TYPE_ARM_CPU)
33
34/**
35 * ARMCPUClass:
14969266 36 * @parent_realize: The parent class' realize handler.
dec9c2d4
AF
37 * @parent_reset: The parent class' reset handler.
38 *
39 * An ARM CPU model.
40 */
41typedef struct ARMCPUClass {
42 /*< private >*/
43 CPUClass parent_class;
44 /*< public >*/
45
14969266 46 DeviceRealize parent_realize;
dec9c2d4
AF
47 void (*parent_reset)(CPUState *cpu);
48} ARMCPUClass;
49
50/**
51 * ARMCPU:
52 * @env: #CPUARMState
53 *
54 * An ARM CPU core.
55 */
56typedef struct ARMCPU {
57 /*< private >*/
58 CPUState parent_obj;
59 /*< public >*/
60
61 CPUARMState env;
777dc784 62
4b6a83fb
PM
63 /* Coprocessor information */
64 GHashTable *cp_regs;
721fae12
PM
65 /* For marshalling (mostly coprocessor) register state between the
66 * kernel and QEMU (for KVM) and between two QEMUs (for migration),
67 * we use these arrays.
68 */
69 /* List of register indexes managed via these arrays; (full KVM style
70 * 64 bit indexes, not CPRegInfo 32 bit indexes)
71 */
72 uint64_t *cpreg_indexes;
73 /* Values of the registers (cpreg_indexes[i]'s value is cpreg_values[i]) */
74 uint64_t *cpreg_values;
2d8e5a0e
PM
75 /* When using KVM, keeps a copy of the initial state of the VCPU,
76 * so that on reset we can feed the reset values back into the kernel.
77 */
78 uint64_t *cpreg_reset_values;
79 /* Length of the indexes, values, reset_values arrays */
721fae12
PM
80 int32_t cpreg_array_len;
81 /* These are used only for migration: incoming data arrives in
82 * these fields and is sanity checked in post_load before copying
83 * to the working data structures above.
84 */
85 uint64_t *cpreg_vmstate_indexes;
86 uint64_t *cpreg_vmstate_values;
87 int32_t cpreg_vmstate_array_len;
4b6a83fb 88
55d284af
PM
89 /* Timers used by the generic (architected) timer */
90 QEMUTimer *gt_timer[NUM_GTIMERS];
91 /* GPIO outputs for generic timer */
92 qemu_irq gt_timer_outputs[NUM_GTIMERS];
93
54d3e3f5
PM
94 /* 'compatible' string for this CPU for Linux device trees */
95 const char *dtb_compatible;
96
5de16430
PM
97 /* Should CPU start in PSCI powered-off state? */
98 bool start_powered_off;
99
3541addc
PM
100 /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or
101 * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type.
102 */
103 uint32_t kvm_target;
104
777dc784
PM
105 /* The instance init functions for implementation-specific subclasses
106 * set these fields to specify the implementation-dependent values of
107 * various constant registers and reset values of non-constant
108 * registers.
109 * Some of these might become QOM properties eventually.
110 * Field names match the official register names as defined in the
111 * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix
112 * is used for reset values of non-constant registers; no reset_
113 * prefix means a constant register.
114 */
115 uint32_t midr;
325b3cef 116 uint32_t reset_fpsid;
bd35c355
PM
117 uint32_t mvfr0;
118 uint32_t mvfr1;
64e1671f 119 uint32_t ctr;
0ca7e01c 120 uint32_t reset_sctlr;
2e4d7e3e
PM
121 uint32_t id_pfr0;
122 uint32_t id_pfr1;
123 uint32_t id_dfr0;
124 uint32_t id_afr0;
125 uint32_t id_mmfr0;
126 uint32_t id_mmfr1;
127 uint32_t id_mmfr2;
128 uint32_t id_mmfr3;
129 uint32_t id_isar0;
130 uint32_t id_isar1;
131 uint32_t id_isar2;
132 uint32_t id_isar3;
133 uint32_t id_isar4;
134 uint32_t id_isar5;
e60cef86
PM
135 uint64_t id_aa64pfr0;
136 uint64_t id_aa64pfr1;
137 uint64_t id_aa64dfr0;
138 uint64_t id_aa64dfr1;
139 uint64_t id_aa64afr0;
140 uint64_t id_aa64afr1;
141 uint64_t id_aa64isar0;
142 uint64_t id_aa64isar1;
143 uint64_t id_aa64mmfr0;
144 uint64_t id_aa64mmfr1;
85df3786
PM
145 uint32_t clidr;
146 /* The elements of this array are the CCSIDR values for each cache,
147 * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc.
148 */
149 uint32_t ccsidr[16];
c5fad12f 150 uint32_t reset_cbar;
2771db27 151 uint32_t reset_auxcr;
68e0a40a 152 bool reset_hivecs;
dec9c2d4
AF
153} ARMCPU;
154
d14d42f1
PM
155#define TYPE_AARCH64_CPU "aarch64-cpu"
156#define AARCH64_CPU_CLASS(klass) \
157 OBJECT_CLASS_CHECK(AArch64CPUClass, (klass), TYPE_AARCH64_CPU)
158#define AARCH64_CPU_GET_CLASS(obj) \
159 OBJECT_GET_CLASS(AArch64CPUClass, (obj), TYPE_AArch64_CPU)
160
161typedef struct AArch64CPUClass {
162 /*< private >*/
163 ARMCPUClass parent_class;
164 /*< public >*/
165} AArch64CPUClass;
166
dec9c2d4
AF
167static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
168{
6e42be7c 169 return container_of(env, ARMCPU, env);
dec9c2d4
AF
170}
171
172#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
173
fadf9825
AF
174#define ENV_OFFSET offsetof(ARMCPU, env)
175
3cc1d208
JQ
176#ifndef CONFIG_USER_ONLY
177extern const struct VMStateDescription vmstate_arm_cpu;
178#endif
179
2ceb98c0 180void register_cp_regs_for_features(ARMCPU *cpu);
721fae12 181void init_cpreg_list(ARMCPU *cpu);
dec9c2d4 182
97a8ea5a 183void arm_cpu_do_interrupt(CPUState *cpu);
e6f010cc 184void arm_v7m_cpu_do_interrupt(CPUState *cpu);
97a8ea5a 185
878096ee
AF
186void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
187 int flags);
188
00b941e5
AF
189hwaddr arm_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
190
5b50e790
AF
191int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
192int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
193
55d284af
PM
194/* Callback functions for the generic timer's timers. */
195void arm_gt_ptimer_cb(void *opaque);
196void arm_gt_vtimer_cb(void *opaque);
197
14ade10f
AG
198#ifdef TARGET_AARCH64
199void aarch64_cpu_dump_state(CPUState *cs, FILE *f,
200 fprintf_function cpu_fprintf, int flags);
96c04212
AG
201int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
202int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
14ade10f
AG
203#endif
204
dec9c2d4 205#endif