hw/pci/pci: Remove multifunction parameter from pci_create_simple_multifunction()
[qemu/ar7.git] / hw / i386 / pc_piix.c
blobac72e8f5bee1fe7b1911e7a2a9247941c89843a8
1 /*
2 * QEMU PC System Emulator
4 * Copyright (c) 2003-2004 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
25 #include "qemu/osdep.h"
26 #include CONFIG_DEVICES
28 #include "qemu/units.h"
29 #include "hw/char/parallel-isa.h"
30 #include "hw/dma/i8257.h"
31 #include "hw/loader.h"
32 #include "hw/i386/x86.h"
33 #include "hw/i386/pc.h"
34 #include "hw/i386/apic.h"
35 #include "hw/pci-host/i440fx.h"
36 #include "hw/rtc/mc146818rtc.h"
37 #include "hw/southbridge/piix.h"
38 #include "hw/display/ramfb.h"
39 #include "hw/firmware/smbios.h"
40 #include "hw/pci/pci.h"
41 #include "hw/pci/pci_ids.h"
42 #include "hw/usb.h"
43 #include "net/net.h"
44 #include "hw/ide/isa.h"
45 #include "hw/ide/pci.h"
46 #include "hw/ide/piix.h"
47 #include "hw/irq.h"
48 #include "sysemu/kvm.h"
49 #include "hw/kvm/clock.h"
50 #include "hw/sysbus.h"
51 #include "hw/i2c/smbus_eeprom.h"
52 #include "exec/memory.h"
53 #include "hw/acpi/acpi.h"
54 #include "hw/acpi/piix4.h"
55 #include "hw/usb/hcd-uhci.h"
56 #include "qapi/error.h"
57 #include "qemu/error-report.h"
58 #include "sysemu/xen.h"
59 #ifdef CONFIG_XEN
60 #include <xen/hvm/hvm_info_table.h>
61 #include "hw/xen/xen_pt.h"
62 #endif
63 #include "hw/xen/xen-x86.h"
64 #include "hw/xen/xen.h"
65 #include "migration/global_state.h"
66 #include "migration/misc.h"
67 #include "sysemu/numa.h"
68 #include "hw/hyperv/vmbus-bridge.h"
69 #include "hw/mem/nvdimm.h"
70 #include "hw/i386/acpi-build.h"
71 #include "kvm/kvm-cpu.h"
73 #define MAX_IDE_BUS 2
74 #define XEN_IOAPIC_NUM_PIRQS 128ULL
76 #ifdef CONFIG_IDE_ISA
77 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
78 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
79 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
80 #endif
83 * Return the global irq number corresponding to a given device irq
84 * pin. We could also use the bus number to have a more precise mapping.
86 static int pc_pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
88 int slot_addend;
89 slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
90 return (pci_intx + slot_addend) & 3;
93 static void piix_intx_routing_notifier_xen(PCIDevice *dev)
95 int i;
97 /* Scan for updates to PCI link routes (0x60-0x63). */
98 for (i = 0; i < PIIX_NUM_PIRQS; i++) {
99 uint8_t v = dev->config_read(dev, PIIX_PIRQCA + i, 1);
100 if (v & 0x80) {
101 v = 0;
103 v &= 0xf;
104 xen_set_pci_link_route(i, v);
108 /* PC hardware initialisation */
109 static void pc_init1(MachineState *machine,
110 const char *host_type, const char *pci_type)
112 PCMachineState *pcms = PC_MACHINE(machine);
113 PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
114 X86MachineState *x86ms = X86_MACHINE(machine);
115 MemoryRegion *system_memory = get_system_memory();
116 MemoryRegion *system_io = get_system_io();
117 PCIBus *pci_bus = NULL;
118 ISABus *isa_bus;
119 int piix3_devfn = -1;
120 qemu_irq smi_irq;
121 GSIState *gsi_state;
122 BusState *idebus[MAX_IDE_BUS];
123 ISADevice *rtc_state;
124 MemoryRegion *ram_memory;
125 MemoryRegion *pci_memory = NULL;
126 MemoryRegion *rom_memory = system_memory;
127 ram_addr_t lowmem;
128 uint64_t hole64_size = 0;
131 * Calculate ram split, for memory below and above 4G. It's a bit
132 * complicated for backward compatibility reasons ...
134 * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the
135 * default value for max_ram_below_4g now.
137 * - Then, to gigabyte align the memory, we move the split to 3G
138 * (lowmem = 0xc0000000). But only in case we have to split in
139 * the first place, i.e. ram_size is larger than (traditional)
140 * lowmem. And for new machine types (gigabyte_align = true)
141 * only, for live migration compatibility reasons.
143 * - Next the max-ram-below-4g option was added, which allowed to
144 * reduce lowmem to a smaller value, to allow a larger PCI I/O
145 * window below 4G. qemu doesn't enforce gigabyte alignment here,
146 * but prints a warning.
148 * - Finally max-ram-below-4g got updated to also allow raising lowmem,
149 * so legacy non-PAE guests can get as much memory as possible in
150 * the 32bit address space below 4G.
152 * - Note that Xen has its own ram setup code in xen_ram_init(),
153 * called via xen_hvm_init_pc().
155 * Examples:
156 * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
157 * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high
158 * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high
159 * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M)
161 if (xen_enabled()) {
162 xen_hvm_init_pc(pcms, &ram_memory);
163 } else {
164 ram_memory = machine->ram;
165 if (!pcms->max_ram_below_4g) {
166 pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
168 lowmem = pcms->max_ram_below_4g;
169 if (machine->ram_size >= pcms->max_ram_below_4g) {
170 if (pcmc->gigabyte_align) {
171 if (lowmem > 0xc0000000) {
172 lowmem = 0xc0000000;
174 if (lowmem & (1 * GiB - 1)) {
175 warn_report("Large machine and max_ram_below_4g "
176 "(%" PRIu64 ") not a multiple of 1G; "
177 "possible bad performance.",
178 pcms->max_ram_below_4g);
183 if (machine->ram_size >= lowmem) {
184 x86ms->above_4g_mem_size = machine->ram_size - lowmem;
185 x86ms->below_4g_mem_size = lowmem;
186 } else {
187 x86ms->above_4g_mem_size = 0;
188 x86ms->below_4g_mem_size = machine->ram_size;
192 pc_machine_init_sgx_epc(pcms);
193 x86_cpus_init(x86ms, pcmc->default_cpu_version);
195 if (pcmc->kvmclock_enabled) {
196 kvmclock_create(pcmc->kvmclock_create_always);
199 if (pcmc->pci_enabled) {
200 Object *phb;
202 pci_memory = g_new(MemoryRegion, 1);
203 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
204 rom_memory = pci_memory;
206 phb = OBJECT(qdev_new(host_type));
207 object_property_add_child(OBJECT(machine), "i440fx", phb);
208 object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM,
209 OBJECT(ram_memory), &error_fatal);
210 object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM,
211 OBJECT(pci_memory), &error_fatal);
212 object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM,
213 OBJECT(system_memory), &error_fatal);
214 object_property_set_link(phb, PCI_HOST_PROP_IO_MEM,
215 OBJECT(system_io), &error_fatal);
216 object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE,
217 x86ms->below_4g_mem_size, &error_fatal);
218 object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE,
219 x86ms->above_4g_mem_size, &error_fatal);
220 object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, pci_type,
221 &error_fatal);
222 sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
224 pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
225 pci_bus_map_irqs(pci_bus,
226 xen_enabled() ? xen_pci_slot_get_pirq
227 : pc_pci_slot_get_pirq);
228 pcms->bus = pci_bus;
230 hole64_size = object_property_get_uint(phb,
231 PCI_HOST_PROP_PCI_HOLE64_SIZE,
232 &error_abort);
235 pc_guest_info_init(pcms);
237 if (pcmc->smbios_defaults) {
238 MachineClass *mc = MACHINE_GET_CLASS(machine);
239 /* These values are guest ABI, do not change */
240 smbios_set_defaults("QEMU", mc->desc,
241 mc->name, pcmc->smbios_legacy_mode,
242 pcmc->smbios_uuid_encoded,
243 pcms->smbios_entry_point_type);
246 /* allocate ram and load rom/bios */
247 if (!xen_enabled()) {
248 pc_memory_init(pcms, system_memory, rom_memory, hole64_size);
249 } else {
250 assert(machine->ram_size == x86ms->below_4g_mem_size +
251 x86ms->above_4g_mem_size);
253 pc_system_flash_cleanup_unused(pcms);
254 if (machine->kernel_filename != NULL) {
255 /* For xen HVM direct kernel boot, load linux here */
256 xen_load_linux(pcms);
260 gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
262 if (pcmc->pci_enabled) {
263 PIIX3State *piix3;
264 PCIDevice *pci_dev;
266 pci_dev = pci_create_simple_multifunction(pci_bus, -1, TYPE_PIIX3_DEVICE);
268 if (xen_enabled()) {
269 pci_device_set_intx_routing_notifier(
270 pci_dev, piix_intx_routing_notifier_xen);
273 * Xen supports additional interrupt routes from the PCI devices to
274 * the IOAPIC: the four pins of each PCI device on the bus are also
275 * connected to the IOAPIC directly.
276 * These additional routes can be discovered through ACPI.
278 pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev,
279 XEN_IOAPIC_NUM_PIRQS);
282 piix3 = PIIX3_PCI_DEVICE(pci_dev);
283 piix3->pic = x86ms->gsi;
284 piix3_devfn = piix3->dev.devfn;
285 isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
286 rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
287 "rtc"));
288 } else {
289 isa_bus = isa_bus_new(NULL, system_memory, system_io,
290 &error_abort);
292 rtc_state = isa_new(TYPE_MC146818_RTC);
293 qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000);
294 isa_realize_and_unref(rtc_state, isa_bus, &error_fatal);
296 i8257_dma_init(isa_bus, 0);
297 pcms->hpet_enabled = false;
299 isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
301 if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
302 pc_i8259_create(isa_bus, gsi_state->i8259_irq);
305 if (pcmc->pci_enabled) {
306 ioapic_init_gsi(gsi_state, "i440fx");
309 if (tcg_enabled()) {
310 x86_register_ferr_irq(x86ms->gsi[13]);
313 pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
315 assert(pcms->vmport != ON_OFF_AUTO__MAX);
316 if (pcms->vmport == ON_OFF_AUTO_AUTO) {
317 pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
320 /* init basic PC hardware */
321 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true,
322 0x4);
324 pc_nic_init(pcmc, isa_bus, pci_bus);
326 if (pcmc->pci_enabled) {
327 PCIDevice *dev;
329 dev = pci_create_simple(pci_bus, piix3_devfn + 1, TYPE_PIIX3_IDE);
330 pci_ide_create_devs(dev);
331 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
332 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
333 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
335 #ifdef CONFIG_IDE_ISA
336 else {
337 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
338 int i;
340 ide_drive_get(hd, ARRAY_SIZE(hd));
341 for (i = 0; i < MAX_IDE_BUS; i++) {
342 ISADevice *dev;
343 char busname[] = "ide.0";
344 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
345 ide_irq[i],
346 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
348 * The ide bus name is ide.0 for the first bus and ide.1 for the
349 * second one.
351 busname[4] = '0' + i;
352 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
354 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
356 #endif
358 if (pcmc->pci_enabled && machine_usb(machine)) {
359 pci_create_simple(pci_bus, piix3_devfn + 2, TYPE_PIIX3_USB_UHCI);
362 if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
363 PCIDevice *piix4_pm;
365 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
366 piix4_pm = pci_new(piix3_devfn + 3, TYPE_PIIX4_PM);
367 qdev_prop_set_uint32(DEVICE(piix4_pm), "smb_io_base", 0xb100);
368 qdev_prop_set_bit(DEVICE(piix4_pm), "smm-enabled",
369 x86_machine_is_smm_enabled(x86ms));
370 pci_realize_and_unref(piix4_pm, pci_bus, &error_fatal);
372 qdev_connect_gpio_out(DEVICE(piix4_pm), 0, x86ms->gsi[9]);
373 qdev_connect_gpio_out_named(DEVICE(piix4_pm), "smi-irq", 0, smi_irq);
374 pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
375 /* TODO: Populate SPD eeprom data. */
376 smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
378 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
379 TYPE_HOTPLUG_HANDLER,
380 (Object **)&x86ms->acpi_dev,
381 object_property_allow_set_link,
382 OBJ_PROP_LINK_STRONG);
383 object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
384 OBJECT(piix4_pm), &error_abort);
387 if (machine->nvdimms_state->is_enabled) {
388 nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
389 x86_nvdimm_acpi_dsmio,
390 x86ms->fw_cfg, OBJECT(pcms));
394 /* Looking for a pc_compat_2_4() function? It doesn't exist.
395 * pc_compat_*() functions that run on machine-init time and
396 * change global QEMU state are deprecated. Please don't create
397 * one, and implement any pc-*-2.4 (and newer) compat code in
398 * hw_compat_*, pc_compat_*, or * pc_*_machine_options().
401 static void pc_compat_2_3_fn(MachineState *machine)
403 X86MachineState *x86ms = X86_MACHINE(machine);
404 if (kvm_enabled()) {
405 x86ms->smm = ON_OFF_AUTO_OFF;
409 static void pc_compat_2_2_fn(MachineState *machine)
411 pc_compat_2_3_fn(machine);
414 static void pc_compat_2_1_fn(MachineState *machine)
416 pc_compat_2_2_fn(machine);
417 x86_cpu_change_kvm_default("svm", NULL);
420 static void pc_compat_2_0_fn(MachineState *machine)
422 pc_compat_2_1_fn(machine);
425 static void pc_compat_1_7_fn(MachineState *machine)
427 pc_compat_2_0_fn(machine);
428 x86_cpu_change_kvm_default("x2apic", NULL);
431 static void pc_compat_1_6_fn(MachineState *machine)
433 pc_compat_1_7_fn(machine);
436 static void pc_compat_1_5_fn(MachineState *machine)
438 pc_compat_1_6_fn(machine);
441 static void pc_compat_1_4_fn(MachineState *machine)
443 pc_compat_1_5_fn(machine);
446 #ifdef CONFIG_ISAPC
447 static void pc_init_isa(MachineState *machine)
449 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
451 #endif
453 #ifdef CONFIG_XEN
454 static void pc_xen_hvm_init_pci(MachineState *machine)
456 const char *pci_type = xen_igd_gfx_pt_enabled() ?
457 TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE;
459 pc_init1(machine,
460 TYPE_I440FX_PCI_HOST_BRIDGE,
461 pci_type);
464 static void pc_xen_hvm_init(MachineState *machine)
466 PCMachineState *pcms = PC_MACHINE(machine);
468 if (!xen_enabled()) {
469 error_report("xenfv machine requires the xen accelerator");
470 exit(1);
473 pc_xen_hvm_init_pci(machine);
474 xen_igd_reserve_slot(pcms->bus);
475 pci_create_simple(pcms->bus, -1, "xen-platform");
477 #endif
479 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
480 static void pc_init_##suffix(MachineState *machine) \
482 void (*compat)(MachineState *m) = (compatfn); \
483 if (compat) { \
484 compat(machine); \
486 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \
487 TYPE_I440FX_PCI_DEVICE); \
489 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
491 static void pc_i440fx_machine_options(MachineClass *m)
493 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
494 pcmc->pci_root_uid = 0;
495 pcmc->default_cpu_version = 1;
497 m->family = "pc_piix";
498 m->desc = "Standard PC (i440FX + PIIX, 1996)";
499 m->default_machine_opts = "firmware=bios-256k.bin";
500 m->default_display = "std";
501 m->default_nic = "e1000";
502 m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
503 machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
504 machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
507 static void pc_i440fx_8_1_machine_options(MachineClass *m)
509 pc_i440fx_machine_options(m);
510 m->alias = "pc";
511 m->is_default = true;
514 DEFINE_I440FX_MACHINE(v8_1, "pc-i440fx-8.1", NULL,
515 pc_i440fx_8_1_machine_options);
517 static void pc_i440fx_8_0_machine_options(MachineClass *m)
519 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
521 pc_i440fx_8_1_machine_options(m);
522 m->alias = NULL;
523 m->is_default = false;
524 compat_props_add(m->compat_props, hw_compat_8_0, hw_compat_8_0_len);
525 compat_props_add(m->compat_props, pc_compat_8_0, pc_compat_8_0_len);
527 /* For pc-i44fx-8.0 and older, use SMBIOS 2.8 by default */
528 pcmc->default_smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32;
531 DEFINE_I440FX_MACHINE(v8_0, "pc-i440fx-8.0", NULL,
532 pc_i440fx_8_0_machine_options);
534 static void pc_i440fx_7_2_machine_options(MachineClass *m)
536 pc_i440fx_8_0_machine_options(m);
537 compat_props_add(m->compat_props, hw_compat_7_2, hw_compat_7_2_len);
538 compat_props_add(m->compat_props, pc_compat_7_2, pc_compat_7_2_len);
541 DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
542 pc_i440fx_7_2_machine_options);
544 static void pc_i440fx_7_1_machine_options(MachineClass *m)
546 pc_i440fx_7_2_machine_options(m);
547 compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
548 compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
551 DEFINE_I440FX_MACHINE(v7_1, "pc-i440fx-7.1", NULL,
552 pc_i440fx_7_1_machine_options);
554 static void pc_i440fx_7_0_machine_options(MachineClass *m)
556 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
557 pc_i440fx_7_1_machine_options(m);
558 pcmc->enforce_amd_1tb_hole = false;
559 compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len);
560 compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len);
563 DEFINE_I440FX_MACHINE(v7_0, "pc-i440fx-7.0", NULL,
564 pc_i440fx_7_0_machine_options);
566 static void pc_i440fx_6_2_machine_options(MachineClass *m)
568 pc_i440fx_7_0_machine_options(m);
569 compat_props_add(m->compat_props, hw_compat_6_2, hw_compat_6_2_len);
570 compat_props_add(m->compat_props, pc_compat_6_2, pc_compat_6_2_len);
573 DEFINE_I440FX_MACHINE(v6_2, "pc-i440fx-6.2", NULL,
574 pc_i440fx_6_2_machine_options);
576 static void pc_i440fx_6_1_machine_options(MachineClass *m)
578 pc_i440fx_6_2_machine_options(m);
579 compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len);
580 compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len);
581 m->smp_props.prefer_sockets = true;
584 DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL,
585 pc_i440fx_6_1_machine_options);
587 static void pc_i440fx_6_0_machine_options(MachineClass *m)
589 pc_i440fx_6_1_machine_options(m);
590 compat_props_add(m->compat_props, hw_compat_6_0, hw_compat_6_0_len);
591 compat_props_add(m->compat_props, pc_compat_6_0, pc_compat_6_0_len);
594 DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL,
595 pc_i440fx_6_0_machine_options);
597 static void pc_i440fx_5_2_machine_options(MachineClass *m)
599 pc_i440fx_6_0_machine_options(m);
600 compat_props_add(m->compat_props, hw_compat_5_2, hw_compat_5_2_len);
601 compat_props_add(m->compat_props, pc_compat_5_2, pc_compat_5_2_len);
604 DEFINE_I440FX_MACHINE(v5_2, "pc-i440fx-5.2", NULL,
605 pc_i440fx_5_2_machine_options);
607 static void pc_i440fx_5_1_machine_options(MachineClass *m)
609 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
611 pc_i440fx_5_2_machine_options(m);
612 compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
613 compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
614 pcmc->kvmclock_create_always = false;
615 pcmc->pci_root_uid = 1;
618 DEFINE_I440FX_MACHINE(v5_1, "pc-i440fx-5.1", NULL,
619 pc_i440fx_5_1_machine_options);
621 static void pc_i440fx_5_0_machine_options(MachineClass *m)
623 pc_i440fx_5_1_machine_options(m);
624 m->numa_mem_supported = true;
625 compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
626 compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
627 m->auto_enable_numa_with_memdev = false;
630 DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL,
631 pc_i440fx_5_0_machine_options);
633 static void pc_i440fx_4_2_machine_options(MachineClass *m)
635 pc_i440fx_5_0_machine_options(m);
636 compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
637 compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
640 DEFINE_I440FX_MACHINE(v4_2, "pc-i440fx-4.2", NULL,
641 pc_i440fx_4_2_machine_options);
643 static void pc_i440fx_4_1_machine_options(MachineClass *m)
645 pc_i440fx_4_2_machine_options(m);
646 compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
647 compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
650 DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL,
651 pc_i440fx_4_1_machine_options);
653 static void pc_i440fx_4_0_machine_options(MachineClass *m)
655 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
656 pc_i440fx_4_1_machine_options(m);
657 pcmc->default_cpu_version = CPU_VERSION_LEGACY;
658 compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
659 compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
662 DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
663 pc_i440fx_4_0_machine_options);
665 static void pc_i440fx_3_1_machine_options(MachineClass *m)
667 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
669 pc_i440fx_4_0_machine_options(m);
670 m->smbus_no_migration_support = true;
671 pcmc->pvh_enabled = false;
672 compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
673 compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
676 DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
677 pc_i440fx_3_1_machine_options);
679 static void pc_i440fx_3_0_machine_options(MachineClass *m)
681 pc_i440fx_3_1_machine_options(m);
682 compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len);
683 compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len);
686 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
687 pc_i440fx_3_0_machine_options);
689 static void pc_i440fx_2_12_machine_options(MachineClass *m)
691 pc_i440fx_3_0_machine_options(m);
692 compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len);
693 compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len);
696 DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
697 pc_i440fx_2_12_machine_options);
699 static void pc_i440fx_2_11_machine_options(MachineClass *m)
701 pc_i440fx_2_12_machine_options(m);
702 compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len);
703 compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len);
706 DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL,
707 pc_i440fx_2_11_machine_options);
709 static void pc_i440fx_2_10_machine_options(MachineClass *m)
711 pc_i440fx_2_11_machine_options(m);
712 compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len);
713 compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len);
714 m->auto_enable_numa_with_memhp = false;
717 DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL,
718 pc_i440fx_2_10_machine_options);
720 static void pc_i440fx_2_9_machine_options(MachineClass *m)
722 pc_i440fx_2_10_machine_options(m);
723 compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len);
724 compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len);
727 DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL,
728 pc_i440fx_2_9_machine_options);
730 static void pc_i440fx_2_8_machine_options(MachineClass *m)
732 pc_i440fx_2_9_machine_options(m);
733 compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len);
734 compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len);
737 DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL,
738 pc_i440fx_2_8_machine_options);
740 static void pc_i440fx_2_7_machine_options(MachineClass *m)
742 pc_i440fx_2_8_machine_options(m);
743 compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len);
744 compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len);
747 DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL,
748 pc_i440fx_2_7_machine_options);
750 static void pc_i440fx_2_6_machine_options(MachineClass *m)
752 X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
753 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
755 pc_i440fx_2_7_machine_options(m);
756 pcmc->legacy_cpu_hotplug = true;
757 x86mc->fwcfg_dma_enabled = false;
758 compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len);
759 compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len);
762 DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL,
763 pc_i440fx_2_6_machine_options);
765 static void pc_i440fx_2_5_machine_options(MachineClass *m)
767 X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
769 pc_i440fx_2_6_machine_options(m);
770 x86mc->save_tsc_khz = false;
771 m->legacy_fw_cfg_order = 1;
772 compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len);
773 compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len);
776 DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
777 pc_i440fx_2_5_machine_options);
779 static void pc_i440fx_2_4_machine_options(MachineClass *m)
781 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
783 pc_i440fx_2_5_machine_options(m);
784 m->hw_version = "2.4.0";
785 pcmc->broken_reserved_end = true;
786 compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len);
787 compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len);
790 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
791 pc_i440fx_2_4_machine_options)
793 static void pc_i440fx_2_3_machine_options(MachineClass *m)
795 pc_i440fx_2_4_machine_options(m);
796 m->hw_version = "2.3.0";
797 compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len);
798 compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len);
801 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn,
802 pc_i440fx_2_3_machine_options);
804 static void pc_i440fx_2_2_machine_options(MachineClass *m)
806 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
808 pc_i440fx_2_3_machine_options(m);
809 m->hw_version = "2.2.0";
810 m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on";
811 compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len);
812 compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len);
813 pcmc->rsdp_in_ram = false;
814 pcmc->resizable_acpi_blob = false;
817 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn,
818 pc_i440fx_2_2_machine_options);
820 static void pc_i440fx_2_1_machine_options(MachineClass *m)
822 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
824 pc_i440fx_2_2_machine_options(m);
825 m->hw_version = "2.1.0";
826 m->default_display = NULL;
827 compat_props_add(m->compat_props, hw_compat_2_1, hw_compat_2_1_len);
828 compat_props_add(m->compat_props, pc_compat_2_1, pc_compat_2_1_len);
829 pcmc->smbios_uuid_encoded = false;
830 pcmc->enforce_aligned_dimm = false;
833 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn,
834 pc_i440fx_2_1_machine_options);
836 static void pc_i440fx_2_0_machine_options(MachineClass *m)
838 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
840 pc_i440fx_2_1_machine_options(m);
841 m->hw_version = "2.0.0";
842 compat_props_add(m->compat_props, pc_compat_2_0, pc_compat_2_0_len);
843 pcmc->smbios_legacy_mode = true;
844 pcmc->has_reserved_memory = false;
845 /* This value depends on the actual DSDT and SSDT compiled into
846 * the source QEMU; unfortunately it depends on the binary and
847 * not on the machine type, so we cannot make pc-i440fx-1.7 work on
848 * both QEMU 1.7 and QEMU 2.0.
850 * Large variations cause migration to fail for more than one
851 * consecutive value of the "-smp" maxcpus option.
853 * For small variations of the kind caused by different iasl versions,
854 * the 4k rounding usually leaves slack. However, there could be still
855 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
856 * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
858 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
859 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
861 pcmc->legacy_acpi_table_size = 6652;
862 pcmc->acpi_data_size = 0x10000;
865 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0_fn,
866 pc_i440fx_2_0_machine_options);
868 static void pc_i440fx_1_7_machine_options(MachineClass *m)
870 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
872 pc_i440fx_2_0_machine_options(m);
873 m->hw_version = "1.7.0";
874 m->default_machine_opts = NULL;
875 m->option_rom_has_mr = true;
876 m->deprecation_reason = "old and unattended - use a newer version instead";
877 compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len);
878 pcmc->smbios_defaults = false;
879 pcmc->gigabyte_align = false;
880 pcmc->legacy_acpi_table_size = 6414;
883 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7_fn,
884 pc_i440fx_1_7_machine_options);
886 static void pc_i440fx_1_6_machine_options(MachineClass *m)
888 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
890 pc_i440fx_1_7_machine_options(m);
891 m->hw_version = "1.6.0";
892 m->rom_file_has_mr = false;
893 compat_props_add(m->compat_props, pc_compat_1_6, pc_compat_1_6_len);
894 pcmc->has_acpi_build = false;
897 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6_fn,
898 pc_i440fx_1_6_machine_options);
900 static void pc_i440fx_1_5_machine_options(MachineClass *m)
902 pc_i440fx_1_6_machine_options(m);
903 m->hw_version = "1.5.0";
904 compat_props_add(m->compat_props, pc_compat_1_5, pc_compat_1_5_len);
907 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5_fn,
908 pc_i440fx_1_5_machine_options);
910 static void pc_i440fx_1_4_machine_options(MachineClass *m)
912 pc_i440fx_1_5_machine_options(m);
913 m->hw_version = "1.4.0";
914 compat_props_add(m->compat_props, pc_compat_1_4, pc_compat_1_4_len);
917 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4_fn,
918 pc_i440fx_1_4_machine_options);
920 #ifdef CONFIG_ISAPC
921 static void isapc_machine_options(MachineClass *m)
923 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
924 m->desc = "ISA-only PC";
925 m->max_cpus = 1;
926 m->option_rom_has_mr = true;
927 m->rom_file_has_mr = false;
928 pcmc->pci_enabled = false;
929 pcmc->has_acpi_build = false;
930 pcmc->smbios_defaults = false;
931 pcmc->gigabyte_align = false;
932 pcmc->smbios_legacy_mode = true;
933 pcmc->has_reserved_memory = false;
934 m->default_nic = "ne2k_isa";
935 m->default_cpu_type = X86_CPU_TYPE_NAME("486");
936 m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
939 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
940 isapc_machine_options);
941 #endif
943 #ifdef CONFIG_XEN
944 static void xenfv_4_2_machine_options(MachineClass *m)
946 pc_i440fx_4_2_machine_options(m);
947 m->desc = "Xen Fully-virtualized PC";
948 m->max_cpus = HVM_MAX_VCPUS;
949 m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
952 DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
953 xenfv_4_2_machine_options);
955 static void xenfv_3_1_machine_options(MachineClass *m)
957 pc_i440fx_3_1_machine_options(m);
958 m->desc = "Xen Fully-virtualized PC";
959 m->alias = "xenfv";
960 m->max_cpus = HVM_MAX_VCPUS;
961 m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
964 DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
965 xenfv_3_1_machine_options);
966 #endif