]> git.proxmox.com Git - qemu.git/blame - hw/isa.h
isa: Add isa_bus_from_device() method
[qemu.git] / hw / isa.h
CommitLineData
79383c9c
BS
1#ifndef HW_ISA_H
2#define HW_ISA_H
f915a115 3
87ecb68b
PB
4/* ISA bus */
5
32993977 6#include "ioport.h"
af956cad 7#include "memory.h"
f915a115
GH
8#include "qdev.h"
9
b881fbe9
JK
10#define ISA_NUM_IRQS 16
11
f915a115 12typedef struct ISADevice ISADevice;
8f04ee08
AL
13
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)
21
22typedef struct ISADeviceClass {
23 DeviceClass parent_class;
24 int (*init)(ISADevice *dev);
25} ISADeviceClass;
f915a115 26
d1a1be18
HP
27struct ISABus {
28 BusState qbus;
29 MemoryRegion *address_space_io;
30 qemu_irq *irqs;
31};
32
f915a115
GH
33struct ISADevice {
34 DeviceState qdev;
2091ba23 35 uint32_t isairq[2];
78e20593 36 int nirqs;
ebf47c24 37 int ioport_id;
f915a115
GH
38};
39
c2d0d012 40ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
48a18b3c
HP
41void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
42qemu_irq isa_get_irq(ISADevice *dev, int isairq);
2e15e23b 43void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
c839adec 44MemoryRegion *isa_address_space(ISADevice *dev);
48a18b3c
HP
45ISADevice *isa_create(ISABus *bus, const char *name);
46ISADevice *isa_try_create(ISABus *bus, const char *name);
47ISADevice *isa_create_simple(ISABus *bus, const char *name);
87ecb68b 48
d7500734
AK
49/**
50 * isa_register_ioport: Install an I/O port region on the ISA bus.
51 *
52 * Register an I/O port region via memory_region_add_subregion
53 * inside the ISA I/O address space.
54 *
55 * @dev: the ISADevice against which these are registered; may be NULL.
56 * @io: the #MemoryRegion being registered.
57 * @start: the base I/O port.
58 */
59void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
60
61/**
62 * isa_register_portio_list: Initialize a set of ISA io ports
63 *
64 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
65 * ports can be interleaved with I/O ports from other devices. This
66 * function makes it easy to create multiple MemoryRegions for a single
67 * device and use the legacy portio routines.
68 *
69 * @dev: the ISADevice against which these are registered; may be NULL.
70 * @start: the base I/O port against which the portio->offset is applied.
71 * @portio: the ports, sorted by offset.
72 * @opaque: passed into the old_portio callbacks.
73 * @name: passed into memory_region_init_io.
74 */
75void isa_register_portio_list(ISADevice *dev, uint16_t start,
76 const MemoryRegionPortio *portio,
77 void *opaque, const char *name);
78
a527b545
HP
79static inline ISABus *isa_bus_from_device(ISADevice *d)
80{
81 return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
82}
83
c227f099 84extern target_phys_addr_t isa_mem_base;
87ecb68b 85
af956cad 86void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
968d683c 87void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
87ecb68b
PB
88
89/* dma.c */
90int DMA_get_channel_mode (int nchan);
91int DMA_read_memory (int nchan, void *buf, int pos, int size);
92int DMA_write_memory (int nchan, void *buf, int pos, int size);
93void DMA_hold_DREQ (int nchan);
94void DMA_release_DREQ (int nchan);
95void DMA_schedule(int nchan);
4556bd8b 96void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
87ecb68b
PB
97void DMA_register_channel (int nchan,
98 DMA_transfer_handler transfer_handler,
99 void *opaque);
79383c9c 100#endif