blob: c2b4cb07e54d5f27c454d9ff0919efc8780f56dc [file] [log] [blame]
Isaku Yamahata845773a2010-05-14 16:29:15 +09001/*
2 * QEMU PC System Emulator
3 *
4 * Copyright (c) 2003-2004 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
Avi Kivityae0a5462011-08-15 17:17:38 +030025#include <glib.h>
26
Isaku Yamahata845773a2010-05-14 16:29:15 +090027#include "hw.h"
28#include "pc.h"
29#include "apic.h"
Michael S. Tsirkina2cb15b2012-12-12 14:24:50 +020030#include "pci/pci.h"
31#include "pci/pci_ids.h"
Paolo Bonzinibce54472012-03-28 18:12:47 +020032#include "usb.h"
Isaku Yamahata845773a2010-05-14 16:29:15 +090033#include "net.h"
34#include "boards.h"
35#include "ide.h"
36#include "kvm.h"
Jan Kiszka3b9a6ee2011-10-15 10:01:27 +020037#include "kvm/clock.h"
Markus Armbruster666daa62010-06-02 18:48:27 +020038#include "sysemu.h"
Blue Swirl96051112010-06-19 07:41:43 +000039#include "sysbus.h"
Isaku Yamahata0dfa5ef2011-01-21 19:53:45 +090040#include "arch_init.h"
Blue Swirl24463332010-08-24 15:22:24 +000041#include "blockdev.h"
Isaku Yamahataa88df0b2011-04-05 11:07:06 +090042#include "smbus.h"
Anthony PERARD29d3ccd2010-06-30 12:58:34 +010043#include "xen.h"
Avi Kivity4aa63af2011-07-26 14:26:16 +030044#include "memory.h"
45#include "exec-memory.h"
Michael S. Tsirkindc599442012-10-18 00:15:48 +020046#include "cpu.h"
Anthony PERARD29d3ccd2010-06-30 12:58:34 +010047#ifdef CONFIG_XEN
48# include <xen/hvm/hvm_info_table.h>
49#endif
Isaku Yamahata845773a2010-05-14 16:29:15 +090050
51#define MAX_IDE_BUS 2
52
53static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
54static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
55static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
56
57/* PC hardware initialisation */
Avi Kivity6bd10512011-07-26 14:26:18 +030058static void pc_init1(MemoryRegion *system_memory,
Avi Kivityaee97b82011-08-08 16:09:04 +030059 MemoryRegion *system_io,
Avi Kivity6bd10512011-07-26 14:26:18 +030060 ram_addr_t ram_size,
Isaku Yamahata845773a2010-05-14 16:29:15 +090061 const char *boot_device,
62 const char *kernel_filename,
63 const char *kernel_cmdline,
64 const char *initrd_filename,
65 const char *cpu_model,
Jan Kiszka0ec329d2011-02-07 12:19:26 +010066 int pci_enabled,
67 int kvmclock_enabled)
Isaku Yamahata845773a2010-05-14 16:29:15 +090068{
69 int i;
70 ram_addr_t below_4g_mem_size, above_4g_mem_size;
71 PCIBus *pci_bus;
Hervé Poussineau48a18b32011-12-15 22:09:51 +010072 ISABus *isa_bus;
Isaku Yamahata845773a2010-05-14 16:29:15 +090073 PCII440FXState *i440fx_state;
74 int piix3_devfn = -1;
75 qemu_irq *cpu_irq;
Jan Kiszkab881fbe2011-10-07 09:19:35 +020076 qemu_irq *gsi;
Isaku Yamahata845773a2010-05-14 16:29:15 +090077 qemu_irq *i8259;
Isaku Yamahata845773a2010-05-14 16:29:15 +090078 qemu_irq *smi_irq;
Jan Kiszkab881fbe2011-10-07 09:19:35 +020079 GSIState *gsi_state;
Isaku Yamahata845773a2010-05-14 16:29:15 +090080 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
Markus Armbrusterc0897e02010-06-24 19:58:20 +020081 BusState *idebus[MAX_IDE_BUS];
Isaku Yamahata1d914fa2010-05-14 16:29:17 +090082 ISADevice *rtc_state;
Kevin Wolf34d42602011-10-20 16:37:26 +020083 ISADevice *floppy;
Avi Kivityae0a5462011-08-15 17:17:38 +030084 MemoryRegion *ram_memory;
85 MemoryRegion *pci_memory;
Jan Kiszka4463aee2011-09-21 20:49:29 +020086 MemoryRegion *rom_memory;
Gleb Natapov459ae5e2012-06-04 14:31:55 +030087 void *fw_cfg = NULL;
Isaku Yamahata845773a2010-05-14 16:29:15 +090088
89 pc_cpus_init(cpu_model);
90
Jan Kiszka0ec329d2011-02-07 12:19:26 +010091 if (kvmclock_enabled) {
92 kvmclock_create();
93 }
94
Anthony PERARDe0e7e672011-04-11 19:48:11 +010095 if (ram_size >= 0xe0000000 ) {
96 above_4g_mem_size = ram_size - 0xe0000000;
97 below_4g_mem_size = 0xe0000000;
98 } else {
99 above_4g_mem_size = 0;
100 below_4g_mem_size = ram_size;
101 }
102
Jan Kiszka4463aee2011-09-21 20:49:29 +0200103 if (pci_enabled) {
104 pci_memory = g_new(MemoryRegion, 1);
105 memory_region_init(pci_memory, "pci", INT64_MAX);
106 rom_memory = pci_memory;
107 } else {
108 pci_memory = NULL;
109 rom_memory = system_memory;
110 }
Avi Kivityae0a5462011-08-15 17:17:38 +0300111
Isaku Yamahata845773a2010-05-14 16:29:15 +0900112 /* allocate ram and load rom/bios */
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100113 if (!xen_enabled()) {
Gleb Natapov459ae5e2012-06-04 14:31:55 +0300114 fw_cfg = pc_memory_init(system_memory,
Avi Kivity4aa63af2011-07-26 14:26:16 +0300115 kernel_filename, kernel_cmdline, initrd_filename,
Avi Kivityae0a5462011-08-15 17:17:38 +0300116 below_4g_mem_size, above_4g_mem_size,
Jan Kiszka0d3cf3b2012-11-01 17:29:24 +0100117 rom_memory, &ram_memory);
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100118 }
Isaku Yamahata845773a2010-05-14 16:29:15 +0900119
Jan Kiszkab881fbe2011-10-07 09:19:35 +0200120 gsi_state = g_malloc0(sizeof(*gsi_state));
Jan Kiszka3d4b2642012-01-31 19:17:52 +0100121 if (kvm_irqchip_in_kernel()) {
Jason Barond8ee0382012-11-14 15:54:02 -0500122 kvm_pc_setup_irq_routing(pci_enabled);
123 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
Jan Kiszka10b61882011-10-16 15:30:27 +0200124 GSI_NUM_PINS);
125 } else {
126 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
127 }
Isaku Yamahata845773a2010-05-14 16:29:15 +0900128
129 if (pci_enabled) {
Hervé Poussineau60573072011-12-15 22:09:54 +0100130 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
Avi Kivityae0a5462011-08-15 17:17:38 +0300131 system_memory, system_io, ram_size,
132 below_4g_mem_size,
133 0x100000000ULL - below_4g_mem_size,
134 0x100000000ULL + above_4g_mem_size,
Avi Kivitya8170e52012-10-23 12:30:10 +0200135 (sizeof(hwaddr) == 4
Avi Kivityae0a5462011-08-15 17:17:38 +0300136 ? 0
137 : ((uint64_t)1 << 62)),
138 pci_memory, ram_memory);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900139 } else {
140 pci_bus = NULL;
Isaku Yamahata02a89b22010-08-04 17:43:20 +0900141 i440fx_state = NULL;
Hervé Poussineau48a18b32011-12-15 22:09:51 +0100142 isa_bus = isa_bus_new(NULL, system_io);
Jan Kiszka57285cc2011-09-21 20:49:30 +0200143 no_hpet = 1;
Isaku Yamahata845773a2010-05-14 16:29:15 +0900144 }
Hervé Poussineau48a18b32011-12-15 22:09:51 +0100145 isa_bus_irqs(isa_bus, gsi);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900146
Jan Kiszka3d4b2642012-01-31 19:17:52 +0100147 if (kvm_irqchip_in_kernel()) {
Jan Kiszka10b61882011-10-16 15:30:27 +0200148 i8259 = kvm_i8259_init(isa_bus);
149 } else if (xen_enabled()) {
150 i8259 = xen_interrupt_controller_init();
151 } else {
Richard Henderson4bae1ef2011-08-10 15:28:13 -0700152 cpu_irq = pc_allocate_cpu_irq();
Hervé Poussineau48a18b32011-12-15 22:09:51 +0100153 i8259 = i8259_init(isa_bus, cpu_irq[0]);
Richard Henderson4bae1ef2011-08-10 15:28:13 -0700154 }
155
Jan Kiszka43a0db32011-10-07 09:19:36 +0200156 for (i = 0; i < ISA_NUM_IRQS; i++) {
157 gsi_state->i8259_irq[i] = i8259[i];
158 }
Richard Henderson4bae1ef2011-08-10 15:28:13 -0700159 if (pci_enabled) {
Jason Barona39e3562012-11-14 15:54:01 -0500160 ioapic_init_gsi(gsi_state, "i440fx");
Richard Henderson4bae1ef2011-08-10 15:28:13 -0700161 }
162
Jan Kiszkab881fbe2011-10-07 09:19:35 +0200163 pc_register_ferr_irq(gsi[13]);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900164
Paolo Bonzinif424d5c2012-03-27 18:38:46 +0200165 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
Steven Smith01195b72011-06-16 17:05:17 +0100166 if (xen_enabled()) {
167 pci_create_simple(pci_bus, -1, "xen-platform");
168 }
169
Isaku Yamahata845773a2010-05-14 16:29:15 +0900170 /* init basic PC hardware */
Hervé Poussineau48a18b32011-12-15 22:09:51 +0100171 pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled());
Isaku Yamahata845773a2010-05-14 16:29:15 +0900172
Isaku Yamahata9011a1a2012-11-14 15:54:01 -0500173 pc_nic_init(isa_bus, pci_bus);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900174
Isaku Yamahata75717902011-04-03 20:32:46 +0900175 ide_drive_get(hd, MAX_IDE_BUS);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900176 if (pci_enabled) {
Markus Armbrusterc0897e02010-06-24 19:58:20 +0200177 PCIDevice *dev;
Stefano Stabellini679f4f82011-07-18 06:07:02 +0000178 if (xen_enabled()) {
179 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
180 } else {
181 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
182 }
Markus Armbrusterc0897e02010-06-24 19:58:20 +0200183 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
184 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
Isaku Yamahata845773a2010-05-14 16:29:15 +0900185 } else {
186 for(i = 0; i < MAX_IDE_BUS; i++) {
Markus Armbrusterc0897e02010-06-24 19:58:20 +0200187 ISADevice *dev;
Hervé Poussineau48a18b32011-12-15 22:09:51 +0100188 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
189 ide_irq[i],
Markus Armbrusterc0897e02010-06-24 19:58:20 +0200190 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
191 idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
Isaku Yamahata845773a2010-05-14 16:29:15 +0900192 }
193 }
194
Hervé Poussineau4a0f0312011-12-15 22:10:01 +0100195 audio_init(isa_bus, pci_enabled ? pci_bus : NULL);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900196
Markus Armbrusterc0897e02010-06-24 19:58:20 +0200197 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
Kevin Wolf34d42602011-10-20 16:37:26 +0200198 floppy, idebus[0], idebus[1], rtc_state);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900199
zhlcindy@gmail.com094b2872012-09-02 19:25:28 +0000200 if (pci_enabled && usb_enabled(false)) {
Gerd Hoffmannafb9a602012-03-07 15:06:32 +0100201 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
Isaku Yamahata845773a2010-05-14 16:29:15 +0900202 }
203
204 if (pci_enabled && acpi_enabled) {
Isaku Yamahata845773a2010-05-14 16:29:15 +0900205 i2c_bus *smbus;
206
Isaku Yamahata845773a2010-05-14 16:29:15 +0900207 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
208 /* TODO: Populate SPD eeprom data. */
209 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
Gerd Hoffmannda98c8e2012-02-23 13:45:20 +0100210 gsi[9], *smi_irq,
Gleb Natapov459ae5e2012-06-04 14:31:55 +0300211 kvm_enabled(), fw_cfg);
Isaku Yamahataa88df0b2011-04-05 11:07:06 +0900212 smbus_eeprom_init(smbus, 8, NULL, 0);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900213 }
214
Isaku Yamahata845773a2010-05-14 16:29:15 +0900215 if (pci_enabled) {
216 pc_pci_device_init(pci_bus);
217 }
218}
219
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300220static void pc_init_pci(QEMUMachineInitArgs *args)
Isaku Yamahata845773a2010-05-14 16:29:15 +0900221{
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300222 ram_addr_t ram_size = args->ram_size;
223 const char *cpu_model = args->cpu_model;
224 const char *kernel_filename = args->kernel_filename;
225 const char *kernel_cmdline = args->kernel_cmdline;
226 const char *initrd_filename = args->initrd_filename;
227 const char *boot_device = args->boot_device;
Avi Kivity6bd10512011-07-26 14:26:18 +0300228 pc_init1(get_system_memory(),
Avi Kivityaee97b82011-08-08 16:09:04 +0300229 get_system_io(),
Avi Kivity6bd10512011-07-26 14:26:18 +0300230 ram_size, boot_device,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900231 kernel_filename, kernel_cmdline,
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100232 initrd_filename, cpu_model, 1, 1);
233}
234
Michael S. Tsirkindc599442012-10-18 00:15:48 +0200235static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
236{
237 enable_kvm_pv_eoi();
238 pc_init_pci(args);
239}
240
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300241static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100242{
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300243 ram_addr_t ram_size = args->ram_size;
244 const char *cpu_model = args->cpu_model;
245 const char *kernel_filename = args->kernel_filename;
246 const char *kernel_cmdline = args->kernel_cmdline;
247 const char *initrd_filename = args->initrd_filename;
248 const char *boot_device = args->boot_device;
Avi Kivity6bd10512011-07-26 14:26:18 +0300249 pc_init1(get_system_memory(),
Avi Kivityaee97b82011-08-08 16:09:04 +0300250 get_system_io(),
Avi Kivity6bd10512011-07-26 14:26:18 +0300251 ram_size, boot_device,
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100252 kernel_filename, kernel_cmdline,
253 initrd_filename, cpu_model, 1, 0);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900254}
255
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300256static void pc_init_isa(QEMUMachineInitArgs *args)
Isaku Yamahata845773a2010-05-14 16:29:15 +0900257{
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300258 ram_addr_t ram_size = args->ram_size;
259 const char *cpu_model = args->cpu_model;
260 const char *kernel_filename = args->kernel_filename;
261 const char *kernel_cmdline = args->kernel_cmdline;
262 const char *initrd_filename = args->initrd_filename;
263 const char *boot_device = args->boot_device;
Isaku Yamahata845773a2010-05-14 16:29:15 +0900264 if (cpu_model == NULL)
265 cpu_model = "486";
Avi Kivity6bd10512011-07-26 14:26:18 +0300266 pc_init1(get_system_memory(),
Avi Kivityaee97b82011-08-08 16:09:04 +0300267 get_system_io(),
Avi Kivity6bd10512011-07-26 14:26:18 +0300268 ram_size, boot_device,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900269 kernel_filename, kernel_cmdline,
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100270 initrd_filename, cpu_model, 0, 1);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900271}
272
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100273#ifdef CONFIG_XEN
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300274static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100275{
276 if (xen_hvm_init() != 0) {
277 hw_error("xen hardware virtual machine initialisation failed");
278 }
Eduardo Habkost5f072e12012-10-15 17:22:02 -0300279 pc_init_pci_no_kvmclock(args);
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100280 xen_vcpu_init();
281}
282#endif
283
Gerd Hoffmannf1ae2e32012-12-04 14:39:16 +0100284static QEMUMachine pc_machine_v1_4 = {
285 .name = "pc-1.4",
Isaku Yamahata845773a2010-05-14 16:29:15 +0900286 .alias = "pc",
287 .desc = "Standard PC",
Michael S. Tsirkindc599442012-10-18 00:15:48 +0200288 .init = pc_init_pci_1_3,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900289 .max_cpus = 255,
290 .is_default = 1,
291};
292
Hans de Goede427e3aa2012-11-17 12:47:18 +0100293#define PC_COMPAT_1_3 \
294 {\
295 .driver = "usb-tablet",\
296 .property = "usb_version",\
297 .value = stringify(1),\
298 }
299
Gerd Hoffmannf1ae2e32012-12-04 14:39:16 +0100300static QEMUMachine pc_machine_v1_3 = {
301 .name = "pc-1.3",
302 .desc = "Standard PC",
303 .init = pc_init_pci_1_3,
304 .max_cpus = 255,
305 .compat_props = (GlobalProperty[]) {
Hans de Goede427e3aa2012-11-17 12:47:18 +0100306 PC_COMPAT_1_3,
Gerd Hoffmannf1ae2e32012-12-04 14:39:16 +0100307 { /* end of list */ }
308 },
309};
310
Gerd Hoffmann183c5ea2012-09-13 11:08:01 +0200311#define PC_COMPAT_1_2 \
Hans de Goede427e3aa2012-11-17 12:47:18 +0100312 PC_COMPAT_1_3,\
Gerd Hoffmann183c5ea2012-09-13 11:08:01 +0200313 {\
314 .driver = "nec-usb-xhci",\
315 .property = "msi",\
316 .value = "off",\
317 },{\
318 .driver = "nec-usb-xhci",\
319 .property = "msix",\
320 .value = "off",\
Gerd Hoffmannc08ba662012-09-13 11:08:02 +0200321 },{\
322 .driver = "ivshmem",\
323 .property = "use64",\
324 .value = "0",\
Gerd Hoffmann591af142012-10-08 10:05:22 +0200325 },{\
326 .driver = "qxl",\
327 .property = "revision",\
328 .value = stringify(3),\
329 },{\
330 .driver = "qxl-vga",\
331 .property = "revision",\
332 .value = stringify(3),\
Gerd Hoffmann803ff052012-10-15 08:02:55 +0200333 },{\
334 .driver = "VGA",\
335 .property = "mmio",\
336 .value = "off",\
Gerd Hoffmann183c5ea2012-09-13 11:08:01 +0200337 }
338
Gerd Hoffmannf4306942012-09-13 11:08:00 +0200339static QEMUMachine pc_machine_v1_2 = {
340 .name = "pc-1.2",
341 .desc = "Standard PC",
342 .init = pc_init_pci,
343 .max_cpus = 255,
Gerd Hoffmann183c5ea2012-09-13 11:08:01 +0200344 .compat_props = (GlobalProperty[]) {
345 PC_COMPAT_1_2,
346 { /* end of list */ }
347 },
Gerd Hoffmannf4306942012-09-13 11:08:00 +0200348};
349
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200350#define PC_COMPAT_1_1 \
Gerd Hoffmann183c5ea2012-09-13 11:08:01 +0200351 PC_COMPAT_1_2,\
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200352 {\
Paolo Bonzini07a52982012-08-20 15:23:28 +0200353 .driver = "virtio-scsi-pci",\
354 .property = "hotplug",\
355 .value = "off",\
356 },{\
357 .driver = "virtio-scsi-pci",\
358 .property = "param_change",\
359 .value = "off",\
360 },{\
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200361 .driver = "VGA",\
362 .property = "vgamem_mb",\
363 .value = stringify(8),\
364 },{\
365 .driver = "vmware-svga",\
366 .property = "vgamem_mb",\
367 .value = stringify(8),\
368 },{\
369 .driver = "qxl-vga",\
370 .property = "vgamem_mb",\
371 .value = stringify(8),\
372 },{\
373 .driver = "qxl",\
374 .property = "vgamem_mb",\
375 .value = stringify(8),\
Stefan Hajnocziea776ab2012-08-21 14:40:49 +0100376 },{\
377 .driver = "virtio-blk-pci",\
378 .property = "config-wce",\
379 .value = "off",\
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200380 }
381
Gerd Hoffmannf1dacf12012-06-11 10:38:22 +0200382static QEMUMachine pc_machine_v1_1 = {
383 .name = "pc-1.1",
384 .desc = "Standard PC",
385 .init = pc_init_pci,
386 .max_cpus = 255,
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200387 .compat_props = (GlobalProperty[]) {
388 PC_COMPAT_1_1,
389 { /* end of list */ }
390 },
Gerd Hoffmannf1dacf12012-06-11 10:38:22 +0200391};
392
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200393#define PC_COMPAT_1_0 \
Gerd Hoffmann9e56edc2012-06-11 10:42:53 +0200394 PC_COMPAT_1_1,\
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200395 {\
396 .driver = "pc-sysfw",\
397 .property = "rom_only",\
398 .value = stringify(1),\
399 }, {\
400 .driver = "isa-fdc",\
401 .property = "check_media_rate",\
402 .value = "off",\
David Gibson2ba1d382012-04-03 17:24:11 +0300403 }, {\
404 .driver = "virtio-balloon-pci",\
405 .property = "class",\
406 .value = stringify(PCI_CLASS_MEMORY_RAM),\
Anthony Liguorifc34e772012-04-16 12:56:28 -0500407 },{\
408 .driver = "apic",\
409 .property = "vapic",\
410 .value = "off",\
Gerd Hoffmanneeb0cf92011-08-22 09:09:51 +0200411 },{\
Paolo Bonzinibce54472012-03-28 18:12:47 +0200412 .driver = TYPE_USB_DEVICE,\
Gerd Hoffmanneeb0cf92011-08-22 09:09:51 +0200413 .property = "full-path",\
414 .value = "no",\
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200415 }
416
Jordan Justen382b3a62012-02-21 23:18:55 -0800417static QEMUMachine pc_machine_v1_0 = {
418 .name = "pc-1.0",
419 .desc = "Standard PC",
420 .init = pc_init_pci,
421 .max_cpus = 255,
Jordan Justen1b89faf2012-02-21 23:18:56 -0800422 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200423 PC_COMPAT_1_0,
Jordan Justen1b89faf2012-02-21 23:18:56 -0800424 { /* end of list */ }
425 },
Crístian Viana93bfef42012-05-30 00:35:51 -0300426 .hw_version = "1.0",
Jordan Justen382b3a62012-02-21 23:18:55 -0800427};
428
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200429#define PC_COMPAT_0_15 \
430 PC_COMPAT_1_0
431
Anthony Liguorice01a502011-12-18 12:59:12 -0600432static QEMUMachine pc_machine_v0_15 = {
433 .name = "pc-0.15",
434 .desc = "Standard PC",
435 .init = pc_init_pci,
436 .max_cpus = 255,
Jordan Justen1b89faf2012-02-21 23:18:56 -0800437 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200438 PC_COMPAT_0_15,
Jordan Justen1b89faf2012-02-21 23:18:56 -0800439 { /* end of list */ }
440 },
Crístian Viana93bfef42012-05-30 00:35:51 -0300441 .hw_version = "0.15",
Anthony Liguorice01a502011-12-18 12:59:12 -0600442};
443
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200444#define PC_COMPAT_0_14 \
445 PC_COMPAT_0_15,\
446 {\
447 .driver = "virtio-blk-pci",\
448 .property = "event_idx",\
449 .value = "off",\
450 },{\
451 .driver = "virtio-serial-pci",\
452 .property = "event_idx",\
453 .value = "off",\
454 },{\
455 .driver = "virtio-net-pci",\
456 .property = "event_idx",\
457 .value = "off",\
458 },{\
459 .driver = "virtio-balloon-pci",\
460 .property = "event_idx",\
461 .value = "off",\
462 }
463
Gerd Hoffmann19857e62011-11-07 16:33:08 +0100464static QEMUMachine pc_machine_v0_14 = {
465 .name = "pc-0.14",
466 .desc = "Standard PC",
467 .init = pc_init_pci,
468 .max_cpus = 255,
Alon Levy3827cdb2011-11-13 15:27:51 +0200469 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200470 PC_COMPAT_0_14,
Alon Levy3827cdb2011-11-13 15:27:51 +0200471 {
472 .driver = "qxl",
473 .property = "revision",
474 .value = stringify(2),
475 },{
476 .driver = "qxl-vga",
477 .property = "revision",
478 .value = stringify(2),
Jordan Justen1b89faf2012-02-21 23:18:56 -0800479 },
Alon Levy3827cdb2011-11-13 15:27:51 +0200480 { /* end of list */ }
481 },
Crístian Viana93bfef42012-05-30 00:35:51 -0300482 .hw_version = "0.14",
Gerd Hoffmann19857e62011-11-07 16:33:08 +0100483};
484
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200485#define PC_COMPAT_0_13 \
486 PC_COMPAT_0_14,\
487 {\
Paolo Bonzinibce54472012-03-28 18:12:47 +0200488 .driver = TYPE_PCI_DEVICE,\
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200489 .property = "command_serr_enable",\
490 .value = "off",\
491 },{\
492 .driver = "AC97",\
493 .property = "use_broken_id",\
494 .value = stringify(1),\
495 }
496
Gerd Hoffmannb903a0f2010-11-11 12:59:25 +0100497static QEMUMachine pc_machine_v0_13 = {
498 .name = "pc-0.13",
499 .desc = "Standard PC",
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100500 .init = pc_init_pci_no_kvmclock,
Gerd Hoffmannb903a0f2010-11-11 12:59:25 +0100501 .max_cpus = 255,
Gerd Hoffmann9dbcca52010-11-11 12:59:26 +0100502 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200503 PC_COMPAT_0_13,
Gerd Hoffmann9dbcca52010-11-11 12:59:26 +0100504 {
505 .driver = "virtio-9p-pci",
506 .property = "vectors",
507 .value = stringify(0),
Gerd Hoffmann281a26b2010-11-17 12:06:44 +0100508 },{
509 .driver = "VGA",
510 .property = "rombar",
511 .value = stringify(0),
512 },{
513 .driver = "vmware-svga",
514 .property = "rombar",
515 .value = stringify(0),
Jordan Justen1b89faf2012-02-21 23:18:56 -0800516 },
Gerd Hoffmann9dbcca52010-11-11 12:59:26 +0100517 { /* end of list */ }
518 },
Crístian Viana93bfef42012-05-30 00:35:51 -0300519 .hw_version = "0.13",
Gerd Hoffmannb903a0f2010-11-11 12:59:25 +0100520};
521
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200522#define PC_COMPAT_0_12 \
523 PC_COMPAT_0_13,\
524 {\
525 .driver = "virtio-serial-pci",\
526 .property = "max_ports",\
527 .value = stringify(1),\
528 },{\
529 .driver = "virtio-serial-pci",\
530 .property = "vectors",\
531 .value = stringify(0),\
532 }
533
Isaku Yamahata845773a2010-05-14 16:29:15 +0900534static QEMUMachine pc_machine_v0_12 = {
535 .name = "pc-0.12",
536 .desc = "Standard PC",
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100537 .init = pc_init_pci_no_kvmclock,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900538 .max_cpus = 255,
539 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200540 PC_COMPAT_0_12,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900541 {
Gerd Hoffmann281a26b2010-11-17 12:06:44 +0100542 .driver = "VGA",
543 .property = "rombar",
544 .value = stringify(0),
545 },{
546 .driver = "vmware-svga",
547 .property = "rombar",
548 .value = stringify(0),
Jordan Justen1b89faf2012-02-21 23:18:56 -0800549 },
Isaku Yamahata845773a2010-05-14 16:29:15 +0900550 { /* end of list */ }
Crístian Viana93bfef42012-05-30 00:35:51 -0300551 },
552 .hw_version = "0.12",
Isaku Yamahata845773a2010-05-14 16:29:15 +0900553};
554
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200555#define PC_COMPAT_0_11 \
556 PC_COMPAT_0_12,\
557 {\
558 .driver = "virtio-blk-pci",\
559 .property = "vectors",\
560 .value = stringify(0),\
Paolo Bonzinic115cd62012-05-02 13:31:04 +0200561 },{\
Paolo Bonzinibce54472012-03-28 18:12:47 +0200562 .driver = TYPE_PCI_DEVICE,\
Paolo Bonzinic115cd62012-05-02 13:31:04 +0200563 .property = "rombar",\
564 .value = stringify(0),\
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200565 }
566
Isaku Yamahata845773a2010-05-14 16:29:15 +0900567static QEMUMachine pc_machine_v0_11 = {
568 .name = "pc-0.11",
569 .desc = "Standard PC, qemu 0.11",
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100570 .init = pc_init_pci_no_kvmclock,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900571 .max_cpus = 255,
572 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200573 PC_COMPAT_0_11,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900574 {
Isaku Yamahata845773a2010-05-14 16:29:15 +0900575 .driver = "ide-drive",
576 .property = "ver",
577 .value = "0.11",
578 },{
579 .driver = "scsi-disk",
580 .property = "ver",
581 .value = "0.11",
Jordan Justen1b89faf2012-02-21 23:18:56 -0800582 },
Isaku Yamahata845773a2010-05-14 16:29:15 +0900583 { /* end of list */ }
Crístian Viana93bfef42012-05-30 00:35:51 -0300584 },
585 .hw_version = "0.11",
Isaku Yamahata845773a2010-05-14 16:29:15 +0900586};
587
588static QEMUMachine pc_machine_v0_10 = {
589 .name = "pc-0.10",
590 .desc = "Standard PC, qemu 0.10",
Jan Kiszka0ec329d2011-02-07 12:19:26 +0100591 .init = pc_init_pci_no_kvmclock,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900592 .max_cpus = 255,
593 .compat_props = (GlobalProperty[]) {
Michael S. Tsirkind6c73002012-03-26 11:26:16 +0200594 PC_COMPAT_0_11,
Isaku Yamahata845773a2010-05-14 16:29:15 +0900595 {
596 .driver = "virtio-blk-pci",
597 .property = "class",
598 .value = stringify(PCI_CLASS_STORAGE_OTHER),
599 },{
600 .driver = "virtio-serial-pci",
601 .property = "class",
602 .value = stringify(PCI_CLASS_DISPLAY_OTHER),
603 },{
Isaku Yamahata845773a2010-05-14 16:29:15 +0900604 .driver = "virtio-net-pci",
605 .property = "vectors",
606 .value = stringify(0),
607 },{
Isaku Yamahata845773a2010-05-14 16:29:15 +0900608 .driver = "ide-drive",
609 .property = "ver",
610 .value = "0.10",
611 },{
612 .driver = "scsi-disk",
613 .property = "ver",
614 .value = "0.10",
Jordan Justen1b89faf2012-02-21 23:18:56 -0800615 },
Isaku Yamahata845773a2010-05-14 16:29:15 +0900616 { /* end of list */ }
617 },
Crístian Viana93bfef42012-05-30 00:35:51 -0300618 .hw_version = "0.10",
Isaku Yamahata845773a2010-05-14 16:29:15 +0900619};
620
621static QEMUMachine isapc_machine = {
622 .name = "isapc",
623 .desc = "ISA-only PC",
624 .init = pc_init_isa,
625 .max_cpus = 1,
Jordan Justen1b89faf2012-02-21 23:18:56 -0800626 .compat_props = (GlobalProperty[]) {
627 {
628 .driver = "pc-sysfw",
629 .property = "rom_only",
630 .value = stringify(1),
631 },
632 { /* end of list */ }
633 },
Isaku Yamahata845773a2010-05-14 16:29:15 +0900634};
635
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100636#ifdef CONFIG_XEN
637static QEMUMachine xenfv_machine = {
638 .name = "xenfv",
639 .desc = "Xen Fully-virtualized PC",
640 .init = pc_xen_hvm_init,
641 .max_cpus = HVM_MAX_VCPUS,
642 .default_machine_opts = "accel=xen",
643};
644#endif
645
Isaku Yamahata845773a2010-05-14 16:29:15 +0900646static void pc_machine_init(void)
647{
Gerd Hoffmannf1ae2e32012-12-04 14:39:16 +0100648 qemu_register_machine(&pc_machine_v1_4);
Gerd Hoffmannf4306942012-09-13 11:08:00 +0200649 qemu_register_machine(&pc_machine_v1_3);
Gerd Hoffmannf1dacf12012-06-11 10:38:22 +0200650 qemu_register_machine(&pc_machine_v1_2);
Jordan Justen382b3a62012-02-21 23:18:55 -0800651 qemu_register_machine(&pc_machine_v1_1);
Gerd Hoffmann19857e62011-11-07 16:33:08 +0100652 qemu_register_machine(&pc_machine_v1_0);
Anthony Liguorice01a502011-12-18 12:59:12 -0600653 qemu_register_machine(&pc_machine_v0_15);
Gerd Hoffmann19857e62011-11-07 16:33:08 +0100654 qemu_register_machine(&pc_machine_v0_14);
Gerd Hoffmannb903a0f2010-11-11 12:59:25 +0100655 qemu_register_machine(&pc_machine_v0_13);
Isaku Yamahata845773a2010-05-14 16:29:15 +0900656 qemu_register_machine(&pc_machine_v0_12);
657 qemu_register_machine(&pc_machine_v0_11);
658 qemu_register_machine(&pc_machine_v0_10);
659 qemu_register_machine(&isapc_machine);
Anthony PERARD29d3ccd2010-06-30 12:58:34 +0100660#ifdef CONFIG_XEN
661 qemu_register_machine(&xenfv_machine);
662#endif
Isaku Yamahata845773a2010-05-14 16:29:15 +0900663}
664
665machine_init(pc_machine_init);