summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
authorGravatar bunnei2020-12-30 01:14:02 -0800
committerGravatar bunnei2021-01-11 14:23:16 -0800
commit912dd501465ffaabd149cc3532839e346982b337 (patch)
tree54f650b18baf040bf9a0555e386989ef2189c223 /src/core/hle/kernel/process.h
parentcore: hle: kernel: Update KAddressArbiter. (diff)
downloadyuzu-912dd501465ffaabd149cc3532839e346982b337.tar.gz
yuzu-912dd501465ffaabd149cc3532839e346982b337.tar.xz
yuzu-912dd501465ffaabd149cc3532839e346982b337.zip
core: hle: Integrate new KConditionVariable and KAddressArbiter implementations.
Diffstat (limited to 'src/core/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 901f1ff27..564e1f27d 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -11,10 +11,10 @@
11#include <unordered_map> 11#include <unordered_map>
12#include <vector> 12#include <vector>
13#include "common/common_types.h" 13#include "common/common_types.h"
14#include "core/hle/kernel/address_arbiter.h"
15#include "core/hle/kernel/handle_table.h" 14#include "core/hle/kernel/handle_table.h"
15#include "core/hle/kernel/k_address_arbiter.h"
16#include "core/hle/kernel/k_condition_variable.h"
16#include "core/hle/kernel/k_synchronization_object.h" 17#include "core/hle/kernel/k_synchronization_object.h"
17#include "core/hle/kernel/mutex.h"
18#include "core/hle/kernel/process_capability.h" 18#include "core/hle/kernel/process_capability.h"
19#include "core/hle/result.h" 19#include "core/hle/result.h"
20 20
@@ -123,24 +123,30 @@ public:
123 return handle_table; 123 return handle_table;
124 } 124 }
125 125
126 /// Gets a reference to the process' address arbiter. 126 ResultCode SignalToAddress(VAddr address) {
127 AddressArbiter& GetAddressArbiter() { 127 return condition_var.SignalToAddress(address);
128 return address_arbiter;
129 } 128 }
130 129
131 /// Gets a const reference to the process' address arbiter. 130 ResultCode WaitForAddress(Handle handle, VAddr address, u32 tag) {
132 const AddressArbiter& GetAddressArbiter() const { 131 return condition_var.WaitForAddress(handle, address, tag);
133 return address_arbiter;
134 } 132 }
135 133
136 /// Gets a reference to the process' mutex lock. 134 void SignalConditionVariable(u64 cv_key, int32_t count) {
137 Mutex& GetMutex() { 135 return condition_var.Signal(cv_key, count);
138 return mutex;
139 } 136 }
140 137
141 /// Gets a const reference to the process' mutex lock 138 ResultCode WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) {
142 const Mutex& GetMutex() const { 139 return condition_var.Wait(address, cv_key, tag, ns);
143 return mutex; 140 }
141
142 ResultCode SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value,
143 s32 count) {
144 return address_arbiter.SignalToAddress(address, signal_type, value, count);
145 }
146
147 ResultCode WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value,
148 s64 timeout) {
149 return address_arbiter.WaitForAddress(address, arb_type, value, timeout);
144 } 150 }
145 151
146 /// Gets the address to the process' dedicated TLS region. 152 /// Gets the address to the process' dedicated TLS region.
@@ -250,15 +256,6 @@ public:
250 return thread_list; 256 return thread_list;
251 } 257 }
252 258
253 /// Insert a thread into the condition variable wait container
254 void InsertConditionVariableThread(std::shared_ptr<Thread> thread);
255
256 /// Remove a thread from the condition variable wait container
257 void RemoveConditionVariableThread(std::shared_ptr<Thread> thread);
258
259 /// Obtain all condition variable threads waiting for some address
260 std::vector<std::shared_ptr<Thread>> GetConditionVariableThreads(VAddr cond_var_addr);
261
262 /// Registers a thread as being created under this process, 259 /// Registers a thread as being created under this process,
263 /// adding it to this process' thread list. 260 /// adding it to this process' thread list.
264 void RegisterThread(const Thread* thread); 261 void RegisterThread(const Thread* thread);
@@ -369,12 +366,12 @@ private:
369 HandleTable handle_table; 366 HandleTable handle_table;
370 367
371 /// Per-process address arbiter. 368 /// Per-process address arbiter.
372 AddressArbiter address_arbiter; 369 KAddressArbiter address_arbiter;
373 370
374 /// The per-process mutex lock instance used for handling various 371 /// The per-process mutex lock instance used for handling various
375 /// forms of services, such as lock arbitration, and condition 372 /// forms of services, such as lock arbitration, and condition
376 /// variable related facilities. 373 /// variable related facilities.
377 Mutex mutex; 374 KConditionVariable condition_var;
378 375
379 /// Address indicating the location of the process' dedicated TLS region. 376 /// Address indicating the location of the process' dedicated TLS region.
380 VAddr tls_region_address = 0; 377 VAddr tls_region_address = 0;
@@ -385,9 +382,6 @@ private:
385 /// List of threads that are running with this process as their owner. 382 /// List of threads that are running with this process as their owner.
386 std::list<const Thread*> thread_list; 383 std::list<const Thread*> thread_list;
387 384
388 /// List of threads waiting for a condition variable
389 std::unordered_map<VAddr, std::list<std::shared_ptr<Thread>>> cond_var_threads;
390
391 /// Address of the top of the main thread's stack 385 /// Address of the top of the main thread's stack
392 VAddr main_thread_stack_top{}; 386 VAddr main_thread_stack_top{};
393 387