From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
"Alistair Francis" <alistair@alistair23.me>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC
Date: Mon, 20 May 2019 23:43:42 +0200 [thread overview]
Message-ID: <20190520214342.13709-5-philmd@redhat.com> (raw)
In-Reply-To: <20190520214342.13709-1-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/exynos4210.c | 26 +++++++++++++++++++++++---
hw/arm/exynos4_boards.c | 9 ++++++---
include/hw/arm/exynos4210.h | 9 +++++++--
3 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 19009b76e7c..0b09129eff8 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -178,9 +178,10 @@ static void pl330_create(uint32_t base, qemu_irq irq, int nreq)
sysbus_connect_irq(busdev, 0, irq);
}
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
+static void exynos4210_realize(DeviceState *socdev, Error **errp)
{
- Exynos4210State *s = g_new0(Exynos4210State, 1);
+ Exynos4210State *s = EXYNOS4210_SOC(socdev);
+ MemoryRegion *system_mem = get_system_memory();
qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
SysBusDevice *busdev;
DeviceState *dev;
@@ -435,6 +436,25 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32);
pl330_create(EXYNOS4210_PL330_BASE2_ADDR,
qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1);
+}
+
+static void exynos4210_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
- return s;
+ dc->realize = exynos4210_realize;
}
+
+static const TypeInfo exynos4210_info = {
+ .name = TYPE_EXYNOS4210_SOC,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(Exynos4210State),
+ .class_init = exynos4210_class_init,
+};
+
+static void exynos4210_register_types(void)
+{
+ type_register_static(&exynos4210_info);
+}
+
+type_init(exynos4210_register_types)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index f824eef0d36..700e90d6671 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -45,7 +45,7 @@ typedef enum Exynos4BoardType {
} Exynos4BoardType;
typedef struct Exynos4BoardState {
- Exynos4210State *soc;
+ Exynos4210State soc;
MemoryRegion dram0_mem;
MemoryRegion dram1_mem;
} Exynos4BoardState;
@@ -130,7 +130,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_SOC);
+ qdev_set_parent_bus(DEVICE(&s->soc), sysbus_get_default());
+ object_property_set_bool(OBJECT(&s->soc), true, "realized",
+ &error_fatal);
return s;
}
@@ -148,7 +151,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 098a69ec73d..27c684e851d 100644
--- a/include/hw/arm/exynos4210.h
+++ b/include/hw/arm/exynos4210.h
@@ -85,6 +85,9 @@ typedef struct Exynos4210Irq {
} Exynos4210Irq;
typedef struct Exynos4210State {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
ARMCPU *cpu[EXYNOS4210_NCPUS];
Exynos4210Irq irqs;
qemu_irq *irq_table;
@@ -98,11 +101,13 @@ typedef struct Exynos4210State {
I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
} Exynos4210State;
+#define TYPE_EXYNOS4210_SOC "exynos4210"
+#define EXYNOS4210_SOC(obj) \
+ OBJECT_CHECK(Exynos4210State, obj, TYPE_EXYNOS4210_SOC)
+
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.20.1
next prev parent reply other threads:[~2019-05-20 21:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
2019-05-20 21:43 ` [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code Philippe Mathieu-Daudé
2019-05-20 21:47 ` Alistair Francis
2019-05-20 21:43 ` [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2019-05-20 21:48 ` Alistair Francis
2019-05-20 21:43 ` [Qemu-devel] [PATCH 3/4] hw/arm/exynos4210: Add DMA support for the Exynos4210 Philippe Mathieu-Daudé
2019-05-20 21:43 ` Philippe Mathieu-Daudé [this message]
2019-05-22 22:46 ` [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC Alistair Francis
2019-05-23 12:57 ` [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Peter Maydell
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=20190520214342.13709-5-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=alistair@alistair23.me \
--cc=i.mitsyanko@gmail.com \
--cc=linux@roeck-us.net \
--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).