diff options
| author | 2017-12-28 23:12:28 -0500 | |
|---|---|---|
| committer | 2017-12-28 23:12:28 -0500 | |
| commit | 834fa5db65ab3bc2e05474e280f5a0a73be7411e (patch) | |
| tree | 3c1557cb761e6c53f6305b6ec349a01cc6438eb3 /src | |
| parent | svc: Implement MapMemory. (diff) | |
| download | yuzu-834fa5db65ab3bc2e05474e280f5a0a73be7411e.tar.gz yuzu-834fa5db65ab3bc2e05474e280f5a0a73be7411e.tar.xz yuzu-834fa5db65ab3bc2e05474e280f5a0a73be7411e.zip | |
kernel: Add SyncObject primitive, use it for ClientSession.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_session.h | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/sync_object.h | 35 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 4 |
4 files changed, 41 insertions, 10 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cbf20823f..29abb703f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -132,6 +132,7 @@ set(HEADERS | |||
| 132 | hle/kernel/server_session.h | 132 | hle/kernel/server_session.h |
| 133 | hle/kernel/session.h | 133 | hle/kernel/session.h |
| 134 | hle/kernel/shared_memory.h | 134 | hle/kernel/shared_memory.h |
| 135 | hle/kernel/sync_object.h | ||
| 135 | hle/kernel/thread.h | 136 | hle/kernel/thread.h |
| 136 | hle/kernel/timer.h | 137 | hle/kernel/timer.h |
| 137 | hle/kernel/vm_manager.h | 138 | hle/kernel/vm_manager.h |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index daf521529..671174ec4 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/sync_object.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| @@ -16,7 +16,7 @@ class ServerSession; | |||
| 16 | class Session; | 16 | class Session; |
| 17 | class Thread; | 17 | class Thread; |
| 18 | 18 | ||
| 19 | class ClientSession final : public Object { | 19 | class ClientSession final : public SyncObject { |
| 20 | public: | 20 | public: |
| 21 | friend class ServerSession; | 21 | friend class ServerSession; |
| 22 | 22 | ||
| @@ -33,12 +33,7 @@ public: | |||
| 33 | return HANDLE_TYPE; | 33 | return HANDLE_TYPE; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /** | 36 | ResultCode SendSyncRequest(SharedPtr<Thread> thread) override; |
| 37 | * Sends an SyncRequest from the current emulated thread. | ||
| 38 | * @param thread Thread that initiated the request. | ||
| 39 | * @return ResultCode of the operation. | ||
| 40 | */ | ||
| 41 | ResultCode SendSyncRequest(SharedPtr<Thread> thread); | ||
| 42 | 37 | ||
| 43 | std::string name; ///< Name of client port (optional) | 38 | std::string name; ///< Name of client port (optional) |
| 44 | 39 | ||
diff --git a/src/core/hle/kernel/sync_object.h b/src/core/hle/kernel/sync_object.h new file mode 100644 index 000000000..ce2835ca4 --- /dev/null +++ b/src/core/hle/kernel/sync_object.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <boost/smart_ptr/intrusive_ptr.hpp> | ||
| 8 | #include "core/hle/kernel/kernel.h" | ||
| 9 | #include "core/hle/result.h" | ||
| 10 | |||
| 11 | namespace Kernel { | ||
| 12 | |||
| 13 | class Thread; | ||
| 14 | |||
| 15 | /// Class that represents a Kernel object that svcSendSyncRequest can be called on | ||
| 16 | class SyncObject : public Object { | ||
| 17 | public: | ||
| 18 | /** | ||
| 19 | * Handle a sync request from the emulated application. | ||
| 20 | * @param thread Thread that initiated the request. | ||
| 21 | * @returns ResultCode from the operation. | ||
| 22 | */ | ||
| 23 | virtual ResultCode SendSyncRequest(SharedPtr<Thread> thread) = 0; | ||
| 24 | }; | ||
| 25 | |||
| 26 | // Specialization of DynamicObjectCast for SyncObjects | ||
| 27 | template <> | ||
| 28 | inline SharedPtr<SyncObject> DynamicObjectCast<SyncObject>(SharedPtr<Object> object) { | ||
| 29 | if (object != nullptr && object->IsSyncable()) { | ||
| 30 | return boost::static_pointer_cast<SyncObject>(std::move(object)); | ||
| 31 | } | ||
| 32 | return nullptr; | ||
| 33 | } | ||
| 34 | |||
| 35 | } // namespace Kernel | ||
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 47041afd4..9db3d632a 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "core/hle/kernel/client_session.h" | 10 | #include "core/hle/kernel/client_session.h" |
| 11 | #include "core/hle/kernel/handle_table.h" | 11 | #include "core/hle/kernel/handle_table.h" |
| 12 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/hle/kernel/sync_object.h" | ||
| 13 | #include "core/hle/kernel/thread.h" | 14 | #include "core/hle/kernel/thread.h" |
| 14 | #include "core/hle/lock.h" | 15 | #include "core/hle/lock.h" |
| 15 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| @@ -71,8 +72,7 @@ static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_addr | |||
| 71 | 72 | ||
| 72 | /// Makes a blocking IPC call to an OS service. | 73 | /// Makes a blocking IPC call to an OS service. |
| 73 | static ResultCode SendSyncRequest(Kernel::Handle handle) { | 74 | static ResultCode SendSyncRequest(Kernel::Handle handle) { |
| 74 | SharedPtr<Kernel::ClientSession> session = | 75 | SharedPtr<Kernel::SyncObject> session = Kernel::g_handle_table.Get<Kernel::SyncObject>(handle); |
| 75 | Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); | ||
| 76 | if (session == nullptr) { | 76 | if (session == nullptr) { |
| 77 | LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); | 77 | LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); |
| 78 | return ERR_INVALID_HANDLE; | 78 | return ERR_INVALID_HANDLE; |