--- trunk/src/memory_rw.c 2007/10/08 16:20:58 32 +++ trunk/src/memory_rw.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2003-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: memory_rw.c,v 1.97 2006/09/07 11:44:01 debug Exp $ + * $Id: memory_rw.c,v 1.101 2007/02/10 14:04:51 debug Exp $ * * Generic memory_rw(), with special hacks for specific CPU families. * @@ -81,70 +81,6 @@ no_exceptions = misc_flags & NO_EXCEPTIONS; cache = misc_flags & CACHE_FLAGS_MASK; -#ifdef MEM_X86 - /* Real-mode wrap-around: */ - if (REAL_MODE && !(misc_flags & PHYSICAL)) { - if ((vaddr & 0xffff) + len > 0x10000) { - /* Do one byte at a time: */ - int res = 0; - size_t i; - for (i=0; i 0x1000 && !(misc_flags & PHYSICAL) - && cpu->cd.x86.cr[0] & X86_CR0_PG) { - /* - * For WRITES: Read ALL BYTES FIRST and write them back!!! - * Then do a write of all the new bytes. This is to make sure - * than both pages around the boundary are writable so that - * there is no "partial write" performed. - */ - int res = 0; - size_t i; - if (writeflag == MEM_WRITE) { - unsigned char tmp; - for (i=0; irunning = 0; - } - return 0; - } - } - } - return res; - } -#endif /* X86 */ - #ifdef MEM_USERLAND #ifdef MEM_ALPHA @@ -159,9 +95,6 @@ ok = cpu->translate_v2p(cpu, vaddr, &paddr, (writeflag? FLAG_WRITEFLAG : 0) + (no_exceptions? FLAG_NOEXCEPTIONS : 0) -#ifdef MEM_X86 - + (misc_flags & NO_SEGMENTATION) -#endif #ifdef MEM_ARM + (misc_flags & MEMORY_USER_ACCESS) #endif @@ -176,22 +109,6 @@ return MEMORY_ACCESS_FAILED; } - -#ifdef MEM_X86 - /* DOS debugging :-) */ - if (!quiet_mode && !(misc_flags & PHYSICAL)) { - if (paddr >= 0x400 && paddr <= 0x4ff) - debug("{ PC BIOS DATA AREA: %s 0x%x }\n", writeflag == - MEM_WRITE? "writing to" : "reading from", - (int)paddr); -#if 0 - if (paddr >= 0xf0000 && paddr <= 0xfffff) - debug("{ BIOS ACCESS: %s 0x%x }\n", - writeflag == MEM_WRITE? "writing to" : - "reading from", (int)paddr); -#endif - } -#endif #endif /* !MEM_USERLAND */ @@ -206,6 +123,12 @@ uint64_t orig_paddr = paddr; int i, start, end, res; +#if 0 + +TODO: The correct solution for this is to add RAM devices _around_ the +dangerous device. The solution below incurs a slowdown for _everything_, +not just the device in question. + /* * Really really slow, but unfortunately necessary. This is * to avoid the folowing scenario: @@ -227,7 +150,6 @@ * TODO: Convert this into a quick (multi-level, 64-bit) * address space lookup, to find dangerous pages. */ -#if 1 for (i=0; in_mmapped_devices; i++) if (paddr >= (mem->devices[i].baseaddr & ~offset_mask)&& paddr <= ((mem->devices[i].endaddr-1)|offset_mask)){ @@ -306,7 +228,6 @@ if (res == 0) res = -1; -#ifndef MEM_X86 /* * If accessing the memory mapped device * failed, then return with a DBE exception. @@ -322,7 +243,6 @@ #endif return MEMORY_ACCESS_FAILED; } -#endif goto do_return_ok; } @@ -373,65 +293,13 @@ } else #endif /* MIPS */ { - if (paddr >= mem->physical_max) { - uint64_t offset, old_pc = cpu->pc; - char *symbol; - - /* This allows for example OS kernels to probe - memory a few KBs past the end of memory, - without giving too many warnings. */ - if (!quiet_mode && !no_exceptions && paddr >= - mem->physical_max + 0x40000) { - fatal("[ memory_rw(): writeflag=%i ", - writeflag); - if (writeflag) { - unsigned int i; - debug("data={", writeflag); - if (len > 16) { - int start2 = len-16; - for (i=0; i<16; i++) - debug("%s%02x", - i?",":"", - data[i]); - debug(" .. "); - if (start2 < 16) - start2 = 16; - for (i=start2; i= physical_max" - "; pc=", (long long)paddr); - if (cpu->is_32bit) - fatal("0x%08x",(int)old_pc); - else - fatal("0x%016llx", - (long long)old_pc); - symbol = get_symbol_name( - &cpu->machine->symbol_context, - old_pc, &offset); - fatal(" <%s> ]\n", - symbol? symbol : " no symbol "); - } - } + if (paddr >= mem->physical_max && !no_exceptions) + memory_warn_about_unimplemented_addr + (cpu, mem, writeflag, paddr, data, len); if (writeflag == MEM_READ) { -#ifdef MEM_X86 - /* Reading non-existant memory on x86: */ - memset(data, 0xff, len); -#else /* Return all zeroes? (Or 0xff? TODO) */ memset(data, 0, len); -#endif #ifdef MEM_MIPS /*