qemu/include/hw/arm/virt.h
<<
>>
Prefs
   1/*
   2 *
   3 * Copyright (c) 2015 Linaro Limited
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms and conditions of the GNU General Public License,
   7 * version 2 or later, as published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  12 * more details.
  13 *
  14 * You should have received a copy of the GNU General Public License along with
  15 * this program.  If not, see <http://www.gnu.org/licenses/>.
  16 *
  17 * Emulate a virtual board which works by passing Linux all the information
  18 * it needs about what devices are present via the device tree.
  19 * There are some restrictions about what we can do here:
  20 *  + we can only present devices whose Linux drivers will work based
  21 *    purely on the device tree with no platform data at all
  22 *  + we want to present a very stripped-down minimalist platform,
  23 *    both because this reduces the security attack surface from the guest
  24 *    and also because it reduces our exposure to being broken when
  25 *    the kernel updates its device tree bindings and requires further
  26 *    information in a device binding that we aren't providing.
  27 * This is essentially the same approach kvmtool uses.
  28 */
  29
  30#ifndef QEMU_ARM_VIRT_H
  31#define QEMU_ARM_VIRT_H
  32
  33#include "qemu-common.h"
  34#include "exec/hwaddr.h"
  35#include "qemu/notify.h"
  36#include "hw/boards.h"
  37#include "hw/arm/arm.h"
  38
  39#define NUM_GICV2M_SPIS       64
  40#define NUM_VIRTIO_TRANSPORTS 32
  41
  42#define ARCH_GICV3_MAINT_IRQ  9
  43
  44#define ARCH_TIMER_VIRT_IRQ   11
  45#define ARCH_TIMER_S_EL1_IRQ  13
  46#define ARCH_TIMER_NS_EL1_IRQ 14
  47#define ARCH_TIMER_NS_EL2_IRQ 10
  48
  49#define VIRTUAL_PMU_IRQ 7
  50
  51#define PPI(irq) ((irq) + 16)
  52
  53enum {
  54    VIRT_FLASH,
  55    VIRT_MEM,
  56    VIRT_CPUPERIPHS,
  57    VIRT_GIC_DIST,
  58    VIRT_GIC_CPU,
  59    VIRT_GIC_V2M,
  60    VIRT_GIC_ITS,
  61    VIRT_GIC_REDIST,
  62    VIRT_UART,
  63    VIRT_MMIO,
  64    VIRT_RTC,
  65    VIRT_FW_CFG,
  66    VIRT_PCIE,
  67    VIRT_PCIE_MMIO,
  68    VIRT_PCIE_PIO,
  69    VIRT_PCIE_ECAM,
  70    VIRT_PLATFORM_BUS,
  71    VIRT_PCIE_MMIO_HIGH,
  72    VIRT_GPIO,
  73    VIRT_SECURE_UART,
  74    VIRT_SECURE_MEM,
  75};
  76
  77typedef struct MemMapEntry {
  78    hwaddr base;
  79    hwaddr size;
  80} MemMapEntry;
  81
  82typedef struct {
  83    MachineClass parent;
  84    bool disallow_affinity_adjustment;
  85    bool no_its;
  86    bool no_pmu;
  87    bool claim_edge_triggered_timers;
  88    bool smbios_old_sys_ver;
  89} VirtMachineClass;
  90
  91typedef struct {
  92    MachineState parent;
  93    Notifier machine_done;
  94    FWCfgState *fw_cfg;
  95    bool secure;
  96    bool highmem;
  97    bool its;
  98    bool virt;
  99    int32_t gic_version;
 100    struct arm_boot_info bootinfo;
 101    const MemMapEntry *memmap;
 102    const int *irqmap;
 103    int smp_cpus;
 104    void *fdt;
 105    int fdt_size;
 106    uint32_t clock_phandle;
 107    uint32_t gic_phandle;
 108    uint32_t msi_phandle;
 109    int psci_conduit;
 110} VirtMachineState;
 111
 112#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
 113#define VIRT_MACHINE(obj) \
 114    OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
 115#define VIRT_MACHINE_GET_CLASS(obj) \
 116    OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE)
 117#define VIRT_MACHINE_CLASS(klass) \
 118    OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
 119
 120void virt_acpi_setup(VirtMachineState *vms);
 121
 122#endif /* QEMU_ARM_VIRT_H */
 123