blob: b11a0be27f66cd674716631649c7546598d9a0a8 [file] [log] [blame]
blueswir179383c92008-08-30 09:51:20 +00001#ifndef HW_ISA_H
2#define HW_ISA_H
Gerd Hoffmannf915a112009-07-31 12:30:14 +02003
pbrook87ecb682007-11-17 17:14:51 +00004/* ISA bus */
5
Isaku Yamahata32993972009-07-02 19:32:06 +09006#include "ioport.h"
Avi Kivityaf956ca2011-08-08 16:09:21 +03007#include "memory.h"
Gerd Hoffmannf915a112009-07-31 12:30:14 +02008#include "qdev.h"
9
Jan Kiszkab881fbe2011-10-07 09:19:35 +020010#define ISA_NUM_IRQS 16
11
Gerd Hoffmannf915a112009-07-31 12:30:14 +020012typedef struct ISADevice ISADevice;
13typedef struct ISADeviceInfo ISADeviceInfo;
14
Hervé Poussineaud1a1be12011-12-15 22:09:52 +010015struct ISABus {
16 BusState qbus;
17 MemoryRegion *address_space_io;
18 qemu_irq *irqs;
19};
20
Gerd Hoffmannf915a112009-07-31 12:30:14 +020021struct ISADevice {
22 DeviceState qdev;
Gerd Hoffmann2091ba22009-08-14 11:36:14 +020023 uint32_t isairq[2];
Richard Henderson78e20592011-08-10 15:28:12 -070024 int nirqs;
Richard Hendersonebf47c22011-08-15 11:59:09 -070025 int ioport_id;
Gerd Hoffmannf915a112009-07-31 12:30:14 +020026};
27
Gerd Hoffmann81a322d2009-08-14 10:36:05 +020028typedef int (*isa_qdev_initfn)(ISADevice *dev);
Gerd Hoffmannf915a112009-07-31 12:30:14 +020029struct ISADeviceInfo {
30 DeviceInfo qdev;
31 isa_qdev_initfn init;
32};
33
Richard Hendersonc2d0d012011-08-10 15:28:11 -070034ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
Hervé Poussineau48a18b32011-12-15 22:09:51 +010035void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
36qemu_irq isa_get_irq(ISADevice *dev, int isairq);
Gerd Hoffmann2e15e232009-09-10 11:43:27 +020037void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
Gerd Hoffmannf915a112009-07-31 12:30:14 +020038void isa_qdev_register(ISADeviceInfo *info);
Avi Kivityc839ade2011-08-15 17:17:35 +030039MemoryRegion *isa_address_space(ISADevice *dev);
Hervé Poussineau48a18b32011-12-15 22:09:51 +010040ISADevice *isa_create(ISABus *bus, const char *name);
41ISADevice *isa_try_create(ISABus *bus, const char *name);
42ISADevice *isa_create_simple(ISABus *bus, const char *name);
pbrook87ecb682007-11-17 17:14:51 +000043
Avi Kivityd7500732011-09-26 14:52:44 +030044/**
45 * isa_register_ioport: Install an I/O port region on the ISA bus.
46 *
47 * Register an I/O port region via memory_region_add_subregion
48 * inside the ISA I/O address space.
49 *
50 * @dev: the ISADevice against which these are registered; may be NULL.
51 * @io: the #MemoryRegion being registered.
52 * @start: the base I/O port.
53 */
54void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
55
56/**
57 * isa_register_portio_list: Initialize a set of ISA io ports
58 *
59 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
60 * ports can be interleaved with I/O ports from other devices. This
61 * function makes it easy to create multiple MemoryRegions for a single
62 * device and use the legacy portio routines.
63 *
64 * @dev: the ISADevice against which these are registered; may be NULL.
65 * @start: the base I/O port against which the portio->offset is applied.
66 * @portio: the ports, sorted by offset.
67 * @opaque: passed into the old_portio callbacks.
68 * @name: passed into memory_region_init_io.
69 */
70void isa_register_portio_list(ISADevice *dev, uint16_t start,
71 const MemoryRegionPortio *portio,
72 void *opaque, const char *name);
73
Anthony Liguoric227f092009-10-01 16:12:16 -050074extern target_phys_addr_t isa_mem_base;
pbrook87ecb682007-11-17 17:14:51 +000075
Avi Kivityaf956ca2011-08-08 16:09:21 +030076void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
Alexander Graf968d6832010-12-08 12:05:49 +010077void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
pbrook87ecb682007-11-17 17:14:51 +000078
79/* dma.c */
80int DMA_get_channel_mode (int nchan);
81int DMA_read_memory (int nchan, void *buf, int pos, int size);
82int DMA_write_memory (int nchan, void *buf, int pos, int size);
83void DMA_hold_DREQ (int nchan);
84void DMA_release_DREQ (int nchan);
85void DMA_schedule(int nchan);
Blue Swirl4556bd82010-05-22 08:00:52 +000086void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
pbrook87ecb682007-11-17 17:14:51 +000087void DMA_register_channel (int nchan,
88 DMA_transfer_handler transfer_handler,
89 void *opaque);
blueswir179383c92008-08-30 09:51:20 +000090#endif