--- trunk/src/devices/dev_ram.c 2007/10/08 16:19:37 22 +++ trunk/src/devices/dev_ram.c 2007/10/08 16:21:34 36 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2004-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_ram.c,v 1.21 2006/01/01 13:17:17 debug Exp $ + * $Id: dev_ram.c,v 1.24 2007/03/08 11:43:44 debug Exp $ * * A generic RAM (memory) device. Can also be used to mirror/alias another * part of RAM. @@ -47,6 +47,8 @@ /* #define RAM_DEBUG */ struct ram_data { + uint64_t baseaddress; + int mode; uint64_t otheraddress; @@ -59,9 +61,6 @@ }; -/* - * dev_ram_access(): - */ DEVICE_ACCESS(ram) { struct ram_data *d = extra; @@ -86,10 +85,18 @@ d->otheraddress + relative_addr, data, len, writeflag, PHYSICAL); case DEV_RAM_RAM: - if (writeflag == MEM_WRITE) + if (writeflag == MEM_WRITE) { memcpy(&d->data[relative_addr], data, len); - else + + /* Invalidate any code translations on a write: */ + if (cpu->invalidate_code_translation != NULL) { + cpu->invalidate_code_translation( + cpu, d->baseaddress + relative_addr, + INVALIDATE_PADDR); + } + } else { memcpy(data, &d->data[relative_addr], len); + } break; default: fatal("dev_ram_access(): unknown mode %i\n", d->mode); @@ -127,6 +134,7 @@ } d->mode = mode; + d->baseaddress = baseaddr; d->otheraddress = otheraddress; switch (d->mode) {