diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d88f037b2..2300d41896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1339,6 +1339,7 @@ add_library(${CoreLibName} ${CoreLinkType} Core/MemMap.cpp Core/MemMap.h Core/MemMapFunctions.cpp + Core/MemMapHelpers.h Core/PSPLoaders.cpp Core/PSPLoaders.h Core/Reporting.cpp diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index d62edfb800..dfe8680722 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -539,6 +539,7 @@ + true true @@ -631,4 +632,4 @@ - + \ No newline at end of file diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 2aeb893964..4bbb788e14 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1061,6 +1061,9 @@ HLE\Libraries + + Core + diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 991e857c4e..165231c0fe 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -413,7 +413,7 @@ void CWCheatEngine::Run() { int len = arg; InvalidateICache(destAddr, len); if (Memory::IsValidAddress(addr) && Memory::IsValidAddress(destAddr)) { - Memory::Memcpy(destAddr, Memory::GetPointer(addr), len); + Memory::MemcpyUnchecked(destAddr, addr, len); } } break; @@ -442,7 +442,9 @@ void CWCheatEngine::Run() { { int srcAddr = Memory::Read_U32(addr) + offset; int dstAddr = Memory::Read_U16(addr + baseOffset) + (arg3 & 0x0FFFFFFF); - Memory::Memcpy(dstAddr, Memory::GetPointer(srcAddr), arg); + if (Memory::IsValidAddress(dstAddr) && Memory::IsValidAddress(srcAddr)) { + Memory::MemcpyUnchecked(dstAddr, srcAddr, arg); + } type = -1; //Done break; } case 0x2: diff --git a/Core/Dialog/PSPGamedataInstallDialog.cpp b/Core/Dialog/PSPGamedataInstallDialog.cpp index 1f716fe85d..af297ba9be 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.cpp +++ b/Core/Dialog/PSPGamedataInstallDialog.cpp @@ -16,7 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Common/ChunkFile.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/System.h" #include "Core/FileSystems/MetaFileSystem.h" #include "Core/Dialog/PSPGamedataInstallDialog.h" diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index c2322b9e84..54cb4865f6 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -15,12 +15,12 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "PSPMsgDialog.h" -#include "../Util/PPGeDraw.h" -#include "../HLE/sceCtrl.h" -#include "../Core/MemMap.h" +#include "Core/Dialog/PSPMsgDialog.h" +#include "Core/Util/PPGeDraw.h" +#include "Core/HLE/sceCtrl.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" -#include "ChunkFile.h" +#include "Common/ChunkFile.h" #include "i18n/i18n.h" #include "util/text/utf8.h" diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index 7bf4b42011..ded27c8cfd 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -18,7 +18,7 @@ #include "PSPNetconfDialog.h" #include "ChunkFile.h" #include "Core/Config.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/HLE/sceNetAdhoc.h" #include "Core/Util/PPGeDraw.h" #include "Core/HLE/sceCtrl.h" diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 9feb1b1412..8410b96003 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -24,7 +24,7 @@ #include "Core/FileSystems/MetaFileSystem.h" #include "Core/Util/PPGeDraw.h" #include "Core/HLE/sceCtrl.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Config.h" #include "Core/Reporting.h" #include "Core/HW/MemoryStick.h" diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 0f6588d10a..d305311ee1 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -24,7 +24,7 @@ #include "Core/Config.h" #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/Core.h" diff --git a/Core/HLE/HLEHelperThread.cpp b/Core/HLE/HLEHelperThread.cpp index 193a1514c7..97b947ceab 100644 --- a/Core/HLE/HLEHelperThread.cpp +++ b/Core/HLE/HLEHelperThread.cpp @@ -16,7 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Common/ChunkFile.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/HLE/HLE.h" #include "Core/HLE/HLEHelperThread.h" #include "Core/HLE/sceKernelThread.h" diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 6fb5b42d6c..ca0df3d418 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -30,7 +30,7 @@ #include "Core/Config.h" #include "Core/CoreTiming.h" #include "Core/Host.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/HLE/__sceAudio.h" #include "Core/HLE/sceAudio.h" diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 534db9e8bb..18c65c8ca3 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -21,7 +21,7 @@ #include "Core/HLE/FunctionWrappers.h" #include "Core/MIPS/MIPS.h" #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/Config.h" #include "Core/Debugger/Breakpoints.h" @@ -803,7 +803,6 @@ u32 _AtracAddStreamData(int atracID, u32 bufPtr, u32 bytesToAdd) { return 0; int addbytes = std::min(bytesToAdd, atrac->first.filesize - atrac->first.fileoffset); Memory::Memcpy(atrac->data_buf + atrac->first.fileoffset, bufPtr, addbytes); - CBreakPoints::ExecMemCheck(bufPtr, false, addbytes, currentMIPS->pc); atrac->first.size += bytesToAdd; if (atrac->first.size > atrac->first.filesize) atrac->first.size = atrac->first.filesize; @@ -839,7 +838,6 @@ static u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) { if (bytesToAdd > 0) { int addbytes = std::min(bytesToAdd, atrac->first.filesize - atrac->first.fileoffset); Memory::Memcpy(atrac->data_buf + atrac->first.fileoffset, atrac->first.addr + atrac->first.offset, addbytes); - CBreakPoints::ExecMemCheck(atrac->first.addr + atrac->first.offset, false, addbytes, currentMIPS->pc); } atrac->first.size += bytesToAdd; if (atrac->first.size > atrac->first.filesize) @@ -1533,7 +1531,6 @@ static int _AtracSetData(Atrac *atrac, u32 buffer, u32 bufferSize) { atrac->data_buf = new u8[atrac->first.filesize]; u32 copybytes = std::min(bufferSize, atrac->first.filesize); Memory::Memcpy(atrac->data_buf, buffer, copybytes); - CBreakPoints::ExecMemCheck(buffer, false, copybytes, currentMIPS->pc); return __AtracSetContext(atrac); #endif // USE_FFMPEG @@ -1546,7 +1543,6 @@ static int _AtracSetData(Atrac *atrac, u32 buffer, u32 bufferSize) { atrac->data_buf = new u8[atrac->first.filesize]; u32 copybytes = std::min(bufferSize, atrac->first.filesize); Memory::Memcpy(atrac->data_buf, buffer, copybytes); - CBreakPoints::ExecMemCheck(buffer, false, copybytes, currentMIPS->pc); return __AtracSetContext(atrac); } @@ -2184,7 +2180,6 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo u32 sourcebytes = atrac->first.writableBytes; if (sourcebytes > 0) { Memory::Memcpy(atrac->data_buf + atrac->first.size, sourceAddr, sourcebytes); - CBreakPoints::ExecMemCheck(sourceAddr, false, sourcebytes, currentMIPS->pc); if (atrac->bufferPos >= atrac->first.size) { atrac->bufferPos = atrac->first.size; } diff --git a/Core/HLE/sceDmac.cpp b/Core/HLE/sceDmac.cpp index d3170a8ba4..e2615e156f 100644 --- a/Core/HLE/sceDmac.cpp +++ b/Core/HLE/sceDmac.cpp @@ -17,7 +17,7 @@ #include "Common/ChunkFile.h" #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/HLE/HLE.h" #include "Core/HLE/sceDmac.h" @@ -44,11 +44,6 @@ void __DmacDoState(PointerWrap &p) { } static int __DmacMemcpy(u32 dst, u32 src, u32 size) { -#ifndef MOBILE_DEVICE - CBreakPoints::ExecMemCheck(src, false, size, currentMIPS->pc); - CBreakPoints::ExecMemCheck(dst, true, size, currentMIPS->pc); -#endif - bool skip = false; if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) { skip = gpu->PerformMemoryCopy(dst, src, size); diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 5d533aba19..943ef656e4 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -19,6 +19,7 @@ #include #include +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 80aca8aa5a..a2525c6933 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -27,7 +27,7 @@ #include "Core/HLE/FunctionWrappers.h" #include "Core/System.h" #include "Core/MIPS/MIPS.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/CoreTiming.h" #include "Core/Reporting.h" diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index c0cee8de62..f0663212b5 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -41,7 +41,7 @@ #include "Core/CoreTiming.h" #include "Core/PSPLoaders.h" #include "Core/System.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Debugger/SymbolMap.h" #include "Core/MIPS/MIPS.h" diff --git a/Core/HLE/sceKernelMsgPipe.cpp b/Core/HLE/sceKernelMsgPipe.cpp index b71c53ce4c..a521c680a1 100644 --- a/Core/HLE/sceKernelMsgPipe.cpp +++ b/Core/HLE/sceKernelMsgPipe.cpp @@ -19,7 +19,7 @@ #include "Core/Reporting.h" #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/HLE/HLE.h" #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelMsgPipe.h" @@ -101,17 +101,17 @@ struct MsgPipeWaitingThread Complete(waitID, result); } - void ReadBuffer(u8 *dest, u32 len) + void ReadBuffer(u32 destPtr, u32 len) { - Memory::Memcpy(dest, bufAddr + bufSize - freeSize, len); + Memory::Memcpy(destPtr, bufAddr + bufSize - freeSize, len); freeSize -= len; if (transferredBytes.IsValid()) *transferredBytes += len; } - void WriteBuffer(const u8 *src, u32 len) + void WriteBuffer(u32 srcPtr, u32 len) { - Memory::Memcpy(bufAddr + (bufSize - freeSize), src, len); + Memory::Memcpy(bufAddr + (bufSize - freeSize), srcPtr, len); freeSize -= len; if (transferredBytes.IsValid()) *transferredBytes += len; @@ -180,7 +180,7 @@ struct MsgPipe : public KernelObject MsgPipeWaitingThread *thread = &sendWaitingThreads.front(); u32 bytesToSend = std::min(thread->freeSize, (u32) nmp.freeSize); - thread->ReadBuffer(Memory::GetPointer(buffer + GetUsedSize()), bytesToSend); + thread->ReadBuffer(buffer + GetUsedSize(), bytesToSend); nmp.freeSize -= bytesToSend; filledSpace = true; @@ -216,7 +216,7 @@ struct MsgPipe : public KernelObject u32 bytesToSend = std::min(thread->freeSize, GetUsedSize()); u8* ptr = Memory::GetPointer(buffer); - thread->WriteBuffer(ptr, bytesToSend); + thread->WriteBuffer(buffer, bytesToSend); // Put the unused data at the start of the buffer. nmp.freeSize += bytesToSend; memmove(ptr, ptr + bytesToSend, GetUsedSize()); @@ -343,7 +343,7 @@ static int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int wa u32 bytesToSend = std::min(thread->freeSize, sendSize); if (bytesToSend > 0) { - thread->WriteBuffer(Memory::GetPointer(curSendAddr), bytesToSend); + thread->WriteBuffer(curSendAddr, bytesToSend); sendSize -= bytesToSend; curSendAddr += bytesToSend; @@ -396,7 +396,7 @@ static int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int wa if (bytesToSend != 0) { - Memory::Memcpy(m->buffer + (m->nmp.bufSize - m->nmp.freeSize), Memory::GetPointer(sendBufAddr), bytesToSend); + Memory::Memcpy(m->buffer + (m->nmp.bufSize - m->nmp.freeSize), sendBufAddr, bytesToSend); m->nmp.freeSize -= bytesToSend; curSendAddr += bytesToSend; sendSize -= bytesToSend; @@ -443,7 +443,7 @@ static int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSiz u32 bytesToReceive = std::min(thread->freeSize, receiveSize); if (bytesToReceive > 0) { - thread->ReadBuffer(Memory::GetPointer(curReceiveAddr), bytesToReceive); + thread->ReadBuffer(curReceiveAddr, bytesToReceive); receiveSize -= bytesToReceive; curReceiveAddr += bytesToReceive; @@ -489,7 +489,7 @@ static int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSiz u32 bytesToReceive = std::min(receiveSize, m->GetUsedSize()); if (bytesToReceive != 0) { - Memory::Memcpy(curReceiveAddr, Memory::GetPointer(m->buffer), bytesToReceive); + Memory::Memcpy(curReceiveAddr, m->buffer, bytesToReceive); m->nmp.freeSize += bytesToReceive; memmove(Memory::GetPointer(m->buffer), Memory::GetPointer(m->buffer) + bytesToReceive, m->GetUsedSize()); curReceiveAddr += bytesToReceive; diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 89b12dd879..8247267d1e 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -28,7 +28,7 @@ #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPS.h" #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Common/ChunkFile.h" @@ -2198,7 +2198,7 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo // Now copy argument to stack. if (!forceArgs && Memory::IsValidAddress(argBlockPtr)) - Memory::Memcpy(sp, Memory::GetPointer(argBlockPtr), argSize); + Memory::Memcpy(sp, argBlockPtr, argSize); // On the PSP, there's an extra 64 bytes of stack eaten after the args. // This could be stack overflow safety, or just stack eaten by the kernel entry func. diff --git a/Core/HLE/sceKernelVTimer.cpp b/Core/HLE/sceKernelVTimer.cpp index 3e8e2a6fbe..276f5db13d 100644 --- a/Core/HLE/sceKernelVTimer.cpp +++ b/Core/HLE/sceKernelVTimer.cpp @@ -17,7 +17,7 @@ #include #include "Core/CoreTiming.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelInterrupt.h" diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index c22fa87243..211c0c79b2 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -27,6 +27,7 @@ #include "Core/HLE/FunctionWrappers.h" #include "Core/HW/MediaEngine.h" #include "Core/Config.h" +#include "Core/MemMapHelpers.h" #include "Core/Reporting.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index b2cdd35fe9..b535281f1a 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -21,7 +21,7 @@ // This is a direct port of Coldbird's code from http://code.google.com/p/aemu/ // All credit goes to him! #include "Core/Core.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Common/ChunkFile.h" #include "Core/MIPS/MIPSCodeUtils.h" diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 38e2e4c47c..8f3583ada9 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -15,14 +15,14 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "Common/ChunkFile.h" +#include "Core/MemMapHelpers.h" +#include "Core/Reporting.h" +#include "Core/System.h" +#include "Core/FileSystems/MetaFileSystem.h" #include "Core/HLE/HLE.h" #include "Core/HLE/HLEHelperThread.h" #include "Core/HLE/FunctionWrappers.h" -#include "Common/ChunkFile.h" -#include "Core/Reporting.h" - -#include "Core/System.h" -#include "Core/FileSystems/MetaFileSystem.h" #include "Core/HLE/scePsmf.h" #include "Core/HLE/sceMpeg.h" #include "Core/HW/MediaEngine.h" diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 3f0bd9f4a1..9cce143ced 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -17,7 +17,7 @@ #include "base/basictypes.h" #include "Globals.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/HLE/sceAtrac.h" #include "Core/Config.h" #include "Core/Reporting.h" diff --git a/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 260c32db63..b4a81c30be 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -5,7 +5,7 @@ #include #include #include "util/text/utf8.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/MIPS/JitCommon/NativeJit.h" #include "Core/Debugger/SymbolMap.h" diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 16b7ee583c..6c1455f5f2 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -501,10 +501,4 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) #endif } -const char *GetAddressName(u32 address) -{ - // TODO, follow GetPointer - return "[mem]"; -} - } // namespace diff --git a/Core/MemMap.h b/Core/MemMap.h index 2064bdaa90..a78c11df46 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -257,31 +257,21 @@ inline const char* GetCharPointer(const u32 address) { return (const char *)GetPointer(address); } -void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); - -inline void Memcpy(const u32 to_address, const void *from_data, const u32 len) -{ - u8 *to = GetPointer(to_address); - if (to) { - memcpy(to, from_data, len); - } - // if not, GetPointer will log. -} - -inline void Memcpy(void *to_data, const u32 from_address, const u32 len) -{ - const u8 *from = GetPointer(from_address); - if (from) { - memcpy(to_data, from, len); - } - // if not, GetPointer will log. -} - inline void MemcpyUnchecked(void *to_data, const u32 from_address, const u32 len) { memcpy(to_data, GetPointerUnchecked(from_address), len); } +inline void MemcpyUnchecked(const u32 to_address, const void *from_data, const u32 len) +{ + memcpy(GetPointerUnchecked(to_address), from_data, len); +} + +inline void MemcpyUnchecked(const u32 to_address, const u32 from_address, const u32 len) +{ + MemcpyUnchecked(GetPointer(to_address), from_address, len); +} + inline bool IsValidAddress(const u32 address) { if ((address & 0x3E000000) == 0x08000000) { return true; @@ -314,8 +304,6 @@ void WriteStruct(u32 address, T *ptr) memcpy(GetPointer(address), ptr, sz); } -const char *GetAddressName(u32 address); - }; template diff --git a/Core/MemMapHelpers.h b/Core/MemMapHelpers.h new file mode 100644 index 0000000000..7d440ca5ab --- /dev/null +++ b/Core/MemMapHelpers.h @@ -0,0 +1,65 @@ +// Copyright (C) 2003 Dolphin Project / 2012 PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#pragma once + +#include "Common/CommonTypes.h" +#include "Core/Debugger/Breakpoints.h" +#include "Core/MemMap.h" +#include "Core/MIPS/MIPS.h" + +// To avoid pulling in the entire HLE.h. +extern MIPSState *currentMIPS; + +namespace Memory +{ + +inline void Memcpy(const u32 to_address, const void *from_data, const u32 len) +{ + u8 *to = GetPointer(to_address); + if (to) { + memcpy(to, from_data, len); +#ifndef MOBILE_DEVICE + CBreakPoints::ExecMemCheck(to_address, true, len, currentMIPS->pc); +#endif + } + // if not, GetPointer will log. +} + +inline void Memcpy(void *to_data, const u32 from_address, const u32 len) +{ + const u8 *from = GetPointer(from_address); + if (from) { + memcpy(to_data, from, len); +#ifndef MOBILE_DEVICE + CBreakPoints::ExecMemCheck(from_address, false, len, currentMIPS->pc); +#endif + } + // if not, GetPointer will log. +} + +inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len) +{ +#ifndef MOBILE_DEVICE + CBreakPoints::ExecMemCheck(to_address, true, len, currentMIPS->pc); +#endif + Memcpy(GetPointer(to_address), from_address, len); +} + +void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); + +} diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 2e1e491e24..4ca876761a 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -31,7 +31,7 @@ #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/HLE/sceGe.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/System.h" static u32 atlasPtr; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index f4acb85add..0b523aa0cb 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -20,7 +20,7 @@ #include "Common/ChunkFile.h" #include "base/logging.h" #include "Core/Debugger/Breakpoints.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/MIPS/MIPS.h" #include "Core/Host.h" #include "Core/Config.h" @@ -1912,7 +1912,7 @@ void DIRECTX9_GPU::PerformMemoryCopyInternal(u32 dest, u32 src, int size) { // We use a little hack for Download/Upload using a VRAM mirror. // Since they're identical we don't need to copy. if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) { - Memory::Memcpy(dest, Memory::GetPointer(src), size); + Memory::Memcpy(dest, src, size); } } InvalidateCache(dest, size, GPU_INVALIDATE_HINT); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index c67aace6f9..7bfe3025c0 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -1535,7 +1535,7 @@ void *TextureCacheDX9::DecodeTextureLevel(GETextureFormat format, GEPaletteForma int len = std::max(bufw, w) * h; tmpTexBuf16.resize(len); tmpTexBufRearrange.resize(len); - Memory::Memcpy(tmpTexBuf16.data(), texaddr, len * sizeof(u16)); + Memory::MemcpyUnchecked(tmpTexBuf16.data(), texaddr, len * sizeof(u16)); finalBuf = tmpTexBuf16.data(); } else { @@ -1554,7 +1554,7 @@ void *TextureCacheDX9::DecodeTextureLevel(GETextureFormat format, GEPaletteForma int len = bufw * h; tmpTexBuf32.resize(std::max(bufw, w) * h); tmpTexBufRearrange.resize(std::max(bufw, w) * h); - Memory::Memcpy(tmpTexBuf32.data(), texaddr, len * sizeof(u32)); + Memory::MemcpyUnchecked(tmpTexBuf32.data(), texaddr, len * sizeof(u32)); finalBuf = tmpTexBuf32.data(); } } else { diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index c8c02f528d..0eab00a5fc 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1597,7 +1597,7 @@ void FramebufferManager::PackFramebufferAsync_(VirtualFramebuffer *vfb) { ConvertFromRGBA8888(dst, packed, pbo.stride, pbo.stride, pbo.stride, pbo.height, pbo.format); } else { // We don't need to convert, GPU already did (or should have) - Memory::Memcpy(pbo.fb_address, packed, pbo.size); + Memory::MemcpyUnchecked(pbo.fb_address, packed, pbo.size); } pbo.reading = false; diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 6b93fe6537..e5a39ddba0 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -21,7 +21,7 @@ #include "Common/ChunkFile.h" #include "Core/Debugger/Breakpoints.h" -#include "Core/MemMap.h" +#include "Core/MemMapHelpers.h" #include "Core/Host.h" #include "Core/Config.h" #include "Core/Reporting.h" @@ -2053,7 +2053,7 @@ void GLES_GPU::PerformMemoryCopyInternal(u32 dest, u32 src, int size) { // We use a little hack for Download/Upload using a VRAM mirror. // Since they're identical we don't need to copy. if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) { - Memory::Memcpy(dest, Memory::GetPointer(src), size); + Memory::Memcpy(dest, src, size); } } InvalidateCache(dest, size, GPU_INVALIDATE_HINT);