diff mbox

[V10,1/8] isa: add isa_address_space_io

Message ID 35452e244b3dd7f3ebc972d39406a2f2b4ab2718.1348052498.git.julien.grall@citrix.com
State New
Headers show

Commit Message

Julien Grall Sept. 19, 2012, 11:50 a.m. UTC
This function permits to retrieve ISA IO address space.
It will be usefull when we need to pass IO address space as argument.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
---
 hw/isa-bus.c |    9 +++++++++
 hw/isa.h     |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)

Comments

Andreas Färber Nov. 25, 2012, 12:39 p.m. UTC | #1
Am 19.09.2012 13:50, schrieb Julien Grall:
> This function permits to retrieve ISA IO address space.
> It will be usefull when we need to pass IO address space as argument.
> 
> Signed-off-by: Julien Grall <julien.grall@citrix.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

A note below:

> ---
>  hw/isa-bus.c |    9 +++++++++
>  hw/isa.h     |    1 +
>  2 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/isa-bus.c b/hw/isa-bus.c
> index f9b2373..c1d8309 100644
> --- a/hw/isa-bus.c
> +++ b/hw/isa-bus.c
> @@ -244,4 +244,13 @@ MemoryRegion *isa_address_space(ISADevice *dev)
>      return get_system_memory();
>  }
>  
> +MemoryRegion *isa_address_space_io(ISADevice *dev)
> +{
> +    if (dev) {
> +        return isa_bus_from_device(dev)->address_space_io;

This assumes that the device is attached to an ISABus already...

> +    }
> +
> +    return isabus->address_space_io;

...and that the ISABus has been set globally, which I think is an
assumption we make elsewhere as well, i.e. it cannot be used at
instance_init time but in qdev initfn/realizefn.

Andreas

> +}
> +
>  type_init(isabus_register_types)
> diff --git a/hw/isa.h b/hw/isa.h
> index dc97052..3891c1f 100644
> --- a/hw/isa.h
> +++ b/hw/isa.h
> @@ -43,6 +43,7 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
>  qemu_irq isa_get_irq(ISADevice *dev, int isairq);
>  void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
>  MemoryRegion *isa_address_space(ISADevice *dev);
> +MemoryRegion *isa_address_space_io(ISADevice *dev);
>  ISADevice *isa_create(ISABus *bus, const char *name);
>  ISADevice *isa_try_create(ISABus *bus, const char *name);
>  ISADevice *isa_create_simple(ISABus *bus, const char *name);
>
diff mbox

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index f9b2373..c1d8309 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -244,4 +244,13 @@  MemoryRegion *isa_address_space(ISADevice *dev)
     return get_system_memory();
 }
 
+MemoryRegion *isa_address_space_io(ISADevice *dev)
+{
+    if (dev) {
+        return isa_bus_from_device(dev)->address_space_io;
+    }
+
+    return isabus->address_space_io;
+}
+
 type_init(isabus_register_types)
diff --git a/hw/isa.h b/hw/isa.h
index dc97052..3891c1f 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -43,6 +43,7 @@  void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
 MemoryRegion *isa_address_space(ISADevice *dev);
+MemoryRegion *isa_address_space_io(ISADevice *dev);
 ISADevice *isa_create(ISABus *bus, const char *name);
 ISADevice *isa_try_create(ISABus *bus, const char *name);
 ISADevice *isa_create_simple(ISABus *bus, const char *name);