summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h64
1 files changed, 28 insertions, 36 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index e412e58aa..564e1f27d 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -11,11 +11,11 @@
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"
16#include "core/hle/kernel/mutex.h" 15#include "core/hle/kernel/k_address_arbiter.h"
16#include "core/hle/kernel/k_condition_variable.h"
17#include "core/hle/kernel/k_synchronization_object.h"
17#include "core/hle/kernel/process_capability.h" 18#include "core/hle/kernel/process_capability.h"
18#include "core/hle/kernel/synchronization_object.h"
19#include "core/hle/result.h" 19#include "core/hle/result.h"
20 20
21namespace Core { 21namespace Core {
@@ -63,7 +63,7 @@ enum class ProcessStatus {
63 DebugBreak, 63 DebugBreak,
64}; 64};
65 65
66class Process final : public SynchronizationObject { 66class Process final : public KSynchronizationObject {
67public: 67public:
68 explicit Process(Core::System& system); 68 explicit Process(Core::System& system);
69 ~Process() override; 69 ~Process() override;
@@ -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);
@@ -304,6 +301,8 @@ public:
304 301
305 void LoadModule(CodeSet code_set, VAddr base_addr); 302 void LoadModule(CodeSet code_set, VAddr base_addr);
306 303
304 bool IsSignaled() const override;
305
307 /////////////////////////////////////////////////////////////////////////////////////////////// 306 ///////////////////////////////////////////////////////////////////////////////////////////////
308 // Thread-local storage management 307 // Thread-local storage management
309 308
@@ -314,12 +313,6 @@ public:
314 void FreeTLSRegion(VAddr tls_address); 313 void FreeTLSRegion(VAddr tls_address);
315 314
316private: 315private:
317 /// Checks if the specified thread should wait until this process is available.
318 bool ShouldWait(const Thread* thread) const override;
319
320 /// Acquires/locks this process for the specified thread if it's available.
321 void Acquire(Thread* thread) override;
322
323 /// Changes the process status. If the status is different 316 /// Changes the process status. If the status is different
324 /// from the current process status, then this will trigger 317 /// from the current process status, then this will trigger
325 /// a process signal. 318 /// a process signal.
@@ -373,12 +366,12 @@ private:
373 HandleTable handle_table; 366 HandleTable handle_table;
374 367
375 /// Per-process address arbiter. 368 /// Per-process address arbiter.
376 AddressArbiter address_arbiter; 369 KAddressArbiter address_arbiter;
377 370
378 /// The per-process mutex lock instance used for handling various 371 /// The per-process mutex lock instance used for handling various
379 /// forms of services, such as lock arbitration, and condition 372 /// forms of services, such as lock arbitration, and condition
380 /// variable related facilities. 373 /// variable related facilities.
381 Mutex mutex; 374 KConditionVariable condition_var;
382 375
383 /// Address indicating the location of the process' dedicated TLS region. 376 /// Address indicating the location of the process' dedicated TLS region.
384 VAddr tls_region_address = 0; 377 VAddr tls_region_address = 0;
@@ -389,9 +382,6 @@ private:
389 /// 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.
390 std::list<const Thread*> thread_list; 383 std::list<const Thread*> thread_list;
391 384
392 /// List of threads waiting for a condition variable
393 std::unordered_map<VAddr, std::list<std::shared_ptr<Thread>>> cond_var_threads;
394
395 /// Address of the top of the main thread's stack 385 /// Address of the top of the main thread's stack
396 VAddr main_thread_stack_top{}; 386 VAddr main_thread_stack_top{};
397 387
@@ -410,6 +400,8 @@ private:
410 /// Schedule count of this process 400 /// Schedule count of this process
411 s64 schedule_count{}; 401 s64 schedule_count{};
412 402
403 bool is_signaled{};
404
413 /// System context 405 /// System context
414 Core::System& system; 406 Core::System& system;
415}; 407};