4 #include "qemu-common.h"
5 #include "exec/memory.h"
6 #include "exec/ioport.h"
7 #include "hw/isa/isa.h"
8 #include "hw/block/fdc.h"
10 #include "hw/i386/ioapic.h"
11 #include "hw/nvram/fw_cfg.h"
13 /* PC-style peripherals (also used by other machines). */
16 static inline bool parallel_init(ISABus
*bus
, int index
, CharDriverState
*chr
)
20 dev
= isa_try_create(bus
, "isa-parallel");
24 qdev_prop_set_uint32(&dev
->qdev
, "index", index
);
25 qdev_prop_set_chr(&dev
->qdev
, "chardev", chr
);
26 if (qdev_init(&dev
->qdev
) < 0) {
32 bool parallel_mm_init(MemoryRegion
*address_space
,
33 hwaddr base
, int it_shift
, qemu_irq irq
,
34 CharDriverState
*chr
);
38 extern DeviceState
*isa_pic
;
39 qemu_irq
*i8259_init(ISABus
*bus
, qemu_irq parent_irq
);
40 qemu_irq
*kvm_i8259_init(ISABus
*bus
);
41 int pic_read_irq(DeviceState
*d
);
42 int pic_get_output(DeviceState
*d
);
43 void pic_info(Monitor
*mon
, const QDict
*qdict
);
44 void irq_info(Monitor
*mon
, const QDict
*qdict
);
46 /* Global System Interrupts */
48 #define GSI_NUM_PINS IOAPIC_NUM_PINS
50 typedef struct GSIState
{
51 qemu_irq i8259_irq
[ISA_NUM_IRQS
];
52 qemu_irq ioapic_irq
[IOAPIC_NUM_PINS
];
55 void gsi_handler(void *opaque
, int n
, int level
);
58 static inline void vmport_init(ISABus
*bus
)
60 isa_create_simple(bus
, "vmport");
62 void vmport_register(unsigned char command
, IOPortReadFunc
*func
, void *opaque
);
63 void vmmouse_get_data(uint32_t *data
);
64 void vmmouse_set_data(const uint32_t *data
);
68 void i8042_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
, uint32_t io_base
);
69 void i8042_mm_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
,
70 MemoryRegion
*region
, ram_addr_t size
,
72 void i8042_isa_mouse_fake_event(void *opaque
);
73 void i8042_setup_a20_line(ISADevice
*dev
, qemu_irq
*a20_out
);
76 extern int fd_bootchk
;
78 void pc_register_ferr_irq(qemu_irq irq
);
79 void pc_acpi_smi_interrupt(void *opaque
, int irq
, int level
);
81 void pc_cpus_init(const char *cpu_model
, DeviceState
*icc_bridge
);
82 void pc_hot_add_cpu(const int64_t id
, Error
**errp
);
83 void pc_acpi_init(const char *default_dsdt
);
84 FWCfgState
*pc_memory_init(MemoryRegion
*system_memory
,
85 const char *kernel_filename
,
86 const char *kernel_cmdline
,
87 const char *initrd_filename
,
88 ram_addr_t below_4g_mem_size
,
89 ram_addr_t above_4g_mem_size
,
90 MemoryRegion
*rom_memory
,
91 MemoryRegion
**ram_memory
);
92 qemu_irq
*pc_allocate_cpu_irq(void);
93 DeviceState
*pc_vga_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
94 void pc_basic_device_init(ISABus
*isa_bus
, qemu_irq
*gsi
,
95 ISADevice
**rtc_state
,
98 void pc_init_ne2k_isa(ISABus
*bus
, NICInfo
*nd
);
99 void pc_cmos_init(ram_addr_t ram_size
, ram_addr_t above_4g_mem_size
,
100 const char *boot_device
,
101 ISADevice
*floppy
, BusState
*ide0
, BusState
*ide1
,
103 void pc_nic_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
104 void pc_pci_device_init(PCIBus
*pci_bus
);
106 typedef void (*cpu_set_smm_t
)(int smm
, void *arg
);
107 void cpu_smm_register(cpu_set_smm_t callback
, void *arg
);
109 void ioapic_init_gsi(GSIState
*gsi_state
, const char *parent_name
);
113 i2c_bus
*piix4_pm_init(PCIBus
*bus
, int devfn
, uint32_t smb_io_base
,
114 qemu_irq sci_irq
, qemu_irq smi_irq
,
115 int kvm_enabled
, FWCfgState
*fw_cfg
);
116 void piix4_smbus_register_device(SMBusDevice
*dev
, uint8_t addr
);
122 struct PCII440FXState
;
123 typedef struct PCII440FXState PCII440FXState
;
125 PCIBus
*i440fx_init(PCII440FXState
**pi440fx_state
, int *piix_devfn
,
126 ISABus
**isa_bus
, qemu_irq
*pic
,
127 MemoryRegion
*address_space_mem
,
128 MemoryRegion
*address_space_io
,
130 hwaddr pci_hole_start
,
131 hwaddr pci_hole_size
,
132 hwaddr pci_hole64_start
,
133 hwaddr pci_hole64_size
,
134 MemoryRegion
*pci_memory
,
135 MemoryRegion
*ram_memory
);
138 extern PCIDevice
*piix4_dev
;
139 int piix4_init(PCIBus
*bus
, ISABus
**isa_bus
, int devfn
);
142 enum vga_retrace_method
{
147 extern enum vga_retrace_method vga_retrace_method
;
149 int isa_vga_mm_init(hwaddr vram_base
,
150 hwaddr ctrl_base
, int it_shift
,
151 MemoryRegion
*address_space
);
154 static inline bool isa_ne2000_init(ISABus
*bus
, int base
, int irq
, NICInfo
*nd
)
158 qemu_check_nic_model(nd
, "ne2k_isa");
160 dev
= isa_try_create(bus
, "ne2k_isa");
164 qdev_prop_set_uint32(&dev
->qdev
, "iobase", base
);
165 qdev_prop_set_uint32(&dev
->qdev
, "irq", irq
);
166 qdev_set_nic_properties(&dev
->qdev
, nd
);
167 qdev_init_nofail(&dev
->qdev
);
172 void pc_system_firmware_init(MemoryRegion
*rom_memory
);
175 int pvpanic_init(ISABus
*bus
);
179 #define E820_RESERVED 2
182 #define E820_UNUSABLE 5
184 int e820_add_entry(uint64_t, uint64_t, uint32_t);
186 #define PC_COMPAT_1_4 \
188 .driver = "scsi-hd",\
189 .property = "discard_granularity",\
190 .value = stringify(0),\
192 .driver = "scsi-cd",\
193 .property = "discard_granularity",\
194 .value = stringify(0),\
196 .driver = "scsi-disk",\
197 .property = "discard_granularity",\
198 .value = stringify(0),\
201 .property = "discard_granularity",\
202 .value = stringify(0),\
205 .property = "discard_granularity",\
206 .value = stringify(0),\
208 .driver = "ide-drive",\
209 .property = "discard_granularity",\
210 .value = stringify(0),\
212 .driver = "virtio-blk-pci",\
213 .property = "discard_granularity",\
214 .value = stringify(0),\
216 .driver = "virtio-serial-pci",\
217 .property = "vectors",\
218 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
219 .value = stringify(0xFFFFFFFF),\
221 .driver = "virtio-net-pci", \
222 .property = "ctrl_guest_offloads", \
226 .property = "romfile",\
227 .value = "pxe-e1000.rom",\
229 .driver = "ne2k_pci",\
230 .property = "romfile",\
231 .value = "pxe-ne2k_pci.rom",\
234 .property = "romfile",\
235 .value = "pxe-pcnet.rom",\
237 .driver = "rtl8139",\
238 .property = "romfile",\
239 .value = "pxe-rtl8139.rom",\
241 .driver = "virtio-net-pci",\
242 .property = "romfile",\
243 .value = "pxe-virtio.rom",\
245 .driver = "486-" TYPE_X86_CPU,\
246 .property = "model",\
247 .value = stringify(0),\