diff options
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index deab5d5a6..2ed5cf74e 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -17,29 +17,29 @@ | |||
| 17 | #include "core/hle/kernel/kernel.h" | 17 | #include "core/hle/kernel/kernel.h" |
| 18 | #include "core/hle/result.h" | 18 | #include "core/hle/result.h" |
| 19 | 19 | ||
| 20 | enum ThreadPriority : s32{ | 20 | enum ThreadPriority : s32 { |
| 21 | THREADPRIO_HIGHEST = 0, ///< Highest thread priority | 21 | THREADPRIO_HIGHEST = 0, ///< Highest thread priority |
| 22 | THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps | 22 | THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps |
| 23 | THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps | 23 | THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps |
| 24 | THREADPRIO_LOWEST = 63, ///< Lowest thread priority | 24 | THREADPRIO_LOWEST = 63, ///< Lowest thread priority |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | enum ThreadProcessorId : s32 { | 27 | enum ThreadProcessorId : s32 { |
| 28 | THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader | 28 | THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader |
| 29 | THREADPROCESSORID_ALL = -1, ///< Run thread on either core | 29 | THREADPROCESSORID_ALL = -1, ///< Run thread on either core |
| 30 | THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore) | 30 | THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore) |
| 31 | THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore) | 31 | THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore) |
| 32 | THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this | 32 | THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | enum ThreadStatus { | 35 | enum ThreadStatus { |
| 36 | THREADSTATUS_RUNNING, ///< Currently running | 36 | THREADSTATUS_RUNNING, ///< Currently running |
| 37 | THREADSTATUS_READY, ///< Ready to run | 37 | THREADSTATUS_READY, ///< Ready to run |
| 38 | THREADSTATUS_WAIT_ARB, ///< Waiting on an address arbiter | 38 | THREADSTATUS_WAIT_ARB, ///< Waiting on an address arbiter |
| 39 | THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC | 39 | THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC |
| 40 | THREADSTATUS_WAIT_SYNCH, ///< Waiting due to a WaitSynchronization SVC | 40 | THREADSTATUS_WAIT_SYNCH, ///< Waiting due to a WaitSynchronization SVC |
| 41 | THREADSTATUS_DORMANT, ///< Created but not yet made ready | 41 | THREADSTATUS_DORMANT, ///< Created but not yet made ready |
| 42 | THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated | 42 | THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | namespace Kernel { | 45 | namespace Kernel { |
| @@ -60,13 +60,19 @@ public: | |||
| 60 | * @return A shared pointer to the newly created thread | 60 | * @return A shared pointer to the newly created thread |
| 61 | */ | 61 | */ |
| 62 | static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority, | 62 | static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority, |
| 63 | u32 arg, s32 processor_id, VAddr stack_top); | 63 | u32 arg, s32 processor_id, VAddr stack_top); |
| 64 | 64 | ||
| 65 | std::string GetName() const override { return name; } | 65 | std::string GetName() const override { |
| 66 | std::string GetTypeName() const override { return "Thread"; } | 66 | return name; |
| 67 | } | ||
| 68 | std::string GetTypeName() const override { | ||
| 69 | return "Thread"; | ||
| 70 | } | ||
| 67 | 71 | ||
| 68 | static const HandleType HANDLE_TYPE = HandleType::Thread; | 72 | static const HandleType HANDLE_TYPE = HandleType::Thread; |
| 69 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | 73 | HandleType GetHandleType() const override { |
| 74 | return HANDLE_TYPE; | ||
| 75 | } | ||
| 70 | 76 | ||
| 71 | bool ShouldWait() override; | 77 | bool ShouldWait() override; |
| 72 | void Acquire() override; | 78 | void Acquire() override; |
| @@ -75,7 +81,9 @@ public: | |||
| 75 | * Gets the thread's current priority | 81 | * Gets the thread's current priority |
| 76 | * @return The current thread's priority | 82 | * @return The current thread's priority |
| 77 | */ | 83 | */ |
| 78 | s32 GetPriority() const { return current_priority; } | 84 | s32 GetPriority() const { |
| 85 | return current_priority; | ||
| 86 | } | ||
| 79 | 87 | ||
| 80 | /** | 88 | /** |
| 81 | * Sets the thread's current priority | 89 | * Sets the thread's current priority |
| @@ -93,7 +101,9 @@ public: | |||
| 93 | * Gets the thread's thread ID | 101 | * Gets the thread's thread ID |
| 94 | * @return The thread's ID | 102 | * @return The thread's ID |
| 95 | */ | 103 | */ |
| 96 | u32 GetThreadId() const { return thread_id; } | 104 | u32 GetThreadId() const { |
| 105 | return thread_id; | ||
| 106 | } | ||
| 97 | 107 | ||
| 98 | /** | 108 | /** |
| 99 | * Resumes a thread from waiting | 109 | * Resumes a thread from waiting |
| @@ -127,7 +137,9 @@ public: | |||
| 127 | * Returns the Thread Local Storage address of the current thread | 137 | * Returns the Thread Local Storage address of the current thread |
| 128 | * @returns VAddr of the thread's TLS | 138 | * @returns VAddr of the thread's TLS |
| 129 | */ | 139 | */ |
| 130 | VAddr GetTLSAddress() const { return tls_address; } | 140 | VAddr GetTLSAddress() const { |
| 141 | return tls_address; | ||
| 142 | } | ||
| 131 | 143 | ||
| 132 | Core::ThreadContext context; | 144 | Core::ThreadContext context; |
| 133 | 145 | ||
| @@ -137,8 +149,8 @@ public: | |||
| 137 | u32 entry_point; | 149 | u32 entry_point; |
| 138 | u32 stack_top; | 150 | u32 stack_top; |
| 139 | 151 | ||
| 140 | s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application | 152 | s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application |
| 141 | s32 current_priority; ///< Current thread priority, can be temporarily changed | 153 | s32 current_priority; ///< Current thread priority, can be temporarily changed |
| 142 | 154 | ||
| 143 | u64 last_running_ticks; ///< CPU tick when thread was last running | 155 | u64 last_running_ticks; ///< CPU tick when thread was last running |
| 144 | 156 | ||
| @@ -151,11 +163,11 @@ public: | |||
| 151 | /// Mutexes currently held by this thread, which will be released when it exits. | 163 | /// Mutexes currently held by this thread, which will be released when it exits. |
| 152 | boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; | 164 | boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; |
| 153 | 165 | ||
| 154 | SharedPtr<Process> owner_process; ///< Process that owns this thread | 166 | SharedPtr<Process> owner_process; ///< Process that owns this thread |
| 155 | std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on | 167 | std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on |
| 156 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address | 168 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address |
| 157 | bool wait_all; ///< True if the thread is waiting on all objects before resuming | 169 | bool wait_all; ///< True if the thread is waiting on all objects before resuming |
| 158 | bool wait_set_output; ///< True if the output parameter should be set on thread wakeup | 170 | bool wait_set_output; ///< True if the output parameter should be set on thread wakeup |
| 159 | 171 | ||
| 160 | std::string name; | 172 | std::string name; |
| 161 | 173 | ||
| @@ -205,10 +217,12 @@ void WaitCurrentThread_Sleep(); | |||
| 205 | /** | 217 | /** |
| 206 | * Waits the current thread from a WaitSynchronization call | 218 | * Waits the current thread from a WaitSynchronization call |
| 207 | * @param wait_objects Kernel objects that we are waiting on | 219 | * @param wait_objects Kernel objects that we are waiting on |
| 208 | * @param wait_set_output If true, set the output parameter on thread wakeup (for WaitSynchronizationN only) | 220 | * @param wait_set_output If true, set the output parameter on thread wakeup (for |
| 221 | * WaitSynchronizationN only) | ||
| 209 | * @param wait_all If true, wait on all objects before resuming (for WaitSynchronizationN only) | 222 | * @param wait_all If true, wait on all objects before resuming (for WaitSynchronizationN only) |
| 210 | */ | 223 | */ |
| 211 | void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects, bool wait_set_output, bool wait_all); | 224 | void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wait_objects, |
| 225 | bool wait_set_output, bool wait_all); | ||
| 212 | 226 | ||
| 213 | /** | 227 | /** |
| 214 | * Waits the current thread from an ArbitrateAddress call | 228 | * Waits the current thread from an ArbitrateAddress call |