All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: patches@linaro.org, "Alex Bennée" <alex.bennee@linaro.org>,
	"Alistair Francis" <alistair23@gmail.com>,
	"Michael Davidsaver" <mdavidsaver@gmail.com>
Subject: [Qemu-devel] [PATCH 04/11] armv7m: Use QOMified armv7m object in armv7m_init()
Date: Mon, 20 Feb 2017 15:35:58 +0000	[thread overview]
Message-ID: <1487604965-23220-5-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1487604965-23220-1-git-send-email-peter.maydell@linaro.org>

Make the legacy armv7m_init() function use the newly QOMified
armv7m object rather than doing everything by hand.

We can return the armv7m object rather than the NVIC from
armv7m_init() because its interface to the rest of the
board (GPIOs, etc) is identical.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/armv7m.c | 49 ++++++++++++-------------------------------------
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 56d02d4..36f213c 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -131,21 +131,6 @@ static void bitband_init(Object *obj)
     sysbus_init_mmio(dev, &s->iomem);
 }
 
-static void armv7m_bitband_init(void)
-{
-    DeviceState *dev;
-
-    dev = qdev_create(NULL, TYPE_BITBAND);
-    qdev_prop_set_uint32(dev, "base", 0x20000000);
-    qdev_init_nofail(dev);
-    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x22000000);
-
-    dev = qdev_create(NULL, TYPE_BITBAND);
-    qdev_prop_set_uint32(dev, "base", 0x40000000);
-    qdev_init_nofail(dev);
-    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x42000000);
-}
-
 /* Board init.  */
 
 static const hwaddr bitband_input_addr[ARMV7M_NUM_BITBANDS] = {
@@ -283,35 +268,25 @@ static void armv7m_reset(void *opaque)
 
 /* Init CPU and memory for a v7-M based board.
    mem_size is in bytes.
-   Returns the NVIC array.  */
+   Returns the ARMv7M device.  */
 
 DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
                       const char *kernel_filename, const char *cpu_model)
 {
-    ARMCPU *cpu;
-    CPUARMState *env;
-    DeviceState *nvic;
+    DeviceState *armv7m;
 
     if (cpu_model == NULL) {
-	cpu_model = "cortex-m3";
+        cpu_model = "cortex-m3";
     }
-    cpu = cpu_arm_init(cpu_model);
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
-    env = &cpu->env;
-
-    armv7m_bitband_init();
-
-    nvic = qdev_create(NULL, "armv7m_nvic");
-    qdev_prop_set_uint32(nvic, "num-irq", num_irq);
-    env->nvic = nvic;
-    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;
+
+    armv7m = qdev_create(NULL, "armv7m");
+    qdev_prop_set_uint32(armv7m, "num-irq", num_irq);
+    qdev_prop_set_string(armv7m, "cpu-model", cpu_model);
+    /* This will exit with an error if the user passed us a bad cpu_model */
+    qdev_init_nofail(armv7m);
+
+    armv7m_load_kernel(ARM_CPU(first_cpu), kernel_filename, mem_size);
+    return armv7m;
 }
 
 void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
-- 
2.7.4

  parent reply	other threads:[~2017-02-20 15:36 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 ` Peter Maydell [this message]
2017-02-21 11:35   ` [Qemu-devel] [PATCH 04/11] armv7m: Use QOMified armv7m object in armv7m_init() 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=1487604965-23220-5-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=alistair23@gmail.com \
    --cc=mdavidsaver@gmail.com \
    --cc=patches@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.