]>
Commit | Line | Data |
---|---|---|
79383c9c BS |
1 | #ifndef HW_ISA_H |
2 | #define HW_ISA_H | |
f915a115 | 3 | |
87ecb68b PB |
4 | /* ISA bus */ |
5 | ||
022c62cb | 6 | #include "exec/memory.h" |
df43d49c | 7 | #include "exec/ioport.h" |
a27bd6c7 | 8 | #include "hw/qdev-core.h" |
db1015e9 | 9 | #include "qom/object.h" |
f915a115 | 10 | |
b881fbe9 JK |
11 | #define ISA_NUM_IRQS 16 |
12 | ||
8f04ee08 | 13 | #define TYPE_ISA_DEVICE "isa-device" |
db1015e9 | 14 | typedef struct ISADeviceClass ISADeviceClass; |
8f04ee08 AL |
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 | ||
0d936928 AL |
22 | #define TYPE_ISA_BUS "ISA" |
23 | #define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS) | |
24 | ||
15bce1b7 | 25 | #define TYPE_APPLE_SMC "isa-applesmc" |
1142e45f IM |
26 | #define APPLESMC_MAX_DATA_LENGTH 32 |
27 | #define APPLESMC_PROP_IO_BASE "iobase" | |
15bce1b7 | 28 | |
1142e45f | 29 | static inline uint16_t applesmc_port(void) |
15bce1b7 | 30 | { |
1142e45f IM |
31 | Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL); |
32 | ||
33 | if (obj) { | |
822335eb | 34 | return object_property_get_uint(obj, APPLESMC_PROP_IO_BASE, NULL); |
1142e45f IM |
35 | } |
36 | return 0; | |
15bce1b7 GS |
37 | } |
38 | ||
5484f30b HP |
39 | #define TYPE_ISADMA "isa-dma" |
40 | ||
db1015e9 | 41 | typedef struct IsaDmaClass IsaDmaClass; |
5484f30b HP |
42 | #define ISADMA_CLASS(klass) \ |
43 | OBJECT_CLASS_CHECK(IsaDmaClass, (klass), TYPE_ISADMA) | |
44 | #define ISADMA_GET_CLASS(obj) \ | |
45 | OBJECT_GET_CLASS(IsaDmaClass, (obj), TYPE_ISADMA) | |
46 | #define ISADMA(obj) \ | |
47 | INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA) | |
48 | ||
5484f30b HP |
49 | typedef enum { |
50 | ISADMA_TRANSFER_VERIFY, | |
51 | ISADMA_TRANSFER_READ, | |
52 | ISADMA_TRANSFER_WRITE, | |
53 | ISADMA_TRANSFER_ILLEGAL, | |
54 | } IsaDmaTransferMode; | |
55 | ||
bd36a618 MA |
56 | typedef int (*IsaDmaTransferHandler)(void *opaque, int nchan, int pos, |
57 | int size); | |
58 | ||
db1015e9 | 59 | struct IsaDmaClass { |
5484f30b HP |
60 | InterfaceClass parent; |
61 | ||
5484f30b HP |
62 | bool (*has_autoinitialization)(IsaDma *obj, int nchan); |
63 | int (*read_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len); | |
64 | int (*write_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len); | |
65 | void (*hold_DREQ)(IsaDma *obj, int nchan); | |
66 | void (*release_DREQ)(IsaDma *obj, int nchan); | |
67 | void (*schedule)(IsaDma *obj); | |
68 | void (*register_channel)(IsaDma *obj, int nchan, | |
bd36a618 | 69 | IsaDmaTransferHandler transfer_handler, |
5484f30b | 70 | void *opaque); |
db1015e9 | 71 | }; |
5484f30b | 72 | |
db1015e9 | 73 | struct ISADeviceClass { |
8f04ee08 | 74 | DeviceClass parent_class; |
a53e581e | 75 | void (*build_aml)(ISADevice *dev, Aml *scope); |
db1015e9 | 76 | }; |
f915a115 | 77 | |
d1a1be18 | 78 | struct ISABus { |
2ae0e48d AF |
79 | /*< private >*/ |
80 | BusState parent_obj; | |
81 | /*< public >*/ | |
82 | ||
bb2ed009 | 83 | MemoryRegion *address_space; |
d1a1be18 HP |
84 | MemoryRegion *address_space_io; |
85 | qemu_irq *irqs; | |
5484f30b | 86 | IsaDma *dma[2]; |
d1a1be18 HP |
87 | }; |
88 | ||
f915a115 | 89 | struct ISADevice { |
4a17cc4f AF |
90 | /*< private >*/ |
91 | DeviceState parent_obj; | |
92 | /*< public >*/ | |
93 | ||
3c29e188 | 94 | int8_t isairq[2]; /* -1 = unassigned */ |
78e20593 | 95 | int nirqs; |
ebf47c24 | 96 | int ioport_id; |
f915a115 GH |
97 | }; |
98 | ||
bb2ed009 | 99 | ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space, |
d10e5432 | 100 | MemoryRegion *address_space_io, Error **errp); |
48a18b3c | 101 | void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); |
3c29e188 PB |
102 | qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq); |
103 | void isa_init_irq(ISADevice *dev, qemu_irq *p, unsigned isairq); | |
104 | void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq); | |
5484f30b HP |
105 | void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16); |
106 | IsaDma *isa_get_dma(ISABus *bus, int nchan); | |
c839adec | 107 | MemoryRegion *isa_address_space(ISADevice *dev); |
ac100273 | 108 | MemoryRegion *isa_address_space_io(ISADevice *dev); |
0fe9d901 MA |
109 | ISADevice *isa_new(const char *name); |
110 | ISADevice *isa_try_new(const char *name); | |
111 | bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp); | |
48a18b3c | 112 | ISADevice *isa_create_simple(ISABus *bus, const char *name); |
87ecb68b | 113 | |
14e7a645 | 114 | ISADevice *isa_vga_init(ISABus *bus); |
a53e581e | 115 | void isa_build_aml(ISABus *bus, Aml *scope); |
14e7a645 | 116 | |
d7500734 AK |
117 | /** |
118 | * isa_register_ioport: Install an I/O port region on the ISA bus. | |
119 | * | |
120 | * Register an I/O port region via memory_region_add_subregion | |
121 | * inside the ISA I/O address space. | |
122 | * | |
123 | * @dev: the ISADevice against which these are registered; may be NULL. | |
124 | * @io: the #MemoryRegion being registered. | |
125 | * @start: the base I/O port. | |
126 | */ | |
127 | void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); | |
128 | ||
129 | /** | |
130 | * isa_register_portio_list: Initialize a set of ISA io ports | |
131 | * | |
132 | * Several ISA devices have many dis-joint I/O ports. Worse, these I/O | |
133 | * ports can be interleaved with I/O ports from other devices. This | |
134 | * function makes it easy to create multiple MemoryRegions for a single | |
135 | * device and use the legacy portio routines. | |
136 | * | |
137 | * @dev: the ISADevice against which these are registered; may be NULL. | |
e305a165 | 138 | * @piolist: the PortioList associated with the io ports |
d7500734 AK |
139 | * @start: the base I/O port against which the portio->offset is applied. |
140 | * @portio: the ports, sorted by offset. | |
520902a6 | 141 | * @opaque: passed into the portio callbacks. |
d7500734 AK |
142 | * @name: passed into memory_region_init_io. |
143 | */ | |
e305a165 MAL |
144 | void isa_register_portio_list(ISADevice *dev, |
145 | PortioList *piolist, | |
146 | uint16_t start, | |
d7500734 AK |
147 | const MemoryRegionPortio *portio, |
148 | void *opaque, const char *name); | |
149 | ||
a527b545 HP |
150 | static inline ISABus *isa_bus_from_device(ISADevice *d) |
151 | { | |
3e7b8f4e | 152 | return ISA_BUS(qdev_get_parent_bus(DEVICE(d))); |
a527b545 HP |
153 | } |
154 | ||
9b74b190 HP |
155 | #define TYPE_PIIX4_PCI_DEVICE "piix4-isa" |
156 | ||
79383c9c | 157 | #endif |