66 unsigned char *
data,
size_t len,
int writeflag,
int misc_flags)
69 const int offset_mask = 0x1fff;
71 const int offset_mask = 0xfff;
76 int cache, no_exceptions, offset;
77 unsigned char *memblock;
78 int dyntrans_device_danger = 0;
109 static int swriteflag = -1, lastswriteflag;
110 static int32_t start = -1, stop = -1;
111 static int32_t laststart = -1, laststop = -1;
115 start = stop = paddr;
116 swriteflag = writeflag;
120 if (paddr == stop + len && writeflag == swriteflag)
126 if (start != laststart || stop != laststop || swriteflag != lastswriteflag)
128 printf(
"%s %08x -- %08x %i-bit\n",
129 swriteflag ?
"WRITE" :
"READ ",
130 (
int)start, (
int)(stop + len - 1), (
int)len*8);
133 laststart = start; laststop = stop; lastswriteflag = swriteflag;
135 start = stop = paddr;
136 swriteflag = writeflag;
151 (paddr >= 0x0c000000 && paddr < 0x0d000000)))
153 int64_t xsize = 1920, ysize = 1080;
155 static int count = 0;
156 static uint8_t* buf = NULL;
160 buf = (uint8_t*)malloc(xsize * ysize*3);
161 memset(buf, 0xff, xsize * ysize*3);
164 uint64_t paddr2 = paddr - 0x0c000000;
166 if (paddr < 0x200000)
167 paddr2 = paddr + 16*1048576;
169 int64_t max = 16*1048576 + (2*1048576);
171 int64_t x = xsize * paddr2 / max;
173 if (x >= 0 && x < xsize)
177 int c = buf[(x+y*xsize)*3+0];
185 buf[(x+y*xsize)*3+1] = c;
186 buf[(x+y*xsize)*3+2] = c;
190 int c = buf[(x+y*xsize)*3+1];
198 buf[(x+y*xsize)*3+0] = c;
199 buf[(x+y*xsize)*3+2] = c;
203 for (
int meg = 0; meg < 18; ++meg)
204 buf[((xsize * (meg * 0x100000LL) / max) +y*xsize)*3+1] = 64;
216 snprintf(name,
sizeof(name),
"memory_%05i.ppm", n++);
217 FILE*
f = fopen(name,
"w");
218 printf(
"writing out %s\n", name);
219 fprintf(
f,
"P6\n%i %i\n255\n", (
int)xsize, (
int)ysize);
220 fwrite((
char*)buf, 1, (
int)(xsize*ysize*3),
f);
222 memset(buf, 0xff, xsize*ysize);
239 uint64_t orig_paddr = paddr;
240 int i, start, end, res;
244 TODO: The correct solution
for this is to add RAM devices _around_ the
245 dangerous device. The solution below incurs a slowdown
for _everything_,
246 not just the device in question.
272 dyntrans_device_danger = 1;
283 paddr < mem->devices[i].endaddr) {
295 unsigned char *host_addr;
301 if (writeflag && wf) {
302 if (paddr < mem->devices[i].
310 dyntrans_write_high =
319 uint64_t *pp = (uint64_t *)mem->
320 devices[i].dyntrans_data;
321 uint64_t p = orig_paddr - *pp;
324 mem, p & ~offset_mask,
329 (paddr & ~offset_mask);
333 vaddr & ~offset_mask, host_addr,
334 wf, orig_paddr & ~offset_mask);
341 data, len, writeflag,
352 if (res <= 0 && !no_exceptions) {
353 debug(
"[ %s device '%s' addr %08lx "
354 "failed ]\n", writeflag?
355 "writing to" :
"reading from",
361 0, vaddr, 0, 0, 0, 0);
378 if (paddr < mem->devices[i].baseaddr)
382 i = (start + end) >> 1;
383 }
while (start <= end);
396 !((vaddr & 0xffffffffULL) >= 0xa0000000ULL &&
397 (vaddr & 0xffffffffULL) <= 0xbfffffffULL)) {
399 writeflag, len,
data))
414 if ((paddr & 0xffffc00000ULL) == 0x1fc00000) {
416 }
else if ((paddr & 0xfffff00000ULL) == 0x1ff00000) {
420 memset(
data, 0, len);
427 (
cpu, mem, writeflag, paddr,
data, len);
431 memset(
data, 0, len);
448 paddr < mem->physical_max+1048576) {
478 if (memblock == NULL) {
480 memset(
data, 0, len);
484 offset = paddr & offset_mask;
497 (writeflag ==
MEM_WRITE? 1 : 0) : ok - 1),
498 paddr & ~offset_mask);
511 printf(
"Write over memblock boundary?\n");
517 memcpy(memblock + offset,
data, len);
519 memcpy(
data, memblock + offset, len);