diff options
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.h | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 2 |
5 files changed, 19 insertions, 2 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index a3715e555..87a0dbe37 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -115,8 +115,7 @@ SharedPtr<Object> HandleTable::GetGeneric(Handle handle) const { | |||
| 115 | if (handle == CurrentThread) { | 115 | if (handle == CurrentThread) { |
| 116 | return GetCurrentThread(); | 116 | return GetCurrentThread(); |
| 117 | } else if (handle == CurrentProcess) { | 117 | } else if (handle == CurrentProcess) { |
| 118 | LOG_ERROR(Kernel, "Current process (%08X) pseudo-handle not supported", CurrentProcess); | 118 | return g_current_process; |
| 119 | return nullptr; | ||
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | if (!IsValid(handle)) { | 121 | if (!IsValid(handle)) { |
| @@ -138,6 +137,7 @@ void Init() { | |||
| 138 | Kernel::ThreadingInit(); | 137 | Kernel::ThreadingInit(); |
| 139 | Kernel::TimersInit(); | 138 | Kernel::TimersInit(); |
| 140 | 139 | ||
| 140 | Process::next_process_id = 0; | ||
| 141 | Object::next_object_id = 0; | 141 | Object::next_object_id = 0; |
| 142 | } | 142 | } |
| 143 | 143 | ||
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 26a9c2360..4c940bcba 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
| 15 | u32 Process::next_process_id; | ||
| 16 | |||
| 15 | SharedPtr<Process> Process::Create(std::string name, u64 program_id) { | 17 | SharedPtr<Process> Process::Create(std::string name, u64 program_id) { |
| 16 | SharedPtr<Process> process(new Process); | 18 | SharedPtr<Process> process(new Process); |
| 17 | 19 | ||
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 88ed9a5a5..11c2ad12d 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -55,6 +55,14 @@ public: | |||
| 55 | static const HandleType HANDLE_TYPE = HandleType::Process; | 55 | static const HandleType HANDLE_TYPE = HandleType::Process; |
| 56 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | 56 | HandleType GetHandleType() const override { return HANDLE_TYPE; } |
| 57 | 57 | ||
| 58 | static u32 next_process_id; | ||
| 59 | |||
| 60 | /* | ||
| 61 | * Gets the process' id | ||
| 62 | * @returns The process' id | ||
| 63 | */ | ||
| 64 | u32 GetProcessId() const { return process_id; } | ||
| 65 | |||
| 58 | /// Name of the process | 66 | /// Name of the process |
| 59 | std::string name; | 67 | std::string name; |
| 60 | /// Title ID corresponding to the process | 68 | /// Title ID corresponding to the process |
| @@ -69,6 +77,9 @@ public: | |||
| 69 | boost::container::static_vector<AddressMapping, 8> address_mappings; | 77 | boost::container::static_vector<AddressMapping, 8> address_mappings; |
| 70 | ProcessFlags flags; | 78 | ProcessFlags flags; |
| 71 | 79 | ||
| 80 | /// The id of this process | ||
| 81 | u32 process_id = next_process_id++; | ||
| 82 | |||
| 72 | /** | 83 | /** |
| 73 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them | 84 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them |
| 74 | * to this process. | 85 | * to this process. |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 5de8f9a73..56ded72cd 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "core/core_timing.h" | 17 | #include "core/core_timing.h" |
| 18 | #include "core/hle/hle.h" | 18 | #include "core/hle/hle.h" |
| 19 | #include "core/hle/kernel/kernel.h" | 19 | #include "core/hle/kernel/kernel.h" |
| 20 | #include "core/hle/kernel/process.h" | ||
| 20 | #include "core/hle/kernel/thread.h" | 21 | #include "core/hle/kernel/thread.h" |
| 21 | #include "core/hle/kernel/mutex.h" | 22 | #include "core/hle/kernel/mutex.h" |
| 22 | #include "core/hle/result.h" | 23 | #include "core/hle/result.h" |
| @@ -402,6 +403,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 402 | thread->wait_address = 0; | 403 | thread->wait_address = 0; |
| 403 | thread->name = std::move(name); | 404 | thread->name = std::move(name); |
| 404 | thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); | 405 | thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); |
| 406 | thread->owner_process = g_current_process; | ||
| 405 | 407 | ||
| 406 | VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200; | 408 | VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200; |
| 407 | 409 | ||
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6891c8c2f..c5f4043ca 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -45,6 +45,7 @@ enum ThreadStatus { | |||
| 45 | namespace Kernel { | 45 | namespace Kernel { |
| 46 | 46 | ||
| 47 | class Mutex; | 47 | class Mutex; |
| 48 | class Process; | ||
| 48 | 49 | ||
| 49 | class Thread final : public WaitObject { | 50 | class Thread final : public WaitObject { |
| 50 | public: | 51 | public: |
| @@ -161,6 +162,7 @@ public: | |||
| 161 | /// Mutexes currently held by this thread, which will be released when it exits. | 162 | /// Mutexes currently held by this thread, which will be released when it exits. |
| 162 | boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; | 163 | boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; |
| 163 | 164 | ||
| 165 | SharedPtr<Process> owner_process; ///< Process that owns this thread | ||
| 164 | std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on | 166 | std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on |
| 165 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address | 167 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address |
| 166 | bool wait_all; ///< True if the thread is waiting on all objects before resuming | 168 | bool wait_all; ///< True if the thread is waiting on all objects before resuming |