All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, patches@linaro.org,
	Alistair Francis <alistair23@gmail.com>,
	Michael Davidsaver <mdavidsaver@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 05/11] armv7m: Make ARMv7M object take memory region link
Date: Tue, 28 Feb 2017 14:02:36 +0000	[thread overview]
Message-ID: <87fuiy2z2b.fsf@linaro.org> (raw)
In-Reply-To: <1487604965-23220-6-git-send-email-peter.maydell@linaro.org>


Peter Maydell <peter.maydell@linaro.org> writes:

> Make the ARMv7M object take a memory region link which it uses
> to wire up the bitband rather than having them always put
> themselves in the system address space.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/hw/arm/armv7m.h | 10 ++++++++++
>  hw/arm/armv7m.c         | 23 ++++++++++++++++++++++-
>  2 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h
> index 193ad71..3333c91 100644
> --- a/include/hw/arm/armv7m.h
> +++ b/include/hw/arm/armv7m.h
> @@ -35,6 +35,9 @@ typedef struct {
>   * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ
>   * + Property "cpu-model": CPU model to instantiate
>   * + Property "num-irq": number of external IRQ lines
> + * + Property "memory": MemoryRegion defining the physical address space
> + *   that CPU accesses see. (The NVIC, bitbanding and other CPU-internal
> + *   devices will be automatically layered on top of this view.)
>   */
>  typedef struct ARMv7MState {
>      /*< private >*/
> @@ -44,8 +47,15 @@ typedef struct ARMv7MState {
>      BitBandState bitband[ARMV7M_NUM_BITBANDS];
>      ARMCPU *cpu;
>
> +    /* MemoryRegion we pass to the CPU, with our devices layered on
> +     * top of the ones the board provides in board_memory.
> +     */
> +    MemoryRegion container;
> +
>      /* Properties */
>      char *cpu_model;
> +    /* MemoryRegion the board provides to us (with its devices, RAM, etc) */
> +    MemoryRegion *board_memory;
>  } ARMv7MState;
>
>  #endif
> diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
> index 36f213c..638c597 100644
> --- a/hw/arm/armv7m.c
> +++ b/hw/arm/armv7m.c
> @@ -18,6 +18,7 @@
>  #include "elf.h"
>  #include "sysemu/qtest.h"
>  #include "qemu/error-report.h"
> +#include "exec/address-spaces.h"
>
>  /* Bitbanded IO.  Each word corresponds to a single bit.  */
>
> @@ -148,6 +149,14 @@ static void armv7m_instance_init(Object *obj)
>
>      /* Can't init the cpu here, we don't yet know which model to use */
>
> +    object_property_add_link(obj, "memory",
> +                             TYPE_MEMORY_REGION,
> +                             (Object **)&s->board_memory,
> +                             qdev_prop_allow_set_link_before_realize,
> +                             OBJ_PROP_LINK_UNREF_ON_RELEASE,
> +                             &error_abort);
> +    memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX);
> +
>      object_initialize(&s->nvic, sizeof(s->nvic), "armv7m_nvic");
>      qdev_set_parent_bus(DEVICE(&s->nvic), sysbus_get_default());
>      object_property_add_alias(obj, "num-irq",
> @@ -170,6 +179,13 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
>      const char *typename;
>      CPUClass *cc;
>
> +    if (!s->board_memory) {
> +        error_setg(errp, "memory property was not set");
> +        return;
> +    }
> +
> +    memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
> +
>      cpustr = g_strsplit(s->cpu_model, ",", 2);
>
>      oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
> @@ -194,6 +210,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>
> +    object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory",
> +                             &error_abort);
>      object_property_set_bool(OBJECT(s->cpu), true, "realized", &err);
>      if (err != NULL) {
>          error_propagate(errp, err);
> @@ -234,7 +252,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
>              return;
>          }
>
> -        sysbus_mmio_map(sbd, 0, bitband_output_addr[i]);
> +        memory_region_add_subregion(&s->container, bitband_output_addr[i],
> +                                    sysbus_mmio_get_region(sbd, 0));
>      }
>  }
>
> @@ -282,6 +301,8 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
>      armv7m = qdev_create(NULL, "armv7m");
>      qdev_prop_set_uint32(armv7m, "num-irq", num_irq);
>      qdev_prop_set_string(armv7m, "cpu-model", cpu_model);
> +    object_property_set_link(OBJECT(armv7m), OBJECT(get_system_memory()),
> +                                     "memory", &error_abort);
>      /* This will exit with an error if the user passed us a bad cpu_model */
>      qdev_init_nofail(armv7m);


--
Alex Bennée

  reply	other threads:[~2017-02-28 14:02 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 15:35 [Qemu-devel] [PATCH 00/11] ARMv7M: QOMify Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] [PATCH 01/11] armv7m: Abstract out the "load kernel" code Peter Maydell
2017-02-20 16:23   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:35     ` Alistair Francis
2017-02-28 13:57   ` [Qemu-devel] " Alex Bennée
2017-02-20 15:35 ` [Qemu-devel] [PATCH 02/11] armv7m: Move NVICState struct definition into header Peter Maydell
2017-02-20 16:24   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-28 13:58   ` [Qemu-devel] " Alex Bennée
2017-02-20 15:35 ` [Qemu-devel] [PATCH 03/11] armv7m: QOMify the armv7m container Peter Maydell
2017-02-28 13:56   ` Alex Bennée
2017-02-28 14:05     ` Peter Maydell
2017-04-17  3:18   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-04-17  3:59   ` Philippe Mathieu-Daudé
2017-04-20 14:17     ` Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] [PATCH 04/11] armv7m: Use QOMified armv7m object in armv7m_init() Peter Maydell
2017-02-21 11:35   ` Alistair Francis
2017-02-28 13:59   ` Alex Bennée
2017-04-17  3:23   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-20 15:35 ` [Qemu-devel] [PATCH 05/11] armv7m: Make ARMv7M object take memory region link Peter Maydell
2017-02-28 14:02   ` Alex Bennée [this message]
2017-02-20 15:36 ` [Qemu-devel] [PATCH 06/11] armv7m: Make NVIC expose a memory region rather than mapping itself Peter Maydell
2017-02-28 14:04   ` Alex Bennée
2017-04-17  3:26   ` Philippe Mathieu-Daudé
2017-02-20 15:36 ` [Qemu-devel] [PATCH 07/11] armv7m: Make bitband device take the address space to access Peter Maydell
2017-02-28 14:06   ` Alex Bennée
2017-02-20 15:36 ` [Qemu-devel] [PATCH 08/11] armv7m: Don't put core v7M devices under CONFIG_STELLARIS Peter Maydell
2017-02-20 16:40   ` Philippe Mathieu-Daudé
2017-02-28 14:06   ` Alex Bennée
2017-02-20 15:36 ` [Qemu-devel] [PATCH 09/11] armv7m: Split systick out from NVIC Peter Maydell
2017-02-20 17:43   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-20 18:51     ` Peter Maydell
2017-04-17  4:08       ` Philippe Mathieu-Daudé
2017-02-24 14:29   ` [Qemu-devel] " Alex Bennée
2017-02-24 14:58     ` Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] [PATCH 10/11] stm32f205: Create armv7m object without using armv7m_init() Peter Maydell
2017-02-20 17:45   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:32     ` Alistair Francis
2017-02-28 14:09   ` [Qemu-devel] " Alex Bennée
2017-02-20 15:36 ` [Qemu-devel] [PATCH 11/11] stm32f205: Rename 'nvic' local to 'armv7m' Peter Maydell
2017-02-20 17:46   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:34     ` Alistair Francis
2017-02-28 14:10   ` [Qemu-devel] " Alex Bennée

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=87fuiy2z2b.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=alistair23@gmail.com \
    --cc=mdavidsaver@gmail.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.