| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU ARM CPU | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2012 SUSE LINUX Products GmbH | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, see | 
					
						
							|  |  |  |  * <http://www.gnu.org/licenses/gpl-2.0.html>
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef QEMU_ARM_CPU_QOM_H
 | 
					
						
							|  |  |  | #define QEMU_ARM_CPU_QOM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-17 18:19:50 +01:00
										 |  |  | #include "qom/cpu.h"
 | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define TYPE_ARM_CPU "arm-cpu"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define ARM_CPU_CLASS(klass) \
 | 
					
						
							|  |  |  |     OBJECT_CLASS_CHECK(ARMCPUClass, (klass), TYPE_ARM_CPU) | 
					
						
							|  |  |  | #define ARM_CPU(obj) \
 | 
					
						
							|  |  |  |     OBJECT_CHECK(ARMCPU, (obj), TYPE_ARM_CPU) | 
					
						
							|  |  |  | #define ARM_CPU_GET_CLASS(obj) \
 | 
					
						
							|  |  |  |     OBJECT_GET_CLASS(ARMCPUClass, (obj), TYPE_ARM_CPU) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * ARMCPUClass: | 
					
						
							| 
									
										
										
										
											2013-01-05 10:18:18 +01:00
										 |  |  |  * @parent_realize: The parent class' realize handler. | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  |  * @parent_reset: The parent class' reset handler. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * An ARM CPU model. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | typedef struct ARMCPUClass { | 
					
						
							|  |  |  |     /*< private >*/ | 
					
						
							|  |  |  |     CPUClass parent_class; | 
					
						
							|  |  |  |     /*< public >*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-05 10:18:18 +01:00
										 |  |  |     DeviceRealize parent_realize; | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  |     void (*parent_reset)(CPUState *cpu); | 
					
						
							|  |  |  | } ARMCPUClass; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * ARMCPU: | 
					
						
							|  |  |  |  * @env: #CPUARMState | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * An ARM CPU core. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | typedef struct ARMCPU { | 
					
						
							|  |  |  |     /*< private >*/ | 
					
						
							|  |  |  |     CPUState parent_obj; | 
					
						
							|  |  |  |     /*< public >*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CPUARMState env; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-20 11:57:06 +00:00
										 |  |  |     /* Coprocessor information */ | 
					
						
							|  |  |  |     GHashTable *cp_regs; | 
					
						
							| 
									
										
										
										
											2013-06-25 18:16:07 +01:00
										 |  |  |     /* For marshalling (mostly coprocessor) register state between the
 | 
					
						
							|  |  |  |      * kernel and QEMU (for KVM) and between two QEMUs (for migration), | 
					
						
							|  |  |  |      * we use these arrays. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     /* List of register indexes managed via these arrays; (full KVM style
 | 
					
						
							|  |  |  |      * 64 bit indexes, not CPRegInfo 32 bit indexes) | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint64_t *cpreg_indexes; | 
					
						
							|  |  |  |     /* Values of the registers (cpreg_indexes[i]'s value is cpreg_values[i]) */ | 
					
						
							|  |  |  |     uint64_t *cpreg_values; | 
					
						
							| 
									
										
										
										
											2013-06-25 18:16:07 +01:00
										 |  |  |     /* Length of the indexes, values, reset_values arrays */ | 
					
						
							| 
									
										
										
										
											2013-06-25 18:16:07 +01:00
										 |  |  |     int32_t cpreg_array_len; | 
					
						
							|  |  |  |     /* These are used only for migration: incoming data arrives in
 | 
					
						
							|  |  |  |      * these fields and is sanity checked in post_load before copying | 
					
						
							|  |  |  |      * to the working data structures above. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint64_t *cpreg_vmstate_indexes; | 
					
						
							|  |  |  |     uint64_t *cpreg_vmstate_values; | 
					
						
							|  |  |  |     int32_t cpreg_vmstate_array_len; | 
					
						
							| 
									
										
										
										
											2012-06-20 11:57:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-20 14:54:31 +01:00
										 |  |  |     /* Timers used by the generic (architected) timer */ | 
					
						
							|  |  |  |     QEMUTimer *gt_timer[NUM_GTIMERS]; | 
					
						
							|  |  |  |     /* GPIO outputs for generic timer */ | 
					
						
							|  |  |  |     qemu_irq gt_timer_outputs[NUM_GTIMERS]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-22 17:17:12 +00:00
										 |  |  |     /* 'compatible' string for this CPU for Linux device trees */ | 
					
						
							|  |  |  |     const char *dtb_compatible; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-19 18:06:26 +01:00
										 |  |  |     /* PSCI version for this CPU
 | 
					
						
							|  |  |  |      * Bits[31:16] = Major Version | 
					
						
							|  |  |  |      * Bits[15:0] = Minor Version | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint32_t psci_version; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-22 17:17:13 +00:00
										 |  |  |     /* Should CPU start in PSCI powered-off state? */ | 
					
						
							|  |  |  |     bool start_powered_off; | 
					
						
							| 
									
										
										
										
											2014-10-24 12:19:12 +01:00
										 |  |  |     /* CPU currently in PSCI powered-off state */ | 
					
						
							|  |  |  |     bool powered_off; | 
					
						
							| 
									
										
										
										
											2014-12-15 17:09:46 -06:00
										 |  |  |     /* CPU has security extension */ | 
					
						
							|  |  |  |     bool has_el3; | 
					
						
							| 
									
										
										
										
											2013-11-22 17:17:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-24 12:19:13 +01:00
										 |  |  |     /* PSCI conduit used to invoke PSCI methods
 | 
					
						
							|  |  |  |      * 0 - disabled, 1 - smc, 2 - hvc | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint32_t psci_conduit; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-22 17:17:16 +00:00
										 |  |  |     /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or
 | 
					
						
							|  |  |  |      * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint32_t kvm_target; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-19 18:06:26 +01:00
										 |  |  |     /* KVM init features for this CPU */ | 
					
						
							|  |  |  |     uint32_t kvm_init_features[7]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-15 18:06:10 +01:00
										 |  |  |     /* Uniprocessor system with MP extensions */ | 
					
						
							|  |  |  |     bool mp_is_up; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:31 +00:00
										 |  |  |     /* The instance init functions for implementation-specific subclasses
 | 
					
						
							|  |  |  |      * set these fields to specify the implementation-dependent values of | 
					
						
							|  |  |  |      * various constant registers and reset values of non-constant | 
					
						
							|  |  |  |      * registers. | 
					
						
							|  |  |  |      * Some of these might become QOM properties eventually. | 
					
						
							|  |  |  |      * Field names match the official register names as defined in the | 
					
						
							|  |  |  |      * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix | 
					
						
							|  |  |  |      * is used for reset values of non-constant registers; no reset_ | 
					
						
							|  |  |  |      * prefix means a constant register. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint32_t midr; | 
					
						
							| 
									
										
										
										
											2015-06-15 18:06:08 +01:00
										 |  |  |     uint32_t revidr; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:32 +00:00
										 |  |  |     uint32_t reset_fpsid; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:32 +00:00
										 |  |  |     uint32_t mvfr0; | 
					
						
							|  |  |  |     uint32_t mvfr1; | 
					
						
							| 
									
										
										
										
											2014-04-15 19:18:44 +01:00
										 |  |  |     uint32_t mvfr2; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:33 +00:00
										 |  |  |     uint32_t ctr; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:33 +00:00
										 |  |  |     uint32_t reset_sctlr; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:34 +00:00
										 |  |  |     uint32_t id_pfr0; | 
					
						
							|  |  |  |     uint32_t id_pfr1; | 
					
						
							|  |  |  |     uint32_t id_dfr0; | 
					
						
							|  |  |  |     uint32_t id_afr0; | 
					
						
							|  |  |  |     uint32_t id_mmfr0; | 
					
						
							|  |  |  |     uint32_t id_mmfr1; | 
					
						
							|  |  |  |     uint32_t id_mmfr2; | 
					
						
							|  |  |  |     uint32_t id_mmfr3; | 
					
						
							|  |  |  |     uint32_t id_isar0; | 
					
						
							|  |  |  |     uint32_t id_isar1; | 
					
						
							|  |  |  |     uint32_t id_isar2; | 
					
						
							|  |  |  |     uint32_t id_isar3; | 
					
						
							|  |  |  |     uint32_t id_isar4; | 
					
						
							|  |  |  |     uint32_t id_isar5; | 
					
						
							| 
									
										
										
										
											2014-02-26 17:20:05 +00:00
										 |  |  |     uint64_t id_aa64pfr0; | 
					
						
							|  |  |  |     uint64_t id_aa64pfr1; | 
					
						
							|  |  |  |     uint64_t id_aa64dfr0; | 
					
						
							|  |  |  |     uint64_t id_aa64dfr1; | 
					
						
							|  |  |  |     uint64_t id_aa64afr0; | 
					
						
							|  |  |  |     uint64_t id_aa64afr1; | 
					
						
							|  |  |  |     uint64_t id_aa64isar0; | 
					
						
							|  |  |  |     uint64_t id_aa64isar1; | 
					
						
							|  |  |  |     uint64_t id_aa64mmfr0; | 
					
						
							|  |  |  |     uint64_t id_aa64mmfr1; | 
					
						
							| 
									
										
										
										
											2014-08-19 18:56:25 +01:00
										 |  |  |     uint32_t dbgdidr; | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:35 +00:00
										 |  |  |     uint32_t clidr; | 
					
						
							| 
									
										
										
										
											2015-06-15 18:06:09 +01:00
										 |  |  |     uint64_t mp_affinity; /* MP ID without feature bits */ | 
					
						
							| 
									
										
										
										
											2012-04-20 17:58:35 +00:00
										 |  |  |     /* The elements of this array are the CCSIDR values for each cache,
 | 
					
						
							|  |  |  |      * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     uint32_t ccsidr[16]; | 
					
						
							| 
									
										
										
										
											2014-04-15 19:18:49 +01:00
										 |  |  |     uint64_t reset_cbar; | 
					
						
							| 
									
										
										
										
											2012-06-20 11:57:18 +00:00
										 |  |  |     uint32_t reset_auxcr; | 
					
						
							| 
									
										
										
										
											2013-12-17 19:42:29 +00:00
										 |  |  |     bool reset_hivecs; | 
					
						
							| 
									
										
										
										
											2014-04-15 19:18:41 +01:00
										 |  |  |     /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | 
					
						
							|  |  |  |     uint32_t dcz_blocksize; | 
					
						
							| 
									
										
										
										
											2014-04-15 19:18:48 +01:00
										 |  |  |     uint64_t rvbar; | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | } ARMCPU; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-03 20:12:07 +01:00
										 |  |  | #define TYPE_AARCH64_CPU "aarch64-cpu"
 | 
					
						
							|  |  |  | #define AARCH64_CPU_CLASS(klass) \
 | 
					
						
							|  |  |  |     OBJECT_CLASS_CHECK(AArch64CPUClass, (klass), TYPE_AARCH64_CPU) | 
					
						
							|  |  |  | #define AARCH64_CPU_GET_CLASS(obj) \
 | 
					
						
							|  |  |  |     OBJECT_GET_CLASS(AArch64CPUClass, (obj), TYPE_AArch64_CPU) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct AArch64CPUClass { | 
					
						
							|  |  |  |     /*< private >*/ | 
					
						
							|  |  |  |     ARMCPUClass parent_class; | 
					
						
							|  |  |  |     /*< public >*/ | 
					
						
							|  |  |  | } AArch64CPUClass; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-10 16:34:06 +02:00
										 |  |  |     return container_of(env, ARMCPU, env); | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-22 18:10:01 +00:00
										 |  |  | #define ENV_OFFSET offsetof(ARMCPU, env)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-19 12:24:19 +01:00
										 |  |  | #ifndef CONFIG_USER_ONLY
 | 
					
						
							|  |  |  | extern const struct VMStateDescription vmstate_arm_cpu; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-20 11:57:09 +00:00
										 |  |  | void register_cp_regs_for_features(ARMCPU *cpu); | 
					
						
							| 
									
										
										
										
											2013-06-25 18:16:07 +01:00
										 |  |  | void init_cpreg_list(ARMCPU *cpu); | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-02 10:57:51 +01:00
										 |  |  | void arm_cpu_do_interrupt(CPUState *cpu); | 
					
						
							| 
									
										
										
										
											2013-02-02 12:33:14 +01:00
										 |  |  | void arm_v7m_cpu_do_interrupt(CPUState *cpu); | 
					
						
							| 
									
										
										
										
											2014-09-13 09:45:25 -07:00
										 |  |  | bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); | 
					
						
							| 
									
										
										
										
											2013-02-02 10:57:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-27 01:33:50 +02:00
										 |  |  | void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, | 
					
						
							|  |  |  |                         int flags); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-29 18:55:54 +02:00
										 |  |  | hwaddr arm_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-29 04:18:45 +02:00
										 |  |  | int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); | 
					
						
							|  |  |  | int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-20 14:54:31 +01:00
										 |  |  | /* Callback functions for the generic timer's timers. */ | 
					
						
							|  |  |  | void arm_gt_ptimer_cb(void *opaque); | 
					
						
							|  |  |  | void arm_gt_vtimer_cb(void *opaque); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-03 20:12:10 +01:00
										 |  |  | #ifdef TARGET_AARCH64
 | 
					
						
							| 
									
										
										
										
											2013-09-03 20:12:11 +01:00
										 |  |  | int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); | 
					
						
							|  |  |  | int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | 
					
						
							| 
									
										
										
										
											2014-04-15 19:18:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void aarch64_cpu_do_interrupt(CPUState *cs); | 
					
						
							| 
									
										
										
										
											2013-09-03 20:12:10 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 04:50:31 +00:00
										 |  |  | #endif
 |