Merge remote-tracking branch 'kwolf/for-anthony' into staging
[qemu-kvm.git] / hw / isa.h
blob6c6fd7fac98c8aac24809939d9c70ee33c42b696
1 #ifndef HW_ISA_H
2 #define HW_ISA_H
4 /* ISA bus */
6 #include "ioport.h"
7 #include "memory.h"
8 #include "qdev.h"
10 #define ISA_NUM_IRQS 16
12 #define TYPE_ISA_DEVICE "isa-device"
13 #define ISA_DEVICE(obj) \
14 OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
15 #define ISA_DEVICE_CLASS(klass) \
16 OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
17 #define ISA_DEVICE_GET_CLASS(obj) \
18 OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
20 typedef struct ISADeviceClass {
21 DeviceClass parent_class;
22 int (*init)(ISADevice *dev);
23 } ISADeviceClass;
25 struct ISABus {
26 BusState qbus;
27 MemoryRegion *address_space_io;
28 qemu_irq *irqs;
31 struct ISADevice {
32 DeviceState qdev;
33 uint32_t isairq[2];
34 int nirqs;
35 int ioport_id;
38 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
39 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
40 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
41 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
42 MemoryRegion *isa_address_space(ISADevice *dev);
43 ISADevice *isa_create(ISABus *bus, const char *name);
44 ISADevice *isa_try_create(ISABus *bus, const char *name);
45 ISADevice *isa_create_simple(ISABus *bus, const char *name);
47 /**
48 * isa_register_ioport: Install an I/O port region on the ISA bus.
50 * Register an I/O port region via memory_region_add_subregion
51 * inside the ISA I/O address space.
53 * @dev: the ISADevice against which these are registered; may be NULL.
54 * @io: the #MemoryRegion being registered.
55 * @start: the base I/O port.
57 void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
59 /**
60 * isa_register_portio_list: Initialize a set of ISA io ports
62 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
63 * ports can be interleaved with I/O ports from other devices. This
64 * function makes it easy to create multiple MemoryRegions for a single
65 * device and use the legacy portio routines.
67 * @dev: the ISADevice against which these are registered; may be NULL.
68 * @start: the base I/O port against which the portio->offset is applied.
69 * @portio: the ports, sorted by offset.
70 * @opaque: passed into the old_portio callbacks.
71 * @name: passed into memory_region_init_io.
73 void isa_register_portio_list(ISADevice *dev, uint16_t start,
74 const MemoryRegionPortio *portio,
75 void *opaque, const char *name);
77 static inline ISABus *isa_bus_from_device(ISADevice *d)
79 return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
82 extern target_phys_addr_t isa_mem_base;
84 void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
85 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
87 /* dma.c */
88 int DMA_get_channel_mode (int nchan);
89 int DMA_read_memory (int nchan, void *buf, int pos, int size);
90 int DMA_write_memory (int nchan, void *buf, int pos, int size);
91 void DMA_hold_DREQ (int nchan);
92 void DMA_release_DREQ (int nchan);
93 void DMA_schedule(int nchan);
94 void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
95 void DMA_register_channel (int nchan,
96 DMA_transfer_handler transfer_handler,
97 void *opaque);
98 #endif