Revision cfe5f011 hw/ppc405_boards.c

b/hw/ppc405_boards.c
32 32
#include "qemu-log.h"
33 33
#include "loader.h"
34 34
#include "blockdev.h"
35
#include "exec-memory.h"
35 36

  
36 37
#define BIOS_FILENAME "ppc405_rom.bin"
37 38
#define BIOS_SIZE (2048 * 1024)
......
181 182
    ppc4xx_bd_info_t bd;
182 183
    CPUPPCState *env;
183 184
    qemu_irq *pic;
184
    ram_addr_t sram_offset, bios_offset, bdloc;
185
    MemoryRegion *bios;
186
    ram_addr_t sram_offset, bdloc;
185 187
    MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
186 188
    target_phys_addr_t ram_bases[2], ram_sizes[2];
187 189
    target_ulong sram_size;
......
224 226
    dinfo = drive_get(IF_PFLASH, 0, fl_idx);
225 227
    if (dinfo) {
226 228
        bios_size = bdrv_getlength(dinfo->bdrv);
227
        bios_offset = qemu_ram_alloc(NULL, "ef405ep.bios", bios_size);
228 229
        fl_sectors = (bios_size + 65535) >> 16;
229 230
#ifdef DEBUG_BOARD_INIT
230 231
        printf("Register parallel flash %d size %lx"
231
               " at offset %08lx addr %lx '%s' %d\n",
232
               fl_idx, bios_size, bios_offset, -bios_size,
232
               " at addr %lx '%s' %d\n",
233
               fl_idx, bios_size, -bios_size,
233 234
               bdrv_get_device_name(dinfo->bdrv), fl_sectors);
234 235
#endif
235
        pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
236
        pflash_cfi02_register((uint32_t)(-bios_size),
237
                              NULL, "ef405ep.bios", bios_size,
236 238
                              dinfo->bdrv, 65536, fl_sectors, 1,
237 239
                              2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
238 240
                              1);
......
243 245
#ifdef DEBUG_BOARD_INIT
244 246
        printf("Load BIOS from file\n");
245 247
#endif
246
        bios_offset = qemu_ram_alloc(NULL, "ef405ep.bios", BIOS_SIZE);
248
        bios = g_new(MemoryRegion, 1);
249
        memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE);
247 250
        if (bios_name == NULL)
248 251
            bios_name = BIOS_FILENAME;
249 252
        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
250 253
        if (filename) {
251
            bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
254
            bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
252 255
            g_free(filename);
253 256
        } else {
254 257
            bios_size = -1;
......
259 262
            exit(1);
260 263
        }
261 264
        bios_size = (bios_size + 0xfff) & ~0xfff;
262
        cpu_register_physical_memory((uint32_t)(-bios_size),
263
                                     bios_size, bios_offset | IO_MEM_ROM);
265
        memory_region_set_readonly(bios, true);
266
        memory_region_add_subregion(get_system_memory(),
267
                                    (uint32_t)(-bios_size), bios);
264 268
    }
265 269
    /* Register FPGA */
266 270
#ifdef DEBUG_BOARD_INIT
......
507 511
{
508 512
    char *filename;
509 513
    qemu_irq *pic;
510
    ram_addr_t bios_offset;
514
    MemoryRegion *bios;
511 515
    MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
512 516
    target_phys_addr_t ram_bases[2], ram_sizes[2];
513 517
    long bios_size;
......
544 548
        /* XXX: should check that size is 2MB */
545 549
        //        bios_size = 2 * 1024 * 1024;
546 550
        fl_sectors = (bios_size + 65535) >> 16;
547
        bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", bios_size);
548 551
#ifdef DEBUG_BOARD_INIT
549 552
        printf("Register parallel flash %d size %lx"
550
               " at offset %08lx addr %lx '%s' %d\n",
551
               fl_idx, bios_size, bios_offset, -bios_size,
553
               " at addr %lx '%s' %d\n",
554
               fl_idx, bios_size, -bios_size,
552 555
               bdrv_get_device_name(dinfo->bdrv), fl_sectors);
553 556
#endif
554
        pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
557
        pflash_cfi02_register((uint32_t)(-bios_size),
558
                              NULL, "taihu_405ep.bios", bios_size,
555 559
                              dinfo->bdrv, 65536, fl_sectors, 1,
556 560
                              4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
557 561
                              1);
......
564 568
#endif
565 569
        if (bios_name == NULL)
566 570
            bios_name = BIOS_FILENAME;
567
        bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", BIOS_SIZE);
571
        bios = g_new(MemoryRegion, 1);
572
        memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE);
568 573
        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
569 574
        if (filename) {
570
            bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
575
            bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
571 576
            g_free(filename);
572 577
        } else {
573 578
            bios_size = -1;
......
578 583
            exit(1);
579 584
        }
580 585
        bios_size = (bios_size + 0xfff) & ~0xfff;
581
        cpu_register_physical_memory((uint32_t)(-bios_size),
582
                                     bios_size, bios_offset | IO_MEM_ROM);
586
        memory_region_set_readonly(bios, true);
587
        memory_region_add_subregion(get_system_memory(), (uint32_t)(-bios_size),
588
                                    bios);
583 589
    }
584 590
    /* Register Linux flash */
585 591
    dinfo = drive_get(IF_PFLASH, 0, fl_idx);
......
590 596
        fl_sectors = (bios_size + 65535) >> 16;
591 597
#ifdef DEBUG_BOARD_INIT
592 598
        printf("Register parallel flash %d size %lx"
593
               " at offset %08lx  addr " TARGET_FMT_lx " '%s'\n",
594
               fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000,
599
               " at addr " TARGET_FMT_lx " '%s'\n",
600
               fl_idx, bios_size, (target_ulong)0xfc000000,
595 601
               bdrv_get_device_name(dinfo->bdrv));
596 602
#endif
597
        bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.flash", bios_size);
598
        pflash_cfi02_register(0xfc000000, bios_offset,
603
        pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size,
599 604
                              dinfo->bdrv, 65536, fl_sectors, 1,
600 605
                              4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
601 606
                              1);

Also available in: Unified diff