diff options
author | Avi Kivity <avi@redhat.com> | 2011-08-04 15:55:30 +0300 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-08-25 10:56:33 +0300 |
commit | c8a50e596c8eeb41bf5718df5bad6be4080f40c7 (patch) | |
tree | 589bfb006ec42863a518debd4775d88a3abfe185 /hw/mips_malta.c | |
parent | a1807ef2954d3ddbf9a9bca3949bd0c69fd45a0e (diff) | |
download | qemu-c8a50e596c8eeb41bf5718df5bad6be4080f40c7.zip qemu-c8a50e596c8eeb41bf5718df5bad6be4080f40c7.tar.gz qemu-c8a50e596c8eeb41bf5718df5bad6be4080f40c7.tar.bz2 |
pflash_cfi01/pflash_cfi02: convert to memory API
cfi02 is annoying in that is ignores some address bits; we probably
want explicit support in the memory API for that.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/mips_malta.c')
-rw-r--r-- | hw/mips_malta.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 86a8ba0..b5c9bcf 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -46,6 +46,7 @@ #include "elf.h" #include "mc146818rtc.h" #include "blockdev.h" +#include "exec-memory.h" //#define DEBUG_BOARD_INIT @@ -762,7 +763,10 @@ void mips_malta_init (ram_addr_t ram_size, { char *filename; ram_addr_t ram_offset; - ram_addr_t bios_offset; + MemoryRegion *address_space_mem = get_system_memory(); + MemoryRegion *bios = g_new(MemoryRegion, 1); + MemoryRegion *bios_1e0 = g_new(MemoryRegion, 1); + MemoryRegion *bios_1fc = g_new(MemoryRegion, 1); target_long bios_size; int64_t kernel_entry; PCIBus *pci_bus; @@ -777,7 +781,7 @@ void mips_malta_init (ram_addr_t ram_size, DriveInfo *fd[MAX_FD]; int fl_idx = 0; int fl_sectors = 0; - int be; + const MemoryRegionOps *bios_ops; /* Make sure the first 3 serial ports are associated with a device. */ for(i = 0; i < 3; i++) { @@ -810,23 +814,24 @@ void mips_malta_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20))); exit(1); } - ram_offset = qemu_ram_alloc(NULL, "mips_malta.ram", ram_size); - bios_offset = qemu_ram_alloc(NULL, "mips_malta.bios", BIOS_SIZE); +#ifdef TARGET_WORDS_BIGENDIAN + bios_ops = &pflash_cfi01_ops_be; +#else + bios_ops = &pflash_cfi01_ops_le; +#endif + ram_offset = qemu_ram_alloc(NULL, "mips_malta.ram", ram_size); + memory_region_init_rom_device(bios, bios_ops, NULL, + "mips_malta.bios", BIOS_SIZE); cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); /* Map the bios at two physical locations, as on the real board. */ - cpu_register_physical_memory(0x1e000000LL, - BIOS_SIZE, bios_offset | IO_MEM_ROM); - cpu_register_physical_memory(0x1fc00000LL, - BIOS_SIZE, bios_offset | IO_MEM_ROM); + memory_region_init_alias(bios_1e0, "bios-1e0", bios, 0, BIOS_SIZE); + memory_region_add_subregion(address_space_mem, 0x1e000000LL, bios_1e0); + memory_region_init_alias(bios_1fc, "bios-1fc", bios, 0, BIOS_SIZE); + memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios_1fc); -#ifdef TARGET_WORDS_BIGENDIAN - be = 1; -#else - be = 0; -#endif /* FPGA */ malta_fpga_init(0x1f000000LL, env->irq[2], serial_hds[2]); @@ -838,7 +843,7 @@ void mips_malta_init (ram_addr_t ram_size, loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel(); - write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry); + write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { @@ -847,13 +852,13 @@ void mips_malta_init (ram_addr_t ram_size, fl_sectors = bios_size >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx " at " - "offset %08lx addr %08llx '%s' %x\n", - fl_idx, bios_size, bios_offset, 0x1e000000LL, + "addr %08llx '%s' %x\n", + fl_idx, bios_size, 0x1e000000LL, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif - pflash_cfi01_register(0x1e000000LL, bios_offset, + pflash_cfi01_register(0x1e000000LL, bios, dinfo->bdrv, 65536, fl_sectors, - 4, 0x0000, 0x0000, 0x0000, 0x0000, be); + 4, 0x0000, 0x0000, 0x0000, 0x0000); fl_idx++; } else { /* Load a BIOS image. */ @@ -878,7 +883,7 @@ void mips_malta_init (ram_addr_t ram_size, a neat trick which allows bi-endian firmware. */ #ifndef TARGET_WORDS_BIGENDIAN { - uint32_t *addr = qemu_get_ram_ptr(bios_offset);; + uint32_t *addr = memory_region_get_ram_ptr(bios); uint32_t *end = addr + bios_size; while (addr < end) { bswap32s(addr); @@ -890,7 +895,7 @@ void mips_malta_init (ram_addr_t ram_size, /* Board ID = 0x420 (Malta Board with CoreLV) XXX: theoretically 0x1e000010 should map to flash and 0x1fc00010 should map to the board ID. */ - stl_p(qemu_get_ram_ptr(bios_offset) + 0x10, 0x00000420); + stl_p(memory_region_get_ram_ptr(bios) + 0x10, 0x00000420); /* Init internal devices */ cpu_mips_irq_init_cpu(env); |