From 1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 8 Jan 2018 14:12:03 -0500 Subject: Kernel: Properly keep track of mutex lock data in the guest memory. This fixes userland locking/unlocking. --- src/core/hle/kernel/mutex.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel/mutex.h') 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: return HANDLE_TYPE; } - int lock_count; ///< Number of times the mutex has been acquired u32 priority; ///< The priority of the mutex, used for priority inheritance. std::string name; ///< Name of mutex (optional) - SharedPtr holding_thread; ///< Thread that has acquired the mutex VAddr guest_addr; ///< Address of the guest mutex value /** @@ -66,6 +64,19 @@ public: */ ResultCode Release(Thread* thread); + /// Gets the handle to the holding process stored in the guest state. + Handle GetOwnerHandle() const; + + /// Gets the Thread pointed to by the owner handle + SharedPtr GetHoldingThread() const; + /// Sets the holding process handle in the guest state. + void SetHoldingThread(SharedPtr thread); + + /// Returns the has_waiters bit in the guest state. + bool GetHasWaiters() const; + /// Sets the has_waiters bit in the guest state. + void SetHasWaiters(bool has_waiters); + private: Mutex(); ~Mutex() override; @@ -79,12 +90,6 @@ private: BitField<30, 1, u32_le> has_waiters; }; static_assert(sizeof(GuestState) == 4, "GuestState size is incorrect"); - - /// Updates the state of the object tracking this mutex in guest memory - void UpdateGuestState(); - - /// Verifies the state of the object tracking this mutex in guest memory - void VerifyGuestState(); }; /** -- cgit v1.2.3