root / hw / pc.h @ 3204db98
History | View | Annotate | Download (7.1 kB)
1 | 87ecb68b | pbrook | #ifndef HW_PC_H
|
---|---|---|---|
2 | 87ecb68b | pbrook | #define HW_PC_H
|
3 | 376253ec | aliguori | |
4 | 376253ec | aliguori | #include "qemu-common.h" |
5 | 00cb2a99 | Avi Kivity | #include "memory.h" |
6 | 35bed8ee | Paul Brook | #include "ioport.h" |
7 | 845773ab | Isaku Yamahata | #include "isa.h" |
8 | 845773ab | Isaku Yamahata | #include "fdc.h" |
9 | cd1b8a8b | Blue Swirl | #include "net.h" |
10 | 4aa63af1 | Avi Kivity | #include "memory.h" |
11 | b881fbe9 | Jan Kiszka | #include "ioapic.h" |
12 | 376253ec | aliguori | |
13 | 87ecb68b | pbrook | /* PC-style peripherals (also used by other machines). */
|
14 | 87ecb68b | pbrook | |
15 | 87ecb68b | pbrook | /* serial.c */
|
16 | 87ecb68b | pbrook | |
17 | b6cd0ea1 | aurel32 | SerialState *serial_init(int base, qemu_irq irq, int baudbase, |
18 | b6cd0ea1 | aurel32 | CharDriverState *chr); |
19 | 39186d8a | Richard Henderson | SerialState *serial_mm_init(MemoryRegion *address_space, |
20 | 39186d8a | Richard Henderson | target_phys_addr_t base, int it_shift,
|
21 | 39186d8a | Richard Henderson | qemu_irq irq, int baudbase,
|
22 | 39186d8a | Richard Henderson | CharDriverState *chr, enum device_endian);
|
23 | e22cf21e | Blue Swirl | static inline bool serial_isa_init(int index, CharDriverState *chr) |
24 | e22cf21e | Blue Swirl | { |
25 | e22cf21e | Blue Swirl | ISADevice *dev; |
26 | e22cf21e | Blue Swirl | |
27 | 9b13ef9f | Blue Swirl | dev = isa_try_create("isa-serial");
|
28 | 9b13ef9f | Blue Swirl | if (!dev) {
|
29 | 9b13ef9f | Blue Swirl | return false; |
30 | 9b13ef9f | Blue Swirl | } |
31 | e22cf21e | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "index", index);
|
32 | e22cf21e | Blue Swirl | qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
33 | e22cf21e | Blue Swirl | if (qdev_init(&dev->qdev) < 0) { |
34 | e22cf21e | Blue Swirl | return false; |
35 | e22cf21e | Blue Swirl | } |
36 | e22cf21e | Blue Swirl | return true; |
37 | e22cf21e | Blue Swirl | } |
38 | e22cf21e | Blue Swirl | |
39 | 038eaf82 | Stefan Weil | void serial_set_frequency(SerialState *s, uint32_t frequency);
|
40 | 87ecb68b | pbrook | |
41 | 87ecb68b | pbrook | /* parallel.c */
|
42 | defdb20e | Blue Swirl | static inline bool parallel_init(int index, CharDriverState *chr) |
43 | defdb20e | Blue Swirl | { |
44 | defdb20e | Blue Swirl | ISADevice *dev; |
45 | defdb20e | Blue Swirl | |
46 | 73531538 | Blue Swirl | dev = isa_try_create("isa-parallel");
|
47 | 73531538 | Blue Swirl | if (!dev) {
|
48 | 73531538 | Blue Swirl | return false; |
49 | 73531538 | Blue Swirl | } |
50 | defdb20e | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "index", index);
|
51 | defdb20e | Blue Swirl | qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
52 | defdb20e | Blue Swirl | if (qdev_init(&dev->qdev) < 0) { |
53 | defdb20e | Blue Swirl | return false; |
54 | defdb20e | Blue Swirl | } |
55 | defdb20e | Blue Swirl | return true; |
56 | defdb20e | Blue Swirl | } |
57 | defdb20e | Blue Swirl | |
58 | defdb20e | Blue Swirl | bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, |
59 | defdb20e | Blue Swirl | CharDriverState *chr); |
60 | 87ecb68b | pbrook | |
61 | 87ecb68b | pbrook | /* i8259.c */
|
62 | 87ecb68b | pbrook | |
63 | c17725f4 | Jan Kiszka | typedef struct PicState PicState; |
64 | c17725f4 | Jan Kiszka | extern PicState *isa_pic;
|
65 | 87ecb68b | pbrook | qemu_irq *i8259_init(qemu_irq parent_irq); |
66 | c17725f4 | Jan Kiszka | int pic_read_irq(PicState *s);
|
67 | c17725f4 | Jan Kiszka | int pic_get_output(PicState *s);
|
68 | 376253ec | aliguori | void pic_info(Monitor *mon);
|
69 | 376253ec | aliguori | void irq_info(Monitor *mon);
|
70 | 87ecb68b | pbrook | |
71 | b881fbe9 | Jan Kiszka | /* Global System Interrupts */
|
72 | 96051119 | Blue Swirl | |
73 | b881fbe9 | Jan Kiszka | #define GSI_NUM_PINS IOAPIC_NUM_PINS
|
74 | 845773ab | Isaku Yamahata | |
75 | b881fbe9 | Jan Kiszka | typedef struct GSIState { |
76 | 43a0db35 | Jan Kiszka | qemu_irq i8259_irq[ISA_NUM_IRQS]; |
77 | b881fbe9 | Jan Kiszka | qemu_irq ioapic_irq[IOAPIC_NUM_PINS]; |
78 | b881fbe9 | Jan Kiszka | } GSIState; |
79 | b881fbe9 | Jan Kiszka | |
80 | b881fbe9 | Jan Kiszka | void gsi_handler(void *opaque, int n, int level); |
81 | 845773ab | Isaku Yamahata | |
82 | 87ecb68b | pbrook | /* i8254.c */
|
83 | 87ecb68b | pbrook | |
84 | 87ecb68b | pbrook | #define PIT_FREQ 1193182 |
85 | 87ecb68b | pbrook | |
86 | 64d7e9a4 | Blue Swirl | static inline ISADevice *pit_init(int base, int irq) |
87 | 64d7e9a4 | Blue Swirl | { |
88 | 64d7e9a4 | Blue Swirl | ISADevice *dev; |
89 | 64d7e9a4 | Blue Swirl | |
90 | 64d7e9a4 | Blue Swirl | dev = isa_create("isa-pit");
|
91 | 64d7e9a4 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "iobase", base);
|
92 | 64d7e9a4 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "irq", irq);
|
93 | 64d7e9a4 | Blue Swirl | qdev_init_nofail(&dev->qdev); |
94 | 64d7e9a4 | Blue Swirl | |
95 | 64d7e9a4 | Blue Swirl | return dev;
|
96 | 64d7e9a4 | Blue Swirl | } |
97 | 87ecb68b | pbrook | |
98 | 64d7e9a4 | Blue Swirl | void pit_set_gate(ISADevice *dev, int channel, int val); |
99 | 64d7e9a4 | Blue Swirl | int pit_get_gate(ISADevice *dev, int channel); |
100 | 64d7e9a4 | Blue Swirl | int pit_get_initial_count(ISADevice *dev, int channel); |
101 | 64d7e9a4 | Blue Swirl | int pit_get_mode(ISADevice *dev, int channel); |
102 | 64d7e9a4 | Blue Swirl | int pit_get_out(ISADevice *dev, int channel, int64_t current_time); |
103 | 87ecb68b | pbrook | |
104 | bf4f74c0 | aurel32 | void hpet_pit_disable(void); |
105 | bf4f74c0 | aurel32 | void hpet_pit_enable(void); |
106 | bf4f74c0 | aurel32 | |
107 | 87ecb68b | pbrook | /* vmport.c */
|
108 | 6872ef61 | Blue Swirl | static inline void vmport_init(void) |
109 | 6872ef61 | Blue Swirl | { |
110 | 6872ef61 | Blue Swirl | isa_create_simple("vmport");
|
111 | 6872ef61 | Blue Swirl | } |
112 | 87ecb68b | pbrook | void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); |
113 | 86d86414 | Blue Swirl | void vmmouse_get_data(uint32_t *data);
|
114 | 86d86414 | Blue Swirl | void vmmouse_set_data(const uint32_t *data); |
115 | 87ecb68b | pbrook | |
116 | 87ecb68b | pbrook | /* pckbd.c */
|
117 | 87ecb68b | pbrook | |
118 | 87ecb68b | pbrook | void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
|
119 | 87ecb68b | pbrook | void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
|
120 | dbff76ac | Richard Henderson | MemoryRegion *region, ram_addr_t size, |
121 | c227f099 | Anthony Liguori | target_phys_addr_t mask); |
122 | 956a3e6b | Blue Swirl | void i8042_isa_mouse_fake_event(void *opaque); |
123 | 956a3e6b | Blue Swirl | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
|
124 | 87ecb68b | pbrook | |
125 | 87ecb68b | pbrook | /* pc.c */
|
126 | 87ecb68b | pbrook | extern int fd_bootchk; |
127 | 87ecb68b | pbrook | |
128 | 8e78eb28 | Isaku Yamahata | void pc_register_ferr_irq(qemu_irq irq);
|
129 | 845773ab | Isaku Yamahata | void pc_cmos_set_s3_resume(void *opaque, int irq, int level); |
130 | 845773ab | Isaku Yamahata | void pc_acpi_smi_interrupt(void *opaque, int irq, int level); |
131 | 845773ab | Isaku Yamahata | |
132 | 845773ab | Isaku Yamahata | void pc_cpus_init(const char *cpu_model); |
133 | 4aa63af1 | Avi Kivity | void pc_memory_init(MemoryRegion *system_memory,
|
134 | 4aa63af1 | Avi Kivity | const char *kernel_filename, |
135 | 845773ab | Isaku Yamahata | const char *kernel_cmdline, |
136 | 845773ab | Isaku Yamahata | const char *initrd_filename, |
137 | e0e7e67b | Anthony PERARD | ram_addr_t below_4g_mem_size, |
138 | ae0a5466 | Avi Kivity | ram_addr_t above_4g_mem_size, |
139 | 4463aee6 | Jan Kiszka | MemoryRegion *rom_memory, |
140 | ae0a5466 | Avi Kivity | MemoryRegion **ram_memory); |
141 | 845773ab | Isaku Yamahata | qemu_irq *pc_allocate_cpu_irq(void);
|
142 | 845773ab | Isaku Yamahata | void pc_vga_init(PCIBus *pci_bus);
|
143 | b881fbe9 | Jan Kiszka | void pc_basic_device_init(qemu_irq *gsi,
|
144 | 1611977c | Anthony PERARD | ISADevice **rtc_state, |
145 | 34d4260e | Kevin Wolf | ISADevice **floppy, |
146 | 1611977c | Anthony PERARD | bool no_vmport);
|
147 | 845773ab | Isaku Yamahata | void pc_init_ne2k_isa(NICInfo *nd);
|
148 | 845773ab | Isaku Yamahata | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
149 | c0897e0c | Markus Armbruster | const char *boot_device, |
150 | 34d4260e | Kevin Wolf | ISADevice *floppy, BusState *ide0, BusState *ide1, |
151 | 63ffb564 | Blue Swirl | ISADevice *s); |
152 | 845773ab | Isaku Yamahata | void pc_pci_device_init(PCIBus *pci_bus);
|
153 | 8e78eb28 | Isaku Yamahata | |
154 | f885f1ea | Isaku Yamahata | typedef void (*cpu_set_smm_t)(int smm, void *arg); |
155 | f885f1ea | Isaku Yamahata | void cpu_smm_register(cpu_set_smm_t callback, void *arg); |
156 | f885f1ea | Isaku Yamahata | |
157 | 87ecb68b | pbrook | /* acpi.c */
|
158 | 87ecb68b | pbrook | extern int acpi_enabled; |
159 | 80deece2 | blueswir1 | extern char *acpi_tables; |
160 | 80deece2 | blueswir1 | extern size_t acpi_tables_len;
|
161 | 80deece2 | blueswir1 | |
162 | 9d5e77a2 | Isaku Yamahata | void acpi_bios_init(void); |
163 | 9d5e77a2 | Isaku Yamahata | int acpi_table_add(const char *table_desc); |
164 | 9d5e77a2 | Isaku Yamahata | |
165 | 9d5e77a2 | Isaku Yamahata | /* acpi_piix.c */
|
166 | 53b67b30 | Blue Swirl | |
167 | cf7a2fe2 | aurel32 | i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
|
168 | 53b67b30 | Blue Swirl | qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq, |
169 | 53b67b30 | Blue Swirl | int kvm_enabled);
|
170 | 87ecb68b | pbrook | void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
|
171 | 87ecb68b | pbrook | |
172 | 16b29ae1 | aliguori | /* hpet.c */
|
173 | 16b29ae1 | aliguori | extern int no_hpet; |
174 | 16b29ae1 | aliguori | |
175 | 87ecb68b | pbrook | /* pcspk.c */
|
176 | 64d7e9a4 | Blue Swirl | void pcspk_init(ISADevice *pit);
|
177 | 22d83b14 | Paul Brook | int pcspk_audio_init(qemu_irq *pic);
|
178 | 87ecb68b | pbrook | |
179 | 87ecb68b | pbrook | /* piix_pci.c */
|
180 | 0a3bacf3 | Juan Quintela | struct PCII440FXState;
|
181 | 0a3bacf3 | Juan Quintela | typedef struct PCII440FXState PCII440FXState; |
182 | 0a3bacf3 | Juan Quintela | |
183 | 1e39101c | Avi Kivity | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
|
184 | aee97b84 | Avi Kivity | qemu_irq *pic, |
185 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
186 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io, |
187 | ae0a5466 | Avi Kivity | ram_addr_t ram_size, |
188 | ae0a5466 | Avi Kivity | target_phys_addr_t pci_hole_start, |
189 | ae0a5466 | Avi Kivity | target_phys_addr_t pci_hole_size, |
190 | ae0a5466 | Avi Kivity | target_phys_addr_t pci_hole64_start, |
191 | ae0a5466 | Avi Kivity | target_phys_addr_t pci_hole64_size, |
192 | ae0a5466 | Avi Kivity | MemoryRegion *pci_memory, |
193 | ae0a5466 | Avi Kivity | MemoryRegion *ram_memory); |
194 | 87ecb68b | pbrook | |
195 | 823e675a | Juan Quintela | /* piix4.c */
|
196 | b1d8e52e | blueswir1 | extern PCIDevice *piix4_dev;
|
197 | 87ecb68b | pbrook | int piix4_init(PCIBus *bus, int devfn); |
198 | 87ecb68b | pbrook | |
199 | 87ecb68b | pbrook | /* vga.c */
|
200 | cb5a7aa8 | malc | enum vga_retrace_method {
|
201 | cb5a7aa8 | malc | VGA_RETRACE_DUMB, |
202 | cb5a7aa8 | malc | VGA_RETRACE_PRECISE |
203 | cb5a7aa8 | malc | }; |
204 | cb5a7aa8 | malc | |
205 | cb5a7aa8 | malc | extern enum vga_retrace_method vga_retrace_method; |
206 | 87ecb68b | pbrook | |
207 | 7435b791 | Blue Swirl | static inline int isa_vga_init(void) |
208 | 7435b791 | Blue Swirl | { |
209 | c74b88df | Blue Swirl | ISADevice *dev; |
210 | 7435b791 | Blue Swirl | |
211 | c74b88df | Blue Swirl | dev = isa_try_create("isa-vga");
|
212 | c74b88df | Blue Swirl | if (!dev) {
|
213 | c74b88df | Blue Swirl | fprintf(stderr, "Warning: isa-vga not available\n");
|
214 | c74b88df | Blue Swirl | return 0; |
215 | c74b88df | Blue Swirl | } |
216 | c74b88df | Blue Swirl | qdev_init_nofail(&dev->qdev); |
217 | c74b88df | Blue Swirl | return 1; |
218 | 7435b791 | Blue Swirl | } |
219 | 7435b791 | Blue Swirl | |
220 | 78895427 | Gerd Hoffmann | int pci_vga_init(PCIBus *bus);
|
221 | c227f099 | Anthony Liguori | int isa_vga_mm_init(target_phys_addr_t vram_base,
|
222 | be20f9e9 | Avi Kivity | target_phys_addr_t ctrl_base, int it_shift,
|
223 | be20f9e9 | Avi Kivity | MemoryRegion *address_space); |
224 | 87ecb68b | pbrook | |
225 | 87ecb68b | pbrook | /* cirrus_vga.c */
|
226 | fbe1b595 | Paul Brook | void pci_cirrus_vga_init(PCIBus *bus);
|
227 | be20f9e9 | Avi Kivity | void isa_cirrus_vga_init(MemoryRegion *address_space);
|
228 | 87ecb68b | pbrook | |
229 | 87ecb68b | pbrook | /* ne2000.c */
|
230 | cd1b8a8b | Blue Swirl | static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd) |
231 | 60a14ad3 | Blue Swirl | { |
232 | 60a14ad3 | Blue Swirl | ISADevice *dev; |
233 | 87ecb68b | pbrook | |
234 | 60a14ad3 | Blue Swirl | qemu_check_nic_model(nd, "ne2k_isa");
|
235 | 60a14ad3 | Blue Swirl | |
236 | cd1b8a8b | Blue Swirl | dev = isa_try_create("ne2k_isa");
|
237 | cd1b8a8b | Blue Swirl | if (!dev) {
|
238 | cd1b8a8b | Blue Swirl | return false; |
239 | cd1b8a8b | Blue Swirl | } |
240 | 60a14ad3 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "iobase", base);
|
241 | 60a14ad3 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "irq", irq);
|
242 | 60a14ad3 | Blue Swirl | qdev_set_nic_properties(&dev->qdev, nd); |
243 | 60a14ad3 | Blue Swirl | qdev_init_nofail(&dev->qdev); |
244 | cd1b8a8b | Blue Swirl | return true; |
245 | 60a14ad3 | Blue Swirl | } |
246 | 87ecb68b | pbrook | |
247 | 4c5b10b7 | Jes Sorensen | /* e820 types */
|
248 | 4c5b10b7 | Jes Sorensen | #define E820_RAM 1 |
249 | 4c5b10b7 | Jes Sorensen | #define E820_RESERVED 2 |
250 | 4c5b10b7 | Jes Sorensen | #define E820_ACPI 3 |
251 | 4c5b10b7 | Jes Sorensen | #define E820_NVS 4 |
252 | 4c5b10b7 | Jes Sorensen | #define E820_UNUSABLE 5 |
253 | 4c5b10b7 | Jes Sorensen | |
254 | 4c5b10b7 | Jes Sorensen | int e820_add_entry(uint64_t, uint64_t, uint32_t);
|
255 | 4c5b10b7 | Jes Sorensen | |
256 | 87ecb68b | pbrook | #endif |