core: memory: Refactor block functions and general cleanup

* Also drop usage of std::vector in CopyBlock in favour of a plain std::array. Now all block functions use the common WalkBlockImpl the implementation of which is very similar to yuzu
This commit is contained in:
emufan4568
2022-09-08 22:47:37 +03:00
committed by GPUCode
parent f26d00fbb4
commit 38a5cc634f
6 changed files with 459 additions and 264 deletions

View File

@ -849,14 +849,14 @@ static void ReadMemory() {
SendReply("E01");
}
if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(),
auto& memory = Core::System::GetInstance().Memory();
if (!memory.IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(),
addr)) {
return SendReply("E00");
}
std::vector<u8> data(len);
Core::System::GetInstance().Memory().ReadBlock(
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, data.data(), len);
memory.ReadBlock(addr, data.data(), len);
MemToGdbHex(reply, data.data(), len);
reply[len * 2] = '\0';
@ -873,7 +873,8 @@ static void WriteMemory() {
auto len_pos = std::find(start_offset, command_buffer + command_length, ':');
u32 len = HexToInt(start_offset, static_cast<u32>(len_pos - start_offset));
if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(),
auto& memory = Core::System::GetInstance().Memory();
if (!memory.IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(),
addr)) {
return SendReply("E00");
}
@ -881,8 +882,7 @@ static void WriteMemory() {
std::vector<u8> data(len);
GdbHexToMem(data.data(), len_pos + 1, len);
Core::System::GetInstance().Memory().WriteBlock(
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, data.data(), len);
memory.WriteBlock(addr, data.data(), len);
Core::GetRunningCore().ClearInstructionCache();
SendReply("OK");
}