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/mainstone.c | |
parent | a1807ef2954d3ddbf9a9bca3949bd0c69fd45a0e (diff) |
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/mainstone.c')
-rw-r--r-- | hw/mainstone.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/hw/mainstone.c b/hw/mainstone.c index 4792f0e3ed..78af41b990 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -101,7 +101,8 @@ static void mainstone_common_init(ram_addr_t ram_size, DeviceState *mst_irq; DriveInfo *dinfo; int i; - int be; + MemoryRegion *flashes = g_new(MemoryRegion, 2); + const MemoryRegionOps *flash_ops; if (!cpu_model) cpu_model = "pxa270-c5"; @@ -113,9 +114,9 @@ static void mainstone_common_init(ram_addr_t ram_size, MAINSTONE_ROM) | IO_MEM_ROM); #ifdef TARGET_WORDS_BIGENDIAN - be = 1; + flash_ops = &pflash_cfi01_ops_be; #else - be = 0; + flash_ops = &pflash_cfi01_ops_le; #endif /* There are two 32MiB flash devices on the board */ for (i = 0; i < 2; i ++) { @@ -126,13 +127,14 @@ static void mainstone_common_init(ram_addr_t ram_size, exit(1); } + memory_region_init_rom_device(&flashes[i], flash_ops, + NULL, (i ? "mainstone.flash1" + : "mainstone.flash0"), + MAINSTONE_FLASH); if (!pflash_cfi01_register(mainstone_flash_base[i], - qemu_ram_alloc(NULL, i ? "mainstone.flash1" : - "mainstone.flash0", - MAINSTONE_FLASH), - dinfo->bdrv, sector_len, - MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0, - be)) { + &flashes[i], dinfo->bdrv, sector_len, + MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, + 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); exit(1); } |