diff options
| author | 2015-05-11 09:15:10 -0500 | |
|---|---|---|
| committer | 2015-05-11 09:15:10 -0500 | |
| commit | 41f74a16fd55934f747f6f7e1f7a6d4d6a3d4e57 (patch) | |
| tree | b9500ee328f5b918edca38251878c4f346a30807 /src | |
| parent | Merge pull request #740 from yuriks/gsp-shmem (diff) | |
| download | yuzu-41f74a16fd55934f747f6f7e1f7a6d4d6a3d4e57.tar.gz yuzu-41f74a16fd55934f747f6f7e1f7a6d4d6a3d4e57.tar.xz yuzu-41f74a16fd55934f747f6f7e1f7a6d4d6a3d4e57.zip | |
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
Diffstat (limited to 'src')
| -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 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 33 |
6 files changed, 50 insertions, 4 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 |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 1ec6599c7..b5cf554c3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "core/hle/kernel/address_arbiter.h" | 16 | #include "core/hle/kernel/address_arbiter.h" |
| 17 | #include "core/hle/kernel/event.h" | 17 | #include "core/hle/kernel/event.h" |
| 18 | #include "core/hle/kernel/mutex.h" | 18 | #include "core/hle/kernel/mutex.h" |
| 19 | #include "core/hle/kernel/process.h" | ||
| 19 | #include "core/hle/kernel/semaphore.h" | 20 | #include "core/hle/kernel/semaphore.h" |
| 20 | #include "core/hle/kernel/shared_memory.h" | 21 | #include "core/hle/kernel/shared_memory.h" |
| 21 | #include "core/hle/kernel/thread.h" | 22 | #include "core/hle/kernel/thread.h" |
| @@ -424,6 +425,34 @@ static ResultCode ReleaseMutex(Handle handle) { | |||
| 424 | return RESULT_SUCCESS; | 425 | return RESULT_SUCCESS; |
| 425 | } | 426 | } |
| 426 | 427 | ||
| 428 | /// Get the ID of the specified process | ||
| 429 | static ResultCode GetProcessId(u32* process_id, Handle handle) { | ||
| 430 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", handle); | ||
| 431 | |||
| 432 | const SharedPtr<Kernel::Process> process = Kernel::g_handle_table.Get<Kernel::Process>(handle); | ||
| 433 | if (process == nullptr) | ||
| 434 | return ERR_INVALID_HANDLE; | ||
| 435 | |||
| 436 | *process_id = process->GetProcessId(); | ||
| 437 | return RESULT_SUCCESS; | ||
| 438 | } | ||
| 439 | |||
| 440 | /// Get the ID of the process that owns the specified thread | ||
| 441 | static ResultCode GetProcessIdOfThread(u32* process_id, Handle handle) { | ||
| 442 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); | ||
| 443 | |||
| 444 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | ||
| 445 | if (thread == nullptr) | ||
| 446 | return ERR_INVALID_HANDLE; | ||
| 447 | |||
| 448 | const SharedPtr<Kernel::Process> process = thread->owner_process; | ||
| 449 | if (process == nullptr) | ||
| 450 | return ERR_INVALID_HANDLE; | ||
| 451 | |||
| 452 | *process_id = process->process_id; | ||
| 453 | return RESULT_SUCCESS; | ||
| 454 | } | ||
| 455 | |||
| 427 | /// Get the ID for the specified thread. | 456 | /// Get the ID for the specified thread. |
| 428 | static ResultCode GetThreadId(u32* thread_id, Handle handle) { | 457 | static ResultCode GetThreadId(u32* thread_id, Handle handle) { |
| 429 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); | 458 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); |
| @@ -674,8 +703,8 @@ static const FunctionDef SVC_Table[] = { | |||
| 674 | {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"}, | 703 | {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"}, |
| 675 | {0x33, nullptr, "OpenProcess"}, | 704 | {0x33, nullptr, "OpenProcess"}, |
| 676 | {0x34, nullptr, "OpenThread"}, | 705 | {0x34, nullptr, "OpenThread"}, |
| 677 | {0x35, nullptr, "GetProcessId"}, | 706 | {0x35, HLE::Wrap<GetProcessId>, "GetProcessId"}, |
| 678 | {0x36, nullptr, "GetProcessIdOfThread"}, | 707 | {0x36, HLE::Wrap<GetProcessIdOfThread>, "GetProcessIdOfThread"}, |
| 679 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, | 708 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, |
| 680 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, | 709 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, |
| 681 | {0x39, nullptr, "GetResourceLimitLimitValues"}, | 710 | {0x39, nullptr, "GetResourceLimitLimitValues"}, |