4 #include "qemu-common.h"
13 /* PC-style peripherals (also used by other machines). */
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(ISABus
*bus
, int index
,
28 dev
= isa_try_create(bus
, "isa-serial");
32 qdev_prop_set_uint32(&dev
->qdev
, "index", index
);
33 qdev_prop_set_chr(&dev
->qdev
, "chardev", chr
);
34 if (qdev_init(&dev
->qdev
) < 0) {
40 void serial_set_frequency(SerialState
*s
, uint32_t frequency
);
43 static inline bool parallel_init(ISABus
*bus
, int index
, CharDriverState
*chr
)
47 dev
= isa_try_create(bus
, "isa-parallel");
51 qdev_prop_set_uint32(&dev
->qdev
, "index", index
);
52 qdev_prop_set_chr(&dev
->qdev
, "chardev", chr
);
53 if (qdev_init(&dev
->qdev
) < 0) {
59 bool parallel_mm_init(MemoryRegion
*address_space
,
60 target_phys_addr_t base
, int it_shift
, qemu_irq irq
,
61 CharDriverState
*chr
);
65 typedef struct PicState PicState
;
66 extern PicState
*isa_pic
;
67 qemu_irq
*i8259_init(ISABus
*bus
, qemu_irq parent_irq
);
68 int pic_read_irq(PicState
*s
);
69 int pic_get_output(PicState
*s
);
70 void pic_info(Monitor
*mon
);
71 void irq_info(Monitor
*mon
);
73 /* Global System Interrupts */
75 #define GSI_NUM_PINS IOAPIC_NUM_PINS
77 typedef struct GSIState
{
78 qemu_irq i8259_irq
[ISA_NUM_IRQS
];
79 qemu_irq ioapic_irq
[IOAPIC_NUM_PINS
];
82 void gsi_handler(void *opaque
, int n
, int level
);
86 #define PIT_FREQ 1193182
88 static inline ISADevice
*pit_init(ISABus
*bus
, int base
, int irq
)
92 dev
= isa_create(bus
, "isa-pit");
93 qdev_prop_set_uint32(&dev
->qdev
, "iobase", base
);
94 qdev_prop_set_uint32(&dev
->qdev
, "irq", irq
);
95 qdev_init_nofail(&dev
->qdev
);
100 void pit_set_gate(ISADevice
*dev
, int channel
, int val
);
101 int pit_get_gate(ISADevice
*dev
, int channel
);
102 int pit_get_initial_count(ISADevice
*dev
, int channel
);
103 int pit_get_mode(ISADevice
*dev
, int channel
);
104 int pit_get_out(ISADevice
*dev
, int channel
, int64_t current_time
);
106 void hpet_pit_disable(void);
107 void hpet_pit_enable(void);
110 static inline void vmport_init(ISABus
*bus
)
112 isa_create_simple(bus
, "vmport");
114 void vmport_register(unsigned char command
, IOPortReadFunc
*func
, void *opaque
);
115 void vmmouse_get_data(uint32_t *data
);
116 void vmmouse_set_data(const uint32_t *data
);
120 void i8042_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
, uint32_t io_base
);
121 void i8042_mm_init(qemu_irq kbd_irq
, qemu_irq mouse_irq
,
122 MemoryRegion
*region
, ram_addr_t size
,
123 target_phys_addr_t mask
);
124 void i8042_isa_mouse_fake_event(void *opaque
);
125 void i8042_setup_a20_line(ISADevice
*dev
, qemu_irq
*a20_out
);
128 extern int fd_bootchk
;
130 void pc_register_ferr_irq(qemu_irq irq
);
131 void pc_cmos_set_s3_resume(void *opaque
, int irq
, int level
);
132 void pc_acpi_smi_interrupt(void *opaque
, int irq
, int level
);
134 void pc_cpus_init(const char *cpu_model
);
135 void pc_memory_init(MemoryRegion
*system_memory
,
136 const char *kernel_filename
,
137 const char *kernel_cmdline
,
138 const char *initrd_filename
,
139 ram_addr_t below_4g_mem_size
,
140 ram_addr_t above_4g_mem_size
,
141 MemoryRegion
*rom_memory
,
142 MemoryRegion
**ram_memory
);
143 qemu_irq
*pc_allocate_cpu_irq(void);
144 DeviceState
*pc_vga_init(ISABus
*isa_bus
, PCIBus
*pci_bus
);
145 void pc_basic_device_init(ISABus
*isa_bus
, qemu_irq
*gsi
,
146 ISADevice
**rtc_state
,
149 void pc_init_ne2k_isa(ISABus
*bus
, NICInfo
*nd
);
150 void pc_cmos_init(ram_addr_t ram_size
, ram_addr_t above_4g_mem_size
,
151 const char *boot_device
,
152 ISADevice
*floppy
, BusState
*ide0
, BusState
*ide1
,
154 void pc_pci_device_init(PCIBus
*pci_bus
);
156 typedef void (*cpu_set_smm_t
)(int smm
, void *arg
);
157 void cpu_smm_register(cpu_set_smm_t callback
, void *arg
);
160 extern int acpi_enabled
;
161 extern char *acpi_tables
;
162 extern size_t acpi_tables_len
;
164 void acpi_bios_init(void);
165 int acpi_table_add(const char *table_desc
);
169 i2c_bus
*piix4_pm_init(PCIBus
*bus
, int devfn
, uint32_t smb_io_base
,
170 qemu_irq sci_irq
, qemu_irq cmos_s3
, qemu_irq smi_irq
,
172 void piix4_smbus_register_device(SMBusDevice
*dev
, uint8_t addr
);
178 void pcspk_init(ISADevice
*pit
);
179 int pcspk_audio_init(ISABus
*bus
, qemu_irq
*pic
);
182 struct PCII440FXState
;
183 typedef struct PCII440FXState PCII440FXState
;
185 PCIBus
*i440fx_init(PCII440FXState
**pi440fx_state
, int *piix_devfn
,
186 ISABus
**isa_bus
, qemu_irq
*pic
,
187 MemoryRegion
*address_space_mem
,
188 MemoryRegion
*address_space_io
,
190 target_phys_addr_t pci_hole_start
,
191 target_phys_addr_t pci_hole_size
,
192 target_phys_addr_t pci_hole64_start
,
193 target_phys_addr_t pci_hole64_size
,
194 MemoryRegion
*pci_memory
,
195 MemoryRegion
*ram_memory
);
198 extern PCIDevice
*piix4_dev
;
199 int piix4_init(PCIBus
*bus
, ISABus
**isa_bus
, int devfn
);
202 enum vga_retrace_method
{
207 extern enum vga_retrace_method vga_retrace_method
;
209 static inline DeviceState
*isa_vga_init(ISABus
*bus
)
213 dev
= isa_try_create(bus
, "isa-vga");
215 fprintf(stderr
, "Warning: isa-vga not available\n");
218 qdev_init_nofail(&dev
->qdev
);
222 DeviceState
*pci_vga_init(PCIBus
*bus
);
223 int isa_vga_mm_init(target_phys_addr_t vram_base
,
224 target_phys_addr_t ctrl_base
, int it_shift
,
225 MemoryRegion
*address_space
);
228 DeviceState
*pci_cirrus_vga_init(PCIBus
*bus
);
229 DeviceState
*isa_cirrus_vga_init(MemoryRegion
*address_space
);
232 static inline bool isa_ne2000_init(ISABus
*bus
, int base
, int irq
, NICInfo
*nd
)
236 qemu_check_nic_model(nd
, "ne2k_isa");
238 dev
= isa_try_create(bus
, "ne2k_isa");
242 qdev_prop_set_uint32(&dev
->qdev
, "iobase", base
);
243 qdev_prop_set_uint32(&dev
->qdev
, "irq", irq
);
244 qdev_set_nic_properties(&dev
->qdev
, nd
);
245 qdev_init_nofail(&dev
->qdev
);
251 #define E820_RESERVED 2
254 #define E820_UNUSABLE 5
256 int e820_add_entry(uint64_t, uint64_t, uint32_t);