From 7444963bbb300cff269e410948de7fa577f5ff16 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 13 Apr 2021 17:48:37 -0700 Subject: hle: kernel: Migrate KSession, KClientSession, and KServerSession to KAutoObject. --- src/core/hle/kernel/k_session.h | 108 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/core/hle/kernel/k_session.h (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h new file mode 100644 index 000000000..1d24e80cd --- /dev/null +++ b/src/core/hle/kernel/k_session.h @@ -0,0 +1,108 @@ +// Copyright 2021 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +#include "core/hle/kernel/k_client_session.h" +#include "core/hle/kernel/k_server_session.h" +#include "core/hle/kernel/slab_helpers.h" + +namespace Kernel { + +class KSession final : public KAutoObjectWithSlabHeapAndContainer { + KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject); + +private: + enum class State : u8 { + Invalid = 0, + Normal = 1, + ClientClosed = 2, + ServerClosed = 3, + }; + +public: + explicit KSession(KernelCore& kernel); + virtual ~KSession() override; + + void Initialize(std::string&& name_); + + virtual void Finalize() override; + + virtual bool IsInitialized() const override { + return initialized; + } + + virtual uintptr_t GetPostDestroyArgument() const override { + return reinterpret_cast(process); + } + + static void PostDestroy(uintptr_t arg); + + void OnServerClosed(); + + void OnClientClosed(); + + bool IsServerClosed() const { + return this->GetState() != State::Normal; + } + + bool IsClientClosed() const { + return this->GetState() != State::Normal; + } + + KClientSession& GetClientSession() { + return client; + } + + KServerSession& GetServerSession() { + return server; + } + + const KClientSession& GetClientSession() const { + return client; + } + + const KServerSession& GetServerSession() const { + return server; + } + + const ClientPort* GetParent() const { + return port; + } + + // DEPRECATED + + std::string GetName() const override { + return name; + } + + static constexpr HandleType HANDLE_TYPE = HandleType::Session; + HandleType GetHandleType() const override { + return HANDLE_TYPE; + } + +private: + void SetState(State state) { + atomic_state = static_cast(state); + } + + State GetState() const { + return static_cast(atomic_state.load()); + } + +private: + KServerSession server; + KClientSession client; + std::atomic::type> atomic_state{ + static_cast::type>(State::Invalid)}; + ClientPort* port{}; + std::string name; + Process* process{}; + bool initialized{}; +}; + +} // namespace Kernel -- cgit v1.2.3 From 0297448fbc6bf909b0bc061723c38208b9667b66 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 21 Apr 2021 21:43:25 -0700 Subject: hle: kernel: Migrate KClientPort to KAutoObject. --- src/core/hle/kernel/k_session.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index 1d24e80cd..6a6fcb588 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -70,7 +70,7 @@ public: return server; } - const ClientPort* GetParent() const { + const KClientPort* GetParent() const { return port; } @@ -99,7 +99,7 @@ private: KClientSession client; std::atomic::type> atomic_state{ static_cast::type>(State::Invalid)}; - ClientPort* port{}; + KClientPort* port{}; std::string name; Process* process{}; bool initialized{}; -- cgit v1.2.3 From 626f746971d1d3216a38b20680959df3a1f5f256 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 23 Apr 2021 17:00:15 -0700 Subject: hle: kernel: Migrate KPort, KClientPort, and KServerPort to KAutoObject. --- src/core/hle/kernel/k_session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index 6a6fcb588..1597cc608 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -28,7 +28,7 @@ public: explicit KSession(KernelCore& kernel); virtual ~KSession() override; - void Initialize(std::string&& name_); + void Initialize(KClientPort* port_, std::string&& name_); virtual void Finalize() override; -- cgit v1.2.3 From bf380b858481ef99d7150d322af2c30ac339bcde Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 23 Apr 2021 21:50:04 -0700 Subject: hle: kernel: Remove deprecated Object class. --- src/core/hle/kernel/k_session.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index 1597cc608..f29195fa0 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -28,7 +28,7 @@ public: explicit KSession(KernelCore& kernel); virtual ~KSession() override; - void Initialize(KClientPort* port_, std::string&& name_); + void Initialize(KClientPort* port_, const std::string& name_); virtual void Finalize() override; @@ -74,17 +74,6 @@ public: return port; } - // DEPRECATED - - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::Session; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: void SetState(State state) { atomic_state = static_cast(state); @@ -100,7 +89,6 @@ private: std::atomic::type> atomic_state{ static_cast::type>(State::Invalid)}; KClientPort* port{}; - std::string name; Process* process{}; bool initialized{}; }; -- cgit v1.2.3 From 2a7eff57a8048933a89c1a8f8d6dced7b5d604f2 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 23 Apr 2021 22:04:28 -0700 Subject: hle: kernel: Rename Process to KProcess. --- src/core/hle/kernel/k_session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index f29195fa0..d50e21f3f 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -89,7 +89,7 @@ private: std::atomic::type> atomic_state{ static_cast::type>(State::Invalid)}; KClientPort* port{}; - Process* process{}; + KProcess* process{}; bool initialized{}; }; -- cgit v1.2.3 From f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 1 May 2021 12:48:41 -0700 Subject: fixup! hle: kernel: Migrate KSession, KClientSession, and KServerSession to KAutoObject. --- src/core/hle/kernel/k_session.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/core/hle/kernel/k_session.h') diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index d50e21f3f..4321b7885 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -16,14 +16,6 @@ namespace Kernel { class KSession final : public KAutoObjectWithSlabHeapAndContainer { KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject); -private: - enum class State : u8 { - Invalid = 0, - Normal = 1, - ClientClosed = 2, - ServerClosed = 3, - }; - public: explicit KSession(KernelCore& kernel); virtual ~KSession() override; @@ -74,20 +66,28 @@ public: return port; } +private: + enum class State : u8 { + Invalid = 0, + Normal = 1, + ClientClosed = 2, + ServerClosed = 3, + }; + private: void SetState(State state) { atomic_state = static_cast(state); } State GetState() const { - return static_cast(atomic_state.load()); + return static_cast(atomic_state.load(std::memory_order_relaxed)); } private: KServerSession server; KClientSession client; - std::atomic::type> atomic_state{ - static_cast::type>(State::Invalid)}; + std::atomic> atomic_state{ + static_cast>(State::Invalid)}; KClientPort* port{}; KProcess* process{}; bool initialized{}; -- cgit v1.2.3