All of lore.kernel.org
 help / color / mirror / Atom feed
From: andrzej zaborowski <balrogg@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Riku Voipio" <riku.voipio@iki.fi>,
	"Juha Riihimäki" <juha.riihimaki@nokia.com>,
	qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 1/2] omap_intc: Use MemoryRegion API
Date: Sat, 17 Sep 2011 02:34:50 +0200	[thread overview]
Message-ID: <CAOq732K7gXnxTasDAdxKH1BVncmPpd=scTh6-OnS17XLETv5Fw@mail.gmail.com> (raw)
In-Reply-To: <1314806132-32389-2-git-send-email-peter.maydell@linaro.org>

On 31 August 2011 17:55, Peter Maydell <peter.maydell@linaro.org> wrote:
> Convert omap_intc to use the MemoryRegion API
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/omap_intc.c |   64 ++++++++++++++++++++++++++-----------------------------
>  1 files changed, 30 insertions(+), 34 deletions(-)
>
> diff --git a/hw/omap_intc.c b/hw/omap_intc.c
> index f1f570e..38637c6 100644
> --- a/hw/omap_intc.c
> +++ b/hw/omap_intc.c
> @@ -19,6 +19,7 @@
>  */
>  #include "hw.h"
>  #include "omap.h"
> +#include "exec-memory.h"
>
>  /* Interrupt Handlers */
>  struct omap_intr_handler_bank_s {
> @@ -34,6 +35,7 @@ struct omap_intr_handler_bank_s {
>  struct omap_intr_handler_s {
>     qemu_irq *pins;
>     qemu_irq parent_intr[2];
> +    MemoryRegion mmio;
>     unsigned char nbanks;
>     int level_only;
>
> @@ -142,7 +144,8 @@ static void omap_set_intr_noedge(void *opaque, int irq, int req)
>         bank->irqs = (bank->inputs &= ~(1 << n)) | bank->swi;
>  }
>
> -static uint32_t omap_inth_read(void *opaque, target_phys_addr_t addr)
> +static uint64_t omap_inth_read(void *opaque, target_phys_addr_t addr,
> +                               unsigned size)
>  {
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
>     int i, offset = addr;
> @@ -220,7 +223,7 @@ static uint32_t omap_inth_read(void *opaque, target_phys_addr_t addr)
>  }
>
>  static void omap_inth_write(void *opaque, target_phys_addr_t addr,
> -                uint32_t value)
> +                            uint64_t value, unsigned size)
>  {
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
>     int i, offset = addr;
> @@ -312,16 +315,14 @@ static void omap_inth_write(void *opaque, target_phys_addr_t addr,
>     OMAP_BAD_REG(addr);
>  }
>
> -static CPUReadMemoryFunc * const omap_inth_readfn[] = {
> -    omap_badwidth_read32,
> -    omap_badwidth_read32,
> -    omap_inth_read,
> -};
> -
> -static CPUWriteMemoryFunc * const omap_inth_writefn[] = {
> -    omap_inth_write,
> -    omap_inth_write,
> -    omap_inth_write,
> +static const MemoryRegionOps omap_inth_mem_ops = {
> +    .read = omap_inth_read,
> +    .write = omap_inth_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,
> +    .valid = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
>  };
>
>  void omap_inth_reset(struct omap_intr_handler_s *s)
> @@ -356,7 +357,6 @@ struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
>                 unsigned long size, unsigned char nbanks, qemu_irq **pins,
>                 qemu_irq parent_irq, qemu_irq parent_fiq, omap_clk clk)
>  {
> -    int iomemtype;
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
>             g_malloc0(sizeof(struct omap_intr_handler_s) +
>                             sizeof(struct omap_intr_handler_bank_s) * nbanks);
> @@ -368,16 +368,16 @@ struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
>     if (pins)
>         *pins = s->pins;
>
> -    omap_inth_reset(s);
> +    memory_region_init_io(&s->mmio, &omap_inth_mem_ops, s, "omap-intc", size);
> +    memory_region_add_subregion(get_system_memory(), base, &s->mmio);
>
> -    iomemtype = cpu_register_io_memory(omap_inth_readfn,
> -                    omap_inth_writefn, s, DEVICE_NATIVE_ENDIAN);
> -    cpu_register_physical_memory(base, size, iomemtype);
> +    omap_inth_reset(s);
>
>     return s;
>  }
>
> -static uint32_t omap2_inth_read(void *opaque, target_phys_addr_t addr)
> +static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,
> +                                unsigned size)
>  {
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
>     int offset = addr;
> @@ -455,7 +455,7 @@ static uint32_t omap2_inth_read(void *opaque, target_phys_addr_t addr)
>  }
>
>  static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
> -                uint32_t value)
> +                             uint64_t value, unsigned size)
>  {
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
>     int offset = addr;
> @@ -558,16 +558,14 @@ static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
>     OMAP_BAD_REG(addr);
>  }
>
> -static CPUReadMemoryFunc * const omap2_inth_readfn[] = {
> -    omap_badwidth_read32,
> -    omap_badwidth_read32,
> -    omap2_inth_read,
> -};
> -
> -static CPUWriteMemoryFunc * const omap2_inth_writefn[] = {
> -    omap2_inth_write,
> -    omap2_inth_write,
> -    omap2_inth_write,
> +static const MemoryRegionOps omap2_inth_mem_ops = {
> +    .read = omap2_inth_read,
> +    .write = omap2_inth_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,
> +    .valid = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
>  };
>
>  struct omap_intr_handler_s *omap2_inth_init(target_phys_addr_t base,
> @@ -575,7 +573,6 @@ struct omap_intr_handler_s *omap2_inth_init(target_phys_addr_t base,
>                 qemu_irq parent_irq, qemu_irq parent_fiq,
>                 omap_clk fclk, omap_clk iclk)
>  {
> -    int iomemtype;
>     struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
>             g_malloc0(sizeof(struct omap_intr_handler_s) +
>                             sizeof(struct omap_intr_handler_bank_s) * nbanks);
> @@ -588,11 +585,10 @@ struct omap_intr_handler_s *omap2_inth_init(target_phys_addr_t base,
>     if (pins)
>         *pins = s->pins;
>
> -    omap_inth_reset(s);
> +    memory_region_init_io(&s->mmio, &omap2_inth_mem_ops, s, "omap2-intc", size);
> +    memory_region_add_subregion(get_system_memory(), base, &s->mmio);
>
> -    iomemtype = cpu_register_io_memory(omap2_inth_readfn,
> -                    omap2_inth_writefn, s, DEVICE_NATIVE_ENDIAN);
> -    cpu_register_physical_memory(base, size, iomemtype);
> +    omap_inth_reset(s);
>
>     return s;
>  }
> --
> 1.7.1
>
>

Both patches look good to me.

Cheers

  reply	other threads:[~2011-09-17  0:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 15:55 [Qemu-devel] [PATCH 0/2] omap_intc: convert to MemoryRegion, qdev Peter Maydell
2011-08-31 15:55 ` [Qemu-devel] [PATCH 1/2] omap_intc: Use MemoryRegion API Peter Maydell
2011-09-17  0:34   ` andrzej zaborowski [this message]
2011-08-31 15:55 ` [Qemu-devel] [PATCH 2/2] omap_intc: Qdevify Peter Maydell
2011-08-31 16:07   ` Peter Maydell
2011-09-01  8:50   ` Avi Kivity
2011-09-01  9:26     ` Peter Maydell
2011-09-09 16:48 ` [Qemu-devel] [PATCH 0/2] omap_intc: convert to MemoryRegion, qdev Peter Maydell
2011-09-16 13:05   ` Anthony Liguori
2011-09-16 14:32     ` Peter Maydell
2011-09-17  0:09       ` andrzej zaborowski
2011-09-16 23:19     ` Edgar E. Iglesias
2011-09-17  0:20       ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOq732K7gXnxTasDAdxKH1BVncmPpd=scTh6-OnS17XLETv5Fw@mail.gmail.com' \
    --to=balrogg@gmail.com \
    --cc=juha.riihimaki@nokia.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.