From: Krzysztof Kozlowski <krzk@kernel.org>
To: Igor Mitsyanko <i.mitsyanko@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Krzysztof Kozlowski" <krzk@kernel.org>
Subject: [Qemu-devel] [PATCH v2 3/3] hw/arm/exynos: QOM-ify the SoC
Date: Sun, 7 May 2017 20:19:40 +0200 [thread overview]
Message-ID: <20170507181940.25882-4-krzk@kernel.org> (raw)
In-Reply-To: <20170507181940.25882-1-krzk@kernel.org>
Convert the Exynos4210 SoC code into a QOM model which is a preferred
approach instead of directly initializing SoC-related devices from the
board file.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/arm/exynos4210.c | 18 +++++++++++++++---
hw/arm/exynos4_boards.c | 9 ++++++---
include/hw/arm/exynos4210.h | 8 ++++++--
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 27a7bf28a5a9..034fc8be9d76 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -160,9 +160,10 @@ static uint64_t exynos4210_calc_affinity(int cpu)
return mp_affinity;
}
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
+static void exynos4210_init(Object *obj)
{
- Exynos4210State *s = g_new(Exynos4210State, 1);
+ MemoryRegion *system_mem = get_system_memory();
+ Exynos4210State *s = EXYNOS4210(obj);
qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
SysBusDevice *busdev;
ObjectClass *cpu_oc;
@@ -402,6 +403,17 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
sysbus_create_simple(TYPE_EXYNOS4210_EHCI, EXYNOS4210_EHCI_BASE_ADDR,
s->irq_table[exynos4210_get_irq(28, 3)]);
+}
+
+static const TypeInfo exynos4210_type_info = {
+ .name = TYPE_EXYNOS4210,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(Exynos4210State),
+ .instance_init = exynos4210_init,
+};
- return s;
+static void exynos4210_register_types(void)
+{
+ type_register_static(&exynos4210_type_info);
}
+type_init(exynos4210_register_types)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 6240b26839cd..5e7c6b562ae2 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -58,7 +58,7 @@ typedef enum Exynos4BoardType {
} Exynos4BoardType;
typedef struct Exynos4BoardState {
- Exynos4210State *soc;
+ Exynos4210State soc;
MemoryRegion dram0_mem;
MemoryRegion dram1_mem;
} Exynos4BoardState;
@@ -162,7 +162,10 @@ exynos4_boards_init_common(MachineState *machine,
exynos4_boards_init_ram(s, get_system_memory(),
exynos4_board_ram_size[board_type]);
- s->soc = exynos4210_init(get_system_memory());
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_EXYNOS4210);
+ object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
return s;
}
@@ -180,7 +183,7 @@ static void smdkc210_init(MachineState *machine)
EXYNOS4_BOARD_SMDKC210);
lan9215_init(SMDK_LAN9118_BASE_ADDR,
- qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)]));
+ qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)]));
arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
}
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
index 098a69ec73d3..116eae62756b 100644
--- a/include/hw/arm/exynos4210.h
+++ b/include/hw/arm/exynos4210.h
@@ -29,6 +29,10 @@
#include "exec/memory.h"
#include "target/arm/cpu-qom.h"
+#define TYPE_EXYNOS4210 "exynos4210"
+#define EXYNOS4210(obj) \
+ OBJECT_CHECK(Exynos4210State, (obj), TYPE_EXYNOS4210)
+
#define EXYNOS4210_NCPUS 2
#define EXYNOS4210_DRAM0_BASE_ADDR 0x40000000
@@ -85,6 +89,8 @@ typedef struct Exynos4210Irq {
} Exynos4210Irq;
typedef struct Exynos4210State {
+ DeviceState parent_obj;
+
ARMCPU *cpu[EXYNOS4210_NCPUS];
Exynos4210Irq irqs;
qemu_irq *irq_table;
@@ -101,8 +107,6 @@ typedef struct Exynos4210State {
void exynos4210_write_secondary(ARMCPU *cpu,
const struct arm_boot_info *info);
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem);
-
/* Initialize exynos4210 IRQ subsystem stub */
qemu_irq *exynos4210_init_irq(Exynos4210Irq *env);
--
2.9.3
next prev parent reply other threads:[~2017-05-07 18:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-07 18:19 [Qemu-devel] [PATCH v2 0/3] hw/arm/exynos: QOM-ify the SoC Krzysztof Kozlowski
2017-05-07 18:19 ` [Qemu-devel] [PATCH v2 1/3] hw/arm/exynos: Move DRAM initialization next boards Krzysztof Kozlowski
2017-05-07 18:19 ` [Qemu-devel] [PATCH v2 2/3] hw/arm/exynos: Declare local variables in some order Krzysztof Kozlowski
2017-05-07 18:19 ` Krzysztof Kozlowski [this message]
2017-05-30 12:07 ` [Qemu-devel] [PATCH v2 0/3] hw/arm/exynos: QOM-ify the SoC Peter Maydell
2017-05-30 13:00 ` Peter Maydell
2017-05-31 8:49 ` Krzysztof Kozlowski
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=20170507181940.25882-4-krzk@kernel.org \
--to=krzk@kernel.org \
--cc=f4bug@amsat.org \
--cc=i.mitsyanko@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).