root / hw / pc.h @ d46ccfce
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 | 376253ec | aliguori | |
12 | 87ecb68b | pbrook | /* PC-style peripherals (also used by other machines). */
|
13 | 87ecb68b | pbrook | |
14 | 87ecb68b | pbrook | /* serial.c */
|
15 | 87ecb68b | pbrook | |
16 | b6cd0ea1 | aurel32 | SerialState *serial_init(int base, qemu_irq irq, int baudbase, |
17 | b6cd0ea1 | aurel32 | CharDriverState *chr); |
18 | 39186d8a | Richard Henderson | SerialState *serial_mm_init(MemoryRegion *address_space, |
19 | 39186d8a | Richard Henderson | target_phys_addr_t base, int it_shift,
|
20 | 39186d8a | Richard Henderson | qemu_irq irq, int baudbase,
|
21 | 39186d8a | Richard Henderson | CharDriverState *chr, enum device_endian);
|
22 | e22cf21e | Blue Swirl | static inline bool serial_isa_init(int index, CharDriverState *chr) |
23 | e22cf21e | Blue Swirl | { |
24 | e22cf21e | Blue Swirl | ISADevice *dev; |
25 | e22cf21e | Blue Swirl | |
26 | 9b13ef9f | Blue Swirl | dev = isa_try_create("isa-serial");
|
27 | 9b13ef9f | Blue Swirl | if (!dev) {
|
28 | 9b13ef9f | Blue Swirl | return false; |
29 | 9b13ef9f | Blue Swirl | } |
30 | e22cf21e | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "index", index);
|
31 | e22cf21e | Blue Swirl | qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
32 | e22cf21e | Blue Swirl | if (qdev_init(&dev->qdev) < 0) { |
33 | e22cf21e | Blue Swirl | return false; |
34 | e22cf21e | Blue Swirl | } |
35 | e22cf21e | Blue Swirl | return true; |
36 | e22cf21e | Blue Swirl | } |
37 | e22cf21e | Blue Swirl | |
38 | 038eaf82 | Stefan Weil | void serial_set_frequency(SerialState *s, uint32_t frequency);
|
39 | 87ecb68b | pbrook | |
40 | 87ecb68b | pbrook | /* parallel.c */
|
41 | defdb20e | Blue Swirl | static inline bool parallel_init(int index, CharDriverState *chr) |
42 | defdb20e | Blue Swirl | { |
43 | defdb20e | Blue Swirl | ISADevice *dev; |
44 | defdb20e | Blue Swirl | |
45 | 73531538 | Blue Swirl | dev = isa_try_create("isa-parallel");
|
46 | 73531538 | Blue Swirl | if (!dev) {
|
47 | 73531538 | Blue Swirl | return false; |
48 | 73531538 | Blue Swirl | } |
49 | defdb20e | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "index", index);
|
50 | defdb20e | Blue Swirl | qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
51 | defdb20e | Blue Swirl | if (qdev_init(&dev->qdev) < 0) { |
52 | defdb20e | Blue Swirl | return false; |
53 | defdb20e | Blue Swirl | } |
54 | defdb20e | Blue Swirl | return true; |
55 | defdb20e | Blue Swirl | } |
56 | defdb20e | Blue Swirl | |
57 | defdb20e | Blue Swirl | bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, |
58 | defdb20e | Blue Swirl | CharDriverState *chr); |
59 | 87ecb68b | pbrook | |
60 | 87ecb68b | pbrook | /* i8259.c */
|
61 | 87ecb68b | pbrook | |
62 | 87ecb68b | pbrook | typedef struct PicState2 PicState2; |
63 | 87ecb68b | pbrook | extern PicState2 *isa_pic;
|
64 | 87ecb68b | pbrook | void pic_set_irq(int irq, int level); |
65 | 87ecb68b | pbrook | void pic_set_irq_new(void *opaque, int irq, int level); |
66 | 87ecb68b | pbrook | qemu_irq *i8259_init(qemu_irq parent_irq); |
67 | 87ecb68b | pbrook | int pic_read_irq(PicState2 *s);
|
68 | 87ecb68b | pbrook | void pic_update_irq(PicState2 *s);
|
69 | 87ecb68b | pbrook | uint32_t pic_intack_read(PicState2 *s); |
70 | 376253ec | aliguori | void pic_info(Monitor *mon);
|
71 | 376253ec | aliguori | void irq_info(Monitor *mon);
|
72 | 87ecb68b | pbrook | |
73 | 845773ab | Isaku Yamahata | /* ISA */
|
74 | 96051119 | Blue Swirl | #define IOAPIC_NUM_PINS 0x18 |
75 | 96051119 | Blue Swirl | |
76 | 845773ab | Isaku Yamahata | typedef struct isa_irq_state { |
77 | 845773ab | Isaku Yamahata | qemu_irq *i8259; |
78 | 96051119 | Blue Swirl | qemu_irq ioapic[IOAPIC_NUM_PINS]; |
79 | 845773ab | Isaku Yamahata | } IsaIrqState; |
80 | 845773ab | Isaku Yamahata | |
81 | 845773ab | Isaku Yamahata | void isa_irq_handler(void *opaque, int n, int level); |
82 | 845773ab | Isaku Yamahata | |
83 | 87ecb68b | pbrook | /* i8254.c */
|
84 | 87ecb68b | pbrook | |
85 | 87ecb68b | pbrook | #define PIT_FREQ 1193182 |
86 | 87ecb68b | pbrook | |
87 | 64d7e9a4 | Blue Swirl | static inline ISADevice *pit_init(int base, int irq) |
88 | 64d7e9a4 | Blue Swirl | { |
89 | 64d7e9a4 | Blue Swirl | ISADevice *dev; |
90 | 64d7e9a4 | Blue Swirl | |
91 | 64d7e9a4 | Blue Swirl | dev = isa_create("isa-pit");
|
92 | 64d7e9a4 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "iobase", base);
|
93 | 64d7e9a4 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "irq", irq);
|
94 | 64d7e9a4 | Blue Swirl | qdev_init_nofail(&dev->qdev); |
95 | 64d7e9a4 | Blue Swirl | |
96 | 64d7e9a4 | Blue Swirl | return dev;
|
97 | 64d7e9a4 | Blue Swirl | } |
98 | 87ecb68b | pbrook | |
99 | 64d7e9a4 | Blue Swirl | void pit_set_gate(ISADevice *dev, int channel, int val); |
100 | 64d7e9a4 | Blue Swirl | int pit_get_gate(ISADevice *dev, int channel); |
101 | 64d7e9a4 | Blue Swirl | int pit_get_initial_count(ISADevice *dev, int channel); |
102 | 64d7e9a4 | Blue Swirl | int pit_get_mode(ISADevice *dev, int channel); |
103 | 64d7e9a4 | Blue Swirl | int pit_get_out(ISADevice *dev, int channel, int64_t current_time); |
104 | 87ecb68b | pbrook | |
105 | bf4f74c0 | aurel32 | void hpet_pit_disable(void); |
106 | bf4f74c0 | aurel32 | void hpet_pit_enable(void); |
107 | bf4f74c0 | aurel32 | |
108 | 87ecb68b | pbrook | /* vmport.c */
|
109 | 6872ef61 | Blue Swirl | static inline void vmport_init(void) |
110 | 6872ef61 | Blue Swirl | { |
111 | 6872ef61 | Blue Swirl | isa_create_simple("vmport");
|
112 | 6872ef61 | Blue Swirl | } |
113 | 87ecb68b | pbrook | void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); |
114 | 86d86414 | Blue Swirl | void vmmouse_get_data(uint32_t *data);
|
115 | 86d86414 | Blue Swirl | void vmmouse_set_data(const uint32_t *data); |
116 | 87ecb68b | pbrook | |
117 | 87ecb68b | pbrook | /* pckbd.c */
|
118 | 87ecb68b | pbrook | |
119 | 87ecb68b | pbrook | void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
|
120 | 87ecb68b | pbrook | void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
|
121 | dbff76ac | Richard Henderson | MemoryRegion *region, ram_addr_t size, |
122 | c227f099 | Anthony Liguori | target_phys_addr_t mask); |
123 | 956a3e6b | Blue Swirl | void i8042_isa_mouse_fake_event(void *opaque); |
124 | 956a3e6b | Blue Swirl | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
|
125 | 87ecb68b | pbrook | |
126 | 87ecb68b | pbrook | /* pc.c */
|
127 | 87ecb68b | pbrook | extern int fd_bootchk; |
128 | 87ecb68b | pbrook | |
129 | 8e78eb28 | Isaku Yamahata | void pc_register_ferr_irq(qemu_irq irq);
|
130 | 845773ab | Isaku Yamahata | void pc_cmos_set_s3_resume(void *opaque, int irq, int level); |
131 | 845773ab | Isaku Yamahata | void pc_acpi_smi_interrupt(void *opaque, int irq, int level); |
132 | 845773ab | Isaku Yamahata | |
133 | 845773ab | Isaku Yamahata | void pc_cpus_init(const char *cpu_model); |
134 | 4aa63af1 | Avi Kivity | void pc_memory_init(MemoryRegion *system_memory,
|
135 | 4aa63af1 | Avi Kivity | const char *kernel_filename, |
136 | 845773ab | Isaku Yamahata | const char *kernel_cmdline, |
137 | 845773ab | Isaku Yamahata | const char *initrd_filename, |
138 | e0e7e67b | Anthony PERARD | ram_addr_t below_4g_mem_size, |
139 | ae0a5466 | Avi Kivity | ram_addr_t above_4g_mem_size, |
140 | 4463aee6 | Jan Kiszka | MemoryRegion *rom_memory, |
141 | ae0a5466 | Avi Kivity | MemoryRegion **ram_memory); |
142 | 845773ab | Isaku Yamahata | qemu_irq *pc_allocate_cpu_irq(void);
|
143 | 845773ab | Isaku Yamahata | void pc_vga_init(PCIBus *pci_bus);
|
144 | 845773ab | Isaku Yamahata | void pc_basic_device_init(qemu_irq *isa_irq,
|
145 | 1611977c | Anthony PERARD | ISADevice **rtc_state, |
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 | c0897e0c | Markus Armbruster | 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 |