]> Git Repo - qemu.git/blame - include/hw/i386/pc.h
pc: exit QEMU if number of slots more than supported 256
[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"
0d09e41a
PB
6#include "hw/isa/isa.h"
7#include "hw/block/fdc.h"
1422e32d 8#include "net/net.h"
0d09e41a 9#include "hw/i386/ioapic.h"
376253ec 10
3459a625 11#include "qemu/range.h"
b20c9bd5
MT
12#include "qemu/bitmap.h"
13#include "sysemu/sysemu.h"
14#include "hw/pci/pci.h"
d5747cac 15#include "hw/boards.h"
3459a625 16
7a10ef51
LPF
17#define HPET_INTCAP "hpet-intcap"
18
619d11e4
IM
19/**
20 * PCMachineState:
21 * @hotplug_memory_base: address in guest RAM address space where hotplug memory
22 * address space begins.
23 * @hotplug_memory: hotplug memory addess space container
24 */
d5747cac
IM
25struct PCMachineState {
26 /*< private >*/
27 MachineState parent_obj;
619d11e4
IM
28
29 /* <public> */
30 ram_addr_t hotplug_memory_base;
31 MemoryRegion hotplug_memory;
d5747cac
IM
32};
33
34struct PCMachineClass {
35 /*< private >*/
36 MachineClass parent_class;
37};
38
39typedef struct PCMachineState PCMachineState;
40typedef struct PCMachineClass PCMachineClass;
41
42#define TYPE_PC_MACHINE "generic-pc-machine"
43#define PC_MACHINE(obj) \
44 OBJECT_CHECK(PCMachineState, (obj), TYPE_PC_MACHINE)
45#define PC_MACHINE_GET_CLASS(obj) \
46 OBJECT_GET_CLASS(PCMachineClass, (obj), TYPE_PC_MACHINE)
47#define PC_MACHINE_CLASS(klass) \
48 OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
49
50void qemu_register_pc_machine(QEMUMachine *m);
51
87ecb68b
PB
52/* PC-style peripherals (also used by other machines). */
53
3459a625
MT
54typedef struct PcPciInfo {
55 Range w32;
56 Range w64;
57} PcPciInfo;
58
f854ecc7
MT
59#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
60#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
61#define ACPI_PM_PROP_S4_VAL "s4_val"
62#define ACPI_PM_PROP_SCI_INT "sci_int"
63#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd"
64#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd"
65#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
66#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
67#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
68
3459a625 69struct PcGuestInfo {
f8c457b8 70 bool has_pci_info;
6dd2a5c9 71 bool isapc_ram_fw;
f30ee8a9 72 hwaddr ram_size, ram_size_below_4g;
b20c9bd5
MT
73 unsigned apic_id_limit;
74 bool apic_xrupt_override;
75 uint64_t numa_nodes;
76 uint64_t *node_mem;
77 uint64_t *node_cpu;
3459a625 78 FWCfgState *fw_cfg;
72c194f7 79 bool has_acpi_build;
3459a625
MT
80};
81
87ecb68b 82/* parallel.c */
48a18b3c 83static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
defdb20e 84{
4a17cc4f
AF
85 DeviceState *dev;
86 ISADevice *isadev;
defdb20e 87
4a17cc4f
AF
88 isadev = isa_try_create(bus, "isa-parallel");
89 if (!isadev) {
73531538
BS
90 return false;
91 }
4a17cc4f
AF
92 dev = DEVICE(isadev);
93 qdev_prop_set_uint32(dev, "index", index);
94 qdev_prop_set_chr(dev, "chardev", chr);
95 if (qdev_init(dev) < 0) {
defdb20e
BS
96 return false;
97 }
98 return true;
99}
100
63858cd9 101bool parallel_mm_init(MemoryRegion *address_space,
a8170e5e 102 hwaddr base, int it_shift, qemu_irq irq,
defdb20e 103 CharDriverState *chr);
87ecb68b
PB
104
105/* i8259.c */
106
9aa78c42 107extern DeviceState *isa_pic;
48a18b3c 108qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
10b61882 109qemu_irq *kvm_i8259_init(ISABus *bus);
9aa78c42
JK
110int pic_read_irq(DeviceState *d);
111int pic_get_output(DeviceState *d);
84f2d0ea
WX
112void pic_info(Monitor *mon, const QDict *qdict);
113void irq_info(Monitor *mon, const QDict *qdict);
87ecb68b 114
b881fbe9 115/* Global System Interrupts */
96051119 116
b881fbe9 117#define GSI_NUM_PINS IOAPIC_NUM_PINS
845773ab 118
b881fbe9 119typedef struct GSIState {
43a0db35 120 qemu_irq i8259_irq[ISA_NUM_IRQS];
b881fbe9
JK
121 qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
122} GSIState;
123
124void gsi_handler(void *opaque, int n, int level);
845773ab 125
87ecb68b 126/* vmport.c */
d67f679d
JK
127typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
128
48a18b3c 129static inline void vmport_init(ISABus *bus)
6872ef61 130{
48a18b3c 131 isa_create_simple(bus, "vmport");
6872ef61 132}
d67f679d
JK
133
134void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque);
86d86414
BS
135void vmmouse_get_data(uint32_t *data);
136void vmmouse_set_data(const uint32_t *data);
87ecb68b 137
87ecb68b
PB
138/* pckbd.c */
139
140void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
141void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
dbff76ac 142 MemoryRegion *region, ram_addr_t size,
a8170e5e 143 hwaddr mask);
956a3e6b
BS
144void i8042_isa_mouse_fake_event(void *opaque);
145void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
87ecb68b 146
87ecb68b
PB
147/* pc.c */
148extern int fd_bootchk;
149
8e78eb28 150void pc_register_ferr_irq(qemu_irq irq);
845773ab
IY
151void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
152
62fc403f 153void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
c649983b 154void pc_hot_add_cpu(const int64_t id, Error **errp);
f7e4dd6c 155void pc_acpi_init(const char *default_dsdt);
3459a625
MT
156
157PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
158 ram_addr_t above_4g_mem_size);
159
39848901
IM
160#define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start"
161#define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
162#define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
163#define PCI_HOST_PROP_PCI_HOLE64_END "pci-hole64-end"
164#define PCI_HOST_PROP_PCI_HOLE64_SIZE "pci-hole64-size"
1466cef3
MT
165#define DEFAULT_PCI_HOLE64_SIZE (~0x0ULL)
166
39848901 167
83d08f26
MT
168void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
169 MemoryRegion *pci_address_space);
39848901 170
a88b362c
LE
171FWCfgState *pc_memory_init(MemoryRegion *system_memory,
172 const char *kernel_filename,
173 const char *kernel_cmdline,
174 const char *initrd_filename,
175 ram_addr_t below_4g_mem_size,
176 ram_addr_t above_4g_mem_size,
177 MemoryRegion *rom_memory,
3459a625
MT
178 MemoryRegion **ram_memory,
179 PcGuestInfo *guest_info);
845773ab 180qemu_irq *pc_allocate_cpu_irq(void);
48a18b3c
HP
181DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
182void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
1611977c 183 ISADevice **rtc_state,
34d4260e 184 ISADevice **floppy,
7a10ef51
LPF
185 bool no_vmport,
186 uint32 hpet_irqs);
48a18b3c 187void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
845773ab 188void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
c0897e0c 189 const char *boot_device,
34d4260e 190 ISADevice *floppy, BusState *ide0, BusState *ide1,
63ffb564 191 ISADevice *s);
9011a1a7 192void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
845773ab 193void pc_pci_device_init(PCIBus *pci_bus);
8e78eb28 194
f885f1ea
IY
195typedef void (*cpu_set_smm_t)(int smm, void *arg);
196void cpu_smm_register(cpu_set_smm_t callback, void *arg);
197
a39e3564
JB
198void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
199
9d5e77a2 200/* acpi_piix.c */
53b67b30 201
a5c82852
AF
202I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
203 qemu_irq sci_irq, qemu_irq smi_irq,
204 int kvm_enabled, FWCfgState *fw_cfg);
87ecb68b 205void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
87ecb68b 206
16b29ae1
AL
207/* hpet.c */
208extern int no_hpet;
209
87ecb68b 210/* piix_pci.c */
0a3bacf3
JQ
211struct PCII440FXState;
212typedef struct PCII440FXState PCII440FXState;
213
1e39101c 214PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
60573079 215 ISABus **isa_bus, qemu_irq *pic,
aee97b84
AK
216 MemoryRegion *address_space_mem,
217 MemoryRegion *address_space_io,
ae0a5466 218 ram_addr_t ram_size,
ddaaefb4 219 ram_addr_t below_4g_mem_size,
39848901 220 ram_addr_t above_4g_mem_size,
ae0a5466
AK
221 MemoryRegion *pci_memory,
222 MemoryRegion *ram_memory);
87ecb68b 223
277e9340 224PCIBus *find_i440fx(void);
823e675a 225/* piix4.c */
b1d8e52e 226extern PCIDevice *piix4_dev;
142e9787 227int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
87ecb68b
PB
228
229/* vga.c */
cb5a7aa8 230enum vga_retrace_method {
231 VGA_RETRACE_DUMB,
232 VGA_RETRACE_PRECISE
233};
234
235extern enum vga_retrace_method vga_retrace_method;
87ecb68b 236
a8170e5e
AK
237int isa_vga_mm_init(hwaddr vram_base,
238 hwaddr ctrl_base, int it_shift,
be20f9e9 239 MemoryRegion *address_space);
87ecb68b 240
87ecb68b 241/* ne2000.c */
48a18b3c 242static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
60a14ad3 243{
4a17cc4f
AF
244 DeviceState *dev;
245 ISADevice *isadev;
87ecb68b 246
60a14ad3
BS
247 qemu_check_nic_model(nd, "ne2k_isa");
248
4a17cc4f
AF
249 isadev = isa_try_create(bus, "ne2k_isa");
250 if (!isadev) {
cd1b8a8b
BS
251 return false;
252 }
4a17cc4f
AF
253 dev = DEVICE(isadev);
254 qdev_prop_set_uint32(dev, "iobase", base);
255 qdev_prop_set_uint32(dev, "irq", irq);
256 qdev_set_nic_properties(dev, nd);
257 qdev_init_nofail(dev);
cd1b8a8b 258 return true;
60a14ad3 259}
87ecb68b 260
cbc5b5f3 261/* pc_sysfw.c */
6dd2a5c9
PB
262void pc_system_firmware_init(MemoryRegion *rom_memory,
263 bool isapc_ram_fw);
cbc5b5f3 264
3ab135f3 265/* pvpanic.c */
309cd62d 266uint16_t pvpanic_port(void);
3ab135f3 267
4c5b10b7
JS
268/* e820 types */
269#define E820_RAM 1
270#define E820_RESERVED 2
271#define E820_ACPI 3
272#define E820_NVS 4
273#define E820_UNUSABLE 5
274
275int e820_add_entry(uint64_t, uint64_t, uint32_t);
7bf8ef19
GS
276int e820_get_num_entries(void);
277bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
4c5b10b7 278
9df11c9f
GS
279#define PC_Q35_COMPAT_2_0 \
280 PC_COMPAT_2_0
281
7a10ef51 282#define PC_Q35_COMPAT_1_7 \
5319dc7b 283 PC_COMPAT_1_7, \
9df11c9f 284 PC_Q35_COMPAT_2_0, \
7a10ef51
LPF
285 {\
286 .driver = "hpet",\
287 .property = HPET_INTCAP,\
288 .value = stringify(4),\
289 }
290
291#define PC_Q35_COMPAT_1_6 \
292 PC_COMPAT_1_6, \
293 PC_Q35_COMPAT_1_7
294
295#define PC_Q35_COMPAT_1_5 \
296 PC_COMPAT_1_5, \
297 PC_Q35_COMPAT_1_6
298
299#define PC_Q35_COMPAT_1_4 \
300 PC_COMPAT_1_4, \
301 PC_Q35_COMPAT_1_5
302
9df11c9f
GS
303#define PC_COMPAT_2_0 \
304 {\
aa93200b
GS
305 .driver = "apic",\
306 .property = "version",\
307 .value = stringify(0x11),\
7bafd888
GH
308 },{\
309 .driver = "nec-usb-xhci",\
310 .property = "superspeed-ports-first",\
311 .value = "off",\
13cc2c3e
BZ
312 },\
313 {\
314 .driver = "pci-serial",\
315 .property = "prog_if",\
316 .value = stringify(0),\
317 },\
318 {\
319 .driver = "pci-serial-2x",\
320 .property = "prof_if",\
321 .value = stringify(0),\
322 },\
323 {\
324 .driver = "pci-serial-4x",\
325 .property = "prog_if",\
326 .value = stringify(0),\
9df11c9f
GS
327 }
328
5319dc7b 329#define PC_COMPAT_1_7 \
9df11c9f 330 PC_COMPAT_2_0, \
5319dc7b
GH
331 {\
332 .driver = TYPE_USB_DEVICE,\
333 .property = "msos-desc",\
334 .value = "no",\
9e047b98
MT
335 },\
336 {\
337 .driver = "PIIX4_PM",\
338 .property = "acpi-pci-hotplug-with-bridge-support",\
339 .value = "off",\
5319dc7b
GH
340 }
341
e9845f09 342#define PC_COMPAT_1_6 \
5319dc7b 343 PC_COMPAT_1_7, \
e9845f09
VM
344 {\
345 .driver = "e1000",\
346 .property = "mitigation",\
347 .value = "off",\
f8e6a11a
EH
348 },{\
349 .driver = "qemu64-" TYPE_X86_CPU,\
350 .property = "model",\
351 .value = stringify(2),\
352 },{\
353 .driver = "qemu32-" TYPE_X86_CPU,\
354 .property = "model",\
355 .value = stringify(3),\
04c7d8b8
CR
356 },{\
357 .driver = "i440FX-pcihost",\
358 .property = "short_root_bus",\
359 .value = stringify(1),\
360 },{\
361 .driver = "q35-pcihost",\
362 .property = "short_root_bus",\
363 .value = stringify(1),\
e9845f09
VM
364 }
365
ffce9ebb 366#define PC_COMPAT_1_5 \
e9845f09 367 PC_COMPAT_1_6, \
ffce9ebb
EH
368 {\
369 .driver = "Conroe-" TYPE_X86_CPU,\
370 .property = "model",\
371 .value = stringify(2),\
6b11322e
EH
372 },{\
373 .driver = "Conroe-" TYPE_X86_CPU,\
374 .property = "level",\
375 .value = stringify(2),\
ffce9ebb
EH
376 },{\
377 .driver = "Penryn-" TYPE_X86_CPU,\
378 .property = "model",\
379 .value = stringify(2),\
6b11322e
EH
380 },{\
381 .driver = "Penryn-" TYPE_X86_CPU,\
382 .property = "level",\
383 .value = stringify(2),\
ffce9ebb
EH
384 },{\
385 .driver = "Nehalem-" TYPE_X86_CPU,\
386 .property = "model",\
387 .value = stringify(2),\
6b11322e
EH
388 },{\
389 .driver = "Nehalem-" TYPE_X86_CPU,\
390 .property = "level",\
391 .value = stringify(2),\
488f069b
MT
392 },{\
393 .driver = "virtio-net-pci",\
394 .property = "any_layout",\
395 .value = "off",\
9337e3b6
EH
396 },{\
397 .driver = TYPE_X86_CPU,\
398 .property = "pmu",\
399 .value = "on",\
04c7d8b8
CR
400 },{\
401 .driver = "i440FX-pcihost",\
402 .property = "short_root_bus",\
403 .value = stringify(0),\
404 },{\
405 .driver = "q35-pcihost",\
406 .property = "short_root_bus",\
407 .value = stringify(0),\
ffce9ebb
EH
408 }
409
bf3caa3d 410#define PC_COMPAT_1_4 \
ffce9ebb 411 PC_COMPAT_1_5, \
bf3caa3d
PB
412 {\
413 .driver = "scsi-hd",\
414 .property = "discard_granularity",\
415 .value = stringify(0),\
416 },{\
417 .driver = "scsi-cd",\
418 .property = "discard_granularity",\
419 .value = stringify(0),\
420 },{\
421 .driver = "scsi-disk",\
422 .property = "discard_granularity",\
423 .value = stringify(0),\
424 },{\
425 .driver = "ide-hd",\
426 .property = "discard_granularity",\
427 .value = stringify(0),\
428 },{\
429 .driver = "ide-cd",\
430 .property = "discard_granularity",\
431 .value = stringify(0),\
432 },{\
433 .driver = "ide-drive",\
434 .property = "discard_granularity",\
435 .value = stringify(0),\
c45e5b5b 436 },{\
bf3caa3d
PB
437 .driver = "virtio-blk-pci",\
438 .property = "discard_granularity",\
439 .value = stringify(0),\
554f1997
GH
440 },{\
441 .driver = "virtio-serial-pci",\
442 .property = "vectors",\
443 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
444 .value = stringify(0xFFFFFFFF),\
644c9858
DF
445 },{ \
446 .driver = "virtio-net-pci", \
447 .property = "ctrl_guest_offloads", \
448 .value = "off", \
c45e5b5b
GH
449 },{\
450 .driver = "e1000",\
451 .property = "romfile",\
452 .value = "pxe-e1000.rom",\
453 },{\
454 .driver = "ne2k_pci",\
455 .property = "romfile",\
456 .value = "pxe-ne2k_pci.rom",\
457 },{\
458 .driver = "pcnet",\
459 .property = "romfile",\
460 .value = "pxe-pcnet.rom",\
461 },{\
462 .driver = "rtl8139",\
463 .property = "romfile",\
464 .value = "pxe-rtl8139.rom",\
465 },{\
466 .driver = "virtio-net-pci",\
467 .property = "romfile",\
468 .value = "pxe-virtio.rom",\
b2a856d9
AF
469 },{\
470 .driver = "486-" TYPE_X86_CPU,\
471 .property = "model",\
472 .value = stringify(0),\
c45e5b5b 473 }
bf3caa3d 474
a0dba644
MT
475#define PC_COMMON_MACHINE_OPTIONS \
476 .default_boot_order = "cad"
477
478#define PC_DEFAULT_MACHINE_OPTIONS \
479 PC_COMMON_MACHINE_OPTIONS, \
480 .hot_add_cpu = pc_hot_add_cpu, \
481 .max_cpus = 255
482
87ecb68b 483#endif
This page took 0.80262 seconds and 4 git commands to generate.