xref: /openbmc/qemu/hw/i386/pc_piix.c (revision 20d0f9cf6a41bad52baba3ebc485849617cc42cf)
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/smbios/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/block-backend.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 #include "qemu/error-report.h"
52 #ifdef CONFIG_XEN
53 #  include <xen/hvm/hvm_info_table.h>
54 #endif
55 #include "migration/migration.h"
56 
57 #define MAX_IDE_BUS 2
58 
59 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
60 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
61 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
62 
63 static bool pci_enabled = true;
64 static bool has_acpi_build = true;
65 static bool rsdp_in_ram = true;
66 static int legacy_acpi_table_size;
67 static bool smbios_defaults = true;
68 static bool smbios_legacy_mode;
69 static bool smbios_uuid_encoded = true;
70 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
71  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
72  * pages in the host.
73  */
74 static bool gigabyte_align = true;
75 static bool has_reserved_memory = true;
76 static bool kvmclock_enabled = true;
77 
78 /* PC hardware initialisation */
79 static void pc_init1(MachineState *machine)
80 {
81     PCMachineState *pcms = PC_MACHINE(machine);
82     MemoryRegion *system_memory = get_system_memory();
83     MemoryRegion *system_io = get_system_io();
84     int i;
85     PCIBus *pci_bus;
86     ISABus *isa_bus;
87     PCII440FXState *i440fx_state;
88     int piix3_devfn = -1;
89     qemu_irq *gsi;
90     qemu_irq *i8259;
91     qemu_irq smi_irq;
92     GSIState *gsi_state;
93     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
94     BusState *idebus[MAX_IDE_BUS];
95     ISADevice *rtc_state;
96     MemoryRegion *ram_memory;
97     MemoryRegion *pci_memory;
98     MemoryRegion *rom_memory;
99     DeviceState *icc_bridge;
100     PcGuestInfo *guest_info;
101     ram_addr_t lowmem;
102 
103     /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
104      * If it doesn't, we need to split it in chunks below and above 4G.
105      * In any case, try to make sure that guest addresses aligned at
106      * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
107      * For old machine types, use whatever split we used historically to avoid
108      * breaking migration.
109      */
110     if (machine->ram_size >= 0xe0000000) {
111         lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
112     } else {
113         lowmem = 0xe0000000;
114     }
115 
116     /* Handle the machine opt max-ram-below-4g.  It is basically doing
117      * min(qemu limit, user limit).
118      */
119     if (lowmem > pcms->max_ram_below_4g) {
120         lowmem = pcms->max_ram_below_4g;
121         if (machine->ram_size - lowmem > lowmem &&
122             lowmem & ((1ULL << 30) - 1)) {
123             error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
124                          ") not a multiple of 1G; possible bad performance.",
125                          pcms->max_ram_below_4g);
126         }
127     }
128 
129     if (machine->ram_size >= lowmem) {
130         pcms->above_4g_mem_size = machine->ram_size - lowmem;
131         pcms->below_4g_mem_size = lowmem;
132     } else {
133         pcms->above_4g_mem_size = 0;
134         pcms->below_4g_mem_size = machine->ram_size;
135     }
136 
137     if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
138                                       &pcms->above_4g_mem_size,
139                                       &ram_memory) != 0) {
140         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
141         exit(1);
142     }
143 
144     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
145     object_property_add_child(qdev_get_machine(), "icc-bridge",
146                               OBJECT(icc_bridge), NULL);
147 
148     pc_cpus_init(machine->cpu_model, icc_bridge);
149 
150     if (kvm_enabled() && kvmclock_enabled) {
151         kvmclock_create();
152     }
153 
154     if (pci_enabled) {
155         pci_memory = g_new(MemoryRegion, 1);
156         memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
157         rom_memory = pci_memory;
158     } else {
159         pci_memory = NULL;
160         rom_memory = system_memory;
161     }
162 
163     guest_info = pc_guest_info_init(pcms);
164 
165     guest_info->has_acpi_build = has_acpi_build;
166     guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
167 
168     guest_info->isapc_ram_fw = !pci_enabled;
169     guest_info->has_reserved_memory = has_reserved_memory;
170     guest_info->rsdp_in_ram = rsdp_in_ram;
171 
172     if (smbios_defaults) {
173         MachineClass *mc = MACHINE_GET_CLASS(machine);
174         /* These values are guest ABI, do not change */
175         smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
176                             mc->name, smbios_legacy_mode, smbios_uuid_encoded,
177                             SMBIOS_ENTRY_POINT_21);
178     }
179 
180     /* allocate ram and load rom/bios */
181     if (!xen_enabled()) {
182         pc_memory_init(pcms, system_memory,
183                        rom_memory, &ram_memory, guest_info);
184     } else if (machine->kernel_filename != NULL) {
185         /* For xen HVM direct kernel boot, load linux here */
186         xen_load_linux(pcms, guest_info);
187     }
188 
189     gsi_state = g_malloc0(sizeof(*gsi_state));
190     if (kvm_irqchip_in_kernel()) {
191         kvm_pc_setup_irq_routing(pci_enabled);
192         gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
193                                  GSI_NUM_PINS);
194     } else {
195         gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
196     }
197 
198     if (pci_enabled) {
199         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
200                               system_memory, system_io, machine->ram_size,
201                               pcms->below_4g_mem_size,
202                               pcms->above_4g_mem_size,
203                               pci_memory, ram_memory);
204     } else {
205         pci_bus = NULL;
206         i440fx_state = NULL;
207         isa_bus = isa_bus_new(NULL, get_system_memory(), system_io);
208         no_hpet = 1;
209     }
210     isa_bus_irqs(isa_bus, gsi);
211 
212     if (kvm_irqchip_in_kernel()) {
213         i8259 = kvm_i8259_init(isa_bus);
214     } else if (xen_enabled()) {
215         i8259 = xen_interrupt_controller_init();
216     } else {
217         i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
218     }
219 
220     for (i = 0; i < ISA_NUM_IRQS; i++) {
221         gsi_state->i8259_irq[i] = i8259[i];
222     }
223     g_free(i8259);
224     if (pci_enabled) {
225         ioapic_init_gsi(gsi_state, "i440fx");
226     }
227     qdev_init_nofail(icc_bridge);
228 
229     pc_register_ferr_irq(gsi[13]);
230 
231     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
232 
233     assert(pcms->vmport != ON_OFF_AUTO_MAX);
234     if (pcms->vmport == ON_OFF_AUTO_AUTO) {
235         pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
236     }
237 
238     /* init basic PC hardware */
239     pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
240                          (pcms->vmport != ON_OFF_AUTO_ON), 0x4);
241 
242     pc_nic_init(isa_bus, pci_bus);
243 
244     ide_drive_get(hd, ARRAY_SIZE(hd));
245     if (pci_enabled) {
246         PCIDevice *dev;
247         if (xen_enabled()) {
248             dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
249         } else {
250             dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
251         }
252         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
253         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
254     } else {
255         for(i = 0; i < MAX_IDE_BUS; i++) {
256             ISADevice *dev;
257             char busname[] = "ide.0";
258             dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
259                                ide_irq[i],
260                                hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
261             /*
262              * The ide bus name is ide.0 for the first bus and ide.1 for the
263              * second one.
264              */
265             busname[4] = '0' + i;
266             idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
267         }
268     }
269 
270     pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
271 
272     if (pci_enabled && usb_enabled()) {
273         pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
274     }
275 
276     if (pci_enabled && acpi_enabled) {
277         DeviceState *piix4_pm;
278         I2CBus *smbus;
279 
280         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
281         /* TODO: Populate SPD eeprom data.  */
282         smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
283                               gsi[9], smi_irq,
284                               pc_machine_is_smm_enabled(pcms),
285                               &piix4_pm);
286         smbus_eeprom_init(smbus, 8, NULL, 0);
287 
288         object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
289                                  TYPE_HOTPLUG_HANDLER,
290                                  (Object **)&pcms->acpi_dev,
291                                  object_property_allow_set_link,
292                                  OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
293         object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
294                                  PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
295     }
296 
297     if (pci_enabled) {
298         pc_pci_device_init(pci_bus);
299     }
300 }
301 
302 static void pc_compat_2_3(MachineState *machine)
303 {
304     PCMachineState *pcms = PC_MACHINE(machine);
305     savevm_skip_section_footers();
306     if (kvm_enabled()) {
307         pcms->smm = ON_OFF_AUTO_OFF;
308     }
309     global_state_set_optional();
310     savevm_skip_configuration();
311 }
312 
313 static void pc_compat_2_2(MachineState *machine)
314 {
315     pc_compat_2_3(machine);
316     rsdp_in_ram = false;
317     machine->suppress_vmdesc = true;
318 }
319 
320 static void pc_compat_2_1(MachineState *machine)
321 {
322     PCMachineState *pcms = PC_MACHINE(machine);
323 
324     pc_compat_2_2(machine);
325     smbios_uuid_encoded = false;
326     x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
327     pcms->enforce_aligned_dimm = false;
328 }
329 
330 static void pc_compat_2_0(MachineState *machine)
331 {
332     pc_compat_2_1(machine);
333     /* This value depends on the actual DSDT and SSDT compiled into
334      * the source QEMU; unfortunately it depends on the binary and
335      * not on the machine type, so we cannot make pc-i440fx-1.7 work on
336      * both QEMU 1.7 and QEMU 2.0.
337      *
338      * Large variations cause migration to fail for more than one
339      * consecutive value of the "-smp" maxcpus option.
340      *
341      * For small variations of the kind caused by different iasl versions,
342      * the 4k rounding usually leaves slack.  However, there could be still
343      * one or two values that break.  For QEMU 1.7 and QEMU 2.0 the
344      * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
345      *
346      * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
347      * QEMU 1.7 it is 6414.  For RHEL/CentOS 7.0 it is 6418.
348      */
349     legacy_acpi_table_size = 6652;
350     smbios_legacy_mode = true;
351     has_reserved_memory = false;
352     pc_set_legacy_acpi_data_size();
353 }
354 
355 static void pc_compat_1_7(MachineState *machine)
356 {
357     pc_compat_2_0(machine);
358     smbios_defaults = false;
359     gigabyte_align = false;
360     option_rom_has_mr = true;
361     legacy_acpi_table_size = 6414;
362     x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
363 }
364 
365 static void pc_compat_1_6(MachineState *machine)
366 {
367     pc_compat_1_7(machine);
368     rom_file_has_mr = false;
369     has_acpi_build = false;
370 }
371 
372 static void pc_compat_1_5(MachineState *machine)
373 {
374     pc_compat_1_6(machine);
375 }
376 
377 static void pc_compat_1_4(MachineState *machine)
378 {
379     pc_compat_1_5(machine);
380 }
381 
382 static void pc_compat_1_3(MachineState *machine)
383 {
384     pc_compat_1_4(machine);
385     enable_compat_apic_id_mode();
386 }
387 
388 /* PC compat function for pc-0.14 to pc-1.2 */
389 static void pc_compat_1_2(MachineState *machine)
390 {
391     pc_compat_1_3(machine);
392     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
393 }
394 
395 /* PC compat function for pc-0.10 to pc-0.13 */
396 static void pc_compat_0_13(MachineState *machine)
397 {
398     pc_compat_1_2(machine);
399     kvmclock_enabled = false;
400 }
401 
402 static void pc_init_isa(MachineState *machine)
403 {
404     pci_enabled = false;
405     has_acpi_build = false;
406     smbios_defaults = false;
407     gigabyte_align = false;
408     smbios_legacy_mode = true;
409     has_reserved_memory = false;
410     option_rom_has_mr = true;
411     rom_file_has_mr = false;
412     if (!machine->cpu_model) {
413         machine->cpu_model = "486";
414     }
415     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
416     enable_compat_apic_id_mode();
417     pc_init1(machine);
418 }
419 
420 #ifdef CONFIG_XEN
421 static void pc_xen_hvm_init(MachineState *machine)
422 {
423     PCIBus *bus;
424 
425     pc_init1(machine);
426 
427     bus = pci_find_primary_bus();
428     if (bus != NULL) {
429         pci_create_simple(bus, -1, "xen-platform");
430     }
431 }
432 #endif
433 
434 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
435     static void pc_init_##suffix(MachineState *machine) \
436     { \
437         void (*compat)(MachineState *m) = (compatfn); \
438         if (compat) { \
439             compat(machine); \
440         } \
441         pc_init1(machine); \
442     } \
443     DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
444 
445 static void pc_i440fx_machine_options(MachineClass *m)
446 {
447     m->family = "pc_piix";
448     m->desc = "Standard PC (i440FX + PIIX, 1996)";
449     m->hot_add_cpu = pc_hot_add_cpu;
450 }
451 
452 static void pc_i440fx_2_4_machine_options(MachineClass *m)
453 {
454     pc_i440fx_machine_options(m);
455     m->default_machine_opts = "firmware=bios-256k.bin";
456     m->default_display = "std";
457     m->alias = "pc";
458     m->is_default = 1;
459 }
460 
461 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
462                       pc_i440fx_2_4_machine_options)
463 
464 
465 static void pc_i440fx_2_3_machine_options(MachineClass *m)
466 {
467     pc_i440fx_2_4_machine_options(m);
468     m->alias = NULL;
469     m->is_default = 0;
470     SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
471 }
472 
473 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
474                       pc_i440fx_2_3_machine_options);
475 
476 
477 static void pc_i440fx_2_2_machine_options(MachineClass *m)
478 {
479     pc_i440fx_2_3_machine_options(m);
480     SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
481 }
482 
483 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
484                       pc_i440fx_2_2_machine_options);
485 
486 
487 static void pc_i440fx_2_1_machine_options(MachineClass *m)
488 {
489     pc_i440fx_2_2_machine_options(m);
490     m->default_display = NULL;
491     SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
492 }
493 
494 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
495                       pc_i440fx_2_1_machine_options);
496 
497 
498 
499 static void pc_i440fx_2_0_machine_options(MachineClass *m)
500 {
501     pc_i440fx_2_1_machine_options(m);
502     SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
503 }
504 
505 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
506                       pc_i440fx_2_0_machine_options);
507 
508 
509 static void pc_i440fx_1_7_machine_options(MachineClass *m)
510 {
511     pc_i440fx_2_0_machine_options(m);
512     m->default_machine_opts = NULL;
513     SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
514 }
515 
516 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
517                       pc_i440fx_1_7_machine_options);
518 
519 
520 static void pc_i440fx_1_6_machine_options(MachineClass *m)
521 {
522     pc_i440fx_1_7_machine_options(m);
523     SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
524 }
525 
526 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
527                       pc_i440fx_1_6_machine_options);
528 
529 
530 static void pc_i440fx_1_5_machine_options(MachineClass *m)
531 {
532     pc_i440fx_1_6_machine_options(m);
533     SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
534 }
535 
536 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
537                       pc_i440fx_1_5_machine_options);
538 
539 
540 static void pc_i440fx_1_4_machine_options(MachineClass *m)
541 {
542     pc_i440fx_1_5_machine_options(m);
543     m->hot_add_cpu = NULL;
544     SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
545 }
546 
547 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
548                       pc_i440fx_1_4_machine_options);
549 
550 
551 #define PC_COMPAT_1_3 \
552         PC_COMPAT_1_4 \
553         {\
554             .driver   = "usb-tablet",\
555             .property = "usb_version",\
556             .value    = stringify(1),\
557         },{\
558             .driver   = "virtio-net-pci",\
559             .property = "ctrl_mac_addr",\
560             .value    = "off",      \
561         },{ \
562             .driver   = "virtio-net-pci", \
563             .property = "mq", \
564             .value    = "off", \
565         }, {\
566             .driver   = "e1000",\
567             .property = "autonegotiation",\
568             .value    = "off",\
569         },
570 
571 
572 static void pc_i440fx_1_3_machine_options(MachineClass *m)
573 {
574     pc_i440fx_1_4_machine_options(m);
575     SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
576 }
577 
578 DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
579                       pc_i440fx_1_3_machine_options);
580 
581 
582 #define PC_COMPAT_1_2 \
583         PC_COMPAT_1_3 \
584         {\
585             .driver   = "nec-usb-xhci",\
586             .property = "msi",\
587             .value    = "off",\
588         },{\
589             .driver   = "nec-usb-xhci",\
590             .property = "msix",\
591             .value    = "off",\
592         },{\
593             .driver   = "ivshmem",\
594             .property = "use64",\
595             .value    = "0",\
596         },{\
597             .driver   = "qxl",\
598             .property = "revision",\
599             .value    = stringify(3),\
600         },{\
601             .driver   = "qxl-vga",\
602             .property = "revision",\
603             .value    = stringify(3),\
604         },{\
605             .driver   = "VGA",\
606             .property = "mmio",\
607             .value    = "off",\
608         },
609 
610 static void pc_i440fx_1_2_machine_options(MachineClass *m)
611 {
612     pc_i440fx_1_3_machine_options(m);
613     SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
614 }
615 
616 DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
617                       pc_i440fx_1_2_machine_options);
618 
619 
620 #define PC_COMPAT_1_1 \
621         PC_COMPAT_1_2 \
622         {\
623             .driver   = "virtio-scsi-pci",\
624             .property = "hotplug",\
625             .value    = "off",\
626         },{\
627             .driver   = "virtio-scsi-pci",\
628             .property = "param_change",\
629             .value    = "off",\
630         },{\
631             .driver   = "VGA",\
632             .property = "vgamem_mb",\
633             .value    = stringify(8),\
634         },{\
635             .driver   = "vmware-svga",\
636             .property = "vgamem_mb",\
637             .value    = stringify(8),\
638         },{\
639             .driver   = "qxl-vga",\
640             .property = "vgamem_mb",\
641             .value    = stringify(8),\
642         },{\
643             .driver   = "qxl",\
644             .property = "vgamem_mb",\
645             .value    = stringify(8),\
646         },{\
647             .driver   = "virtio-blk-pci",\
648             .property = "config-wce",\
649             .value    = "off",\
650         },
651 
652 static void pc_i440fx_1_1_machine_options(MachineClass *m)
653 {
654     pc_i440fx_1_2_machine_options(m);
655     SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
656 }
657 
658 DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
659                       pc_i440fx_1_1_machine_options);
660 
661 
662 #define PC_COMPAT_1_0 \
663         PC_COMPAT_1_1 \
664         {\
665             .driver   = TYPE_ISA_FDC,\
666             .property = "check_media_rate",\
667             .value    = "off",\
668         }, {\
669             .driver   = "virtio-balloon-pci",\
670             .property = "class",\
671             .value    = stringify(PCI_CLASS_MEMORY_RAM),\
672         },{\
673             .driver   = "apic-common",\
674             .property = "vapic",\
675             .value    = "off",\
676         },{\
677             .driver   = TYPE_USB_DEVICE,\
678             .property = "full-path",\
679             .value    = "no",\
680         },
681 
682 static void pc_i440fx_1_0_machine_options(MachineClass *m)
683 {
684     pc_i440fx_1_1_machine_options(m);
685     m->hw_version = "1.0";
686     SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
687 }
688 
689 DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
690                       pc_i440fx_1_0_machine_options);
691 
692 
693 #define PC_COMPAT_0_15 \
694         PC_COMPAT_1_0
695 
696 static void pc_i440fx_0_15_machine_options(MachineClass *m)
697 {
698     pc_i440fx_1_0_machine_options(m);
699     m->hw_version = "0.15";
700     SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
701 }
702 
703 DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
704                       pc_i440fx_0_15_machine_options);
705 
706 
707 #define PC_COMPAT_0_14 \
708         PC_COMPAT_0_15 \
709         {\
710             .driver   = "virtio-blk-pci",\
711             .property = "event_idx",\
712             .value    = "off",\
713         },{\
714             .driver   = "virtio-serial-pci",\
715             .property = "event_idx",\
716             .value    = "off",\
717         },{\
718             .driver   = "virtio-net-pci",\
719             .property = "event_idx",\
720             .value    = "off",\
721         },{\
722             .driver   = "virtio-balloon-pci",\
723             .property = "event_idx",\
724             .value    = "off",\
725         },{\
726             .driver   = "qxl",\
727             .property = "revision",\
728             .value    = stringify(2),\
729         },{\
730             .driver   = "qxl-vga",\
731             .property = "revision",\
732             .value    = stringify(2),\
733         },
734 
735 static void pc_i440fx_0_14_machine_options(MachineClass *m)
736 {
737     pc_i440fx_0_15_machine_options(m);
738     m->hw_version = "0.14";
739     SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
740 }
741 
742 DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
743                       pc_i440fx_0_14_machine_options);
744 
745 
746 #define PC_COMPAT_0_13 \
747         PC_COMPAT_0_14 \
748         {\
749             .driver   = TYPE_PCI_DEVICE,\
750             .property = "command_serr_enable",\
751             .value    = "off",\
752         },{\
753             .driver   = "AC97",\
754             .property = "use_broken_id",\
755             .value    = stringify(1),\
756         },{\
757             .driver   = "virtio-9p-pci",\
758             .property = "vectors",\
759             .value    = stringify(0),\
760         },{\
761             .driver   = "VGA",\
762             .property = "rombar",\
763             .value    = stringify(0),\
764         },{\
765             .driver   = "vmware-svga",\
766             .property = "rombar",\
767             .value    = stringify(0),\
768         },
769 
770 static void pc_i440fx_0_13_machine_options(MachineClass *m)
771 {
772     pc_i440fx_0_14_machine_options(m);
773     m->hw_version = "0.13";
774     SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
775 }
776 
777 DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
778                       pc_i440fx_0_13_machine_options);
779 
780 
781 #define PC_COMPAT_0_12 \
782         PC_COMPAT_0_13 \
783         {\
784             .driver   = "virtio-serial-pci",\
785             .property = "max_ports",\
786             .value    = stringify(1),\
787         },{\
788             .driver   = "virtio-serial-pci",\
789             .property = "vectors",\
790             .value    = stringify(0),\
791         },{\
792             .driver   = "usb-mouse",\
793             .property = "serial",\
794             .value    = "1",\
795         },{\
796             .driver   = "usb-tablet",\
797             .property = "serial",\
798             .value    = "1",\
799         },{\
800             .driver   = "usb-kbd",\
801             .property = "serial",\
802             .value    = "1",\
803         },
804 
805 static void pc_i440fx_0_12_machine_options(MachineClass *m)
806 {
807     pc_i440fx_0_13_machine_options(m);
808     m->hw_version = "0.12";
809     SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
810 }
811 
812 DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
813                       pc_i440fx_0_12_machine_options);
814 
815 
816 #define PC_COMPAT_0_11 \
817         PC_COMPAT_0_12 \
818         {\
819             .driver   = "virtio-blk-pci",\
820             .property = "vectors",\
821             .value    = stringify(0),\
822         },{\
823             .driver   = TYPE_PCI_DEVICE,\
824             .property = "rombar",\
825             .value    = stringify(0),\
826         },{\
827             .driver   = "ide-drive",\
828             .property = "ver",\
829             .value    = "0.11",\
830         },{\
831             .driver   = "scsi-disk",\
832             .property = "ver",\
833             .value    = "0.11",\
834         },
835 
836 static void pc_i440fx_0_11_machine_options(MachineClass *m)
837 {
838     pc_i440fx_0_12_machine_options(m);
839     m->hw_version = "0.11";
840     SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
841 }
842 
843 DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
844                       pc_i440fx_0_11_machine_options);
845 
846 
847 #define PC_COMPAT_0_10 \
848     PC_COMPAT_0_11 \
849     {\
850         .driver   = "virtio-blk-pci",\
851         .property = "class",\
852         .value    = stringify(PCI_CLASS_STORAGE_OTHER),\
853     },{\
854         .driver   = "virtio-serial-pci",\
855         .property = "class",\
856         .value    = stringify(PCI_CLASS_DISPLAY_OTHER),\
857     },{\
858         .driver   = "virtio-net-pci",\
859         .property = "vectors",\
860         .value    = stringify(0),\
861     },{\
862         .driver   = "ide-drive",\
863         .property = "ver",\
864         .value    = "0.10",\
865     },{\
866         .driver   = "scsi-disk",\
867         .property = "ver",\
868         .value    = "0.10",\
869     },
870 
871 static void pc_i440fx_0_10_machine_options(MachineClass *m)
872 {
873     pc_i440fx_0_11_machine_options(m);
874     m->hw_version = "0.10";
875     SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
876 }
877 
878 DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
879                       pc_i440fx_0_10_machine_options);
880 
881 
882 static void isapc_machine_options(MachineClass *m)
883 {
884     m->desc = "ISA-only PC";
885     m->max_cpus = 1;
886 }
887 
888 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
889                   isapc_machine_options);
890 
891 
892 #ifdef CONFIG_XEN
893 static void xenfv_machine_options(MachineClass *m)
894 {
895     m->desc = "Xen Fully-virtualized PC";
896     m->max_cpus = HVM_MAX_VCPUS;
897     m->default_machine_opts = "accel=xen";
898     m->hot_add_cpu = pc_hot_add_cpu;
899 }
900 
901 DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,
902                   xenfv_machine_options);
903 #endif
904