25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_ram.c,v 1.19 2005/10/25 15:51:04 debug Exp $ |
* $Id: dev_ram.c,v 1.20 2005/11/13 00:14:09 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. |
113 |
int mode, uint64_t otheraddress) |
int mode, uint64_t otheraddress) |
114 |
{ |
{ |
115 |
struct ram_data *d; |
struct ram_data *d; |
116 |
int flags = MEM_DEFAULT, points_to_ram = 1; |
int flags = DM_DEFAULT, points_to_ram = 1; |
117 |
|
|
118 |
d = malloc(sizeof(struct ram_data)); |
d = malloc(sizeof(struct ram_data)); |
119 |
if (d == NULL) { |
if (d == NULL) { |
137 |
/* |
/* |
138 |
* Calculate the amount that the mirror memory is offset from |
* Calculate the amount that the mirror memory is offset from |
139 |
* the real (physical) memory. This is used in src/memory_rw.c |
* the real (physical) memory. This is used in src/memory_rw.c |
140 |
* with dyntrans accesses if MEM_EMULATED_RAM is set. |
* with dyntrans accesses if DM_EMULATED_RAM is set. |
141 |
*/ |
*/ |
142 |
d->offset = baseaddr - otheraddress; |
d->offset = baseaddr - otheraddress; |
143 |
|
|
146 |
(baseaddr & (machine->arch_pagesize-1)) == 0 && |
(baseaddr & (machine->arch_pagesize-1)) == 0 && |
147 |
(otheraddress & (machine->arch_pagesize - 1)) == 0 && |
(otheraddress & (machine->arch_pagesize - 1)) == 0 && |
148 |
(length & (machine->arch_pagesize - 1)) == 0) |
(length & (machine->arch_pagesize - 1)) == 0) |
149 |
flags |= MEM_DYNTRANS_OK | MEM_DYNTRANS_WRITE_OK |
flags |= DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK |
150 |
| MEM_EMULATED_RAM; |
| DM_EMULATED_RAM; |
151 |
|
|
152 |
memory_device_register(machine->memory, "ram [mirror]", |
memory_device_register(machine->memory, "ram [mirror]", |
153 |
baseaddr, length, dev_ram_access, d, flags |
baseaddr, length, dev_ram_access, d, flags |
154 |
| MEM_READING_HAS_NO_SIDE_EFFECTS, (void *) &d->offset); |
| DM_READS_HAVE_NO_SIDE_EFFECTS, (void *) &d->offset); |
155 |
break; |
break; |
156 |
|
|
157 |
case DEV_RAM_RAM: |
case DEV_RAM_RAM: |
175 |
/* Aligned memory? Then it works with dyntrans. */ |
/* Aligned memory? Then it works with dyntrans. */ |
176 |
if ((baseaddr & (machine->arch_pagesize - 1)) == 0 && |
if ((baseaddr & (machine->arch_pagesize - 1)) == 0 && |
177 |
(length & (machine->arch_pagesize - 1)) == 0) |
(length & (machine->arch_pagesize - 1)) == 0) |
178 |
flags |= MEM_DYNTRANS_OK | MEM_DYNTRANS_WRITE_OK; |
flags |= DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK; |
179 |
|
|
180 |
memory_device_register(machine->memory, "ram", baseaddr, |
memory_device_register(machine->memory, "ram", baseaddr, |
181 |
d->length, dev_ram_access, d, flags |
d->length, dev_ram_access, d, flags |
182 |
| MEM_READING_HAS_NO_SIDE_EFFECTS, d->data); |
| DM_READS_HAVE_NO_SIDE_EFFECTS, d->data); |
183 |
break; |
break; |
184 |
|
|
185 |
default: |
default: |