25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: memory.c,v 1.176 2005/08/28 20:16:23 debug Exp $ |
* $Id: memory.c,v 1.180 2005/10/25 15:51:02 debug Exp $ |
29 |
* |
* |
30 |
* Functions for handling the memory of an emulated machine. |
* Functions for handling the memory of an emulated machine. |
31 |
*/ |
*/ |
290 |
/* Invalidate any pages of this device that might |
/* Invalidate any pages of this device that might |
291 |
be in the dyntrans load/store cache, by marking |
be in the dyntrans load/store cache, by marking |
292 |
the pages read-only. */ |
the pages read-only. */ |
293 |
if (cpu->invalidate_translation_caches_paddr != NULL) { |
if (cpu->invalidate_translation_caches != NULL) { |
294 |
for (s=0; s<mem->dev_length[i]; |
for (s=0; s<mem->dev_length[i]; |
295 |
s+=cpu->machine->arch_pagesize) |
s+=cpu->machine->arch_pagesize) |
296 |
cpu->invalidate_translation_caches_paddr |
cpu->invalidate_translation_caches |
297 |
(cpu, mem->dev_baseaddr[i] + s, |
(cpu, mem->dev_baseaddr[i] + s, |
298 |
JUST_MARK_AS_NON_WRITABLE); |
JUST_MARK_AS_NON_WRITABLE |
299 |
|
| INVALIDATE_PADDR); |
300 |
} |
} |
301 |
|
|
302 |
if (cpu->machine->arch == ARCH_MIPS) { |
if (cpu->machine->arch == ARCH_MIPS) { |
402 |
|
|
403 |
mem->dev_name[mem->n_mmapped_devices] = strdup(device_name); |
mem->dev_name[mem->n_mmapped_devices] = strdup(device_name); |
404 |
mem->dev_baseaddr[mem->n_mmapped_devices] = baseaddr; |
mem->dev_baseaddr[mem->n_mmapped_devices] = baseaddr; |
405 |
|
mem->dev_endaddr[mem->n_mmapped_devices] = baseaddr + len; |
406 |
mem->dev_length[mem->n_mmapped_devices] = len; |
mem->dev_length[mem->n_mmapped_devices] = len; |
407 |
mem->dev_flags[mem->n_mmapped_devices] = flags; |
mem->dev_flags[mem->n_mmapped_devices] = flags; |
408 |
mem->dev_dyntrans_data[mem->n_mmapped_devices] = dyntrans_data; |
mem->dev_dyntrans_data[mem->n_mmapped_devices] = dyntrans_data; |
413 |
} |
} |
414 |
|
|
415 |
if (flags & (MEM_DYNTRANS_OK | MEM_DYNTRANS_WRITE_OK) |
if (flags & (MEM_DYNTRANS_OK | MEM_DYNTRANS_WRITE_OK) |
416 |
&& dyntrans_data == NULL) { |
&& !(flags & MEM_EMULATED_RAM) && dyntrans_data == NULL) { |
417 |
fatal("\nERROR: Device dyntrans access, but dyntrans_data" |
fatal("\nERROR: Device dyntrans access, but dyntrans_data" |
418 |
" = NULL!\n"); |
" = NULL!\n"); |
419 |
exit(1); |
exit(1); |
420 |
} |
} |
421 |
|
|
422 |
if ((size_t)dyntrans_data & 7) { |
if ((size_t)dyntrans_data & (sizeof(void *) - 1)) { |
423 |
fprintf(stderr, "memory_device_register():" |
fprintf(stderr, "memory_device_register():" |
424 |
" dyntrans_data not aligned correctly (%p)\n", |
" dyntrans_data not aligned correctly (%p)\n", |
425 |
dyntrans_data); |
dyntrans_data); |