]>
Commit | Line | Data |
---|---|---|
afe0b380 SZ |
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" | |
33c11879 | 34 | #include "exec/hwaddr.h" |
d05fdab4 | 35 | #include "qemu/notify.h" |
a72d4363 AJ |
36 | #include "hw/boards.h" |
37 | #include "hw/arm/arm.h" | |
f90747c4 EA |
38 | #include "sysemu/kvm.h" |
39 | #include "hw/intc/arm_gicv3_common.h" | |
afe0b380 | 40 | |
bd204e63 | 41 | #define NUM_GICV2M_SPIS 64 |
afe0b380 | 42 | #define NUM_VIRTIO_TRANSPORTS 32 |
584105ea | 43 | #define NUM_SMMU_IRQS 4 |
afe0b380 | 44 | |
55ef3233 | 45 | #define ARCH_GIC_MAINT_IRQ 9 |
5454006a | 46 | |
ee246400 SZ |
47 | #define ARCH_TIMER_VIRT_IRQ 11 |
48 | #define ARCH_TIMER_S_EL1_IRQ 13 | |
49 | #define ARCH_TIMER_NS_EL1_IRQ 14 | |
50 | #define ARCH_TIMER_NS_EL2_IRQ 10 | |
51 | ||
01fe6b60 SZ |
52 | #define VIRTUAL_PMU_IRQ 7 |
53 | ||
54 | #define PPI(irq) ((irq) + 16) | |
55 | ||
afe0b380 SZ |
56 | enum { |
57 | VIRT_FLASH, | |
58 | VIRT_MEM, | |
59 | VIRT_CPUPERIPHS, | |
60 | VIRT_GIC_DIST, | |
61 | VIRT_GIC_CPU, | |
b92ad394 | 62 | VIRT_GIC_V2M, |
55ef3233 LM |
63 | VIRT_GIC_HYP, |
64 | VIRT_GIC_VCPU, | |
b92ad394 PF |
65 | VIRT_GIC_ITS, |
66 | VIRT_GIC_REDIST, | |
f90747c4 | 67 | VIRT_GIC_REDIST2, |
584105ea | 68 | VIRT_SMMU, |
afe0b380 SZ |
69 | VIRT_UART, |
70 | VIRT_MMIO, | |
71 | VIRT_RTC, | |
72 | VIRT_FW_CFG, | |
73 | VIRT_PCIE, | |
6a1f001b SZ |
74 | VIRT_PCIE_MMIO, |
75 | VIRT_PCIE_PIO, | |
76 | VIRT_PCIE_ECAM, | |
601d626d | 77 | VIRT_PCIE_ECAM_HIGH, |
5f7a5a0e | 78 | VIRT_PLATFORM_BUS, |
5125f9cd | 79 | VIRT_PCIE_MMIO_HIGH, |
b0a3721e | 80 | VIRT_GPIO, |
3df708eb | 81 | VIRT_SECURE_UART, |
83ec1923 | 82 | VIRT_SECURE_MEM, |
afe0b380 SZ |
83 | }; |
84 | ||
584105ea PM |
85 | typedef enum VirtIOMMUType { |
86 | VIRT_IOMMU_NONE, | |
87 | VIRT_IOMMU_SMMUV3, | |
88 | VIRT_IOMMU_VIRTIO, | |
89 | } VirtIOMMUType; | |
90 | ||
afe0b380 SZ |
91 | typedef struct MemMapEntry { |
92 | hwaddr base; | |
93 | hwaddr size; | |
94 | } MemMapEntry; | |
95 | ||
a72d4363 AJ |
96 | typedef struct { |
97 | MachineClass parent; | |
98 | bool disallow_affinity_adjustment; | |
99 | bool no_its; | |
100 | bool no_pmu; | |
101 | bool claim_edge_triggered_timers; | |
dfadc3bf | 102 | bool smbios_old_sys_ver; |
17ec075a | 103 | bool no_highmem_ecam; |
a72d4363 AJ |
104 | } VirtMachineClass; |
105 | ||
106 | typedef struct { | |
107 | MachineState parent; | |
a72d4363 | 108 | Notifier machine_done; |
a3fc8396 | 109 | DeviceState *platform_bus_dev; |
af1f60a4 | 110 | FWCfgState *fw_cfg; |
a72d4363 AJ |
111 | bool secure; |
112 | bool highmem; | |
601d626d | 113 | bool highmem_ecam; |
ccc11b02 | 114 | bool its; |
f29cacfb | 115 | bool virt; |
a72d4363 | 116 | int32_t gic_version; |
584105ea | 117 | VirtIOMMUType iommu; |
a72d4363 AJ |
118 | struct arm_boot_info bootinfo; |
119 | const MemMapEntry *memmap; | |
120 | const int *irqmap; | |
121 | int smp_cpus; | |
122 | void *fdt; | |
123 | int fdt_size; | |
124 | uint32_t clock_phandle; | |
125 | uint32_t gic_phandle; | |
126 | uint32_t msi_phandle; | |
584105ea | 127 | uint32_t iommu_phandle; |
2013c566 | 128 | int psci_conduit; |
a72d4363 AJ |
129 | } VirtMachineState; |
130 | ||
601d626d EA |
131 | #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) |
132 | ||
a72d4363 AJ |
133 | #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") |
134 | #define VIRT_MACHINE(obj) \ | |
135 | OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE) | |
136 | #define VIRT_MACHINE_GET_CLASS(obj) \ | |
137 | OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE) | |
138 | #define VIRT_MACHINE_CLASS(klass) \ | |
139 | OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) | |
140 | ||
e9a8e474 | 141 | void virt_acpi_setup(VirtMachineState *vms); |
d05fdab4 | 142 | |
f90747c4 EA |
143 | /* Return the number of used redistributor regions */ |
144 | static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | |
145 | { | |
146 | uint32_t redist0_capacity = | |
147 | vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; | |
148 | ||
149 | assert(vms->gic_version == 3); | |
150 | ||
151 | return vms->smp_cpus > redist0_capacity ? 2 : 1; | |
152 | } | |
153 | ||
d05fdab4 | 154 | #endif /* QEMU_ARM_VIRT_H */ |