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: [PATCH 10/11] stm32f205: Create armv7m object without using armv7m_init()
Date: Tue, 28 Feb 2017 14:09:16 +0000 [thread overview]
Message-ID: <87a8962yr7.fsf@linaro.org> (raw)
In-Reply-To: <1487604965-23220-11-git-send-email-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> Switch the stm32f205 SoC to create the armv7m object directly
> rather than via the armv7m_init() wrapper. This fits better
> with the SoC model's very QOMified design.
>
> In particular this means we can push loading the guest image
> out to the top level board code where it belongs, rather
> than the SoC object having a QOM property for the filename
> to load.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> include/hw/arm/stm32f205_soc.h | 4 +++-
> hw/arm/netduino2.c | 7 ++++---
> hw/arm/stm32f205_soc.c | 16 +++++++++++++---
> 3 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h
> index 1332141..e2dce11 100644
> --- a/include/hw/arm/stm32f205_soc.h
> +++ b/include/hw/arm/stm32f205_soc.h
> @@ -31,6 +31,7 @@
> #include "hw/adc/stm32f2xx_adc.h"
> #include "hw/or-irq.h"
> #include "hw/ssi/stm32f2xx_spi.h"
> +#include "hw/arm/armv7m.h"
>
> #define TYPE_STM32F205_SOC "stm32f205-soc"
> #define STM32F205_SOC(obj) \
> @@ -51,9 +52,10 @@ typedef struct STM32F205State {
> SysBusDevice parent_obj;
> /*< public >*/
>
> - char *kernel_filename;
> char *cpu_model;
>
> + ARMv7MState armv7m;
> +
> STM32F2XXSyscfgState syscfg;
> STM32F2XXUsartState usart[STM_NUM_USARTS];
> STM32F2XXTimerState timer[STM_NUM_TIMERS];
> diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c
> index 23d7928..3cfe332 100644
> --- a/hw/arm/netduino2.c
> +++ b/hw/arm/netduino2.c
> @@ -27,17 +27,18 @@
> #include "hw/boards.h"
> #include "qemu/error-report.h"
> #include "hw/arm/stm32f205_soc.h"
> +#include "hw/arm/arm.h"
>
> static void netduino2_init(MachineState *machine)
> {
> DeviceState *dev;
>
> dev = qdev_create(NULL, TYPE_STM32F205_SOC);
> - if (machine->kernel_filename) {
> - qdev_prop_set_string(dev, "kernel-filename", machine->kernel_filename);
> - }
> qdev_prop_set_string(dev, "cpu-model", "cortex-m3");
> object_property_set_bool(OBJECT(dev), true, "realized", &error_fatal);
> +
> + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
> + FLASH_SIZE);
> }
>
> static void netduino2_machine_init(MachineClass *mc)
> diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
> index 38425bd..e6bd73a 100644
> --- a/hw/arm/stm32f205_soc.c
> +++ b/hw/arm/stm32f205_soc.c
> @@ -49,6 +49,9 @@ static void stm32f205_soc_initfn(Object *obj)
> STM32F205State *s = STM32F205_SOC(obj);
> int i;
>
> + object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M);
> + qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default());
> +
> object_initialize(&s->syscfg, sizeof(s->syscfg), TYPE_STM32F2XX_SYSCFG);
> qdev_set_parent_bus(DEVICE(&s->syscfg), sysbus_get_default());
>
> @@ -110,8 +113,16 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
> vmstate_register_ram_global(sram);
> memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
>
> - nvic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,
> - s->kernel_filename, s->cpu_model);
> + nvic = DEVICE(&s->armv7m);
> + qdev_prop_set_uint32(nvic, "num-irq", 96);
> + qdev_prop_set_string(nvic, "cpu-model", s->cpu_model);
> + object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
> + "memory", &error_abort);
> + object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err);
> + if (err != NULL) {
> + error_propagate(errp, err);
> + return;
> + }
>
> /* System configuration controller */
> dev = DEVICE(&s->syscfg);
> @@ -192,7 +203,6 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
> }
>
> static Property stm32f205_soc_properties[] = {
> - DEFINE_PROP_STRING("kernel-filename", STM32F205State, kernel_filename),
> DEFINE_PROP_STRING("cpu-model", STM32F205State, cpu_model),
> DEFINE_PROP_END_OF_LIST(),
> };
--
Alex Bennée
WARNING: multiple messages have this Message-ID (diff)
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 10/11] stm32f205: Create armv7m object without using armv7m_init()
Date: Tue, 28 Feb 2017 14:09:16 +0000 [thread overview]
Message-ID: <87a8962yr7.fsf@linaro.org> (raw)
In-Reply-To: <1487604965-23220-11-git-send-email-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> Switch the stm32f205 SoC to create the armv7m object directly
> rather than via the armv7m_init() wrapper. This fits better
> with the SoC model's very QOMified design.
>
> In particular this means we can push loading the guest image
> out to the top level board code where it belongs, rather
> than the SoC object having a QOM property for the filename
> to load.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> include/hw/arm/stm32f205_soc.h | 4 +++-
> hw/arm/netduino2.c | 7 ++++---
> hw/arm/stm32f205_soc.c | 16 +++++++++++++---
> 3 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h
> index 1332141..e2dce11 100644
> --- a/include/hw/arm/stm32f205_soc.h
> +++ b/include/hw/arm/stm32f205_soc.h
> @@ -31,6 +31,7 @@
> #include "hw/adc/stm32f2xx_adc.h"
> #include "hw/or-irq.h"
> #include "hw/ssi/stm32f2xx_spi.h"
> +#include "hw/arm/armv7m.h"
>
> #define TYPE_STM32F205_SOC "stm32f205-soc"
> #define STM32F205_SOC(obj) \
> @@ -51,9 +52,10 @@ typedef struct STM32F205State {
> SysBusDevice parent_obj;
> /*< public >*/
>
> - char *kernel_filename;
> char *cpu_model;
>
> + ARMv7MState armv7m;
> +
> STM32F2XXSyscfgState syscfg;
> STM32F2XXUsartState usart[STM_NUM_USARTS];
> STM32F2XXTimerState timer[STM_NUM_TIMERS];
> diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c
> index 23d7928..3cfe332 100644
> --- a/hw/arm/netduino2.c
> +++ b/hw/arm/netduino2.c
> @@ -27,17 +27,18 @@
> #include "hw/boards.h"
> #include "qemu/error-report.h"
> #include "hw/arm/stm32f205_soc.h"
> +#include "hw/arm/arm.h"
>
> static void netduino2_init(MachineState *machine)
> {
> DeviceState *dev;
>
> dev = qdev_create(NULL, TYPE_STM32F205_SOC);
> - if (machine->kernel_filename) {
> - qdev_prop_set_string(dev, "kernel-filename", machine->kernel_filename);
> - }
> qdev_prop_set_string(dev, "cpu-model", "cortex-m3");
> object_property_set_bool(OBJECT(dev), true, "realized", &error_fatal);
> +
> + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
> + FLASH_SIZE);
> }
>
> static void netduino2_machine_init(MachineClass *mc)
> diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
> index 38425bd..e6bd73a 100644
> --- a/hw/arm/stm32f205_soc.c
> +++ b/hw/arm/stm32f205_soc.c
> @@ -49,6 +49,9 @@ static void stm32f205_soc_initfn(Object *obj)
> STM32F205State *s = STM32F205_SOC(obj);
> int i;
>
> + object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M);
> + qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default());
> +
> object_initialize(&s->syscfg, sizeof(s->syscfg), TYPE_STM32F2XX_SYSCFG);
> qdev_set_parent_bus(DEVICE(&s->syscfg), sysbus_get_default());
>
> @@ -110,8 +113,16 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
> vmstate_register_ram_global(sram);
> memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
>
> - nvic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,
> - s->kernel_filename, s->cpu_model);
> + nvic = DEVICE(&s->armv7m);
> + qdev_prop_set_uint32(nvic, "num-irq", 96);
> + qdev_prop_set_string(nvic, "cpu-model", s->cpu_model);
> + object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
> + "memory", &error_abort);
> + object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err);
> + if (err != NULL) {
> + error_propagate(errp, err);
> + return;
> + }
>
> /* System configuration controller */
> dev = DEVICE(&s->syscfg);
> @@ -192,7 +203,6 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
> }
>
> static Property stm32f205_soc_properties[] = {
> - DEFINE_PROP_STRING("kernel-filename", STM32F205State, kernel_filename),
> DEFINE_PROP_STRING("cpu-model", STM32F205State, cpu_model),
> DEFINE_PROP_END_OF_LIST(),
> };
--
Alex Bennée
next prev parent reply other threads:[~2017-02-28 14:09 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 15:35 [PATCH 00/11] ARMv7M: QOMify Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-20 15:35 ` [PATCH 01/11] armv7m: Abstract out the "load kernel" code Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-20 16:23 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:35 ` Alistair Francis
2017-02-21 11:35 ` [Qemu-devel] " Alistair Francis
2017-02-28 13:57 ` Alex Bennée
2017-02-28 13:57 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:35 ` [PATCH 02/11] armv7m: Move NVICState struct definition into header Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-20 16:24 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-28 13:58 ` Alex Bennée
2017-02-28 13:58 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:35 ` [PATCH 03/11] armv7m: QOMify the armv7m container Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-28 13:56 ` Alex Bennée
2017-02-28 13:56 ` [Qemu-devel] " Alex Bennée
2017-02-28 14:05 ` Peter Maydell
2017-02-28 14:05 ` [Qemu-devel] " Peter Maydell
2017-04-17 3:18 ` [Qemu-arm] " Philippe Mathieu-Daudé
2017-04-17 3:18 ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-04-17 3:59 ` Philippe Mathieu-Daudé
2017-04-17 3:59 ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-04-20 14:17 ` Peter Maydell
2017-04-20 14:17 ` [Qemu-devel] " Peter Maydell
2017-02-20 15:35 ` [PATCH 04/11] armv7m: Use QOMified armv7m object in armv7m_init() Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-21 11:35 ` Alistair Francis
2017-02-21 11:35 ` [Qemu-devel] " Alistair Francis
2017-02-28 13:59 ` Alex Bennée
2017-02-28 13:59 ` [Qemu-devel] " Alex Bennée
2017-04-17 3:23 ` [Qemu-arm] " Philippe Mathieu-Daudé
2017-04-17 3:23 ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-02-20 15:35 ` [PATCH 05/11] armv7m: Make ARMv7M object take memory region link Peter Maydell
2017-02-20 15:35 ` [Qemu-devel] " Peter Maydell
2017-02-28 14:02 ` Alex Bennée
2017-02-28 14:02 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:36 ` [PATCH 06/11] armv7m: Make NVIC expose a memory region rather than mapping itself Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-28 14:04 ` Alex Bennée
2017-02-28 14:04 ` [Qemu-devel] " Alex Bennée
2017-04-17 3:26 ` Philippe Mathieu-Daudé
2017-02-20 15:36 ` [PATCH 07/11] armv7m: Make bitband device take the address space to access Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-28 14:06 ` Alex Bennée
2017-02-28 14:06 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:36 ` [PATCH 08/11] armv7m: Don't put core v7M devices under CONFIG_STELLARIS Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-20 16:40 ` Philippe Mathieu-Daudé
2017-02-28 14:06 ` Alex Bennée
2017-02-28 14:06 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:36 ` [PATCH 09/11] armv7m: Split systick out from NVIC Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-20 17:43 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-20 18:51 ` Peter Maydell
2017-02-20 18:51 ` [Qemu-devel] " Peter Maydell
2017-04-17 4:08 ` Philippe Mathieu-Daudé
2017-04-17 4:08 ` Philippe Mathieu-Daudé
2017-02-24 14:29 ` Alex Bennée
2017-02-24 14:29 ` [Qemu-devel] " Alex Bennée
2017-02-24 14:58 ` Peter Maydell
2017-02-24 14:58 ` [Qemu-devel] " Peter Maydell
2017-02-20 15:36 ` [PATCH 10/11] stm32f205: Create armv7m object without using armv7m_init() Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-20 17:45 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:32 ` Alistair Francis
2017-02-21 11:32 ` [Qemu-devel] " Alistair Francis
2017-02-28 14:09 ` Alex Bennée [this message]
2017-02-28 14:09 ` [Qemu-devel] " Alex Bennée
2017-02-20 15:36 ` [PATCH 11/11] stm32f205: Rename 'nvic' local to 'armv7m' Peter Maydell
2017-02-20 15:36 ` [Qemu-devel] " Peter Maydell
2017-02-20 17:46 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-02-21 11:34 ` Alistair Francis
2017-02-21 11:34 ` [Qemu-devel] " Alistair Francis
2017-02-28 14:10 ` Alex Bennée
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=87a8962yr7.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.