yuzu-emu
/
yuzu
Archived
1
0
Fork 0

kernel: Remove all dependencies on the global system instance

With this, the kernel finally doesn't depend directly on the global
system instance anymore.
This commit is contained in:
Lioncash 2020-09-14 14:03:10 -04:00
parent 042567e4b2
commit ec2a6e5ba8
5 changed files with 20 additions and 11 deletions

View File

@ -48,14 +48,15 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern
} }
ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread, ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread,
Core::Memory::Memory& memory) { Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing) {
// Keep ServerSession alive until we're done working with it. // Keep ServerSession alive until we're done working with it.
if (!parent->Server()) { if (!parent->Server()) {
return ERR_SESSION_CLOSED_BY_REMOTE; return ERR_SESSION_CLOSED_BY_REMOTE;
} }
// Signal the server session that new data is available // Signal the server session that new data is available
return parent->Server()->HandleSyncRequest(std::move(thread), memory); return parent->Server()->HandleSyncRequest(std::move(thread), memory, core_timing);
} }
} // namespace Kernel } // namespace Kernel

View File

@ -16,6 +16,10 @@ namespace Core::Memory {
class Memory; class Memory;
} }
namespace Core::Timing {
class CoreTiming;
}
namespace Kernel { namespace Kernel {
class KernelCore; class KernelCore;
@ -42,7 +46,8 @@ public:
return HANDLE_TYPE; return HANDLE_TYPE;
} }
ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing);
bool ShouldWait(const Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;

View File

@ -8,7 +8,6 @@
#include "common/assert.h" #include "common/assert.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/core_timing.h" #include "core/core_timing.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_port.h"
@ -185,10 +184,11 @@ ResultCode ServerSession::CompleteSyncRequest() {
} }
ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread,
Core::Memory::Memory& memory) { Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing) {
const ResultCode result = QueueSyncRequest(std::move(thread), memory); const ResultCode result = QueueSyncRequest(std::move(thread), memory);
const auto delay = std::chrono::nanoseconds{kernel.IsMulticore() ? 0 : 20000}; const auto delay = std::chrono::nanoseconds{kernel.IsMulticore() ? 0 : 20000};
Core::System::GetInstance().CoreTiming().ScheduleEvent(delay, request_event, {}); core_timing.ScheduleEvent(delay, request_event, {});
return result; return result;
} }

View File

@ -18,8 +18,9 @@ class Memory;
} }
namespace Core::Timing { namespace Core::Timing {
class CoreTiming;
struct EventType; struct EventType;
} } // namespace Core::Timing
namespace Kernel { namespace Kernel {
@ -87,12 +88,14 @@ public:
/** /**
* Handle a sync request from the emulated application. * Handle a sync request from the emulated application.
* *
* @param thread Thread that initiated the request. * @param thread Thread that initiated the request.
* @param memory Memory context to handle the sync request under. * @param memory Memory context to handle the sync request under.
* @param core_timing Core timing context to schedule the request event under.
* *
* @returns ResultCode from the operation. * @returns ResultCode from the operation.
*/ */
ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing);
bool ShouldWait(const Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;

View File

@ -346,7 +346,7 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
SchedulerLock lock(system.Kernel()); SchedulerLock lock(system.Kernel());
thread->InvalidateHLECallback(); thread->InvalidateHLECallback();
thread->SetStatus(ThreadStatus::WaitIPC); thread->SetStatus(ThreadStatus::WaitIPC);
session->SendSyncRequest(SharedFrom(thread), system.Memory()); session->SendSyncRequest(SharedFrom(thread), system.Memory(), system.CoreTiming());
} }
if (thread->HasHLECallback()) { if (thread->HasHLECallback()) {