]>
Commit | Line | Data |
---|---|---|
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" |
ae0a5466 | 26 | |
83c9f4ca | 27 | #include "hw/hw.h" |
04920fc0 | 28 | #include "hw/loader.h" |
0d09e41a PB |
29 | #include "hw/i386/pc.h" |
30 | #include "hw/i386/apic.h" | |
94692dcd | 31 | #include "hw/display/ramfb.h" |
60d8f328 | 32 | #include "hw/smbios/smbios.h" |
83c9f4ca PB |
33 | #include "hw/pci/pci.h" |
34 | #include "hw/pci/pci_ids.h" | |
35 | #include "hw/usb.h" | |
1422e32d | 36 | #include "net/net.h" |
83c9f4ca PB |
37 | #include "hw/boards.h" |
38 | #include "hw/ide.h" | |
9c17d615 | 39 | #include "sysemu/kvm.h" |
83c9f4ca | 40 | #include "hw/kvm/clock.h" |
9c17d615 | 41 | #include "sysemu/sysemu.h" |
83c9f4ca | 42 | #include "hw/sysbus.h" |
9c17d615 | 43 | #include "sysemu/arch_init.h" |
0d09e41a PB |
44 | #include "hw/i2c/smbus.h" |
45 | #include "hw/xen/xen.h" | |
022c62cb PB |
46 | #include "exec/memory.h" |
47 | #include "exec/address-spaces.h" | |
0445259b | 48 | #include "hw/acpi/acpi.h" |
dc59944b | 49 | #include "cpu.h" |
e688df6b | 50 | #include "qapi/error.h" |
c87b1520 | 51 | #include "qemu/error-report.h" |
29d3ccde | 52 | #ifdef CONFIG_XEN |
998250e9 TC |
53 | #include <xen/hvm/hvm_info_table.h> |
54 | #include "hw/xen/xen_pt.h" | |
29d3ccde | 55 | #endif |
84a899de | 56 | #include "migration/global_state.h" |
c4b63b7c | 57 | #include "migration/misc.h" |
32c18a2d | 58 | #include "kvm_i386.h" |
3bfe5716 | 59 | #include "sysemu/numa.h" |
845773ab IY |
60 | |
61 | #define MAX_IDE_BUS 2 | |
62 | ||
63 | static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; | |
64 | static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; | |
65 | static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; | |
66 | ||
67 | /* PC hardware initialisation */ | |
76d39ab4 TC |
68 | static void pc_init1(MachineState *machine, |
69 | const char *host_type, const char *pci_type) | |
845773ab | 70 | { |
ec68007a | 71 | PCMachineState *pcms = PC_MACHINE(machine); |
7102fa70 | 72 | PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); |
1e099556 EH |
73 | MemoryRegion *system_memory = get_system_memory(); |
74 | MemoryRegion *system_io = get_system_io(); | |
845773ab | 75 | int i; |
845773ab | 76 | PCIBus *pci_bus; |
48a18b3c | 77 | ISABus *isa_bus; |
845773ab IY |
78 | PCII440FXState *i440fx_state; |
79 | int piix3_devfn = -1; | |
845773ab | 80 | qemu_irq *i8259; |
2ba154cf | 81 | qemu_irq smi_irq; |
b881fbe9 | 82 | GSIState *gsi_state; |
845773ab | 83 | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
c0897e0c | 84 | BusState *idebus[MAX_IDE_BUS]; |
1d914fa0 | 85 | ISADevice *rtc_state; |
ae0a5466 AK |
86 | MemoryRegion *ram_memory; |
87 | MemoryRegion *pci_memory; | |
4463aee6 | 88 | MemoryRegion *rom_memory; |
c87b1520 | 89 | ram_addr_t lowmem; |
845773ab | 90 | |
8156d480 GH |
91 | /* |
92 | * Calculate ram split, for memory below and above 4G. It's a bit | |
93 | * complicated for backward compatibility reasons ... | |
94 | * | |
95 | * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the | |
96 | * default value for max_ram_below_4g now. | |
97 | * | |
98 | * - Then, to gigabyte align the memory, we move the split to 3G | |
99 | * (lowmem = 0xc0000000). But only in case we have to split in | |
100 | * the first place, i.e. ram_size is larger than (traditional) | |
101 | * lowmem. And for new machine types (gigabyte_align = true) | |
102 | * only, for live migration compatibility reasons. | |
103 | * | |
104 | * - Next the max-ram-below-4g option was added, which allowed to | |
105 | * reduce lowmem to a smaller value, to allow a larger PCI I/O | |
106 | * window below 4G. qemu doesn't enforce gigabyte alignment here, | |
107 | * but prints a warning. | |
108 | * | |
109 | * - Finally max-ram-below-4g got updated to also allow raising lowmem, | |
110 | * so legacy non-PAE guests can get as much memory as possible in | |
111 | * the 32bit address space below 4G. | |
112 | * | |
5ec7d098 GH |
113 | * - Note that Xen has its own ram setp code in xen_ram_init(), |
114 | * called via xen_hvm_init(). | |
115 | * | |
8156d480 GH |
116 | * Examples: |
117 | * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high | |
118 | * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high | |
119 | * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high | |
120 | * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M) | |
ecdbfceb | 121 | */ |
5ec7d098 GH |
122 | if (xen_enabled()) { |
123 | xen_hvm_init(pcms, &ram_memory); | |
124 | } else { | |
125 | if (!pcms->max_ram_below_4g) { | |
126 | pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ | |
127 | } | |
128 | lowmem = pcms->max_ram_below_4g; | |
129 | if (machine->ram_size >= pcms->max_ram_below_4g) { | |
130 | if (pcmc->gigabyte_align) { | |
131 | if (lowmem > 0xc0000000) { | |
132 | lowmem = 0xc0000000; | |
133 | } | |
134 | if (lowmem & ((1ULL << 30) - 1)) { | |
3dc6f869 AF |
135 | warn_report("Large machine and max_ram_below_4g " |
136 | "(%" PRIu64 ") not a multiple of 1G; " | |
137 | "possible bad performance.", | |
138 | pcms->max_ram_below_4g); | |
5ec7d098 | 139 | } |
8156d480 | 140 | } |
c87b1520 | 141 | } |
c87b1520 | 142 | |
5ec7d098 GH |
143 | if (machine->ram_size >= lowmem) { |
144 | pcms->above_4g_mem_size = machine->ram_size - lowmem; | |
145 | pcms->below_4g_mem_size = lowmem; | |
146 | } else { | |
147 | pcms->above_4g_mem_size = 0; | |
148 | pcms->below_4g_mem_size = machine->ram_size; | |
149 | } | |
3c2a9669 DS |
150 | } |
151 | ||
4884b7bf | 152 | pc_cpus_init(pcms); |
3c2a9669 | 153 | |
7102fa70 | 154 | if (kvm_enabled() && pcmc->kvmclock_enabled) { |
3c2a9669 DS |
155 | kvmclock_create(); |
156 | } | |
157 | ||
7102fa70 | 158 | if (pcmc->pci_enabled) { |
4463aee6 | 159 | pci_memory = g_new(MemoryRegion, 1); |
286690e3 | 160 | memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); |
4463aee6 JK |
161 | rom_memory = pci_memory; |
162 | } else { | |
163 | pci_memory = NULL; | |
164 | rom_memory = system_memory; | |
165 | } | |
ae0a5466 | 166 | |
5db3f0de | 167 | pc_guest_info_init(pcms); |
3459a625 | 168 | |
7102fa70 | 169 | if (pcmc->smbios_defaults) { |
3ef96221 | 170 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
b29ad07e | 171 | /* These values are guest ABI, do not change */ |
e6667f71 | 172 | smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", |
7102fa70 EH |
173 | mc->name, pcmc->smbios_legacy_mode, |
174 | pcmc->smbios_uuid_encoded, | |
86299120 | 175 | SMBIOS_ENTRY_POINT_21); |
b29ad07e MA |
176 | } |
177 | ||
845773ab | 178 | /* allocate ram and load rom/bios */ |
29d3ccde | 179 | if (!xen_enabled()) { |
62b160c0 | 180 | pc_memory_init(pcms, system_memory, |
5934e216 | 181 | rom_memory, &ram_memory); |
b33a5bbf CL |
182 | } else if (machine->kernel_filename != NULL) { |
183 | /* For xen HVM direct kernel boot, load linux here */ | |
7bc35e0f | 184 | xen_load_linux(pcms); |
29d3ccde | 185 | } |
845773ab | 186 | |
b881fbe9 | 187 | gsi_state = g_malloc0(sizeof(*gsi_state)); |
15eafc2e | 188 | if (kvm_ioapic_in_kernel()) { |
7102fa70 | 189 | kvm_pc_setup_irq_routing(pcmc->pci_enabled); |
3e6c0c4c MAL |
190 | pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, |
191 | GSI_NUM_PINS); | |
10b61882 | 192 | } else { |
3e6c0c4c | 193 | pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); |
10b61882 | 194 | } |
845773ab | 195 | |
7102fa70 | 196 | if (pcmc->pci_enabled) { |
76d39ab4 TC |
197 | pci_bus = i440fx_init(host_type, |
198 | pci_type, | |
3e6c0c4c | 199 | &i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi, |
3ef96221 | 200 | system_memory, system_io, machine->ram_size, |
c0aa4e1e EH |
201 | pcms->below_4g_mem_size, |
202 | pcms->above_4g_mem_size, | |
ae0a5466 | 203 | pci_memory, ram_memory); |
81ed6482 | 204 | pcms->bus = pci_bus; |
845773ab IY |
205 | } else { |
206 | pci_bus = NULL; | |
02a89b21 | 207 | i440fx_state = NULL; |
d10e5432 MA |
208 | isa_bus = isa_bus_new(NULL, get_system_memory(), system_io, |
209 | &error_abort); | |
57285cc3 | 210 | no_hpet = 1; |
845773ab | 211 | } |
3e6c0c4c | 212 | isa_bus_irqs(isa_bus, pcms->gsi); |
845773ab | 213 | |
15eafc2e | 214 | if (kvm_pic_in_kernel()) { |
10b61882 JK |
215 | i8259 = kvm_i8259_init(isa_bus); |
216 | } else if (xen_enabled()) { | |
217 | i8259 = xen_interrupt_controller_init(); | |
218 | } else { | |
0b0cc076 | 219 | i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq()); |
4bae1efe RH |
220 | } |
221 | ||
43a0db35 JK |
222 | for (i = 0; i < ISA_NUM_IRQS; i++) { |
223 | gsi_state->i8259_irq[i] = i8259[i]; | |
224 | } | |
2ba154cf | 225 | g_free(i8259); |
7102fa70 | 226 | if (pcmc->pci_enabled) { |
a39e3564 | 227 | ioapic_init_gsi(gsi_state, "i440fx"); |
4bae1efe RH |
228 | } |
229 | ||
3e6c0c4c | 230 | pc_register_ferr_irq(pcms->gsi[13]); |
845773ab | 231 | |
7102fa70 | 232 | pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); |
01195b73 | 233 | |
7fb1cf16 | 234 | assert(pcms->vmport != ON_OFF_AUTO__MAX); |
ec68007a EH |
235 | if (pcms->vmport == ON_OFF_AUTO_AUTO) { |
236 | pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; | |
d1048bef DS |
237 | } |
238 | ||
845773ab | 239 | /* init basic PC hardware */ |
3e6c0c4c | 240 | pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true, |
feddd2fd | 241 | (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4); |
845773ab | 242 | |
4b9c264b | 243 | pc_nic_init(pcmc, isa_bus, pci_bus); |
845773ab | 244 | |
d8f94e1b | 245 | ide_drive_get(hd, ARRAY_SIZE(hd)); |
7102fa70 | 246 | if (pcmc->pci_enabled) { |
c0897e0c | 247 | PCIDevice *dev; |
679f4f8b SS |
248 | if (xen_enabled()) { |
249 | dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); | |
250 | } else { | |
251 | dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); | |
252 | } | |
c0897e0c MA |
253 | idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); |
254 | idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); | |
845773ab IY |
255 | } else { |
256 | for(i = 0; i < MAX_IDE_BUS; i++) { | |
c0897e0c | 257 | ISADevice *dev; |
61de3676 | 258 | char busname[] = "ide.0"; |
48a18b3c HP |
259 | dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], |
260 | ide_irq[i], | |
c0897e0c | 261 | hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); |
61de3676 AG |
262 | /* |
263 | * The ide bus name is ide.0 for the first bus and ide.1 for the | |
264 | * second one. | |
265 | */ | |
266 | busname[4] = '0' + i; | |
267 | idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); | |
845773ab IY |
268 | } |
269 | } | |
270 | ||
88076854 | 271 | pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); |
845773ab | 272 | |
4bcbe0b6 | 273 | if (pcmc->pci_enabled && machine_usb(machine)) { |
afb9a60e | 274 | pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); |
845773ab IY |
275 | } |
276 | ||
7102fa70 | 277 | if (pcmc->pci_enabled && acpi_enabled) { |
781bbd6b | 278 | DeviceState *piix4_pm; |
a5c82852 | 279 | I2CBus *smbus; |
845773ab | 280 | |
2ba154cf | 281 | smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); |
845773ab IY |
282 | /* TODO: Populate SPD eeprom data. */ |
283 | smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, | |
3e6c0c4c | 284 | pcms->gsi[9], smi_irq, |
ec68007a | 285 | pc_machine_is_smm_enabled(pcms), |
355023f2 | 286 | &piix4_pm); |
a88df0b9 | 287 | smbus_eeprom_init(smbus, 8, NULL, 0); |
781bbd6b IM |
288 | |
289 | object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, | |
290 | TYPE_HOTPLUG_HANDLER, | |
ec68007a | 291 | (Object **)&pcms->acpi_dev, |
781bbd6b | 292 | object_property_allow_set_link, |
265b578c | 293 | OBJ_PROP_LINK_STRONG, &error_abort); |
781bbd6b IM |
294 | object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), |
295 | PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); | |
845773ab IY |
296 | } |
297 | ||
5fe79386 XG |
298 | if (pcms->acpi_nvdimm_state.is_enabled) { |
299 | nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, | |
300 | pcms->fw_cfg, OBJECT(pcms)); | |
301 | } | |
845773ab IY |
302 | } |
303 | ||
79859507 EH |
304 | /* Looking for a pc_compat_2_4() function? It doesn't exist. |
305 | * pc_compat_*() functions that run on machine-init time and | |
306 | * change global QEMU state are deprecated. Please don't create | |
307 | * one, and implement any pc-*-2.4 (and newer) compat code in | |
308 | * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options(). | |
309 | */ | |
310 | ||
5cb50e0a JW |
311 | static void pc_compat_2_3(MachineState *machine) |
312 | { | |
355023f2 | 313 | PCMachineState *pcms = PC_MACHINE(machine); |
355023f2 PB |
314 | if (kvm_enabled()) { |
315 | pcms->smm = ON_OFF_AUTO_OFF; | |
316 | } | |
5cb50e0a JW |
317 | } |
318 | ||
64bbd372 PB |
319 | static void pc_compat_2_2(MachineState *machine) |
320 | { | |
5cb50e0a | 321 | pc_compat_2_3(machine); |
54ed388b | 322 | machine->suppress_vmdesc = true; |
64bbd372 PB |
323 | } |
324 | ||
2cad57c7 EH |
325 | static void pc_compat_2_1(MachineState *machine) |
326 | { | |
64bbd372 | 327 | pc_compat_2_2(machine); |
5114e842 | 328 | x86_cpu_change_kvm_default("svm", NULL); |
2cad57c7 EH |
329 | } |
330 | ||
3ef96221 | 331 | static void pc_compat_2_0(MachineState *machine) |
3458b2b0 | 332 | { |
2cad57c7 | 333 | pc_compat_2_1(machine); |
3458b2b0 MT |
334 | } |
335 | ||
3ef96221 | 336 | static void pc_compat_1_7(MachineState *machine) |
b29ad07e | 337 | { |
3ef96221 | 338 | pc_compat_2_0(machine); |
5114e842 | 339 | x86_cpu_change_kvm_default("x2apic", NULL); |
b29ad07e MA |
340 | } |
341 | ||
3ef96221 | 342 | static void pc_compat_1_6(MachineState *machine) |
f8c457b8 | 343 | { |
3ef96221 | 344 | pc_compat_1_7(machine); |
f8c457b8 MT |
345 | } |
346 | ||
3ef96221 | 347 | static void pc_compat_1_5(MachineState *machine) |
9604f70f | 348 | { |
3ef96221 | 349 | pc_compat_1_6(machine); |
9604f70f MT |
350 | } |
351 | ||
3ef96221 | 352 | static void pc_compat_1_4(MachineState *machine) |
9953f882 | 353 | { |
3ef96221 | 354 | pc_compat_1_5(machine); |
9953f882 MA |
355 | } |
356 | ||
3ef96221 | 357 | static void pc_compat_1_3(MachineState *machine) |
8932cfdf | 358 | { |
3ef96221 | 359 | pc_compat_1_4(machine); |
8932cfdf | 360 | enable_compat_apic_id_mode(); |
89b439f3 EH |
361 | } |
362 | ||
363 | /* PC compat function for pc-0.14 to pc-1.2 */ | |
3ef96221 | 364 | static 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 | ||
72d164aa EH |
370 | /* PC compat function for pc-0.10 to pc-0.13 */ |
371 | static void pc_compat_0_13(MachineState *machine) | |
372 | { | |
373 | pc_compat_1_2(machine); | |
72d164aa EH |
374 | } |
375 | ||
3ef96221 | 376 | static void pc_init_isa(MachineState *machine) |
845773ab | 377 | { |
76d39ab4 | 378 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); |
845773ab IY |
379 | } |
380 | ||
29d3ccde | 381 | #ifdef CONFIG_XEN |
998250e9 TC |
382 | static void pc_xen_hvm_init_pci(MachineState *machine) |
383 | { | |
384 | const char *pci_type = has_igd_gfx_passthru ? | |
385 | TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE; | |
386 | ||
387 | pc_init1(machine, | |
388 | TYPE_I440FX_PCI_HOST_BRIDGE, | |
389 | pci_type); | |
390 | } | |
391 | ||
3ef96221 | 392 | static void pc_xen_hvm_init(MachineState *machine) |
29d3ccde | 393 | { |
e492dc5a | 394 | PCMachineState *pcms = PC_MACHINE(machine); |
39ae4972 | 395 | |
a88ae0d4 EH |
396 | if (!xen_enabled()) { |
397 | error_report("xenfv machine requires the xen accelerator"); | |
398 | exit(1); | |
399 | } | |
400 | ||
998250e9 | 401 | pc_xen_hvm_init_pci(machine); |
e492dc5a | 402 | pci_create_simple(pcms->bus, -1, "xen-platform"); |
29d3ccde AP |
403 | } |
404 | #endif | |
405 | ||
99fbeafe EH |
406 | #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ |
407 | static void pc_init_##suffix(MachineState *machine) \ | |
408 | { \ | |
409 | void (*compat)(MachineState *m) = (compatfn); \ | |
410 | if (compat) { \ | |
411 | compat(machine); \ | |
412 | } \ | |
76d39ab4 TC |
413 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \ |
414 | TYPE_I440FX_PCI_DEVICE); \ | |
99fbeafe EH |
415 | } \ |
416 | DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) | |
fddd179a | 417 | |
865906f7 | 418 | static void pc_i440fx_machine_options(MachineClass *m) |
fddd179a | 419 | { |
4b9c264b PB |
420 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
421 | pcmc->default_nic_model = "e1000"; | |
422 | ||
fddd179a EH |
423 | m->family = "pc_piix"; |
424 | m->desc = "Standard PC (i440FX + PIIX, 1996)"; | |
254bdb1c EH |
425 | m->default_machine_opts = "firmware=bios-256k.bin"; |
426 | m->default_display = "std"; | |
94692dcd | 427 | machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); |
fddd179a EH |
428 | } |
429 | ||
aa78a16d | 430 | static void pc_i440fx_3_0_machine_options(MachineClass *m) |
fddd179a EH |
431 | { |
432 | pc_i440fx_machine_options(m); | |
fddd179a EH |
433 | m->alias = "pc"; |
434 | m->is_default = 1; | |
435 | } | |
aeca6e8d | 436 | |
aa78a16d PM |
437 | DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, |
438 | pc_i440fx_3_0_machine_options); | |
968ee4ad BM |
439 | |
440 | static void pc_i440fx_2_12_machine_options(MachineClass *m) | |
441 | { | |
aa78a16d | 442 | pc_i440fx_3_0_machine_options(m); |
968ee4ad BM |
443 | m->is_default = 0; |
444 | m->alias = NULL; | |
445 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); | |
446 | } | |
447 | ||
df47ce8a HZ |
448 | DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL, |
449 | pc_i440fx_2_12_machine_options); | |
450 | ||
451 | static void pc_i440fx_2_11_machine_options(MachineClass *m) | |
452 | { | |
453 | pc_i440fx_2_12_machine_options(m); | |
df47ce8a HZ |
454 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_11); |
455 | } | |
456 | ||
a6fd5b0e MA |
457 | DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, |
458 | pc_i440fx_2_11_machine_options); | |
459 | ||
460 | static void pc_i440fx_2_10_machine_options(MachineClass *m) | |
461 | { | |
462 | pc_i440fx_2_11_machine_options(m); | |
a6fd5b0e | 463 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_10); |
7b8be49d | 464 | m->auto_enable_numa_with_memhp = false; |
a6fd5b0e MA |
465 | } |
466 | ||
465238d9 PX |
467 | DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, |
468 | pc_i440fx_2_10_machine_options); | |
469 | ||
470 | static void pc_i440fx_2_9_machine_options(MachineClass *m) | |
471 | { | |
472 | pc_i440fx_2_10_machine_options(m); | |
465238d9 | 473 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); |
3da2bd8c | 474 | m->numa_auto_assign_ram = numa_legacy_auto_assign_ram; |
465238d9 PX |
475 | } |
476 | ||
d580bd4b EH |
477 | DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, |
478 | pc_i440fx_2_9_machine_options); | |
479 | ||
480 | static void pc_i440fx_2_8_machine_options(MachineClass *m) | |
481 | { | |
482 | pc_i440fx_2_9_machine_options(m); | |
d580bd4b EH |
483 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); |
484 | } | |
485 | ||
a4d3c834 LM |
486 | DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL, |
487 | pc_i440fx_2_8_machine_options); | |
488 | ||
489 | ||
490 | static void pc_i440fx_2_7_machine_options(MachineClass *m) | |
491 | { | |
492 | pc_i440fx_2_8_machine_options(m); | |
a4d3c834 LM |
493 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_7); |
494 | } | |
495 | ||
d86c1451 IM |
496 | DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL, |
497 | pc_i440fx_2_7_machine_options); | |
498 | ||
499 | ||
500 | static void pc_i440fx_2_6_machine_options(MachineClass *m) | |
501 | { | |
679dd1a9 | 502 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
d86c1451 | 503 | pc_i440fx_2_7_machine_options(m); |
679dd1a9 | 504 | pcmc->legacy_cpu_hotplug = true; |
98e753a6 | 505 | pcmc->linuxboot_dma_enabled = false; |
d86c1451 IM |
506 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); |
507 | } | |
508 | ||
240240d5 EH |
509 | DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, |
510 | pc_i440fx_2_6_machine_options); | |
511 | ||
512 | ||
513 | static void pc_i440fx_2_5_machine_options(MachineClass *m) | |
514 | { | |
36f96c4b | 515 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
240240d5 | 516 | pc_i440fx_2_6_machine_options(m); |
36f96c4b | 517 | pcmc->save_tsc_khz = false; |
bab47d9a | 518 | m->legacy_fw_cfg_order = 1; |
240240d5 EH |
519 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_5); |
520 | } | |
521 | ||
87e896ab EH |
522 | DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, |
523 | pc_i440fx_2_5_machine_options); | |
524 | ||
525 | ||
526 | static void pc_i440fx_2_4_machine_options(MachineClass *m) | |
527 | { | |
528 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | |
529 | pc_i440fx_2_5_machine_options(m); | |
de796d93 | 530 | m->hw_version = "2.4.0"; |
87e896ab EH |
531 | pcmc->broken_reserved_end = true; |
532 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); | |
533 | } | |
534 | ||
99fbeafe EH |
535 | DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, |
536 | pc_i440fx_2_4_machine_options) | |
5cb50e0a | 537 | |
f9f21873 | 538 | |
865906f7 | 539 | static void pc_i440fx_2_3_machine_options(MachineClass *m) |
fddd179a | 540 | { |
4421c6a3 | 541 | pc_i440fx_2_4_machine_options(m); |
de796d93 | 542 | m->hw_version = "2.3.0"; |
25519b06 | 543 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); |
fddd179a | 544 | } |
5cb50e0a | 545 | |
99fbeafe EH |
546 | DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, |
547 | pc_i440fx_2_3_machine_options); | |
61f219df | 548 | |
5cb50e0a | 549 | |
865906f7 | 550 | static void pc_i440fx_2_2_machine_options(MachineClass *m) |
fddd179a | 551 | { |
7102fa70 | 552 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 553 | pc_i440fx_2_3_machine_options(m); |
de796d93 | 554 | m->hw_version = "2.2.0"; |
25519b06 | 555 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); |
7102fa70 | 556 | pcmc->rsdp_in_ram = false; |
fddd179a | 557 | } |
64bbd372 | 558 | |
99fbeafe EH |
559 | DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, |
560 | pc_i440fx_2_2_machine_options); | |
61f219df | 561 | |
64bbd372 | 562 | |
865906f7 | 563 | static void pc_i440fx_2_1_machine_options(MachineClass *m) |
fddd179a | 564 | { |
7102fa70 | 565 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 566 | pc_i440fx_2_2_machine_options(m); |
de796d93 | 567 | m->hw_version = "2.1.0"; |
fddd179a | 568 | m->default_display = NULL; |
25519b06 | 569 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); |
7102fa70 | 570 | pcmc->smbios_uuid_encoded = false; |
16a9e8a5 | 571 | pcmc->enforce_aligned_dimm = false; |
fddd179a | 572 | } |
f9f21873 | 573 | |
99fbeafe EH |
574 | DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, |
575 | pc_i440fx_2_1_machine_options); | |
61f219df | 576 | |
aeca6e8d | 577 | |
fddd179a | 578 | |
865906f7 | 579 | static void pc_i440fx_2_0_machine_options(MachineClass *m) |
fddd179a | 580 | { |
7102fa70 | 581 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 582 | pc_i440fx_2_1_machine_options(m); |
de796d93 | 583 | m->hw_version = "2.0.0"; |
25519b06 | 584 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); |
7102fa70 EH |
585 | pcmc->smbios_legacy_mode = true; |
586 | pcmc->has_reserved_memory = false; | |
2b0ddf66 EH |
587 | /* This value depends on the actual DSDT and SSDT compiled into |
588 | * the source QEMU; unfortunately it depends on the binary and | |
589 | * not on the machine type, so we cannot make pc-i440fx-1.7 work on | |
590 | * both QEMU 1.7 and QEMU 2.0. | |
591 | * | |
592 | * Large variations cause migration to fail for more than one | |
593 | * consecutive value of the "-smp" maxcpus option. | |
594 | * | |
595 | * For small variations of the kind caused by different iasl versions, | |
596 | * the 4k rounding usually leaves slack. However, there could be still | |
597 | * one or two values that break. For QEMU 1.7 and QEMU 2.0 the | |
598 | * slack is only ~10 bytes before one "-smp maxcpus" value breaks! | |
599 | * | |
600 | * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on | |
601 | * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. | |
602 | */ | |
603 | pcmc->legacy_acpi_table_size = 6652; | |
cd4040ec | 604 | pcmc->acpi_data_size = 0x10000; |
fddd179a | 605 | } |
3458b2b0 | 606 | |
99fbeafe EH |
607 | DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, |
608 | pc_i440fx_2_0_machine_options); | |
61f219df | 609 | |
3458b2b0 | 610 | |
865906f7 | 611 | static void pc_i440fx_1_7_machine_options(MachineClass *m) |
fddd179a | 612 | { |
7102fa70 | 613 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 614 | pc_i440fx_2_0_machine_options(m); |
de796d93 | 615 | m->hw_version = "1.7.0"; |
fddd179a | 616 | m->default_machine_opts = NULL; |
71ae9e94 | 617 | m->option_rom_has_mr = true; |
25519b06 | 618 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); |
7102fa70 EH |
619 | pcmc->smbios_defaults = false; |
620 | pcmc->gigabyte_align = false; | |
2b0ddf66 | 621 | pcmc->legacy_acpi_table_size = 6414; |
fddd179a | 622 | } |
aeca6e8d | 623 | |
99fbeafe EH |
624 | DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, |
625 | pc_i440fx_1_7_machine_options); | |
61f219df | 626 | |
e9845f09 | 627 | |
865906f7 | 628 | static void pc_i440fx_1_6_machine_options(MachineClass *m) |
fddd179a | 629 | { |
7102fa70 | 630 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 631 | pc_i440fx_1_7_machine_options(m); |
de796d93 | 632 | m->hw_version = "1.6.0"; |
71ae9e94 | 633 | m->rom_file_has_mr = false; |
25519b06 | 634 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); |
7102fa70 | 635 | pcmc->has_acpi_build = false; |
fddd179a | 636 | } |
a0dba644 | 637 | |
99fbeafe EH |
638 | DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, |
639 | pc_i440fx_1_6_machine_options); | |
61f219df | 640 | |
845773ab | 641 | |
865906f7 | 642 | static void pc_i440fx_1_5_machine_options(MachineClass *m) |
fddd179a EH |
643 | { |
644 | pc_i440fx_1_6_machine_options(m); | |
de796d93 | 645 | m->hw_version = "1.5.0"; |
25519b06 | 646 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); |
fddd179a | 647 | } |
b6b5c8e4 | 648 | |
99fbeafe EH |
649 | DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, |
650 | pc_i440fx_1_5_machine_options); | |
61f219df | 651 | |
45053fde | 652 | |
865906f7 | 653 | static void pc_i440fx_1_4_machine_options(MachineClass *m) |
fddd179a EH |
654 | { |
655 | pc_i440fx_1_5_machine_options(m); | |
de796d93 | 656 | m->hw_version = "1.4.0"; |
fddd179a | 657 | m->hot_add_cpu = NULL; |
25519b06 | 658 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); |
fddd179a | 659 | } |
a0dba644 | 660 | |
99fbeafe EH |
661 | DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, |
662 | pc_i440fx_1_4_machine_options); | |
61f219df | 663 | |
bf3caa3d | 664 | |
427e3aa1 | 665 | #define PC_COMPAT_1_3 \ |
cd6c1b70 | 666 | PC_CPU_MODEL_IDS("1.3.0") \ |
427e3aa1 HG |
667 | {\ |
668 | .driver = "usb-tablet",\ | |
669 | .property = "usb_version",\ | |
670 | .value = stringify(1),\ | |
c1943a3f AK |
671 | },{\ |
672 | .driver = "virtio-net-pci",\ | |
673 | .property = "ctrl_mac_addr",\ | |
674 | .value = "off", \ | |
a9c87c58 JW |
675 | },{ \ |
676 | .driver = "virtio-net-pci", \ | |
677 | .property = "mq", \ | |
678 | .value = "off", \ | |
2af234e6 MT |
679 | }, {\ |
680 | .driver = "e1000",\ | |
681 | .property = "autonegotiation",\ | |
682 | .value = "off",\ | |
a7cde24d | 683 | }, |
427e3aa1 | 684 | |
fddd179a | 685 | |
865906f7 | 686 | static void pc_i440fx_1_3_machine_options(MachineClass *m) |
fddd179a EH |
687 | { |
688 | pc_i440fx_1_4_machine_options(m); | |
de796d93 | 689 | m->hw_version = "1.3.0"; |
25519b06 | 690 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); |
fddd179a | 691 | } |
b6b5c8e4 | 692 | |
99fbeafe EH |
693 | DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, |
694 | pc_i440fx_1_3_machine_options); | |
61f219df | 695 | |
f1ae2e38 | 696 | |
183c5eaa | 697 | #define PC_COMPAT_1_2 \ |
cd6c1b70 | 698 | PC_CPU_MODEL_IDS("1.2.0") \ |
183c5eaa GH |
699 | {\ |
700 | .driver = "nec-usb-xhci",\ | |
701 | .property = "msi",\ | |
702 | .value = "off",\ | |
703 | },{\ | |
704 | .driver = "nec-usb-xhci",\ | |
705 | .property = "msix",\ | |
706 | .value = "off",\ | |
c08ba66f GH |
707 | },{\ |
708 | .driver = "ivshmem",\ | |
709 | .property = "use64",\ | |
710 | .value = "0",\ | |
591af143 GH |
711 | },{\ |
712 | .driver = "qxl",\ | |
713 | .property = "revision",\ | |
714 | .value = stringify(3),\ | |
715 | },{\ | |
716 | .driver = "qxl-vga",\ | |
717 | .property = "revision",\ | |
718 | .value = stringify(3),\ | |
803ff052 GH |
719 | },{\ |
720 | .driver = "VGA",\ | |
721 | .property = "mmio",\ | |
722 | .value = "off",\ | |
a7cde24d | 723 | }, |
183c5eaa | 724 | |
865906f7 | 725 | static void pc_i440fx_1_2_machine_options(MachineClass *m) |
fddd179a EH |
726 | { |
727 | pc_i440fx_1_3_machine_options(m); | |
de796d93 | 728 | m->hw_version = "1.2.0"; |
25519b06 | 729 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); |
fddd179a | 730 | } |
a0dba644 | 731 | |
99fbeafe EH |
732 | DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, |
733 | pc_i440fx_1_2_machine_options); | |
61f219df | 734 | |
f4306941 | 735 | |
9e56edcf | 736 | #define PC_COMPAT_1_1 \ |
cd6c1b70 | 737 | PC_CPU_MODEL_IDS("1.1.0") \ |
9e56edcf | 738 | {\ |
07a5298c PB |
739 | .driver = "virtio-scsi-pci",\ |
740 | .property = "hotplug",\ | |
741 | .value = "off",\ | |
742 | },{\ | |
743 | .driver = "virtio-scsi-pci",\ | |
744 | .property = "param_change",\ | |
745 | .value = "off",\ | |
746 | },{\ | |
9e56edcf GH |
747 | .driver = "VGA",\ |
748 | .property = "vgamem_mb",\ | |
749 | .value = stringify(8),\ | |
750 | },{\ | |
751 | .driver = "vmware-svga",\ | |
752 | .property = "vgamem_mb",\ | |
753 | .value = stringify(8),\ | |
754 | },{\ | |
755 | .driver = "qxl-vga",\ | |
756 | .property = "vgamem_mb",\ | |
757 | .value = stringify(8),\ | |
758 | },{\ | |
759 | .driver = "qxl",\ | |
760 | .property = "vgamem_mb",\ | |
761 | .value = stringify(8),\ | |
ea776abc SH |
762 | },{\ |
763 | .driver = "virtio-blk-pci",\ | |
764 | .property = "config-wce",\ | |
765 | .value = "off",\ | |
a7cde24d | 766 | }, |
9e56edcf | 767 | |
865906f7 | 768 | static void pc_i440fx_1_1_machine_options(MachineClass *m) |
fddd179a EH |
769 | { |
770 | pc_i440fx_1_2_machine_options(m); | |
de796d93 | 771 | m->hw_version = "1.1.0"; |
25519b06 | 772 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); |
fddd179a | 773 | } |
b6b5c8e4 | 774 | |
99fbeafe EH |
775 | DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, |
776 | pc_i440fx_1_1_machine_options); | |
61f219df | 777 | |
f1dacf1c | 778 | |
d6c73008 | 779 | #define PC_COMPAT_1_0 \ |
cd6c1b70 | 780 | PC_CPU_MODEL_IDS("1.0") \ |
d6c73008 | 781 | {\ |
020c8e76 | 782 | .driver = TYPE_ISA_FDC,\ |
d6c73008 MT |
783 | .property = "check_media_rate",\ |
784 | .value = "off",\ | |
2ba1d381 DG |
785 | }, {\ |
786 | .driver = "virtio-balloon-pci",\ | |
787 | .property = "class",\ | |
788 | .value = stringify(PCI_CLASS_MEMORY_RAM),\ | |
fc34e77b | 789 | },{\ |
df1fd4b5 | 790 | .driver = "apic-common",\ |
fc34e77b AL |
791 | .property = "vapic",\ |
792 | .value = "off",\ | |
eeb0cf9a | 793 | },{\ |
bce54474 | 794 | .driver = TYPE_USB_DEVICE,\ |
eeb0cf9a GH |
795 | .property = "full-path",\ |
796 | .value = "no",\ | |
a7cde24d | 797 | }, |
d6c73008 | 798 | |
865906f7 | 799 | static void pc_i440fx_1_0_machine_options(MachineClass *m) |
fddd179a EH |
800 | { |
801 | pc_i440fx_1_1_machine_options(m); | |
802 | m->hw_version = "1.0"; | |
25519b06 | 803 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); |
fddd179a | 804 | } |
b6b5c8e4 | 805 | |
99fbeafe EH |
806 | DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, |
807 | pc_i440fx_1_0_machine_options); | |
61f219df | 808 | |
382b3a68 | 809 | |
cd6c1b70 EH |
810 | #define PC_COMPAT_0_15 \ |
811 | PC_CPU_MODEL_IDS("0.15") | |
812 | ||
865906f7 | 813 | static void pc_i440fx_0_15_machine_options(MachineClass *m) |
fddd179a EH |
814 | { |
815 | pc_i440fx_1_0_machine_options(m); | |
816 | m->hw_version = "0.15"; | |
cd6c1b70 | 817 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); |
fddd179a | 818 | } |
b6b5c8e4 | 819 | |
99fbeafe EH |
820 | DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, |
821 | pc_i440fx_0_15_machine_options); | |
61f219df | 822 | |
ce01a508 | 823 | |
d6c73008 | 824 | #define PC_COMPAT_0_14 \ |
cd6c1b70 | 825 | PC_CPU_MODEL_IDS("0.14") \ |
d6c73008 MT |
826 | {\ |
827 | .driver = "virtio-blk-pci",\ | |
828 | .property = "event_idx",\ | |
829 | .value = "off",\ | |
830 | },{\ | |
831 | .driver = "virtio-serial-pci",\ | |
832 | .property = "event_idx",\ | |
833 | .value = "off",\ | |
834 | },{\ | |
835 | .driver = "virtio-net-pci",\ | |
836 | .property = "event_idx",\ | |
837 | .value = "off",\ | |
838 | },{\ | |
839 | .driver = "virtio-balloon-pci",\ | |
840 | .property = "event_idx",\ | |
841 | .value = "off",\ | |
bb08d882 EH |
842 | },{\ |
843 | .driver = "qxl",\ | |
844 | .property = "revision",\ | |
845 | .value = stringify(2),\ | |
846 | },{\ | |
847 | .driver = "qxl-vga",\ | |
848 | .property = "revision",\ | |
849 | .value = stringify(2),\ | |
a7cde24d | 850 | }, |
d6c73008 | 851 | |
865906f7 | 852 | static void pc_i440fx_0_14_machine_options(MachineClass *m) |
fddd179a EH |
853 | { |
854 | pc_i440fx_0_15_machine_options(m); | |
855 | m->hw_version = "0.14"; | |
25519b06 | 856 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); |
fddd179a | 857 | } |
b6b5c8e4 | 858 | |
99fbeafe EH |
859 | DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, |
860 | pc_i440fx_0_14_machine_options); | |
61f219df | 861 | |
19857e62 | 862 | |
d6c73008 | 863 | #define PC_COMPAT_0_13 \ |
cd6c1b70 | 864 | PC_CPU_MODEL_IDS("0.13") \ |
d6c73008 | 865 | {\ |
bce54474 | 866 | .driver = TYPE_PCI_DEVICE,\ |
d6c73008 MT |
867 | .property = "command_serr_enable",\ |
868 | .value = "off",\ | |
869 | },{\ | |
870 | .driver = "AC97",\ | |
871 | .property = "use_broken_id",\ | |
872 | .value = stringify(1),\ | |
d765519b EH |
873 | },{\ |
874 | .driver = "virtio-9p-pci",\ | |
875 | .property = "vectors",\ | |
876 | .value = stringify(0),\ | |
faf7e425 EH |
877 | },{\ |
878 | .driver = "VGA",\ | |
879 | .property = "rombar",\ | |
880 | .value = stringify(0),\ | |
881 | },{\ | |
882 | .driver = "vmware-svga",\ | |
883 | .property = "rombar",\ | |
884 | .value = stringify(0),\ | |
a7cde24d | 885 | }, |
d6c73008 | 886 | |
865906f7 | 887 | static void pc_i440fx_0_13_machine_options(MachineClass *m) |
fddd179a | 888 | { |
7102fa70 | 889 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
890 | pc_i440fx_0_14_machine_options(m); |
891 | m->hw_version = "0.13"; | |
25519b06 | 892 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); |
7102fa70 | 893 | pcmc->kvmclock_enabled = false; |
fddd179a | 894 | } |
a0dba644 | 895 | |
99fbeafe EH |
896 | DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, |
897 | pc_i440fx_0_13_machine_options); | |
61f219df | 898 | |
b903a0f7 | 899 | |
d6c73008 | 900 | #define PC_COMPAT_0_12 \ |
cd6c1b70 | 901 | PC_CPU_MODEL_IDS("0.12") \ |
d6c73008 MT |
902 | {\ |
903 | .driver = "virtio-serial-pci",\ | |
904 | .property = "max_ports",\ | |
905 | .value = stringify(1),\ | |
906 | },{\ | |
907 | .driver = "virtio-serial-pci",\ | |
908 | .property = "vectors",\ | |
909 | .value = stringify(0),\ | |
93c8e4dc GH |
910 | },{\ |
911 | .driver = "usb-mouse",\ | |
912 | .property = "serial",\ | |
913 | .value = "1",\ | |
914 | },{\ | |
915 | .driver = "usb-tablet",\ | |
916 | .property = "serial",\ | |
917 | .value = "1",\ | |
918 | },{\ | |
919 | .driver = "usb-kbd",\ | |
920 | .property = "serial",\ | |
921 | .value = "1",\ | |
a7cde24d | 922 | }, |
d6c73008 | 923 | |
865906f7 | 924 | static void pc_i440fx_0_12_machine_options(MachineClass *m) |
fddd179a EH |
925 | { |
926 | pc_i440fx_0_13_machine_options(m); | |
927 | m->hw_version = "0.12"; | |
25519b06 | 928 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); |
fddd179a | 929 | } |
b6b5c8e4 | 930 | |
99fbeafe EH |
931 | DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, |
932 | pc_i440fx_0_12_machine_options); | |
61f219df | 933 | |
845773ab | 934 | |
d6c73008 | 935 | #define PC_COMPAT_0_11 \ |
cd6c1b70 | 936 | PC_CPU_MODEL_IDS("0.11") \ |
d6c73008 MT |
937 | {\ |
938 | .driver = "virtio-blk-pci",\ | |
939 | .property = "vectors",\ | |
940 | .value = stringify(0),\ | |
c115cd65 | 941 | },{\ |
bce54474 | 942 | .driver = TYPE_PCI_DEVICE,\ |
c115cd65 PB |
943 | .property = "rombar",\ |
944 | .value = stringify(0),\ | |
d5303df7 EH |
945 | },{\ |
946 | .driver = "ide-drive",\ | |
947 | .property = "ver",\ | |
948 | .value = "0.11",\ | |
949 | },{\ | |
950 | .driver = "scsi-disk",\ | |
951 | .property = "ver",\ | |
952 | .value = "0.11",\ | |
a7cde24d | 953 | }, |
d6c73008 | 954 | |
865906f7 | 955 | static void pc_i440fx_0_11_machine_options(MachineClass *m) |
fddd179a EH |
956 | { |
957 | pc_i440fx_0_12_machine_options(m); | |
958 | m->hw_version = "0.11"; | |
08fe6824 | 959 | m->deprecation_reason = "use a newer machine type instead"; |
25519b06 | 960 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); |
fddd179a | 961 | } |
b6b5c8e4 | 962 | |
99fbeafe EH |
963 | DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, |
964 | pc_i440fx_0_11_machine_options); | |
61f219df | 965 | |
845773ab | 966 | |
f6d5a0ba | 967 | #define PC_COMPAT_0_10 \ |
cd6c1b70 | 968 | PC_CPU_MODEL_IDS("0.10") \ |
f6d5a0ba EH |
969 | {\ |
970 | .driver = "virtio-blk-pci",\ | |
971 | .property = "class",\ | |
972 | .value = stringify(PCI_CLASS_STORAGE_OTHER),\ | |
973 | },{\ | |
974 | .driver = "virtio-serial-pci",\ | |
975 | .property = "class",\ | |
976 | .value = stringify(PCI_CLASS_DISPLAY_OTHER),\ | |
977 | },{\ | |
978 | .driver = "virtio-net-pci",\ | |
979 | .property = "vectors",\ | |
980 | .value = stringify(0),\ | |
981 | },{\ | |
982 | .driver = "ide-drive",\ | |
983 | .property = "ver",\ | |
984 | .value = "0.10",\ | |
985 | },{\ | |
986 | .driver = "scsi-disk",\ | |
987 | .property = "ver",\ | |
988 | .value = "0.10",\ | |
989 | }, | |
990 | ||
865906f7 | 991 | static void pc_i440fx_0_10_machine_options(MachineClass *m) |
fddd179a EH |
992 | { |
993 | pc_i440fx_0_11_machine_options(m); | |
994 | m->hw_version = "0.10"; | |
25519b06 | 995 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); |
fddd179a | 996 | } |
b6b5c8e4 | 997 | |
99fbeafe EH |
998 | DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, |
999 | pc_i440fx_0_10_machine_options); | |
61f219df | 1000 | |
bd8107d7 TC |
1001 | typedef struct { |
1002 | uint16_t gpu_device_id; | |
1003 | uint16_t pch_device_id; | |
1004 | uint8_t pch_revision_id; | |
1005 | } IGDDeviceIDInfo; | |
1006 | ||
1007 | /* In real world different GPU should have different PCH. But actually | |
1008 | * the different PCH DIDs likely map to different PCH SKUs. We do the | |
1009 | * same thing for the GPU. For PCH, the different SKUs are going to be | |
1010 | * all the same silicon design and implementation, just different | |
1011 | * features turn on and off with fuses. The SW interfaces should be | |
1012 | * consistent across all SKUs in a given family (eg LPT). But just same | |
1013 | * features may not be supported. | |
1014 | * | |
1015 | * Most of these different PCH features probably don't matter to the | |
1016 | * Gfx driver, but obviously any difference in display port connections | |
1017 | * will so it should be fine with any PCH in case of passthrough. | |
1018 | * | |
1019 | * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell) | |
1020 | * scenarios, 0x9cc3 for BDW(Broadwell). | |
1021 | */ | |
1022 | static const IGDDeviceIDInfo igd_combo_id_infos[] = { | |
1023 | /* HSW Classic */ | |
1024 | {0x0402, 0x8c4e, 0x04}, /* HSWGT1D, HSWD_w7 */ | |
1025 | {0x0406, 0x8c4e, 0x04}, /* HSWGT1M, HSWM_w7 */ | |
1026 | {0x0412, 0x8c4e, 0x04}, /* HSWGT2D, HSWD_w7 */ | |
1027 | {0x0416, 0x8c4e, 0x04}, /* HSWGT2M, HSWM_w7 */ | |
1028 | {0x041E, 0x8c4e, 0x04}, /* HSWGT15D, HSWD_w7 */ | |
1029 | /* HSW ULT */ | |
1030 | {0x0A06, 0x8c4e, 0x04}, /* HSWGT1UT, HSWM_w7 */ | |
1031 | {0x0A16, 0x8c4e, 0x04}, /* HSWGT2UT, HSWM_w7 */ | |
1032 | {0x0A26, 0x8c4e, 0x06}, /* HSWGT3UT, HSWM_w7 */ | |
1033 | {0x0A2E, 0x8c4e, 0x04}, /* HSWGT3UT28W, HSWM_w7 */ | |
1034 | {0x0A1E, 0x8c4e, 0x04}, /* HSWGT2UX, HSWM_w7 */ | |
1035 | {0x0A0E, 0x8c4e, 0x04}, /* HSWGT1ULX, HSWM_w7 */ | |
1036 | /* HSW CRW */ | |
1037 | {0x0D26, 0x8c4e, 0x04}, /* HSWGT3CW, HSWM_w7 */ | |
1038 | {0x0D22, 0x8c4e, 0x04}, /* HSWGT3CWDT, HSWD_w7 */ | |
1039 | /* HSW Server */ | |
1040 | {0x041A, 0x8c4e, 0x04}, /* HSWSVGT2, HSWD_w7 */ | |
1041 | /* HSW SRVR */ | |
1042 | {0x040A, 0x8c4e, 0x04}, /* HSWSVGT1, HSWD_w7 */ | |
1043 | /* BSW */ | |
1044 | {0x1606, 0x9cc3, 0x03}, /* BDWULTGT1, BDWM_w7 */ | |
1045 | {0x1616, 0x9cc3, 0x03}, /* BDWULTGT2, BDWM_w7 */ | |
1046 | {0x1626, 0x9cc3, 0x03}, /* BDWULTGT3, BDWM_w7 */ | |
1047 | {0x160E, 0x9cc3, 0x03}, /* BDWULXGT1, BDWM_w7 */ | |
1048 | {0x161E, 0x9cc3, 0x03}, /* BDWULXGT2, BDWM_w7 */ | |
1049 | {0x1602, 0x9cc3, 0x03}, /* BDWHALOGT1, BDWM_w7 */ | |
1050 | {0x1612, 0x9cc3, 0x03}, /* BDWHALOGT2, BDWM_w7 */ | |
1051 | {0x1622, 0x9cc3, 0x03}, /* BDWHALOGT3, BDWM_w7 */ | |
1052 | {0x162B, 0x9cc3, 0x03}, /* BDWHALO28W, BDWM_w7 */ | |
1053 | {0x162A, 0x9cc3, 0x03}, /* BDWGT3WRKS, BDWM_w7 */ | |
1054 | {0x162D, 0x9cc3, 0x03}, /* BDWGT3SRVR, BDWM_w7 */ | |
1055 | }; | |
1056 | ||
1057 | static void isa_bridge_class_init(ObjectClass *klass, void *data) | |
1058 | { | |
1059 | DeviceClass *dc = DEVICE_CLASS(klass); | |
1060 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
1061 | ||
1062 | dc->desc = "ISA bridge faked to support IGD PT"; | |
1063 | k->vendor_id = PCI_VENDOR_ID_INTEL; | |
1064 | k->class_id = PCI_CLASS_BRIDGE_ISA; | |
1065 | }; | |
1066 | ||
1067 | static TypeInfo isa_bridge_info = { | |
1068 | .name = "igd-passthrough-isa-bridge", | |
1069 | .parent = TYPE_PCI_DEVICE, | |
1070 | .instance_size = sizeof(PCIDevice), | |
1071 | .class_init = isa_bridge_class_init, | |
fd3b02c8 EH |
1072 | .interfaces = (InterfaceInfo[]) { |
1073 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | |
1074 | { }, | |
1075 | }, | |
bd8107d7 TC |
1076 | }; |
1077 | ||
1078 | static void pt_graphics_register_types(void) | |
1079 | { | |
1080 | type_register_static(&isa_bridge_info); | |
1081 | } | |
1082 | type_init(pt_graphics_register_types) | |
1083 | ||
1084 | void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id) | |
1085 | { | |
1086 | struct PCIDevice *bridge_dev; | |
1087 | int i, num; | |
1088 | uint16_t pch_dev_id = 0xffff; | |
1089 | uint8_t pch_rev_id; | |
1090 | ||
1091 | num = ARRAY_SIZE(igd_combo_id_infos); | |
1092 | for (i = 0; i < num; i++) { | |
1093 | if (gpu_dev_id == igd_combo_id_infos[i].gpu_device_id) { | |
1094 | pch_dev_id = igd_combo_id_infos[i].pch_device_id; | |
1095 | pch_rev_id = igd_combo_id_infos[i].pch_revision_id; | |
1096 | } | |
1097 | } | |
1098 | ||
1099 | if (pch_dev_id == 0xffff) { | |
1100 | return; | |
1101 | } | |
1102 | ||
1103 | /* Currently IGD drivers always need to access PCH by 1f.0. */ | |
1104 | bridge_dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0), | |
1105 | "igd-passthrough-isa-bridge"); | |
1106 | ||
1107 | /* | |
1108 | * Note that vendor id is always PCI_VENDOR_ID_INTEL. | |
1109 | */ | |
1110 | if (!bridge_dev) { | |
1111 | fprintf(stderr, "set igd-passthrough-isa-bridge failed!\n"); | |
1112 | return; | |
1113 | } | |
1114 | pci_config_set_device_id(bridge_dev->config, pch_dev_id); | |
1115 | pci_config_set_revision(bridge_dev->config, pch_rev_id); | |
1116 | } | |
845773ab | 1117 | |
865906f7 | 1118 | static void isapc_machine_options(MachineClass *m) |
fddd179a | 1119 | { |
7102fa70 | 1120 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
1121 | m->desc = "ISA-only PC"; |
1122 | m->max_cpus = 1; | |
71ae9e94 EH |
1123 | m->option_rom_has_mr = true; |
1124 | m->rom_file_has_mr = false; | |
7102fa70 EH |
1125 | pcmc->pci_enabled = false; |
1126 | pcmc->has_acpi_build = false; | |
1127 | pcmc->smbios_defaults = false; | |
1128 | pcmc->gigabyte_align = false; | |
1129 | pcmc->smbios_legacy_mode = true; | |
1130 | pcmc->has_reserved_memory = false; | |
4b9c264b | 1131 | pcmc->default_nic_model = "ne2k_isa"; |
311ca98d | 1132 | m->default_cpu_type = X86_CPU_TYPE_NAME("486"); |
fddd179a | 1133 | } |
b6b5c8e4 | 1134 | |
61f219df | 1135 | DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, |
25519b06 | 1136 | isapc_machine_options); |
61f219df | 1137 | |
845773ab | 1138 | |
29d3ccde | 1139 | #ifdef CONFIG_XEN |
865906f7 | 1140 | static void xenfv_machine_options(MachineClass *m) |
fddd179a | 1141 | { |
fddd179a EH |
1142 | m->desc = "Xen Fully-virtualized PC"; |
1143 | m->max_cpus = HVM_MAX_VCPUS; | |
1144 | m->default_machine_opts = "accel=xen"; | |
fddd179a | 1145 | } |
b6b5c8e4 | 1146 | |
61f219df | 1147 | DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, |
25519b06 | 1148 | xenfv_machine_options); |
29d3ccde | 1149 | #endif |