From 4e99641a3b58e92bfe38e7c76b6c88e628ac382a Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 17 Nov 2018 15:06:56 -0500 Subject: [PATCH] Memory: remove WriteBlock with current process --- src/core/gdbstub/gdbstub.cpp | 9 ++++++--- src/core/hle/service/ldr_ro/cro_helper.h | 3 ++- src/core/memory.cpp | 5 ----- src/core/memory.h | 1 - src/core/rpc/rpc_server.cpp | 3 ++- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 9e13f9a464..55936ed971 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -409,7 +409,8 @@ static void RemoveBreakpoint(BreakpointType type, VAddr addr) { LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:08x} bytes at {:08x} of type {}", bp->second.len, bp->second.addr, static_cast(type)); - Memory::WriteBlock(bp->second.addr, bp->second.inst.data(), bp->second.inst.size()); + Memory::WriteBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), bp->second.addr, + bp->second.inst.data(), bp->second.inst.size()); Core::CPU().ClearInstructionCache(); p.erase(addr); } @@ -862,7 +863,8 @@ static void WriteMemory() { std::vector data(len); GdbHexToMem(data.data(), len_pos + 1, len); - Memory::WriteBlock(addr, data.data(), len); + Memory::WriteBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, data.data(), + len); Core::CPU().ClearInstructionCache(); SendReply("OK"); } @@ -918,7 +920,8 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u32 len) { Memory::ReadBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, breakpoint.inst.data(), breakpoint.inst.size()); static constexpr std::array btrap{0x70, 0x00, 0x20, 0xe1}; - Memory::WriteBlock(addr, btrap.data(), btrap.size()); + Memory::WriteBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, + btrap.data(), btrap.size()); Core::CPU().ClearInstructionCache(); p.insert({addr, breakpoint}); diff --git a/src/core/hle/service/ldr_ro/cro_helper.h b/src/core/hle/service/ldr_ro/cro_helper.h index fe0cb97978..f61483bd76 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.h +++ b/src/core/hle/service/ldr_ro/cro_helper.h @@ -437,7 +437,8 @@ private: */ template void SetEntry(std::size_t index, const T& data) { - Memory::WriteBlock(GetField(T::TABLE_OFFSET_FIELD) + static_cast(index * sizeof(T)), + Memory::WriteBlock(process, + GetField(T::TABLE_OFFSET_FIELD) + static_cast(index * sizeof(T)), &data, sizeof(T)); } diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 25e0142532..ef3b64c556 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -547,11 +547,6 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi } } -void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { - WriteBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), dest_addr, src_buffer, - size); -} - void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { auto& page_table = process.vm_manager.page_table; std::size_t remaining_size = size; diff --git a/src/core/memory.h b/src/core/memory.h index 1e6b6e615c..60b1027656 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -199,7 +199,6 @@ void Write64(VAddr addr, u64 data); void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, std::size_t size); void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, std::size_t size); -void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, const std::size_t size); void ZeroBlock(VAddr dest_addr, const std::size_t size); void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, std::size_t size); diff --git a/src/core/rpc/rpc_server.cpp b/src/core/rpc/rpc_server.cpp index b9246e922d..b3ea1ed42e 100644 --- a/src/core/rpc/rpc_server.cpp +++ b/src/core/rpc/rpc_server.cpp @@ -41,7 +41,8 @@ void RPCServer::HandleWriteMemory(Packet& packet, u32 address, const u8* data, u (address >= Memory::HEAP_VADDR && address <= Memory::HEAP_VADDR_END) || (address >= Memory::N3DS_EXTRA_RAM_VADDR && address <= Memory::N3DS_EXTRA_RAM_VADDR_END)) { // Note: Memory write occurs asynchronously from the state of the emulator - Memory::WriteBlock(address, data, data_size); + Memory::WriteBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), address, data, + data_size); // If the memory happens to be executable code, make sure the changes become visible Core::CPU().InvalidateCacheRange(address, data_size); }