Revision 5c130f65 hw/ppc405_boards.c

b/hw/ppc405_boards.c
192 192
    int index;
193 193

  
194 194
    /* XXX: fix this */
195
    ram_bases[0] = 0x00000000;
195
    ram_bases[0] = qemu_ram_alloc(0x08000000);
196 196
    ram_sizes[0] = 0x08000000;
197 197
    ram_bases[1] = 0x00000000;
198 198
    ram_sizes[1] = 0x00000000;
......
200 200
#ifdef DEBUG_BOARD_INIT
201 201
    printf("%s: register cpu\n", __func__);
202 202
#endif
203
    env = ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic, &sram_offset,
203
    env = ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,
204 204
                        kernel_filename == NULL ? 0 : 1);
205 205
    /* allocate SRAM */
206
    sram_size = 512 * 1024;
207
    sram_offset = qemu_ram_alloc(sram_size);
206 208
#ifdef DEBUG_BOARD_INIT
207 209
    printf("%s: register SRAM at offset %08lx\n", __func__, sram_offset);
208 210
#endif
209
    sram_size = 512 * 1024;
210 211
    cpu_register_physical_memory(0xFFF00000, sram_size,
211 212
                                 sram_offset | IO_MEM_RAM);
212 213
    /* allocate and load BIOS */
213 214
#ifdef DEBUG_BOARD_INIT
214 215
    printf("%s: register BIOS\n", __func__);
215 216
#endif
216
    bios_offset = sram_offset + sram_size;
217 217
    fl_idx = 0;
218 218
#ifdef USE_FLASH_BIOS
219 219
    index = drive_get_index(IF_PFLASH, 0, fl_idx);
220 220
    if (index != -1) {
221 221
        bios_size = bdrv_getlength(drives_table[index].bdrv);
222
        bios_offset = qemu_ram_alloc(bios_size);
222 223
        fl_sectors = (bios_size + 65535) >> 16;
223 224
#ifdef DEBUG_BOARD_INIT
224 225
        printf("Register parallel flash %d size " ADDRX " at offset %08lx "
......
239 240
        if (bios_name == NULL)
240 241
            bios_name = BIOS_FILENAME;
241 242
        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
242
        bios_size = load_image(buf, phys_ram_base + bios_offset);
243
        bios_offset = qemu_ram_alloc(BIOS_SIZE);
244
        bios_size = load_image(buf, qemu_get_ram_ptr(bios_offset));
243 245
        if (bios_size < 0 || bios_size > BIOS_SIZE) {
244 246
            fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
245 247
            exit(1);
......
248 250
        cpu_register_physical_memory((uint32_t)(-bios_size),
249 251
                                     bios_size, bios_offset | IO_MEM_ROM);
250 252
    }
251
    bios_offset += bios_size;
252 253
    /* Register FPGA */
253 254
#ifdef DEBUG_BOARD_INIT
254 255
    printf("%s: register FPGA\n", __func__);
......
294 295
        env->gpr[3] = bdloc;
295 296
        kernel_base = KERNEL_LOAD_ADDR;
296 297
        /* now we can load the kernel */
297
        kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
298
        kernel_size = load_image_targphys(kernel_filename, kernel_base,
299
                                          ram_size - kernel_base);
298 300
        if (kernel_size < 0) {
299 301
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
300 302
                    kernel_filename);
301 303
            exit(1);
302 304
        }
303
        printf("Load kernel size " TARGET_FMT_ld " at " TARGET_FMT_lx
304
               " %02x %02x %02x %02x\n", kernel_size, kernel_base,
305
               *(char *)(phys_ram_base + kernel_base),
306
               *(char *)(phys_ram_base + kernel_base + 1),
307
               *(char *)(phys_ram_base + kernel_base + 2),
308
               *(char *)(phys_ram_base + kernel_base + 3));
305
        printf("Load kernel size " TARGET_FMT_ld " at " TARGET_FMT_lx,
306
               kernel_size, kernel_base);
309 307
        /* load initrd */
310 308
        if (initrd_filename) {
311 309
            initrd_base = INITRD_LOAD_ADDR;
312
            initrd_size = load_image(initrd_filename,
313
                                     phys_ram_base + initrd_base);
310
            initrd_size = load_image_targphys(initrd_filename, initrd_base,
311
                                              ram_size - initrd_base);
314 312
            if (initrd_size < 0) {
315 313
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
316 314
                        initrd_filename);
......
326 324
        if (kernel_cmdline != NULL) {
327 325
            len = strlen(kernel_cmdline);
328 326
            bdloc -= ((len + 255) & ~255);
329
            memcpy(phys_ram_base + bdloc, kernel_cmdline, len + 1);
327
            cpu_physical_memory_write(bdloc, (void *)kernel_cmdline, len + 1);
330 328
            env->gpr[6] = bdloc;
331 329
            env->gpr[7] = bdloc + len;
332 330
        } else {
......
344 342
#ifdef DEBUG_BOARD_INIT
345 343
    printf("%s: Done\n", __func__);
346 344
#endif
347
    printf("bdloc %016lx %s\n",
348
           (unsigned long)bdloc, (char *)(phys_ram_base + bdloc));
345
    printf("bdloc %016lx\n", (unsigned long)bdloc);
349 346
}
350 347

  
351 348
QEMUMachine ref405ep_machine = {
......
511 508
    int index;
512 509

  
513 510
    /* RAM is soldered to the board so the size cannot be changed */
514
    ram_bases[0] = 0x00000000;
511
    ram_bases[0] = qemu_ram_alloc(0x04000000);
515 512
    ram_sizes[0] = 0x04000000;
516
    ram_bases[1] = 0x04000000;
513
    ram_bases[1] = qemu_ram_alloc(0x04000000);
517 514
    ram_sizes[1] = 0x04000000;
518 515
#ifdef DEBUG_BOARD_INIT
519 516
    printf("%s: register cpu\n", __func__);
520 517
#endif
521
    env = ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic, &bios_offset,
518
    env = ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,
522 519
                        kernel_filename == NULL ? 0 : 1);
523 520
    /* allocate and load BIOS */
524 521
#ifdef DEBUG_BOARD_INIT
......
532 529
        /* XXX: should check that size is 2MB */
533 530
        //        bios_size = 2 * 1024 * 1024;
534 531
        fl_sectors = (bios_size + 65535) >> 16;
532
        bios_offset = qemu_ram_alloc(bios_size);
535 533
#ifdef DEBUG_BOARD_INIT
536 534
        printf("Register parallel flash %d size " ADDRX " at offset %08lx "
537 535
               " addr " ADDRX " '%s' %d\n",
......
550 548
#endif
551 549
        if (bios_name == NULL)
552 550
            bios_name = BIOS_FILENAME;
551
        bios_offset = qemu_ram_alloc(BIOS_SIZE);
553 552
        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
554
        bios_size = load_image(buf, phys_ram_base + bios_offset);
553
        bios_size = load_image(buf, qemu_get_ram_ptr(bios_offset));
555 554
        if (bios_size < 0 || bios_size > BIOS_SIZE) {
556 555
            fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
557 556
            exit(1);
......
560 559
        cpu_register_physical_memory((uint32_t)(-bios_size),
561 560
                                     bios_size, bios_offset | IO_MEM_ROM);
562 561
    }
563
    bios_offset += bios_size;
564 562
    /* Register Linux flash */
565 563
    index = drive_get_index(IF_PFLASH, 0, fl_idx);
566 564
    if (index != -1) {
......
574 572
               fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000,
575 573
               bdrv_get_device_name(drives_table[index].bdrv));
576 574
#endif
575
        bios_offset = qemu_ram_alloc(bios_size);
577 576
        pflash_cfi02_register(0xfc000000, bios_offset,
578 577
                              drives_table[index].bdrv, 65536, fl_sectors, 1,
579 578
                              4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA);
......
592 591
#endif
593 592
        kernel_base = KERNEL_LOAD_ADDR;
594 593
        /* now we can load the kernel */
595
        kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
594
        kernel_size = load_image_targphys(kernel_filename, kernel_base,
595
                                          ram_size - kernel_base);
596 596
        if (kernel_size < 0) {
597 597
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
598 598
                    kernel_filename);
......
601 601
        /* load initrd */
602 602
        if (initrd_filename) {
603 603
            initrd_base = INITRD_LOAD_ADDR;
604
            initrd_size = load_image(initrd_filename,
605
                                     phys_ram_base + initrd_base);
604
            initrd_size = load_image_targphys(initrd_filename, initrd_base,
605
                                              ram_size - initrd_base);
606 606
            if (initrd_size < 0) {
607 607
                fprintf(stderr,
608 608
                        "qemu: could not load initial ram disk '%s'\n",

Also available in: Unified diff