qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 68/86] ppc:prep: use memdev for RAM


From: Mark Cave-Ayland
Subject: Re: [PATCH v2 68/86] ppc:prep: use memdev for RAM
Date: Thu, 16 Jan 2020 08:50:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0

On 15/01/2020 15:07, 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 <address@hidden>
> ---
> CC: address@hidden
> CC: address@hidden
> CC: address@hidden
> ---
>  hw/ppc/prep.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 862345c..bf75dde 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -400,7 +400,6 @@ static int PPC_NVRAM_set_params (Nvram *nvram, uint16_t 
> NVRAM_size,
>  /* PowerPC PREP hardware initialisation */
>  static void ppc_prep_init(MachineState *machine)
>  {
> -    ram_addr_t ram_size = machine->ram_size;
>      const char *kernel_filename = machine->kernel_filename;
>      const char *kernel_cmdline = machine->kernel_cmdline;
>      const char *initrd_filename = machine->initrd_filename;
> @@ -413,7 +412,6 @@ static void ppc_prep_init(MachineState *machine)
>      MemoryRegion *xcsr = g_new(MemoryRegion, 1);
>  #endif
>      int linux_boot, i, nb_nics1;
> -    MemoryRegion *ram = g_new(MemoryRegion, 1);
>      uint32_t kernel_base, initrd_base;
>      long kernel_size, initrd_size;
>      DeviceState *dev;
> @@ -444,15 +442,14 @@ static void ppc_prep_init(MachineState *machine)
>          qemu_register_reset(ppc_prep_reset, cpu);
>      }
>  
> -    /* allocate RAM */
> -    memory_region_allocate_system_memory(ram, NULL, "ppc_prep.ram", 
> ram_size);
> -    memory_region_add_subregion(sysmem, 0, ram);
> +    /* map RAM */
> +    memory_region_add_subregion(sysmem, 0, machine->ram);
>  
>      if (linux_boot) {
>          kernel_base = KERNEL_LOAD_ADDR;
>          /* now we can load the kernel */
>          kernel_size = load_image_targphys(kernel_filename, kernel_base,
> -                                          ram_size - kernel_base);
> +                                          machine->ram_size - kernel_base);
>          if (kernel_size < 0) {
>              error_report("could not load kernel '%s'", kernel_filename);
>              exit(1);
> @@ -461,7 +458,7 @@ static void ppc_prep_init(MachineState *machine)
>          if (initrd_filename) {
>              initrd_base = INITRD_LOAD_ADDR;
>              initrd_size = load_image_targphys(initrd_filename, initrd_base,
> -                                              ram_size - initrd_base);
> +                                              machine->ram_size - 
> initrd_base);
>              if (initrd_size < 0) {
>                  error_report("could not load initial ram disk '%s'",
>                               initrd_filename);
> @@ -576,7 +573,7 @@ static void ppc_prep_init(MachineState *machine)
>      sysctrl->nvram = m48t59;
>  
>      /* Initialise NVRAM */
> -    PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size,
> +    PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", machine->ram_size,
>                           ppc_boot_device,
>                           kernel_base, kernel_size,
>                           kernel_cmdline,
> @@ -596,6 +593,7 @@ static void prep_machine_init(MachineClass *mc)
>      mc->default_boot_order = "cad";
>      mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("602");
>      mc->default_display = "std";
> +    mc->default_ram_id = "ppc_prep.ram";
>  }
>  
>  static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
> @@ -814,6 +812,7 @@ static void ibm_40p_machine_init(MachineClass *mc)
>      mc->init = ibm_40p_init;
>      mc->max_cpus = 1;
>      mc->default_ram_size = 128 * MiB;
> +    mc->default_ram_id = "ppc_prep.ram";
>      mc->block_default_type = IF_SCSI;
>      mc->default_boot_order = "c";
>      mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("604");

Note that the prep machine is scheduled for removal soon (I believe Thomas has 
posted
a patch on-list for this), but the 40p part looks fine.

Acked-by: Mark Cave-Ayland <address@hidden>


ATB,

Mark.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]