Merge commit 'd34e8f6e9d3a396c3327aa9807c83f9e1f4a7bd7' into upstream-merge
[qemu-kvm.git] / hw / isa.h
blob9f5d1588b503c51d192b066f1715f5cdb832521e
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 typedef struct ISADevice ISADevice;
14 #define TYPE_ISA_DEVICE "isa-device"
15 #define ISA_DEVICE(obj) \
16 OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
17 #define ISA_DEVICE_CLASS(klass) \
18 OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
19 #define ISA_DEVICE_GET_CLASS(obj) \
20 OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
22 typedef struct ISADeviceClass {
23 DeviceClass parent_class;
24 int (*init)(ISADevice *dev);
25 } ISADeviceClass;
27 struct ISABus {
28 BusState qbus;
29 MemoryRegion *address_space_io;
30 qemu_irq *irqs;
33 struct ISADevice {
34 DeviceState qdev;
35 uint32_t isairq[2];
36 int nirqs;
37 int ioport_id;
40 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
41 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
42 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
43 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
44 void isa_qdev_register(DeviceInfo *info);
45 void isa_qdev_register_subclass(DeviceInfo *info, const char *parent);
46 MemoryRegion *isa_address_space(ISADevice *dev);
47 ISADevice *isa_create(ISABus *bus, const char *name);
48 ISADevice *isa_try_create(ISABus *bus, const char *name);
49 ISADevice *isa_create_simple(ISABus *bus, const char *name);
51 /**
52 * isa_register_ioport: Install an I/O port region on the ISA bus.
54 * Register an I/O port region via memory_region_add_subregion
55 * inside the ISA I/O address space.
57 * @dev: the ISADevice against which these are registered; may be NULL.
58 * @io: the #MemoryRegion being registered.
59 * @start: the base I/O port.
61 void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
63 /**
64 * isa_register_portio_list: Initialize a set of ISA io ports
66 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
67 * ports can be interleaved with I/O ports from other devices. This
68 * function makes it easy to create multiple MemoryRegions for a single
69 * device and use the legacy portio routines.
71 * @dev: the ISADevice against which these are registered; may be NULL.
72 * @start: the base I/O port against which the portio->offset is applied.
73 * @portio: the ports, sorted by offset.
74 * @opaque: passed into the old_portio callbacks.
75 * @name: passed into memory_region_init_io.
77 void isa_register_portio_list(ISADevice *dev, uint16_t start,
78 const MemoryRegionPortio *portio,
79 void *opaque, const char *name);
81 extern target_phys_addr_t isa_mem_base;
83 void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
84 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
86 /* dma.c */
87 int DMA_get_channel_mode (int nchan);
88 int DMA_read_memory (int nchan, void *buf, int pos, int size);
89 int DMA_write_memory (int nchan, void *buf, int pos, int size);
90 void DMA_hold_DREQ (int nchan);
91 void DMA_release_DREQ (int nchan);
92 void DMA_schedule(int nchan);
93 void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
94 void DMA_register_channel (int nchan,
95 DMA_transfer_handler transfer_handler,
96 void *opaque);
97 #endif