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 01/11] armv7m: Abstract out the "load kernel" code
Date: Tue, 28 Feb 2017 13:57:31 +0000	[thread overview]
Message-ID: <87k28a2zas.fsf@linaro.org> (raw)
In-Reply-To: <1487604965-23220-2-git-send-email-peter.maydell@linaro.org>


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

> Abstract the "load kernel" code out of armv7m_init() into its own
> function.  This includes the registration of the CPU reset function,
> to parallel how we handle this for A profile cores.
>
> We make the function public so that boards which choose to
> directly instantiate an ARMv7M device object can call it.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

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

> ---
>  include/hw/arm/arm.h | 12 ++++++++++++
>  hw/arm/armv7m.c      | 23 ++++++++++++++++++-----
>  2 files changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
> index c175c0e..a3f79d3 100644
> --- a/include/hw/arm/arm.h
> +++ b/include/hw/arm/arm.h
> @@ -26,6 +26,18 @@ typedef enum {
>  /* armv7m.c */
>  DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
>                        const char *kernel_filename, const char *cpu_model);
> +/**
> + * armv7m_load_kernel:
> + * @cpu: CPU
> + * @kernel_filename: file to load
> + * @mem_size: mem_size: maximum image size to load
> + *
> + * Load the guest image for an ARMv7M system. This must be called by
> + * any ARMv7M board, either directly or via armv7m_init(). (This is
> + * necessary to ensure that the CPU resets correctly on system reset,
> + * as well as for kernel loading.)
> + */
> +void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size);
>
>  /*
>   * struct used as a parameter of the arm_load_kernel machine init
> diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
> index 0c9ca7b..b2cc6e9 100644
> --- a/hw/arm/armv7m.c
> +++ b/hw/arm/armv7m.c
> @@ -176,10 +176,6 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
>      ARMCPU *cpu;
>      CPUARMState *env;
>      DeviceState *nvic;
> -    int image_size;
> -    uint64_t entry;
> -    uint64_t lowaddr;
> -    int big_endian;
>
>      if (cpu_model == NULL) {
>  	cpu_model = "cortex-m3";
> @@ -199,6 +195,16 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
>      qdev_init_nofail(nvic);
>      sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0,
>                         qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
> +    armv7m_load_kernel(cpu, kernel_filename, mem_size);
> +    return nvic;
> +}
> +
> +void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
> +{
> +    int image_size;
> +    uint64_t entry;
> +    uint64_t lowaddr;
> +    int big_endian;
>
>  #ifdef TARGET_WORDS_BIGENDIAN
>      big_endian = 1;
> @@ -224,8 +230,15 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
>          }
>      }
>
> +    /* CPU objects (unlike devices) are not automatically reset on system
> +     * reset, so we must always register a handler to do so. Unlike
> +     * A-profile CPUs, we don't need to do anything special in the
> +     * handler to arrange that it starts correctly.
> +     * This is arguably the wrong place to do this, but it matches the
> +     * way A-profile does it. Note that this means that every M profile
> +     * board must call this function!
> +     */
>      qemu_register_reset(armv7m_reset, cpu);
> -    return nvic;
>  }
>
>  static Property bitband_properties[] = {


--
Alex Bennée

  parent reply	other threads:[~2017-02-28 13:57 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   ` Alex Bennée [this message]
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
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=87k28a2zas.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.