diff mbox

[17/24] arm11mpcore: use sysbus_init_mmio_cb2

Message ID 1312823229-12822-18-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Aug. 8, 2011, 5:07 p.m. UTC
This tells the sysbus code it need not use IO_MEM_UNASSIGNED.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/arm11mpcore.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Comments

Peter Maydell Aug. 12, 2011, 1:23 p.m. UTC | #1
On 8 August 2011 18:07, Avi Kivity <avi@redhat.com> wrote:
> This tells the sysbus code it need not use IO_MEM_UNASSIGNED.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  hw/arm11mpcore.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
> index b47707f..7d60ef6 100644
> --- a/hw/arm11mpcore.c
> +++ b/hw/arm11mpcore.c
> @@ -54,6 +54,11 @@ static void mpcore_rirq_map(SysBusDevice *dev, target_phys_addr_t base)
>     sysbus_mmio_map(s->priv, 0, base);
>  }
>
> +static void mpcore_rirq_unmap(SysBusDevice *dev, target_phys_addr_t base)
> +{
> +    /* nothing to do */
> +}
> +
>  static int realview_mpcore_init(SysBusDevice *dev)
>  {
>     mpcore_rirq_state *s = FROM_SYSBUS(mpcore_rirq_state, dev);
> @@ -79,7 +84,7 @@ static int realview_mpcore_init(SysBusDevice *dev)
>         }
>     }
>     qdev_init_gpio_in(&dev->qdev, mpcore_rirq_set_irq, 64);
> -    sysbus_init_mmio_cb(dev, 0x2000, mpcore_rirq_map);
> +    sysbus_init_mmio_cb2(dev, mpcore_rirq_map, mpcore_rirq_unmap);
>     return 0;
>  }

Since the mpcore code here is only using sysbus mmio callbacks as
a way to pass things through to a sysbus mmio provided by another
device, I think it would be cleaner to just have a way to say "my
mmio is actually provided by this other device".

For instance you could have
MemoryRegion* sysbus_mmio_get_region(SysBusDevice *dev, int n))
{
    return dev->mmio[n].memory;
}

and then realview_mpcore_init() can just
  sysbus_init_mmio_region(dev, sysbus_mmio_get_region(s->priv, 0));

Or you could have a sysbus_pass_mmio() which worked like
sysbus_pass_irq() and just said "my mmios are all this other
device's mmios"; that's less flexible though.

-- PMM
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Aug. 14, 2011, 6:45 p.m. UTC | #2
On 08/12/2011 06:23 AM, Peter Maydell wrote:
> >    static int realview_mpcore_init(SysBusDevice *dev)
> >    {
> >       mpcore_rirq_state *s = FROM_SYSBUS(mpcore_rirq_state, dev);
> >  @@ -79,7 +84,7 @@ static int realview_mpcore_init(SysBusDevice *dev)
> >           }
> >       }
> >       qdev_init_gpio_in(&dev->qdev, mpcore_rirq_set_irq, 64);
> >  -    sysbus_init_mmio_cb(dev, 0x2000, mpcore_rirq_map);
> >  +    sysbus_init_mmio_cb2(dev, mpcore_rirq_map, mpcore_rirq_unmap);
> >       return 0;
> >    }
>
> Since the mpcore code here is only using sysbus mmio callbacks as
> a way to pass things through to a sysbus mmio provided by another
> device, I think it would be cleaner to just have a way to say "my
> mmio is actually provided by this other device".
>
> For instance you could have
> MemoryRegion* sysbus_mmio_get_region(SysBusDevice *dev, int n))
> {
>      return dev->mmio[n].memory;
> }
>
> and then realview_mpcore_init() can just
>    sysbus_init_mmio_region(dev, sysbus_mmio_get_region(s->priv, 0));
>
> Or you could have a sysbus_pass_mmio() which worked like
> sysbus_pass_irq() and just said "my mmios are all this other
> device's mmios"; that's less flexible though.
>
>

Yes. Yet another option is to create a container MemoryRegion and pass 
it upwards, then allow the device that actually implements that mmio to 
register its regions with the container.

I'll leave this to the device maintainer though.
diff mbox

Patch

diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index b47707f..7d60ef6 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -54,6 +54,11 @@  static void mpcore_rirq_map(SysBusDevice *dev, target_phys_addr_t base)
     sysbus_mmio_map(s->priv, 0, base);
 }
 
+static void mpcore_rirq_unmap(SysBusDevice *dev, target_phys_addr_t base)
+{
+    /* nothing to do */
+}
+
 static int realview_mpcore_init(SysBusDevice *dev)
 {
     mpcore_rirq_state *s = FROM_SYSBUS(mpcore_rirq_state, dev);
@@ -79,7 +84,7 @@  static int realview_mpcore_init(SysBusDevice *dev)
         }
     }
     qdev_init_gpio_in(&dev->qdev, mpcore_rirq_set_irq, 64);
-    sysbus_init_mmio_cb(dev, 0x2000, mpcore_rirq_map);
+    sysbus_init_mmio_cb2(dev, mpcore_rirq_map, mpcore_rirq_unmap);
     return 0;
 }