qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Alistair Francis" <alistair@alistair23.me>,
	qemu-devel@nongnu.org,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH 4/6] hw/arm/raspi: Get board RAM size from board revision code
Date: Mon, 3 Feb 2020 10:58:39 +0100	[thread overview]
Message-ID: <20200203105839.2d369c9f@redhat.com> (raw)
In-Reply-To: <20200203082619.7426-5-f4bug@amsat.org>

On Mon,  3 Feb 2020 09:26:17 +0100
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> The amount of RAM is encoded in the board revision.
> Add the board_ram_size() helper, it will allow us to quickly
> support new boards.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/arm/raspi.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index f5e54fe876..656d834e07 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -13,6 +13,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "qemu/units.h"
> +#include "qemu/cutils.h"
>  #include "qapi/error.h"
>  #include "cpu.h"
>  #include "hw/arm/bcm2836.h"
> @@ -71,6 +72,11 @@ static const RaspiBoardInfo raspi_boards[] = {
>  #endif
>  };
>  
> +static uint64_t board_ram_size(const RaspiBoardInfo *config)
> +{
> +    return 1 * MiB << extract32(config->board_rev, 20, 4);
> +}
> +
>  static int board_chip_id(const RaspiBoardInfo *config)
>  {
>      return extract32(config->board_rev, 12, 4);
> @@ -222,10 +228,13 @@ static void raspi_init(MachineState *machine, const RaspiBoardInfo *config)
>      BlockBackend *blk;
>      BusState *bus;
>      DeviceState *carddev;
> +    uint64_t ram_size;
>  
> -    if (machine->ram_size > 1 * GiB) {
> -        error_report("Requested ram size is too large for this machine: "
> -                     "maximum is 1GB");
> +    ram_size = board_ram_size(config);
> +    if (machine->ram_size != ram_size) {
> +        char *size_str = size_to_str(ram_size);
> +        error_report("This machine can only be used with %s", size_str);
> +        g_free(size_str);
>          exit(1);
>      }
>  



  reply	other threads:[~2020-02-03  9:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03  8:26 [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision Philippe Mathieu-Daudé
2020-02-03  8:26 ` [PATCH 1/6] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels Philippe Mathieu-Daudé
2020-02-03 18:38   ` Alistair Francis
2020-02-03  8:26 ` [PATCH 2/6] hw/arm/raspi: Get board version from board revision code Philippe Mathieu-Daudé
2020-02-03  9:57   ` Igor Mammedov
2020-02-03  8:26 ` [PATCH 3/6] hw/arm/raspi: Get the SoC type name from the " Philippe Mathieu-Daudé
2020-02-03  8:26 ` [PATCH 4/6] hw/arm/raspi: Get board RAM size from board " Philippe Mathieu-Daudé
2020-02-03  9:58   ` Igor Mammedov [this message]
2020-02-03  8:26 ` [PATCH 5/6] hw/arm/raspi: Dynamically create machines based on the board revision Philippe Mathieu-Daudé
2020-02-03 10:10   ` Igor Mammedov
2020-02-03  8:26 ` [PATCH 6/6] hw/arm/raspi: Get the CPU core count from the revision code Philippe Mathieu-Daudé
2020-02-03 16:48 ` [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision no-reply

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=20200203105839.2d369c9f@redhat.com \
    --to=imammedo@redhat.com \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=alistair@alistair23.me \
    --cc=f4bug@amsat.org \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --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).