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