1#ifndef HW_ISA_H
2#define HW_ISA_H
3
4
5
6#include "exec/memory.h"
7#include "exec/ioport.h"
8#include "hw/qdev-core.h"
9#include "qom/object.h"
10
11#define ISA_NUM_IRQS 16
12
13#define TYPE_ISA_DEVICE "isa-device"
14OBJECT_DECLARE_TYPE(ISADevice, ISADeviceClass, ISA_DEVICE)
15
16#define TYPE_ISA_BUS "ISA"
17OBJECT_DECLARE_SIMPLE_TYPE(ISABus, ISA_BUS)
18
19#define TYPE_ISADMA "isa-dma"
20
21typedef struct IsaDmaClass IsaDmaClass;
22DECLARE_CLASS_CHECKERS(IsaDmaClass, ISADMA,
23 TYPE_ISADMA)
24#define ISADMA(obj) \
25 INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
26
27typedef enum {
28 ISADMA_TRANSFER_VERIFY,
29 ISADMA_TRANSFER_READ,
30 ISADMA_TRANSFER_WRITE,
31 ISADMA_TRANSFER_ILLEGAL,
32} IsaDmaTransferMode;
33
34typedef int (*IsaDmaTransferHandler)(void *opaque, int nchan, int pos,
35 int size);
36
37struct IsaDmaClass {
38 InterfaceClass parent;
39
40 bool (*has_autoinitialization)(IsaDma *obj, int nchan);
41 int (*read_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len);
42 int (*write_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len);
43 void (*hold_DREQ)(IsaDma *obj, int nchan);
44 void (*release_DREQ)(IsaDma *obj, int nchan);
45 void (*schedule)(IsaDma *obj);
46 void (*register_channel)(IsaDma *obj, int nchan,
47 IsaDmaTransferHandler transfer_handler,
48 void *opaque);
49};
50
51struct ISADeviceClass {
52 DeviceClass parent_class;
53};
54
55struct ISABus {
56
57 BusState parent_obj;
58
59
60 MemoryRegion *address_space;
61 MemoryRegion *address_space_io;
62 qemu_irq *irqs;
63 IsaDma *dma[2];
64};
65
66struct ISADevice {
67
68 DeviceState parent_obj;
69
70
71 int ioport_id;
72};
73
74ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space,
75 MemoryRegion *address_space_io, Error **errp);
76void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
77qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq);
78void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq);
79void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16);
80IsaDma *isa_get_dma(ISABus *bus, int nchan);
81MemoryRegion *isa_address_space(ISADevice *dev);
82MemoryRegion *isa_address_space_io(ISADevice *dev);
83ISADevice *isa_new(const char *name);
84ISADevice *isa_try_new(const char *name);
85bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
86ISADevice *isa_create_simple(ISABus *bus, const char *name);
87
88ISADevice *isa_vga_init(ISABus *bus);
89void isa_build_aml(ISABus *bus, Aml *scope);
90
91
92
93
94
95
96
97
98
99
100
101void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121int isa_register_portio_list(ISADevice *dev,
122 PortioList *piolist,
123 uint16_t start,
124 const MemoryRegionPortio *portio,
125 void *opaque, const char *name);
126
127static inline ISABus *isa_bus_from_device(ISADevice *d)
128{
129 return ISA_BUS(qdev_get_parent_bus(DEVICE(d)));
130}
131
132#endif
133