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