qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: kvm-ppc@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 3/8] Create a helper function to allow more flexible RAM allocation for PPC 4xx
Date: Tue, 16 Dec 2008 00:18:56 +0100	[thread overview]
Message-ID: <20081215231856.GY22069@hall.aurel32.net> (raw)
In-Reply-To: <aa441a89c51d92ea485ff6858e931b20d57db146.1229359102.git.hollisb@us.ibm.com>

On Mon, Dec 15, 2008 at 10:44:14AM -0600, Hollis Blanchard wrote:
> The 4xx SDRAM controller supports a small number of banks, and each bank must
> be one of a small set of sizes. The number of banks and the supported sizes
> varies by SoC.
> 
> This function uses the user-specified RAM size to fill in the "ram_bases" and
> "ram_sizes" arrays required by ppc4xx_sdram_init().
> 
> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

Applied, thanks.

> ---
>  hw/ppc4xx.h      |    5 +++++
>  hw/ppc4xx_devs.c |   42 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/ppc4xx.h b/hw/ppc4xx.h
> index 3b98662..7832cd9 100644
> --- a/hw/ppc4xx.h
> +++ b/hw/ppc4xx.h
> @@ -48,6 +48,11 @@ enum {
>  qemu_irq *ppcuic_init (CPUState *env, qemu_irq *irqs,
>                         uint32_t dcr_base, int has_ssr, int has_vr);
>  
> +ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
> +                               target_phys_addr_t ram_bases[],
> +                               target_phys_addr_t ram_sizes[],
> +                               const unsigned int sdram_bank_sizes[]);
> +
>  void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
>                          target_phys_addr_t *ram_bases,
>                          target_phys_addr_t *ram_sizes,
> diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c
> index 2d27e23..939e066 100644
> --- a/hw/ppc4xx_devs.c
> +++ b/hw/ppc4xx_devs.c
> @@ -873,3 +873,45 @@ void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
>              sdram_map_bcr(sdram);
>      }
>  }
> +
> +/* Fill in consecutive SDRAM banks with 'ram_size' bytes of memory.
> + *
> + * sdram_bank_sizes[] must be 0-terminated.
> + *
> + * The 4xx SDRAM controller supports a small number of banks, and each bank
> + * must be one of a small set of sizes. The number of banks and the supported
> + * sizes varies by SoC. */
> +ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
> +                               target_phys_addr_t ram_bases[],
> +                               target_phys_addr_t ram_sizes[],
> +                               const unsigned int sdram_bank_sizes[])
> +{
> +    ram_addr_t ram_end = 0;
> +    int i;
> +    int j;
> +
> +    for (i = 0; i < nr_banks; i++) {
> +        for (j = 0; sdram_bank_sizes[j] != 0; j++) {
> +            unsigned int bank_size = sdram_bank_sizes[j];
> +
> +            if (bank_size <= ram_size) {
> +                ram_bases[i] = ram_end;
> +                ram_sizes[i] = bank_size;
> +                ram_end += bank_size;
> +                ram_size -= bank_size;
> +                break;
> +            }
> +        }
> +
> +        if (!ram_size) {
> +            /* No need to use the remaining banks. */
> +            break;
> +        }
> +    }
> +
> +    if (ram_size)
> +        printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",
> +               (int)(ram_end >> 20));
> +
> +    return ram_end;
> +}
> -- 
> 1.5.6.5
> 
> 
> 
> 

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

  reply	other threads:[~2008-12-15 23:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-15 16:44 [Qemu-devel] KVM PowerPC support Hollis Blanchard
2008-12-15 16:44 ` [Qemu-devel] [PATCH 1/8] Move PPC4xx SDRAM controller emulation from ppc405_uc.c to ppc4xx_devs.c Hollis Blanchard
2008-12-15 16:44   ` [Qemu-devel] [PATCH 2/8] Rename ppc405_sdram_init() to ppc4xx_sdram_init() Hollis Blanchard
2008-12-15 23:14     ` Aurelien Jarno
2008-12-15 16:44   ` [Qemu-devel] [PATCH 3/8] Create a helper function to allow more flexible RAM allocation for PPC 4xx Hollis Blanchard
2008-12-15 23:18     ` Aurelien Jarno [this message]
2008-12-15 16:44   ` [Qemu-devel] [PATCH 4/8] kvm: sync vcpu state during initialization Hollis Blanchard
2008-12-15 22:20     ` Anthony Liguori
2008-12-15 16:44   ` [Qemu-devel] [PATCH 5/8] Implement device tree support needed for Bamboo emulation Hollis Blanchard
2008-12-15 23:20     ` Aurelien Jarno
2008-12-15 16:44   ` [Qemu-devel] [PATCH 6/8] Enable KVM for ppcemb Hollis Blanchard
2008-12-15 22:24     ` Anthony Liguori
2008-12-15 16:44   ` [Qemu-devel] [PATCH 7/8] PowerPC 440EP SoC emulation Hollis Blanchard
2008-12-15 16:44   ` [Qemu-devel] [PATCH 8/8] IBM PowerPC 440EP Bamboo reference board emulation Hollis Blanchard
2008-12-15 17:03     ` Paul Brook
2008-12-15 23:14   ` [Qemu-devel] [PATCH 1/8] Move PPC4xx SDRAM controller emulation from ppc405_uc.c to ppc4xx_devs.c Aurelien Jarno

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=20081215231856.GY22069@hall.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=kvm-ppc@vger.kernel.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).