isa: give ISABus/ISADevice to isa_create(), isa_bus_irqs() and isa_get_irq() functions
[sdk/emulator/qemu.git] / hw / isa.h
1 #ifndef HW_ISA_H
2 #define HW_ISA_H
3
4 /* ISA bus */
5
6 #include "ioport.h"
7 #include "memory.h"
8 #include "qdev.h"
9
10 #define ISA_NUM_IRQS 16
11
12 typedef struct ISADevice ISADevice;
13 typedef struct ISADeviceInfo ISADeviceInfo;
14
15 struct ISADevice {
16     DeviceState qdev;
17     uint32_t isairq[2];
18     int nirqs;
19     int ioport_id;
20 };
21
22 typedef int (*isa_qdev_initfn)(ISADevice *dev);
23 struct ISADeviceInfo {
24     DeviceInfo qdev;
25     isa_qdev_initfn init;
26 };
27
28 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
29 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
30 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
31 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
32 void isa_qdev_register(ISADeviceInfo *info);
33 MemoryRegion *isa_address_space(ISADevice *dev);
34 ISADevice *isa_create(ISABus *bus, const char *name);
35 ISADevice *isa_try_create(ISABus *bus, const char *name);
36 ISADevice *isa_create_simple(ISABus *bus, const char *name);
37
38 /**
39  * isa_register_ioport: Install an I/O port region on the ISA bus.
40  *
41  * Register an I/O port region via memory_region_add_subregion
42  * inside the ISA I/O address space.
43  *
44  * @dev: the ISADevice against which these are registered; may be NULL.
45  * @io: the #MemoryRegion being registered.
46  * @start: the base I/O port.
47  */
48 void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
49
50 /**
51  * isa_register_portio_list: Initialize a set of ISA io ports
52  *
53  * Several ISA devices have many dis-joint I/O ports.  Worse, these I/O
54  * ports can be interleaved with I/O ports from other devices.  This
55  * function makes it easy to create multiple MemoryRegions for a single
56  * device and use the legacy portio routines.
57  *
58  * @dev: the ISADevice against which these are registered; may be NULL.
59  * @start: the base I/O port against which the portio->offset is applied.
60  * @portio: the ports, sorted by offset.
61  * @opaque: passed into the old_portio callbacks.
62  * @name: passed into memory_region_init_io.
63  */
64 void isa_register_portio_list(ISADevice *dev, uint16_t start,
65                               const MemoryRegionPortio *portio,
66                               void *opaque, const char *name);
67
68 extern target_phys_addr_t isa_mem_base;
69
70 void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
71 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
72
73 /* dma.c */
74 int DMA_get_channel_mode (int nchan);
75 int DMA_read_memory (int nchan, void *buf, int pos, int size);
76 int DMA_write_memory (int nchan, void *buf, int pos, int size);
77 void DMA_hold_DREQ (int nchan);
78 void DMA_release_DREQ (int nchan);
79 void DMA_schedule(int nchan);
80 void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
81 void DMA_register_channel (int nchan,
82                            DMA_transfer_handler transfer_handler,
83                            void *opaque);
84 #endif