Statistics
| Branch: | Revision:

root / hw / isa.h @ d36b66f7

History | View | Annotate | Download (3.3 kB)

1 79383c9c blueswir1
#ifndef HW_ISA_H
2 79383c9c blueswir1
#define HW_ISA_H
3 f915a115 Gerd Hoffmann
4 87ecb68b pbrook
/* ISA bus */
5 87ecb68b pbrook
6 32993977 Isaku Yamahata
#include "ioport.h"
7 af956cad Avi Kivity
#include "memory.h"
8 f915a115 Gerd Hoffmann
#include "qdev.h"
9 f915a115 Gerd Hoffmann
10 b881fbe9 Jan Kiszka
#define ISA_NUM_IRQS 16
11 b881fbe9 Jan Kiszka
12 8f04ee08 Anthony Liguori
#define TYPE_ISA_DEVICE "isa-device"
13 8f04ee08 Anthony Liguori
#define ISA_DEVICE(obj) \
14 8f04ee08 Anthony Liguori
     OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
15 8f04ee08 Anthony Liguori
#define ISA_DEVICE_CLASS(klass) \
16 8f04ee08 Anthony Liguori
     OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
17 8f04ee08 Anthony Liguori
#define ISA_DEVICE_GET_CLASS(obj) \
18 8f04ee08 Anthony Liguori
     OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
19 8f04ee08 Anthony Liguori
20 0d936928 Anthony Liguori
#define TYPE_ISA_BUS "ISA"
21 0d936928 Anthony Liguori
#define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
22 0d936928 Anthony Liguori
23 8f04ee08 Anthony Liguori
typedef struct ISADeviceClass {
24 8f04ee08 Anthony Liguori
    DeviceClass parent_class;
25 8f04ee08 Anthony Liguori
    int (*init)(ISADevice *dev);
26 8f04ee08 Anthony Liguori
} ISADeviceClass;
27 f915a115 Gerd Hoffmann
28 d1a1be18 Hervé Poussineau
struct ISABus {
29 d1a1be18 Hervé Poussineau
    BusState qbus;
30 d1a1be18 Hervé Poussineau
    MemoryRegion *address_space_io;
31 d1a1be18 Hervé Poussineau
    qemu_irq *irqs;
32 d1a1be18 Hervé Poussineau
};
33 d1a1be18 Hervé Poussineau
34 f915a115 Gerd Hoffmann
struct ISADevice {
35 f915a115 Gerd Hoffmann
    DeviceState qdev;
36 2091ba23 Gerd Hoffmann
    uint32_t isairq[2];
37 78e20593 Richard Henderson
    int nirqs;
38 ebf47c24 Richard Henderson
    int ioport_id;
39 f915a115 Gerd Hoffmann
};
40 f915a115 Gerd Hoffmann
41 c2d0d012 Richard Henderson
ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
42 48a18b3c Hervé Poussineau
void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
43 48a18b3c Hervé Poussineau
qemu_irq isa_get_irq(ISADevice *dev, int isairq);
44 2e15e23b Gerd Hoffmann
void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
45 c839adec Avi Kivity
MemoryRegion *isa_address_space(ISADevice *dev);
46 ac100273 Julien Grall
MemoryRegion *isa_address_space_io(ISADevice *dev);
47 48a18b3c Hervé Poussineau
ISADevice *isa_create(ISABus *bus, const char *name);
48 48a18b3c Hervé Poussineau
ISADevice *isa_try_create(ISABus *bus, const char *name);
49 48a18b3c Hervé Poussineau
ISADevice *isa_create_simple(ISABus *bus, const char *name);
50 87ecb68b pbrook
51 14e7a645 Aurelien Jarno
ISADevice *isa_vga_init(ISABus *bus);
52 14e7a645 Aurelien Jarno
53 d7500734 Avi Kivity
/**
54 d7500734 Avi Kivity
 * isa_register_ioport: Install an I/O port region on the ISA bus.
55 d7500734 Avi Kivity
 *
56 d7500734 Avi Kivity
 * Register an I/O port region via memory_region_add_subregion
57 d7500734 Avi Kivity
 * inside the ISA I/O address space.
58 d7500734 Avi Kivity
 *
59 d7500734 Avi Kivity
 * @dev: the ISADevice against which these are registered; may be NULL.
60 d7500734 Avi Kivity
 * @io: the #MemoryRegion being registered.
61 d7500734 Avi Kivity
 * @start: the base I/O port.
62 d7500734 Avi Kivity
 */
63 d7500734 Avi Kivity
void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
64 d7500734 Avi Kivity
65 d7500734 Avi Kivity
/**
66 d7500734 Avi Kivity
 * isa_register_portio_list: Initialize a set of ISA io ports
67 d7500734 Avi Kivity
 *
68 d7500734 Avi Kivity
 * Several ISA devices have many dis-joint I/O ports.  Worse, these I/O
69 d7500734 Avi Kivity
 * ports can be interleaved with I/O ports from other devices.  This
70 d7500734 Avi Kivity
 * function makes it easy to create multiple MemoryRegions for a single
71 d7500734 Avi Kivity
 * device and use the legacy portio routines.
72 d7500734 Avi Kivity
 *
73 d7500734 Avi Kivity
 * @dev: the ISADevice against which these are registered; may be NULL.
74 d7500734 Avi Kivity
 * @start: the base I/O port against which the portio->offset is applied.
75 d7500734 Avi Kivity
 * @portio: the ports, sorted by offset.
76 d7500734 Avi Kivity
 * @opaque: passed into the old_portio callbacks.
77 d7500734 Avi Kivity
 * @name: passed into memory_region_init_io.
78 d7500734 Avi Kivity
 */
79 d7500734 Avi Kivity
void isa_register_portio_list(ISADevice *dev, uint16_t start,
80 d7500734 Avi Kivity
                              const MemoryRegionPortio *portio,
81 d7500734 Avi Kivity
                              void *opaque, const char *name);
82 d7500734 Avi Kivity
83 a527b545 Hervé Poussineau
static inline ISABus *isa_bus_from_device(ISADevice *d)
84 a527b545 Hervé Poussineau
{
85 a527b545 Hervé Poussineau
    return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
86 a527b545 Hervé Poussineau
}
87 a527b545 Hervé Poussineau
88 a8170e5e Avi Kivity
extern hwaddr isa_mem_base;
89 87ecb68b pbrook
90 a8170e5e Avi Kivity
void isa_mmio_setup(MemoryRegion *mr, hwaddr size);
91 a8170e5e Avi Kivity
void isa_mmio_init(hwaddr base, hwaddr size);
92 87ecb68b pbrook
93 87ecb68b pbrook
/* dma.c */
94 87ecb68b pbrook
int DMA_get_channel_mode (int nchan);
95 87ecb68b pbrook
int DMA_read_memory (int nchan, void *buf, int pos, int size);
96 87ecb68b pbrook
int DMA_write_memory (int nchan, void *buf, int pos, int size);
97 87ecb68b pbrook
void DMA_hold_DREQ (int nchan);
98 87ecb68b pbrook
void DMA_release_DREQ (int nchan);
99 87ecb68b pbrook
void DMA_schedule(int nchan);
100 4556bd8b Blue Swirl
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
101 87ecb68b pbrook
void DMA_register_channel (int nchan,
102 87ecb68b pbrook
                           DMA_transfer_handler transfer_handler,
103 87ecb68b pbrook
                           void *opaque);
104 79383c9c blueswir1
#endif