root / hw / pc.h @ 7435b791
History | View | Annotate | Download (6.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 | 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 | 87ecb68b | pbrook | typedef struct PITState PITState; |
86 | 87ecb68b | pbrook | |
87 | 87ecb68b | pbrook | PITState *pit_init(int base, qemu_irq irq);
|
88 | 87ecb68b | pbrook | void pit_set_gate(PITState *pit, int channel, int val); |
89 | 87ecb68b | pbrook | int pit_get_gate(PITState *pit, int channel); |
90 | 87ecb68b | pbrook | int pit_get_initial_count(PITState *pit, int channel); |
91 | 87ecb68b | pbrook | int pit_get_mode(PITState *pit, int channel); |
92 | 87ecb68b | pbrook | int pit_get_out(PITState *pit, int channel, int64_t current_time); |
93 | 87ecb68b | pbrook | |
94 | bf4f74c0 | aurel32 | void hpet_pit_disable(void); |
95 | bf4f74c0 | aurel32 | void hpet_pit_enable(void); |
96 | bf4f74c0 | aurel32 | |
97 | 87ecb68b | pbrook | /* vmport.c */
|
98 | 6872ef61 | Blue Swirl | static inline void vmport_init(void) |
99 | 6872ef61 | Blue Swirl | { |
100 | 6872ef61 | Blue Swirl | isa_create_simple("vmport");
|
101 | 6872ef61 | Blue Swirl | } |
102 | 87ecb68b | pbrook | void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); |
103 | 86d86414 | Blue Swirl | void vmmouse_get_data(uint32_t *data);
|
104 | 86d86414 | Blue Swirl | void vmmouse_set_data(const uint32_t *data); |
105 | 87ecb68b | pbrook | |
106 | 87ecb68b | pbrook | /* pckbd.c */
|
107 | 87ecb68b | pbrook | |
108 | 87ecb68b | pbrook | void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
|
109 | 87ecb68b | pbrook | void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
|
110 | c227f099 | Anthony Liguori | target_phys_addr_t base, ram_addr_t size, |
111 | c227f099 | Anthony Liguori | target_phys_addr_t mask); |
112 | 956a3e6b | Blue Swirl | void i8042_isa_mouse_fake_event(void *opaque); |
113 | 956a3e6b | Blue Swirl | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
|
114 | 87ecb68b | pbrook | |
115 | 87ecb68b | pbrook | /* pc.c */
|
116 | 87ecb68b | pbrook | extern int fd_bootchk; |
117 | 87ecb68b | pbrook | |
118 | 8e78eb28 | Isaku Yamahata | void pc_register_ferr_irq(qemu_irq irq);
|
119 | 845773ab | Isaku Yamahata | void pc_cmos_set_s3_resume(void *opaque, int irq, int level); |
120 | 845773ab | Isaku Yamahata | void pc_acpi_smi_interrupt(void *opaque, int irq, int level); |
121 | 845773ab | Isaku Yamahata | |
122 | 845773ab | Isaku Yamahata | void pc_cpus_init(const char *cpu_model); |
123 | 845773ab | Isaku Yamahata | void pc_memory_init(ram_addr_t ram_size,
|
124 | 845773ab | Isaku Yamahata | const char *kernel_filename, |
125 | 845773ab | Isaku Yamahata | const char *kernel_cmdline, |
126 | 845773ab | Isaku Yamahata | const char *initrd_filename, |
127 | 845773ab | Isaku Yamahata | ram_addr_t *below_4g_mem_size_p, |
128 | 845773ab | Isaku Yamahata | ram_addr_t *above_4g_mem_size_p); |
129 | 845773ab | Isaku Yamahata | qemu_irq *pc_allocate_cpu_irq(void);
|
130 | 845773ab | Isaku Yamahata | void pc_vga_init(PCIBus *pci_bus);
|
131 | 845773ab | Isaku Yamahata | void pc_basic_device_init(qemu_irq *isa_irq,
|
132 | 1d914fa0 | Isaku Yamahata | ISADevice **rtc_state); |
133 | 845773ab | Isaku Yamahata | void pc_init_ne2k_isa(NICInfo *nd);
|
134 | 845773ab | Isaku Yamahata | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
135 | c0897e0c | Markus Armbruster | const char *boot_device, |
136 | c0897e0c | Markus Armbruster | BusState *ide0, BusState *ide1, |
137 | 63ffb564 | Blue Swirl | ISADevice *s); |
138 | 845773ab | Isaku Yamahata | void pc_pci_device_init(PCIBus *pci_bus);
|
139 | 8e78eb28 | Isaku Yamahata | |
140 | f885f1ea | Isaku Yamahata | typedef void (*cpu_set_smm_t)(int smm, void *arg); |
141 | f885f1ea | Isaku Yamahata | void cpu_smm_register(cpu_set_smm_t callback, void *arg); |
142 | f885f1ea | Isaku Yamahata | |
143 | 87ecb68b | pbrook | /* acpi.c */
|
144 | 87ecb68b | pbrook | extern int acpi_enabled; |
145 | 80deece2 | blueswir1 | extern char *acpi_tables; |
146 | 80deece2 | blueswir1 | extern size_t acpi_tables_len;
|
147 | 80deece2 | blueswir1 | |
148 | 9d5e77a2 | Isaku Yamahata | void acpi_bios_init(void); |
149 | 9d5e77a2 | Isaku Yamahata | int acpi_table_add(const char *table_desc); |
150 | 9d5e77a2 | Isaku Yamahata | |
151 | 9d5e77a2 | Isaku Yamahata | /* acpi_piix.c */
|
152 | 53b67b30 | Blue Swirl | |
153 | cf7a2fe2 | aurel32 | i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
|
154 | 53b67b30 | Blue Swirl | qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq, |
155 | 53b67b30 | Blue Swirl | int kvm_enabled);
|
156 | 87ecb68b | pbrook | void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
|
157 | 87ecb68b | pbrook | |
158 | 16b29ae1 | aliguori | /* hpet.c */
|
159 | 16b29ae1 | aliguori | extern int no_hpet; |
160 | 16b29ae1 | aliguori | |
161 | 87ecb68b | pbrook | /* pcspk.c */
|
162 | 87ecb68b | pbrook | void pcspk_init(PITState *);
|
163 | 22d83b14 | Paul Brook | int pcspk_audio_init(qemu_irq *pic);
|
164 | 87ecb68b | pbrook | |
165 | 87ecb68b | pbrook | /* piix_pci.c */
|
166 | 0a3bacf3 | Juan Quintela | struct PCII440FXState;
|
167 | 0a3bacf3 | Juan Quintela | typedef struct PCII440FXState PCII440FXState; |
168 | 0a3bacf3 | Juan Quintela | |
169 | 97679527 | Avi Kivity | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, ram_addr_t ram_size);
|
170 | 0a3bacf3 | Juan Quintela | void i440fx_init_memory_mappings(PCII440FXState *d);
|
171 | 87ecb68b | pbrook | |
172 | 823e675a | Juan Quintela | /* piix4.c */
|
173 | b1d8e52e | blueswir1 | extern PCIDevice *piix4_dev;
|
174 | 87ecb68b | pbrook | int piix4_init(PCIBus *bus, int devfn); |
175 | 87ecb68b | pbrook | |
176 | 87ecb68b | pbrook | /* vga.c */
|
177 | cb5a7aa8 | malc | enum vga_retrace_method {
|
178 | cb5a7aa8 | malc | VGA_RETRACE_DUMB, |
179 | cb5a7aa8 | malc | VGA_RETRACE_PRECISE |
180 | cb5a7aa8 | malc | }; |
181 | cb5a7aa8 | malc | |
182 | cb5a7aa8 | malc | extern enum vga_retrace_method vga_retrace_method; |
183 | 87ecb68b | pbrook | |
184 | 7435b791 | Blue Swirl | static inline int isa_vga_init(void) |
185 | 7435b791 | Blue Swirl | { |
186 | 7435b791 | Blue Swirl | isa_create_simple("isa-vga");
|
187 | 7435b791 | Blue Swirl | |
188 | 7435b791 | Blue Swirl | return 0; |
189 | 7435b791 | Blue Swirl | } |
190 | 7435b791 | Blue Swirl | |
191 | 78895427 | Gerd Hoffmann | int pci_vga_init(PCIBus *bus);
|
192 | c227f099 | Anthony Liguori | int isa_vga_mm_init(target_phys_addr_t vram_base,
|
193 | c227f099 | Anthony Liguori | target_phys_addr_t ctrl_base, int it_shift);
|
194 | 87ecb68b | pbrook | |
195 | 87ecb68b | pbrook | /* cirrus_vga.c */
|
196 | fbe1b595 | Paul Brook | void pci_cirrus_vga_init(PCIBus *bus);
|
197 | fbe1b595 | Paul Brook | void isa_cirrus_vga_init(void); |
198 | 87ecb68b | pbrook | |
199 | 87ecb68b | pbrook | /* ne2000.c */
|
200 | cd1b8a8b | Blue Swirl | static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd) |
201 | 60a14ad3 | Blue Swirl | { |
202 | 60a14ad3 | Blue Swirl | ISADevice *dev; |
203 | 87ecb68b | pbrook | |
204 | 60a14ad3 | Blue Swirl | qemu_check_nic_model(nd, "ne2k_isa");
|
205 | 60a14ad3 | Blue Swirl | |
206 | cd1b8a8b | Blue Swirl | dev = isa_try_create("ne2k_isa");
|
207 | cd1b8a8b | Blue Swirl | if (!dev) {
|
208 | cd1b8a8b | Blue Swirl | return false; |
209 | cd1b8a8b | Blue Swirl | } |
210 | 60a14ad3 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "iobase", base);
|
211 | 60a14ad3 | Blue Swirl | qdev_prop_set_uint32(&dev->qdev, "irq", irq);
|
212 | 60a14ad3 | Blue Swirl | qdev_set_nic_properties(&dev->qdev, nd); |
213 | 60a14ad3 | Blue Swirl | qdev_init_nofail(&dev->qdev); |
214 | cd1b8a8b | Blue Swirl | return true; |
215 | 60a14ad3 | Blue Swirl | } |
216 | 87ecb68b | pbrook | |
217 | 4c5b10b7 | Jes Sorensen | /* e820 types */
|
218 | 4c5b10b7 | Jes Sorensen | #define E820_RAM 1 |
219 | 4c5b10b7 | Jes Sorensen | #define E820_RESERVED 2 |
220 | 4c5b10b7 | Jes Sorensen | #define E820_ACPI 3 |
221 | 4c5b10b7 | Jes Sorensen | #define E820_NVS 4 |
222 | 4c5b10b7 | Jes Sorensen | #define E820_UNUSABLE 5 |
223 | 4c5b10b7 | Jes Sorensen | |
224 | 4c5b10b7 | Jes Sorensen | int e820_add_entry(uint64_t, uint64_t, uint32_t);
|
225 | 4c5b10b7 | Jes Sorensen | |
226 | 87ecb68b | pbrook | #endif |