Statistics
| Branch: | Revision:

root / hw / isa.h @ 0d936928

History | View | Annotate | Download (3.3 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
typedef struct ISADevice ISADevice;
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

    
22
#define TYPE_ISA_BUS "ISA"
23
#define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
24

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

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

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

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

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

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

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

    
87
extern target_phys_addr_t isa_mem_base;
88

    
89
void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
90
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
91

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