forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #3879 from lioncash/global2

hle_ipc: Eliminate core memory globals
This commit is contained in:
bunnei 2020-05-07 19:13:34 -04:00 committed by GitHub
commit 1121960f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,6 @@
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/hle_ipc.h"
@ -57,7 +56,6 @@ std::shared_ptr<WritableEvent> HLERequestContext::SleepClientThread(
return true; return true;
}); });
auto& kernel = Core::System::GetInstance().Kernel();
if (!writable_event) { if (!writable_event) {
// Create event if not provided // Create event if not provided
const auto pair = WritableEvent::CreateEventPair(kernel, "HLE Pause Event: " + reason); const auto pair = WritableEvent::CreateEventPair(kernel, "HLE Pause Event: " + reason);
@ -79,9 +77,11 @@ std::shared_ptr<WritableEvent> HLERequestContext::SleepClientThread(
return writable_event; return writable_event;
} }
HLERequestContext::HLERequestContext(std::shared_ptr<Kernel::ServerSession> server_session, HLERequestContext::HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory,
std::shared_ptr<ServerSession> server_session,
std::shared_ptr<Thread> thread) std::shared_ptr<Thread> thread)
: server_session(std::move(server_session)), thread(std::move(thread)) { : server_session(std::move(server_session)),
thread(std::move(thread)), kernel{kernel}, memory{memory} {
cmd_buf[0] = 0; cmd_buf[0] = 0;
} }
@ -216,7 +216,6 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const HandleTabl
ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(Thread& thread) { ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(Thread& thread) {
auto& owner_process = *thread.GetOwnerProcess(); auto& owner_process = *thread.GetOwnerProcess();
auto& handle_table = owner_process.GetHandleTable(); auto& handle_table = owner_process.GetHandleTable();
auto& memory = Core::System::GetInstance().Memory();
std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf; std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf;
memory.ReadBlock(owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(), memory.ReadBlock(owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(),
@ -286,7 +285,6 @@ std::vector<u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const {
std::vector<u8> buffer; std::vector<u8> buffer;
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
BufferDescriptorA()[buffer_index].Size()}; BufferDescriptorA()[buffer_index].Size()};
auto& memory = Core::System::GetInstance().Memory();
if (is_buffer_a) { if (is_buffer_a) {
ASSERT_MSG(BufferDescriptorA().size() > buffer_index, ASSERT_MSG(BufferDescriptorA().size() > buffer_index,
@ -319,7 +317,6 @@ std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size,
size = buffer_size; // TODO(bunnei): This needs to be HW tested size = buffer_size; // TODO(bunnei): This needs to be HW tested
} }
auto& memory = Core::System::GetInstance().Memory();
if (is_buffer_b) { if (is_buffer_b) {
ASSERT_MSG(BufferDescriptorB().size() > buffer_index, ASSERT_MSG(BufferDescriptorB().size() > buffer_index,
"BufferDescriptorB invalid buffer_index {}", buffer_index); "BufferDescriptorB invalid buffer_index {}", buffer_index);

View File

@ -19,6 +19,10 @@
union ResultCode; union ResultCode;
namespace Core::Memory {
class Memory;
}
namespace Service { namespace Service {
class ServiceFrameworkBase; class ServiceFrameworkBase;
} }
@ -28,6 +32,7 @@ namespace Kernel {
class Domain; class Domain;
class HandleTable; class HandleTable;
class HLERequestContext; class HLERequestContext;
class KernelCore;
class Process; class Process;
class ServerSession; class ServerSession;
class Thread; class Thread;
@ -98,7 +103,8 @@ protected:
*/ */
class HLERequestContext { class HLERequestContext {
public: public:
explicit HLERequestContext(std::shared_ptr<ServerSession> session, explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory,
std::shared_ptr<ServerSession> session,
std::shared_ptr<Thread> thread); std::shared_ptr<Thread> thread);
~HLERequestContext(); ~HLERequestContext();
@ -305,6 +311,9 @@ private:
std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers; std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers;
bool is_thread_waiting{}; bool is_thread_waiting{};
KernelCore& kernel;
Core::Memory::Memory& memory;
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -137,8 +137,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con
ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread, ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread,
Core::Memory::Memory& memory) { Core::Memory::Memory& memory) {
u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))};
std::shared_ptr<Kernel::HLERequestContext> context{ auto context =
std::make_shared<Kernel::HLERequestContext>(SharedFrom(this), std::move(thread))}; std::make_shared<HLERequestContext>(kernel, memory, SharedFrom(this), std::move(thread));
context->PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf); context->PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf);
request_queue.Push(std::move(context)); request_queue.Push(std::move(context));