ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,

                               MemoryRegion ram_memories[],

                               hwaddr ram_bases[],

                               hwaddr ram_sizes[],

                               const unsigned int sdram_bank_sizes[])

{

    ram_addr_t size_left = ram_size;

    ram_addr_t base = 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 <= size_left) {

                char name[32];

                snprintf(name, sizeof(name), "ppc4xx.sdram%d", i);

                memory_region_allocate_system_memory(&ram_memories[i], NULL,

                                                     name, bank_size);

                ram_bases[i] = base;

                ram_sizes[i] = bank_size;

                base += bank_size;

                size_left -= bank_size;

                break;

            }

        }



        if (!size_left) {

            /* No need to use the remaining banks. */

            break;

        }

    }



    ram_size -= size_left;

    if (size_left)

        printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",

               (int)(ram_size >> 20));



    return ram_size;

}

ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,

                               MemoryRegion ram_memories[],

                               hwaddr ram_bases[],

                               hwaddr ram_sizes[],

                               const unsigned int sdram_bank_sizes[])

{

    ram_addr_t size_left = ram_size;

    ram_addr_t base = 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 <= size_left) {

                char name[32];

                snprintf(name, sizeof(name), "ppc4xx.sdram%d", i);

                memory_region_allocate_system_memory(&ram_memories[i], NULL,

                                                     name, bank_size);

                ram_bases[i] = base;

                ram_sizes[i] = bank_size;

                base += bank_size;

                size_left -= bank_size;

                break;

            }

        }



        if (!size_left) {

            

            break;

        }

    }



    ram_size -= size_left;

    if (size_left)

        printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",

               (int)(ram_size >> 20));



    return ram_size;

}

            unsigned int bank_size = sdram_bank_sizes[j];                 char name[32];                 snprintf(name, sizeof(name), "ppc4xx.sdram%d", i);                 memory_region_allocate_system_memory(&ram_memories[i], NULL,                                                      name, bank_size);                 ram_bases[i] = base;                 ram_sizes[i] = bank_size;                 base += bank_size;                 break;     if (size_left)
ram_addr_t FUNC_0(ram_addr_t ram_size, int nr_banks,

                               MemoryRegion ram_memories[],

                               hwaddr ram_bases[],

                               hwaddr ram_sizes[],

                               const unsigned int sdram_bank_sizes[])

{

    ram_addr_t size_left = ram_size;

    ram_addr_t base = 0;

    int VAR_0;

    int VAR_1;



    for (VAR_0 = 0; VAR_0 < nr_banks; VAR_0++) {

        for (VAR_1 = 0; sdram_bank_sizes[VAR_1] != 0; VAR_1++) {

            unsigned int VAR_2 = sdram_bank_sizes[VAR_1];



            if (VAR_2 <= size_left) {

                char VAR_3[32];

                snprintf(VAR_3, sizeof(VAR_3), "ppc4xx.sdram%d", VAR_0);

                memory_region_allocate_system_memory(&ram_memories[VAR_0], NULL,

                                                     VAR_3, VAR_2);

                ram_bases[VAR_0] = base;

                ram_sizes[VAR_0] = VAR_2;

                base += VAR_2;

                size_left -= VAR_2;

                break;

            }

        }



        if (!size_left) {

            

            break;

        }

    }



    ram_size -= size_left;

    if (size_left)

        printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",

               (int)(ram_size >> 20));



    return ram_size;

}

ram_addr_t FUNC_0(ram_addr_t ram_size, int nr_banks,
MemoryRegion ram_memories[],
hwaddr ram_bases[],
hwaddr ram_sizes[],
const unsigned int sdram_bank_sizes[])
{ ram_addr_t size_left = ram_size; ram_addr_t base = 0; int VAR_0; int VAR_1; for (VAR_0 = 0; VAR_0 < nr_banks; VAR_0++) { for (VAR_1 = 0; sdram_bank_sizes[VAR_1] != 0; VAR_1++) { unsigned int VAR_2 = sdram_bank_sizes[VAR_1]; if (VAR_2 <= size_left) { char VAR_3[32]; snprintf(VAR_3, sizeof(VAR_3), "ppc4xx.sdram%d", VAR_0); memory_region_allocate_system_memory(&ram_memories[VAR_0], NULL,
VAR_3, VAR_2); ram_bases[VAR_0] = base; ram_sizes[VAR_0] = VAR_2; base += VAR_2; size_left -= VAR_2; break; } } if (!size_left) { break; } } ram_size -= size_left; if (size_left)
printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",
(int)(ram_size >> 20)); return ram_size; }