diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 4427c6bd6c..d31007beff 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -630,7 +630,7 @@ inline void CallSyscallWithFlags(const HLEFunction *info) if (flags & HLE_CLEAR_STACK_BYTES) { u32 stackStart = __KernelGetCurThreadStackStart(); if (currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear >= stackStart) { - Memory::Memset(currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear, 0, info->stackBytesToClear); + Memory::Memset(currentMIPS->r[MIPS_REG_SP] - info->stackBytesToClear, 0, info->stackBytesToClear, "HLEStackClear"); } } diff --git a/Core/HLE/HLEHelperThread.cpp b/Core/HLE/HLEHelperThread.cpp index a142820b92..1a35395c39 100644 --- a/Core/HLE/HLEHelperThread.cpp +++ b/Core/HLE/HLEHelperThread.cpp @@ -59,8 +59,8 @@ HLEHelperThread::~HLEHelperThread() { } void HLEHelperThread::AllocEntry(u32 size) { - entry_ = kernelMemory.Alloc(size); - Memory::Memset(entry_, 0, size); + entry_ = kernelMemory.Alloc(size, false, "HLEHelper"); + Memory::Memset(entry_, 0, size, "HLEHelperClear"); currentMIPS->InvalidateICache(entry_, size); } diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 19861fc045..1b3758507c 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -2310,7 +2310,7 @@ static u32 _sceAtracGetContextAddress(int atracID) { u32 contextsize = 256; atrac->context_ = kernelMemory.Alloc(contextsize, false, "Atrac Context"); if (atrac->context_.IsValid()) - Memory::Memset(atrac->context_.ptr, 0, 256); + Memory::Memset(atrac->context_.ptr, 0, 256, "AtracContextClear"); WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", atrac->context_.ptr, atracID); } diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 7358dd3ffc..fa8a80b61f 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -430,8 +430,8 @@ void __KernelMemoryInit() MemBlockInfoInit(); kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), false); userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), false); - Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase()); - Memory::Memset(PSP_GetUserMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase()); + Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInit"); + Memory::Memset(PSP_GetUserMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), "MemInit"); INFO_LOG(SCEKERNEL, "Kernel and user memory pools initialized"); vplWaitTimer = CoreTiming::RegisterEvent("VplTimeout", __KernelVplTimeout); @@ -1968,8 +1968,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID) NotifyMemInfo(MemBlockFlags::SUB_ALLOC, freedAddress, tls->ntls.blockSize, "TlsFree"); // Whenever freeing a block, clear it (even if it's not going to wake anyone.) - Memory::Memset(freedAddress, 0, tls->ntls.blockSize); - NotifyMemInfo(MemBlockFlags::WRITE, freedAddress, tls->ntls.blockSize, "TlsFree"); + Memory::Memset(freedAddress, 0, tls->ntls.blockSize, "TlsFree"); // First, let's remove the end check for the freeing thread. auto freeingLocked = tlsplThreadEndChecks.equal_range(threadID); @@ -2245,8 +2244,7 @@ int sceKernelGetTlsAddr(SceUID uid) // We clear the blocks upon first allocation (and also when they are freed, both are necessary.) if (needsClear) { - Memory::Memset(allocAddress, 0, tls->ntls.blockSize); - NotifyMemInfo(MemBlockFlags::WRITE, allocAddress, tls->ntls.blockSize, "TlsAddr"); + Memory::Memset(allocAddress, 0, tls->ntls.blockSize, "TlsAddr"); } return allocAddress; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 5faa9ea6ef..e3906ea6c8 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -856,8 +856,7 @@ void PSPModule::Cleanup() { for (u32 i = 0; i < (u32)(nm.text_size + 3); i += 4) { Memory::Write_U32(MIPS_MAKE_BREAK(1), nm.text_addr + i); } - Memory::Memset(nm.text_addr + nm.text_size, -1, nm.data_size + nm.bss_size); - NotifyMemInfo(MemBlockFlags::WRITE, nm.text_addr + nm.text_size, nm.data_size + nm.bss_size, "ModuleClear"); + Memory::Memset(nm.text_addr + nm.text_size, -1, nm.data_size + nm.bss_size, "ModuleClear"); // Let's also invalidate, just to make sure it's cleared out for any future data. currentMIPS->InvalidateICache(memoryBlockAddr, memoryBlockSize); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index f704a67f0b..eca32da94b 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -432,8 +432,7 @@ public: bool FillStack() { // Fill the stack. if ((nt.attr & PSP_THREAD_ATTR_NO_FILLSTACK) == 0) { - Memory::Memset(currentStack.start, 0xFF, nt.stackSize); - NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadFillStack"); + Memory::Memset(currentStack.start, 0xFF, nt.stackSize, "ThreadFillStack"); } context.r[MIPS_REG_SP] = currentStack.start + nt.stackSize; currentStack.end = context.r[MIPS_REG_SP]; @@ -441,7 +440,7 @@ public: context.r[MIPS_REG_SP] -= 256; context.r[MIPS_REG_K0] = context.r[MIPS_REG_SP]; u32 k0 = context.r[MIPS_REG_K0]; - Memory::Memset(k0, 0, 0x100); + Memory::Memset(k0, 0, 0x100, "ThreadK0"); Memory::Write_U32(GetUID(), k0 + 0xc0); Memory::Write_U32(nt.initialStack, k0 + 0xc8); Memory::Write_U32(0xffffffff, k0 + 0xf8); @@ -457,8 +456,7 @@ public: DEBUG_LOG(SCEKERNEL, "Freeing thread stack %s", nt.name); if ((nt.attr & PSP_THREAD_ATTR_CLEAR_STACK) != 0 && nt.initialStack != 0) { - Memory::Memset(nt.initialStack, 0, nt.stackSize); - NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadFreeStack"); + Memory::Memset(nt.initialStack, 0, nt.stackSize, "ThreadFreeStack"); } if (nt.attr & PSP_THREAD_ATTR_KERNEL) { @@ -483,9 +481,8 @@ public: nt.stackSize = currentStack.end - currentStack.start; // We still drop the threadID at the bottom and fill it, but there's no k0. - Memory::Memset(currentStack.start, 0xFF, nt.stackSize); + Memory::Memset(currentStack.start, 0xFF, nt.stackSize, "ThreadExtendStack"); Memory::Write_U32(GetUID(), nt.initialStack); - NotifyMemInfo(MemBlockFlags::WRITE, currentStack.start, nt.stackSize, "ThreadExtendStack"); return true; } @@ -1294,7 +1291,7 @@ u32 sceKernelReferThreadStatus(u32 threadID, u32 statusPtr) Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt))); // TODO: What is this value? Basic tests show 0... if (wantedSize > sizeof(t->nt)) - Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt)); + Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt), "ThreadStatus"); } else { t->nt.nativeSize = THREADINFO_SIZE; u32 sz = std::min(THREADINFO_SIZE, wantedSize); diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index b98f57d7b4..87ab458172 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1960,7 +1960,7 @@ static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init) // We kept track of the stream number here in sceMpegGetAtracAu(). ctx->mediaengine->setAudioStream(atracAu.esBuffer); - Memory::Memset(bufferAddr, 0, MPEG_ATRAC_ES_OUTPUT_SIZE); + Memory::Memset(bufferAddr, 0, MPEG_ATRAC_ES_OUTPUT_SIZE, "MpegAtracClear"); ctx->mediaengine->getAudioSamples(bufferAddr); atracAu.pts = ctx->mediaengine->getAudioTimeStamp() + ctx->mpegFirstTimestamp; diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index c21aa4be1d..b49a3bc48a 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -965,7 +965,7 @@ static u32 scePsmfVerifyPsmf(u32 psmfAddr) } // Kurohyou 2 (at least the demo) uses an uninitialized value that happens to be zero on the PSP. // It appears to be written by scePsmfVerifyPsmf(), so we write some bytes into the stack here. - Memory::Memset(currentMIPS->r[MIPS_REG_SP] - 0x20, 0, 0x20); + Memory::Memset(currentMIPS->r[MIPS_REG_SP] - 0x20, 0, 0x20, "PsmfStack"); DEBUG_LOG(ME, "scePsmfVerifyPsmf(%08x)", psmfAddr); return 0; } @@ -1656,7 +1656,7 @@ static int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr) if (psmfplayer->mediaengine->getAudioSamples(audioDataAddr) == 0) { if (psmfplayer->totalAudioStreams > 0 && (s64)psmfplayer->psmfPlayerAvcAu.pts < (s64)psmfplayer->totalDurationTimestamp - VIDEO_FRAME_DURATION_TS) { // Write zeros for any missing trailing frames so it syncs with the video. - Memory::Memset(audioDataAddr, 0, audioSamplesBytes); + Memory::Memset(audioDataAddr, 0, audioSamplesBytes, "PsmfAudioClear"); } else { ret = (int)ERROR_PSMFPLAYER_NO_MORE_DATA; } diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index a751a94bfc..6d86bebd03 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -459,7 +459,7 @@ void Write_Opcode_JIT(const u32 _Address, const Opcode& _Value) Memory::WriteUnchecked_U32(_Value.encoding, _Address); } -void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) { +void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength, const std::string &tag) { if (IsValidRange(_Address, _iLength)) { uint8_t *ptr = GetPointerUnchecked(_Address); memset(ptr, _iValue, _iLength); @@ -468,7 +468,7 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) { Write_U8(_iValue, (u32)(_Address + i)); } - NotifyMemInfo(MemBlockFlags::WRITE, _Address, _iLength, "Memset"); + NotifyMemInfo(MemBlockFlags::WRITE, _Address, _iLength, tag); } } // namespace diff --git a/Core/MemMapHelpers.h b/Core/MemMapHelpers.h index f5bda4a6f9..451c723707 100644 --- a/Core/MemMapHelpers.h +++ b/Core/MemMapHelpers.h @@ -55,7 +55,7 @@ inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len) NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, "Memcpy"); } -void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); +void Memset(const u32 _Address, const u8 _Data, const u32 _iLength, const std::string &tag = "Memset"); template void ReadStruct(u32 address, T *ptr) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index dc497a146e..391f3aaf9c 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -1261,7 +1261,7 @@ bool PPGeImage::Load() { } Memory::Memcpy(texture_, textureData, dataSize); - Memory::Memset(texture_ + dataSize, 0, texSize - dataSize); + Memory::Memset(texture_ + dataSize, 0, texSize - dataSize, "PPGeTexClear"); free(textureData); lastFrame_ = gpuStats.numFlips; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 07139f0c04..e3b21070a9 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2728,8 +2728,6 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) { } bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { - NotifyMemInfo(MemBlockFlags::READ, src, size, "GPUMemcpy"); - NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemcpy"); // Track stray copies of a framebuffer in RAM. MotoGP does this. if (framebufferManager_->MayIntersectFramebuffer(src) || framebufferManager_->MayIntersectFramebuffer(dest)) { @@ -2746,23 +2744,24 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { return true; } + NotifyMemInfo(MemBlockFlags::READ, src, size, "GPUMemcpy"); + NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemcpy"); InvalidateCache(dest, size, GPU_INVALIDATE_HINT); GPURecord::NotifyMemcpy(dest, src, size); return false; } bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { - NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemset"); - // This may indicate a memset, usually to 0, of a framebuffer. if (framebufferManager_->MayIntersectFramebuffer(dest)) { - Memory::Memset(dest, v, size); + Memory::Memset(dest, v, size, "GPUMemset"); if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, true, gstate_c.skipDrawReason)) { InvalidateCache(dest, size, GPU_INVALIDATE_HINT); } return true; } + NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemset"); // Or perhaps a texture, let's invalidate. InvalidateCache(dest, size, GPU_INVALIDATE_HINT); GPURecord::NotifyMemset(dest, v, size);