2015-05-29 13:28:54 +03:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Linaro Limited
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2 or later, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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/>.
|
|
|
|
*
|
|
|
|
* Emulate a virtual board which works by passing Linux all the information
|
|
|
|
* it needs about what devices are present via the device tree.
|
|
|
|
* There are some restrictions about what we can do here:
|
|
|
|
* + we can only present devices whose Linux drivers will work based
|
|
|
|
* purely on the device tree with no platform data at all
|
|
|
|
* + we want to present a very stripped-down minimalist platform,
|
|
|
|
* both because this reduces the security attack surface from the guest
|
|
|
|
* and also because it reduces our exposure to being broken when
|
|
|
|
* the kernel updates its device tree bindings and requires further
|
|
|
|
* information in a device binding that we aren't providing.
|
|
|
|
* This is essentially the same approach kvmtool uses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_ARM_VIRT_H
|
|
|
|
#define QEMU_ARM_VIRT_H
|
|
|
|
|
|
|
|
#include "qemu-common.h"
|
2016-03-15 18:58:45 +03:00
|
|
|
#include "exec/hwaddr.h"
|
2017-01-09 14:40:22 +03:00
|
|
|
#include "qemu/notify.h"
|
2017-01-09 14:40:22 +03:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/arm/arm.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2015-06-02 16:56:23 +03:00
|
|
|
#define NUM_GICV2M_SPIS 64
|
2015-05-29 13:28:54 +03:00
|
|
|
#define NUM_VIRTIO_TRANSPORTS 32
|
2018-05-04 20:05:52 +03:00
|
|
|
#define NUM_SMMU_IRQS 4
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2017-01-20 14:15:09 +03:00
|
|
|
#define ARCH_GICV3_MAINT_IRQ 9
|
|
|
|
|
2015-05-29 13:28:56 +03:00
|
|
|
#define ARCH_TIMER_VIRT_IRQ 11
|
|
|
|
#define ARCH_TIMER_S_EL1_IRQ 13
|
|
|
|
#define ARCH_TIMER_NS_EL1_IRQ 14
|
|
|
|
#define ARCH_TIMER_NS_EL2_IRQ 10
|
|
|
|
|
2016-06-14 17:59:12 +03:00
|
|
|
#define VIRTUAL_PMU_IRQ 7
|
|
|
|
|
|
|
|
#define PPI(irq) ((irq) + 16)
|
|
|
|
|
2015-05-29 13:28:54 +03:00
|
|
|
enum {
|
|
|
|
VIRT_FLASH,
|
|
|
|
VIRT_MEM,
|
|
|
|
VIRT_CPUPERIPHS,
|
|
|
|
VIRT_GIC_DIST,
|
|
|
|
VIRT_GIC_CPU,
|
2015-09-24 03:29:37 +03:00
|
|
|
VIRT_GIC_V2M,
|
|
|
|
VIRT_GIC_ITS,
|
|
|
|
VIRT_GIC_REDIST,
|
2018-05-04 20:05:52 +03:00
|
|
|
VIRT_SMMU,
|
2015-05-29 13:28:54 +03:00
|
|
|
VIRT_UART,
|
|
|
|
VIRT_MMIO,
|
|
|
|
VIRT_RTC,
|
|
|
|
VIRT_FW_CFG,
|
|
|
|
VIRT_PCIE,
|
2015-05-29 13:28:54 +03:00
|
|
|
VIRT_PCIE_MMIO,
|
|
|
|
VIRT_PCIE_PIO,
|
|
|
|
VIRT_PCIE_ECAM,
|
2015-06-02 14:29:13 +03:00
|
|
|
VIRT_PLATFORM_BUS,
|
2015-09-07 12:39:29 +03:00
|
|
|
VIRT_PCIE_MMIO_HIGH,
|
2015-12-17 16:37:13 +03:00
|
|
|
VIRT_GPIO,
|
2016-01-21 17:15:07 +03:00
|
|
|
VIRT_SECURE_UART,
|
2016-03-04 14:30:17 +03:00
|
|
|
VIRT_SECURE_MEM,
|
2015-05-29 13:28:54 +03:00
|
|
|
};
|
|
|
|
|
2018-05-04 20:05:52 +03:00
|
|
|
typedef enum VirtIOMMUType {
|
|
|
|
VIRT_IOMMU_NONE,
|
|
|
|
VIRT_IOMMU_SMMUV3,
|
|
|
|
VIRT_IOMMU_VIRTIO,
|
|
|
|
} VirtIOMMUType;
|
|
|
|
|
2015-05-29 13:28:54 +03:00
|
|
|
typedef struct MemMapEntry {
|
|
|
|
hwaddr base;
|
|
|
|
hwaddr size;
|
|
|
|
} MemMapEntry;
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
typedef struct {
|
|
|
|
MachineClass parent;
|
|
|
|
bool disallow_affinity_adjustment;
|
|
|
|
bool no_its;
|
|
|
|
bool no_pmu;
|
|
|
|
bool claim_edge_triggered_timers;
|
2018-03-23 21:26:46 +03:00
|
|
|
bool smbios_old_sys_ver;
|
2017-01-09 14:40:22 +03:00
|
|
|
} VirtMachineClass;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
MachineState parent;
|
|
|
|
Notifier machine_done;
|
2018-05-10 20:10:56 +03:00
|
|
|
DeviceState *platform_bus_dev;
|
2017-01-09 14:40:23 +03:00
|
|
|
FWCfgState *fw_cfg;
|
2017-01-09 14:40:22 +03:00
|
|
|
bool secure;
|
|
|
|
bool highmem;
|
2017-02-28 15:08:16 +03:00
|
|
|
bool its;
|
2017-01-20 14:15:11 +03:00
|
|
|
bool virt;
|
2017-01-09 14:40:22 +03:00
|
|
|
int32_t gic_version;
|
2018-05-04 20:05:52 +03:00
|
|
|
VirtIOMMUType iommu;
|
2017-01-09 14:40:22 +03:00
|
|
|
struct arm_boot_info bootinfo;
|
|
|
|
const MemMapEntry *memmap;
|
|
|
|
const int *irqmap;
|
|
|
|
int smp_cpus;
|
|
|
|
void *fdt;
|
|
|
|
int fdt_size;
|
|
|
|
uint32_t clock_phandle;
|
|
|
|
uint32_t gic_phandle;
|
|
|
|
uint32_t msi_phandle;
|
2018-05-04 20:05:52 +03:00
|
|
|
uint32_t iommu_phandle;
|
2017-01-20 14:15:10 +03:00
|
|
|
int psci_conduit;
|
2017-01-09 14:40:22 +03:00
|
|
|
} VirtMachineState;
|
|
|
|
|
|
|
|
#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
|
|
|
|
#define VIRT_MACHINE(obj) \
|
|
|
|
OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
|
|
|
|
#define VIRT_MACHINE_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE)
|
|
|
|
#define VIRT_MACHINE_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
void virt_acpi_setup(VirtMachineState *vms);
|
2017-01-09 14:40:22 +03:00
|
|
|
|
|
|
|
#endif /* QEMU_ARM_VIRT_H */
|