提交 563c2bf3 编写于 作者: P Peter Maydell 提交者: Andrzej Zaborowski

hw/integratorcp: Simplify flash remap code

Use the new memory mutator API to simplify the flash remap code;
this allows us to drop the flash_mapped flag.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NAndrzej Zaborowski <andrew.zaborowski@intel.com>
上级 4753dea8
...@@ -21,7 +21,6 @@ typedef struct { ...@@ -21,7 +21,6 @@ typedef struct {
MemoryRegion iomem; MemoryRegion iomem;
uint32_t memsz; uint32_t memsz;
MemoryRegion flash; MemoryRegion flash;
bool flash_mapped;
uint32_t cm_osc; uint32_t cm_osc;
uint32_t cm_ctrl; uint32_t cm_ctrl;
uint32_t cm_lock; uint32_t cm_lock;
...@@ -110,20 +109,12 @@ static uint64_t integratorcm_read(void *opaque, target_phys_addr_t offset, ...@@ -110,20 +109,12 @@ static uint64_t integratorcm_read(void *opaque, target_phys_addr_t offset,
} }
} }
static void integratorcm_do_remap(integratorcm_state *s, int flash) static void integratorcm_do_remap(integratorcm_state *s)
{ {
if (!flash) { /* Sync memory region state with CM_CTRL REMAP bit:
if (s->flash_mapped) { * bit 0 => flash at address 0; bit 1 => RAM
sysbus_del_memory(&s->busdev, &s->flash); */
s->flash_mapped = false; memory_region_set_enabled(&s->flash, !(s->cm_ctrl & 4));
}
} else {
if (!s->flash_mapped) {
sysbus_add_memory_overlap(&s->busdev, 0, &s->flash, 1);
s->flash_mapped = true;
}
}
//??? tlb_flush (cpu_single_env, 1);
} }
static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value) static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value)
...@@ -131,9 +122,6 @@ static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value) ...@@ -131,9 +122,6 @@ static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value)
if (value & 8) { if (value & 8) {
qemu_system_reset_request(); qemu_system_reset_request();
} }
if ((s->cm_ctrl ^ value) & 4) {
integratorcm_do_remap(s, (value & 4) == 0);
}
if ((s->cm_ctrl ^ value) & 1) { if ((s->cm_ctrl ^ value) & 1) {
/* (value & 1) != 0 means the green "MISC LED" is lit. /* (value & 1) != 0 means the green "MISC LED" is lit.
* We don't have any nice place to display LEDs. printf is a bad * We don't have any nice place to display LEDs. printf is a bad
...@@ -143,6 +131,7 @@ static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value) ...@@ -143,6 +131,7 @@ static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value)
} }
/* Note that the RESET bit [3] always reads as zero */ /* Note that the RESET bit [3] always reads as zero */
s->cm_ctrl = (s->cm_ctrl & ~5) | (value & 5); s->cm_ctrl = (s->cm_ctrl & ~5) | (value & 5);
integratorcm_do_remap(s);
} }
static void integratorcm_update(integratorcm_state *s) static void integratorcm_update(integratorcm_state *s)
...@@ -263,13 +252,12 @@ static int integratorcm_init(SysBusDevice *dev) ...@@ -263,13 +252,12 @@ static int integratorcm_init(SysBusDevice *dev)
s->cm_init = 0x00000112; s->cm_init = 0x00000112;
memory_region_init_ram(&s->flash, "integrator.flash", 0x100000); memory_region_init_ram(&s->flash, "integrator.flash", 0x100000);
vmstate_register_ram_global(&s->flash); vmstate_register_ram_global(&s->flash);
s->flash_mapped = false;
memory_region_init_io(&s->iomem, &integratorcm_ops, s, memory_region_init_io(&s->iomem, &integratorcm_ops, s,
"integratorcm", 0x00800000); "integratorcm", 0x00800000);
sysbus_init_mmio(dev, &s->iomem); sysbus_init_mmio(dev, &s->iomem);
integratorcm_do_remap(s, 1); integratorcm_do_remap(s);
/* ??? Save/restore. */ /* ??? Save/restore. */
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册