4 #include "qemu-common.h"
5 #include "exec/memory.h"
6 #include "hw/isa/isa.h"
7 #include "hw/block/fdc.h"
9 #include "hw/i386/ioapic.h"
11 #include "qemu/range.h"
12 #include "qemu/bitmap.h"
13 #include "sysemu/sysemu.h"
14 #include "hw/pci/pci.h"
16 #define HPET_INTCAP "hpet-intcap"
18 /* PC-style peripherals (also used by other machines). */
20 typedef struct PcPciInfo
{
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"
38 hwaddr ram_size
, ram_size_below_4g
;
39 unsigned apic_id_limit
;
40 bool apic_xrupt_override
;
49 static inline bool parallel_init(ISABus
*bus
, int index
, CharDriverState
*chr
)
54 isadev
= isa_try_create(bus
, "isa-parallel");
59 qdev_prop_set_uint32(dev
, "index", index
);
60 qdev_prop_set_chr(dev
, "chardev", chr
);
61 if (qdev_init(dev
) < 0) {
67 bool parallel_mm_init(MemoryRegion
*address_space
,
68 hwaddr base
, int it_shift
, qemu_irq irq
,
69 CharDriverState
*chr
);
73 extern DeviceState
*isa_pic
;
74 qemu_irq
*i8259_init(ISABus
*bus
, qemu_irq parent_irq
);
75 qemu_irq
*kvm_i8259_init(ISABus
*bus
);
76 int pic_read_irq(DeviceState
*d
);
77 int pic_get_output(DeviceState
*d
);
78 void pic_info(Monitor
*mon
, const QDict
*qdict
);
79 void irq_info(Monitor
*mon
, const QDict
*qdict
);
81 /* Global System Interrupts */
83 #define GSI_NUM_PINS IOAPIC_NUM_PINS
85 typedef struct GSIState
{
86 qemu_irq i8259_irq
[ISA_NUM_IRQS
];
87 qemu_irq ioapic_irq
[IOAPIC_NUM_PINS
];
90 void gsi_handler(void *opaque
, int n
, int level
);
93 typedef uint32_t (VMPortReadFunc
)(void *opaque
, uint32_t address
);
95 static inline void vmport_init(ISABus
*bus
)
97 isa_create_simple(bus
, "vmport");
100 void vmport_register(unsigned char command
, VMPortReadFunc
*func
, void *opaque
);
101 void vmmouse_get_data(uint32_t *data
);
102 void vmmouse_set_data(const uint32_t *data
);
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
,
108 MemoryRegion
*region
, ram_addr_t size
,
110 void i8042_isa_mouse_fake_event(void *opaque
);
111 void i8042_setup_a20_line(ISADevice
*dev
, qemu_irq
*a20_out
);
114 extern int fd_bootchk
;
116 void pc_register_ferr_irq(qemu_irq irq
);
117 void pc_acpi_smi_interrupt(void *opaque
, int irq
, int level
);
119 void pc_cpus_init(const char *cpu_model
, DeviceState
*icc_bridge
);
120 void pc_hot_add_cpu(const int64_t id
, Error
**errp
);
121 void pc_acpi_init(const char *default_dsdt
);
123 PcGuestInfo
*pc_guest_info_init(ram_addr_t below_4g_mem_size
,
124 ram_addr_t above_4g_mem_size
);
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"
131 #define DEFAULT_PCI_HOLE64_SIZE (~0x0ULL)
134 void pc_pci_as_mapping_init(Object
*owner
, MemoryRegion
*system_memory
,
135 MemoryRegion
*pci_address_space
);
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
,
144 MemoryRegion
**ram_memory
,
145 PcGuestInfo
*guest_info
);
146 qemu_irq
*pc_allocate_cpu_irq(void);
147 DeviceState
*pc_vga_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
148 void pc_basic_device_init(ISABus
*isa_bus
, qemu_irq
*gsi
,
149 ISADevice
**rtc_state
,
153 void pc_init_ne2k_isa(ISABus
*bus
, NICInfo
*nd
);
154 void pc_cmos_init(ram_addr_t ram_size
, ram_addr_t above_4g_mem_size
,
155 const char *boot_device
,
156 ISADevice
*floppy
, BusState
*ide0
, BusState
*ide1
,
158 void pc_nic_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
159 void pc_pci_device_init(PCIBus
*pci_bus
);
161 typedef void (*cpu_set_smm_t
)(int smm
, void *arg
);
162 void cpu_smm_register(cpu_set_smm_t callback
, void *arg
);
164 void ioapic_init_gsi(GSIState
*gsi_state
, const char *parent_name
);
168 I2CBus
*piix4_pm_init(PCIBus
*bus
, int devfn
, uint32_t smb_io_base
,
169 qemu_irq sci_irq
, qemu_irq smi_irq
,
170 int kvm_enabled
, FWCfgState
*fw_cfg
);
171 void piix4_smbus_register_device(SMBusDevice
*dev
, uint8_t addr
);
177 struct PCII440FXState
;
178 typedef struct PCII440FXState PCII440FXState
;
180 PCIBus
*i440fx_init(PCII440FXState
**pi440fx_state
, int *piix_devfn
,
181 ISABus
**isa_bus
, qemu_irq
*pic
,
182 MemoryRegion
*address_space_mem
,
183 MemoryRegion
*address_space_io
,
185 ram_addr_t below_4g_mem_size
,
186 ram_addr_t above_4g_mem_size
,
187 MemoryRegion
*pci_memory
,
188 MemoryRegion
*ram_memory
);
190 PCIBus
*find_i440fx(void);
192 extern PCIDevice
*piix4_dev
;
193 int piix4_init(PCIBus
*bus
, ISABus
**isa_bus
, int devfn
);
196 enum vga_retrace_method
{
201 extern enum vga_retrace_method vga_retrace_method
;
203 int isa_vga_mm_init(hwaddr vram_base
,
204 hwaddr ctrl_base
, int it_shift
,
205 MemoryRegion
*address_space
);
208 static inline bool isa_ne2000_init(ISABus
*bus
, int base
, int irq
, NICInfo
*nd
)
213 qemu_check_nic_model(nd
, "ne2k_isa");
215 isadev
= isa_try_create(bus
, "ne2k_isa");
219 dev
= DEVICE(isadev
);
220 qdev_prop_set_uint32(dev
, "iobase", base
);
221 qdev_prop_set_uint32(dev
, "irq", irq
);
222 qdev_set_nic_properties(dev
, nd
);
223 qdev_init_nofail(dev
);
228 void pc_system_firmware_init(MemoryRegion
*rom_memory
,
232 uint16_t pvpanic_port(void);
236 #define E820_RESERVED 2
239 #define E820_UNUSABLE 5
241 int e820_add_entry(uint64_t, uint64_t, uint32_t);
242 int e820_get_num_entries(void);
243 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
245 #define PC_Q35_COMPAT_2_0 \
248 #define PC_Q35_COMPAT_1_7 \
253 .property = HPET_INTCAP,\
254 .value = stringify(4),\
257 #define PC_Q35_COMPAT_1_6 \
261 #define PC_Q35_COMPAT_1_5 \
265 #define PC_Q35_COMPAT_1_4 \
269 #define PC_COMPAT_2_0 \
273 #define PC_COMPAT_1_7 \
276 .driver = TYPE_USB_DEVICE,\
277 .property = "msos-desc",\
281 .driver = "PIIX4_PM",\
282 .property = "acpi-pci-hotplug-with-bridge-support",\
286 #define PC_COMPAT_1_6 \
290 .property = "mitigation",\
293 .driver = "qemu64-" TYPE_X86_CPU,\
294 .property = "model",\
295 .value = stringify(2),\
297 .driver = "qemu32-" TYPE_X86_CPU,\
298 .property = "model",\
299 .value = stringify(3),\
301 .driver = "i440FX-pcihost",\
302 .property = "short_root_bus",\
303 .value = stringify(1),\
305 .driver = "q35-pcihost",\
306 .property = "short_root_bus",\
307 .value = stringify(1),\
310 #define PC_COMPAT_1_5 \
313 .driver = "Conroe-" TYPE_X86_CPU,\
314 .property = "model",\
315 .value = stringify(2),\
317 .driver = "Conroe-" TYPE_X86_CPU,\
318 .property = "level",\
319 .value = stringify(2),\
321 .driver = "Penryn-" TYPE_X86_CPU,\
322 .property = "model",\
323 .value = stringify(2),\
325 .driver = "Penryn-" TYPE_X86_CPU,\
326 .property = "level",\
327 .value = stringify(2),\
329 .driver = "Nehalem-" TYPE_X86_CPU,\
330 .property = "model",\
331 .value = stringify(2),\
333 .driver = "Nehalem-" TYPE_X86_CPU,\
334 .property = "level",\
335 .value = stringify(2),\
337 .driver = "virtio-net-pci",\
338 .property = "any_layout",\
341 .driver = TYPE_X86_CPU,\
345 .driver = "i440FX-pcihost",\
346 .property = "short_root_bus",\
347 .value = stringify(0),\
349 .driver = "q35-pcihost",\
350 .property = "short_root_bus",\
351 .value = stringify(0),\
354 #define PC_COMPAT_1_4 \
357 .driver = "scsi-hd",\
358 .property = "discard_granularity",\
359 .value = stringify(0),\
361 .driver = "scsi-cd",\
362 .property = "discard_granularity",\
363 .value = stringify(0),\
365 .driver = "scsi-disk",\
366 .property = "discard_granularity",\
367 .value = stringify(0),\
370 .property = "discard_granularity",\
371 .value = stringify(0),\
374 .property = "discard_granularity",\
375 .value = stringify(0),\
377 .driver = "ide-drive",\
378 .property = "discard_granularity",\
379 .value = stringify(0),\
381 .driver = "virtio-blk-pci",\
382 .property = "discard_granularity",\
383 .value = stringify(0),\
385 .driver = "virtio-serial-pci",\
386 .property = "vectors",\
387 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
388 .value = stringify(0xFFFFFFFF),\
390 .driver = "virtio-net-pci", \
391 .property = "ctrl_guest_offloads", \
395 .property = "romfile",\
396 .value = "pxe-e1000.rom",\
398 .driver = "ne2k_pci",\
399 .property = "romfile",\
400 .value = "pxe-ne2k_pci.rom",\
403 .property = "romfile",\
404 .value = "pxe-pcnet.rom",\
406 .driver = "rtl8139",\
407 .property = "romfile",\
408 .value = "pxe-rtl8139.rom",\
410 .driver = "virtio-net-pci",\
411 .property = "romfile",\
412 .value = "pxe-virtio.rom",\
414 .driver = "486-" TYPE_X86_CPU,\
415 .property = "model",\
416 .value = stringify(0),\
419 #define PC_COMMON_MACHINE_OPTIONS \
420 .default_boot_order = "cad"
422 #define PC_DEFAULT_MACHINE_OPTIONS \
423 PC_COMMON_MACHINE_OPTIONS, \
424 .hot_add_cpu = pc_hot_add_cpu, \