]> Git Repo - qemu.git/blame - include/hw/i386/pc.h
Merge remote-tracking branch 'remotes/kraxel/tags/vga-20190111-pull-request' into...
[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"
a7d69ff1 16#include "hw/mem/pc-dimm.h"
5fe79386 17#include "hw/mem/nvdimm.h"
ac35f13b 18#include "hw/acpi/acpi_dev_interface.h"
3459a625 19
7a10ef51
LPF
20#define HPET_INTCAP "hpet-intcap"
21
619d11e4
IM
22/**
23 * PCMachineState:
781bbd6b 24 * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
e3cadac0 25 * @boot_cpus: number of present VCPUs
619d11e4 26 */
d5747cac
IM
27struct PCMachineState {
28 /*< private >*/
29 MachineState parent_obj;
619d11e4
IM
30
31 /* <public> */
13fc8343
EH
32
33 /* State for other subsystems/APIs: */
9ebeed0c 34 Notifier machine_done;
781bbd6b 35
13fc8343 36 /* Pointers to devices and objects: */
781bbd6b 37 HotplugHandler *acpi_dev;
2d996150 38 ISADevice *rtc;
13fc8343 39 PCIBus *bus;
f264d360 40 FWCfgState *fw_cfg;
3e6c0c4c 41 qemu_irq *gsi;
c87b1520 42
13fc8343 43 /* Configuration options: */
c87b1520 44 uint64_t max_ram_below_4g;
d1048bef 45 OnOffAuto vmport;
355023f2 46 OnOffAuto smm;
5fe79386
XG
47
48 AcpiNVDIMMState acpi_nvdimm_state;
13fc8343 49
021746c1 50 bool acpi_build_enabled;
f5878b03
CM
51 bool smbus_enabled;
52 bool sata_enabled;
53 bool pit_enabled;
021746c1 54
13fc8343 55 /* RAM information (sizes, addresses, configuration): */
c0aa4e1e 56 ram_addr_t below_4g_mem_size, above_4g_mem_size;
dd4c2f01
EH
57
58 /* CPU and apic information: */
59 bool apic_xrupt_override;
60 unsigned apic_id_limit;
e3cadac0 61 uint16_t boot_cpus;
dd4c2f01
EH
62
63 /* NUMA information: */
64 uint64_t numa_nodes;
65 uint64_t *node_mem;
cb135f59
PX
66
67 /* Address space used by IOAPIC device. All IOAPIC interrupts
68 * will be translated to MSI messages in the address space. */
69 AddressSpace *ioapic_as;
d5747cac
IM
70};
71
781bbd6b 72#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
f2ffbe2b 73#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"
c87b1520 74#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
9b23cfb7 75#define PC_MACHINE_VMPORT "vmport"
355023f2 76#define PC_MACHINE_SMM "smm"
87252e1b 77#define PC_MACHINE_NVDIMM "nvdimm"
11c39b5c 78#define PC_MACHINE_NVDIMM_PERSIST "nvdimm-persistence"
be232eb0 79#define PC_MACHINE_SMBUS "smbus"
272f0428 80#define PC_MACHINE_SATA "sata"
feddd2fd 81#define PC_MACHINE_PIT "pit"
781bbd6b 82
95bee274
IM
83/**
84 * PCMachineClass:
13fc8343 85 *
13fc8343
EH
86 * Compat fields:
87 *
16a9e8a5
EH
88 * @enforce_aligned_dimm: check that DIMM's address/size is aligned by
89 * backend's alignment value if provided
13fc8343
EH
90 * @acpi_data_size: Size of the chunk of memory at the top of RAM
91 * for the BIOS ACPI tables and other BIOS
92 * datastructures.
93 * @gigabyte_align: Make sure that guest addresses aligned at
94 * 1Gbyte boundaries get mapped to host
95 * addresses aligned at 1Gbyte boundaries. This
96 * way we can use 1GByte pages in the host.
97 *
95bee274 98 */
d5747cac
IM
99struct PCMachineClass {
100 /*< private >*/
101 MachineClass parent_class;
95bee274
IM
102
103 /*< public >*/
13fc8343 104
13fc8343 105 /* Device configuration: */
7102fa70 106 bool pci_enabled;
13fc8343 107 bool kvmclock_enabled;
4b9c264b 108 const char *default_nic_model;
13fc8343
EH
109
110 /* Compat options: */
111
112 /* ACPI compat: */
7102fa70
EH
113 bool has_acpi_build;
114 bool rsdp_in_ram;
13fc8343
EH
115 int legacy_acpi_table_size;
116 unsigned acpi_data_size;
117
118 /* SMBIOS compat: */
7102fa70
EH
119 bool smbios_defaults;
120 bool smbios_legacy_mode;
121 bool smbios_uuid_encoded;
13fc8343
EH
122
123 /* RAM / address space compat: */
7102fa70
EH
124 bool gigabyte_align;
125 bool has_reserved_memory;
16a9e8a5 126 bool enforce_aligned_dimm;
13fc8343 127 bool broken_reserved_end;
36f96c4b
HZ
128
129 /* TSC rate migration: */
130 bool save_tsc_khz;
679dd1a9
IM
131 /* generate legacy CPU hotplug AML */
132 bool legacy_cpu_hotplug;
98e753a6
IM
133
134 /* use DMA capable linuxboot option rom */
135 bool linuxboot_dma_enabled;
d5747cac
IM
136};
137
d5747cac
IM
138#define TYPE_PC_MACHINE "generic-pc-machine"
139#define PC_MACHINE(obj) \
140 OBJECT_CHECK(PCMachineState, (obj), TYPE_PC_MACHINE)
141#define PC_MACHINE_GET_CLASS(obj) \
142 OBJECT_GET_CLASS(PCMachineClass, (obj), TYPE_PC_MACHINE)
143#define PC_MACHINE_CLASS(klass) \
144 OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
145
87ecb68b
PB
146/* i8259.c */
147
9aa78c42 148extern DeviceState *isa_pic;
48a18b3c 149qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
10b61882 150qemu_irq *kvm_i8259_init(ISABus *bus);
9aa78c42
JK
151int pic_read_irq(DeviceState *d);
152int pic_get_output(DeviceState *d);
87ecb68b 153
d665d696
PB
154/* ioapic.c */
155
b881fbe9 156/* Global System Interrupts */
96051119 157
b881fbe9 158#define GSI_NUM_PINS IOAPIC_NUM_PINS
845773ab 159
b881fbe9 160typedef struct GSIState {
43a0db35 161 qemu_irq i8259_irq[ISA_NUM_IRQS];
b881fbe9
JK
162 qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
163} GSIState;
164
165void gsi_handler(void *opaque, int n, int level);
845773ab 166
87ecb68b 167/* vmport.c */
936a6447 168#define TYPE_VMPORT "vmport"
d67f679d
JK
169typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
170
48a18b3c 171static inline void vmport_init(ISABus *bus)
6872ef61 172{
936a6447 173 isa_create_simple(bus, TYPE_VMPORT);
6872ef61 174}
d67f679d
JK
175
176void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque);
86d86414
BS
177void vmmouse_get_data(uint32_t *data);
178void vmmouse_set_data(const uint32_t *data);
87ecb68b 179
87ecb68b
PB
180/* pc.c */
181extern int fd_bootchk;
182
355023f2 183bool pc_machine_is_smm_enabled(PCMachineState *pcms);
8e78eb28 184void pc_register_ferr_irq(qemu_irq irq);
845773ab
IY
185void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
186
4884b7bf 187void pc_cpus_init(PCMachineState *pcms);
c649983b 188void pc_hot_add_cpu(const int64_t id, Error **errp);
f7e4dd6c 189void pc_acpi_init(const char *default_dsdt);
3459a625 190
e4e8ba04 191void pc_guest_info_init(PCMachineState *pcms);
3459a625 192
39848901
IM
193#define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start"
194#define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
195#define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
196#define PCI_HOST_PROP_PCI_HOLE64_END "pci-hole64-end"
197#define PCI_HOST_PROP_PCI_HOLE64_SIZE "pci-hole64-size"
401f2f3e
EV
198#define PCI_HOST_BELOW_4G_MEM_SIZE "below-4g-mem-size"
199#define PCI_HOST_ABOVE_4G_MEM_SIZE "above-4g-mem-size"
1466cef3 200
39848901 201
83d08f26
MT
202void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
203 MemoryRegion *pci_address_space);
39848901 204
7bc35e0f 205void xen_load_linux(PCMachineState *pcms);
5934e216
EH
206void pc_memory_init(PCMachineState *pcms,
207 MemoryRegion *system_memory,
208 MemoryRegion *rom_memory,
209 MemoryRegion **ram_memory);
9fa99d25 210uint64_t pc_pci_hole64_start(void);
0b0cc076 211qemu_irq pc_allocate_cpu_irq(void);
48a18b3c
HP
212DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
213void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
1611977c 214 ISADevice **rtc_state,
fd53c87c 215 bool create_fdctrl,
7a10ef51 216 bool no_vmport,
feddd2fd 217 bool has_pit,
3a87d009 218 uint32_t hpet_irqs);
48a18b3c 219void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
23d30407 220void pc_cmos_init(PCMachineState *pcms,
220a8846 221 BusState *ide0, BusState *ide1,
63ffb564 222 ISADevice *s);
4b9c264b 223void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus);
845773ab 224void pc_pci_device_init(PCIBus *pci_bus);
8e78eb28 225
f885f1ea 226typedef void (*cpu_set_smm_t)(int smm, void *arg);
f885f1ea 227
a39e3564
JB
228void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
229
424e4a87 230ISADevice *pc_find_fdc0(void);
bda05509 231int cmos_get_fd_drive_type(FloppyDriveType fd0);
424e4a87 232
305ae888
GS
233#define FW_CFG_IO_BASE 0x510
234
d812b3d6
EV
235#define PORT92_A20_LINE "a20"
236
9d5e77a2 237/* acpi_piix.c */
53b67b30 238
a5c82852
AF
239I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
240 qemu_irq sci_irq, qemu_irq smi_irq,
61e66c62 241 int smm_enabled, DeviceState **piix4_pm);
87ecb68b 242
16b29ae1
AL
243/* hpet.c */
244extern int no_hpet;
245
87ecb68b 246/* piix_pci.c */
0a3bacf3
JQ
247struct PCII440FXState;
248typedef struct PCII440FXState PCII440FXState;
249
7bb836e4
MT
250#define TYPE_I440FX_PCI_HOST_BRIDGE "i440FX-pcihost"
251#define TYPE_I440FX_PCI_DEVICE "i440FX"
252
595a4f07
TC
253#define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX"
254
6103451a
PDJ
255/*
256 * Reset Control Register: PCI-accessible ISA-Compatible Register at address
257 * 0xcf9, provided by the PCI/ISA bridge (PIIX3 PCI function 0, 8086:7000).
258 */
259#define RCR_IOPORT 0xcf9
260
7bb836e4
MT
261PCIBus *i440fx_init(const char *host_type, const char *pci_type,
262 PCII440FXState **pi440fx_state, int *piix_devfn,
60573079 263 ISABus **isa_bus, qemu_irq *pic,
aee97b84
AK
264 MemoryRegion *address_space_mem,
265 MemoryRegion *address_space_io,
ae0a5466 266 ram_addr_t ram_size,
ddaaefb4 267 ram_addr_t below_4g_mem_size,
39848901 268 ram_addr_t above_4g_mem_size,
ae0a5466
AK
269 MemoryRegion *pci_memory,
270 MemoryRegion *ram_memory);
87ecb68b 271
277e9340 272PCIBus *find_i440fx(void);
823e675a 273/* piix4.c */
b1d8e52e 274extern PCIDevice *piix4_dev;
142e9787 275int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
87ecb68b 276
cbc5b5f3 277/* pc_sysfw.c */
6dd2a5c9
PB
278void pc_system_firmware_init(MemoryRegion *rom_memory,
279 bool isapc_ram_fw);
cbc5b5f3 280
ac35f13b
IM
281/* acpi-build.c */
282void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
80e5db30 283 const CPUArchIdList *apic_ids, GArray *entry);
ac35f13b 284
4c5b10b7
JS
285/* e820 types */
286#define E820_RAM 1
287#define E820_RESERVED 2
288#define E820_ACPI 3
289#define E820_NVS 4
290#define E820_UNUSABLE 5
291
292int e820_add_entry(uint64_t, uint64_t, uint32_t);
7bf8ef19
GS
293int e820_get_num_entries(void);
294bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
4c5b10b7 295
abd93cc7
MAL
296extern GlobalProperty pc_compat_3_1[];
297extern const size_t pc_compat_3_1_len;
84e060bf 298
ddb3235d
MAL
299extern GlobalProperty pc_compat_3_0[];
300extern const size_t pc_compat_3_0_len;
9b4cf107 301
0d47310b
MAL
302extern GlobalProperty pc_compat_2_12[];
303extern const size_t pc_compat_2_12_len;
968ee4ad 304
43df70a9
MAL
305extern GlobalProperty pc_compat_2_11[];
306extern const size_t pc_compat_2_11_len;
df47ce8a 307
503224f4
MAL
308extern GlobalProperty pc_compat_2_10[];
309extern const size_t pc_compat_2_10_len;
a6fd5b0e 310
3e803152
MAL
311extern GlobalProperty pc_compat_2_9[];
312extern const size_t pc_compat_2_9_len;
465238d9 313
edc24ccd
MAL
314extern GlobalProperty pc_compat_2_8[];
315extern const size_t pc_compat_2_8_len;
abc62c89 316
5a995064
MAL
317extern GlobalProperty pc_compat_2_7[];
318extern const size_t pc_compat_2_7_len;
14c985cf 319
ff8f261f
MAL
320extern GlobalProperty pc_compat_2_6[];
321extern const size_t pc_compat_2_6_len;
d86c1451 322
fe759610
MAL
323extern GlobalProperty pc_compat_2_5[];
324extern const size_t pc_compat_2_5_len;
240240d5 325
2f99b9c2
MAL
326extern GlobalProperty pc_compat_2_4[];
327extern const size_t pc_compat_2_4_len;
328
8995dd90
MAL
329extern GlobalProperty pc_compat_2_3[];
330extern const size_t pc_compat_2_3_len;
331
1c30044e
MAL
332extern GlobalProperty pc_compat_2_2[];
333extern const size_t pc_compat_2_2_len;
334
c4fc5695
MAL
335extern GlobalProperty pc_compat_2_1[];
336extern const size_t pc_compat_2_1_len;
337
a310e653
MAL
338extern GlobalProperty pc_compat_2_0[];
339extern const size_t pc_compat_2_0_len;
340
341extern GlobalProperty pc_compat_1_7[];
342extern const size_t pc_compat_1_7_len;
343
344extern GlobalProperty pc_compat_1_6[];
345extern const size_t pc_compat_1_6_len;
346
347extern GlobalProperty pc_compat_1_5[];
348extern const size_t pc_compat_1_5_len;
349
350extern GlobalProperty pc_compat_1_4[];
351extern const size_t pc_compat_1_4_len;
352
cd6c1b70
EH
353/* Helper for setting model-id for CPU models that changed model-id
354 * depending on QEMU versions up to QEMU 2.4.
355 */
356#define PC_CPU_MODEL_IDS(v) \
6c36bddf
EH
357 { "qemu32-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
358 { "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
359 { "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },
cd6c1b70 360
25519b06 361#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
865906f7
EH
362 static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
363 { \
364 MachineClass *mc = MACHINE_CLASS(oc); \
365 optsfn(mc); \
865906f7
EH
366 mc->init = initfn; \
367 } \
368 static const TypeInfo pc_machine_type_##suffix = { \
369 .name = namestr TYPE_MACHINE_SUFFIX, \
370 .parent = TYPE_PC_MACHINE, \
371 .class_init = pc_machine_##suffix##_class_init, \
372 }; \
61f219df
EH
373 static void pc_machine_init_##suffix(void) \
374 { \
865906f7 375 type_register(&pc_machine_type_##suffix); \
61f219df 376 } \
0e6aac87 377 type_init(pc_machine_init_##suffix)
61f219df 378
bd8107d7 379extern void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id);
87ecb68b 380#endif
This page took 0.99489 seconds and 4 git commands to generate.