Statistics
| Branch: | Revision:

root / hw / isa.h @ c06aaf01

History | View | Annotate | Download (3.2 kB)

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
#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)
19

    
20
#define TYPE_ISA_BUS "ISA"
21
#define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
22

    
23
typedef struct ISADeviceClass {
24
    DeviceClass parent_class;
25
    int (*init)(ISADevice *dev);
26
} ISADeviceClass;
27

    
28
struct ISABus {
29
    BusState qbus;
30
    MemoryRegion *address_space_io;
31
    qemu_irq *irqs;
32
};
33

    
34
struct ISADevice {
35
    DeviceState qdev;
36
    uint32_t isairq[2];
37
    int nirqs;
38
    int ioport_id;
39
};
40

    
41
ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
42
void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
43
qemu_irq isa_get_irq(ISADevice *dev, int isairq);
44
void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
45
MemoryRegion *isa_address_space(ISADevice *dev);
46
ISADevice *isa_create(ISABus *bus, const char *name);
47
ISADevice *isa_try_create(ISABus *bus, const char *name);
48
ISADevice *isa_create_simple(ISABus *bus, const char *name);
49

    
50
/**
51
 * isa_register_ioport: Install an I/O port region on the ISA bus.
52
 *
53
 * Register an I/O port region via memory_region_add_subregion
54
 * inside the ISA I/O address space.
55
 *
56
 * @dev: the ISADevice against which these are registered; may be NULL.
57
 * @io: the #MemoryRegion being registered.
58
 * @start: the base I/O port.
59
 */
60
void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
61

    
62
/**
63
 * isa_register_portio_list: Initialize a set of ISA io ports
64
 *
65
 * Several ISA devices have many dis-joint I/O ports.  Worse, these I/O
66
 * ports can be interleaved with I/O ports from other devices.  This
67
 * function makes it easy to create multiple MemoryRegions for a single
68
 * device and use the legacy portio routines.
69
 *
70
 * @dev: the ISADevice against which these are registered; may be NULL.
71
 * @start: the base I/O port against which the portio->offset is applied.
72
 * @portio: the ports, sorted by offset.
73
 * @opaque: passed into the old_portio callbacks.
74
 * @name: passed into memory_region_init_io.
75
 */
76
void isa_register_portio_list(ISADevice *dev, uint16_t start,
77
                              const MemoryRegionPortio *portio,
78
                              void *opaque, const char *name);
79

    
80
static inline ISABus *isa_bus_from_device(ISADevice *d)
81
{
82
    return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
83
}
84

    
85
extern target_phys_addr_t isa_mem_base;
86

    
87
void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
88
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
89

    
90
/* dma.c */
91
int DMA_get_channel_mode (int nchan);
92
int DMA_read_memory (int nchan, void *buf, int pos, int size);
93
int DMA_write_memory (int nchan, void *buf, int pos, int size);
94
void DMA_hold_DREQ (int nchan);
95
void DMA_release_DREQ (int nchan);
96
void DMA_schedule(int nchan);
97
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
98
void DMA_register_channel (int nchan,
99
                           DMA_transfer_handler transfer_handler,
100
                           void *opaque);
101
#endif