]>
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 MT |
11 | #include "qemu/range.h" |
12 | ||
87ecb68b PB |
13 | /* PC-style peripherals (also used by other machines). */ |
14 | ||
3459a625 MT |
15 | typedef struct PcPciInfo { |
16 | Range w32; | |
17 | Range w64; | |
18 | } PcPciInfo; | |
19 | ||
20 | struct PcGuestInfo { | |
f8c457b8 | 21 | bool has_pci_info; |
6dd2a5c9 | 22 | bool isapc_ram_fw; |
3459a625 MT |
23 | FWCfgState *fw_cfg; |
24 | }; | |
25 | ||
87ecb68b | 26 | /* parallel.c */ |
48a18b3c | 27 | static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr) |
defdb20e | 28 | { |
4a17cc4f AF |
29 | DeviceState *dev; |
30 | ISADevice *isadev; | |
defdb20e | 31 | |
4a17cc4f AF |
32 | isadev = isa_try_create(bus, "isa-parallel"); |
33 | if (!isadev) { | |
73531538 BS |
34 | return false; |
35 | } | |
4a17cc4f AF |
36 | dev = DEVICE(isadev); |
37 | qdev_prop_set_uint32(dev, "index", index); | |
38 | qdev_prop_set_chr(dev, "chardev", chr); | |
39 | if (qdev_init(dev) < 0) { | |
defdb20e BS |
40 | return false; |
41 | } | |
42 | return true; | |
43 | } | |
44 | ||
63858cd9 | 45 | bool parallel_mm_init(MemoryRegion *address_space, |
a8170e5e | 46 | hwaddr base, int it_shift, qemu_irq irq, |
defdb20e | 47 | CharDriverState *chr); |
87ecb68b PB |
48 | |
49 | /* i8259.c */ | |
50 | ||
9aa78c42 | 51 | extern DeviceState *isa_pic; |
48a18b3c | 52 | qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq); |
10b61882 | 53 | qemu_irq *kvm_i8259_init(ISABus *bus); |
9aa78c42 JK |
54 | int pic_read_irq(DeviceState *d); |
55 | int pic_get_output(DeviceState *d); | |
84f2d0ea WX |
56 | void pic_info(Monitor *mon, const QDict *qdict); |
57 | void irq_info(Monitor *mon, const QDict *qdict); | |
87ecb68b | 58 | |
b881fbe9 | 59 | /* Global System Interrupts */ |
96051119 | 60 | |
b881fbe9 | 61 | #define GSI_NUM_PINS IOAPIC_NUM_PINS |
845773ab | 62 | |
b881fbe9 | 63 | typedef struct GSIState { |
43a0db35 | 64 | qemu_irq i8259_irq[ISA_NUM_IRQS]; |
b881fbe9 JK |
65 | qemu_irq ioapic_irq[IOAPIC_NUM_PINS]; |
66 | } GSIState; | |
67 | ||
68 | void gsi_handler(void *opaque, int n, int level); | |
845773ab | 69 | |
87ecb68b | 70 | /* vmport.c */ |
d67f679d JK |
71 | typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); |
72 | ||
48a18b3c | 73 | static inline void vmport_init(ISABus *bus) |
6872ef61 | 74 | { |
48a18b3c | 75 | isa_create_simple(bus, "vmport"); |
6872ef61 | 76 | } |
d67f679d JK |
77 | |
78 | void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque); | |
86d86414 BS |
79 | void vmmouse_get_data(uint32_t *data); |
80 | void vmmouse_set_data(const uint32_t *data); | |
87ecb68b | 81 | |
87ecb68b PB |
82 | /* pckbd.c */ |
83 | ||
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, | |
dbff76ac | 86 | MemoryRegion *region, ram_addr_t size, |
a8170e5e | 87 | hwaddr mask); |
956a3e6b BS |
88 | void i8042_isa_mouse_fake_event(void *opaque); |
89 | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out); | |
87ecb68b | 90 | |
87ecb68b PB |
91 | /* pc.c */ |
92 | extern int fd_bootchk; | |
93 | ||
8e78eb28 | 94 | void pc_register_ferr_irq(qemu_irq irq); |
845773ab IY |
95 | void pc_acpi_smi_interrupt(void *opaque, int irq, int level); |
96 | ||
62fc403f | 97 | void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge); |
c649983b | 98 | void pc_hot_add_cpu(const int64_t id, Error **errp); |
f7e4dd6c | 99 | void pc_acpi_init(const char *default_dsdt); |
3459a625 MT |
100 | |
101 | PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, | |
102 | ram_addr_t above_4g_mem_size); | |
103 | ||
39848901 IM |
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" | |
1466cef3 MT |
109 | #define DEFAULT_PCI_HOLE64_SIZE (~0x0ULL) |
110 | ||
111 | static inline uint64_t pci_host_get_hole64_size(uint64_t pci_hole64_size) | |
112 | { | |
113 | if (pci_hole64_size == DEFAULT_PCI_HOLE64_SIZE) { | |
114 | return 1ULL << 62; | |
115 | } else { | |
116 | return pci_hole64_size; | |
117 | } | |
118 | } | |
39848901 IM |
119 | |
120 | void pc_init_pci64_hole(PcPciInfo *pci_info, uint64_t pci_hole64_start, | |
121 | uint64_t pci_hole64_size); | |
122 | ||
a88b362c LE |
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, | |
3459a625 MT |
130 | MemoryRegion **ram_memory, |
131 | PcGuestInfo *guest_info); | |
845773ab | 132 | qemu_irq *pc_allocate_cpu_irq(void); |
48a18b3c HP |
133 | DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); |
134 | void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, | |
1611977c | 135 | ISADevice **rtc_state, |
34d4260e | 136 | ISADevice **floppy, |
1611977c | 137 | bool no_vmport); |
48a18b3c | 138 | void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd); |
845773ab | 139 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, |
c0897e0c | 140 | const char *boot_device, |
34d4260e | 141 | ISADevice *floppy, BusState *ide0, BusState *ide1, |
63ffb564 | 142 | ISADevice *s); |
9011a1a7 | 143 | void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus); |
845773ab | 144 | void pc_pci_device_init(PCIBus *pci_bus); |
8e78eb28 | 145 | |
f885f1ea IY |
146 | typedef void (*cpu_set_smm_t)(int smm, void *arg); |
147 | void cpu_smm_register(cpu_set_smm_t callback, void *arg); | |
148 | ||
a39e3564 JB |
149 | void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); |
150 | ||
9d5e77a2 | 151 | /* acpi_piix.c */ |
53b67b30 | 152 | |
cf7a2fe2 | 153 | i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, |
da98c8eb | 154 | qemu_irq sci_irq, qemu_irq smi_irq, |
a88b362c | 155 | int kvm_enabled, FWCfgState *fw_cfg); |
87ecb68b | 156 | void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr); |
87ecb68b | 157 | |
16b29ae1 AL |
158 | /* hpet.c */ |
159 | extern int no_hpet; | |
160 | ||
87ecb68b | 161 | /* piix_pci.c */ |
0a3bacf3 JQ |
162 | struct PCII440FXState; |
163 | typedef struct PCII440FXState PCII440FXState; | |
164 | ||
1e39101c | 165 | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, |
60573079 | 166 | ISABus **isa_bus, qemu_irq *pic, |
aee97b84 AK |
167 | MemoryRegion *address_space_mem, |
168 | MemoryRegion *address_space_io, | |
ae0a5466 | 169 | ram_addr_t ram_size, |
a8170e5e AK |
170 | hwaddr pci_hole_start, |
171 | hwaddr pci_hole_size, | |
39848901 | 172 | ram_addr_t above_4g_mem_size, |
ae0a5466 AK |
173 | MemoryRegion *pci_memory, |
174 | MemoryRegion *ram_memory); | |
87ecb68b | 175 | |
823e675a | 176 | /* piix4.c */ |
b1d8e52e | 177 | extern PCIDevice *piix4_dev; |
142e9787 | 178 | int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn); |
87ecb68b PB |
179 | |
180 | /* vga.c */ | |
cb5a7aa8 | 181 | enum vga_retrace_method { |
182 | VGA_RETRACE_DUMB, | |
183 | VGA_RETRACE_PRECISE | |
184 | }; | |
185 | ||
186 | extern enum vga_retrace_method vga_retrace_method; | |
87ecb68b | 187 | |
a8170e5e AK |
188 | int isa_vga_mm_init(hwaddr vram_base, |
189 | hwaddr ctrl_base, int it_shift, | |
be20f9e9 | 190 | MemoryRegion *address_space); |
87ecb68b | 191 | |
87ecb68b | 192 | /* ne2000.c */ |
48a18b3c | 193 | static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd) |
60a14ad3 | 194 | { |
4a17cc4f AF |
195 | DeviceState *dev; |
196 | ISADevice *isadev; | |
87ecb68b | 197 | |
60a14ad3 BS |
198 | qemu_check_nic_model(nd, "ne2k_isa"); |
199 | ||
4a17cc4f AF |
200 | isadev = isa_try_create(bus, "ne2k_isa"); |
201 | if (!isadev) { | |
cd1b8a8b BS |
202 | return false; |
203 | } | |
4a17cc4f AF |
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); | |
cd1b8a8b | 209 | return true; |
60a14ad3 | 210 | } |
87ecb68b | 211 | |
cbc5b5f3 | 212 | /* pc_sysfw.c */ |
6dd2a5c9 PB |
213 | void pc_system_firmware_init(MemoryRegion *rom_memory, |
214 | bool isapc_ram_fw); | |
cbc5b5f3 | 215 | |
3ab135f3 | 216 | /* pvpanic.c */ |
bc3e6a0d | 217 | void pvpanic_init(ISABus *bus); |
3ab135f3 | 218 | |
4c5b10b7 JS |
219 | /* e820 types */ |
220 | #define E820_RAM 1 | |
221 | #define E820_RESERVED 2 | |
222 | #define E820_ACPI 3 | |
223 | #define E820_NVS 4 | |
224 | #define E820_UNUSABLE 5 | |
225 | ||
226 | int e820_add_entry(uint64_t, uint64_t, uint32_t); | |
227 | ||
ffce9ebb EH |
228 | #define PC_COMPAT_1_5 \ |
229 | {\ | |
230 | .driver = "Conroe-" TYPE_X86_CPU,\ | |
231 | .property = "model",\ | |
232 | .value = stringify(2),\ | |
6b11322e EH |
233 | },{\ |
234 | .driver = "Conroe-" TYPE_X86_CPU,\ | |
235 | .property = "level",\ | |
236 | .value = stringify(2),\ | |
ffce9ebb EH |
237 | },{\ |
238 | .driver = "Penryn-" TYPE_X86_CPU,\ | |
239 | .property = "model",\ | |
240 | .value = stringify(2),\ | |
6b11322e EH |
241 | },{\ |
242 | .driver = "Penryn-" TYPE_X86_CPU,\ | |
243 | .property = "level",\ | |
244 | .value = stringify(2),\ | |
ffce9ebb EH |
245 | },{\ |
246 | .driver = "Nehalem-" TYPE_X86_CPU,\ | |
247 | .property = "model",\ | |
248 | .value = stringify(2),\ | |
6b11322e EH |
249 | },{\ |
250 | .driver = "Nehalem-" TYPE_X86_CPU,\ | |
251 | .property = "level",\ | |
252 | .value = stringify(2),\ | |
488f069b MT |
253 | },{\ |
254 | .driver = "virtio-net-pci",\ | |
255 | .property = "any_layout",\ | |
256 | .value = "off",\ | |
9337e3b6 EH |
257 | },{\ |
258 | .driver = TYPE_X86_CPU,\ | |
259 | .property = "pmu",\ | |
260 | .value = "on",\ | |
ffce9ebb EH |
261 | } |
262 | ||
bf3caa3d | 263 | #define PC_COMPAT_1_4 \ |
ffce9ebb | 264 | PC_COMPAT_1_5, \ |
bf3caa3d PB |
265 | {\ |
266 | .driver = "scsi-hd",\ | |
267 | .property = "discard_granularity",\ | |
268 | .value = stringify(0),\ | |
269 | },{\ | |
270 | .driver = "scsi-cd",\ | |
271 | .property = "discard_granularity",\ | |
272 | .value = stringify(0),\ | |
273 | },{\ | |
274 | .driver = "scsi-disk",\ | |
275 | .property = "discard_granularity",\ | |
276 | .value = stringify(0),\ | |
277 | },{\ | |
278 | .driver = "ide-hd",\ | |
279 | .property = "discard_granularity",\ | |
280 | .value = stringify(0),\ | |
281 | },{\ | |
282 | .driver = "ide-cd",\ | |
283 | .property = "discard_granularity",\ | |
284 | .value = stringify(0),\ | |
285 | },{\ | |
286 | .driver = "ide-drive",\ | |
287 | .property = "discard_granularity",\ | |
288 | .value = stringify(0),\ | |
c45e5b5b | 289 | },{\ |
bf3caa3d PB |
290 | .driver = "virtio-blk-pci",\ |
291 | .property = "discard_granularity",\ | |
292 | .value = stringify(0),\ | |
554f1997 GH |
293 | },{\ |
294 | .driver = "virtio-serial-pci",\ | |
295 | .property = "vectors",\ | |
296 | /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\ | |
297 | .value = stringify(0xFFFFFFFF),\ | |
644c9858 DF |
298 | },{ \ |
299 | .driver = "virtio-net-pci", \ | |
300 | .property = "ctrl_guest_offloads", \ | |
301 | .value = "off", \ | |
c45e5b5b GH |
302 | },{\ |
303 | .driver = "e1000",\ | |
304 | .property = "romfile",\ | |
305 | .value = "pxe-e1000.rom",\ | |
306 | },{\ | |
307 | .driver = "ne2k_pci",\ | |
308 | .property = "romfile",\ | |
309 | .value = "pxe-ne2k_pci.rom",\ | |
310 | },{\ | |
311 | .driver = "pcnet",\ | |
312 | .property = "romfile",\ | |
313 | .value = "pxe-pcnet.rom",\ | |
314 | },{\ | |
315 | .driver = "rtl8139",\ | |
316 | .property = "romfile",\ | |
317 | .value = "pxe-rtl8139.rom",\ | |
318 | },{\ | |
319 | .driver = "virtio-net-pci",\ | |
320 | .property = "romfile",\ | |
321 | .value = "pxe-virtio.rom",\ | |
b2a856d9 AF |
322 | },{\ |
323 | .driver = "486-" TYPE_X86_CPU,\ | |
324 | .property = "model",\ | |
325 | .value = stringify(0),\ | |
c45e5b5b | 326 | } |
bf3caa3d | 327 | |
87ecb68b | 328 | #endif |