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