diff options
| author | 2018-01-08 14:12:03 -0500 | |
|---|---|---|
| committer | 2018-01-08 21:12:51 -0500 | |
| commit | 1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c (patch) | |
| tree | 71a8fc9f6ab552fb242923372238f691caa4e3d6 /src/core/hle/kernel/mutex.h | |
| parent | Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback. (diff) | |
| download | yuzu-1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c.tar.gz yuzu-1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c.tar.xz yuzu-1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c.zip | |
Kernel: Properly keep track of mutex lock data in the guest memory. This fixes userland locking/unlocking.
Diffstat (limited to 'src/core/hle/kernel/mutex.h')
| -rw-r--r-- | src/core/hle/kernel/mutex.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 87e3c15ee..49b6b454e 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h | |||
| @@ -41,10 +41,8 @@ public: | |||
| 41 | return HANDLE_TYPE; | 41 | return HANDLE_TYPE; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | int lock_count; ///< Number of times the mutex has been acquired | ||
| 45 | u32 priority; ///< The priority of the mutex, used for priority inheritance. | 44 | u32 priority; ///< The priority of the mutex, used for priority inheritance. |
| 46 | std::string name; ///< Name of mutex (optional) | 45 | std::string name; ///< Name of mutex (optional) |
| 47 | SharedPtr<Thread> holding_thread; ///< Thread that has acquired the mutex | ||
| 48 | VAddr guest_addr; ///< Address of the guest mutex value | 46 | VAddr guest_addr; ///< Address of the guest mutex value |
| 49 | 47 | ||
| 50 | /** | 48 | /** |
| @@ -66,6 +64,19 @@ public: | |||
| 66 | */ | 64 | */ |
| 67 | ResultCode Release(Thread* thread); | 65 | ResultCode Release(Thread* thread); |
| 68 | 66 | ||
| 67 | /// Gets the handle to the holding process stored in the guest state. | ||
| 68 | Handle GetOwnerHandle() const; | ||
| 69 | |||
| 70 | /// Gets the Thread pointed to by the owner handle | ||
| 71 | SharedPtr<Thread> GetHoldingThread() const; | ||
| 72 | /// Sets the holding process handle in the guest state. | ||
| 73 | void SetHoldingThread(SharedPtr<Thread> thread); | ||
| 74 | |||
| 75 | /// Returns the has_waiters bit in the guest state. | ||
| 76 | bool GetHasWaiters() const; | ||
| 77 | /// Sets the has_waiters bit in the guest state. | ||
| 78 | void SetHasWaiters(bool has_waiters); | ||
| 79 | |||
| 69 | private: | 80 | private: |
| 70 | Mutex(); | 81 | Mutex(); |
| 71 | ~Mutex() override; | 82 | ~Mutex() override; |
| @@ -79,12 +90,6 @@ private: | |||
| 79 | BitField<30, 1, u32_le> has_waiters; | 90 | BitField<30, 1, u32_le> has_waiters; |
| 80 | }; | 91 | }; |
| 81 | static_assert(sizeof(GuestState) == 4, "GuestState size is incorrect"); | 92 | static_assert(sizeof(GuestState) == 4, "GuestState size is incorrect"); |
| 82 | |||
| 83 | /// Updates the state of the object tracking this mutex in guest memory | ||
| 84 | void UpdateGuestState(); | ||
| 85 | |||
| 86 | /// Verifies the state of the object tracking this mutex in guest memory | ||
| 87 | void VerifyGuestState(); | ||
| 88 | }; | 93 | }; |
| 89 | 94 | ||
| 90 | /** | 95 | /** |