]>
Commit | Line | Data |
---|---|---|
87ecb68b PB |
1 | #ifndef HW_PC_H |
2 | #define HW_PC_H | |
376253ec AL |
3 | |
4 | #include "qemu-common.h" | |
022c62cb PB |
5 | #include "exec/memory.h" |
6 | #include "exec/ioport.h" | |
0d09e41a PB |
7 | #include "hw/isa/isa.h" |
8 | #include "hw/block/fdc.h" | |
1422e32d | 9 | #include "net/net.h" |
022c62cb | 10 | #include "exec/memory.h" |
0d09e41a | 11 | #include "hw/i386/ioapic.h" |
376253ec | 12 | |
87ecb68b PB |
13 | /* PC-style peripherals (also used by other machines). */ |
14 | ||
87ecb68b | 15 | /* parallel.c */ |
48a18b3c | 16 | static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr) |
defdb20e BS |
17 | { |
18 | ISADevice *dev; | |
19 | ||
48a18b3c | 20 | dev = isa_try_create(bus, "isa-parallel"); |
73531538 BS |
21 | if (!dev) { |
22 | return false; | |
23 | } | |
defdb20e BS |
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) { | |
27 | return false; | |
28 | } | |
29 | return true; | |
30 | } | |
31 | ||
63858cd9 | 32 | bool parallel_mm_init(MemoryRegion *address_space, |
a8170e5e | 33 | hwaddr base, int it_shift, qemu_irq irq, |
defdb20e | 34 | CharDriverState *chr); |
87ecb68b PB |
35 | |
36 | /* i8259.c */ | |
37 | ||
9aa78c42 | 38 | extern DeviceState *isa_pic; |
48a18b3c | 39 | qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq); |
10b61882 | 40 | qemu_irq *kvm_i8259_init(ISABus *bus); |
9aa78c42 JK |
41 | int pic_read_irq(DeviceState *d); |
42 | int pic_get_output(DeviceState *d); | |
84f2d0ea WX |
43 | void pic_info(Monitor *mon, const QDict *qdict); |
44 | void irq_info(Monitor *mon, const QDict *qdict); | |
87ecb68b | 45 | |
b881fbe9 | 46 | /* Global System Interrupts */ |
96051119 | 47 | |
b881fbe9 | 48 | #define GSI_NUM_PINS IOAPIC_NUM_PINS |
845773ab | 49 | |
b881fbe9 | 50 | typedef struct GSIState { |
43a0db35 | 51 | qemu_irq i8259_irq[ISA_NUM_IRQS]; |
b881fbe9 JK |
52 | qemu_irq ioapic_irq[IOAPIC_NUM_PINS]; |
53 | } GSIState; | |
54 | ||
55 | void gsi_handler(void *opaque, int n, int level); | |
845773ab | 56 | |
87ecb68b | 57 | /* vmport.c */ |
48a18b3c | 58 | static inline void vmport_init(ISABus *bus) |
6872ef61 | 59 | { |
48a18b3c | 60 | isa_create_simple(bus, "vmport"); |
6872ef61 | 61 | } |
87ecb68b | 62 | void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); |
86d86414 BS |
63 | void vmmouse_get_data(uint32_t *data); |
64 | void vmmouse_set_data(const uint32_t *data); | |
87ecb68b | 65 | |
87ecb68b PB |
66 | /* pckbd.c */ |
67 | ||
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, | |
dbff76ac | 70 | MemoryRegion *region, ram_addr_t size, |
a8170e5e | 71 | hwaddr mask); |
956a3e6b BS |
72 | void i8042_isa_mouse_fake_event(void *opaque); |
73 | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out); | |
87ecb68b | 74 | |
87ecb68b PB |
75 | /* pc.c */ |
76 | extern int fd_bootchk; | |
77 | ||
8e78eb28 | 78 | void pc_register_ferr_irq(qemu_irq irq); |
845773ab IY |
79 | void pc_acpi_smi_interrupt(void *opaque, int irq, int level); |
80 | ||
62fc403f | 81 | void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge); |
c649983b | 82 | void pc_hot_add_cpu(const int64_t id, Error **errp); |
f7e4dd6c | 83 | void pc_acpi_init(const char *default_dsdt); |
459ae5ea | 84 | void *pc_memory_init(MemoryRegion *system_memory, |
4aa63af1 | 85 | const char *kernel_filename, |
845773ab IY |
86 | const char *kernel_cmdline, |
87 | const char *initrd_filename, | |
e0e7e67b | 88 | ram_addr_t below_4g_mem_size, |
ae0a5466 | 89 | ram_addr_t above_4g_mem_size, |
4463aee6 | 90 | MemoryRegion *rom_memory, |
ae0a5466 | 91 | MemoryRegion **ram_memory); |
845773ab | 92 | qemu_irq *pc_allocate_cpu_irq(void); |
48a18b3c HP |
93 | DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); |
94 | void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, | |
1611977c | 95 | ISADevice **rtc_state, |
34d4260e | 96 | ISADevice **floppy, |
1611977c | 97 | bool no_vmport); |
48a18b3c | 98 | void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd); |
845773ab | 99 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, |
c0897e0c | 100 | const char *boot_device, |
34d4260e | 101 | ISADevice *floppy, BusState *ide0, BusState *ide1, |
63ffb564 | 102 | ISADevice *s); |
9011a1a7 | 103 | void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus); |
845773ab | 104 | void pc_pci_device_init(PCIBus *pci_bus); |
8e78eb28 | 105 | |
f885f1ea IY |
106 | typedef void (*cpu_set_smm_t)(int smm, void *arg); |
107 | void cpu_smm_register(cpu_set_smm_t callback, void *arg); | |
108 | ||
a39e3564 JB |
109 | void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); |
110 | ||
9d5e77a2 | 111 | /* acpi_piix.c */ |
53b67b30 | 112 | |
cf7a2fe2 | 113 | i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, |
da98c8eb | 114 | qemu_irq sci_irq, qemu_irq smi_irq, |
459ae5ea | 115 | int kvm_enabled, void *fw_cfg); |
87ecb68b | 116 | void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr); |
87ecb68b | 117 | |
16b29ae1 AL |
118 | /* hpet.c */ |
119 | extern int no_hpet; | |
120 | ||
87ecb68b | 121 | /* piix_pci.c */ |
0a3bacf3 JQ |
122 | struct PCII440FXState; |
123 | typedef struct PCII440FXState PCII440FXState; | |
124 | ||
1e39101c | 125 | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, |
60573079 | 126 | ISABus **isa_bus, qemu_irq *pic, |
aee97b84 AK |
127 | MemoryRegion *address_space_mem, |
128 | MemoryRegion *address_space_io, | |
ae0a5466 | 129 | ram_addr_t ram_size, |
a8170e5e AK |
130 | hwaddr pci_hole_start, |
131 | hwaddr pci_hole_size, | |
132 | hwaddr pci_hole64_start, | |
133 | hwaddr pci_hole64_size, | |
ae0a5466 AK |
134 | MemoryRegion *pci_memory, |
135 | MemoryRegion *ram_memory); | |
87ecb68b | 136 | |
823e675a | 137 | /* piix4.c */ |
b1d8e52e | 138 | extern PCIDevice *piix4_dev; |
142e9787 | 139 | int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn); |
87ecb68b PB |
140 | |
141 | /* vga.c */ | |
cb5a7aa8 | 142 | enum vga_retrace_method { |
143 | VGA_RETRACE_DUMB, | |
144 | VGA_RETRACE_PRECISE | |
145 | }; | |
146 | ||
147 | extern enum vga_retrace_method vga_retrace_method; | |
87ecb68b | 148 | |
a8170e5e AK |
149 | int isa_vga_mm_init(hwaddr vram_base, |
150 | hwaddr ctrl_base, int it_shift, | |
be20f9e9 | 151 | MemoryRegion *address_space); |
87ecb68b | 152 | |
87ecb68b | 153 | /* ne2000.c */ |
48a18b3c | 154 | static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd) |
60a14ad3 BS |
155 | { |
156 | ISADevice *dev; | |
87ecb68b | 157 | |
60a14ad3 BS |
158 | qemu_check_nic_model(nd, "ne2k_isa"); |
159 | ||
48a18b3c | 160 | dev = isa_try_create(bus, "ne2k_isa"); |
cd1b8a8b BS |
161 | if (!dev) { |
162 | return false; | |
163 | } | |
60a14ad3 BS |
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); | |
cd1b8a8b | 168 | return true; |
60a14ad3 | 169 | } |
87ecb68b | 170 | |
cbc5b5f3 | 171 | /* pc_sysfw.c */ |
9953f882 | 172 | extern bool pc_sysfw_flash_vs_rom_bug_compatible; |
cbc5b5f3 JJ |
173 | void pc_system_firmware_init(MemoryRegion *rom_memory); |
174 | ||
3ab135f3 HT |
175 | /* pvpanic.c */ |
176 | int pvpanic_init(ISABus *bus); | |
177 | ||
4c5b10b7 JS |
178 | /* e820 types */ |
179 | #define E820_RAM 1 | |
180 | #define E820_RESERVED 2 | |
181 | #define E820_ACPI 3 | |
182 | #define E820_NVS 4 | |
183 | #define E820_UNUSABLE 5 | |
184 | ||
185 | int e820_add_entry(uint64_t, uint64_t, uint32_t); | |
186 | ||
bf3caa3d PB |
187 | #define PC_COMPAT_1_4 \ |
188 | {\ | |
189 | .driver = "scsi-hd",\ | |
190 | .property = "discard_granularity",\ | |
191 | .value = stringify(0),\ | |
192 | },{\ | |
193 | .driver = "scsi-cd",\ | |
194 | .property = "discard_granularity",\ | |
195 | .value = stringify(0),\ | |
196 | },{\ | |
197 | .driver = "scsi-disk",\ | |
198 | .property = "discard_granularity",\ | |
199 | .value = stringify(0),\ | |
200 | },{\ | |
201 | .driver = "ide-hd",\ | |
202 | .property = "discard_granularity",\ | |
203 | .value = stringify(0),\ | |
204 | },{\ | |
205 | .driver = "ide-cd",\ | |
206 | .property = "discard_granularity",\ | |
207 | .value = stringify(0),\ | |
208 | },{\ | |
209 | .driver = "ide-drive",\ | |
210 | .property = "discard_granularity",\ | |
211 | .value = stringify(0),\ | |
c45e5b5b | 212 | },{\ |
bf3caa3d PB |
213 | .driver = "virtio-blk-pci",\ |
214 | .property = "discard_granularity",\ | |
215 | .value = stringify(0),\ | |
554f1997 GH |
216 | },{\ |
217 | .driver = "virtio-serial-pci",\ | |
218 | .property = "vectors",\ | |
219 | /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\ | |
220 | .value = stringify(0xFFFFFFFF),\ | |
c45e5b5b GH |
221 | },{\ |
222 | .driver = "e1000",\ | |
223 | .property = "romfile",\ | |
224 | .value = "pxe-e1000.rom",\ | |
225 | },{\ | |
226 | .driver = "ne2k_pci",\ | |
227 | .property = "romfile",\ | |
228 | .value = "pxe-ne2k_pci.rom",\ | |
229 | },{\ | |
230 | .driver = "pcnet",\ | |
231 | .property = "romfile",\ | |
232 | .value = "pxe-pcnet.rom",\ | |
233 | },{\ | |
234 | .driver = "rtl8139",\ | |
235 | .property = "romfile",\ | |
236 | .value = "pxe-rtl8139.rom",\ | |
237 | },{\ | |
238 | .driver = "virtio-net-pci",\ | |
239 | .property = "romfile",\ | |
240 | .value = "pxe-virtio.rom",\ | |
9953f882 MA |
241 | },{\ |
242 | .driver = "pc-sysfw",\ | |
243 | .property = "rom_only",\ | |
244 | .value = stringify(0),\ | |
c45e5b5b | 245 | } |
bf3caa3d | 246 | |
87ecb68b | 247 | #endif |