cmd: Fix coding style in cmd.c
[qemu/ar7.git] / hw / pc.h
blob4515006381318f7f934b71f35e8e17e5c8760efe
1 #ifndef HW_PC_H
2 #define HW_PC_H
4 #include "qemu-common.h"
5 #include "memory.h"
6 #include "ioport.h"
7 #include "isa.h"
8 #include "fdc.h"
9 #include "net.h"
10 #include "memory.h"
11 #include "ioapic.h"
13 /* PC-style peripherals (also used by other machines). */
15 /* serial.c */
17 SerialState *serial_init(int base, qemu_irq irq, int baudbase,
18 CharDriverState *chr);
19 SerialState *serial_mm_init(MemoryRegion *address_space,
20 target_phys_addr_t base, int it_shift,
21 qemu_irq irq, int baudbase,
22 CharDriverState *chr, enum device_endian);
23 static inline bool serial_isa_init(int index, CharDriverState *chr)
25 ISADevice *dev;
27 dev = isa_try_create("isa-serial");
28 if (!dev) {
29 return false;
31 qdev_prop_set_uint32(&dev->qdev, "index", index);
32 qdev_prop_set_chr(&dev->qdev, "chardev", chr);
33 if (qdev_init(&dev->qdev) < 0) {
34 return false;
36 return true;
39 void serial_set_frequency(SerialState *s, uint32_t frequency);
41 /* parallel.c */
42 static inline bool parallel_init(int index, CharDriverState *chr)
44 ISADevice *dev;
46 dev = isa_try_create("isa-parallel");
47 if (!dev) {
48 return false;
50 qdev_prop_set_uint32(&dev->qdev, "index", index);
51 qdev_prop_set_chr(&dev->qdev, "chardev", chr);
52 if (qdev_init(&dev->qdev) < 0) {
53 return false;
55 return true;
58 bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
59 CharDriverState *chr);
61 /* i8259.c */
63 typedef struct PicState PicState;
64 extern PicState *isa_pic;
65 qemu_irq *i8259_init(qemu_irq parent_irq);
66 int pic_read_irq(PicState *s);
67 int pic_get_output(PicState *s);
68 void pic_info(Monitor *mon);
69 void irq_info(Monitor *mon);
71 /* Global System Interrupts */
73 #define GSI_NUM_PINS IOAPIC_NUM_PINS
75 typedef struct GSIState {
76 qemu_irq i8259_irq[ISA_NUM_IRQS];
77 qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
78 } GSIState;
80 void gsi_handler(void *opaque, int n, int level);
82 /* i8254.c */
84 #define PIT_FREQ 1193182
86 static inline ISADevice *pit_init(int base, int irq)
88 ISADevice *dev;
90 dev = isa_create("isa-pit");
91 qdev_prop_set_uint32(&dev->qdev, "iobase", base);
92 qdev_prop_set_uint32(&dev->qdev, "irq", irq);
93 qdev_init_nofail(&dev->qdev);
95 return dev;
98 void pit_set_gate(ISADevice *dev, int channel, int val);
99 int pit_get_gate(ISADevice *dev, int channel);
100 int pit_get_initial_count(ISADevice *dev, int channel);
101 int pit_get_mode(ISADevice *dev, int channel);
102 int pit_get_out(ISADevice *dev, int channel, int64_t current_time);
104 void hpet_pit_disable(void);
105 void hpet_pit_enable(void);
107 /* vmport.c */
108 static inline void vmport_init(void)
110 isa_create_simple("vmport");
112 void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
113 void vmmouse_get_data(uint32_t *data);
114 void vmmouse_set_data(const uint32_t *data);
116 /* pckbd.c */
118 void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
119 void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
120 MemoryRegion *region, ram_addr_t size,
121 target_phys_addr_t mask);
122 void i8042_isa_mouse_fake_event(void *opaque);
123 void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
125 /* pc.c */
126 extern int fd_bootchk;
128 void pc_register_ferr_irq(qemu_irq irq);
129 void pc_cmos_set_s3_resume(void *opaque, int irq, int level);
130 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
132 void pc_cpus_init(const char *cpu_model);
133 void pc_memory_init(MemoryRegion *system_memory,
134 const char *kernel_filename,
135 const char *kernel_cmdline,
136 const char *initrd_filename,
137 ram_addr_t below_4g_mem_size,
138 ram_addr_t above_4g_mem_size,
139 MemoryRegion *rom_memory,
140 MemoryRegion **ram_memory);
141 qemu_irq *pc_allocate_cpu_irq(void);
142 void pc_vga_init(PCIBus *pci_bus);
143 void pc_basic_device_init(qemu_irq *gsi,
144 ISADevice **rtc_state,
145 ISADevice **floppy,
146 bool no_vmport);
147 void pc_init_ne2k_isa(NICInfo *nd);
148 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
149 const char *boot_device,
150 ISADevice *floppy, BusState *ide0, BusState *ide1,
151 ISADevice *s);
152 void pc_pci_device_init(PCIBus *pci_bus);
154 typedef void (*cpu_set_smm_t)(int smm, void *arg);
155 void cpu_smm_register(cpu_set_smm_t callback, void *arg);
157 /* acpi.c */
158 extern int acpi_enabled;
159 extern char *acpi_tables;
160 extern size_t acpi_tables_len;
162 void acpi_bios_init(void);
163 int acpi_table_add(const char *table_desc);
165 /* acpi_piix.c */
167 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
168 qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
169 int kvm_enabled);
170 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
172 /* hpet.c */
173 extern int no_hpet;
175 /* pcspk.c */
176 void pcspk_init(ISADevice *pit);
177 int pcspk_audio_init(qemu_irq *pic);
179 /* piix_pci.c */
180 struct PCII440FXState;
181 typedef struct PCII440FXState PCII440FXState;
183 PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
184 qemu_irq *pic,
185 MemoryRegion *address_space_mem,
186 MemoryRegion *address_space_io,
187 ram_addr_t ram_size,
188 target_phys_addr_t pci_hole_start,
189 target_phys_addr_t pci_hole_size,
190 target_phys_addr_t pci_hole64_start,
191 target_phys_addr_t pci_hole64_size,
192 MemoryRegion *pci_memory,
193 MemoryRegion *ram_memory);
195 /* piix4.c */
196 extern PCIDevice *piix4_dev;
197 int piix4_init(PCIBus *bus, int devfn);
199 /* vga.c */
200 enum vga_retrace_method {
201 VGA_RETRACE_DUMB,
202 VGA_RETRACE_PRECISE
205 extern enum vga_retrace_method vga_retrace_method;
207 static inline int isa_vga_init(void)
209 ISADevice *dev;
211 dev = isa_try_create("isa-vga");
212 if (!dev) {
213 fprintf(stderr, "Warning: isa-vga not available\n");
214 return 0;
216 qdev_init_nofail(&dev->qdev);
217 return 1;
220 int pci_vga_init(PCIBus *bus);
221 int isa_vga_mm_init(target_phys_addr_t vram_base,
222 target_phys_addr_t ctrl_base, int it_shift,
223 MemoryRegion *address_space);
225 /* cirrus_vga.c */
226 void pci_cirrus_vga_init(PCIBus *bus);
227 void isa_cirrus_vga_init(MemoryRegion *address_space);
229 /* ne2000.c */
230 static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd)
232 ISADevice *dev;
234 qemu_check_nic_model(nd, "ne2k_isa");
236 dev = isa_try_create("ne2k_isa");
237 if (!dev) {
238 return false;
240 qdev_prop_set_uint32(&dev->qdev, "iobase", base);
241 qdev_prop_set_uint32(&dev->qdev, "irq", irq);
242 qdev_set_nic_properties(&dev->qdev, nd);
243 qdev_init_nofail(&dev->qdev);
244 return true;
247 /* e820 types */
248 #define E820_RAM 1
249 #define E820_RESERVED 2
250 #define E820_ACPI 3
251 #define E820_NVS 4
252 #define E820_UNUSABLE 5
254 int e820_add_entry(uint64_t, uint64_t, uint32_t);
256 #endif