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/CMakeLists.txt | 2 - src/core/core.h | 1 - src/core/hle/ipc_helpers.h | 17 ----- src/core/hle/kernel/handle_table.h | 1 - src/core/hle/kernel/hle_ipc.cpp | 1 - src/core/hle/kernel/hle_ipc.h | 10 --- src/core/hle/kernel/k_auto_object.h | 14 ++-- src/core/hle/kernel/k_client_port.h | 15 ---- src/core/hle/kernel/k_client_session.h | 19 ----- src/core/hle/kernel/k_event.h | 11 --- src/core/hle/kernel/k_port.h | 18 ----- src/core/hle/kernel/k_readable_event.h | 12 ---- src/core/hle/kernel/k_resource_limit.h | 15 ---- src/core/hle/kernel/k_server_port.cpp | 1 - src/core/hle/kernel/k_server_port.h | 15 ---- src/core/hle/kernel/k_server_session.h | 18 ----- src/core/hle/kernel/k_session.cpp | 4 +- src/core/hle/kernel/k_session.h | 14 +--- src/core/hle/kernel/k_shared_memory.h | 13 ---- src/core/hle/kernel/k_synchronization_object.h | 9 --- src/core/hle/kernel/k_thread.cpp | 1 - src/core/hle/kernel/k_thread.h | 15 ---- src/core/hle/kernel/k_transfer_memory.h | 15 ---- src/core/hle/kernel/k_writable_event.h | 12 ---- src/core/hle/kernel/kernel.h | 2 - src/core/hle/kernel/object.cpp | 42 ----------- src/core/hle/kernel/object.h | 98 -------------------------- src/core/hle/kernel/process.h | 15 ---- src/core/hle/kernel/time_manager.h | 2 - src/core/hle/service/am/applets/applets.h | 1 - src/core/hle/service/hid/controllers/npad.h | 1 - src/core/hle/service/hid/irs.h | 1 - src/core/hle/service/nvflinger/buffer_queue.h | 1 - src/core/hle/service/nvflinger/nvflinger.h | 1 - src/core/hle/service/service.h | 1 - src/core/hle/service/sm/controller.cpp | 2 +- src/core/hle/service/sm/sm.cpp | 2 +- src/yuzu/debugger/wait_tree.cpp | 28 ++++---- src/yuzu/debugger/wait_tree.h | 7 +- 39 files changed, 34 insertions(+), 423 deletions(-) delete mode 100644 src/core/hle/kernel/object.cpp delete mode 100644 src/core/hle/kernel/object.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cee6d30f6..4e1387c7e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -232,8 +232,6 @@ add_library(core STATIC hle/kernel/kernel.cpp hle/kernel/kernel.h hle/kernel/memory_types.h - hle/kernel/object.cpp - hle/kernel/object.h hle/kernel/physical_core.cpp hle/kernel/physical_core.h hle/kernel/physical_memory.h diff --git a/src/core/core.h b/src/core/core.h index f1068d23f..16e191266 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -12,7 +12,6 @@ #include "common/common_types.h" #include "core/file_sys/vfs_types.h" -#include "core/hle/kernel/object.h" namespace Core::Frontend { class EmuWindow; diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 8128445fd..0906b8cfb 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -16,7 +16,6 @@ #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_session.h" -#include "core/hle/kernel/object.h" #include "core/hle/result.h" namespace IPC { @@ -381,12 +380,6 @@ public: template T PopRaw(); - template - T* GetMoveObject(std::size_t index); - - template - T* GetCopyObject(std::size_t index); - template std::shared_ptr PopIpcInterface() { ASSERT(context->Session()->IsDomain()); @@ -491,14 +484,4 @@ void RequestParser::Pop(First& first_value, Other&... other_values) { Pop(other_values...); } -template -T* RequestParser::GetMoveObject(std::size_t index) { - return context->GetMoveObject(index); -} - -template -T* RequestParser::GetCopyObject(std::size_t index) { - return context->GetCopyObject(index); -} - } // namespace IPC diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 2e0b2d8b8..791e303d1 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -12,7 +12,6 @@ #include "core/hle/kernel/k_auto_object.h" #include "core/hle/kernel/k_spin_lock.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/object.h" #include "core/hle/result.h" namespace Kernel { diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index ddff9ce99..a11528f28 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -23,7 +23,6 @@ #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/time_manager.h" diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index d63c730ac..7f7ab74dd 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -212,16 +212,6 @@ public: return move_handles.at(index); } - template - T* GetCopyObject(std::size_t index) { - return DynamicObjectCast(copy_objects.at(index)); - } - - template - T* GetMoveObject(std::size_t index) { - return DynamicObjectCast(move_objects.at(index)); - } - void AddMoveObject(KAutoObject* object) { move_objects.emplace_back(object); } diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index 64c012d44..fd6405a0e 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -11,13 +11,14 @@ #include "common/common_types.h" #include "common/intrusive_red_black_tree.h" #include "core/hle/kernel/k_class_token.h" -#include "core/hle/kernel/object.h" namespace Kernel { class KernelCore; class Process; +using Handle = u32; + #define KERNEL_AUTOOBJECT_TRAITS(CLASS, BASE_CLASS) \ NON_COPYABLE(CLASS); \ NON_MOVEABLE(CLASS); \ @@ -48,7 +49,7 @@ public: \ private: -class KAutoObject : public Object { +class KAutoObject { protected: class TypeObj { private: @@ -84,16 +85,17 @@ private: KERNEL_AUTOOBJECT_TRAITS(KAutoObject, KAutoObject); private: - std::atomic m_ref_count; + std::atomic m_ref_count{}; protected: KernelCore& kernel; + std::string name; public: static KAutoObject* Create(KAutoObject* ptr); public: - explicit KAutoObject(KernelCore& kernel_) : Object{kernel_}, m_ref_count(0), kernel(kernel_) {} + explicit KAutoObject(KernelCore& kernel_) : kernel(kernel_) {} virtual ~KAutoObject() {} // Destroy is responsible for destroying the auto object's resources when ref_count hits zero. @@ -205,6 +207,10 @@ public: virtual u64 GetId() const { return reinterpret_cast(this); } + + virtual const std::string& GetName() const { + return name; + } }; template diff --git a/src/core/hle/kernel/k_client_port.h b/src/core/hle/kernel/k_client_port.h index 43a17f4a4..f971a8b2c 100644 --- a/src/core/hle/kernel/k_client_port.h +++ b/src/core/hle/kernel/k_client_port.h @@ -51,26 +51,11 @@ public: ResultCode CreateSession(KClientSession** out); - // DEPRECATED - - std::string GetTypeName() const override { - return "ClientPort"; - } - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::ClientPort; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: std::atomic num_sessions{}; std::atomic peak_sessions{}; s32 max_sessions{}; KPort* parent{}; - std::string name; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_client_session.h b/src/core/hle/kernel/k_client_session.h index c4b193773..1480597e2 100644 --- a/src/core/hle/kernel/k_client_session.h +++ b/src/core/hle/kernel/k_client_session.h @@ -54,27 +54,8 @@ public: void OnServerClosed(); - // DEPRECATED - - static constexpr HandleType HANDLE_TYPE = HandleType::ClientSession; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - - std::string GetTypeName() const override { - return "ClientSession"; - } - - std::string GetName() const override { - return name; - } - private: - /// The parent session, which links to the server endpoint. KSession* parent{}; - - /// Name of the client session (optional) - std::string name; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_event.h b/src/core/hle/kernel/k_event.h index 45634e401..f0b89f882 100644 --- a/src/core/hle/kernel/k_event.h +++ b/src/core/hle/kernel/k_event.h @@ -48,17 +48,6 @@ public: return writable_event; } - // DEPRECATED - - std::string GetTypeName() const override { - return "KEvent"; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::Event; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: KReadableEvent readable_event; KWritableEvent writable_event; diff --git a/src/core/hle/kernel/k_port.h b/src/core/hle/kernel/k_port.h index 68c8ed8df..f1b2838d8 100644 --- a/src/core/hle/kernel/k_port.h +++ b/src/core/hle/kernel/k_port.h @@ -51,22 +51,6 @@ public: return server; } - // DEPRECATED - - friend class ServerPort; - std::string GetTypeName() const override { - return "Port"; - } - std::string GetName() const override { - return name; - } - - HandleType GetHandleType() const override { - return {}; - } - - void Finalize() override {} - private: enum class State : u8 { Invalid = 0, @@ -80,8 +64,6 @@ private: KClientPort client; State state{State::Invalid}; bool is_light{}; - - std::string name; ///< Name of client port (optional) }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_readable_event.h b/src/core/hle/kernel/k_readable_event.h index 4c22f0584..8514d065a 100644 --- a/src/core/hle/kernel/k_readable_event.h +++ b/src/core/hle/kernel/k_readable_event.h @@ -6,7 +6,6 @@ #include "core/hle/kernel/k_auto_object.h" #include "core/hle/kernel/k_synchronization_object.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/slab_helpers.h" #include "core/hle/result.h" @@ -39,17 +38,6 @@ public: ResultCode Clear(); ResultCode Reset(); - // DEPRECATED - - std::string GetTypeName() const override { - return "KReadableEvent"; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::ReadableEvent; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: bool is_signaled{}; KEvent* parent{}; diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h index 483c66c33..66ebf32df 100644 --- a/src/core/hle/kernel/k_resource_limit.h +++ b/src/core/hle/kernel/k_resource_limit.h @@ -8,7 +8,6 @@ #include "common/common_types.h" #include "core/hle/kernel/k_light_condition_variable.h" #include "core/hle/kernel/k_light_lock.h" -#include "core/hle/kernel/object.h" union ResultCode; @@ -57,20 +56,6 @@ public: static void PostDestroy([[maybe_unused]] uintptr_t arg) {} - // DEPRECATED - - std::string GetTypeName() const override { - return "KResourceLimit"; - } - std::string GetName() const override { - return GetTypeName(); - } - - static constexpr HandleType HANDLE_TYPE = HandleType::ResourceLimit; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: using ResourceArray = std::array(LimitableResource::Count)>; ResourceArray limit_values{}; diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp index fcc04abaa..5e44c48e2 100644 --- a/src/core/hle/kernel/k_server_port.cpp +++ b/src/core/hle/kernel/k_server_port.cpp @@ -10,7 +10,6 @@ #include "core/hle/kernel/k_server_port.h" #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_thread.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/svc_results.h" namespace Kernel { diff --git a/src/core/hle/kernel/k_server_port.h b/src/core/hle/kernel/k_server_port.h index 9f45ca3f4..a46fa8f54 100644 --- a/src/core/hle/kernel/k_server_port.h +++ b/src/core/hle/kernel/k_server_port.h @@ -68,20 +68,6 @@ public: virtual void Destroy() override; virtual bool IsSignaled() const override; - // DEPRECATED - - std::string GetTypeName() const override { - return "ServerPort"; - } - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::ServerPort; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: void CleanupSessions(); @@ -89,7 +75,6 @@ private: SessionList session_list; HLEHandler hle_handler; KPort* parent{}; - std::string name; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h index d748754d0..4a54e6634 100644 --- a/src/core/hle/kernel/k_server_session.h +++ b/src/core/hle/kernel/k_server_session.h @@ -103,21 +103,6 @@ public: convert_to_domain = true; } - // DEPRECATED - - std::string GetTypeName() const override { - return "ServerSession"; - } - - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::ServerSession; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: /// Queues a sync request from the emulated application. ResultCode QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory); @@ -138,9 +123,6 @@ private: /// When set to True, converts the session to a domain at the end of the command bool convert_to_domain{}; - /// The name of this session (optional) - std::string name; - /// Thread to dispatch service requests std::weak_ptr service_thread; diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp index 6f4276189..6f5947ce7 100644 --- a/src/core/hle/kernel/k_session.cpp +++ b/src/core/hle/kernel/k_session.cpp @@ -15,7 +15,7 @@ KSession::KSession(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel}, server{kernel}, client{kernel} {} KSession::~KSession() = default; -void KSession::Initialize(KClientPort* port_, std::string&& name_) { +void KSession::Initialize(KClientPort* port_, const std::string& name_) { // Increment reference count. // Because reference count is one on creation, this will result // in a reference count of two. Thus, when both server and client are closed @@ -32,7 +32,7 @@ void KSession::Initialize(KClientPort* port_, std::string&& name_) { // Set state and name. SetState(State::Normal); - name = std::move(name_); + name = name_; // Set our owner process. process = kernel.CurrentProcess(); 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{}; }; diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h index 93153ab20..9547546a5 100644 --- a/src/core/hle/kernel/k_shared_memory.h +++ b/src/core/hle/kernel/k_shared_memory.h @@ -32,19 +32,6 @@ public: KMemoryPermission owner_permission_, KMemoryPermission user_permission_, PAddr physical_address_, std::size_t size_, std::string name_); - std::string GetTypeName() const override { - return "SharedMemory"; - } - - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::SharedMemory; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - /** * Maps a shared memory block to an address in the target process' address space * @param target_process Process on which to map the memory block diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h index 5a99dbd46..a41dd1220 100644 --- a/src/core/hle/kernel/k_synchronization_object.h +++ b/src/core/hle/kernel/k_synchronization_object.h @@ -51,13 +51,4 @@ private: ThreadListNode* thread_list_tail{}; }; -// Specialization of DynamicObjectCast for KSynchronizationObjects -template <> -inline KSynchronizationObject* DynamicObjectCast(Object* object) { - if (object != nullptr && object->IsWaitable()) { - return reinterpret_cast(object); - } - return nullptr; -} - } // namespace Kernel diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 5cc0a0064..c59f3113c 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -27,7 +27,6 @@ #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread_queue.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/time_manager.h" diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 5c1c17d48..5b943b18b 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -19,7 +19,6 @@ #include "core/hle/kernel/k_light_lock.h" #include "core/hle/kernel/k_spin_lock.h" #include "core/hle/kernel/k_synchronization_object.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/slab_helpers.h" #include "core/hle/kernel/svc_common.h" #include "core/hle/kernel/svc_types.h" @@ -120,23 +119,10 @@ public: using ThreadContext64 = Core::ARM_Interface::ThreadContext64; using WaiterList = boost::intrusive::list; - [[nodiscard]] std::string GetName() const override { - return name; - } - void SetName(std::string new_name) { name = std::move(new_name); } - [[nodiscard]] std::string GetTypeName() const override { - return "Thread"; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::Thread; - [[nodiscard]] HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - /** * Gets the thread's current priority * @return The current thread's priority @@ -728,7 +714,6 @@ private: VAddr mutex_wait_address_for_debugging{}; ThreadWaitReasonForDebugging wait_reason_for_debugging{}; ThreadType thread_type_for_debugging{}; - std::string name; public: using ConditionVariableThreadTreeType = ConditionVariableThreadTree; diff --git a/src/core/hle/kernel/k_transfer_memory.h b/src/core/hle/kernel/k_transfer_memory.h index 3c3fa401b..1e4fa9323 100644 --- a/src/core/hle/kernel/k_transfer_memory.h +++ b/src/core/hle/kernel/k_transfer_memory.h @@ -55,21 +55,6 @@ public: return is_initialized ? size * PageSize : 0; } - // DEPRECATED - - std::string GetTypeName() const override { - return "TransferMemory"; - } - - std::string GetName() const override { - return GetTypeName(); - } - - static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: Process* owner{}; VAddr address{}; diff --git a/src/core/hle/kernel/k_writable_event.h b/src/core/hle/kernel/k_writable_event.h index 7cf43f77e..f5e083482 100644 --- a/src/core/hle/kernel/k_writable_event.h +++ b/src/core/hle/kernel/k_writable_event.h @@ -5,7 +5,6 @@ #pragma once #include "core/hle/kernel/k_auto_object.h" -#include "core/hle/kernel/object.h" #include "core/hle/kernel/slab_helpers.h" #include "core/hle/result.h" @@ -34,17 +33,6 @@ public: return parent; } - // DEPRECATED - - std::string GetTypeName() const override { - return "KWritableEvent"; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::WritableEvent; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - private: KEvent* parent{}; }; diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 723be6b51..de7f83423 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -14,7 +14,6 @@ #include "core/hle/kernel/k_auto_object.h" #include "core/hle/kernel/k_slab_heap.h" #include "core/hle/kernel/memory_types.h" -#include "core/hle/kernel/object.h" namespace Core { class CPUInterruptHandler; @@ -293,7 +292,6 @@ public: } private: - friend class Object; friend class Process; friend class KThread; diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp deleted file mode 100644 index d7f40c403..000000000 --- a/src/core/hle/kernel/object.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "common/assert.h" -#include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/object.h" - -namespace Kernel { - -Object::Object(KernelCore& kernel_) - : kernel{kernel_}, object_id{kernel_.CreateNewObjectID()}, name{"[UNKNOWN KERNEL OBJECT]"} {} -Object::Object(KernelCore& kernel_, std::string&& name_) - : kernel{kernel_}, object_id{kernel_.CreateNewObjectID()}, name{std::move(name_)} {} -Object::~Object() = default; - -bool Object::IsWaitable() const { - switch (GetHandleType()) { - case HandleType::ReadableEvent: - case HandleType::Thread: - case HandleType::Process: - case HandleType::ServerPort: - case HandleType::ServerSession: - return true; - - case HandleType::Unknown: - case HandleType::Event: - case HandleType::WritableEvent: - case HandleType::SharedMemory: - case HandleType::TransferMemory: - case HandleType::ResourceLimit: - case HandleType::ClientPort: - case HandleType::ClientSession: - case HandleType::Session: - return false; - } - - UNREACHABLE(); - return false; -} - -} // namespace Kernel diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h deleted file mode 100644 index 03443b947..000000000 --- a/src/core/hle/kernel/object.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2018 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include - -#include "common/common_types.h" - -namespace Kernel { - -class KernelCore; - -using Handle = u32; - -enum class HandleType : u32 { - Unknown, - Event, - WritableEvent, - ReadableEvent, - SharedMemory, - TransferMemory, - Thread, - Process, - ResourceLimit, - ClientPort, - ServerPort, - ClientSession, - ServerSession, - Session, -}; - -class Object : NonCopyable, public std::enable_shared_from_this { -public: - explicit Object(KernelCore& kernel_); - explicit Object(KernelCore& kernel_, std::string&& name_); - virtual ~Object(); - - /// Returns a unique identifier for the object. For debugging purposes only. - u32 GetObjectId() const { - return object_id.load(std::memory_order_relaxed); - } - - virtual std::string GetTypeName() const { - return "[BAD KERNEL OBJECT TYPE]"; - } - virtual std::string GetName() const { - return name; - } - virtual HandleType GetHandleType() const = 0; - - void Close() { - // TODO(bunnei): This is a placeholder to decrement the reference count, which we will use - // when we implement KAutoObject instead of using shared_ptr. - } - - /** - * Check if a thread can wait on the object - * @return True if a thread can wait on the object, otherwise false - */ - bool IsWaitable() const; - - virtual void Finalize() = 0; - -protected: - /// The kernel instance this object was created under. - KernelCore& kernel; - -private: - std::atomic object_id{0}; - -protected: - std::string name; -}; - -template -std::shared_ptr SharedFrom(T* raw) { - if (raw == nullptr) - return nullptr; - return std::static_pointer_cast(raw->shared_from_this()); -} - -/** - * Attempts to downcast the given Object pointer to a pointer to T. - * @return Derived pointer to the object, or `nullptr` if `object` isn't of type T. - */ -template -inline T* DynamicObjectCast(Object* object) { - if (object != nullptr && object->GetHandleType() == T::HANDLE_TYPE) { - return reinterpret_cast(object); - } - return nullptr; -} - -} // namespace Kernel diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 35fe16433..b775e1fd0 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -92,18 +92,6 @@ public: static ResultCode Initialize(Process* process, Core::System& system, std::string name, ProcessType type); - std::string GetTypeName() const override { - return "Process"; - } - std::string GetName() const override { - return name; - } - - static constexpr HandleType HANDLE_TYPE = HandleType::Process; - HandleType GetHandleType() const override { - return HANDLE_TYPE; - } - /// Gets a reference to the process' page table. KPageTable& PageTable() { return *page_table; @@ -468,9 +456,6 @@ private: /// Process total image size std::size_t image_size{}; - /// Name of this process - std::string name; - /// Schedule count of this process s64 schedule_count{}; diff --git a/src/core/hle/kernel/time_manager.h b/src/core/hle/kernel/time_manager.h index 0d7f05f30..2d175a9c4 100644 --- a/src/core/hle/kernel/time_manager.h +++ b/src/core/hle/kernel/time_manager.h @@ -8,8 +8,6 @@ #include #include -#include "core/hle/kernel/object.h" - namespace Core { class System; } // namespace Core diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 229dc7a1e..5c0b4b459 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -9,7 +9,6 @@ #include "common/swap.h" #include "core/hle/kernel/k_event.h" -#include "core/hle/kernel/object.h" union ResultCode; diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index b0f575561..c050c9a44 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -11,7 +11,6 @@ #include "common/quaternion.h" #include "common/settings.h" #include "core/frontend/input.h" -#include "core/hle/kernel/object.h" #include "core/hle/service/hid/controllers/controller_base.h" namespace Kernel { diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h index a1bcb5859..9bc6462b0 100644 --- a/src/core/hle/service/hid/irs.h +++ b/src/core/hle/service/hid/irs.h @@ -4,7 +4,6 @@ #pragma once -#include "core/hle/kernel/object.h" #include "core/hle/service/service.h" namespace Core { diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 044e51d08..4ec0b1506 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -15,7 +15,6 @@ #include "common/swap.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/object.h" #include "core/hle/service/nvdrv/nvdata.h" namespace Kernel { diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 1c0aa8ec4..b0febdaec 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -15,7 +15,6 @@ #include #include "common/common_types.h" -#include "core/hle/kernel/object.h" namespace Common { class Event; diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 076f50b0b..884951428 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -11,7 +11,6 @@ #include "common/common_types.h" #include "common/spin_lock.h" #include "core/hle/kernel/hle_ipc.h" -#include "core/hle/kernel/object.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace Service diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index cb397fcc7..ee026e22f 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp @@ -14,7 +14,7 @@ namespace Service::SM { void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) { ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain"); - LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId()); + LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId()); ctx.Session()->ConvertToDomain(); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 71ab4b6f5..568effbc9 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -140,7 +140,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { port->EnqueueSession(&session->GetServerSession()); } - LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetObjectId()); + LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; rb.Push(RESULT_SUCCESS); rb.PushMoveObjects(session->GetClientSession()); diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 317c42631..3ac4a9e2b 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp @@ -13,6 +13,7 @@ #include "core/arm/arm_interface.h" #include "core/core.h" #include "core/hle/kernel/handle_table.h" +#include "core/hle/kernel/k_class_token.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_synchronization_object.h" @@ -183,20 +184,20 @@ bool WaitTreeExpandableItem::IsExpandable() const { } QString WaitTreeSynchronizationObject::GetText() const { - // return tr("[%1]%2 %3") - // .arg(object.GetObjectId()) - // .arg(QString::fromStdString(object.GetTypeName()), - // QString::fromStdString(object.GetName())); - - return tr("UNIMPLEMENTED"); + return tr("[%1] %2 %3") + .arg(object.GetId()) + .arg(QString::fromStdString(object.GetTypeObj().GetName()), + QString::fromStdString(object.GetName())); } std::unique_ptr WaitTreeSynchronizationObject::make( const Kernel::KSynchronizationObject& object) { - switch (object.GetHandleType()) { - case Kernel::HandleType::ReadableEvent: + const auto type = + static_cast(object.GetTypeObj().GetClassToken()); + switch (type) { + case Kernel::KClassTokenGenerator::ObjectType::KReadableEvent: return std::make_unique(static_cast(object)); - case Kernel::HandleType::Thread: + case Kernel::KClassTokenGenerator::ObjectType::KThread: return std::make_unique(static_cast(object)); default: return std::make_unique(object); @@ -206,12 +207,13 @@ std::unique_ptr WaitTreeSynchronizationObject::ma std::vector> WaitTreeSynchronizationObject::GetChildren() const { std::vector> list; - const auto& threads = object.GetWaitingThreadsForDebugging(); + auto threads = object.GetWaitingThreadsForDebugging(); if (threads.empty()) { list.push_back(std::make_unique(tr("waited by no thread"))); } else { - list.push_back(std::make_unique(threads)); + list.push_back(std::make_unique(std::move(threads))); } + return list; } @@ -379,8 +381,8 @@ WaitTreeEvent::WaitTreeEvent(const Kernel::KReadableEvent& object) : WaitTreeSynchronizationObject(object) {} WaitTreeEvent::~WaitTreeEvent() = default; -WaitTreeThreadList::WaitTreeThreadList(const std::vector& list) - : thread_list(list) {} +WaitTreeThreadList::WaitTreeThreadList(std::vector&& list) + : thread_list(std::move(list)) {} WaitTreeThreadList::~WaitTreeThreadList() = default; QString WaitTreeThreadList::GetText() const { diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index bf8120a71..3dd4acab0 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h @@ -11,8 +11,9 @@ #include #include #include + #include "common/common_types.h" -#include "core/hle/kernel/object.h" +#include "core/hle/kernel/k_auto_object.h" class EmuThread; @@ -149,14 +150,14 @@ public: class WaitTreeThreadList : public WaitTreeExpandableItem { Q_OBJECT public: - explicit WaitTreeThreadList(const std::vector& list); + explicit WaitTreeThreadList(std::vector&& list); ~WaitTreeThreadList() override; QString GetText() const override; std::vector> GetChildren() const override; private: - const std::vector& thread_list; + std::vector thread_list; }; class WaitTreeModel : public QAbstractItemModel { -- cgit v1.2.3