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"
13 /* PC-style peripherals (also used by other machines). */
15 typedef struct PcPciInfo
{
27 static inline bool parallel_init(ISABus
*bus
, int index
, CharDriverState
*chr
)
32 isadev
= isa_try_create(bus
, "isa-parallel");
37 qdev_prop_set_uint32(dev
, "index", index
);
38 qdev_prop_set_chr(dev
, "chardev", chr
);
39 if (qdev_init(dev
) < 0) {
45 bool parallel_mm_init(MemoryRegion
*address_space
,
46 hwaddr base
, int it_shift
, qemu_irq irq
,
47 CharDriverState
*chr
);
51 extern DeviceState
*isa_pic
;
52 qemu_irq
*i8259_init(ISABus
*bus
, qemu_irq parent_irq
);
53 qemu_irq
*kvm_i8259_init(ISABus
*bus
);
54 int pic_read_irq(DeviceState
*d
);
55 int pic_get_output(DeviceState
*d
);
56 void pic_info(Monitor
*mon
, const QDict
*qdict
);
57 void irq_info(Monitor
*mon
, const QDict
*qdict
);
59 /* Global System Interrupts */
61 #define GSI_NUM_PINS IOAPIC_NUM_PINS
63 typedef struct GSIState
{
64 qemu_irq i8259_irq
[ISA_NUM_IRQS
];
65 qemu_irq ioapic_irq
[IOAPIC_NUM_PINS
];
68 void gsi_handler(void *opaque
, int n
, int level
);
71 typedef uint32_t (VMPortReadFunc
)(void *opaque
, uint32_t address
);
73 static inline void vmport_init(ISABus
*bus
)
75 isa_create_simple(bus
, "vmport");
78 void vmport_register(unsigned char command
, VMPortReadFunc
*func
, void *opaque
);
79 void vmmouse_get_data(uint32_t *data
);
80 void vmmouse_set_data(const uint32_t *data
);
84 void i8042_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
, uint32_t io_base
);
85 void i8042_mm_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
,
86 MemoryRegion
*region
, ram_addr_t size
,
88 void i8042_isa_mouse_fake_event(void *opaque
);
89 void i8042_setup_a20_line(ISADevice
*dev
, qemu_irq
*a20_out
);
92 extern int fd_bootchk
;
94 void pc_register_ferr_irq(qemu_irq irq
);
95 void pc_acpi_smi_interrupt(void *opaque
, int irq
, int level
);
97 void pc_cpus_init(const char *cpu_model
, DeviceState
*icc_bridge
);
98 void pc_hot_add_cpu(const int64_t id
, Error
**errp
);
99 void pc_acpi_init(const char *default_dsdt
);
101 PcGuestInfo
*pc_guest_info_init(ram_addr_t below_4g_mem_size
,
102 ram_addr_t above_4g_mem_size
);
104 #define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start"
105 #define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
106 #define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
107 #define PCI_HOST_PROP_PCI_HOLE64_END "pci-hole64-end"
108 #define PCI_HOST_PROP_PCI_HOLE64_SIZE "pci-hole64-size"
109 #define DEFAULT_PCI_HOLE64_SIZE (~0x0ULL)
111 static inline uint64_t pci_host_get_hole64_size(uint64_t pci_hole64_size
)
113 if (pci_hole64_size
== DEFAULT_PCI_HOLE64_SIZE
) {
116 return pci_hole64_size
;
120 void pc_init_pci64_hole(PcPciInfo
*pci_info
, uint64_t pci_hole64_start
,
121 uint64_t pci_hole64_size
);
123 FWCfgState
*pc_memory_init(MemoryRegion
*system_memory
,
124 const char *kernel_filename
,
125 const char *kernel_cmdline
,
126 const char *initrd_filename
,
127 ram_addr_t below_4g_mem_size
,
128 ram_addr_t above_4g_mem_size
,
129 MemoryRegion
*rom_memory
,
130 MemoryRegion
**ram_memory
,
131 PcGuestInfo
*guest_info
);
132 qemu_irq
*pc_allocate_cpu_irq(void);
133 DeviceState
*pc_vga_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
134 void pc_basic_device_init(ISABus
*isa_bus
, qemu_irq
*gsi
,
135 ISADevice
**rtc_state
,
138 void pc_init_ne2k_isa(ISABus
*bus
, NICInfo
*nd
);
139 void pc_cmos_init(ram_addr_t ram_size
, ram_addr_t above_4g_mem_size
,
140 const char *boot_device
,
141 ISADevice
*floppy
, BusState
*ide0
, BusState
*ide1
,
143 void pc_nic_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
144 void pc_pci_device_init(PCIBus
*pci_bus
);
146 typedef void (*cpu_set_smm_t
)(int smm
, void *arg
);
147 void cpu_smm_register(cpu_set_smm_t callback
, void *arg
);
149 void ioapic_init_gsi(GSIState
*gsi_state
, const char *parent_name
);
153 i2c_bus
*piix4_pm_init(PCIBus
*bus
, int devfn
, uint32_t smb_io_base
,
154 qemu_irq sci_irq
, qemu_irq smi_irq
,
155 int kvm_enabled
, FWCfgState
*fw_cfg
);
156 void piix4_smbus_register_device(SMBusDevice
*dev
, uint8_t addr
);
162 struct PCII440FXState
;
163 typedef struct PCII440FXState PCII440FXState
;
165 PCIBus
*i440fx_init(PCII440FXState
**pi440fx_state
, int *piix_devfn
,
166 ISABus
**isa_bus
, qemu_irq
*pic
,
167 MemoryRegion
*address_space_mem
,
168 MemoryRegion
*address_space_io
,
170 hwaddr pci_hole_start
,
171 hwaddr pci_hole_size
,
172 ram_addr_t above_4g_mem_size
,
173 MemoryRegion
*pci_memory
,
174 MemoryRegion
*ram_memory
);
177 extern PCIDevice
*piix4_dev
;
178 int piix4_init(PCIBus
*bus
, ISABus
**isa_bus
, int devfn
);
181 enum vga_retrace_method
{
186 extern enum vga_retrace_method vga_retrace_method
;
188 int isa_vga_mm_init(hwaddr vram_base
,
189 hwaddr ctrl_base
, int it_shift
,
190 MemoryRegion
*address_space
);
193 static inline bool isa_ne2000_init(ISABus
*bus
, int base
, int irq
, NICInfo
*nd
)
198 qemu_check_nic_model(nd
, "ne2k_isa");
200 isadev
= isa_try_create(bus
, "ne2k_isa");
204 dev
= DEVICE(isadev
);
205 qdev_prop_set_uint32(dev
, "iobase", base
);
206 qdev_prop_set_uint32(dev
, "irq", irq
);
207 qdev_set_nic_properties(dev
, nd
);
208 qdev_init_nofail(dev
);
213 void pc_system_firmware_init(MemoryRegion
*rom_memory
,
217 void pvpanic_init(ISABus
*bus
);
221 #define E820_RESERVED 2
224 #define E820_UNUSABLE 5
226 int e820_add_entry(uint64_t, uint64_t, uint32_t);
228 #define PC_COMPAT_1_6 \
231 .property = "mitigation",\
235 #define PC_COMPAT_1_5 \
238 .driver = "Conroe-" TYPE_X86_CPU,\
239 .property = "model",\
240 .value = stringify(2),\
242 .driver = "Conroe-" TYPE_X86_CPU,\
243 .property = "level",\
244 .value = stringify(2),\
246 .driver = "Penryn-" TYPE_X86_CPU,\
247 .property = "model",\
248 .value = stringify(2),\
250 .driver = "Penryn-" TYPE_X86_CPU,\
251 .property = "level",\
252 .value = stringify(2),\
254 .driver = "Nehalem-" TYPE_X86_CPU,\
255 .property = "model",\
256 .value = stringify(2),\
258 .driver = "Nehalem-" TYPE_X86_CPU,\
259 .property = "level",\
260 .value = stringify(2),\
262 .driver = "virtio-net-pci",\
263 .property = "any_layout",\
266 .driver = TYPE_X86_CPU,\
271 #define PC_COMPAT_1_4 \
274 .driver = "scsi-hd",\
275 .property = "discard_granularity",\
276 .value = stringify(0),\
278 .driver = "scsi-cd",\
279 .property = "discard_granularity",\
280 .value = stringify(0),\
282 .driver = "scsi-disk",\
283 .property = "discard_granularity",\
284 .value = stringify(0),\
287 .property = "discard_granularity",\
288 .value = stringify(0),\
291 .property = "discard_granularity",\
292 .value = stringify(0),\
294 .driver = "ide-drive",\
295 .property = "discard_granularity",\
296 .value = stringify(0),\
298 .driver = "virtio-blk-pci",\
299 .property = "discard_granularity",\
300 .value = stringify(0),\
302 .driver = "virtio-serial-pci",\
303 .property = "vectors",\
304 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
305 .value = stringify(0xFFFFFFFF),\
307 .driver = "virtio-net-pci", \
308 .property = "ctrl_guest_offloads", \
312 .property = "romfile",\
313 .value = "pxe-e1000.rom",\
315 .driver = "ne2k_pci",\
316 .property = "romfile",\
317 .value = "pxe-ne2k_pci.rom",\
320 .property = "romfile",\
321 .value = "pxe-pcnet.rom",\
323 .driver = "rtl8139",\
324 .property = "romfile",\
325 .value = "pxe-rtl8139.rom",\
327 .driver = "virtio-net-pci",\
328 .property = "romfile",\
329 .value = "pxe-virtio.rom",\
331 .driver = "486-" TYPE_X86_CPU,\
332 .property = "model",\
333 .value = stringify(0),\
336 #define PC_COMMON_MACHINE_OPTIONS \
337 .default_boot_order = "cad"
339 #define PC_DEFAULT_MACHINE_OPTIONS \
340 PC_COMMON_MACHINE_OPTIONS, \
341 .hot_add_cpu = pc_hot_add_cpu, \