]> git.proxmox.com Git - mirror_qemu.git/blame - hw/i386/pc_piix.c
hw: add compat machines for 5.1
[mirror_qemu.git] / hw / i386 / pc_piix.c
CommitLineData
845773ab
IY
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
b6a0aa05 25#include "qemu/osdep.h"
60386ea2 26#include "config-devices.h"
ae0a5466 27
d471bf3e 28#include "qemu/units.h"
04920fc0 29#include "hw/loader.h"
549e984e 30#include "hw/i386/x86.h"
0d09e41a
PB
31#include "hw/i386/pc.h"
32#include "hw/i386/apic.h"
0fd61a2d 33#include "hw/pci-host/i440fx.h"
fff123b8 34#include "hw/southbridge/piix.h"
94692dcd 35#include "hw/display/ramfb.h"
a2eb5c0c 36#include "hw/firmware/smbios.h"
83c9f4ca
PB
37#include "hw/pci/pci.h"
38#include "hw/pci/pci_ids.h"
39#include "hw/usb.h"
1422e32d 40#include "net/net.h"
df45d38f 41#include "hw/ide/pci.h"
64552b6b 42#include "hw/irq.h"
9c17d615 43#include "sysemu/kvm.h"
83c9f4ca 44#include "hw/kvm/clock.h"
9c17d615 45#include "sysemu/sysemu.h"
83c9f4ca 46#include "hw/sysbus.h"
9c17d615 47#include "sysemu/arch_init.h"
93198b6c 48#include "hw/i2c/smbus_eeprom.h"
0d09e41a 49#include "hw/xen/xen.h"
022c62cb
PB
50#include "exec/memory.h"
51#include "exec/address-spaces.h"
0445259b 52#include "hw/acpi/acpi.h"
dc59944b 53#include "cpu.h"
e688df6b 54#include "qapi/error.h"
c87b1520 55#include "qemu/error-report.h"
29d3ccde 56#ifdef CONFIG_XEN
998250e9
TC
57#include <xen/hvm/hvm_info_table.h>
58#include "hw/xen/xen_pt.h"
29d3ccde 59#endif
84a899de 60#include "migration/global_state.h"
c4b63b7c 61#include "migration/misc.h"
3bfe5716 62#include "sysemu/numa.h"
4b997690 63#include "hw/mem/nvdimm.h"
5c94b826 64#include "hw/i386/acpi-build.h"
845773ab
IY
65
66#define MAX_IDE_BUS 2
67
60386ea2 68#ifdef CONFIG_IDE_ISA
845773ab
IY
69static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
70static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
71static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
60386ea2 72#endif
845773ab
IY
73
74/* PC hardware initialisation */
76d39ab4
TC
75static void pc_init1(MachineState *machine,
76 const char *host_type, const char *pci_type)
845773ab 77{
ec68007a 78 PCMachineState *pcms = PC_MACHINE(machine);
7102fa70 79 PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
f0bb276b 80 X86MachineState *x86ms = X86_MACHINE(machine);
1e099556
EH
81 MemoryRegion *system_memory = get_system_memory();
82 MemoryRegion *system_io = get_system_io();
845773ab 83 PCIBus *pci_bus;
48a18b3c 84 ISABus *isa_bus;
845773ab
IY
85 PCII440FXState *i440fx_state;
86 int piix3_devfn = -1;
2ba154cf 87 qemu_irq smi_irq;
b881fbe9 88 GSIState *gsi_state;
c0897e0c 89 BusState *idebus[MAX_IDE_BUS];
1d914fa0 90 ISADevice *rtc_state;
ae0a5466
AK
91 MemoryRegion *ram_memory;
92 MemoryRegion *pci_memory;
4463aee6 93 MemoryRegion *rom_memory;
c87b1520 94 ram_addr_t lowmem;
845773ab 95
8156d480
GH
96 /*
97 * Calculate ram split, for memory below and above 4G. It's a bit
98 * complicated for backward compatibility reasons ...
99 *
100 * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the
101 * default value for max_ram_below_4g now.
102 *
103 * - Then, to gigabyte align the memory, we move the split to 3G
104 * (lowmem = 0xc0000000). But only in case we have to split in
105 * the first place, i.e. ram_size is larger than (traditional)
106 * lowmem. And for new machine types (gigabyte_align = true)
107 * only, for live migration compatibility reasons.
108 *
109 * - Next the max-ram-below-4g option was added, which allowed to
110 * reduce lowmem to a smaller value, to allow a larger PCI I/O
111 * window below 4G. qemu doesn't enforce gigabyte alignment here,
112 * but prints a warning.
113 *
114 * - Finally max-ram-below-4g got updated to also allow raising lowmem,
115 * so legacy non-PAE guests can get as much memory as possible in
116 * the 32bit address space below 4G.
117 *
5ec7d098
GH
118 * - Note that Xen has its own ram setp code in xen_ram_init(),
119 * called via xen_hvm_init().
120 *
8156d480
GH
121 * Examples:
122 * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
123 * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high
124 * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high
125 * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M)
ecdbfceb 126 */
5ec7d098
GH
127 if (xen_enabled()) {
128 xen_hvm_init(pcms, &ram_memory);
129 } else {
f0bb276b
PB
130 if (!x86ms->max_ram_below_4g) {
131 x86ms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
5ec7d098 132 }
f0bb276b
PB
133 lowmem = x86ms->max_ram_below_4g;
134 if (machine->ram_size >= x86ms->max_ram_below_4g) {
5ec7d098
GH
135 if (pcmc->gigabyte_align) {
136 if (lowmem > 0xc0000000) {
137 lowmem = 0xc0000000;
138 }
d471bf3e 139 if (lowmem & (1 * GiB - 1)) {
3dc6f869
AF
140 warn_report("Large machine and max_ram_below_4g "
141 "(%" PRIu64 ") not a multiple of 1G; "
142 "possible bad performance.",
f0bb276b 143 x86ms->max_ram_below_4g);
5ec7d098 144 }
8156d480 145 }
c87b1520 146 }
c87b1520 147
5ec7d098 148 if (machine->ram_size >= lowmem) {
f0bb276b
PB
149 x86ms->above_4g_mem_size = machine->ram_size - lowmem;
150 x86ms->below_4g_mem_size = lowmem;
5ec7d098 151 } else {
f0bb276b
PB
152 x86ms->above_4g_mem_size = 0;
153 x86ms->below_4g_mem_size = machine->ram_size;
5ec7d098 154 }
3c2a9669
DS
155 }
156
703a548a 157 x86_cpus_init(x86ms, pcmc->default_cpu_version);
3c2a9669 158
7102fa70 159 if (kvm_enabled() && pcmc->kvmclock_enabled) {
3c2a9669
DS
160 kvmclock_create();
161 }
162
7102fa70 163 if (pcmc->pci_enabled) {
4463aee6 164 pci_memory = g_new(MemoryRegion, 1);
286690e3 165 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
4463aee6
JK
166 rom_memory = pci_memory;
167 } else {
168 pci_memory = NULL;
169 rom_memory = system_memory;
170 }
ae0a5466 171
5db3f0de 172 pc_guest_info_init(pcms);
3459a625 173
7102fa70 174 if (pcmc->smbios_defaults) {
3ef96221 175 MachineClass *mc = MACHINE_GET_CLASS(machine);
b29ad07e 176 /* These values are guest ABI, do not change */
e6667f71 177 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
7102fa70
EH
178 mc->name, pcmc->smbios_legacy_mode,
179 pcmc->smbios_uuid_encoded,
86299120 180 SMBIOS_ENTRY_POINT_21);
b29ad07e
MA
181 }
182
845773ab 183 /* allocate ram and load rom/bios */
29d3ccde 184 if (!xen_enabled()) {
62b160c0 185 pc_memory_init(pcms, system_memory,
5934e216 186 rom_memory, &ram_memory);
b33a5bbf
CL
187 } else if (machine->kernel_filename != NULL) {
188 /* For xen HVM direct kernel boot, load linux here */
7bc35e0f 189 xen_load_linux(pcms);
29d3ccde 190 }
845773ab 191
417258f1 192 gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
845773ab 193
7102fa70 194 if (pcmc->pci_enabled) {
48bc99a0
PMD
195 PIIX3State *piix3;
196
76d39ab4
TC
197 pci_bus = i440fx_init(host_type,
198 pci_type,
48bc99a0 199 &i440fx_state,
3ef96221 200 system_memory, system_io, machine->ram_size,
f0bb276b
PB
201 x86ms->below_4g_mem_size,
202 x86ms->above_4g_mem_size,
ae0a5466 203 pci_memory, ram_memory);
81ed6482 204 pcms->bus = pci_bus;
48bc99a0
PMD
205
206 piix3 = piix3_create(pci_bus, &isa_bus);
207 piix3->pic = x86ms->gsi;
208 piix3_devfn = piix3->dev.devfn;
845773ab
IY
209 } else {
210 pci_bus = NULL;
02a89b21 211 i440fx_state = NULL;
d10e5432
MA
212 isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
213 &error_abort);
57285cc3 214 no_hpet = 1;
845773ab 215 }
f0bb276b 216 isa_bus_irqs(isa_bus, x86ms->gsi);
845773ab 217
4501d317 218 pc_i8259_create(isa_bus, gsi_state->i8259_irq);
4bae1efe 219
7102fa70 220 if (pcmc->pci_enabled) {
a39e3564 221 ioapic_init_gsi(gsi_state, "i440fx");
4bae1efe
RH
222 }
223
6f529b75
PB
224 if (tcg_enabled()) {
225 x86_register_ferr_irq(x86ms->gsi[13]);
226 }
845773ab 227
7102fa70 228 pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
01195b73 229
7fb1cf16 230 assert(pcms->vmport != ON_OFF_AUTO__MAX);
ec68007a
EH
231 if (pcms->vmport == ON_OFF_AUTO_AUTO) {
232 pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
d1048bef
DS
233 }
234
845773ab 235 /* init basic PC hardware */
f0bb276b 236 pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true,
f5878b03
CM
237 (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
238 0x4);
845773ab 239
4b9c264b 240 pc_nic_init(pcmc, isa_bus, pci_bus);
845773ab 241
7102fa70 242 if (pcmc->pci_enabled) {
c0897e0c 243 PCIDevice *dev;
df45d38f
BZ
244
245 dev = pci_create_simple(pci_bus, piix3_devfn + 1,
246 xen_enabled() ? "piix3-ide-xen" : "piix3-ide");
be1765f3 247 pci_ide_create_devs(dev);
c0897e0c
MA
248 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
249 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
60386ea2
JM
250 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
251 }
252#ifdef CONFIG_IDE_ISA
be1765f3
BZ
253 else {
254 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
c9d6da3a 255 int i;
be1765f3
BZ
256
257 ide_drive_get(hd, ARRAY_SIZE(hd));
c9d6da3a 258 for (i = 0; i < MAX_IDE_BUS; i++) {
c0897e0c 259 ISADevice *dev;
61de3676 260 char busname[] = "ide.0";
48a18b3c
HP
261 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
262 ide_irq[i],
c0897e0c 263 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
61de3676
AG
264 /*
265 * The ide bus name is ide.0 for the first bus and ide.1 for the
266 * second one.
267 */
268 busname[4] = '0' + i;
269 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
845773ab 270 }
60386ea2 271 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
845773ab 272 }
60386ea2 273#endif
845773ab 274
4bcbe0b6 275 if (pcmc->pci_enabled && machine_usb(machine)) {
afb9a60e 276 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
845773ab
IY
277 }
278
17e89077 279 if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
781bbd6b 280 DeviceState *piix4_pm;
845773ab 281
2ba154cf 282 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
845773ab 283 /* TODO: Populate SPD eeprom data. */
ebe15582 284 pcms->smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
f0bb276b 285 x86ms->gsi[9], smi_irq,
ed9e923c 286 x86_machine_is_smm_enabled(x86ms),
ebe15582
CM
287 &piix4_pm);
288 smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
781bbd6b
IM
289
290 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
291 TYPE_HOTPLUG_HANDLER,
ec68007a 292 (Object **)&pcms->acpi_dev,
781bbd6b 293 object_property_allow_set_link,
265b578c 294 OBJ_PROP_LINK_STRONG, &error_abort);
781bbd6b
IM
295 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
296 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
845773ab
IY
297 }
298
f6a0d06b
EA
299 if (machine->nvdimms_state->is_enabled) {
300 nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
5c94b826 301 x86_nvdimm_acpi_dsmio,
f0bb276b 302 x86ms->fw_cfg, OBJECT(pcms));
5fe79386 303 }
845773ab
IY
304}
305
79859507
EH
306/* Looking for a pc_compat_2_4() function? It doesn't exist.
307 * pc_compat_*() functions that run on machine-init time and
308 * change global QEMU state are deprecated. Please don't create
309 * one, and implement any pc-*-2.4 (and newer) compat code in
ac78f737 310 * hw_compat_*, pc_compat_*, or * pc_*_machine_options().
79859507
EH
311 */
312
8995dd90 313static void pc_compat_2_3_fn(MachineState *machine)
5cb50e0a 314{
ed9e923c 315 X86MachineState *x86ms = X86_MACHINE(machine);
355023f2 316 if (kvm_enabled()) {
ed9e923c 317 x86ms->smm = ON_OFF_AUTO_OFF;
355023f2 318 }
5cb50e0a
JW
319}
320
1c30044e 321static void pc_compat_2_2_fn(MachineState *machine)
64bbd372 322{
8995dd90 323 pc_compat_2_3_fn(machine);
64bbd372
PB
324}
325
c4fc5695 326static void pc_compat_2_1_fn(MachineState *machine)
2cad57c7 327{
1c30044e 328 pc_compat_2_2_fn(machine);
5114e842 329 x86_cpu_change_kvm_default("svm", NULL);
2cad57c7
EH
330}
331
a310e653 332static void pc_compat_2_0_fn(MachineState *machine)
3458b2b0 333{
c4fc5695 334 pc_compat_2_1_fn(machine);
3458b2b0
MT
335}
336
a310e653 337static void pc_compat_1_7_fn(MachineState *machine)
b29ad07e 338{
a310e653 339 pc_compat_2_0_fn(machine);
5114e842 340 x86_cpu_change_kvm_default("x2apic", NULL);
b29ad07e
MA
341}
342
a310e653 343static void pc_compat_1_6_fn(MachineState *machine)
f8c457b8 344{
a310e653 345 pc_compat_1_7_fn(machine);
f8c457b8
MT
346}
347
a310e653 348static void pc_compat_1_5_fn(MachineState *machine)
9604f70f 349{
a310e653 350 pc_compat_1_6_fn(machine);
9604f70f
MT
351}
352
a310e653 353static void pc_compat_1_4_fn(MachineState *machine)
9953f882 354{
a310e653 355 pc_compat_1_5_fn(machine);
9953f882
MA
356}
357
3ef96221 358static void pc_compat_1_3(MachineState *machine)
8932cfdf 359{
a310e653 360 pc_compat_1_4_fn(machine);
89b439f3
EH
361}
362
30d2a17b 363/* PC compat function for pc-1.0 to pc-1.2 */
3ef96221 364static void pc_compat_1_2(MachineState *machine)
89b439f3 365{
3ef96221 366 pc_compat_1_3(machine);
5114e842 367 x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
89b439f3
EH
368}
369
3ef96221 370static void pc_init_isa(MachineState *machine)
845773ab 371{
76d39ab4 372 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
845773ab
IY
373}
374
29d3ccde 375#ifdef CONFIG_XEN
998250e9
TC
376static void pc_xen_hvm_init_pci(MachineState *machine)
377{
378 const char *pci_type = has_igd_gfx_passthru ?
379 TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE;
380
381 pc_init1(machine,
382 TYPE_I440FX_PCI_HOST_BRIDGE,
383 pci_type);
384}
385
3ef96221 386static void pc_xen_hvm_init(MachineState *machine)
29d3ccde 387{
e492dc5a 388 PCMachineState *pcms = PC_MACHINE(machine);
39ae4972 389
a88ae0d4
EH
390 if (!xen_enabled()) {
391 error_report("xenfv machine requires the xen accelerator");
392 exit(1);
393 }
394
998250e9 395 pc_xen_hvm_init_pci(machine);
e492dc5a 396 pci_create_simple(pcms->bus, -1, "xen-platform");
29d3ccde
AP
397}
398#endif
399
99fbeafe
EH
400#define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
401 static void pc_init_##suffix(MachineState *machine) \
402 { \
403 void (*compat)(MachineState *m) = (compatfn); \
404 if (compat) { \
405 compat(machine); \
406 } \
76d39ab4
TC
407 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \
408 TYPE_I440FX_PCI_DEVICE); \
99fbeafe
EH
409 } \
410 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
fddd179a 411
865906f7 412static void pc_i440fx_machine_options(MachineClass *m)
fddd179a 413{
4b9c264b
PB
414 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
415 pcmc->default_nic_model = "e1000";
416
fddd179a
EH
417 m->family = "pc_piix";
418 m->desc = "Standard PC (i440FX + PIIX, 1996)";
254bdb1c
EH
419 m->default_machine_opts = "firmware=bios-256k.bin";
420 m->default_display = "std";
94692dcd 421 machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
fddd179a
EH
422}
423
541aaa1d 424static void pc_i440fx_5_1_machine_options(MachineClass *m)
fddd179a 425{
0788a56b 426 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
fddd179a 427 pc_i440fx_machine_options(m);
fddd179a 428 m->alias = "pc";
ea0ac7f6 429 m->is_default = true;
0788a56b 430 pcmc->default_cpu_version = 1;
fddd179a 431}
aeca6e8d 432
541aaa1d
CH
433DEFINE_I440FX_MACHINE(v5_1, "pc-i440fx-5.1", NULL,
434 pc_i440fx_5_1_machine_options);
435
436static void pc_i440fx_5_0_machine_options(MachineClass *m)
437{
438 pc_i440fx_5_1_machine_options(m);
439 m->alias = NULL;
440 m->is_default = false;
441 compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
442 compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
443}
444
3eb74d20
CH
445DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL,
446 pc_i440fx_5_0_machine_options);
447
448static void pc_i440fx_4_2_machine_options(MachineClass *m)
449{
450 pc_i440fx_5_0_machine_options(m);
451 m->alias = NULL;
ea0ac7f6 452 m->is_default = false;
3eb74d20
CH
453 compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
454 compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
455}
456
9aec2e52
CH
457DEFINE_I440FX_MACHINE(v4_2, "pc-i440fx-4.2", NULL,
458 pc_i440fx_4_2_machine_options);
459
460static void pc_i440fx_4_1_machine_options(MachineClass *m)
461{
462 pc_i440fx_4_2_machine_options(m);
463 m->alias = NULL;
ea0ac7f6 464 m->is_default = false;
9aec2e52
CH
465 compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
466 compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
467}
468
9bf2650b
CH
469DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL,
470 pc_i440fx_4_1_machine_options);
471
472static void pc_i440fx_4_0_machine_options(MachineClass *m)
473{
0788a56b 474 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
9bf2650b
CH
475 pc_i440fx_4_1_machine_options(m);
476 m->alias = NULL;
ea0ac7f6 477 m->is_default = false;
0788a56b 478 pcmc->default_cpu_version = CPU_VERSION_LEGACY;
9bf2650b
CH
479 compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
480 compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
481}
482
84e060bf
AW
483DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
484 pc_i440fx_4_0_machine_options);
485
486static void pc_i440fx_3_1_machine_options(MachineClass *m)
487{
fda672b5
SG
488 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
489
84e060bf 490 pc_i440fx_4_0_machine_options(m);
ea0ac7f6 491 m->is_default = false;
ebe15582 492 pcmc->do_not_add_smb_acpi = true;
7fccf2a0 493 m->smbus_no_migration_support = true;
84e060bf 494 m->alias = NULL;
fda672b5 495 pcmc->pvh_enabled = false;
abd93cc7
MAL
496 compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
497 compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
84e060bf
AW
498}
499
4a93722f
MAL
500DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
501 pc_i440fx_3_1_machine_options);
502
503static void pc_i440fx_3_0_machine_options(MachineClass *m)
504{
505 pc_i440fx_3_1_machine_options(m);
ddb3235d
MAL
506 compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len);
507 compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len);
4a93722f
MAL
508}
509
aa78a16d
PM
510DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
511 pc_i440fx_3_0_machine_options);
968ee4ad
BM
512
513static void pc_i440fx_2_12_machine_options(MachineClass *m)
514{
aa78a16d 515 pc_i440fx_3_0_machine_options(m);
0d47310b
MAL
516 compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len);
517 compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len);
968ee4ad
BM
518}
519
df47ce8a
HZ
520DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
521 pc_i440fx_2_12_machine_options);
522
523static void pc_i440fx_2_11_machine_options(MachineClass *m)
524{
525 pc_i440fx_2_12_machine_options(m);
43df70a9
MAL
526 compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len);
527 compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len);
df47ce8a
HZ
528}
529
a6fd5b0e
MA
530DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL,
531 pc_i440fx_2_11_machine_options);
532
533static void pc_i440fx_2_10_machine_options(MachineClass *m)
534{
535 pc_i440fx_2_11_machine_options(m);
503224f4
MAL
536 compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len);
537 compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len);
7b8be49d 538 m->auto_enable_numa_with_memhp = false;
a6fd5b0e
MA
539}
540
465238d9
PX
541DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL,
542 pc_i440fx_2_10_machine_options);
543
544static void pc_i440fx_2_9_machine_options(MachineClass *m)
545{
546 pc_i440fx_2_10_machine_options(m);
3e803152
MAL
547 compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len);
548 compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len);
3da2bd8c 549 m->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
465238d9
PX
550}
551
d580bd4b
EH
552DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL,
553 pc_i440fx_2_9_machine_options);
554
555static void pc_i440fx_2_8_machine_options(MachineClass *m)
556{
557 pc_i440fx_2_9_machine_options(m);
edc24ccd
MAL
558 compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len);
559 compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len);
d580bd4b
EH
560}
561
a4d3c834
LM
562DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL,
563 pc_i440fx_2_8_machine_options);
564
a4d3c834
LM
565static void pc_i440fx_2_7_machine_options(MachineClass *m)
566{
567 pc_i440fx_2_8_machine_options(m);
5a995064
MAL
568 compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len);
569 compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len);
a4d3c834
LM
570}
571
d86c1451
IM
572DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL,
573 pc_i440fx_2_7_machine_options);
574
d86c1451
IM
575static void pc_i440fx_2_6_machine_options(MachineClass *m)
576{
679dd1a9 577 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 578
d86c1451 579 pc_i440fx_2_7_machine_options(m);
679dd1a9 580 pcmc->legacy_cpu_hotplug = true;
98e753a6 581 pcmc->linuxboot_dma_enabled = false;
ff8f261f
MAL
582 compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len);
583 compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len);
d86c1451
IM
584}
585
240240d5
EH
586DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL,
587 pc_i440fx_2_6_machine_options);
588
240240d5
EH
589static void pc_i440fx_2_5_machine_options(MachineClass *m)
590{
2f34ebf2 591 X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
88cbe073 592
240240d5 593 pc_i440fx_2_6_machine_options(m);
2f34ebf2 594 x86mc->save_tsc_khz = false;
bab47d9a 595 m->legacy_fw_cfg_order = 1;
fe759610
MAL
596 compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len);
597 compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len);
240240d5
EH
598}
599
87e896ab
EH
600DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
601 pc_i440fx_2_5_machine_options);
602
87e896ab
EH
603static void pc_i440fx_2_4_machine_options(MachineClass *m)
604{
605 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 606
87e896ab 607 pc_i440fx_2_5_machine_options(m);
de796d93 608 m->hw_version = "2.4.0";
87e896ab 609 pcmc->broken_reserved_end = true;
2f99b9c2
MAL
610 compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len);
611 compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len);
87e896ab
EH
612}
613
99fbeafe
EH
614DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
615 pc_i440fx_2_4_machine_options)
5cb50e0a 616
865906f7 617static void pc_i440fx_2_3_machine_options(MachineClass *m)
fddd179a 618{
4421c6a3 619 pc_i440fx_2_4_machine_options(m);
de796d93 620 m->hw_version = "2.3.0";
8995dd90
MAL
621 compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len);
622 compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len);
fddd179a 623}
5cb50e0a 624
8995dd90 625DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn,
99fbeafe 626 pc_i440fx_2_3_machine_options);
61f219df 627
865906f7 628static void pc_i440fx_2_2_machine_options(MachineClass *m)
fddd179a 629{
7102fa70 630 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 631
fddd179a 632 pc_i440fx_2_3_machine_options(m);
de796d93 633 m->hw_version = "2.2.0";
112394af 634 m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on";
1c30044e
MAL
635 compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len);
636 compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len);
7102fa70 637 pcmc->rsdp_in_ram = false;
fddd179a 638}
64bbd372 639
1c30044e 640DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn,
99fbeafe 641 pc_i440fx_2_2_machine_options);
61f219df 642
865906f7 643static void pc_i440fx_2_1_machine_options(MachineClass *m)
fddd179a 644{
7102fa70 645 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 646
fddd179a 647 pc_i440fx_2_2_machine_options(m);
de796d93 648 m->hw_version = "2.1.0";
fddd179a 649 m->default_display = NULL;
c4fc5695
MAL
650 compat_props_add(m->compat_props, hw_compat_2_1, hw_compat_2_1_len);
651 compat_props_add(m->compat_props, pc_compat_2_1, pc_compat_2_1_len);
7102fa70 652 pcmc->smbios_uuid_encoded = false;
16a9e8a5 653 pcmc->enforce_aligned_dimm = false;
fddd179a 654}
f9f21873 655
c4fc5695 656DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn,
99fbeafe 657 pc_i440fx_2_1_machine_options);
61f219df 658
865906f7 659static void pc_i440fx_2_0_machine_options(MachineClass *m)
fddd179a 660{
7102fa70 661 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 662
fddd179a 663 pc_i440fx_2_1_machine_options(m);
de796d93 664 m->hw_version = "2.0.0";
a310e653 665 compat_props_add(m->compat_props, pc_compat_2_0, pc_compat_2_0_len);
7102fa70
EH
666 pcmc->smbios_legacy_mode = true;
667 pcmc->has_reserved_memory = false;
2b0ddf66
EH
668 /* This value depends on the actual DSDT and SSDT compiled into
669 * the source QEMU; unfortunately it depends on the binary and
670 * not on the machine type, so we cannot make pc-i440fx-1.7 work on
671 * both QEMU 1.7 and QEMU 2.0.
672 *
673 * Large variations cause migration to fail for more than one
674 * consecutive value of the "-smp" maxcpus option.
675 *
676 * For small variations of the kind caused by different iasl versions,
677 * the 4k rounding usually leaves slack. However, there could be still
678 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
679 * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
680 *
681 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
682 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
683 */
684 pcmc->legacy_acpi_table_size = 6652;
cd4040ec 685 pcmc->acpi_data_size = 0x10000;
fddd179a 686}
3458b2b0 687
a310e653 688DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0_fn,
99fbeafe 689 pc_i440fx_2_0_machine_options);
61f219df 690
865906f7 691static void pc_i440fx_1_7_machine_options(MachineClass *m)
fddd179a 692{
7102fa70 693 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 694
fddd179a 695 pc_i440fx_2_0_machine_options(m);
de796d93 696 m->hw_version = "1.7.0";
fddd179a 697 m->default_machine_opts = NULL;
71ae9e94 698 m->option_rom_has_mr = true;
a310e653 699 compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len);
7102fa70
EH
700 pcmc->smbios_defaults = false;
701 pcmc->gigabyte_align = false;
2b0ddf66 702 pcmc->legacy_acpi_table_size = 6414;
fddd179a 703}
aeca6e8d 704
a310e653 705DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7_fn,
99fbeafe 706 pc_i440fx_1_7_machine_options);
61f219df 707
865906f7 708static void pc_i440fx_1_6_machine_options(MachineClass *m)
fddd179a 709{
7102fa70 710 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
88cbe073 711
fddd179a 712 pc_i440fx_1_7_machine_options(m);
de796d93 713 m->hw_version = "1.6.0";
71ae9e94 714 m->rom_file_has_mr = false;
a310e653 715 compat_props_add(m->compat_props, pc_compat_1_6, pc_compat_1_6_len);
7102fa70 716 pcmc->has_acpi_build = false;
fddd179a 717}
a0dba644 718
a310e653 719DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6_fn,
99fbeafe 720 pc_i440fx_1_6_machine_options);
61f219df 721
865906f7 722static void pc_i440fx_1_5_machine_options(MachineClass *m)
fddd179a
EH
723{
724 pc_i440fx_1_6_machine_options(m);
de796d93 725 m->hw_version = "1.5.0";
a310e653 726 compat_props_add(m->compat_props, pc_compat_1_5, pc_compat_1_5_len);
fddd179a 727}
b6b5c8e4 728
a310e653 729DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5_fn,
99fbeafe 730 pc_i440fx_1_5_machine_options);
61f219df 731
865906f7 732static void pc_i440fx_1_4_machine_options(MachineClass *m)
fddd179a
EH
733{
734 pc_i440fx_1_5_machine_options(m);
de796d93 735 m->hw_version = "1.4.0";
fddd179a 736 m->hot_add_cpu = NULL;
a310e653 737 compat_props_add(m->compat_props, pc_compat_1_4, pc_compat_1_4_len);
fddd179a 738}
a0dba644 739
a310e653 740DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4_fn,
99fbeafe 741 pc_i440fx_1_4_machine_options);
61f219df 742
865906f7 743static void pc_i440fx_1_3_machine_options(MachineClass *m)
fddd179a 744{
f0bb276b 745 X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
88cbe073
MAL
746 static GlobalProperty compat[] = {
747 PC_CPU_MODEL_IDS("1.3.0")
6c36bddf
EH
748 { "usb-tablet", "usb_version", "1" },
749 { "virtio-net-pci", "ctrl_mac_addr", "off" },
750 { "virtio-net-pci", "mq", "off" },
751 { "e1000", "autonegotiation", "off" },
88cbe073
MAL
752 };
753
fddd179a 754 pc_i440fx_1_4_machine_options(m);
de796d93 755 m->hw_version = "1.3.0";
30d2a17b 756 m->deprecation_reason = "use a newer machine type instead";
f0bb276b 757 x86mc->compat_apic_id_mode = true;
88cbe073 758 compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
fddd179a 759}
b6b5c8e4 760
99fbeafe
EH
761DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
762 pc_i440fx_1_3_machine_options);
61f219df 763
f1ae2e38 764
865906f7 765static void pc_i440fx_1_2_machine_options(MachineClass *m)
fddd179a 766{
88cbe073
MAL
767 static GlobalProperty compat[] = {
768 PC_CPU_MODEL_IDS("1.2.0")
6c36bddf
EH
769 { "nec-usb-xhci", "msi", "off" },
770 { "nec-usb-xhci", "msix", "off" },
6c36bddf
EH
771 { "qxl", "revision", "3" },
772 { "qxl-vga", "revision", "3" },
773 { "VGA", "mmio", "off" },
88cbe073
MAL
774 };
775
fddd179a 776 pc_i440fx_1_3_machine_options(m);
de796d93 777 m->hw_version = "1.2.0";
88cbe073 778 compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
fddd179a 779}
a0dba644 780
99fbeafe
EH
781DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
782 pc_i440fx_1_2_machine_options);
61f219df 783
f4306941 784
865906f7 785static void pc_i440fx_1_1_machine_options(MachineClass *m)
fddd179a 786{
88cbe073
MAL
787 static GlobalProperty compat[] = {
788 PC_CPU_MODEL_IDS("1.1.0")
6c36bddf
EH
789 { "virtio-scsi-pci", "hotplug", "off" },
790 { "virtio-scsi-pci", "param_change", "off" },
791 { "VGA", "vgamem_mb", "8" },
792 { "vmware-svga", "vgamem_mb", "8" },
793 { "qxl-vga", "vgamem_mb", "8" },
794 { "qxl", "vgamem_mb", "8" },
795 { "virtio-blk-pci", "config-wce", "off" },
88cbe073
MAL
796 };
797
fddd179a 798 pc_i440fx_1_2_machine_options(m);
de796d93 799 m->hw_version = "1.1.0";
88cbe073 800 compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
fddd179a 801}
b6b5c8e4 802
99fbeafe
EH
803DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
804 pc_i440fx_1_1_machine_options);
61f219df 805
865906f7 806static void pc_i440fx_1_0_machine_options(MachineClass *m)
fddd179a 807{
88cbe073
MAL
808 static GlobalProperty compat[] = {
809 PC_CPU_MODEL_IDS("1.0")
6c36bddf
EH
810 { TYPE_ISA_FDC, "check_media_rate", "off" },
811 { "virtio-balloon-pci", "class", stringify(PCI_CLASS_MEMORY_RAM) },
812 { "apic-common", "vapic", "off" },
813 { TYPE_USB_DEVICE, "full-path", "no" },
88cbe073
MAL
814 };
815
fddd179a
EH
816 pc_i440fx_1_1_machine_options(m);
817 m->hw_version = "1.0";
88cbe073 818 compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
fddd179a 819}
b6b5c8e4 820
99fbeafe
EH
821DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
822 pc_i440fx_1_0_machine_options);
61f219df 823
382b3a68 824
bd8107d7
TC
825typedef struct {
826 uint16_t gpu_device_id;
827 uint16_t pch_device_id;
828 uint8_t pch_revision_id;
829} IGDDeviceIDInfo;
830
831/* In real world different GPU should have different PCH. But actually
832 * the different PCH DIDs likely map to different PCH SKUs. We do the
833 * same thing for the GPU. For PCH, the different SKUs are going to be
834 * all the same silicon design and implementation, just different
835 * features turn on and off with fuses. The SW interfaces should be
836 * consistent across all SKUs in a given family (eg LPT). But just same
837 * features may not be supported.
838 *
839 * Most of these different PCH features probably don't matter to the
840 * Gfx driver, but obviously any difference in display port connections
841 * will so it should be fine with any PCH in case of passthrough.
842 *
843 * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell)
844 * scenarios, 0x9cc3 for BDW(Broadwell).
845 */
846static const IGDDeviceIDInfo igd_combo_id_infos[] = {
847 /* HSW Classic */
848 {0x0402, 0x8c4e, 0x04}, /* HSWGT1D, HSWD_w7 */
849 {0x0406, 0x8c4e, 0x04}, /* HSWGT1M, HSWM_w7 */
850 {0x0412, 0x8c4e, 0x04}, /* HSWGT2D, HSWD_w7 */
851 {0x0416, 0x8c4e, 0x04}, /* HSWGT2M, HSWM_w7 */
852 {0x041E, 0x8c4e, 0x04}, /* HSWGT15D, HSWD_w7 */
853 /* HSW ULT */
854 {0x0A06, 0x8c4e, 0x04}, /* HSWGT1UT, HSWM_w7 */
855 {0x0A16, 0x8c4e, 0x04}, /* HSWGT2UT, HSWM_w7 */
856 {0x0A26, 0x8c4e, 0x06}, /* HSWGT3UT, HSWM_w7 */
857 {0x0A2E, 0x8c4e, 0x04}, /* HSWGT3UT28W, HSWM_w7 */
858 {0x0A1E, 0x8c4e, 0x04}, /* HSWGT2UX, HSWM_w7 */
859 {0x0A0E, 0x8c4e, 0x04}, /* HSWGT1ULX, HSWM_w7 */
860 /* HSW CRW */
861 {0x0D26, 0x8c4e, 0x04}, /* HSWGT3CW, HSWM_w7 */
862 {0x0D22, 0x8c4e, 0x04}, /* HSWGT3CWDT, HSWD_w7 */
863 /* HSW Server */
864 {0x041A, 0x8c4e, 0x04}, /* HSWSVGT2, HSWD_w7 */
865 /* HSW SRVR */
866 {0x040A, 0x8c4e, 0x04}, /* HSWSVGT1, HSWD_w7 */
867 /* BSW */
868 {0x1606, 0x9cc3, 0x03}, /* BDWULTGT1, BDWM_w7 */
869 {0x1616, 0x9cc3, 0x03}, /* BDWULTGT2, BDWM_w7 */
870 {0x1626, 0x9cc3, 0x03}, /* BDWULTGT3, BDWM_w7 */
871 {0x160E, 0x9cc3, 0x03}, /* BDWULXGT1, BDWM_w7 */
872 {0x161E, 0x9cc3, 0x03}, /* BDWULXGT2, BDWM_w7 */
873 {0x1602, 0x9cc3, 0x03}, /* BDWHALOGT1, BDWM_w7 */
874 {0x1612, 0x9cc3, 0x03}, /* BDWHALOGT2, BDWM_w7 */
875 {0x1622, 0x9cc3, 0x03}, /* BDWHALOGT3, BDWM_w7 */
876 {0x162B, 0x9cc3, 0x03}, /* BDWHALO28W, BDWM_w7 */
877 {0x162A, 0x9cc3, 0x03}, /* BDWGT3WRKS, BDWM_w7 */
878 {0x162D, 0x9cc3, 0x03}, /* BDWGT3SRVR, BDWM_w7 */
879};
880
881static void isa_bridge_class_init(ObjectClass *klass, void *data)
882{
883 DeviceClass *dc = DEVICE_CLASS(klass);
884 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
885
886 dc->desc = "ISA bridge faked to support IGD PT";
965242db 887 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
bd8107d7
TC
888 k->vendor_id = PCI_VENDOR_ID_INTEL;
889 k->class_id = PCI_CLASS_BRIDGE_ISA;
890};
891
892static TypeInfo isa_bridge_info = {
893 .name = "igd-passthrough-isa-bridge",
894 .parent = TYPE_PCI_DEVICE,
895 .instance_size = sizeof(PCIDevice),
896 .class_init = isa_bridge_class_init,
fd3b02c8
EH
897 .interfaces = (InterfaceInfo[]) {
898 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
899 { },
900 },
bd8107d7
TC
901};
902
903static void pt_graphics_register_types(void)
904{
905 type_register_static(&isa_bridge_info);
906}
907type_init(pt_graphics_register_types)
908
909void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id)
910{
911 struct PCIDevice *bridge_dev;
912 int i, num;
913 uint16_t pch_dev_id = 0xffff;
914 uint8_t pch_rev_id;
915
916 num = ARRAY_SIZE(igd_combo_id_infos);
917 for (i = 0; i < num; i++) {
918 if (gpu_dev_id == igd_combo_id_infos[i].gpu_device_id) {
919 pch_dev_id = igd_combo_id_infos[i].pch_device_id;
920 pch_rev_id = igd_combo_id_infos[i].pch_revision_id;
921 }
922 }
923
924 if (pch_dev_id == 0xffff) {
925 return;
926 }
927
928 /* Currently IGD drivers always need to access PCH by 1f.0. */
929 bridge_dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
930 "igd-passthrough-isa-bridge");
931
932 /*
933 * Note that vendor id is always PCI_VENDOR_ID_INTEL.
934 */
935 if (!bridge_dev) {
936 fprintf(stderr, "set igd-passthrough-isa-bridge failed!\n");
937 return;
938 }
939 pci_config_set_device_id(bridge_dev->config, pch_dev_id);
940 pci_config_set_revision(bridge_dev->config, pch_rev_id);
941}
845773ab 942
865906f7 943static void isapc_machine_options(MachineClass *m)
fddd179a 944{
7102fa70 945 PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
fddd179a
EH
946 m->desc = "ISA-only PC";
947 m->max_cpus = 1;
71ae9e94
EH
948 m->option_rom_has_mr = true;
949 m->rom_file_has_mr = false;
7102fa70
EH
950 pcmc->pci_enabled = false;
951 pcmc->has_acpi_build = false;
952 pcmc->smbios_defaults = false;
953 pcmc->gigabyte_align = false;
954 pcmc->smbios_legacy_mode = true;
955 pcmc->has_reserved_memory = false;
4b9c264b 956 pcmc->default_nic_model = "ne2k_isa";
311ca98d 957 m->default_cpu_type = X86_CPU_TYPE_NAME("486");
fddd179a 958}
b6b5c8e4 959
61f219df 960DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
25519b06 961 isapc_machine_options);
61f219df 962
845773ab 963
29d3ccde 964#ifdef CONFIG_XEN
9a709f06 965static void xenfv_4_2_machine_options(MachineClass *m)
fddd179a 966{
9a709f06
OH
967 pc_i440fx_4_2_machine_options(m);
968 m->desc = "Xen Fully-virtualized PC";
969 m->max_cpus = HVM_MAX_VCPUS;
970 m->default_machine_opts = "accel=xen";
971}
972
973DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
974 xenfv_4_2_machine_options);
975
976static void xenfv_3_1_machine_options(MachineClass *m)
977{
978 pc_i440fx_3_1_machine_options(m);
fddd179a 979 m->desc = "Xen Fully-virtualized PC";
9a709f06 980 m->alias = "xenfv";
fddd179a
EH
981 m->max_cpus = HVM_MAX_VCPUS;
982 m->default_machine_opts = "accel=xen";
fddd179a 983}
b6b5c8e4 984
9a709f06
OH
985DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
986 xenfv_3_1_machine_options);
29d3ccde 987#endif