summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-05-12 02:44:26 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-05-12 02:44:26 +0200
commit820b97787c9bdfaed018558f33b8d3542e6d6b1f (patch)
treef2050259d4a9584aa3000335e91b7fc210ec1947 /src/core/hle/kernel
parentMerge pull request #754 from purpasmart96/nwm_typo_fix (diff)
parentfixup! (diff)
downloadyuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.gz
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.bz2
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.lz
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.xz
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.zst
yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/kernel.cpp6
-rw-r--r--src/core/hle/kernel/process.cpp2
-rw-r--r--src/core/hle/kernel/process.h5
-rw-r--r--src/core/hle/kernel/thread.cpp2
-rw-r--r--src/core/hle/kernel/thread.h2
5 files changed, 15 insertions, 2 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index a3715e555..b5c98b249 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 {
if (handle == CurrentThread) {
return GetCurrentThread();
} else if (handle == CurrentProcess) {
- LOG_ERROR(Kernel, "Current process (%08X) pseudo-handle not supported", CurrentProcess);
- return nullptr;
+ return g_current_process;
}
if (!IsValid(handle)) {
@@ -139,6 +138,9 @@ void Init() {
Kernel::TimersInit();
Object::next_object_id = 0;
+ // TODO(Subv): Start the process ids from 10 for now, as lower PIDs are
+ // reserved for low-level services
+ Process::next_process_id = 10;
}
/// Shutdown the kernel
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index efae4a179..1e439db9e 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -12,6 +12,8 @@
namespace Kernel {
+u32 Process::next_process_id;
+
SharedPtr<Process> Process::Create(std::string name, u64 program_id) {
SharedPtr<Process> process(new Process);
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 88ed9a5a5..22cd1049b 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -55,6 +55,8 @@ public:
static const HandleType HANDLE_TYPE = HandleType::Process;
HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ static u32 next_process_id;
+
/// Name of the process
std::string name;
/// Title ID corresponding to the process
@@ -69,6 +71,9 @@ public:
boost::container::static_vector<AddressMapping, 8> address_mappings;
ProcessFlags flags;
+ /// The id of this process
+ u32 process_id = next_process_id++;
+
/**
* Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them
* to this process.
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 957cbdfee..ab69a4262 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -17,6 +17,7 @@
#include "core/core_timing.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h"
+#include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/result.h"
@@ -402,6 +403,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
thread->wait_address = 0;
thread->name = std::move(name);
thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom();
+ thread->owner_process = g_current_process;
VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200;
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index afdaf8511..1d4d010fe 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -45,6 +45,7 @@ enum ThreadStatus {
namespace Kernel {
class Mutex;
+class Process;
class Thread final : public WaitObject {
public:
@@ -161,6 +162,7 @@ public:
/// Mutexes currently held by this thread, which will be released when it exits.
boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
+ SharedPtr<Process> owner_process; ///< Process that owns this thread
std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
bool wait_all; ///< True if the thread is waiting on all objects before resuming