]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/i386/pc.h
Merge remote-tracking branch 'remotes/rth/tags/pull-sparc-20161031-2' into staging
[mirror_qemu.git] / include / hw / i386 / pc.h
CommitLineData
87ecb68b
PB
1#ifndef HW_PC_H
2#define HW_PC_H
376253ec
AL
3
4#include "qemu-common.h"
022c62cb 5#include "exec/memory.h"
9521d42b 6#include "hw/boards.h"
0d09e41a
PB
7#include "hw/isa/isa.h"
8#include "hw/block/fdc.h"
1422e32d 9#include "net/net.h"
0d09e41a 10#include "hw/i386/ioapic.h"
376253ec 11
3459a625 12#include "qemu/range.h"
b20c9bd5
MT
13#include "qemu/bitmap.h"
14#include "sysemu/sysemu.h"
15#include "hw/pci/pci.h"
68a27b20 16#include "hw/compat.h"
a7d69ff1 17#include "hw/mem/pc-dimm.h"
5fe79386 18#include "hw/mem/nvdimm.h"
ac35f13b 19#include "hw/acpi/acpi_dev_interface.h"
3459a625 20
7a10ef51
LPF
21#define HPET_INTCAP "hpet-intcap"
22
15eafc2e
PB
23#ifdef CONFIG_KVM
24#define kvm_pit_in_kernel() \
25 (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split())
26#define kvm_pic_in_kernel() \
27 (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split())
28#define kvm_ioapic_in_kernel() \
29 (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split())
30#else
31#define kvm_pit_in_kernel() 0
32#define kvm_pic_in_kernel() 0
33#define kvm_ioapic_in_kernel() 0
34#endif
35
619d11e4
IM
36/**
37 * PCMachineState:
781bbd6b 38 * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
080ac219 39 * @boot_cpus_le: number of present VCPUs, referenced by 'etc/boot-cpus' fw_cfg
619d11e4 40 */
d5747cac
IM
41struct PCMachineState {
42 /*< private >*/
43 MachineState parent_obj;
619d11e4
IM
44
45 /* <public> */
13fc8343
EH
46
47 /* State for other subsystems/APIs: */
a7d69ff1 48 MemoryHotplugState hotplug_memory;
9ebeed0c 49 Notifier machine_done;
781bbd6b 50
13fc8343 51 /* Pointers to devices and objects: */
781bbd6b 52 HotplugHandler *acpi_dev;
2d996150 53 ISADevice *rtc;
13fc8343 54 PCIBus *bus;
f264d360 55 FWCfgState *fw_cfg;
3e6c0c4c 56 qemu_irq *gsi;
c87b1520 57
13fc8343 58 /* Configuration options: */
c87b1520 59 uint64_t max_ram_below_4g;
d1048bef 60 OnOffAuto vmport;
355023f2 61 OnOffAuto smm;
5fe79386
XG
62
63 AcpiNVDIMMState acpi_nvdimm_state;
13fc8343
EH
64
65 /* RAM information (sizes, addresses, configuration): */
c0aa4e1e 66 ram_addr_t below_4g_mem_size, above_4g_mem_size;
dd4c2f01
EH
67
68 /* CPU and apic information: */
69 bool apic_xrupt_override;
70 unsigned apic_id_limit;
3811ef14 71 CPUArchIdList *possible_cpus;
080ac219 72 uint16_t boot_cpus_le;
dd4c2f01
EH
73
74 /* NUMA information: */
75 uint64_t numa_nodes;
76 uint64_t *node_mem;
cb135f59
PX
77
78 /* Address space used by IOAPIC device. All IOAPIC interrupts
79 * will be translated to MSI messages in the address space. */
80 AddressSpace *ioapic_as;
d5747cac
IM
81};
82
781bbd6b 83#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
bf1e8939 84#define PC_MACHINE_MEMHP_REGION_SIZE "hotplug-memory-region-size"
c87b1520 85#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
9b23cfb7 86#define PC_MACHINE_VMPORT "vmport"
355023f2 87#define PC_MACHINE_SMM "smm"
87252e1b 88#define PC_MACHINE_NVDIMM "nvdimm"
781bbd6b 89
95bee274
IM
90/**
91 * PCMachineClass:
13fc8343
EH
92 *
93 * Methods:
94 *
95bee274 95 * @get_hotplug_handler: pointer to parent class callback @get_hotplug_handler
13fc8343
EH
96 *
97 * Compat fields:
98 *
16a9e8a5
EH
99 * @enforce_aligned_dimm: check that DIMM's address/size is aligned by
100 * backend's alignment value if provided
13fc8343
EH
101 * @acpi_data_size: Size of the chunk of memory at the top of RAM
102 * for the BIOS ACPI tables and other BIOS
103 * datastructures.
104 * @gigabyte_align: Make sure that guest addresses aligned at
105 * 1Gbyte boundaries get mapped to host
106 * addresses aligned at 1Gbyte boundaries. This
107 * way we can use 1GByte pages in the host.
108 *
95bee274 109 */
d5747cac
IM
110struct PCMachineClass {
111 /*< private >*/
112 MachineClass parent_class;
95bee274
IM
113
114 /*< public >*/
13fc8343
EH
115
116 /* Methods: */
95bee274
IM
117 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
118 DeviceState *dev);
7102fa70 119
13fc8343 120 /* Device configuration: */
7102fa70 121 bool pci_enabled;
13fc8343
EH
122 bool kvmclock_enabled;
123
124 /* Compat options: */
125
126 /* ACPI compat: */
7102fa70
EH
127 bool has_acpi_build;
128 bool rsdp_in_ram;
13fc8343
EH
129 int legacy_acpi_table_size;
130 unsigned acpi_data_size;
131
132 /* SMBIOS compat: */
7102fa70
EH
133 bool smbios_defaults;
134 bool smbios_legacy_mode;
135 bool smbios_uuid_encoded;
13fc8343
EH
136
137 /* RAM / address space compat: */
7102fa70
EH
138 bool gigabyte_align;
139 bool has_reserved_memory;
16a9e8a5 140 bool enforce_aligned_dimm;
13fc8343 141 bool broken_reserved_end;
36f96c4b
HZ
142
143 /* TSC rate migration: */
144 bool save_tsc_khz;
679dd1a9
IM
145 /* generate legacy CPU hotplug AML */
146 bool legacy_cpu_hotplug;
d5747cac
IM
147};
148
d5747cac
IM
149#define TYPE_PC_MACHINE "generic-pc-machine"
150#define PC_MACHINE(obj) \
151 OBJECT_CHECK(PCMachineState, (obj), TYPE_PC_MACHINE)
152#define PC_MACHINE_GET_CLASS(obj) \
153 OBJECT_GET_CLASS(PCMachineClass, (obj), TYPE_PC_MACHINE)
154#define PC_MACHINE_CLASS(klass) \
155 OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
156
87ecb68b
PB
157/* PC-style peripherals (also used by other machines). */
158
f854ecc7
MT
159#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
160#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
161#define ACPI_PM_PROP_S4_VAL "s4_val"
162#define ACPI_PM_PROP_SCI_INT "sci_int"
163#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd"
164#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd"
165#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
166#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
167#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
92055797 168#define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
f854ecc7 169
87ecb68b 170/* parallel.c */
07dc7880
MA
171
172void parallel_hds_isa_init(ISABus *bus, int n);
defdb20e 173
63858cd9 174bool parallel_mm_init(MemoryRegion *address_space,
a8170e5e 175 hwaddr base, int it_shift, qemu_irq irq,
defdb20e 176 CharDriverState *chr);
87ecb68b
PB
177
178/* i8259.c */
179
9aa78c42 180extern DeviceState *isa_pic;
48a18b3c 181qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
10b61882 182qemu_irq *kvm_i8259_init(ISABus *bus);
9aa78c42
JK
183int pic_read_irq(DeviceState *d);
184int pic_get_output(DeviceState *d);
87ecb68b 185
d665d696
PB
186/* ioapic.c */
187
188void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict);
6bde8fd6 189void ioapic_dump_state(Monitor *mon, const QDict *qdict);
d665d696 190
b881fbe9 191/* Global System Interrupts */
96051119 192
b881fbe9 193#define GSI_NUM_PINS IOAPIC_NUM_PINS
845773ab 194
b881fbe9 195typedef struct GSIState {
43a0db35 196 qemu_irq i8259_irq[ISA_NUM_IRQS];
b881fbe9
JK
197 qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
198} GSIState;
199
200void gsi_handler(void *opaque, int n, int level);
845773ab 201
87ecb68b 202/* vmport.c */
936a6447 203#define TYPE_VMPORT "vmport"
d67f679d
JK
204typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
205
48a18b3c 206static inline void vmport_init(ISABus *bus)
6872ef61 207{
936a6447 208 isa_create_simple(bus, TYPE_VMPORT);
6872ef61 209}
d67f679d
JK
210
211void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque);
86d86414
BS
212void vmmouse_get_data(uint32_t *data);
213void vmmouse_set_data(const uint32_t *data);
87ecb68b 214
87ecb68b 215/* pckbd.c */
3115b9e2 216#define I8042_A20_LINE "a20"
87ecb68b 217
87ecb68b 218void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
dbff76ac 219 MemoryRegion *region, ram_addr_t size,
a8170e5e 220 hwaddr mask);
956a3e6b 221void i8042_isa_mouse_fake_event(void *opaque);
d80fe99d 222void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out);
87ecb68b 223
87ecb68b
PB
224/* pc.c */
225extern int fd_bootchk;
226
355023f2 227bool pc_machine_is_smm_enabled(PCMachineState *pcms);
8e78eb28 228void pc_register_ferr_irq(qemu_irq irq);
845773ab
IY
229void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
230
4884b7bf 231void pc_cpus_init(PCMachineState *pcms);
c649983b 232void pc_hot_add_cpu(const int64_t id, Error **errp);
f7e4dd6c 233void pc_acpi_init(const char *default_dsdt);
3459a625 234
e4e8ba04 235void pc_guest_info_init(PCMachineState *pcms);
3459a625 236
39848901
IM
237#define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start"
238#define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
239#define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
240#define PCI_HOST_PROP_PCI_HOLE64_END "pci-hole64-end"
241#define PCI_HOST_PROP_PCI_HOLE64_SIZE "pci-hole64-size"
401f2f3e
EV
242#define PCI_HOST_BELOW_4G_MEM_SIZE "below-4g-mem-size"
243#define PCI_HOST_ABOVE_4G_MEM_SIZE "above-4g-mem-size"
1466cef3
MT
244#define DEFAULT_PCI_HOLE64_SIZE (~0x0ULL)
245
39848901 246
83d08f26
MT
247void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
248 MemoryRegion *pci_address_space);
39848901 249
7bc35e0f 250void xen_load_linux(PCMachineState *pcms);
5934e216
EH
251void pc_memory_init(PCMachineState *pcms,
252 MemoryRegion *system_memory,
253 MemoryRegion *rom_memory,
254 MemoryRegion **ram_memory);
0b0cc076 255qemu_irq pc_allocate_cpu_irq(void);
48a18b3c
HP
256DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
257void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
1611977c 258 ISADevice **rtc_state,
fd53c87c 259 bool create_fdctrl,
7a10ef51 260 bool no_vmport,
3a87d009 261 uint32_t hpet_irqs);
48a18b3c 262void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
23d30407 263void pc_cmos_init(PCMachineState *pcms,
220a8846 264 BusState *ide0, BusState *ide1,
63ffb564 265 ISADevice *s);
9011a1a7 266void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
845773ab 267void pc_pci_device_init(PCIBus *pci_bus);
8e78eb28 268
f885f1ea 269typedef void (*cpu_set_smm_t)(int smm, void *arg);
f885f1ea 270
a39e3564
JB
271void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
272
424e4a87 273ISADevice *pc_find_fdc0(void);
bda05509 274int cmos_get_fd_drive_type(FloppyDriveType fd0);
424e4a87 275
305ae888
GS
276#define FW_CFG_IO_BASE 0x510
277
d812b3d6
EV
278#define PORT92_A20_LINE "a20"
279
9d5e77a2 280/* acpi_piix.c */
53b67b30 281
a5c82852
AF
282I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
283 qemu_irq sci_irq, qemu_irq smi_irq,
61e66c62 284 int smm_enabled, DeviceState **piix4_pm);
87ecb68b 285
16b29ae1
AL
286/* hpet.c */
287extern int no_hpet;
288
87ecb68b 289/* piix_pci.c */
0a3bacf3
JQ
290struct PCII440FXState;
291typedef struct PCII440FXState PCII440FXState;
292
7bb836e4
MT
293#define TYPE_I440FX_PCI_HOST_BRIDGE "i440FX-pcihost"
294#define TYPE_I440FX_PCI_DEVICE "i440FX"
295
595a4f07
TC
296#define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX"
297
7bb836e4
MT
298PCIBus *i440fx_init(const char *host_type, const char *pci_type,
299 PCII440FXState **pi440fx_state, int *piix_devfn,
60573079 300 ISABus **isa_bus, qemu_irq *pic,
aee97b84
AK
301 MemoryRegion *address_space_mem,
302 MemoryRegion *address_space_io,
ae0a5466 303 ram_addr_t ram_size,
ddaaefb4 304 ram_addr_t below_4g_mem_size,
39848901 305 ram_addr_t above_4g_mem_size,
ae0a5466
AK
306 MemoryRegion *pci_memory,
307 MemoryRegion *ram_memory);
87ecb68b 308
277e9340 309PCIBus *find_i440fx(void);
823e675a 310/* piix4.c */
b1d8e52e 311extern PCIDevice *piix4_dev;
142e9787 312int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
87ecb68b
PB
313
314/* vga.c */
cb5a7aa8 315enum vga_retrace_method {
316 VGA_RETRACE_DUMB,
317 VGA_RETRACE_PRECISE
318};
319
320extern enum vga_retrace_method vga_retrace_method;
87ecb68b 321
a8170e5e
AK
322int isa_vga_mm_init(hwaddr vram_base,
323 hwaddr ctrl_base, int it_shift,
be20f9e9 324 MemoryRegion *address_space);
87ecb68b 325
87ecb68b 326/* ne2000.c */
48a18b3c 327static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
60a14ad3 328{
4a17cc4f
AF
329 DeviceState *dev;
330 ISADevice *isadev;
87ecb68b 331
60a14ad3
BS
332 qemu_check_nic_model(nd, "ne2k_isa");
333
4a17cc4f
AF
334 isadev = isa_try_create(bus, "ne2k_isa");
335 if (!isadev) {
cd1b8a8b
BS
336 return false;
337 }
4a17cc4f
AF
338 dev = DEVICE(isadev);
339 qdev_prop_set_uint32(dev, "iobase", base);
340 qdev_prop_set_uint32(dev, "irq", irq);
341 qdev_set_nic_properties(dev, nd);
342 qdev_init_nofail(dev);
cd1b8a8b 343 return true;
60a14ad3 344}
87ecb68b 345
cbc5b5f3 346/* pc_sysfw.c */
6dd2a5c9
PB
347void pc_system_firmware_init(MemoryRegion *rom_memory,
348 bool isapc_ram_fw);
cbc5b5f3 349
3ab135f3 350/* pvpanic.c */
309cd62d 351uint16_t pvpanic_port(void);
3ab135f3 352
ac35f13b
IM
353/* acpi-build.c */
354void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
355 CPUArchIdList *apic_ids, GArray *entry);
356
4c5b10b7
JS
357/* e820 types */
358#define E820_RAM 1
359#define E820_RESERVED 2
360#define E820_ACPI 3
361#define E820_NVS 4
362#define E820_UNUSABLE 5
363
364int e820_add_entry(uint64_t, uint64_t, uint32_t);
7bf8ef19
GS
365int e820_get_num_entries(void);
366bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
4c5b10b7 367
14c985cf 368#define PC_COMPAT_2_8 \
152fcbec
IM
369
370#define PC_COMPAT_2_7 \
371 HW_COMPAT_2_7 \
14c985cf
LM
372 {\
373 .driver = TYPE_X86_CPU,\
374 .property = "l3-cache",\
375 .value = "off",\
c39c0edf
EH
376 },\
377 {\
378 .driver = TYPE_X86_CPU,\
379 .property = "full-cpuid-auto-level",\
380 .value = "off",\
339892d7
EY
381 },\
382 {\
383 .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
384 .property = "family",\
385 .value = "15",\
386 },\
387 {\
388 .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
389 .property = "model",\
390 .value = "6",\
391 },\
392 {\
393 .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
394 .property = "stepping",\
395 .value = "1",\
14c985cf
LM
396 },
397
d86c1451 398#define PC_COMPAT_2_6 \
5232d00a
RK
399 HW_COMPAT_2_6 \
400 {\
b2a575a1
MM
401 .driver = "fw_cfg_io",\
402 .property = "dma_enabled",\
403 .value = "off",\
404 },{\
5232d00a
RK
405 .driver = TYPE_X86_CPU,\
406 .property = "cpuid-0xb",\
407 .value = "off",\
43716de6
GH
408 },{\
409 .driver = "vmxnet3",\
410 .property = "romfile",\
411 .value = "",\
fcc35e7c
DDAG
412 },\
413 {\
414 .driver = TYPE_X86_CPU,\
415 .property = "fill-mtrr-mask",\
416 .value = "off",\
f6e98444
IM
417 },\
418 {\
7298d4fd 419 .driver = "apic-common",\
f6e98444
IM
420 .property = "legacy-instance-id",\
421 .value = "on",\
5232d00a 422 },
d86c1451 423
240240d5
EH
424#define PC_COMPAT_2_5 \
425 HW_COMPAT_2_5
426
cd6c1b70
EH
427/* Helper for setting model-id for CPU models that changed model-id
428 * depending on QEMU versions up to QEMU 2.4.
429 */
430#define PC_CPU_MODEL_IDS(v) \
431 {\
432 .driver = "qemu32-" TYPE_X86_CPU,\
433 .property = "model-id",\
434 .value = "QEMU Virtual CPU version " v,\
435 },\
436 {\
437 .driver = "qemu64-" TYPE_X86_CPU,\
438 .property = "model-id",\
439 .value = "QEMU Virtual CPU version " v,\
440 },\
441 {\
442 .driver = "athlon-" TYPE_X86_CPU,\
443 .property = "model-id",\
444 .value = "QEMU Virtual CPU version " v,\
445 },
446
87e896ab 447#define PC_COMPAT_2_4 \
276a65ba 448 HW_COMPAT_2_4 \
cd6c1b70 449 PC_CPU_MODEL_IDS("2.4.0") \
276a65ba
EH
450 {\
451 .driver = "Haswell-" TYPE_X86_CPU,\
452 .property = "abm",\
453 .value = "off",\
454 },\
455 {\
456 .driver = "Haswell-noTSX-" TYPE_X86_CPU,\
457 .property = "abm",\
458 .value = "off",\
459 },\
460 {\
461 .driver = "Broadwell-" TYPE_X86_CPU,\
462 .property = "abm",\
463 .value = "off",\
464 },\
465 {\
466 .driver = "Broadwell-noTSX-" TYPE_X86_CPU,\
467 .property = "abm",\
468 .value = "off",\
469 },\
470 {\
471 .driver = "host" "-" TYPE_X86_CPU,\
472 .property = "host-cache-info",\
473 .value = "on",\
474 },\
475 {\
476 .driver = TYPE_X86_CPU,\
477 .property = "check",\
478 .value = "off",\
479 },\
480 {\
481 .driver = "qemu64" "-" TYPE_X86_CPU,\
482 .property = "sse4a",\
483 .value = "on",\
484 },\
485 {\
486 .driver = "qemu64" "-" TYPE_X86_CPU,\
487 .property = "abm",\
488 .value = "on",\
489 },\
490 {\
491 .driver = "qemu64" "-" TYPE_X86_CPU,\
492 .property = "popcnt",\
493 .value = "on",\
494 },\
495 {\
496 .driver = "qemu32" "-" TYPE_X86_CPU,\
497 .property = "popcnt",\
498 .value = "on",\
499 },{\
500 .driver = "Opteron_G2" "-" TYPE_X86_CPU,\
501 .property = "rdtscp",\
502 .value = "on",\
503 },{\
504 .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
505 .property = "rdtscp",\
506 .value = "on",\
507 },{\
508 .driver = "Opteron_G4" "-" TYPE_X86_CPU,\
509 .property = "rdtscp",\
510 .value = "on",\
511 },{\
512 .driver = "Opteron_G5" "-" TYPE_X86_CPU,\
513 .property = "rdtscp",\
514 .value = "on",\
515 },
87e896ab 516
33b5e8c0 517
42134ac9 518#define PC_COMPAT_2_3 \
276a65ba 519 HW_COMPAT_2_3 \
cd6c1b70 520 PC_CPU_MODEL_IDS("2.3.0") \
276a65ba
EH
521 {\
522 .driver = TYPE_X86_CPU,\
523 .property = "arat",\
524 .value = "off",\
525 },{\
526 .driver = "qemu64" "-" TYPE_X86_CPU,\
527 .property = "level",\
528 .value = stringify(4),\
529 },{\
530 .driver = "kvm64" "-" TYPE_X86_CPU,\
531 .property = "level",\
532 .value = stringify(5),\
533 },{\
534 .driver = "pentium3" "-" TYPE_X86_CPU,\
535 .property = "level",\
536 .value = stringify(2),\
537 },{\
538 .driver = "n270" "-" TYPE_X86_CPU,\
539 .property = "level",\
540 .value = stringify(5),\
541 },{\
542 .driver = "Conroe" "-" TYPE_X86_CPU,\
543 .property = "level",\
544 .value = stringify(4),\
545 },{\
546 .driver = "Penryn" "-" TYPE_X86_CPU,\
547 .property = "level",\
548 .value = stringify(4),\
549 },{\
550 .driver = "Nehalem" "-" TYPE_X86_CPU,\
551 .property = "level",\
552 .value = stringify(4),\
553 },{\
554 .driver = "n270" "-" TYPE_X86_CPU,\
555 .property = "xlevel",\
556 .value = stringify(0x8000000a),\
557 },{\
558 .driver = "Penryn" "-" TYPE_X86_CPU,\
559 .property = "xlevel",\
560 .value = stringify(0x8000000a),\
561 },{\
562 .driver = "Conroe" "-" TYPE_X86_CPU,\
563 .property = "xlevel",\
564 .value = stringify(0x8000000a),\
565 },{\
566 .driver = "Nehalem" "-" TYPE_X86_CPU,\
567 .property = "xlevel",\
568 .value = stringify(0x8000000a),\
569 },{\
570 .driver = "Westmere" "-" TYPE_X86_CPU,\
571 .property = "xlevel",\
572 .value = stringify(0x8000000a),\
573 },{\
574 .driver = "SandyBridge" "-" TYPE_X86_CPU,\
575 .property = "xlevel",\
576 .value = stringify(0x8000000a),\
577 },{\
578 .driver = "IvyBridge" "-" TYPE_X86_CPU,\
579 .property = "xlevel",\
580 .value = stringify(0x8000000a),\
581 },{\
582 .driver = "Haswell" "-" TYPE_X86_CPU,\
583 .property = "xlevel",\
584 .value = stringify(0x8000000a),\
585 },{\
586 .driver = "Haswell-noTSX" "-" TYPE_X86_CPU,\
587 .property = "xlevel",\
588 .value = stringify(0x8000000a),\
589 },{\
590 .driver = "Broadwell" "-" TYPE_X86_CPU,\
591 .property = "xlevel",\
592 .value = stringify(0x8000000a),\
593 },{\
594 .driver = "Broadwell-noTSX" "-" TYPE_X86_CPU,\
595 .property = "xlevel",\
596 .value = stringify(0x8000000a),\
597 },
42134ac9
EH
598
599#define PC_COMPAT_2_2 \
276a65ba 600 HW_COMPAT_2_2 \
cd6c1b70 601 PC_CPU_MODEL_IDS("2.3.0") \
276a65ba
EH
602 {\
603 .driver = "kvm64" "-" TYPE_X86_CPU,\
604 .property = "vme",\
605 .value = "off",\
606 },\
607 {\
608 .driver = "kvm32" "-" TYPE_X86_CPU,\
609 .property = "vme",\
610 .value = "off",\
611 },\
612 {\
613 .driver = "Conroe" "-" TYPE_X86_CPU,\
614 .property = "vme",\
615 .value = "off",\
616 },\
617 {\
618 .driver = "Penryn" "-" TYPE_X86_CPU,\
619 .property = "vme",\
620 .value = "off",\
621 },\
622 {\
623 .driver = "Nehalem" "-" TYPE_X86_CPU,\
624 .property = "vme",\
625 .value = "off",\
626 },\
627 {\
628 .driver = "Westmere" "-" TYPE_X86_CPU,\
629 .property = "vme",\
630 .value = "off",\
631 },\
632 {\
633 .driver = "SandyBridge" "-" TYPE_X86_CPU,\
634 .property = "vme",\
635 .value = "off",\
636 },\
637 {\
638 .driver = "Haswell" "-" TYPE_X86_CPU,\
639 .property = "vme",\
640 .value = "off",\
641 },\
642 {\
643 .driver = "Broadwell" "-" TYPE_X86_CPU,\
644 .property = "vme",\
645 .value = "off",\
646 },\
647 {\
648 .driver = "Opteron_G1" "-" TYPE_X86_CPU,\
649 .property = "vme",\
650 .value = "off",\
651 },\
652 {\
653 .driver = "Opteron_G2" "-" TYPE_X86_CPU,\
654 .property = "vme",\
655 .value = "off",\
656 },\
657 {\
658 .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
659 .property = "vme",\
660 .value = "off",\
661 },\
662 {\
663 .driver = "Opteron_G4" "-" TYPE_X86_CPU,\
664 .property = "vme",\
665 .value = "off",\
666 },\
667 {\
668 .driver = "Opteron_G5" "-" TYPE_X86_CPU,\
669 .property = "vme",\
670 .value = "off",\
671 },\
672 {\
673 .driver = "Haswell" "-" TYPE_X86_CPU,\
674 .property = "f16c",\
675 .value = "off",\
676 },\
677 {\
678 .driver = "Haswell" "-" TYPE_X86_CPU,\
679 .property = "rdrand",\
680 .value = "off",\
681 },\
682 {\
683 .driver = "Broadwell" "-" TYPE_X86_CPU,\
684 .property = "f16c",\
685 .value = "off",\
686 },\
687 {\
688 .driver = "Broadwell" "-" TYPE_X86_CPU,\
689 .property = "rdrand",\
690 .value = "off",\
691 },
42134ac9
EH
692
693#define PC_COMPAT_2_1 \
276a65ba 694 HW_COMPAT_2_1 \
cd6c1b70 695 PC_CPU_MODEL_IDS("2.1.0") \
276a65ba
EH
696 {\
697 .driver = "coreduo" "-" TYPE_X86_CPU,\
698 .property = "vmx",\
699 .value = "on",\
700 },\
701 {\
702 .driver = "core2duo" "-" TYPE_X86_CPU,\
703 .property = "vmx",\
704 .value = "on",\
705 },
42134ac9 706
9df11c9f 707#define PC_COMPAT_2_0 \
cd6c1b70 708 PC_CPU_MODEL_IDS("2.0.0") \
276a65ba
EH
709 {\
710 .driver = "virtio-scsi-pci",\
711 .property = "any_layout",\
712 .value = "off",\
713 },{\
714 .driver = "PIIX4_PM",\
715 .property = "memory-hotplug-support",\
716 .value = "off",\
717 },\
718 {\
719 .driver = "apic",\
720 .property = "version",\
721 .value = stringify(0x11),\
722 },\
723 {\
724 .driver = "nec-usb-xhci",\
725 .property = "superspeed-ports-first",\
726 .value = "off",\
727 },\
728 {\
729 .driver = "nec-usb-xhci",\
730 .property = "force-pcie-endcap",\
731 .value = "on",\
732 },\
733 {\
734 .driver = "pci-serial",\
735 .property = "prog_if",\
736 .value = stringify(0),\
737 },\
738 {\
739 .driver = "pci-serial-2x",\
740 .property = "prog_if",\
741 .value = stringify(0),\
742 },\
743 {\
744 .driver = "pci-serial-4x",\
745 .property = "prog_if",\
746 .value = stringify(0),\
747 },\
748 {\
749 .driver = "virtio-net-pci",\
750 .property = "guest_announce",\
751 .value = "off",\
752 },\
753 {\
754 .driver = "ICH9-LPC",\
755 .property = "memory-hotplug-support",\
756 .value = "off",\
757 },{\
758 .driver = "xio3130-downstream",\
759 .property = COMPAT_PROP_PCP,\
760 .value = "off",\
761 },{\
762 .driver = "ioh3420",\
763 .property = COMPAT_PROP_PCP,\
764 .value = "off",\
765 },
9df11c9f 766
5319dc7b 767#define PC_COMPAT_1_7 \
cd6c1b70 768 PC_CPU_MODEL_IDS("1.7.0") \
276a65ba
EH
769 {\
770 .driver = TYPE_USB_DEVICE,\
771 .property = "msos-desc",\
772 .value = "no",\
773 },\
774 {\
775 .driver = "PIIX4_PM",\
776 .property = "acpi-pci-hotplug-with-bridge-support",\
777 .value = "off",\
778 },\
779 {\
780 .driver = "hpet",\
781 .property = HPET_INTCAP,\
782 .value = stringify(4),\
783 },
5319dc7b 784
e9845f09 785#define PC_COMPAT_1_6 \
cd6c1b70 786 PC_CPU_MODEL_IDS("1.6.0") \
276a65ba
EH
787 {\
788 .driver = "e1000",\
789 .property = "mitigation",\
790 .value = "off",\
791 },{\
792 .driver = "qemu64-" TYPE_X86_CPU,\
793 .property = "model",\
794 .value = stringify(2),\
795 },{\
796 .driver = "qemu32-" TYPE_X86_CPU,\
797 .property = "model",\
798 .value = stringify(3),\
799 },{\
800 .driver = "i440FX-pcihost",\
801 .property = "short_root_bus",\
802 .value = stringify(1),\
803 },{\
804 .driver = "q35-pcihost",\
805 .property = "short_root_bus",\
806 .value = stringify(1),\
807 },
e9845f09 808
ffce9ebb 809#define PC_COMPAT_1_5 \
cd6c1b70 810 PC_CPU_MODEL_IDS("1.5.0") \
276a65ba
EH
811 {\
812 .driver = "Conroe-" TYPE_X86_CPU,\
813 .property = "model",\
814 .value = stringify(2),\
815 },{\
816 .driver = "Conroe-" TYPE_X86_CPU,\
817 .property = "level",\
818 .value = stringify(2),\
819 },{\
820 .driver = "Penryn-" TYPE_X86_CPU,\
821 .property = "model",\
822 .value = stringify(2),\
823 },{\
824 .driver = "Penryn-" TYPE_X86_CPU,\
825 .property = "level",\
826 .value = stringify(2),\
827 },{\
828 .driver = "Nehalem-" TYPE_X86_CPU,\
829 .property = "model",\
830 .value = stringify(2),\
831 },{\
832 .driver = "Nehalem-" TYPE_X86_CPU,\
833 .property = "level",\
834 .value = stringify(2),\
835 },{\
836 .driver = "virtio-net-pci",\
837 .property = "any_layout",\
838 .value = "off",\
839 },{\
840 .driver = TYPE_X86_CPU,\
841 .property = "pmu",\
842 .value = "on",\
843 },{\
844 .driver = "i440FX-pcihost",\
845 .property = "short_root_bus",\
846 .value = stringify(0),\
847 },{\
848 .driver = "q35-pcihost",\
849 .property = "short_root_bus",\
850 .value = stringify(0),\
851 },
ffce9ebb 852
bf3caa3d 853#define PC_COMPAT_1_4 \
cd6c1b70 854 PC_CPU_MODEL_IDS("1.4.0") \
276a65ba
EH
855 {\
856 .driver = "scsi-hd",\
857 .property = "discard_granularity",\
858 .value = stringify(0),\
859 },{\
860 .driver = "scsi-cd",\
861 .property = "discard_granularity",\
862 .value = stringify(0),\
863 },{\
864 .driver = "scsi-disk",\
865 .property = "discard_granularity",\
866 .value = stringify(0),\
867 },{\
868 .driver = "ide-hd",\
869 .property = "discard_granularity",\
870 .value = stringify(0),\
871 },{\
872 .driver = "ide-cd",\
873 .property = "discard_granularity",\
874 .value = stringify(0),\
875 },{\
876 .driver = "ide-drive",\
877 .property = "discard_granularity",\
878 .value = stringify(0),\
879 },{\
880 .driver = "virtio-blk-pci",\
881 .property = "discard_granularity",\
882 .value = stringify(0),\
883 },{\
884 .driver = "virtio-serial-pci",\
885 .property = "vectors",\
886 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
887 .value = stringify(0xFFFFFFFF),\
888 },{ \
889 .driver = "virtio-net-pci", \
890 .property = "ctrl_guest_offloads", \
891 .value = "off", \
892 },{\
893 .driver = "e1000",\
894 .property = "romfile",\
895 .value = "pxe-e1000.rom",\
896 },{\
897 .driver = "ne2k_pci",\
898 .property = "romfile",\
899 .value = "pxe-ne2k_pci.rom",\
900 },{\
901 .driver = "pcnet",\
902 .property = "romfile",\
903 .value = "pxe-pcnet.rom",\
904 },{\
905 .driver = "rtl8139",\
906 .property = "romfile",\
907 .value = "pxe-rtl8139.rom",\
908 },{\
909 .driver = "virtio-net-pci",\
910 .property = "romfile",\
911 .value = "pxe-virtio.rom",\
912 },{\
913 .driver = "486-" TYPE_X86_CPU,\
914 .property = "model",\
915 .value = stringify(0),\
916 },\
917 {\
918 .driver = "n270" "-" TYPE_X86_CPU,\
919 .property = "movbe",\
920 .value = "off",\
921 },\
922 {\
923 .driver = "Westmere" "-" TYPE_X86_CPU,\
924 .property = "pclmulqdq",\
925 .value = "off",\
926 },
bf3caa3d 927
25519b06 928#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
865906f7
EH
929 static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
930 { \
931 MachineClass *mc = MACHINE_CLASS(oc); \
932 optsfn(mc); \
865906f7
EH
933 mc->init = initfn; \
934 } \
935 static const TypeInfo pc_machine_type_##suffix = { \
936 .name = namestr TYPE_MACHINE_SUFFIX, \
937 .parent = TYPE_PC_MACHINE, \
938 .class_init = pc_machine_##suffix##_class_init, \
939 }; \
61f219df
EH
940 static void pc_machine_init_##suffix(void) \
941 { \
865906f7 942 type_register(&pc_machine_type_##suffix); \
61f219df 943 } \
0e6aac87 944 type_init(pc_machine_init_##suffix)
61f219df 945
bd8107d7 946extern void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id);
87ecb68b 947#endif