diff options
| author | 2015-01-17 02:03:44 -0500 | |
|---|---|---|
| committer | 2015-01-21 19:09:03 -0500 | |
| commit | 7faf2d8e06e705d1866fa0d7848ff43541a4b172 (patch) | |
| tree | 7cca6433c6b06a1299af1193df2cedac7ad522c5 /src/core/hle/kernel/thread.h | |
| parent | Event: Fixed some bugs and cleanup (Subv) (diff) | |
| download | yuzu-7faf2d8e06e705d1866fa0d7848ff43541a4b172.tar.gz yuzu-7faf2d8e06e705d1866fa0d7848ff43541a4b172.tar.xz yuzu-7faf2d8e06e705d1866fa0d7848ff43541a4b172.zip | |
WaitSynchronizationN: Implement return values
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 9ec96c18c..f3dc4eec0 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -70,7 +70,7 @@ public: | |||
| 70 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } | 70 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } |
| 71 | inline bool IsIdle() const { return idle; } | 71 | inline bool IsIdle() const { return idle; } |
| 72 | 72 | ||
| 73 | ResultVal<bool> WaitSynchronization() override; | 73 | ResultVal<bool> WaitSynchronization(unsigned index) override; |
| 74 | 74 | ||
| 75 | s32 GetPriority() const { return current_priority; } | 75 | s32 GetPriority() const { return current_priority; } |
| 76 | void SetPriority(s32 priority); | 76 | void SetPriority(s32 priority); |
| @@ -78,9 +78,29 @@ public: | |||
| 78 | u32 GetThreadId() const { return thread_id; } | 78 | u32 GetThreadId() const { return thread_id; } |
| 79 | 79 | ||
| 80 | void Stop(const char* reason); | 80 | void Stop(const char* reason); |
| 81 | /// Resumes a thread from waiting by marking it as "ready". | 81 | |
| 82 | /** | ||
| 83 | * Release an object from the thread's wait list | ||
| 84 | * @param wait_object WaitObject to release from the thread's wait list | ||
| 85 | */ | ||
| 86 | void ReleaseFromWait(WaitObject* wait_object); | ||
| 87 | |||
| 88 | /// Resumes a thread from waiting by marking it as "ready" | ||
| 82 | void ResumeFromWait(); | 89 | void ResumeFromWait(); |
| 83 | 90 | ||
| 91 | /** | ||
| 92 | * Sets the waiting mode of the thread | ||
| 93 | * @param wait_all If true, wait for all objects, otherwise just wait for the first one | ||
| 94 | */ | ||
| 95 | void SetWaitAll(bool wait_all) { this->wait_all = wait_all; } | ||
| 96 | |||
| 97 | /** | ||
| 98 | * Sets the output values after the thread awakens from WaitSynchronization | ||
| 99 | * @param return_val Value returned | ||
| 100 | * @param out_val Value to set to the output parameter | ||
| 101 | */ | ||
| 102 | void SetReturnValue(ResultCode return_val, s32 out_val); | ||
| 103 | |||
| 84 | Core::ThreadContext context; | 104 | Core::ThreadContext context; |
| 85 | 105 | ||
| 86 | u32 thread_id; | 106 | u32 thread_id; |
| @@ -96,7 +116,7 @@ public: | |||
| 96 | s32 processor_id; | 116 | s32 processor_id; |
| 97 | 117 | ||
| 98 | WaitType wait_type; | 118 | WaitType wait_type; |
| 99 | std::vector<SharedPtr<WaitObject>> wait_objects; | 119 | std::vector<std::pair<SharedPtr<WaitObject>, unsigned>> wait_objects; |
| 100 | VAddr wait_address; | 120 | VAddr wait_address; |
| 101 | 121 | ||
| 102 | std::string name; | 122 | std::string name; |
| @@ -105,6 +125,8 @@ public: | |||
| 105 | bool idle = false; | 125 | bool idle = false; |
| 106 | 126 | ||
| 107 | private: | 127 | private: |
| 128 | bool wait_all = false; | ||
| 129 | |||
| 108 | Thread() = default; | 130 | Thread() = default; |
| 109 | }; | 131 | }; |
| 110 | 132 | ||
| @@ -115,37 +137,41 @@ SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size); | |||
| 115 | void Reschedule(); | 137 | void Reschedule(); |
| 116 | 138 | ||
| 117 | /// Arbitrate the highest priority thread that is waiting | 139 | /// Arbitrate the highest priority thread that is waiting |
| 118 | Thread* ArbitrateHighestPriorityThread(Object* arbiter, u32 address); | 140 | Thread* ArbitrateHighestPriorityThread(WaitObject* arbiter, u32 address); |
| 119 | 141 | ||
| 120 | /// Arbitrate all threads currently waiting... | 142 | /// Arbitrate all threads currently waiting... |
| 121 | void ArbitrateAllThreads(Object* arbiter, u32 address); | 143 | void ArbitrateAllThreads(WaitObject* arbiter, u32 address); |
| 122 | 144 | ||
| 123 | /// Gets the current thread | 145 | /// Gets the current thread |
| 124 | Thread* GetCurrentThread(); | 146 | Thread* GetCurrentThread(); |
| 125 | 147 | ||
| 126 | /** | 148 | /** |
| 127 | * Puts the current thread in the wait state for the given type | 149 | * Waits the current thread for the given type |
| 128 | * @param wait_type Type of wait | 150 | * @param wait_type Type of wait |
| 129 | * @param wait_object Kernel object that we are waiting on, defaults to current thread | ||
| 130 | */ | 151 | */ |
| 131 | void WaitCurrentThread(WaitType wait_type, WaitObject* wait_object = GetCurrentThread()); | 152 | void WaitCurrentThread(WaitType wait_type); |
| 132 | 153 | ||
| 133 | /** | 154 | /** |
| 134 | * Schedules an event to wake up the specified thread after the specified delay. | 155 | * Waits the current thread from a WaitSynchronization call |
| 135 | * @param thread The thread to wake after the delay. | 156 | * @param wait_type Type of wait |
| 136 | * @param nanoseconds The time this thread will be allowed to sleep for. | 157 | * @param wait_object Kernel object that we are waiting on |
| 158 | * @param index Index of calling object (for WaitSynchronizationN only) | ||
| 137 | */ | 159 | */ |
| 138 | void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds); | 160 | void WaitCurrentThread_WaitSynchronization(WaitType wait_type, WaitObject* wait_object, unsigned index=0); |
| 139 | 161 | ||
| 140 | /** | 162 | /** |
| 141 | * Puts the current thread in the wait state for the given type | 163 | * Waits the current thread from an ArbitrateAddress call |
| 142 | * @param wait_type Type of wait | ||
| 143 | * @param wait_object Kernel object that we are waiting on | 164 | * @param wait_object Kernel object that we are waiting on |
| 144 | * @param wait_address Arbitration address used to resume from wait | 165 | * @param wait_address Arbitration address used to resume from wait |
| 145 | */ | 166 | */ |
| 146 | void WaitCurrentThread(WaitType wait_type, WaitObject* wait_object, VAddr wait_address); | 167 | void WaitCurrentThread_ArbitrateAddress(WaitObject* wait_object, VAddr wait_address); |
| 147 | |||
| 148 | 168 | ||
| 169 | /** | ||
| 170 | * Schedules an event to wake up the specified thread after the specified delay. | ||
| 171 | * @param handle The thread handle. | ||
| 172 | * @param nanoseconds The time this thread will be allowed to sleep for. | ||
| 173 | */ | ||
| 174 | void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds); | ||
| 149 | 175 | ||
| 150 | /** | 176 | /** |
| 151 | * Sets up the idle thread, this is a thread that is intended to never execute instructions, | 177 | * Sets up the idle thread, this is a thread that is intended to never execute instructions, |