Memory: remove WriteBlock with current process

This commit is contained in:
Weiyi Wang 2018-11-17 15:06:56 -05:00
parent 8871f5a4ac
commit 4e99641a3b
5 changed files with 10 additions and 11 deletions

View File

@ -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 {}", LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:08x} bytes at {:08x} of type {}",
bp->second.len, bp->second.addr, static_cast<int>(type)); bp->second.len, bp->second.addr, static_cast<int>(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(); Core::CPU().ClearInstructionCache();
p.erase(addr); p.erase(addr);
} }
@ -862,7 +863,8 @@ static void WriteMemory() {
std::vector<u8> data(len); std::vector<u8> data(len);
GdbHexToMem(data.data(), len_pos + 1, 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(); Core::CPU().ClearInstructionCache();
SendReply("OK"); SendReply("OK");
} }
@ -918,7 +920,8 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u32 len) {
Memory::ReadBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, Memory::ReadBlock(*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr,
breakpoint.inst.data(), breakpoint.inst.size()); breakpoint.inst.data(), breakpoint.inst.size());
static constexpr std::array<u8, 4> btrap{0x70, 0x00, 0x20, 0xe1}; static constexpr std::array<u8, 4> 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(); Core::CPU().ClearInstructionCache();
p.insert({addr, breakpoint}); p.insert({addr, breakpoint});

View File

@ -437,7 +437,8 @@ private:
*/ */
template <typename T> template <typename T>
void SetEntry(std::size_t index, const T& data) { void SetEntry(std::size_t index, const T& data) {
Memory::WriteBlock(GetField(T::TABLE_OFFSET_FIELD) + static_cast<u32>(index * sizeof(T)), Memory::WriteBlock(process,
GetField(T::TABLE_OFFSET_FIELD) + static_cast<u32>(index * sizeof(T)),
&data, sizeof(T)); &data, sizeof(T));
} }

View File

@ -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) { void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) {
auto& page_table = process.vm_manager.page_table; auto& page_table = process.vm_manager.page_table;
std::size_t remaining_size = size; std::size_t remaining_size = size;

View File

@ -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 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, void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,
std::size_t size); 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(const Kernel::Process& process, VAddr dest_addr, const std::size_t size);
void ZeroBlock(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); void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, std::size_t size);

View File

@ -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::HEAP_VADDR && address <= Memory::HEAP_VADDR_END) ||
(address >= Memory::N3DS_EXTRA_RAM_VADDR && address <= Memory::N3DS_EXTRA_RAM_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 // 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 // If the memory happens to be executable code, make sure the changes become visible
Core::CPU().InvalidateCacheRange(address, data_size); Core::CPU().InvalidateCacheRange(address, data_size);
} }