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;
107 if (cpu->
running && paddr < 0x00300000)
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;
150 if (cpu->
running && (paddr < 0x200000 ||
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);
340 res = mem->
devices[i].
f(cpu, mem, paddr,
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);
int(* translate_v2p)(struct cpu *, uint64_t vaddr, uint64_t *return_paddr, int flags)
#define FLAG_NOEXCEPTIONS
#define MEMORY_NOT_FULL_PAGE
#define MIPS1_ISOL_CACHES
int(* f)(struct cpu *, struct memory *, uint64_t, unsigned char *, size_t, int, void *)
void f(int s, int func, int only_name)
void m88k_exception(struct cpu *cpu, int vector, int is_trap)
#define BITS_PER_MEMBLOCK
uint64_t reg[N_MIPS_COPROC_REGS]
void memory_warn_about_unimplemented_addr(struct cpu *cpu, struct memory *mem, int writeflag, uint64_t paddr, uint8_t *data, size_t len)
#define DM_READS_HAVE_NO_SIDE_EFFECTS
int memory_cache_R3000(struct cpu *cpu, int cache, uint64_t paddr, int writeflag, size_t len, unsigned char *data)
#define DM_DYNTRANS_WRITE_OK
void mips_cpu_exception(struct cpu *cpu, int exccode, int tlb, uint64_t vaddr, int coproc_nr, uint64_t vaddr_vpn2, int vaddr_asid, int x_64)
struct mips_coproc * coproc[N_MIPS_COPROCS]
int MEMORY_RW(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int misc_flags)
#define CACHE_INSTRUCTION
#define MEMORY_USER_ACCESS
#define MEMORY_ACCESS_FAILED
#define M88K_EXCEPTION_INSTRUCTION_ACCESS
uint64_t mmap_dev_minaddr
void(* update_translation_table)(struct cpu *, uint64_t vaddr_page, unsigned char *host_page, int writeflag, uint64_t paddr_page)
struct memory_device * devices
#define M88K_EXCEPTION_DATA_ACCESS
void(* invalidate_code_translation)(struct cpu *, uint64_t paddr, int flags)
struct mips_cpu_type_def cpu_type
unsigned char * memory_paddr_to_hostaddr(struct memory *mem, uint64_t paddr, int writeflag)