diff options
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/client_session.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_session.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/global_scheduler_context.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/global_scheduler_context.h | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.h | 14 |
9 files changed, 26 insertions, 54 deletions
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index e230f365a..13c55abe4 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp | |||
| @@ -38,8 +38,7 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern | |||
| 38 | return MakeResult(std::move(client_session)); | 38 | return MakeResult(std::move(client_session)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | ResultCode ClientSession::SendSyncRequest(std::shared_ptr<KThread> thread, | 41 | ResultCode ClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, |
| 42 | Core::Memory::Memory& memory, | ||
| 43 | Core::Timing::CoreTiming& core_timing) { | 42 | Core::Timing::CoreTiming& core_timing) { |
| 44 | // Keep ServerSession alive until we're done working with it. | 43 | // Keep ServerSession alive until we're done working with it. |
| 45 | if (!parent->Server()) { | 44 | if (!parent->Server()) { |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 85aafeaf4..7a1d15d0c 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | return HANDLE_TYPE; | 46 | return HANDLE_TYPE; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | ResultCode SendSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory, | 49 | ResultCode SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, |
| 50 | Core::Timing::CoreTiming& core_timing); | 50 | Core::Timing::CoreTiming& core_timing); |
| 51 | 51 | ||
| 52 | bool IsSignaled() const override; | 52 | bool IsSignaled() const override; |
diff --git a/src/core/hle/kernel/global_scheduler_context.cpp b/src/core/hle/kernel/global_scheduler_context.cpp index c6838649f..7c87cbada 100644 --- a/src/core/hle/kernel/global_scheduler_context.cpp +++ b/src/core/hle/kernel/global_scheduler_context.cpp | |||
| @@ -17,12 +17,12 @@ GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel) | |||
| 17 | 17 | ||
| 18 | GlobalSchedulerContext::~GlobalSchedulerContext() = default; | 18 | GlobalSchedulerContext::~GlobalSchedulerContext() = default; |
| 19 | 19 | ||
| 20 | void GlobalSchedulerContext::AddThread(std::shared_ptr<KThread> thread) { | 20 | void GlobalSchedulerContext::AddThread(KThread* thread) { |
| 21 | std::scoped_lock lock{global_list_guard}; | 21 | std::scoped_lock lock{global_list_guard}; |
| 22 | thread_list.push_back(std::move(thread)); | 22 | thread_list.push_back(thread); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void GlobalSchedulerContext::RemoveThread(std::shared_ptr<KThread> thread) { | 25 | void GlobalSchedulerContext::RemoveThread(KThread* thread) { |
| 26 | std::scoped_lock lock{global_list_guard}; | 26 | std::scoped_lock lock{global_list_guard}; |
| 27 | thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), | 27 | thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), |
| 28 | thread_list.end()); | 28 | thread_list.end()); |
diff --git a/src/core/hle/kernel/global_scheduler_context.h b/src/core/hle/kernel/global_scheduler_context.h index 11592843e..ba8b67fd1 100644 --- a/src/core/hle/kernel/global_scheduler_context.h +++ b/src/core/hle/kernel/global_scheduler_context.h | |||
| @@ -38,13 +38,13 @@ public: | |||
| 38 | ~GlobalSchedulerContext(); | 38 | ~GlobalSchedulerContext(); |
| 39 | 39 | ||
| 40 | /// Adds a new thread to the scheduler | 40 | /// Adds a new thread to the scheduler |
| 41 | void AddThread(std::shared_ptr<KThread> thread); | 41 | void AddThread(KThread* thread); |
| 42 | 42 | ||
| 43 | /// Removes a thread from the scheduler | 43 | /// Removes a thread from the scheduler |
| 44 | void RemoveThread(std::shared_ptr<KThread> thread); | 44 | void RemoveThread(KThread* thread); |
| 45 | 45 | ||
| 46 | /// Returns a list of all threads managed by the scheduler | 46 | /// Returns a list of all threads managed by the scheduler |
| 47 | [[nodiscard]] const std::vector<std::shared_ptr<KThread>>& GetThreadList() const { | 47 | [[nodiscard]] const std::vector<KThread*>& GetThreadList() const { |
| 48 | return thread_list; | 48 | return thread_list; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| @@ -79,7 +79,7 @@ private: | |||
| 79 | LockType scheduler_lock; | 79 | LockType scheduler_lock; |
| 80 | 80 | ||
| 81 | /// Lists all thread ids that aren't deleted/etc. | 81 | /// Lists all thread ids that aren't deleted/etc. |
| 82 | std::vector<std::shared_ptr<KThread>> thread_list; | 82 | std::vector<KThread*> thread_list; |
| 83 | Common::SpinLock global_list_guard{}; | 83 | Common::SpinLock global_list_guard{}; |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 2b363b1d9..6ffe6ac41 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -46,11 +46,11 @@ void SessionRequestHandler::ClientDisconnected( | |||
| 46 | boost::range::remove_erase(connected_sessions, server_session); | 46 | boost::range::remove_erase(connected_sessions, server_session); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | HLERequestContext::HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, | 49 | HLERequestContext::HLERequestContext(KernelCore& kernel_, Core::Memory::Memory& memory_, |
| 50 | std::shared_ptr<ServerSession> server_session, | 50 | std::shared_ptr<ServerSession> server_session_, |
| 51 | std::shared_ptr<KThread> thread) | 51 | KThread* thread_) |
| 52 | : server_session(std::move(server_session)), | 52 | : server_session(std::move(server_session_)), |
| 53 | thread(std::move(thread)), kernel{kernel}, memory{memory} { | 53 | thread(thread_), kernel{kernel_}, memory{memory_} { |
| 54 | cmd_buf[0] = 0; | 54 | cmd_buf[0] = 0; |
| 55 | } | 55 | } |
| 56 | 56 | ||
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 6fba42615..75617bff0 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -109,8 +109,7 @@ protected: | |||
| 109 | class HLERequestContext { | 109 | class HLERequestContext { |
| 110 | public: | 110 | public: |
| 111 | explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, | 111 | explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, |
| 112 | std::shared_ptr<ServerSession> session, | 112 | std::shared_ptr<ServerSession> session, KThread* thread); |
| 113 | std::shared_ptr<KThread> thread); | ||
| 114 | ~HLERequestContext(); | 113 | ~HLERequestContext(); |
| 115 | 114 | ||
| 116 | /// Returns a pointer to the IPC command buffer for this request. | 115 | /// Returns a pointer to the IPC command buffer for this request. |
| @@ -276,10 +275,6 @@ public: | |||
| 276 | return *thread; | 275 | return *thread; |
| 277 | } | 276 | } |
| 278 | 277 | ||
| 279 | const KThread& GetThread() const { | ||
| 280 | return *thread; | ||
| 281 | } | ||
| 282 | |||
| 283 | bool IsThreadWaiting() const { | 278 | bool IsThreadWaiting() const { |
| 284 | return is_thread_waiting; | 279 | return is_thread_waiting; |
| 285 | } | 280 | } |
| @@ -291,7 +286,8 @@ private: | |||
| 291 | 286 | ||
| 292 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; | 287 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; |
| 293 | std::shared_ptr<Kernel::ServerSession> server_session; | 288 | std::shared_ptr<Kernel::ServerSession> server_session; |
| 294 | std::shared_ptr<KThread> thread; | 289 | KThread* thread; |
| 290 | |||
| 295 | // TODO(yuriks): Check common usage of this and optimize size accordingly | 291 | // TODO(yuriks): Check common usage of this and optimize size accordingly |
| 296 | boost::container::small_vector<Handle, 8> move_handles; | 292 | boost::container::small_vector<Handle, 8> move_handles; |
| 297 | boost::container::small_vector<Handle, 8> copy_handles; | 293 | boost::container::small_vector<Handle, 8> copy_handles; |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 5c4f45ab4..17fe1d59f 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -60,8 +60,6 @@ struct KernelCore::Impl { | |||
| 60 | void Initialize(KernelCore& kernel) { | 60 | void Initialize(KernelCore& kernel) { |
| 61 | global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel); | 61 | global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel); |
| 62 | 62 | ||
| 63 | RegisterHostThread(); | ||
| 64 | |||
| 65 | service_thread_manager = | 63 | service_thread_manager = |
| 66 | std::make_unique<Common::ThreadWorker>(1, "yuzu:ServiceThreadManager"); | 64 | std::make_unique<Common::ThreadWorker>(1, "yuzu:ServiceThreadManager"); |
| 67 | is_phantom_mode_for_singlecore = false; | 65 | is_phantom_mode_for_singlecore = false; |
| @@ -77,6 +75,8 @@ struct KernelCore::Impl { | |||
| 77 | InitializeSchedulers(); | 75 | InitializeSchedulers(); |
| 78 | InitializeSuspendThreads(); | 76 | InitializeSuspendThreads(); |
| 79 | InitializePreemption(kernel); | 77 | InitializePreemption(kernel); |
| 78 | |||
| 79 | RegisterHostThread(); | ||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | void InitializeCores() { | 82 | void InitializeCores() { |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 790dbb998..bb247959c 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -44,12 +44,7 @@ ResultVal<std::shared_ptr<ServerSession>> ServerSession::Create(KernelCore& kern | |||
| 44 | 44 | ||
| 45 | bool ServerSession::IsSignaled() const { | 45 | bool ServerSession::IsSignaled() const { |
| 46 | // Closed sessions should never wait, an error will be returned from svcReplyAndReceive. | 46 | // Closed sessions should never wait, an error will be returned from svcReplyAndReceive. |
| 47 | if (!parent->Client()) { | 47 | return !parent->Client(); |
| 48 | return true; | ||
| 49 | } | ||
| 50 | |||
| 51 | // Wait if we have no pending requests, or if we're currently handling a request. | ||
| 52 | return !pending_requesting_threads.empty() && currently_handling == nullptr; | ||
| 53 | } | 48 | } |
| 54 | 49 | ||
| 55 | void ServerSession::ClientDisconnected() { | 50 | void ServerSession::ClientDisconnected() { |
| @@ -62,11 +57,6 @@ void ServerSession::ClientDisconnected() { | |||
| 62 | // invalidated (set to null). | 57 | // invalidated (set to null). |
| 63 | handler->ClientDisconnected(SharedFrom(this)); | 58 | handler->ClientDisconnected(SharedFrom(this)); |
| 64 | } | 59 | } |
| 65 | |||
| 66 | // Clean up the list of client threads with pending requests, they are unneeded now that the | ||
| 67 | // client endpoint is closed. | ||
| 68 | pending_requesting_threads.clear(); | ||
| 69 | currently_handling = nullptr; | ||
| 70 | } | 60 | } |
| 71 | 61 | ||
| 72 | void ServerSession::AppendDomainRequestHandler(std::shared_ptr<SessionRequestHandler> handler) { | 62 | void ServerSession::AppendDomainRequestHandler(std::shared_ptr<SessionRequestHandler> handler) { |
| @@ -116,11 +106,9 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 116 | return RESULT_SUCCESS; | 106 | return RESULT_SUCCESS; |
| 117 | } | 107 | } |
| 118 | 108 | ||
| 119 | ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<KThread> thread, | 109 | ResultCode ServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) { |
| 120 | Core::Memory::Memory& memory) { | ||
| 121 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; | 110 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; |
| 122 | auto context = | 111 | auto context = std::make_shared<HLERequestContext>(kernel, memory, SharedFrom(this), thread); |
| 123 | std::make_shared<HLERequestContext>(kernel, memory, SharedFrom(this), std::move(thread)); | ||
| 124 | 112 | ||
| 125 | context->PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf); | 113 | context->PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf); |
| 126 | 114 | ||
| @@ -161,10 +149,9 @@ ResultCode ServerSession::CompleteSyncRequest(HLERequestContext& context) { | |||
| 161 | return result; | 149 | return result; |
| 162 | } | 150 | } |
| 163 | 151 | ||
| 164 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<KThread> thread, | 152 | ResultCode ServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, |
| 165 | Core::Memory::Memory& memory, | ||
| 166 | Core::Timing::CoreTiming& core_timing) { | 153 | Core::Timing::CoreTiming& core_timing) { |
| 167 | return QueueSyncRequest(std::move(thread), memory); | 154 | return QueueSyncRequest(thread, memory); |
| 168 | } | 155 | } |
| 169 | 156 | ||
| 170 | } // namespace Kernel | 157 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index c42d5ee59..77ed18c60 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -95,7 +95,7 @@ public: | |||
| 95 | * | 95 | * |
| 96 | * @returns ResultCode from the operation. | 96 | * @returns ResultCode from the operation. |
| 97 | */ | 97 | */ |
| 98 | ResultCode HandleSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory, | 98 | ResultCode HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, |
| 99 | Core::Timing::CoreTiming& core_timing); | 99 | Core::Timing::CoreTiming& core_timing); |
| 100 | 100 | ||
| 101 | /// Called when a client disconnection occurs. | 101 | /// Called when a client disconnection occurs. |
| @@ -130,7 +130,7 @@ public: | |||
| 130 | 130 | ||
| 131 | private: | 131 | private: |
| 132 | /// Queues a sync request from the emulated application. | 132 | /// Queues a sync request from the emulated application. |
| 133 | ResultCode QueueSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory); | 133 | ResultCode QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory); |
| 134 | 134 | ||
| 135 | /// Completes a sync request from the emulated application. | 135 | /// Completes a sync request from the emulated application. |
| 136 | ResultCode CompleteSyncRequest(HLERequestContext& context); | 136 | ResultCode CompleteSyncRequest(HLERequestContext& context); |
| @@ -148,16 +148,6 @@ private: | |||
| 148 | /// This is the list of domain request handlers (after conversion to a domain) | 148 | /// This is the list of domain request handlers (after conversion to a domain) |
| 149 | std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers; | 149 | std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers; |
| 150 | 150 | ||
| 151 | /// List of threads that are pending a response after a sync request. This list is processed in | ||
| 152 | /// a LIFO manner, thus, the last request will be dispatched first. | ||
| 153 | /// TODO(Subv): Verify if this is indeed processed in LIFO using a hardware test. | ||
| 154 | std::vector<std::shared_ptr<KThread>> pending_requesting_threads; | ||
| 155 | |||
| 156 | /// Thread whose request is currently being handled. A request is considered "handled" when a | ||
| 157 | /// response is sent via svcReplyAndReceive. | ||
| 158 | /// TODO(Subv): Find a better name for this. | ||
| 159 | std::shared_ptr<KThread> currently_handling; | ||
| 160 | |||
| 161 | /// When set to True, converts the session to a domain at the end of the command | 151 | /// When set to True, converts the session to a domain at the end of the command |
| 162 | bool convert_to_domain{}; | 152 | bool convert_to_domain{}; |
| 163 | 153 | ||