Revision 563c2bf3 hw/integratorcp.c
b/hw/integratorcp.c | ||
---|---|---|
21 | 21 |
MemoryRegion iomem; |
22 | 22 |
uint32_t memsz; |
23 | 23 |
MemoryRegion flash; |
24 |
bool flash_mapped; |
|
25 | 24 |
uint32_t cm_osc; |
26 | 25 |
uint32_t cm_ctrl; |
27 | 26 |
uint32_t cm_lock; |
... | ... | |
110 | 109 |
} |
111 | 110 |
} |
112 | 111 |
|
113 |
static void integratorcm_do_remap(integratorcm_state *s, int flash)
|
|
112 |
static void integratorcm_do_remap(integratorcm_state *s) |
|
114 | 113 |
{ |
115 |
if (!flash) { |
|
116 |
if (s->flash_mapped) { |
|
117 |
sysbus_del_memory(&s->busdev, &s->flash); |
|
118 |
s->flash_mapped = false; |
|
119 |
} |
|
120 |
} else { |
|
121 |
if (!s->flash_mapped) { |
|
122 |
sysbus_add_memory_overlap(&s->busdev, 0, &s->flash, 1); |
|
123 |
s->flash_mapped = true; |
|
124 |
} |
|
125 |
} |
|
126 |
//??? tlb_flush (cpu_single_env, 1); |
|
114 |
/* Sync memory region state with CM_CTRL REMAP bit: |
|
115 |
* bit 0 => flash at address 0; bit 1 => RAM |
|
116 |
*/ |
|
117 |
memory_region_set_enabled(&s->flash, !(s->cm_ctrl & 4)); |
|
127 | 118 |
} |
128 | 119 |
|
129 | 120 |
static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value) |
... | ... | |
131 | 122 |
if (value & 8) { |
132 | 123 |
qemu_system_reset_request(); |
133 | 124 |
} |
134 |
if ((s->cm_ctrl ^ value) & 4) { |
|
135 |
integratorcm_do_remap(s, (value & 4) == 0); |
|
136 |
} |
|
137 | 125 |
if ((s->cm_ctrl ^ value) & 1) { |
138 | 126 |
/* (value & 1) != 0 means the green "MISC LED" is lit. |
139 | 127 |
* We don't have any nice place to display LEDs. printf is a bad |
... | ... | |
143 | 131 |
} |
144 | 132 |
/* Note that the RESET bit [3] always reads as zero */ |
145 | 133 |
s->cm_ctrl = (s->cm_ctrl & ~5) | (value & 5); |
134 |
integratorcm_do_remap(s); |
|
146 | 135 |
} |
147 | 136 |
|
148 | 137 |
static void integratorcm_update(integratorcm_state *s) |
... | ... | |
263 | 252 |
s->cm_init = 0x00000112; |
264 | 253 |
memory_region_init_ram(&s->flash, "integrator.flash", 0x100000); |
265 | 254 |
vmstate_register_ram_global(&s->flash); |
266 |
s->flash_mapped = false; |
|
267 | 255 |
|
268 | 256 |
memory_region_init_io(&s->iomem, &integratorcm_ops, s, |
269 | 257 |
"integratorcm", 0x00800000); |
270 | 258 |
sysbus_init_mmio(dev, &s->iomem); |
271 | 259 |
|
272 |
integratorcm_do_remap(s, 1);
|
|
260 |
integratorcm_do_remap(s); |
|
273 | 261 |
/* ??? Save/restore. */ |
274 | 262 |
return 0; |
275 | 263 |
} |
Also available in: Unified diff