[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] hw/arm/raspi4b: Split raspi4b_machine_class_init() in two (1
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 3/7] hw/arm/raspi4b: Split raspi4b_machine_class_init() in two (1g and 2g) |
Date: |
Sat, 1 Feb 2025 10:15:24 +0100 |
Current raspi4b_machine_class_init() method register 2 distinct
machines, with different board revision (thus different memory
size), whether the host is 32-bit or more. Split it as 2 new
methods, one for the raspi4b with 1GB of memory (on 32-bit hosts)
and another for the raspi4b with 2GB of memory.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/arm/raspi4b.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
index 548059f6d69..4ea79ec7092 100644
--- a/hw/arm/raspi4b.c
+++ b/hw/arm/raspi4b.c
@@ -107,26 +107,45 @@ static void raspi4b_machine_init(MachineState *machine)
raspi_base_machine_init(machine, &soc->parent_obj);
}
-static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
+#if HOST_LONG_BITS == 32
+static void raspi4b_1g_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
-#if HOST_LONG_BITS == 32
rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
-#else
- rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
-#endif
+
raspi_machine_class_common_init(mc, rmc->board_rev);
mc->init = raspi4b_machine_init;
}
+#else
+static void raspi4b_2g_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
+
+
+ rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
+ raspi_machine_class_common_init(mc, rmc->board_rev);
+ mc->init = raspi4b_machine_init;
+}
+#endif
static const TypeInfo raspi4_machine_types[] = {
+#if HOST_LONG_BITS == 32
{
.name = MACHINE_TYPE_NAME("raspi4b"),
.parent = TYPE_RASPI4_MACHINE,
- .class_init = raspi4b_machine_class_init,
- }, {
+ .class_init = raspi4b_1g_machine_class_init,
+ },
+#else
+ {
+ .name = MACHINE_TYPE_NAME("raspi4b"),
+ .parent = TYPE_RASPI4_MACHINE,
+ .class_init = raspi4b_2g_machine_class_init,
+ },
+#endif
+ {
.name = TYPE_RASPI4_MACHINE,
.parent = TYPE_RASPI_BASE_MACHINE,
.instance_size = sizeof(Raspi4bMachineState),
--
2.47.1
- [PATCH 0/7] hw/arm/raspi4b: Add models with 4GB and 8GB of DRAM, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 1/7] hw/arm/raspi4b: Declare machine types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 2/7] hw/arm/raspi4b: Introduce abstract raspi4-base machine type, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 3/7] hw/arm/raspi4b: Split raspi4b_machine_class_init() in two (1g and 2g),
Philippe Mathieu-Daudé <=
- [PATCH 4/7] hw/arm/raspi4b: Rename as raspi4b-1g / raspi4b-2g, deprecating old name, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 5/7] hw/arm/raspi4b: Expose the raspi4b-1g machine on 64-bit hosts, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 6/7] hw/arm/raspi4b: Add the raspi4b-4g machine, Philippe Mathieu-Daudé, 2025/02/01
- [PATCH 7/7] hw/arm/raspi4b: Add the raspi4b-8g machine, Philippe Mathieu-Daudé, 2025/02/01
- Re: [PATCH 0/7] hw/arm/raspi4b: Add models with 4GB and 8GB of DRAM, BALATON Zoltan, 2025/02/01