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