Revision 211adf4d hw/integratorcp.c
b/hw/integratorcp.c | ||
---|---|---|
13 | 13 |
#include "boards.h" |
14 | 14 |
#include "arm-misc.h" |
15 | 15 |
#include "net.h" |
16 |
#include "exec-memory.h" |
|
16 | 17 |
|
17 | 18 |
typedef struct { |
18 | 19 |
SysBusDevice busdev; |
19 | 20 |
uint32_t memsz; |
20 |
uint32_t flash_offset; |
|
21 |
MemoryRegion flash; |
|
22 |
bool flash_mapped; |
|
21 | 23 |
uint32_t cm_osc; |
22 | 24 |
uint32_t cm_ctrl; |
23 | 25 |
uint32_t cm_lock; |
... | ... | |
108 | 110 |
static void integratorcm_do_remap(integratorcm_state *s, int flash) |
109 | 111 |
{ |
110 | 112 |
if (flash) { |
111 |
cpu_register_physical_memory(0, 0x100000, IO_MEM_RAM); |
|
113 |
if (s->flash_mapped) { |
|
114 |
sysbus_del_memory(&s->busdev, &s->flash); |
|
115 |
s->flash_mapped = false; |
|
116 |
} |
|
112 | 117 |
} else { |
113 |
cpu_register_physical_memory(0, 0x100000, s->flash_offset | IO_MEM_RAM); |
|
118 |
if (!s->flash_mapped) { |
|
119 |
sysbus_add_memory_overlap(&s->busdev, 0, &s->flash, 1); |
|
120 |
s->flash_mapped = true; |
|
121 |
} |
|
114 | 122 |
} |
115 | 123 |
//??? tlb_flush (cpu_single_env, 1); |
116 | 124 |
} |
... | ... | |
252 | 260 |
} |
253 | 261 |
memcpy(integrator_spd + 73, "QEMU-MEMORY", 11); |
254 | 262 |
s->cm_init = 0x00000112; |
255 |
s->flash_offset = qemu_ram_alloc(NULL, "integrator.flash", 0x100000); |
|
263 |
memory_region_init_ram(&s->flash, NULL, "integrator.flash", 0x100000); |
|
264 |
s->flash_mapped = false; |
|
256 | 265 |
|
257 | 266 |
iomemtype = cpu_register_io_memory(integratorcm_readfn, |
258 | 267 |
integratorcm_writefn, s, |
... | ... | |
456 | 465 |
const char *initrd_filename, const char *cpu_model) |
457 | 466 |
{ |
458 | 467 |
CPUState *env; |
459 |
ram_addr_t ram_offset; |
|
468 |
MemoryRegion *address_space_mem = get_system_memory(); |
|
469 |
MemoryRegion *ram = g_new(MemoryRegion, 1); |
|
470 |
MemoryRegion *ram_alias = g_new(MemoryRegion, 1); |
|
460 | 471 |
qemu_irq pic[32]; |
461 | 472 |
qemu_irq *cpu_pic; |
462 | 473 |
DeviceState *dev; |
... | ... | |
469 | 480 |
fprintf(stderr, "Unable to find CPU definition\n"); |
470 | 481 |
exit(1); |
471 | 482 |
} |
472 |
ram_offset = qemu_ram_alloc(NULL, "integrator.ram", ram_size);
|
|
483 |
memory_region_init_ram(ram, NULL, "integrator.ram", ram_size);
|
|
473 | 484 |
/* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ |
474 | 485 |
/* ??? RAM should repeat to fill physical memory space. */ |
475 | 486 |
/* SDRAM at address zero*/ |
476 |
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
|
|
487 |
memory_region_add_subregion(address_space_mem, 0, ram);
|
|
477 | 488 |
/* And again at address 0x80000000 */ |
478 |
cpu_register_physical_memory(0x80000000, ram_size, ram_offset | IO_MEM_RAM); |
|
489 |
memory_region_init_alias(ram_alias, "ram.alias", ram, 0, ram_size); |
|
490 |
memory_region_add_subregion(address_space_mem, 0x80000000, ram_alias); |
|
479 | 491 |
|
480 | 492 |
dev = qdev_create(NULL, "integrator_core"); |
481 | 493 |
qdev_prop_set_uint32(dev, "memsz", ram_size >> 20); |
Also available in: Unified diff