net: stellaris_enet: check packet length against receive buffer
[qemu/ar7.git] / target-arm / cpu-qom.h
blob1061c08a102d48ae962c41ca2871d4fd7312a090
1 /*
2 * QEMU ARM CPU
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
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.
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.
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>
20 #ifndef QEMU_ARM_CPU_QOM_H
21 #define QEMU_ARM_CPU_QOM_H
23 #include "qom/cpu.h"
25 #define TYPE_ARM_CPU "arm-cpu"
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)
34 /**
35 * ARMCPUClass:
36 * @parent_realize: The parent class' realize handler.
37 * @parent_reset: The parent class' reset handler.
39 * An ARM CPU model.
41 typedef struct ARMCPUClass {
42 /*< private >*/
43 CPUClass parent_class;
44 /*< public >*/
46 DeviceRealize parent_realize;
47 void (*parent_reset)(CPUState *cpu);
48 } ARMCPUClass;
50 /**
51 * ARMCPU:
52 * @env: #CPUARMState
54 * An ARM CPU core.
56 typedef struct ARMCPU {
57 /*< private >*/
58 CPUState parent_obj;
59 /*< public >*/
61 CPUARMState env;
63 /* Coprocessor information */
64 GHashTable *cp_regs;
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.
69 /* List of register indexes managed via these arrays; (full KVM style
70 * 64 bit indexes, not CPRegInfo 32 bit indexes)
72 uint64_t *cpreg_indexes;
73 /* Values of the registers (cpreg_indexes[i]'s value is cpreg_values[i]) */
74 uint64_t *cpreg_values;
75 /* Length of the indexes, values, reset_values arrays */
76 int32_t cpreg_array_len;
77 /* These are used only for migration: incoming data arrives in
78 * these fields and is sanity checked in post_load before copying
79 * to the working data structures above.
81 uint64_t *cpreg_vmstate_indexes;
82 uint64_t *cpreg_vmstate_values;
83 int32_t cpreg_vmstate_array_len;
85 /* Timers used by the generic (architected) timer */
86 QEMUTimer *gt_timer[NUM_GTIMERS];
87 /* GPIO outputs for generic timer */
88 qemu_irq gt_timer_outputs[NUM_GTIMERS];
90 /* MemoryRegion to use for secure physical accesses */
91 MemoryRegion *secure_memory;
93 /* 'compatible' string for this CPU for Linux device trees */
94 const char *dtb_compatible;
96 /* PSCI version for this CPU
97 * Bits[31:16] = Major Version
98 * Bits[15:0] = Minor Version
100 uint32_t psci_version;
102 /* Should CPU start in PSCI powered-off state? */
103 bool start_powered_off;
104 /* CPU currently in PSCI powered-off state */
105 bool powered_off;
106 /* CPU has security extension */
107 bool has_el3;
109 /* CPU has memory protection unit */
110 bool has_mpu;
111 /* PMSAv7 MPU number of supported regions */
112 uint32_t pmsav7_dregion;
114 /* PSCI conduit used to invoke PSCI methods
115 * 0 - disabled, 1 - smc, 2 - hvc
117 uint32_t psci_conduit;
119 /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or
120 * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type.
122 uint32_t kvm_target;
124 /* KVM init features for this CPU */
125 uint32_t kvm_init_features[7];
127 /* Uniprocessor system with MP extensions */
128 bool mp_is_up;
130 /* The instance init functions for implementation-specific subclasses
131 * set these fields to specify the implementation-dependent values of
132 * various constant registers and reset values of non-constant
133 * registers.
134 * Some of these might become QOM properties eventually.
135 * Field names match the official register names as defined in the
136 * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix
137 * is used for reset values of non-constant registers; no reset_
138 * prefix means a constant register.
140 uint32_t midr;
141 uint32_t revidr;
142 uint32_t reset_fpsid;
143 uint32_t mvfr0;
144 uint32_t mvfr1;
145 uint32_t mvfr2;
146 uint32_t ctr;
147 uint32_t reset_sctlr;
148 uint32_t id_pfr0;
149 uint32_t id_pfr1;
150 uint32_t id_dfr0;
151 uint32_t pmceid0;
152 uint32_t pmceid1;
153 uint32_t id_afr0;
154 uint32_t id_mmfr0;
155 uint32_t id_mmfr1;
156 uint32_t id_mmfr2;
157 uint32_t id_mmfr3;
158 uint32_t id_mmfr4;
159 uint32_t id_isar0;
160 uint32_t id_isar1;
161 uint32_t id_isar2;
162 uint32_t id_isar3;
163 uint32_t id_isar4;
164 uint32_t id_isar5;
165 uint64_t id_aa64pfr0;
166 uint64_t id_aa64pfr1;
167 uint64_t id_aa64dfr0;
168 uint64_t id_aa64dfr1;
169 uint64_t id_aa64afr0;
170 uint64_t id_aa64afr1;
171 uint64_t id_aa64isar0;
172 uint64_t id_aa64isar1;
173 uint64_t id_aa64mmfr0;
174 uint64_t id_aa64mmfr1;
175 uint32_t dbgdidr;
176 uint32_t clidr;
177 uint64_t mp_affinity; /* MP ID without feature bits */
178 /* The elements of this array are the CCSIDR values for each cache,
179 * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc.
181 uint32_t ccsidr[16];
182 uint64_t reset_cbar;
183 uint32_t reset_auxcr;
184 bool reset_hivecs;
185 /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
186 uint32_t dcz_blocksize;
187 uint64_t rvbar;
188 } ARMCPU;
190 #define TYPE_AARCH64_CPU "aarch64-cpu"
191 #define AARCH64_CPU_CLASS(klass) \
192 OBJECT_CLASS_CHECK(AArch64CPUClass, (klass), TYPE_AARCH64_CPU)
193 #define AARCH64_CPU_GET_CLASS(obj) \
194 OBJECT_GET_CLASS(AArch64CPUClass, (obj), TYPE_AArch64_CPU)
196 typedef struct AArch64CPUClass {
197 /*< private >*/
198 ARMCPUClass parent_class;
199 /*< public >*/
200 } AArch64CPUClass;
202 static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
204 return container_of(env, ARMCPU, env);
207 #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
209 #define ENV_OFFSET offsetof(ARMCPU, env)
211 #ifndef CONFIG_USER_ONLY
212 extern const struct VMStateDescription vmstate_arm_cpu;
213 #endif
215 void register_cp_regs_for_features(ARMCPU *cpu);
216 void init_cpreg_list(ARMCPU *cpu);
218 void arm_cpu_do_interrupt(CPUState *cpu);
219 void arm_v7m_cpu_do_interrupt(CPUState *cpu);
220 bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
222 void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
223 int flags);
225 hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
226 MemTxAttrs *attrs);
228 int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
229 int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
231 int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
232 int cpuid, void *opaque);
233 int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
234 int cpuid, void *opaque);
236 /* Callback functions for the generic timer's timers. */
237 void arm_gt_ptimer_cb(void *opaque);
238 void arm_gt_vtimer_cb(void *opaque);
239 void arm_gt_htimer_cb(void *opaque);
240 void arm_gt_stimer_cb(void *opaque);
242 #define ARM_AFF0_SHIFT 0
243 #define ARM_AFF0_MASK (0xFFULL << ARM_AFF0_SHIFT)
244 #define ARM_AFF1_SHIFT 8
245 #define ARM_AFF1_MASK (0xFFULL << ARM_AFF1_SHIFT)
246 #define ARM_AFF2_SHIFT 16
247 #define ARM_AFF2_MASK (0xFFULL << ARM_AFF2_SHIFT)
248 #define ARM_AFF3_SHIFT 32
249 #define ARM_AFF3_MASK (0xFFULL << ARM_AFF3_SHIFT)
251 #define ARM32_AFFINITY_MASK (ARM_AFF0_MASK|ARM_AFF1_MASK|ARM_AFF2_MASK)
252 #define ARM64_AFFINITY_MASK \
253 (ARM_AFF0_MASK|ARM_AFF1_MASK|ARM_AFF2_MASK|ARM_AFF3_MASK)
255 #ifdef TARGET_AARCH64
256 int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
257 int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
258 #endif
260 #endif