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