[PATCH 51/86] m68k:next-cube: use memdev for RAM

Igor Mammedov posted 86 patches 5 years, 11 months ago
Maintainers: Andrew Baumann <Andrew.Baumann@microsoft.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Andrew Jeffery <andrew@aj.id.au>, Sergio Lopez <slp@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Aurelien Jarno <aurelien@aurel32.net>, Christian Borntraeger <borntraeger@de.ibm.com>, Paul Burton <pburton@wavecomp.com>, Artyom Tarasenko <atar4qemu@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Igor Mammedov <imammedo@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Thomas Huth <thuth@redhat.com>, Aleksandar Markovic <amarkovic@wavecomp.com>, KONRAD Frederic <frederic.konrad@adacore.com>, David Hildenbrand <david@redhat.com>, Michael Walle <michael@walle.cc>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Eduardo Habkost <ehabkost@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Andrey Smirnov <andrew.smirnov@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Rob Herring <robh@kernel.org>, Jan Kiszka <jan.kiszka@web.de>, Beniamino Galvani <b.galvani@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, Fabien Chouteau <chouteau@adacore.com>, Leif Lindholm <leif.lindholm@linaro.org>, Thomas Huth <huth@tuxfamily.org>, Peter Chubb <peter.chubb@nicta.com.au>, Radoslaw Biernacki <radoslaw.biernacki@linaro.org>, Cornelia Huck <cohuck@redhat.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Antony Pavlov <antonynpavlov@gmail.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, Helge Deller <deller@gmx.de>, Alistair Francis <alistair@alistair23.me>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, Joel Stanley <joel@jms.id.au>, BALATON Zoltan <balaton@eik.bme.hu>, Richard Henderson <rth@twiddle.net>
There is a newer version of this series
[PATCH 51/86] m68k:next-cube: use memdev for RAM
Posted by Igor Mammedov 5 years, 11 months ago
memory_region_allocate_system_memory() API is going away, so
replace it with memdev allocated MemoryRegion. The later is
initialized by generic code, so board only needs to opt in
to memdev scheme by providing
  MachineClass::default_ram_id
and using MachineState::ram instead of manually initializing
RAM memory region.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/m68k/next-cube.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index e534334..cd93d9e 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -860,7 +860,6 @@ static void next_cube_init(MachineState *machine)
 {
     M68kCPU *cpu;
     CPUM68KState *env;
-    MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *rom = g_new(MemoryRegion, 1);
     MemoryRegion *mmiomem = g_new(MemoryRegion, 1);
     MemoryRegion *scrmem = g_new(MemoryRegion, 1);
@@ -893,8 +892,7 @@ static void next_cube_init(MachineState *machine)
     memcpy(ns->rtc.ram, rtc_ram2, 32);
 
     /* 64MB RAM starting at 0x04000000  */
-    memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size);
-    memory_region_add_subregion(sysmem, 0x04000000, ram);
+    memory_region_add_subregion(sysmem, 0x04000000, machine->ram);
 
     /* Framebuffer */
     dev = qdev_create(NULL, TYPE_NEXTFB);
@@ -967,6 +965,7 @@ static void next_machine_class_init(ObjectClass *oc, void *data)
     mc->desc = "NeXT Cube";
     mc->init = next_cube_init;
     mc->default_ram_size = RAM_SIZE;
+    mc->default_ram_id = "next.ram";
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
 }
 
-- 
2.7.4


Re: [PATCH 51/86] m68k:next-cube: use memdev for RAM
Posted by Thomas Huth 5 years, 11 months ago
On 31/12/2019 14.03, Igor Mammedov wrote:
> memory_region_allocate_system_memory() API is going away, so
> replace it with memdev allocated MemoryRegion. The later is
> initialized by generic code, so board only needs to opt in
> to memdev scheme by providing
>   MachineClass::default_ram_id
> and using MachineState::ram instead of manually initializing
> RAM memory region.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/m68k/next-cube.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> index e534334..cd93d9e 100644
> --- a/hw/m68k/next-cube.c
> +++ b/hw/m68k/next-cube.c
> @@ -860,7 +860,6 @@ static void next_cube_init(MachineState *machine)
>  {
>      M68kCPU *cpu;
>      CPUM68KState *env;
> -    MemoryRegion *ram = g_new(MemoryRegion, 1);
>      MemoryRegion *rom = g_new(MemoryRegion, 1);
>      MemoryRegion *mmiomem = g_new(MemoryRegion, 1);
>      MemoryRegion *scrmem = g_new(MemoryRegion, 1);
> @@ -893,8 +892,7 @@ static void next_cube_init(MachineState *machine)
>      memcpy(ns->rtc.ram, rtc_ram2, 32);
>  
>      /* 64MB RAM starting at 0x04000000  */
> -    memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size);
> -    memory_region_add_subregion(sysmem, 0x04000000, ram);
> +    memory_region_add_subregion(sysmem, 0x04000000, machine->ram);
>  
>      /* Framebuffer */
>      dev = qdev_create(NULL, TYPE_NEXTFB);
> @@ -967,6 +965,7 @@ static void next_machine_class_init(ObjectClass *oc, void *data)
>      mc->desc = "NeXT Cube";
>      mc->init = next_cube_init;
>      mc->default_ram_size = RAM_SIZE;
> +    mc->default_ram_id = "next.ram";
>      mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
>  }
>  
> 

Acked-by: Thomas Huth <thuth@redhat.com>