diff options
author | Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> | 2008-10-28 16:52:38 +0100 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-10-29 14:45:02 +0200 |
commit | 1a66b27db80f98f1dcd1e2b859af00b9ce7709a6 (patch) | |
tree | 411db62202e3c32466caee3f5073a49d0e426a74 | |
parent | 2c76eff8db04c019e6b6f15be7fc441bc0f34fdf (diff) |
Ppc: fix initial ppc memory setupkvm-78rc2
The old memory initialization code was broken for all cases not fitting in one
ram stick. This patch fixes the ram_stick calculation, now sets the proper
base adresses per stick and removes the old workaround.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | hw/ppc440.c | 12 | ||||
-rw-r--r-- | hw/ppc440.h | 8 | ||||
-rw-r--r-- | hw/ppc440_bamboo.c | 29 |
3 files changed, 30 insertions, 19 deletions
diff --git a/hw/ppc440.c b/hw/ppc440.c index eb91688ff..5a0218619 100644 --- a/hw/ppc440.c +++ b/hw/ppc440.c @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <jyoung5@us.ibm.com> + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -24,15 +25,15 @@ void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init) { ppc4xx_mmio_t *mmio; qemu_irq *pic, *irqs; - ram_addr_t offset; ppc4xx_pci_t *pci; int i; @@ -55,10 +56,7 @@ void ppc440ep_init(CPUState *env, /* SDRAM controller */ printf("trying to setup sdram controller\n"); /* XXX 440EP's ECC interrupts are on UIC1 */ - ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init); - offset = 0; - for (i = 0; i < 2; i++) - offset += ram_sizes[i]; + ppc405_sdram_init(env, pic[14], nbanks, ram_bases, ram_sizes, do_init); /* PCI */ pci = ppc4xx_pci_init(env, pic, diff --git a/hw/ppc440.h b/hw/ppc440.h index 087af1963..36156496a 100644 --- a/hw/ppc440.h +++ b/hw/ppc440.h @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <jyoung5@us.ibm.com> + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> * * This work is licensed under the GNU GPL licence version 2 or later * @@ -20,9 +21,12 @@ #include "exec-all.h" #include "boards.h" +#define PPC440_MAX_RAM_SLOTS 4 + void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init); diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 13e370a0d..bf422454a 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -2,7 +2,9 @@ * Qemu PowerPC 440 board emualtion * * Copyright 2007 IBM Corporation. - * Authors: Jerone Young <jyoung5@us.ibm.com> + * Authors: + * Jerone Young <jyoung5@us.ibm.com> + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -30,7 +32,8 @@ void bamboo_init(ram_addr_t ram_size, int vga_ram_size, const char *cpu_model) { char *buf=NULL; - target_phys_addr_t ram_bases[4], ram_sizes[4]; + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS]; + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS]; NICInfo *nd; qemu_irq *pic; ppc4xx_pci_t *pci; @@ -46,6 +49,8 @@ void bamboo_init(ram_addr_t ram_size, int vga_ram_size, int ret; int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, 32<<20, 16<<20, 8<<20 }; /* in bytes */ + int nbanks = 0; /* number of used memory banks */ + int next_bank_offset = 0; ram_addr_t tmp_ram_size; int i=0, k=0; uint32_t cpu_freq; @@ -55,15 +60,22 @@ void bamboo_init(ram_addr_t ram_size, int vga_ram_size, printf("%s: START\n", __func__); /* Setup Memory */ - printf("Ram size passed is: %i MB\n", - bytes_to_mb((int)ram_size)); + if (ram_size < 8<<20) { + printf("ERROR: ram size too small (min 8mb)\n"); + exit(1); + } else + printf("Ram size passed is: %i MB\n", + bytes_to_mb((int)ram_size)); tmp_ram_size = ram_size; - for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) { - for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) { + for (i = 0; i < PPC440_MAX_RAM_SLOTS; i++) { + for (k = 0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) { if ((tmp_ram_size/ram_stick_sizes[k]) > 0) { ram_sizes[i] = ram_stick_sizes[k]; + ram_bases[i] = next_bank_offset; + next_bank_offset += ram_stick_sizes[k]; + nbanks++; tmp_ram_size -= ram_stick_sizes[k]; break; } @@ -88,12 +100,9 @@ void bamboo_init(ram_addr_t ram_size, int vga_ram_size, /* call init */ printf("Calling function ppc440_init\n"); - ppc440ep_init(env, ram_bases, ram_sizes, &pic, &pci, 1); + ppc440ep_init(env, ram_bases, ram_sizes, nbanks, &pic, &pci, 1); printf("Done calling ppc440_init\n"); - /* Register mem */ - cpu_register_physical_memory(0, ram_size, 0); - /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux); |