pc_piix.c 26.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * QEMU PC System Emulator
 *
 * Copyright (c) 2003-2004 Fabrice Bellard
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

A
Avi Kivity 已提交
25 26
#include <glib.h>

27
#include "hw/hw.h"
28
#include "hw/loader.h"
P
Paolo Bonzini 已提交
29 30
#include "hw/i386/pc.h"
#include "hw/i386/apic.h"
31
#include "hw/i386/smbios.h"
32 33 34
#include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h"
#include "hw/usb.h"
P
Paolo Bonzini 已提交
35
#include "net/net.h"
36 37
#include "hw/boards.h"
#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"
P
Paolo Bonzini 已提交
45 46
#include "hw/i2c/smbus.h"
#include "hw/xen/xen.h"
47 48
#include "exec/memory.h"
#include "exec/address-spaces.h"
49
#include "hw/acpi/acpi.h"
50
#include "cpu.h"
51
#include "qemu/error-report.h"
A
Anthony PERARD 已提交
52 53 54
#ifdef CONFIG_XEN
#  include <xen/hvm/hvm_info_table.h>
#endif
55
#include "migration/migration.h"
56 57 58 59 60 61 62

#define MAX_IDE_BUS 2

static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };

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 71 72 73
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
 * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
 * pages in the host.
 */
G
Gerd Hoffmann 已提交
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 *pc_machine = PC_MACHINE(machine);
82 83
    MemoryRegion *system_memory = get_system_memory();
    MemoryRegion *system_io = get_system_io();
84 85 86
    int i;
    ram_addr_t below_4g_mem_size, above_4g_mem_size;
    PCIBus *pci_bus;
87
    ISABus *isa_bus;
88 89
    PCII440FXState *i440fx_state;
    int piix3_devfn = -1;
J
Jan Kiszka 已提交
90
    qemu_irq *gsi;
91
    qemu_irq *i8259;
S
Shannon Zhao 已提交
92
    qemu_irq smi_irq;
J
Jan Kiszka 已提交
93
    GSIState *gsi_state;
94
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
95
    BusState *idebus[MAX_IDE_BUS];
96
    ISADevice *rtc_state;
A
Avi Kivity 已提交
97 98
    MemoryRegion *ram_memory;
    MemoryRegion *pci_memory;
99
    MemoryRegion *rom_memory;
100
    DeviceState *icc_bridge;
101
    PcGuestInfo *guest_info;
102
    ram_addr_t lowmem;
103

104 105 106 107 108 109 110
    /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
     * If it doesn't, we need to split it in chunks below and above 4G.
     * In any case, try to make sure that guest addresses aligned at
     * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
     * For old machine types, use whatever split we used historically to avoid
     * breaking migration.
     */
111
    if (machine->ram_size >= 0xe0000000) {
112 113 114 115 116
        lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
    } else {
        lowmem = 0xe0000000;
    }

117
    /* Handle the machine opt max-ram-below-4g.  It is basically doing
118 119 120 121 122 123 124 125 126 127 128 129 130
     * min(qemu limit, user limit).
     */
    if (lowmem > pc_machine->max_ram_below_4g) {
        lowmem = pc_machine->max_ram_below_4g;
        if (machine->ram_size - lowmem > lowmem &&
            lowmem & ((1ULL << 30) - 1)) {
            error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
                         ") not a multiple of 1G; possible bad performance.",
                         pc_machine->max_ram_below_4g);
        }
    }

    if (machine->ram_size >= lowmem) {
131
        above_4g_mem_size = machine->ram_size - lowmem;
G
Gerd Hoffmann 已提交
132
        below_4g_mem_size = lowmem;
133 134
    } else {
        above_4g_mem_size = 0;
135
        below_4g_mem_size = machine->ram_size;
136 137
    }

138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
    if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
                                      &ram_memory) != 0) {
        fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
        exit(1);
    }

    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
    object_property_add_child(qdev_get_machine(), "icc-bridge",
                              OBJECT(icc_bridge), NULL);

    pc_cpus_init(machine->cpu_model, icc_bridge);

    if (kvm_enabled() && kvmclock_enabled) {
        kvmclock_create();
    }

154 155
    if (pci_enabled) {
        pci_memory = g_new(MemoryRegion, 1);
P
Paolo Bonzini 已提交
156
        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
157 158 159 160 161
        rom_memory = pci_memory;
    } else {
        pci_memory = NULL;
        rom_memory = system_memory;
    }
A
Avi Kivity 已提交
162

163
    guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
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 178
    }

179
    /* allocate ram and load rom/bios */
A
Anthony PERARD 已提交
180
    if (!xen_enabled()) {
181 182 183
        pc_memory_init(machine, system_memory,
                       below_4g_mem_size, above_4g_mem_size,
                       rom_memory, &ram_memory, guest_info);
184 185
    } else if (machine->kernel_filename != NULL) {
        /* For xen HVM direct kernel boot, load linux here */
186 187 188 189 190
        xen_load_linux(machine->kernel_filename,
                       machine->kernel_cmdline,
                       machine->initrd_filename,
                       below_4g_mem_size,
                       guest_info);
A
Anthony PERARD 已提交
191
    }
192

J
Jan Kiszka 已提交
193
    gsi_state = g_malloc0(sizeof(*gsi_state));
194
    if (kvm_irqchip_in_kernel()) {
195 196
        kvm_pc_setup_irq_routing(pci_enabled);
        gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
197 198 199 200
                                 GSI_NUM_PINS);
    } else {
        gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
    }
201 202

    if (pci_enabled) {
203
        pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
204
                              system_memory, system_io, machine->ram_size,
G
Gerd Hoffmann 已提交
205
                              below_4g_mem_size,
206
                              above_4g_mem_size,
A
Avi Kivity 已提交
207
                              pci_memory, ram_memory);
208 209
    } else {
        pci_bus = NULL;
I
Isaku Yamahata 已提交
210
        i440fx_state = NULL;
211
        isa_bus = isa_bus_new(NULL, get_system_memory(), system_io);
J
Jan Kiszka 已提交
212
        no_hpet = 1;
213
    }
214
    isa_bus_irqs(isa_bus, gsi);
215

216
    if (kvm_irqchip_in_kernel()) {
217 218 219 220
        i8259 = kvm_i8259_init(isa_bus);
    } else if (xen_enabled()) {
        i8259 = xen_interrupt_controller_init();
    } else {
221
        i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
222 223
    }

224 225 226
    for (i = 0; i < ISA_NUM_IRQS; i++) {
        gsi_state->i8259_irq[i] = i8259[i];
    }
S
Shannon Zhao 已提交
227
    g_free(i8259);
228
    if (pci_enabled) {
229
        ioapic_init_gsi(gsi_state, "i440fx");
230
    }
231
    qdev_init_nofail(icc_bridge);
232

J
Jan Kiszka 已提交
233
    pc_register_ferr_irq(gsi[13]);
234

235
    pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
236

237 238 239 240 241
    assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
    if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
        pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
    }

242
    /* init basic PC hardware */
243
    pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
244
                         (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
245

246
    pc_nic_init(isa_bus, pci_bus);
247

248
    ide_drive_get(hd, ARRAY_SIZE(hd));
249
    if (pci_enabled) {
250
        PCIDevice *dev;
251 252 253 254 255
        if (xen_enabled()) {
            dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
        } else {
            dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
        }
256 257
        idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
        idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
258 259
    } else {
        for(i = 0; i < MAX_IDE_BUS; i++) {
260
            ISADevice *dev;
261
            char busname[] = "ide.0";
262 263
            dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
                               ide_irq[i],
264
                               hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
265 266 267 268 269 270
            /*
             * The ide bus name is ide.0 for the first bus and ide.1 for the
             * second one.
             */
            busname[4] = '0' + i;
            idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
271 272 273
        }
    }

274
    pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
275
                 machine, idebus[0], idebus[1], rtc_state);
276

277
    if (pci_enabled && usb_enabled()) {
278
        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
279 280 281
    }

    if (pci_enabled && acpi_enabled) {
282
        DeviceState *piix4_pm;
A
Andreas Färber 已提交
283
        I2CBus *smbus;
284

S
Shannon Zhao 已提交
285
        smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
286 287
        /* TODO: Populate SPD eeprom data.  */
        smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
S
Shannon Zhao 已提交
288
                              gsi[9], smi_irq,
P
Paolo Bonzini 已提交
289 290
                              pc_machine_is_smm_enabled(pc_machine),
                              &piix4_pm);
291
        smbus_eeprom_init(smbus, 8, NULL, 0);
292 293 294 295 296 297 298 299

        object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
                                 TYPE_HOTPLUG_HANDLER,
                                 (Object **)&pc_machine->acpi_dev,
                                 object_property_allow_set_link,
                                 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
        object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
                                 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
300 301 302 303 304 305 306
    }

    if (pci_enabled) {
        pc_pci_device_init(pci_bus);
    }
}

J
Jason Wang 已提交
307 308
static void pc_compat_2_3(MachineState *machine)
{
P
Paolo Bonzini 已提交
309
    PCMachineState *pcms = PC_MACHINE(machine);
310
    savevm_skip_section_footers();
P
Paolo Bonzini 已提交
311 312 313
    if (kvm_enabled()) {
        pcms->smm = ON_OFF_AUTO_OFF;
    }
314
    global_state_set_optional();
315
    savevm_skip_configuration();
J
Jason Wang 已提交
316 317
}

P
Paolo Bonzini 已提交
318 319
static void pc_compat_2_2(MachineState *machine)
{
J
Jason Wang 已提交
320
    pc_compat_2_3(machine);
321
    rsdp_in_ram = false;
322
    machine->suppress_vmdesc = true;
P
Paolo Bonzini 已提交
323 324
}

E
Eduardo Habkost 已提交
325 326
static void pc_compat_2_1(MachineState *machine)
{
327
    PCMachineState *pcms = PC_MACHINE(machine);
P
Paolo Bonzini 已提交
328 329

    pc_compat_2_2(machine);
330
    smbios_uuid_encoded = false;
331
    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
332
    pcms->enforce_aligned_dimm = false;
E
Eduardo Habkost 已提交
333 334
}

335
static void pc_compat_2_0(MachineState *machine)
M
Michael S. Tsirkin 已提交
336
{
E
Eduardo Habkost 已提交
337
    pc_compat_2_1(machine);
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
    /* This value depends on the actual DSDT and SSDT compiled into
     * the source QEMU; unfortunately it depends on the binary and
     * not on the machine type, so we cannot make pc-i440fx-1.7 work on
     * both QEMU 1.7 and QEMU 2.0.
     *
     * Large variations cause migration to fail for more than one
     * consecutive value of the "-smp" maxcpus option.
     *
     * For small variations of the kind caused by different iasl versions,
     * the 4k rounding usually leaves slack.  However, there could be still
     * one or two values that break.  For QEMU 1.7 and QEMU 2.0 the
     * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
     *
     * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
     * QEMU 1.7 it is 6414.  For RHEL/CentOS 7.0 it is 6418.
     */
    legacy_acpi_table_size = 6652;
355
    smbios_legacy_mode = true;
356
    has_reserved_memory = false;
357
    pc_set_legacy_acpi_data_size();
M
Michael S. Tsirkin 已提交
358 359
}

360
static void pc_compat_1_7(MachineState *machine)
361
{
362
    pc_compat_2_0(machine);
363
    smbios_defaults = false;
G
Gerd Hoffmann 已提交
364
    gigabyte_align = false;
365
    option_rom_has_mr = true;
366
    legacy_acpi_table_size = 6414;
367
    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
368 369
}

370
static void pc_compat_1_6(MachineState *machine)
371
{
372
    pc_compat_1_7(machine);
373
    rom_file_has_mr = false;
374
    has_acpi_build = false;
375 376
}

377
static void pc_compat_1_5(MachineState *machine)
378
{
379
    pc_compat_1_6(machine);
380 381
}

382
static void pc_compat_1_4(MachineState *machine)
383
{
384
    pc_compat_1_5(machine);
385 386
}

387
static void pc_compat_1_3(MachineState *machine)
388
{
389
    pc_compat_1_4(machine);
390
    enable_compat_apic_id_mode();
391 392 393
}

/* PC compat function for pc-0.14 to pc-1.2 */
394
static void pc_compat_1_2(MachineState *machine)
395
{
396
    pc_compat_1_3(machine);
397
    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
398 399
}

400 401 402 403 404 405 406
/* PC compat function for pc-0.10 to pc-0.13 */
static void pc_compat_0_13(MachineState *machine)
{
    pc_compat_1_2(machine);
    kvmclock_enabled = false;
}

407
static void pc_init_isa(MachineState *machine)
408
{
409
    pci_enabled = false;
410
    has_acpi_build = false;
411
    smbios_defaults = false;
412 413 414 415 416
    gigabyte_align = false;
    smbios_legacy_mode = true;
    has_reserved_memory = false;
    option_rom_has_mr = true;
    rom_file_has_mr = false;
417 418
    if (!machine->cpu_model) {
        machine->cpu_model = "486";
419
    }
420
    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
421
    enable_compat_apic_id_mode();
422
    pc_init1(machine);
423 424
}

A
Anthony PERARD 已提交
425
#ifdef CONFIG_XEN
426
static void pc_xen_hvm_init(MachineState *machine)
A
Anthony PERARD 已提交
427
{
428 429
    PCIBus *bus;

E
Eduardo Habkost 已提交
430
    pc_init1(machine);
431

D
David Gibson 已提交
432
    bus = pci_find_primary_bus();
433 434 435
    if (bus != NULL) {
        pci_create_simple(bus, -1, "xen-platform");
    }
A
Anthony PERARD 已提交
436 437 438
}
#endif

439 440 441 442 443 444 445 446 447 448
#define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
    static void pc_init_##suffix(MachineState *machine) \
    { \
        void (*compat)(MachineState *m) = (compatfn); \
        if (compat) { \
            compat(machine); \
        } \
        pc_init1(machine); \
    } \
    DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
449

450
static void pc_i440fx_machine_options(MachineClass *m)
451 452 453 454 455 456 457
{
    pc_default_machine_options(m);
    m->family = "pc_piix";
    m->desc = "Standard PC (i440FX + PIIX, 1996)";
    m->hot_add_cpu = pc_hot_add_cpu;
}

458
static void pc_i440fx_2_4_machine_options(MachineClass *m)
459 460 461 462 463 464 465
{
    pc_i440fx_machine_options(m);
    m->default_machine_opts = "firmware=bios-256k.bin";
    m->default_display = "std";
    m->alias = "pc";
    m->is_default = 1;
}
466

467 468
DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
                      pc_i440fx_2_4_machine_options)
J
Jason Wang 已提交
469

J
Jan Kiszka 已提交
470

471
static void pc_i440fx_2_3_machine_options(MachineClass *m)
472
{
473
    pc_i440fx_2_4_machine_options(m);
474 475
    m->alias = NULL;
    m->is_default = 0;
476
    SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
477
}
J
Jason Wang 已提交
478

479 480
DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
                      pc_i440fx_2_3_machine_options);
481

J
Jason Wang 已提交
482

483
static void pc_i440fx_2_2_machine_options(MachineClass *m)
484 485
{
    pc_i440fx_2_3_machine_options(m);
486
    SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
487
}
P
Paolo Bonzini 已提交
488

489 490
DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
                      pc_i440fx_2_2_machine_options);
491

P
Paolo Bonzini 已提交
492

493
static void pc_i440fx_2_1_machine_options(MachineClass *m)
494 495 496
{
    pc_i440fx_2_2_machine_options(m);
    m->default_display = NULL;
497
    SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
498
}
J
Jan Kiszka 已提交
499

500 501
DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
                      pc_i440fx_2_1_machine_options);
502

503

504

505
static void pc_i440fx_2_0_machine_options(MachineClass *m)
506 507
{
    pc_i440fx_2_1_machine_options(m);
508
    SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
509
}
M
Michael S. Tsirkin 已提交
510

511 512
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
                      pc_i440fx_2_0_machine_options);
513

M
Michael S. Tsirkin 已提交
514

515
static void pc_i440fx_1_7_machine_options(MachineClass *m)
516 517 518
{
    pc_i440fx_2_0_machine_options(m);
    m->default_machine_opts = NULL;
519
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
520
}
521

522 523
DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
                      pc_i440fx_1_7_machine_options);
524

525

526
static void pc_i440fx_1_6_machine_options(MachineClass *m)
527 528
{
    pc_i440fx_1_7_machine_options(m);
529
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
530
}
531

532 533
DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
                      pc_i440fx_1_6_machine_options);
534

535

536
static void pc_i440fx_1_5_machine_options(MachineClass *m)
537 538
{
    pc_i440fx_1_6_machine_options(m);
539
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
540
}
541

542 543
DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
                      pc_i440fx_1_5_machine_options);
544

545

546
static void pc_i440fx_1_4_machine_options(MachineClass *m)
547 548 549
{
    pc_i440fx_1_5_machine_options(m);
    m->hot_add_cpu = NULL;
550
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
551
}
552

553 554
DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
                      pc_i440fx_1_4_machine_options);
555

556

557
#define PC_COMPAT_1_3 \
558
        PC_COMPAT_1_4 \
559 560 561 562
        {\
            .driver   = "usb-tablet",\
            .property = "usb_version",\
            .value    = stringify(1),\
563 564 565 566
        },{\
            .driver   = "virtio-net-pci",\
            .property = "ctrl_mac_addr",\
            .value    = "off",      \
567 568 569 570
        },{ \
            .driver   = "virtio-net-pci", \
            .property = "mq", \
            .value    = "off", \
571 572 573 574
        }, {\
            .driver   = "e1000",\
            .property = "autonegotiation",\
            .value    = "off",\
575
        },
576

577

578
static void pc_i440fx_1_3_machine_options(MachineClass *m)
579 580
{
    pc_i440fx_1_4_machine_options(m);
581
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
582
}
583

584 585
DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
                      pc_i440fx_1_3_machine_options);
586

G
Gerd Hoffmann 已提交
587

588
#define PC_COMPAT_1_2 \
589
        PC_COMPAT_1_3 \
590 591 592 593 594 595 596 597
        {\
            .driver   = "nec-usb-xhci",\
            .property = "msi",\
            .value    = "off",\
        },{\
            .driver   = "nec-usb-xhci",\
            .property = "msix",\
            .value    = "off",\
G
Gerd Hoffmann 已提交
598 599 600 601
        },{\
            .driver   = "ivshmem",\
            .property = "use64",\
            .value    = "0",\
G
Gerd Hoffmann 已提交
602 603 604 605 606 607 608 609
        },{\
            .driver   = "qxl",\
            .property = "revision",\
            .value    = stringify(3),\
        },{\
            .driver   = "qxl-vga",\
            .property = "revision",\
            .value    = stringify(3),\
G
Gerd Hoffmann 已提交
610 611 612 613
        },{\
            .driver   = "VGA",\
            .property = "mmio",\
            .value    = "off",\
614
        },
615

616
static void pc_i440fx_1_2_machine_options(MachineClass *m)
617 618
{
    pc_i440fx_1_3_machine_options(m);
619
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
620
}
621

622 623
DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
                      pc_i440fx_1_2_machine_options);
624

G
Gerd Hoffmann 已提交
625

G
Gerd Hoffmann 已提交
626
#define PC_COMPAT_1_1 \
627
        PC_COMPAT_1_2 \
G
Gerd Hoffmann 已提交
628
        {\
629 630 631 632 633 634 635 636
            .driver   = "virtio-scsi-pci",\
            .property = "hotplug",\
            .value    = "off",\
        },{\
            .driver   = "virtio-scsi-pci",\
            .property = "param_change",\
            .value    = "off",\
        },{\
G
Gerd Hoffmann 已提交
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
            .driver   = "VGA",\
            .property = "vgamem_mb",\
            .value    = stringify(8),\
        },{\
            .driver   = "vmware-svga",\
            .property = "vgamem_mb",\
            .value    = stringify(8),\
        },{\
            .driver   = "qxl-vga",\
            .property = "vgamem_mb",\
            .value    = stringify(8),\
        },{\
            .driver   = "qxl",\
            .property = "vgamem_mb",\
            .value    = stringify(8),\
652 653 654 655
        },{\
            .driver   = "virtio-blk-pci",\
            .property = "config-wce",\
            .value    = "off",\
656
        },
G
Gerd Hoffmann 已提交
657

658
static void pc_i440fx_1_1_machine_options(MachineClass *m)
659 660
{
    pc_i440fx_1_2_machine_options(m);
661
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
662
}
663

664 665
DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
                      pc_i440fx_1_1_machine_options);
666

G
Gerd Hoffmann 已提交
667

668
#define PC_COMPAT_1_0 \
669
        PC_COMPAT_1_1 \
670
        {\
671
            .driver   = TYPE_ISA_FDC,\
672 673
            .property = "check_media_rate",\
            .value    = "off",\
674 675 676 677
        }, {\
            .driver   = "virtio-balloon-pci",\
            .property = "class",\
            .value    = stringify(PCI_CLASS_MEMORY_RAM),\
678
        },{\
679
            .driver   = "apic-common",\
680 681
            .property = "vapic",\
            .value    = "off",\
G
Gerd Hoffmann 已提交
682
        },{\
683
            .driver   = TYPE_USB_DEVICE,\
G
Gerd Hoffmann 已提交
684 685
            .property = "full-path",\
            .value    = "no",\
686
        },
687

688
static void pc_i440fx_1_0_machine_options(MachineClass *m)
689 690 691
{
    pc_i440fx_1_1_machine_options(m);
    m->hw_version = "1.0";
692
    SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
693
}
694

695 696
DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
                      pc_i440fx_1_0_machine_options);
697

J
Jordan Justen 已提交
698

699 700 701
#define PC_COMPAT_0_15 \
        PC_COMPAT_1_0

702
static void pc_i440fx_0_15_machine_options(MachineClass *m)
703 704 705
{
    pc_i440fx_1_0_machine_options(m);
    m->hw_version = "0.15";
706
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
707
}
708

709 710
DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
                      pc_i440fx_0_15_machine_options);
711

A
Anthony Liguori 已提交
712

713
#define PC_COMPAT_0_14 \
714
        PC_COMPAT_0_15 \
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
        {\
            .driver   = "virtio-blk-pci",\
            .property = "event_idx",\
            .value    = "off",\
        },{\
            .driver   = "virtio-serial-pci",\
            .property = "event_idx",\
            .value    = "off",\
        },{\
            .driver   = "virtio-net-pci",\
            .property = "event_idx",\
            .value    = "off",\
        },{\
            .driver   = "virtio-balloon-pci",\
            .property = "event_idx",\
            .value    = "off",\
731 732 733 734 735 736 737 738
        },{\
            .driver   = "qxl",\
            .property = "revision",\
            .value    = stringify(2),\
        },{\
            .driver   = "qxl-vga",\
            .property = "revision",\
            .value    = stringify(2),\
739
        },
740

741
static void pc_i440fx_0_14_machine_options(MachineClass *m)
742 743 744
{
    pc_i440fx_0_15_machine_options(m);
    m->hw_version = "0.14";
745
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
746
}
747

748 749
DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
                      pc_i440fx_0_14_machine_options);
750

G
Gerd Hoffmann 已提交
751

752
#define PC_COMPAT_0_13 \
753
        PC_COMPAT_0_14 \
754
        {\
755
            .driver   = TYPE_PCI_DEVICE,\
756 757 758 759 760 761
            .property = "command_serr_enable",\
            .value    = "off",\
        },{\
            .driver   = "AC97",\
            .property = "use_broken_id",\
            .value    = stringify(1),\
762 763 764 765
        },{\
            .driver   = "virtio-9p-pci",\
            .property = "vectors",\
            .value    = stringify(0),\
766 767 768 769 770 771 772 773
        },{\
            .driver   = "VGA",\
            .property = "rombar",\
            .value    = stringify(0),\
        },{\
            .driver   = "vmware-svga",\
            .property = "rombar",\
            .value    = stringify(0),\
774
        },
775

776
static void pc_i440fx_0_13_machine_options(MachineClass *m)
777 778 779
{
    pc_i440fx_0_14_machine_options(m);
    m->hw_version = "0.13";
780
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
781
}
782

783 784
DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
                      pc_i440fx_0_13_machine_options);
785

G
Gerd Hoffmann 已提交
786

787
#define PC_COMPAT_0_12 \
788
        PC_COMPAT_0_13 \
789 790 791 792 793 794 795 796
        {\
            .driver   = "virtio-serial-pci",\
            .property = "max_ports",\
            .value    = stringify(1),\
        },{\
            .driver   = "virtio-serial-pci",\
            .property = "vectors",\
            .value    = stringify(0),\
797 798 799 800 801 802 803 804 805 806 807 808
        },{\
            .driver   = "usb-mouse",\
            .property = "serial",\
            .value    = "1",\
        },{\
            .driver   = "usb-tablet",\
            .property = "serial",\
            .value    = "1",\
        },{\
            .driver   = "usb-kbd",\
            .property = "serial",\
            .value    = "1",\
809
        },
810

811
static void pc_i440fx_0_12_machine_options(MachineClass *m)
812 813 814
{
    pc_i440fx_0_13_machine_options(m);
    m->hw_version = "0.12";
815
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
816
}
817

818 819
DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
                      pc_i440fx_0_12_machine_options);
820

821

822
#define PC_COMPAT_0_11 \
823
        PC_COMPAT_0_12 \
824 825 826 827
        {\
            .driver   = "virtio-blk-pci",\
            .property = "vectors",\
            .value    = stringify(0),\
828
        },{\
829
            .driver   = TYPE_PCI_DEVICE,\
830 831
            .property = "rombar",\
            .value    = stringify(0),\
832 833 834 835 836 837 838 839
        },{\
            .driver   = "ide-drive",\
            .property = "ver",\
            .value    = "0.11",\
        },{\
            .driver   = "scsi-disk",\
            .property = "ver",\
            .value    = "0.11",\
840
        },
841

842
static void pc_i440fx_0_11_machine_options(MachineClass *m)
843 844 845
{
    pc_i440fx_0_12_machine_options(m);
    m->hw_version = "0.11";
846
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
847
}
848

849 850
DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
                      pc_i440fx_0_11_machine_options);
851

852

E
Eduardo Habkost 已提交
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
#define PC_COMPAT_0_10 \
    PC_COMPAT_0_11 \
    {\
        .driver   = "virtio-blk-pci",\
        .property = "class",\
        .value    = stringify(PCI_CLASS_STORAGE_OTHER),\
    },{\
        .driver   = "virtio-serial-pci",\
        .property = "class",\
        .value    = stringify(PCI_CLASS_DISPLAY_OTHER),\
    },{\
        .driver   = "virtio-net-pci",\
        .property = "vectors",\
        .value    = stringify(0),\
    },{\
        .driver   = "ide-drive",\
        .property = "ver",\
        .value    = "0.10",\
    },{\
        .driver   = "scsi-disk",\
        .property = "ver",\
        .value    = "0.10",\
    },

877
static void pc_i440fx_0_10_machine_options(MachineClass *m)
878 879 880
{
    pc_i440fx_0_11_machine_options(m);
    m->hw_version = "0.10";
881
    SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
882
}
883

884 885
DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
                      pc_i440fx_0_10_machine_options);
886

887

888
static void isapc_machine_options(MachineClass *m)
889 890 891 892 893
{
    pc_common_machine_options(m);
    m->desc = "ISA-only PC";
    m->max_cpus = 1;
}
894

895
DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
896
                  isapc_machine_options);
897

898

A
Anthony PERARD 已提交
899
#ifdef CONFIG_XEN
900
static void xenfv_machine_options(MachineClass *m)
901 902 903 904 905 906 907
{
    pc_common_machine_options(m);
    m->desc = "Xen Fully-virtualized PC";
    m->max_cpus = HVM_MAX_VCPUS;
    m->default_machine_opts = "accel=xen";
    m->hot_add_cpu = pc_hot_add_cpu;
}
908

909
DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,
910
                  xenfv_machine_options);
A
Anthony PERARD 已提交
911
#endif