summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-25 19:43:28 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:14 -0400
commit15a79eb0d7abe752a9a55d0cfa7ea220e17318b7 (patch)
tree863357ab4be1ff9a72804c40455d6a4c4c493acd /src/core/hle/kernel/thread.h
parentSVC: Correct ArbitrateUnlock (diff)
downloadyuzu-15a79eb0d7abe752a9a55d0cfa7ea220e17318b7.tar.gz
yuzu-15a79eb0d7abe752a9a55d0cfa7ea220e17318b7.tar.xz
yuzu-15a79eb0d7abe752a9a55d0cfa7ea220e17318b7.zip
SVC: Correct SendSyncRequest.
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h82
1 files changed, 53 insertions, 29 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index a8ae1a66f..04496f96e 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -31,12 +31,12 @@ class Process;
31class Scheduler; 31class Scheduler;
32 32
33enum ThreadPriority : u32 { 33enum ThreadPriority : u32 {
34 THREADPRIO_HIGHEST = 0, ///< Highest thread priority 34 THREADPRIO_HIGHEST = 0, ///< Highest thread priority
35 THREADPRIO_MAX_CORE_MIGRATION = 2, ///< Highest priority for a core migration 35 THREADPRIO_MAX_CORE_MIGRATION = 2, ///< Highest priority for a core migration
36 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps 36 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
37 THREADPRIO_DEFAULT = 44, ///< Default thread priority for userland apps 37 THREADPRIO_DEFAULT = 44, ///< Default thread priority for userland apps
38 THREADPRIO_LOWEST = 63, ///< Lowest thread priority 38 THREADPRIO_LOWEST = 63, ///< Lowest thread priority
39 THREADPRIO_COUNT = 64, ///< Total number of possible thread priorities. 39 THREADPRIO_COUNT = 64, ///< Total number of possible thread priorities.
40}; 40};
41 41
42enum ThreadType : u32 { 42enum ThreadType : u32 {
@@ -129,23 +129,24 @@ public:
129 using WakeupCallback = 129 using WakeupCallback =
130 std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 130 std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
131 std::shared_ptr<SynchronizationObject> object, std::size_t index)>; 131 std::shared_ptr<SynchronizationObject> object, std::size_t index)>;
132 using HLECallback = std::function<bool(std::shared_ptr<Thread> thread)>;
132 133
133 /** 134 /**
134 * Creates and returns a new thread. The new thread is immediately scheduled 135 * Creates and returns a new thread. The new thread is immediately scheduled
135 * @param system The instance of the whole system 136 * @param system The instance of the whole system
136 * @param name The friendly name desired for the thread 137 * @param name The friendly name desired for the thread
137 * @param entry_point The address at which the thread should start execution 138 * @param entry_point The address at which the thread should start execution
138 * @param priority The thread's priority 139 * @param priority The thread's priority
139 * @param arg User data to pass to the thread 140 * @param arg User data to pass to the thread
140 * @param processor_id The ID(s) of the processors on which the thread is desired to be run 141 * @param processor_id The ID(s) of the processors on which the thread is desired to be run
141 * @param stack_top The address of the thread's stack top 142 * @param stack_top The address of the thread's stack top
142 * @param owner_process The parent process for the thread, if null, it's a kernel thread 143 * @param owner_process The parent process for the thread, if null, it's a kernel thread
143 * @return A shared pointer to the newly created thread 144 * @return A shared pointer to the newly created thread
144 */ 145 */
145 static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, std::string name, 146 static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags,
146 VAddr entry_point, u32 priority, u64 arg, 147 std::string name, VAddr entry_point,
147 s32 processor_id, VAddr stack_top, 148 u32 priority, u64 arg, s32 processor_id,
148 Process* owner_process); 149 VAddr stack_top, Process* owner_process);
149 150
150 /** 151 /**
151 * Creates and returns a new thread. The new thread is immediately scheduled 152 * Creates and returns a new thread. The new thread is immediately scheduled
@@ -161,10 +162,10 @@ public:
161 * @param thread_start_parameter The parameter which will passed to host context on init 162 * @param thread_start_parameter The parameter which will passed to host context on init
162 * @return A shared pointer to the newly created thread 163 * @return A shared pointer to the newly created thread
163 */ 164 */
164 static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, std::string name, 165 static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags,
165 VAddr entry_point, u32 priority, u64 arg, 166 std::string name, VAddr entry_point,
166 s32 processor_id, VAddr stack_top, 167 u32 priority, u64 arg, s32 processor_id,
167 Process* owner_process, 168 VAddr stack_top, Process* owner_process,
168 std::function<void(void*)>&& thread_start_func, 169 std::function<void(void*)>&& thread_start_func,
169 void* thread_start_parameter); 170 void* thread_start_parameter);
170 171
@@ -447,17 +448,37 @@ public:
447 } 448 }
448 449
449 bool HasWakeupCallback() const { 450 bool HasWakeupCallback() const {
450 return wakeup_callback != nullptr; 451 return hle_callback != nullptr;
452 }
453
454 bool HasHLECallback() const {
455 return hle_callback != nullptr;
451 } 456 }
452 457
453 void SetWakeupCallback(WakeupCallback callback) { 458 void SetWakeupCallback(WakeupCallback callback) {
454 wakeup_callback = std::move(callback); 459 hle_callback = std::move(callback);
460 }
461
462 void SetHLECallback(WakeupCallback callback) {
463 hle_callback = std::move(callback);
464 }
465
466 void SetHLETimeEvent(Handle time_event) {
467 hle_time_event = time_event;
468 }
469
470 Handle GetHLETimeEvent() const {
471 return hle_time_event;
455 } 472 }
456 473
457 void InvalidateWakeupCallback() { 474 void InvalidateWakeupCallback() {
458 SetWakeupCallback(nullptr); 475 SetWakeupCallback(nullptr);
459 } 476 }
460 477
478 void InvalidateHLECallback() {
479 SetHLECallback(nullptr);
480 }
481
461 /** 482 /**
462 * Invokes the thread's wakeup callback. 483 * Invokes the thread's wakeup callback.
463 * 484 *
@@ -466,6 +487,8 @@ public:
466 */ 487 */
467 bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 488 bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
468 std::shared_ptr<SynchronizationObject> object, std::size_t index); 489 std::shared_ptr<SynchronizationObject> object, std::size_t index);
490 bool InvokeHLECallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
491 std::shared_ptr<SynchronizationObject> object, std::size_t index);
469 492
470 u32 GetIdealCore() const { 493 u32 GetIdealCore() const {
471 return ideal_core; 494 return ideal_core;
@@ -600,7 +623,8 @@ private:
600 /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread 623 /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread
601 /// was waiting via WaitSynchronization then the object will be the last object that became 624 /// was waiting via WaitSynchronization then the object will be the last object that became
602 /// available. In case of a timeout, the object will be nullptr. 625 /// available. In case of a timeout, the object will be nullptr.
603 WakeupCallback wakeup_callback; 626 WakeupCallback hle_callback;
627 Handle hle_time_event;
604 628
605 Scheduler* scheduler = nullptr; 629 Scheduler* scheduler = nullptr;
606 630