Kernel/IPC: use MemorySystem from parameter

This commit is contained in:
Weiyi Wang 2019-02-01 12:32:49 -05:00
parent 20f47583f6
commit 5f6d9f1915
3 changed files with 19 additions and 12 deletions

View File

@ -16,11 +16,11 @@
namespace Kernel { namespace Kernel {
ResultCode TranslateCommandBuffer(SharedPtr<Thread> src_thread, SharedPtr<Thread> dst_thread, ResultCode TranslateCommandBuffer(Memory::MemorySystem& memory, SharedPtr<Thread> src_thread,
VAddr src_address, VAddr dst_address, SharedPtr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, std::vector<MappedBufferContext>& mapped_buffer_context,
bool reply) { bool reply) {
Memory::MemorySystem& memory = Core::System::GetInstance().Memory();
auto& src_process = src_thread->owner_process; auto& src_process = src_thread->owner_process;
auto& dst_process = dst_thread->owner_process; auto& dst_process = dst_thread->owner_process;

View File

@ -10,6 +10,10 @@
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
namespace Memory {
class MemorySystem;
}
namespace Kernel { namespace Kernel {
struct MappedBufferContext { struct MappedBufferContext {
@ -23,8 +27,9 @@ struct MappedBufferContext {
}; };
/// Performs IPC command buffer translation from one process to another. /// Performs IPC command buffer translation from one process to another.
ResultCode TranslateCommandBuffer(SharedPtr<Thread> src_thread, SharedPtr<Thread> dst_thread, ResultCode TranslateCommandBuffer(Memory::MemorySystem& memory, SharedPtr<Thread> src_thread,
VAddr src_address, VAddr dst_address, SharedPtr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, std::vector<MappedBufferContext>& mapped_buffer_context,
bool reply); bool reply);
} // namespace Kernel } // namespace Kernel

View File

@ -592,7 +592,8 @@ ResultCode SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle
} }
} }
static ResultCode ReceiveIPCRequest(SharedPtr<ServerSession> server_session, static ResultCode ReceiveIPCRequest(Memory::MemorySystem& memory,
SharedPtr<ServerSession> server_session,
SharedPtr<Thread> thread) { SharedPtr<Thread> thread) {
if (server_session->parent->client == nullptr) { if (server_session->parent->client == nullptr) {
return ERR_SESSION_CLOSED_BY_REMOTE; return ERR_SESSION_CLOSED_BY_REMOTE;
@ -602,7 +603,7 @@ static ResultCode ReceiveIPCRequest(SharedPtr<ServerSession> server_session,
VAddr source_address = server_session->currently_handling->GetCommandBufferAddress(); VAddr source_address = server_session->currently_handling->GetCommandBufferAddress();
ResultCode translation_result = ResultCode translation_result =
TranslateCommandBuffer(server_session->currently_handling, thread, source_address, TranslateCommandBuffer(memory, server_session->currently_handling, thread, source_address,
target_address, server_session->mapped_buffer_context, false); target_address, server_session->mapped_buffer_context, false);
// If a translation error occurred, immediately resume the client thread. // If a translation error occurred, immediately resume the client thread.
@ -669,7 +670,7 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co
VAddr target_address = request_thread->GetCommandBufferAddress(); VAddr target_address = request_thread->GetCommandBufferAddress();
ResultCode translation_result = ResultCode translation_result =
TranslateCommandBuffer(thread, request_thread, source_address, target_address, TranslateCommandBuffer(memory, thread, request_thread, source_address, target_address,
session->mapped_buffer_context, true); session->mapped_buffer_context, true);
// Note: The real kernel seems to always panic if the Server->Client buffer translation // Note: The real kernel seems to always panic if the Server->Client buffer translation
@ -705,7 +706,7 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co
return RESULT_SUCCESS; return RESULT_SUCCESS;
auto server_session = static_cast<ServerSession*>(object); auto server_session = static_cast<ServerSession*>(object);
return ReceiveIPCRequest(server_session, thread); return ReceiveIPCRequest(memory, server_session, thread);
} }
// No objects were ready to be acquired, prepare to suspend the thread. // No objects were ready to be acquired, prepare to suspend the thread.
@ -721,7 +722,8 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co
thread->wait_objects = std::move(objects); thread->wait_objects = std::move(objects);
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread, thread->wakeup_callback = [& memory = this->memory](ThreadWakeupReason reason,
SharedPtr<Thread> thread,
SharedPtr<WaitObject> object) { SharedPtr<WaitObject> object) {
ASSERT(thread->status == ThreadStatus::WaitSynchAny); ASSERT(thread->status == ThreadStatus::WaitSynchAny);
ASSERT(reason == ThreadWakeupReason::Signal); ASSERT(reason == ThreadWakeupReason::Signal);
@ -730,7 +732,7 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co
if (object->GetHandleType() == HandleType::ServerSession) { if (object->GetHandleType() == HandleType::ServerSession) {
auto server_session = DynamicObjectCast<ServerSession>(object); auto server_session = DynamicObjectCast<ServerSession>(object);
result = ReceiveIPCRequest(server_session, thread); result = ReceiveIPCRequest(memory, server_session, thread);
} }
thread->SetWaitSynchronizationResult(result); thread->SetWaitSynchronizationResult(result);