xref: /qemu/hw/i386/pc_piix.c (revision 72ac97cd)
1 /*
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 
25 #include <glib.h>
26 
27 #include "hw/hw.h"
28 #include "hw/loader.h"
29 #include "hw/i386/pc.h"
30 #include "hw/i386/apic.h"
31 #include "hw/i386/smbios.h"
32 #include "hw/pci/pci.h"
33 #include "hw/pci/pci_ids.h"
34 #include "hw/usb.h"
35 #include "net/net.h"
36 #include "hw/boards.h"
37 #include "hw/ide.h"
38 #include "sysemu/kvm.h"
39 #include "hw/kvm/clock.h"
40 #include "sysemu/sysemu.h"
41 #include "hw/sysbus.h"
42 #include "hw/cpu/icc_bus.h"
43 #include "sysemu/arch_init.h"
44 #include "sysemu/blockdev.h"
45 #include "hw/i2c/smbus.h"
46 #include "hw/xen/xen.h"
47 #include "exec/memory.h"
48 #include "exec/address-spaces.h"
49 #include "hw/acpi/acpi.h"
50 #include "cpu.h"
51 #ifdef CONFIG_XEN
52 #  include <xen/hvm/hvm_info_table.h>
53 #endif
54 
55 #define MAX_IDE_BUS 2
56 
57 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
58 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
59 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
60 
61 static bool has_pci_info;
62 static bool has_acpi_build = true;
63 static bool smbios_defaults = true;
64 static bool smbios_legacy_mode;
65 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
66  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
67  * pages in the host.
68  */
69 static bool gigabyte_align = true;
70 
71 /* PC hardware initialisation */
72 static void pc_init1(MachineState *machine,
73                      int pci_enabled,
74                      int kvmclock_enabled)
75 {
76     MemoryRegion *system_memory = get_system_memory();
77     MemoryRegion *system_io = get_system_io();
78     int i;
79     ram_addr_t below_4g_mem_size, above_4g_mem_size;
80     PCIBus *pci_bus;
81     ISABus *isa_bus;
82     PCII440FXState *i440fx_state;
83     int piix3_devfn = -1;
84     qemu_irq *cpu_irq;
85     qemu_irq *gsi;
86     qemu_irq *i8259;
87     qemu_irq *smi_irq;
88     GSIState *gsi_state;
89     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
90     BusState *idebus[MAX_IDE_BUS];
91     ISADevice *rtc_state;
92     ISADevice *floppy;
93     MemoryRegion *ram_memory;
94     MemoryRegion *pci_memory;
95     MemoryRegion *rom_memory;
96     DeviceState *icc_bridge;
97     FWCfgState *fw_cfg = NULL;
98     PcGuestInfo *guest_info;
99 
100     if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
101         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
102         exit(1);
103     }
104 
105     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
106     object_property_add_child(qdev_get_machine(), "icc-bridge",
107                               OBJECT(icc_bridge), NULL);
108 
109     pc_cpus_init(machine->cpu_model, icc_bridge);
110 
111     if (kvm_enabled() && kvmclock_enabled) {
112         kvmclock_create();
113     }
114 
115     /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
116      * If it doesn't, we need to split it in chunks below and above 4G.
117      * In any case, try to make sure that guest addresses aligned at
118      * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
119      * For old machine types, use whatever split we used historically to avoid
120      * breaking migration.
121      */
122     if (machine->ram_size >= 0xe0000000) {
123         ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
124         above_4g_mem_size = machine->ram_size - lowmem;
125         below_4g_mem_size = lowmem;
126     } else {
127         above_4g_mem_size = 0;
128         below_4g_mem_size = machine->ram_size;
129     }
130 
131     if (pci_enabled) {
132         pci_memory = g_new(MemoryRegion, 1);
133         memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
134         rom_memory = pci_memory;
135     } else {
136         pci_memory = NULL;
137         rom_memory = system_memory;
138     }
139 
140     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
141 
142     guest_info->has_acpi_build = has_acpi_build;
143 
144     guest_info->has_pci_info = has_pci_info;
145     guest_info->isapc_ram_fw = !pci_enabled;
146 
147     if (smbios_defaults) {
148         MachineClass *mc = MACHINE_GET_CLASS(machine);
149         /* These values are guest ABI, do not change */
150         smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
151                             mc->name, smbios_legacy_mode);
152     }
153 
154     /* allocate ram and load rom/bios */
155     if (!xen_enabled()) {
156         fw_cfg = pc_memory_init(system_memory,
157                        machine->kernel_filename, machine->kernel_cmdline,
158                        machine->initrd_filename,
159                        below_4g_mem_size, above_4g_mem_size,
160                        rom_memory, &ram_memory, guest_info);
161     }
162 
163     gsi_state = g_malloc0(sizeof(*gsi_state));
164     if (kvm_irqchip_in_kernel()) {
165         kvm_pc_setup_irq_routing(pci_enabled);
166         gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
167                                  GSI_NUM_PINS);
168     } else {
169         gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
170     }
171 
172     if (pci_enabled) {
173         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
174                               system_memory, system_io, machine->ram_size,
175                               below_4g_mem_size,
176                               above_4g_mem_size,
177                               pci_memory, ram_memory);
178     } else {
179         pci_bus = NULL;
180         i440fx_state = NULL;
181         isa_bus = isa_bus_new(NULL, system_io);
182         no_hpet = 1;
183     }
184     isa_bus_irqs(isa_bus, gsi);
185 
186     if (kvm_irqchip_in_kernel()) {
187         i8259 = kvm_i8259_init(isa_bus);
188     } else if (xen_enabled()) {
189         i8259 = xen_interrupt_controller_init();
190     } else {
191         cpu_irq = pc_allocate_cpu_irq();
192         i8259 = i8259_init(isa_bus, cpu_irq[0]);
193     }
194 
195     for (i = 0; i < ISA_NUM_IRQS; i++) {
196         gsi_state->i8259_irq[i] = i8259[i];
197     }
198     if (pci_enabled) {
199         ioapic_init_gsi(gsi_state, "i440fx");
200     }
201     qdev_init_nofail(icc_bridge);
202 
203     pc_register_ferr_irq(gsi[13]);
204 
205     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
206 
207     /* init basic PC hardware */
208     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(),
209         0x4);
210 
211     pc_nic_init(isa_bus, pci_bus);
212 
213     ide_drive_get(hd, MAX_IDE_BUS);
214     if (pci_enabled) {
215         PCIDevice *dev;
216         if (xen_enabled()) {
217             dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
218         } else {
219             dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
220         }
221         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
222         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
223     } else {
224         for(i = 0; i < MAX_IDE_BUS; i++) {
225             ISADevice *dev;
226             char busname[] = "ide.0";
227             dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
228                                ide_irq[i],
229                                hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
230             /*
231              * The ide bus name is ide.0 for the first bus and ide.1 for the
232              * second one.
233              */
234             busname[4] = '0' + i;
235             idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
236         }
237     }
238 
239     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
240                  floppy, idebus[0], idebus[1], rtc_state);
241 
242     if (pci_enabled && usb_enabled(false)) {
243         pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
244     }
245 
246     if (pci_enabled && acpi_enabled) {
247         I2CBus *smbus;
248 
249         smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
250         /* TODO: Populate SPD eeprom data.  */
251         smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
252                               gsi[9], *smi_irq,
253                               kvm_enabled(), fw_cfg);
254         smbus_eeprom_init(smbus, 8, NULL, 0);
255     }
256 
257     if (pci_enabled) {
258         pc_pci_device_init(pci_bus);
259     }
260 }
261 
262 static void pc_init_pci(MachineState *machine)
263 {
264     pc_init1(machine, 1, 1);
265 }
266 
267 static void pc_compat_2_0(MachineState *machine)
268 {
269     smbios_legacy_mode = true;
270 }
271 
272 static void pc_compat_1_7(MachineState *machine)
273 {
274     pc_compat_2_0(machine);
275     smbios_defaults = false;
276     gigabyte_align = false;
277     option_rom_has_mr = true;
278     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
279 }
280 
281 static void pc_compat_1_6(MachineState *machine)
282 {
283     pc_compat_1_7(machine);
284     has_pci_info = false;
285     rom_file_has_mr = false;
286     has_acpi_build = false;
287 }
288 
289 static void pc_compat_1_5(MachineState *machine)
290 {
291     pc_compat_1_6(machine);
292 }
293 
294 static void pc_compat_1_4(MachineState *machine)
295 {
296     pc_compat_1_5(machine);
297     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
298     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
299 }
300 
301 static void pc_compat_1_3(MachineState *machine)
302 {
303     pc_compat_1_4(machine);
304     enable_compat_apic_id_mode();
305 }
306 
307 /* PC compat function for pc-0.14 to pc-1.2 */
308 static void pc_compat_1_2(MachineState *machine)
309 {
310     pc_compat_1_3(machine);
311     x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
312 }
313 
314 static void pc_init_pci_2_0(MachineState *machine)
315 {
316     pc_compat_2_0(machine);
317     pc_init_pci(machine);
318 }
319 
320 static void pc_init_pci_1_7(MachineState *machine)
321 {
322     pc_compat_1_7(machine);
323     pc_init_pci(machine);
324 }
325 
326 static void pc_init_pci_1_6(MachineState *machine)
327 {
328     pc_compat_1_6(machine);
329     pc_init_pci(machine);
330 }
331 
332 static void pc_init_pci_1_5(MachineState *machine)
333 {
334     pc_compat_1_5(machine);
335     pc_init_pci(machine);
336 }
337 
338 static void pc_init_pci_1_4(MachineState *machine)
339 {
340     pc_compat_1_4(machine);
341     pc_init_pci(machine);
342 }
343 
344 static void pc_init_pci_1_3(MachineState *machine)
345 {
346     pc_compat_1_3(machine);
347     pc_init_pci(machine);
348 }
349 
350 /* PC machine init function for pc-0.14 to pc-1.2 */
351 static void pc_init_pci_1_2(MachineState *machine)
352 {
353     pc_compat_1_2(machine);
354     pc_init_pci(machine);
355 }
356 
357 /* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
358 static void pc_init_pci_no_kvmclock(MachineState *machine)
359 {
360     has_pci_info = false;
361     has_acpi_build = false;
362     smbios_defaults = false;
363     x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
364     enable_compat_apic_id_mode();
365     pc_init1(machine, 1, 0);
366 }
367 
368 static void pc_init_isa(MachineState *machine)
369 {
370     has_pci_info = false;
371     has_acpi_build = false;
372     smbios_defaults = false;
373     if (!machine->cpu_model) {
374         machine->cpu_model = "486";
375     }
376     x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
377     enable_compat_apic_id_mode();
378     pc_init1(machine, 0, 1);
379 }
380 
381 #ifdef CONFIG_XEN
382 static void pc_xen_hvm_init(MachineState *machine)
383 {
384     PCIBus *bus;
385 
386     pc_init_pci(machine);
387 
388     bus = pci_find_primary_bus();
389     if (bus != NULL) {
390         pci_create_simple(bus, -1, "xen-platform");
391     }
392 }
393 #endif
394 
395 #define PC_I440FX_MACHINE_OPTIONS \
396     PC_DEFAULT_MACHINE_OPTIONS, \
397     .desc = "Standard PC (i440FX + PIIX, 1996)", \
398     .hot_add_cpu = pc_hot_add_cpu
399 
400 #define PC_I440FX_2_1_MACHINE_OPTIONS                           \
401     PC_I440FX_MACHINE_OPTIONS,                                  \
402     .default_machine_opts = "firmware=bios-256k.bin"
403 
404 static QEMUMachine pc_i440fx_machine_v2_1 = {
405     PC_I440FX_2_1_MACHINE_OPTIONS,
406     .name = "pc-i440fx-2.1",
407     .alias = "pc",
408     .init = pc_init_pci,
409     .is_default = 1,
410 };
411 
412 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
413 
414 static QEMUMachine pc_i440fx_machine_v2_0 = {
415     PC_I440FX_2_0_MACHINE_OPTIONS,
416     .name = "pc-i440fx-2.0",
417     .init = pc_init_pci_2_0,
418     .compat_props = (GlobalProperty[]) {
419         PC_COMPAT_2_0,
420         { /* end of list */ }
421     },
422 };
423 
424 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
425 
426 static QEMUMachine pc_i440fx_machine_v1_7 = {
427     PC_I440FX_1_7_MACHINE_OPTIONS,
428     .name = "pc-i440fx-1.7",
429     .init = pc_init_pci_1_7,
430     .compat_props = (GlobalProperty[]) {
431         PC_COMPAT_1_7,
432         { /* end of list */ }
433     },
434 };
435 
436 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
437 
438 static QEMUMachine pc_i440fx_machine_v1_6 = {
439     PC_I440FX_1_6_MACHINE_OPTIONS,
440     .name = "pc-i440fx-1.6",
441     .init = pc_init_pci_1_6,
442     .compat_props = (GlobalProperty[]) {
443         PC_COMPAT_1_6,
444         { /* end of list */ }
445     },
446 };
447 
448 static QEMUMachine pc_i440fx_machine_v1_5 = {
449     PC_I440FX_1_6_MACHINE_OPTIONS,
450     .name = "pc-i440fx-1.5",
451     .init = pc_init_pci_1_5,
452     .compat_props = (GlobalProperty[]) {
453         PC_COMPAT_1_5,
454         { /* end of list */ }
455     },
456 };
457 
458 #define PC_I440FX_1_4_MACHINE_OPTIONS \
459     PC_I440FX_1_6_MACHINE_OPTIONS, \
460     .hot_add_cpu = NULL
461 
462 static QEMUMachine pc_i440fx_machine_v1_4 = {
463     PC_I440FX_1_4_MACHINE_OPTIONS,
464     .name = "pc-i440fx-1.4",
465     .init = pc_init_pci_1_4,
466     .compat_props = (GlobalProperty[]) {
467         PC_COMPAT_1_4,
468         { /* end of list */ }
469     },
470 };
471 
472 #define PC_COMPAT_1_3 \
473 	PC_COMPAT_1_4, \
474         {\
475             .driver   = "usb-tablet",\
476             .property = "usb_version",\
477             .value    = stringify(1),\
478         },{\
479             .driver   = "virtio-net-pci",\
480             .property = "ctrl_mac_addr",\
481             .value    = "off",      \
482         },{ \
483             .driver   = "virtio-net-pci", \
484             .property = "mq", \
485             .value    = "off", \
486         }, {\
487             .driver   = "e1000",\
488             .property = "autonegotiation",\
489             .value    = "off",\
490         }
491 
492 static QEMUMachine pc_machine_v1_3 = {
493     PC_I440FX_1_4_MACHINE_OPTIONS,
494     .name = "pc-1.3",
495     .init = pc_init_pci_1_3,
496     .compat_props = (GlobalProperty[]) {
497         PC_COMPAT_1_3,
498         { /* end of list */ }
499     },
500 };
501 
502 #define PC_COMPAT_1_2 \
503         PC_COMPAT_1_3,\
504         {\
505             .driver   = "nec-usb-xhci",\
506             .property = "msi",\
507             .value    = "off",\
508         },{\
509             .driver   = "nec-usb-xhci",\
510             .property = "msix",\
511             .value    = "off",\
512         },{\
513             .driver   = "ivshmem",\
514             .property = "use64",\
515             .value    = "0",\
516         },{\
517             .driver   = "qxl",\
518             .property = "revision",\
519             .value    = stringify(3),\
520         },{\
521             .driver   = "qxl-vga",\
522             .property = "revision",\
523             .value    = stringify(3),\
524         },{\
525             .driver   = "VGA",\
526             .property = "mmio",\
527             .value    = "off",\
528         }
529 
530 #define PC_I440FX_1_2_MACHINE_OPTIONS \
531     PC_I440FX_1_4_MACHINE_OPTIONS, \
532     .init = pc_init_pci_1_2
533 
534 static QEMUMachine pc_machine_v1_2 = {
535     PC_I440FX_1_2_MACHINE_OPTIONS,
536     .name = "pc-1.2",
537     .compat_props = (GlobalProperty[]) {
538         PC_COMPAT_1_2,
539         { /* end of list */ }
540     },
541 };
542 
543 #define PC_COMPAT_1_1 \
544         PC_COMPAT_1_2,\
545         {\
546             .driver   = "virtio-scsi-pci",\
547             .property = "hotplug",\
548             .value    = "off",\
549         },{\
550             .driver   = "virtio-scsi-pci",\
551             .property = "param_change",\
552             .value    = "off",\
553         },{\
554             .driver   = "VGA",\
555             .property = "vgamem_mb",\
556             .value    = stringify(8),\
557         },{\
558             .driver   = "vmware-svga",\
559             .property = "vgamem_mb",\
560             .value    = stringify(8),\
561         },{\
562             .driver   = "qxl-vga",\
563             .property = "vgamem_mb",\
564             .value    = stringify(8),\
565         },{\
566             .driver   = "qxl",\
567             .property = "vgamem_mb",\
568             .value    = stringify(8),\
569         },{\
570             .driver   = "virtio-blk-pci",\
571             .property = "config-wce",\
572             .value    = "off",\
573         }
574 
575 static QEMUMachine pc_machine_v1_1 = {
576     PC_I440FX_1_2_MACHINE_OPTIONS,
577     .name = "pc-1.1",
578     .compat_props = (GlobalProperty[]) {
579         PC_COMPAT_1_1,
580         { /* end of list */ }
581     },
582 };
583 
584 #define PC_COMPAT_1_0 \
585         PC_COMPAT_1_1,\
586         {\
587             .driver   = TYPE_ISA_FDC,\
588             .property = "check_media_rate",\
589             .value    = "off",\
590         }, {\
591             .driver   = "virtio-balloon-pci",\
592             .property = "class",\
593             .value    = stringify(PCI_CLASS_MEMORY_RAM),\
594         },{\
595             .driver   = "apic",\
596             .property = "vapic",\
597             .value    = "off",\
598         },{\
599             .driver   = TYPE_USB_DEVICE,\
600             .property = "full-path",\
601             .value    = "no",\
602         }
603 
604 static QEMUMachine pc_machine_v1_0 = {
605     PC_I440FX_1_2_MACHINE_OPTIONS,
606     .name = "pc-1.0",
607     .compat_props = (GlobalProperty[]) {
608         PC_COMPAT_1_0,
609         { /* end of list */ }
610     },
611     .hw_version = "1.0",
612 };
613 
614 #define PC_COMPAT_0_15 \
615         PC_COMPAT_1_0
616 
617 static QEMUMachine pc_machine_v0_15 = {
618     PC_I440FX_1_2_MACHINE_OPTIONS,
619     .name = "pc-0.15",
620     .compat_props = (GlobalProperty[]) {
621         PC_COMPAT_0_15,
622         { /* end of list */ }
623     },
624     .hw_version = "0.15",
625 };
626 
627 #define PC_COMPAT_0_14 \
628         PC_COMPAT_0_15,\
629         {\
630             .driver   = "virtio-blk-pci",\
631             .property = "event_idx",\
632             .value    = "off",\
633         },{\
634             .driver   = "virtio-serial-pci",\
635             .property = "event_idx",\
636             .value    = "off",\
637         },{\
638             .driver   = "virtio-net-pci",\
639             .property = "event_idx",\
640             .value    = "off",\
641         },{\
642             .driver   = "virtio-balloon-pci",\
643             .property = "event_idx",\
644             .value    = "off",\
645         }
646 
647 static QEMUMachine pc_machine_v0_14 = {
648     PC_I440FX_1_2_MACHINE_OPTIONS,
649     .name = "pc-0.14",
650     .compat_props = (GlobalProperty[]) {
651         PC_COMPAT_0_14,
652         {
653             .driver   = "qxl",
654             .property = "revision",
655             .value    = stringify(2),
656         },{
657             .driver   = "qxl-vga",
658             .property = "revision",
659             .value    = stringify(2),
660         },
661         { /* end of list */ }
662     },
663     .hw_version = "0.14",
664 };
665 
666 #define PC_COMPAT_0_13 \
667         PC_COMPAT_0_14,\
668         {\
669             .driver   = TYPE_PCI_DEVICE,\
670             .property = "command_serr_enable",\
671             .value    = "off",\
672         },{\
673             .driver   = "AC97",\
674             .property = "use_broken_id",\
675             .value    = stringify(1),\
676         }
677 
678 #define PC_I440FX_0_13_MACHINE_OPTIONS \
679     PC_I440FX_1_2_MACHINE_OPTIONS, \
680     .init = pc_init_pci_no_kvmclock
681 
682 static QEMUMachine pc_machine_v0_13 = {
683     PC_I440FX_0_13_MACHINE_OPTIONS,
684     .name = "pc-0.13",
685     .compat_props = (GlobalProperty[]) {
686         PC_COMPAT_0_13,
687         {
688             .driver   = "virtio-9p-pci",
689             .property = "vectors",
690             .value    = stringify(0),
691         },{
692             .driver   = "VGA",
693             .property = "rombar",
694             .value    = stringify(0),
695         },{
696             .driver   = "vmware-svga",
697             .property = "rombar",
698             .value    = stringify(0),
699         },
700         { /* end of list */ }
701     },
702     .hw_version = "0.13",
703 };
704 
705 #define PC_COMPAT_0_12 \
706         PC_COMPAT_0_13,\
707         {\
708             .driver   = "virtio-serial-pci",\
709             .property = "max_ports",\
710             .value    = stringify(1),\
711         },{\
712             .driver   = "virtio-serial-pci",\
713             .property = "vectors",\
714             .value    = stringify(0),\
715         },{\
716             .driver   = "usb-mouse",\
717             .property = "serial",\
718             .value    = "1",\
719         },{\
720             .driver   = "usb-tablet",\
721             .property = "serial",\
722             .value    = "1",\
723         },{\
724             .driver   = "usb-kbd",\
725             .property = "serial",\
726             .value    = "1",\
727         }
728 
729 static QEMUMachine pc_machine_v0_12 = {
730     PC_I440FX_0_13_MACHINE_OPTIONS,
731     .name = "pc-0.12",
732     .compat_props = (GlobalProperty[]) {
733         PC_COMPAT_0_12,
734         {
735             .driver   = "VGA",
736             .property = "rombar",
737             .value    = stringify(0),
738         },{
739             .driver   = "vmware-svga",
740             .property = "rombar",
741             .value    = stringify(0),
742         },
743         { /* end of list */ }
744     },
745     .hw_version = "0.12",
746 };
747 
748 #define PC_COMPAT_0_11 \
749         PC_COMPAT_0_12,\
750         {\
751             .driver   = "virtio-blk-pci",\
752             .property = "vectors",\
753             .value    = stringify(0),\
754         },{\
755             .driver   = TYPE_PCI_DEVICE,\
756             .property = "rombar",\
757             .value    = stringify(0),\
758         }
759 
760 static QEMUMachine pc_machine_v0_11 = {
761     PC_I440FX_0_13_MACHINE_OPTIONS,
762     .name = "pc-0.11",
763     .compat_props = (GlobalProperty[]) {
764         PC_COMPAT_0_11,
765         {
766             .driver   = "ide-drive",
767             .property = "ver",
768             .value    = "0.11",
769         },{
770             .driver   = "scsi-disk",
771             .property = "ver",
772             .value    = "0.11",
773         },
774         { /* end of list */ }
775     },
776     .hw_version = "0.11",
777 };
778 
779 static QEMUMachine pc_machine_v0_10 = {
780     PC_I440FX_0_13_MACHINE_OPTIONS,
781     .name = "pc-0.10",
782     .compat_props = (GlobalProperty[]) {
783         PC_COMPAT_0_11,
784         {
785             .driver   = "virtio-blk-pci",
786             .property = "class",
787             .value    = stringify(PCI_CLASS_STORAGE_OTHER),
788         },{
789             .driver   = "virtio-serial-pci",
790             .property = "class",
791             .value    = stringify(PCI_CLASS_DISPLAY_OTHER),
792         },{
793             .driver   = "virtio-net-pci",
794             .property = "vectors",
795             .value    = stringify(0),
796         },{
797             .driver   = "ide-drive",
798             .property = "ver",
799             .value    = "0.10",
800         },{
801             .driver   = "scsi-disk",
802             .property = "ver",
803             .value    = "0.10",
804         },
805         { /* end of list */ }
806     },
807     .hw_version = "0.10",
808 };
809 
810 static QEMUMachine isapc_machine = {
811     PC_COMMON_MACHINE_OPTIONS,
812     .name = "isapc",
813     .desc = "ISA-only PC",
814     .init = pc_init_isa,
815     .max_cpus = 1,
816     .compat_props = (GlobalProperty[]) {
817         { /* end of list */ }
818     },
819 };
820 
821 #ifdef CONFIG_XEN
822 static QEMUMachine xenfv_machine = {
823     PC_COMMON_MACHINE_OPTIONS,
824     .name = "xenfv",
825     .desc = "Xen Fully-virtualized PC",
826     .init = pc_xen_hvm_init,
827     .max_cpus = HVM_MAX_VCPUS,
828     .default_machine_opts = "accel=xen",
829     .hot_add_cpu = pc_hot_add_cpu,
830     .compat_props = (GlobalProperty[]) {
831         /* xenfv has no fwcfg and so does not load acpi from QEMU.
832          * as such new acpi features don't work.
833          */
834         {
835             .driver   = "PIIX4_PM",
836             .property = "acpi-pci-hotplug-with-bridge-support",
837             .value    = "off",
838         },
839         { /* end of list */ }
840     },
841 };
842 #endif
843 
844 static void pc_machine_init(void)
845 {
846     qemu_register_machine(&pc_i440fx_machine_v2_1);
847     qemu_register_machine(&pc_i440fx_machine_v2_0);
848     qemu_register_machine(&pc_i440fx_machine_v1_7);
849     qemu_register_machine(&pc_i440fx_machine_v1_6);
850     qemu_register_machine(&pc_i440fx_machine_v1_5);
851     qemu_register_machine(&pc_i440fx_machine_v1_4);
852     qemu_register_machine(&pc_machine_v1_3);
853     qemu_register_machine(&pc_machine_v1_2);
854     qemu_register_machine(&pc_machine_v1_1);
855     qemu_register_machine(&pc_machine_v1_0);
856     qemu_register_machine(&pc_machine_v0_15);
857     qemu_register_machine(&pc_machine_v0_14);
858     qemu_register_machine(&pc_machine_v0_13);
859     qemu_register_machine(&pc_machine_v0_12);
860     qemu_register_machine(&pc_machine_v0_11);
861     qemu_register_machine(&pc_machine_v0_10);
862     qemu_register_machine(&isapc_machine);
863 #ifdef CONFIG_XEN
864     qemu_register_machine(&xenfv_machine);
865 #endif
866 }
867 
868 machine_init(pc_machine_init);
869