Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * isa bus support for qdev. |
| 3 | * |
| 4 | * Copyright (c) 2009 Gerd Hoffmann <kraxel@redhat.com> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
Chetan Pant | 61f3c91 | 2020-10-23 12:44:24 +0000 | [diff] [blame] | 9 | * version 2.1 of the License, or (at your option) any later version. |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
Markus Armbruster | 0b8fa32 | 2019-05-23 16:35:07 +0200 | [diff] [blame] | 19 | |
Peter Maydell | 0430891 | 2016-01-26 18:17:30 +0000 | [diff] [blame] | 20 | #include "qemu/osdep.h" |
Alistair Francis | 1081ed2 | 2017-11-08 14:57:30 -0800 | [diff] [blame] | 21 | #include "qemu/error-report.h" |
Markus Armbruster | 0b8fa32 | 2019-05-23 16:35:07 +0200 | [diff] [blame] | 22 | #include "qemu/module.h" |
Markus Armbruster | da34e65 | 2016-03-14 09:01:28 +0100 | [diff] [blame] | 23 | #include "qapi/error.h" |
Paolo Bonzini | 83c9f4c | 2013-02-04 15:40:22 +0100 | [diff] [blame] | 24 | #include "hw/sysbus.h" |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 25 | #include "sysemu/sysemu.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 26 | #include "hw/isa/isa.h" |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 27 | |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 28 | static ISABus *isabus; |
| 29 | |
Gleb Natapov | 6a26e11 | 2010-12-08 13:34:57 +0200 | [diff] [blame] | 30 | static char *isabus_get_fw_dev_path(DeviceState *dev); |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 31 | |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 32 | static void isa_bus_class_init(ObjectClass *klass, void *data) |
| 33 | { |
| 34 | BusClass *k = BUS_CLASS(klass); |
| 35 | |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 36 | k->get_fw_dev_path = isabus_get_fw_dev_path; |
| 37 | } |
| 38 | |
Hervé Poussineau | 5484f30 | 2016-02-03 11:28:57 -0500 | [diff] [blame] | 39 | static const TypeInfo isa_dma_info = { |
| 40 | .name = TYPE_ISADMA, |
| 41 | .parent = TYPE_INTERFACE, |
| 42 | .class_size = sizeof(IsaDmaClass), |
| 43 | }; |
| 44 | |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 45 | static const TypeInfo isa_bus_info = { |
| 46 | .name = TYPE_ISA_BUS, |
| 47 | .parent = TYPE_BUS, |
| 48 | .instance_size = sizeof(ISABus), |
| 49 | .class_init = isa_bus_class_init, |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
Hervé Poussineau | bb2ed00 | 2015-02-01 09:12:50 +0100 | [diff] [blame] | 52 | ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space, |
Markus Armbruster | d10e543 | 2015-12-17 17:35:18 +0100 | [diff] [blame] | 53 | MemoryRegion *address_space_io, Error **errp) |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 54 | { |
Philippe Mathieu-Daudé | 675d717 | 2023-10-18 14:41:33 +0200 | [diff] [blame] | 55 | DeviceState *bridge = NULL; |
| 56 | |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 57 | if (isabus) { |
Markus Armbruster | d10e543 | 2015-12-17 17:35:18 +0100 | [diff] [blame] | 58 | error_setg(errp, "Can't create a second ISA bus"); |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 59 | return NULL; |
| 60 | } |
Gonglei | 337a3e5c | 2014-08-11 21:00:54 +0800 | [diff] [blame] | 61 | if (!dev) { |
Philippe Mathieu-Daudé | 675d717 | 2023-10-18 14:41:33 +0200 | [diff] [blame] | 62 | bridge = qdev_new("isabus-bridge"); |
| 63 | dev = bridge; |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 64 | } |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 65 | |
Peter Maydell | 9388d17 | 2021-09-23 13:11:52 +0100 | [diff] [blame] | 66 | isabus = ISA_BUS(qbus_new(TYPE_ISA_BUS, dev, NULL)); |
Hervé Poussineau | bb2ed00 | 2015-02-01 09:12:50 +0100 | [diff] [blame] | 67 | isabus->address_space = address_space; |
Richard Henderson | c2d0d01 | 2011-08-10 15:28:11 -0700 | [diff] [blame] | 68 | isabus->address_space_io = address_space_io; |
Philippe Mathieu-Daudé | 675d717 | 2023-10-18 14:41:33 +0200 | [diff] [blame] | 69 | |
| 70 | if (bridge) { |
| 71 | sysbus_realize_and_unref(SYS_BUS_DEVICE(bridge), &error_fatal); |
| 72 | } |
| 73 | |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 74 | return isabus; |
| 75 | } |
| 76 | |
Philippe Mathieu-Daudé | 7067887 | 2023-02-09 13:32:18 +0100 | [diff] [blame] | 77 | void isa_bus_register_input_irqs(ISABus *bus, qemu_irq *irqs_in) |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 78 | { |
Philippe Mathieu-Daudé | 7067887 | 2023-02-09 13:32:18 +0100 | [diff] [blame] | 79 | bus->irqs_in = irqs_in; |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Philippe Mathieu-Daudé | d2fbec5 | 2023-02-09 11:55:03 +0100 | [diff] [blame] | 82 | qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum) |
| 83 | { |
| 84 | assert(irqnum < ISA_NUM_IRQS); |
| 85 | assert(bus->irqs_in); |
| 86 | return bus->irqs_in[irqnum]; |
| 87 | } |
| 88 | |
Jes Sorensen | 3a38d43 | 2009-08-14 11:36:15 +0200 | [diff] [blame] | 89 | /* |
Philippe Mathieu-Daudé | 7067887 | 2023-02-09 13:32:18 +0100 | [diff] [blame] | 90 | * isa_get_irq() returns the corresponding input qemu_irq entry for the i8259. |
Jes Sorensen | 3a38d43 | 2009-08-14 11:36:15 +0200 | [diff] [blame] | 91 | * |
| 92 | * This function is only for special cases such as the 'ferr', and |
| 93 | * temporary use for normal devices until they are converted to qdev. |
| 94 | */ |
Paolo Bonzini | 3c29e18 | 2019-12-13 13:00:43 +0100 | [diff] [blame] | 95 | qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq) |
Jes Sorensen | 3a38d43 | 2009-08-14 11:36:15 +0200 | [diff] [blame] | 96 | { |
Andreas Färber | 2ae0e48 | 2013-06-07 14:11:07 +0200 | [diff] [blame] | 97 | assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus); |
Philippe Mathieu-Daudé | d2fbec5 | 2023-02-09 11:55:03 +0100 | [diff] [blame] | 98 | return isa_bus_get_irq(isabus, isairq); |
Jes Sorensen | 3a38d43 | 2009-08-14 11:36:15 +0200 | [diff] [blame] | 99 | } |
| 100 | |
Paolo Bonzini | 3c29e18 | 2019-12-13 13:00:43 +0100 | [diff] [blame] | 101 | void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq) |
Efimov Vasily | 2502630 | 2016-06-22 15:24:56 +0300 | [diff] [blame] | 102 | { |
Philippe Mathieu-Daudé | d2fbec5 | 2023-02-09 11:55:03 +0100 | [diff] [blame] | 103 | qemu_irq input_irq = isa_get_irq(isadev, isairq); |
| 104 | qdev_connect_gpio_out(DEVICE(isadev), gpioirq, input_irq); |
Efimov Vasily | 2502630 | 2016-06-22 15:24:56 +0300 | [diff] [blame] | 105 | } |
| 106 | |
Hervé Poussineau | 5484f30 | 2016-02-03 11:28:57 -0500 | [diff] [blame] | 107 | void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16) |
| 108 | { |
| 109 | assert(bus && dma8 && dma16); |
| 110 | assert(!bus->dma[0] && !bus->dma[1]); |
| 111 | bus->dma[0] = dma8; |
| 112 | bus->dma[1] = dma16; |
| 113 | } |
| 114 | |
Philippe Mathieu-Daudé | dc8d6cf | 2023-02-15 15:38:19 +0100 | [diff] [blame] | 115 | IsaDma *isa_bus_get_dma(ISABus *bus, int nchan) |
Hervé Poussineau | 5484f30 | 2016-02-03 11:28:57 -0500 | [diff] [blame] | 116 | { |
| 117 | assert(bus); |
| 118 | return bus->dma[nchan > 3 ? 1 : 0]; |
| 119 | } |
| 120 | |
Richard Henderson | 0d95952 | 2011-08-16 09:02:36 -0700 | [diff] [blame] | 121 | static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport) |
Gleb Natapov | dee41d5 | 2010-12-08 13:34:56 +0200 | [diff] [blame] | 122 | { |
Richard Henderson | 0d95952 | 2011-08-16 09:02:36 -0700 | [diff] [blame] | 123 | if (dev && (dev->ioport_id == 0 || ioport < dev->ioport_id)) { |
| 124 | dev->ioport_id = ioport; |
Gleb Natapov | dee41d5 | 2010-12-08 13:34:56 +0200 | [diff] [blame] | 125 | } |
Gleb Natapov | dee41d5 | 2010-12-08 13:34:56 +0200 | [diff] [blame] | 126 | } |
| 127 | |
Richard Henderson | 78e2059 | 2011-08-10 15:28:12 -0700 | [diff] [blame] | 128 | void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start) |
| 129 | { |
Philippe Mathieu-Daudé | e5bf277 | 2023-01-20 12:45:54 +0100 | [diff] [blame] | 130 | memory_region_add_subregion(isa_address_space_io(dev), start, io); |
Richard Henderson | 0d95952 | 2011-08-16 09:02:36 -0700 | [diff] [blame] | 131 | isa_init_ioport(dev, start); |
Richard Henderson | 78e2059 | 2011-08-10 15:28:12 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Thomas Huth | 9405d87 | 2021-04-16 14:52:56 +0200 | [diff] [blame] | 134 | int isa_register_portio_list(ISADevice *dev, |
| 135 | PortioList *piolist, uint16_t start, |
| 136 | const MemoryRegionPortio *pio_start, |
| 137 | void *opaque, const char *name) |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 138 | { |
Marc-André Lureau | e305a16 | 2016-07-13 02:11:59 +0200 | [diff] [blame] | 139 | assert(piolist && !piolist->owner); |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 140 | |
Thomas Huth | 9405d87 | 2021-04-16 14:52:56 +0200 | [diff] [blame] | 141 | if (!isabus) { |
| 142 | return -ENODEV; |
| 143 | } |
| 144 | |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 145 | /* START is how we should treat DEV, regardless of the actual |
| 146 | contents of the portio array. This is how the old code |
| 147 | actually handled e.g. the FDC device. */ |
Richard Henderson | 0d95952 | 2011-08-16 09:02:36 -0700 | [diff] [blame] | 148 | isa_init_ioport(dev, start); |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 149 | |
Marc-André Lureau | e305a16 | 2016-07-13 02:11:59 +0200 | [diff] [blame] | 150 | portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name); |
Philippe Mathieu-Daudé | e5bf277 | 2023-01-20 12:45:54 +0100 | [diff] [blame] | 151 | portio_list_add(piolist, isa_address_space_io(dev), start); |
Thomas Huth | 9405d87 | 2021-04-16 14:52:56 +0200 | [diff] [blame] | 152 | |
| 153 | return 0; |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 154 | } |
| 155 | |
Markus Armbruster | 0fe9d90 | 2020-06-10 07:32:07 +0200 | [diff] [blame] | 156 | ISADevice *isa_new(const char *name) |
| 157 | { |
| 158 | return ISA_DEVICE(qdev_new(name)); |
| 159 | } |
| 160 | |
| 161 | ISADevice *isa_try_new(const char *name) |
| 162 | { |
| 163 | return ISA_DEVICE(qdev_try_new(name)); |
| 164 | } |
| 165 | |
Hervé Poussineau | 48a18b3 | 2011-12-15 22:09:51 +0100 | [diff] [blame] | 166 | ISADevice *isa_create_simple(ISABus *bus, const char *name) |
Gerd Hoffmann | 924f6d7 | 2009-09-10 11:43:29 +0200 | [diff] [blame] | 167 | { |
| 168 | ISADevice *dev; |
| 169 | |
Markus Armbruster | 96927c7 | 2020-06-10 07:32:08 +0200 | [diff] [blame] | 170 | dev = isa_new(name); |
| 171 | isa_realize_and_unref(dev, bus, &error_fatal); |
Gerd Hoffmann | 924f6d7 | 2009-09-10 11:43:29 +0200 | [diff] [blame] | 172 | return dev; |
| 173 | } |
| 174 | |
Markus Armbruster | 0fe9d90 | 2020-06-10 07:32:07 +0200 | [diff] [blame] | 175 | bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp) |
| 176 | { |
| 177 | return qdev_realize_and_unref(&dev->parent_obj, &bus->parent_obj, errp); |
| 178 | } |
| 179 | |
Philippe Mathieu-Daudé | 23c69bb | 2023-02-07 22:47:20 +0100 | [diff] [blame] | 180 | ISABus *isa_bus_from_device(ISADevice *dev) |
| 181 | { |
| 182 | return ISA_BUS(qdev_get_parent_bus(DEVICE(dev))); |
| 183 | } |
| 184 | |
Aurelien Jarno | 14e7a64 | 2012-09-08 16:58:57 +0200 | [diff] [blame] | 185 | ISADevice *isa_vga_init(ISABus *bus) |
| 186 | { |
Gautam Agrawal | f9bcb2d | 2022-05-01 17:55:05 +0530 | [diff] [blame] | 187 | vga_interface_created = true; |
Aurelien Jarno | 14e7a64 | 2012-09-08 16:58:57 +0200 | [diff] [blame] | 188 | switch (vga_interface_type) { |
| 189 | case VGA_CIRRUS: |
| 190 | return isa_create_simple(bus, "isa-cirrus-vga"); |
| 191 | case VGA_QXL: |
Alistair Francis | 1081ed2 | 2017-11-08 14:57:30 -0800 | [diff] [blame] | 192 | error_report("%s: qxl: no PCI bus", __func__); |
Aurelien Jarno | 14e7a64 | 2012-09-08 16:58:57 +0200 | [diff] [blame] | 193 | return NULL; |
| 194 | case VGA_STD: |
| 195 | return isa_create_simple(bus, "isa-vga"); |
| 196 | case VGA_VMWARE: |
Alistair Francis | 1081ed2 | 2017-11-08 14:57:30 -0800 | [diff] [blame] | 197 | error_report("%s: vmware_vga: no PCI bus", __func__); |
Aurelien Jarno | 14e7a64 | 2012-09-08 16:58:57 +0200 | [diff] [blame] | 198 | return NULL; |
Gerd Hoffmann | a94f0c5 | 2014-09-10 14:28:48 +0200 | [diff] [blame] | 199 | case VGA_VIRTIO: |
Alistair Francis | 1081ed2 | 2017-11-08 14:57:30 -0800 | [diff] [blame] | 200 | error_report("%s: virtio-vga: no PCI bus", __func__); |
Gerd Hoffmann | a94f0c5 | 2014-09-10 14:28:48 +0200 | [diff] [blame] | 201 | return NULL; |
Aurelien Jarno | 14e7a64 | 2012-09-08 16:58:57 +0200 | [diff] [blame] | 202 | case VGA_NONE: |
| 203 | default: |
| 204 | return NULL; |
| 205 | } |
| 206 | } |
| 207 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 208 | static void isabus_bridge_class_init(ObjectClass *klass, void *data) |
| 209 | { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 210 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 211 | |
Thomas Huth | 5658ffa | 2017-01-20 16:53:59 +0100 | [diff] [blame] | 212 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 213 | dc->fw_name = "isa"; |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 214 | } |
| 215 | |
Andreas Färber | 8c43a6f | 2013-01-10 16:19:07 +0100 | [diff] [blame] | 216 | static const TypeInfo isabus_bridge_info = { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 217 | .name = "isabus-bridge", |
| 218 | .parent = TYPE_SYS_BUS_DEVICE, |
| 219 | .instance_size = sizeof(SysBusDevice), |
| 220 | .class_init = isabus_bridge_class_init, |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 221 | }; |
| 222 | |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 223 | static void isa_device_class_init(ObjectClass *klass, void *data) |
| 224 | { |
| 225 | DeviceClass *k = DEVICE_CLASS(klass); |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 226 | k->bus_type = TYPE_ISA_BUS; |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 227 | } |
| 228 | |
Andreas Färber | 8c43a6f | 2013-01-10 16:19:07 +0100 | [diff] [blame] | 229 | static const TypeInfo isa_device_type_info = { |
Anthony Liguori | 8f04ee0 | 2011-12-04 11:52:49 -0600 | [diff] [blame] | 230 | .name = TYPE_ISA_DEVICE, |
| 231 | .parent = TYPE_DEVICE, |
| 232 | .instance_size = sizeof(ISADevice), |
| 233 | .abstract = true, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 234 | .class_init = isa_device_class_init, |
Anthony Liguori | 8f04ee0 | 2011-12-04 11:52:49 -0600 | [diff] [blame] | 235 | }; |
| 236 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 237 | static void isabus_register_types(void) |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 238 | { |
Hervé Poussineau | 5484f30 | 2016-02-03 11:28:57 -0500 | [diff] [blame] | 239 | type_register_static(&isa_dma_info); |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 240 | type_register_static(&isa_bus_info); |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 241 | type_register_static(&isabus_bridge_info); |
Anthony Liguori | 8f04ee0 | 2011-12-04 11:52:49 -0600 | [diff] [blame] | 242 | type_register_static(&isa_device_type_info); |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 243 | } |
| 244 | |
Gleb Natapov | 6a26e11 | 2010-12-08 13:34:57 +0200 | [diff] [blame] | 245 | static char *isabus_get_fw_dev_path(DeviceState *dev) |
| 246 | { |
Andreas Färber | 4a17cc4 | 2013-06-07 13:49:13 +0200 | [diff] [blame] | 247 | ISADevice *d = ISA_DEVICE(dev); |
Gleb Natapov | 6a26e11 | 2010-12-08 13:34:57 +0200 | [diff] [blame] | 248 | char path[40]; |
| 249 | int off; |
| 250 | |
| 251 | off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev)); |
Richard Henderson | ebf47c2 | 2011-08-15 11:59:09 -0700 | [diff] [blame] | 252 | if (d->ioport_id) { |
| 253 | snprintf(path + off, sizeof(path) - off, "@%04x", d->ioport_id); |
Gleb Natapov | 6a26e11 | 2010-12-08 13:34:57 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Jim Meyering | a5cf826 | 2012-10-04 13:09:44 +0200 | [diff] [blame] | 256 | return g_strdup(path); |
Gleb Natapov | 6a26e11 | 2010-12-08 13:34:57 +0200 | [diff] [blame] | 257 | } |
| 258 | |
Avi Kivity | c839ade | 2011-08-15 17:17:35 +0300 | [diff] [blame] | 259 | MemoryRegion *isa_address_space(ISADevice *dev) |
| 260 | { |
Hervé Poussineau | bb2ed00 | 2015-02-01 09:12:50 +0100 | [diff] [blame] | 261 | if (dev) { |
| 262 | return isa_bus_from_device(dev)->address_space; |
| 263 | } |
| 264 | |
| 265 | return isabus->address_space; |
Avi Kivity | c839ade | 2011-08-15 17:17:35 +0300 | [diff] [blame] | 266 | } |
| 267 | |
Julien Grall | ac10027 | 2012-09-19 12:50:02 +0100 | [diff] [blame] | 268 | MemoryRegion *isa_address_space_io(ISADevice *dev) |
| 269 | { |
| 270 | if (dev) { |
| 271 | return isa_bus_from_device(dev)->address_space_io; |
| 272 | } |
| 273 | |
| 274 | return isabus->address_space_io; |
| 275 | } |
| 276 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 277 | type_init(isabus_register_types) |