25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_ram.c,v 1.23 2006/12/30 13:30:59 debug Exp $ |
* $Id: dev_ram.c,v 1.24 2007/03/08 11:43:44 debug Exp $ |
29 |
* |
* |
30 |
* A generic RAM (memory) device. Can also be used to mirror/alias another |
* A generic RAM (memory) device. Can also be used to mirror/alias another |
31 |
* part of RAM. |
* part of RAM. |
47 |
/* #define RAM_DEBUG */ |
/* #define RAM_DEBUG */ |
48 |
|
|
49 |
struct ram_data { |
struct ram_data { |
50 |
|
uint64_t baseaddress; |
51 |
|
|
52 |
int mode; |
int mode; |
53 |
uint64_t otheraddress; |
uint64_t otheraddress; |
54 |
|
|
85 |
d->otheraddress + relative_addr, data, len, |
d->otheraddress + relative_addr, data, len, |
86 |
writeflag, PHYSICAL); |
writeflag, PHYSICAL); |
87 |
case DEV_RAM_RAM: |
case DEV_RAM_RAM: |
88 |
if (writeflag == MEM_WRITE) |
if (writeflag == MEM_WRITE) { |
89 |
memcpy(&d->data[relative_addr], data, len); |
memcpy(&d->data[relative_addr], data, len); |
90 |
else |
|
91 |
|
/* Invalidate any code translations on a write: */ |
92 |
|
if (cpu->invalidate_code_translation != NULL) { |
93 |
|
cpu->invalidate_code_translation( |
94 |
|
cpu, d->baseaddress + relative_addr, |
95 |
|
INVALIDATE_PADDR); |
96 |
|
} |
97 |
|
} else { |
98 |
memcpy(data, &d->data[relative_addr], len); |
memcpy(data, &d->data[relative_addr], len); |
99 |
|
} |
100 |
break; |
break; |
101 |
default: |
default: |
102 |
fatal("dev_ram_access(): unknown mode %i\n", d->mode); |
fatal("dev_ram_access(): unknown mode %i\n", d->mode); |
134 |
} |
} |
135 |
|
|
136 |
d->mode = mode; |
d->mode = mode; |
137 |
|
d->baseaddress = baseaddr; |
138 |
d->otheraddress = otheraddress; |
d->otheraddress = otheraddress; |
139 |
|
|
140 |
switch (d->mode) { |
switch (d->mode) { |